LCOV - code coverage report
Current view: top level - lib_com - ivas_agc_com_fx.c (source / functions) Hit Total Coverage
Test: Coverage on main enc/dec/rend @ 3b2f07138c61dcf997bbf4165d0882f794b2995f Lines: 28 31 90.3 %
Date: 2025-05-03 01:55:50 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /******************************************************************************************************
       2             : 
       3             :    (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
       4             :    Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
       5             :    Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
       6             :    Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
       7             :    contributors to this repository. All Rights Reserved.
       8             : 
       9             :    This software is protected by copyright law and by international treaties.
      10             :    The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
      11             :    Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
      12             :    Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
      13             :    Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
      14             :    contributors to this repository retain full ownership rights in their respective contributions in
      15             :    the software. This notice grants no license of any kind, including but not limited to patent
      16             :    license, nor is any license granted by implication, estoppel or otherwise.
      17             : 
      18             :    Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
      19             :    contributions.
      20             : 
      21             :    This software is provided "AS IS", without any express or implied warranties. The software is in the
      22             :    development stage. It is intended exclusively for experts who have experience with such software and
      23             :    solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
      24             :    and fitness for a particular purpose are hereby disclaimed and excluded.
      25             : 
      26             :    Any dispute, controversy or claim arising under or in relation to providing this software shall be
      27             :    submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
      28             :    accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
      29             :    the United Nations Convention on Contracts on the International Sales of Goods.
      30             : 
      31             : *******************************************************************************************************/
      32             : 
      33             : #include <stdint.h>
      34             : #include "options.h"
      35             : #include "cnst.h"
      36             : #include "ivas_cnst.h"
      37             : #include "ivas_prot_fx.h"
      38             : #include <math.h>
      39             : #include "wmc_auto.h"
      40             : #include "prot_fx.h"
      41             : #include "rom_com.h"
      42             : /*------------------------------------------------------------------------------------------*
      43             :  * Local constants
      44             :  *------------------------------------------------------------------------------------------*/
      45             : 
      46             : #define ABS_EMIN_MAX          ( 3 )
      47             : #define MAXATTEXP             ( 1 )    /* the desired maximum attenuation exponent range per frame*/
      48             : #define LOG2_NUMCOEFF_SQRKMAX ( 3 )    /* ceilf(logf(ceilf(SQRKMAX * numCoeffs)) * INV_LOG_2) in Q0 */
      49             : #define LOG2_4                ( 2 )    /* ceilf(logf(totExp) * INV_LOG_2)in Q0 */
      50             : #define A_FX                  ( 8172 ) /* 0.5f * ( 1.f - powf( 10.f, DBSTEP / 20.f ) ) in Q15 */
      51             : 
      52             : /*-----------------------------------------------------------------------------------------*
      53             :  * Function ivas_agc_initWindowFunc()
      54             :  *
      55             :  * Get a window function
      56             :  *-----------------------------------------------------------------------------------------*/
      57             : 
      58        2016 : void ivas_agc_initWindowFunc_fx(
      59             :     Word16 *pWinFunc, // o: Q15
      60             :     const Word16 length )
      61             : {
      62             :     Word16 i;
      63             :     Word16 a;
      64             :     const Word16 *cos_val;
      65             : 
      66        2016 :     a = A_FX; /* for DBSTEP -6.f */ // Q15
      67        2016 :     move16();
      68             : 
      69        2016 :     SWITCH( length )
      70             :     {
      71          57 :         case 128:
      72          57 :             cos_val = cos_pi_by_127; // Q15
      73          57 :             BREAK;
      74         589 :         case 256:
      75         589 :             cos_val = cos_pi_by_255; // Q15
      76         589 :             BREAK;
      77        1370 :         case 384:
      78        1370 :             cos_val = cos_pi_by_383; // Q15
      79        1370 :             BREAK;
      80           0 :         default:
      81           0 :             cos_val = cos_pi_by_383; // Q15
      82           0 :             BREAK;
      83             :     }
      84             : 
      85      686176 :     FOR( i = 0; i < length; i++ )
      86             :     {
      87      684160 :         pWinFunc[i] = add( MAX_16, extract_l( Mpy_32_16_1( L_sub( cos_val[i], MAX_16 ), a ) ) ); // Q15 + Q15 - 15 = Q15
      88      684160 :         move16();
      89             :     }
      90             : 
      91        2016 :     return;
      92             : }
      93             : 
      94             : /*-----------------------------------------------------------------------------------------*
      95             :  * Function ivas_agc_calcGainParams_fx()
      96             :  *
      97             :  * Calculate gain parameters
      98             :  *-----------------------------------------------------------------------------------------*/
      99             : 
     100        2016 : void ivas_agc_calcGainParams_fx(
     101             :     UWord16 *absEmin,   // o: Q0
     102             :     UWord16 *betaE,     // o: Q0
     103             :     UWord16 *maxAttExp, // o: Q0
     104             :     const Word16 numCoeffs )
     105             : {
     106        2016 :     assert( numCoeffs == IVAS_SPAR_MAX_DMX_CHS );
     107        2016 :     *absEmin = s_max( ABS_EMIN_MAX, LOG2_NUMCOEFF_SQRKMAX );
     108        2016 :     move16();
     109        2016 :     *betaE = (UWord16) LOG2_4;
     110        2016 :     move16();
     111        2016 :     *maxAttExp = sub( shl( 2, 1 ), 2 );
     112        2016 :     *maxAttExp = s_min( MAXATTEXP, *maxAttExp );
     113        2016 :     move16();
     114        2016 :     move16();
     115             : 
     116        2016 :     return;
     117             : }

Generated by: LCOV version 1.14