LCOV - code coverage report
Current view: top level - lib_com - deemph.c (source / functions) Hit Total Coverage
Test: Coverage on main enc/dec/rend @ 3b2f07138c61dcf997bbf4165d0882f794b2995f Lines: 54 54 100.0 %
Date: 2025-05-03 01:55:50 Functions: 4 4 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             : /*====================================================================================
      34             :     EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
      35             :   ====================================================================================*/
      36             : 
      37             : #include <stdint.h>
      38             : #include "options.h"
      39             : #include "prot_fx.h"
      40             : #include "wmc_auto.h"
      41             : 
      42             : 
      43       36496 : void deemph_fx_32(
      44             :     Word32 *signal,  /* i/o: signal            Qx*/
      45             :     const Word16 mu, /* i  : deemphasis factor Q15*/
      46             :     const Word16 L,  /* i  : vector size         */
      47             :     Word32 *mem      /* i/o: memory (y[-1])    Qx*/
      48             : )
      49             : {
      50             :     Word16 i;
      51             : 
      52       36496 :     signal[0] = Madd_32_16( signal[0], *mem, mu ); // Qx
      53       36496 :     move32();
      54    14237440 :     FOR( i = 1; i < L; i++ )
      55             :     {
      56    14200944 :         signal[i] = Madd_32_16( signal[i], signal[i - 1], mu ); // Qx
      57    14200944 :         move32();
      58             :     }
      59             : 
      60       36496 :     *mem = signal[L - 1]; // Qx
      61       36496 :     move32();
      62             : 
      63       36496 :     return;
      64             : }
      65             : 
      66             : 
      67             : /*========================================================================*/
      68             : /* FUNCTION : deemph_fx()                                                                                                 */
      69             : /*------------------------------------------------------------------------*/
      70             : /* PURPOSE : Deemphasis: filtering through 1/(1-mu z^-1)                                  */
      71             : /*------------------------------------------------------------------------*/
      72             : /* INPUT ARGUMENTS :                                                                                                      */
      73             : /* _ (Word16) mu  : deemphasis factor   Q15                                                               */
      74             : /* _ (Word16) L   : vector size                                                                           */
      75             : /*------------------------------------------------------------------------*/
      76             : /* INPUT/OUTPUT ARGUMENTS :                                                                                               */
      77             : /* _ (Word16*) signal     : signal              Q_syn2-1                              */
      78             : /* _ (Word16*) mem        : memory (y[-1])          Q_syn2-1                              */
      79             : /*------------------------------------------------------------------------*/
      80             : /* OUTPUT ARGUMENTS :                                                                                                     */
      81             : /*------------------------------------------------------------------------*/
      82             : 
      83             : /*------------------------------------------------------------------------*/
      84             : /* RETURN ARGUMENTS :                                                                                                     */
      85             : /* _ None                                                                                                                                 */
      86             : /*========================================================================*/
      87     5193862 : void deemph_fx(
      88             :     Word16 *signal,  /* i/o: signal                             Qx  */
      89             :     const Word16 mu, /* i  : deemphasis factor   Q15 */
      90             :     const Word16 L,  /* i  : vector size         Q0  */
      91             :     Word16 *mem      /* i/o: memory (y[-1])      Qx  */
      92             : )
      93             : {
      94             :     Word16 i;
      95             :     Word32 L_tmp;
      96             : #ifdef BASOP_NOGLOB_DECLARE_LOCAL
      97             :     Flag Overflow;
      98     5193862 :     Overflow = 0;
      99     5193862 :     move32();
     100             : #endif
     101             : 
     102     5193862 :     L_tmp = L_deposit_h( signal[0] );              /*Qx+16*/
     103     5193862 :     L_tmp = L_mac_o( L_tmp, *mem, mu, &Overflow ); /*Qx+16*/
     104     5193862 :     signal[0] = round_fx_o( L_tmp, &Overflow );    /*Qx*/
     105     5193862 :     move16();
     106             : 
     107   889842488 :     FOR( i = 1; i < L; i++ )
     108             :     {
     109   884648626 :         L_tmp = L_deposit_h( signal[i] );                       /*Qx+16*/
     110   884648626 :         L_tmp = L_mac_o( L_tmp, signal[i - 1], mu, &Overflow ); /*Qx+16*/
     111   884648626 :         signal[i] = round_fx_o( L_tmp, &Overflow );             /*Qx*/
     112   884648626 :         move16();
     113             :     }
     114             : 
     115     5193862 :     *mem = signal[L - 1]; /*Qx*/
     116     5193862 :     move16();
     117     5193862 : }
     118             : 
     119             : /*-------------------------------------------------------------------*
     120             :  * Deeemph2 :
     121             :  *
     122             :  * Deemphasis: filtering through 1/(1-mu z^-1)
     123             :  * Output divided by 2
     124             :  *-------------------------------------------------------------------*/
     125      716082 : void Deemph2(
     126             :     Word16 x[],      /* i/o: input signal overwritten by the output   Qx/Qx-1 */
     127             :     const Word16 mu, /* i  : deemphasis factor                        Q15     */
     128             :     const Word16 L,  /* i  : vector size                              Q0      */
     129             :     Word16 *mem      /* i/o: memory (y[-1])                           Qx-1    */
     130             : )
     131             : {
     132             :     Word16 i;
     133             :     Word32 L_tmp;
     134             : #ifdef BASOP_NOGLOB_DECLARE_LOCAL
     135             :     Flag Overflow;
     136      716082 :     Overflow = 0;
     137      716082 :     move32();
     138             : #endif
     139             :     /* saturation can occur in L_mac() */
     140             : 
     141      716082 :     L_tmp = L_mult( x[0], 16384 /*0.5f in Q15*/ ); /*Qx+16*/
     142      716082 :     x[0] = mac_r( L_tmp, *mem, mu );               /*Qx-1*/
     143      716082 :     move16();
     144             : 
     145    48017536 :     FOR( i = 1; i < L; i++ )
     146             :     {
     147    47301454 :         L_tmp = L_mult( x[i], 16384 /*0.5f in Q15*/ );   /*Qx+16*/
     148    47301454 :         x[i] = mac_ro( L_tmp, x[i - 1], mu, &Overflow ); /*Qx-1*/
     149    47301454 :         move16();
     150             :     }
     151             : 
     152      716082 :     *mem = x[L - 1]; /*Qx-1*/
     153      716082 :     move16();
     154      716082 : }
     155             : 
     156             : 
     157             : /*
     158             :  * E_UTIL_deemph2
     159             :  *
     160             :  * Parameters:
     161             :  *    shift          I: scale output
     162             :  *    x              I/O: signal                                  Qx/Qx-shift
     163             :  *    mu             I: deemphasis factor         Qx
     164             :  *    L              I: vector size
     165             :  *    mem            I/O: memory (signal[-1])   Qx
     166             :  *
     167             :  * Function:
     168             :  *    Filtering through 1/(1-mu z^-1)
     169             :  *    Signal is divided by 2.
     170             :  *
     171             :  * Returns:
     172             :  *    void
     173             :  */
     174        2641 : void E_UTIL_deemph2( Word16 shift, Word16 *x, const Word16 mu, const Word16 L, Word16 *mem )
     175             : {
     176             :     Word16 i;
     177             :     Word32 L_tmp;
     178             : #ifdef BASOP_NOGLOB_DECLARE_LOCAL
     179             :     Flag Overflow;
     180        2641 :     Overflow = 0;
     181        2641 :     move32();
     182             : #endif
     183             : 
     184             :     /* signal[0] = signal[0] + mu * (*mem); */
     185        2641 :     L_tmp = L_deposit_h( *mem ); /*Qx+16*/
     186        2641 :     IF( shift >= 0 )
     187             :     {
     188        2343 :         shift = shr( -32768, shift ); /*Q15 - shift*/
     189      703911 :         FOR( i = 0; i < L; i++ )
     190             :         {
     191      701568 :             L_tmp = L_msu_o( Mpy_32_16_1( L_tmp, mu ), x[i], shift, &Overflow ); /*Qx-shift+16*/
     192      701568 :             x[i] = round_fx_o( L_tmp, &Overflow );                               /*Qx-shift*/
     193      701568 :             move16();
     194             :         }
     195             :     }
     196             :     ELSE
     197             :     {
     198       95658 :         FOR( i = 0; i < L; i++ )
     199             :         {
     200       95360 :             L_tmp = L_msu_o( Mpy_32_16_1( L_tmp, mu ), shr_o( x[i], shift, &Overflow ), -32768 /*1.0f in Q15*/, &Overflow ); /*Qx-shift+16*/
     201       95360 :             x[i] = round_fx_o( L_tmp, &Overflow );                                                                           /*Qx-shift*/
     202       95360 :             move16();
     203             :         }
     204             :     }
     205             : 
     206        2641 :     *mem = x[L - 1]; /*Qx-shift*/
     207        2641 :     move16();
     208             : 
     209        2641 :     return;
     210             : }

Generated by: LCOV version 1.14