LCOV - code coverage report
Current view: top level - lib_dec - inov_dec_fx.c (source / functions) Hit Total Coverage
Test: Coverage on main enc/dec/rend @ 3b2f07138c61dcf997bbf4165d0882f794b2995f Lines: 46 126 36.5 %
Date: 2025-05-03 01:55:50 Functions: 1 2 50.0 %

          Line data    Source code
       1             : /*====================================================================================
       2             :     EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
       3             :   ====================================================================================*/
       4             : 
       5             : #include <stdint.h>
       6             : #include "options.h" /* Compilation switches                   */
       7             : #include "cnst.h"    /* Common constants                       */
       8             : #include "prot_fx.h" /* Function prototypes                    */
       9             : #include "rom_com.h" /* Static table prototypes                */
      10             : /*======================================================================*/
      11             : /* FUNCTION : inov_decode_fx() */
      12             : /*-----------------------------------------------------------------------*/
      13             : /* PURPOSE :  Decode the algebraic innovation and do pitch sharpening    */
      14             : /*                                                                       */
      15             : /*-----------------------------------------------------------------------*/
      16             : /*  INPUT ARGUMENTS :                                                                                                    */
      17             : /* _ (Word32) core_brate : Core bitrate Q0                               */
      18             : /* _ (Word16) Opt_AMR_WB : flag indicating AMR-WB IO mode  Q0            */
      19             : /* _ (Word16) L_frame : length of the frame  Q0                          */
      20             : /* _ (Word16) i_subfr : length of the frame  Q0                          */
      21             : /* _ (Word16) coder_type :  coding type                                  */
      22             : /* _ (Word16) L_subfr : subframe length                                  */
      23             : /* _ (Word16) sharpFlag :  formant sharpening flag                       */
      24             : /* _ (Word16) tc_subfr : TC subframe index                               */
      25             : /* _ (Word16 *) p_Aq : LP filter coefficients Q12                        */
      26             : /* _ (Word16) tilt_code : tilt of the excitation of previous subframe Q15*/
      27             : /* _ (Word16) pt_pitch :   current subframe fractional pitch Q6          */
      28             : /*-----------------------------------------------------------------------*/
      29             : /* OUTPUT ARGUMENTS :                                                    */
      30             : /* _ (Word16 *[]) code : subframe length Q12                             */
      31             : /* _ (Word16 []) index_buf_4T : subframe length                          */
      32             : /*-----------------------------------------------------------------------*/
      33             : /* INPUT OUTPUT ARGUMENTS                                                */
      34             : /*-----------------------------------------------------------------------*/
      35             : 
      36             : /*-----------------------------------------------------------------------*/
      37             : /* RETURN ARGUMENTS :                                                    */
      38             : /* _ None                                                                */
      39             : /*=======================================================================*/
      40             : 
      41      548989 : void inov_decode_fx(
      42             :     Decoder_State *st_fx,    /* i/o: decoder state structure */
      43             :     const Word32 core_brate, /* i  : core bitrate Q0                                */
      44             :     const Word16 Opt_AMR_WB, /* i  : flag indicating AMR-WB IO mode Q0              */
      45             :     const Word16 L_frame,    /* i  : length of the frame Q0                         */
      46             :     const Word16 sharpFlag,  /* i  : formant sharpening flag Q0                     */
      47             :     const Word16 i_subfr,    /* i  : subframe index Q0                              */
      48             :     const Word16 *p_Aq,      /* i  : LP filter coefficients Q12                  */
      49             :     const Word16 tilt_code,  /* i  : tilt of the excitation of previous subframe Q15 */
      50             :     const Word16 pt_pitch,   /* i  : pointer to current subframe fractional pitch Q6*/
      51             :     Word16 *code,            /* o  : algebraic excitation Q12                        */
      52             :     const Word16 L_subfr     /* i  : subframe length Q0                             */
      53             : )
      54             : {
      55             :     Word16 nBits;
      56             :     Word16 g1, g2;
      57             : 
      58      548989 :     IF( EQ_16( L_frame, L_FRAME ) )
      59             :     {
      60      227585 :         g1 = FORMANT_SHARPENING_G1;
      61      227585 :         move16();
      62      227585 :         g2 = FORMANT_SHARPENING_G2;
      63      227585 :         move16();
      64             :     }
      65             :     ELSE
      66             :     {
      67      321404 :         g1 = FORMANT_SHARPENING_G1_16k;
      68      321404 :         move16();
      69      321404 :         g2 = FORMANT_SHARPENING_G2_16k;
      70      321404 :         move16();
      71             :     }
      72             : 
      73      548989 :     IF( !Opt_AMR_WB )
      74             :     {
      75      548989 :         IF( st_fx->acelp_cfg.fcb_mode )
      76             :         {
      77             :             Word16 i;
      78             :             Word16 indexing_indices[8], wordcnt, bitcnt;
      79             :             PulseConfig config;
      80      482678 :             test();
      81      482678 :             test();
      82      482678 :             test();
      83      482678 :             IF( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_subfr] >= 0 )
      84             :             {
      85      482642 :                 IF( EQ_16( L_subfr, 2 * L_SUBFR ) )
      86             :                 {
      87        3644 :                     nBits = st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_subfr]; // Q0
      88        3644 :                     move16();
      89             : 
      90        3644 :                     IF( EQ_16( nBits, 8 ) )
      91             :                     {
      92           0 :                         dec_acelp_1t64_fx( st_fx, code, L_subfr );
      93             :                     }
      94             :                     ELSE
      95             :                     {
      96        3644 :                         dec_acelp_fast_fx( st_fx, nBits, code, L_subfr );
      97             :                     }
      98             :                 }
      99      478998 :                 ELSE IF( ( EQ_16( st_fx->idchan, 1 ) && LE_16( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], 7 ) ) || ( ( st_fx->idchan == 0 ) && LE_16( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], 3 ) ) )
     100             :                 {
     101       22468 :                     IF( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] == 0 )
     102             :                     {
     103         367 :                         dec_acelp_1t64_fx( st_fx, code, L_SUBFR );
     104             :                     }
     105             :                     ELSE
     106             :                     {
     107       22101 :                         dec_acelp_fast_fx( st_fx, st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], code, L_SUBFR );
     108             :                     }
     109             :                 }
     110             :                 ELSE
     111             :                 {
     112      456530 :                     wordcnt = shr( ACELP_FIXED_CDK_BITS( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] ), 4 ); // Q0
     113      456530 :                     move16();
     114      456530 :                     bitcnt = s_and( ACELP_FIXED_CDK_BITS( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] ), 15 ); // Q0
     115      456530 :                     move16();
     116             : 
     117     1509098 :                     FOR( i = 0; i < wordcnt; i++ )
     118             :                     {
     119     1052568 :                         indexing_indices[i] = extract_l( get_next_indice_fx( st_fx, 16 ) ); // Q0
     120     1052568 :                         move16();
     121             :                     }
     122      456530 :                     IF( bitcnt )
     123             :                     {
     124      425180 :                         indexing_indices[i] = extract_l( get_next_indice_fx( st_fx, bitcnt ) ); // Q0
     125      425180 :                         move16();
     126             :                     }
     127      456530 :                     config = PulseConfTable[st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR]];
     128      456530 :                     D_ACELP_indexing_fx( code, config, NB_TRACK_FCB_4T, indexing_indices, &st_fx->BER_detect );
     129             :                 }
     130             :             }
     131             :             ELSE
     132             :             {
     133          36 :                 set16_fx( code, 0, L_SUBFR );
     134             :             }
     135             :         }
     136             :         ELSE
     137             :         {
     138       66311 :             nBits = st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR]; // Q0
     139       66311 :             move16();
     140             : 
     141       66311 :             IF( EQ_16( nBits, 7 ) )
     142             :             {
     143           0 :                 dec_acelp_1t64_fx( st_fx, code, L_SUBFR );
     144             :             }
     145       66311 :             ELSE IF( EQ_16( nBits, 12 ) )
     146             :             {
     147       11110 :                 dec_acelp_2t32_fx( st_fx, code );
     148             :             }
     149             :             ELSE
     150             :             {
     151       55201 :                 dec_acelp_4t64_fx( st_fx, nBits, code, Opt_AMR_WB );
     152             :             }
     153             :         }
     154             :     }
     155             :     ELSE
     156             :     {
     157           0 :         IF( EQ_32( core_brate, ACELP_6k60 ) )
     158             :         {
     159           0 :             dec_acelp_2t32_fx( st_fx, code );
     160             :         }
     161           0 :         ELSE IF( EQ_32( core_brate, ACELP_8k85 ) )
     162             :         {
     163           0 :             dec_acelp_4t64_fx( st_fx, 20, code, Opt_AMR_WB );
     164             :         }
     165           0 :         ELSE IF( EQ_32( core_brate, ACELP_12k65 ) )
     166             :         {
     167           0 :             dec_acelp_4t64_fx( st_fx, 36, code, Opt_AMR_WB );
     168             :         }
     169           0 :         ELSE IF( EQ_32( core_brate, ACELP_14k25 ) )
     170             :         {
     171           0 :             dec_acelp_4t64_fx( st_fx, 44, code, Opt_AMR_WB );
     172             :         }
     173           0 :         ELSE IF( EQ_32( core_brate, ACELP_15k85 ) )
     174             :         {
     175           0 :             dec_acelp_4t64_fx( st_fx, 52, code, Opt_AMR_WB );
     176             :         }
     177           0 :         ELSE IF( EQ_32( core_brate, ACELP_18k25 ) )
     178             :         {
     179           0 :             dec_acelp_4t64_fx( st_fx, 64, code, Opt_AMR_WB );
     180             :         }
     181           0 :         ELSE IF( EQ_32( core_brate, ACELP_19k85 ) )
     182             :         {
     183           0 :             dec_acelp_4t64_fx( st_fx, 72, code, Opt_AMR_WB );
     184             :         }
     185             :         ELSE
     186             :         {
     187           0 :             dec_acelp_4t64_fx( st_fx, 88, code, Opt_AMR_WB );
     188             :         }
     189             :     }
     190             : 
     191      548989 :     cb_shape_fx( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, code, tilt_code, shr( add( pt_pitch, 26 ), 6 ), 0, L_subfr );
     192      548989 :     return;
     193             : }
     194             : 
     195             : /*======================================================================*/
     196             : /* FUNCTION : inov_decode_ivas_fx() */
     197             : /*-----------------------------------------------------------------------*/
     198             : /* PURPOSE :  Decode the algebraic innovation and do pitch sharpening    */
     199             : /*                                                                       */
     200             : /*-----------------------------------------------------------------------*/
     201             : /*  INPUT ARGUMENTS :                                                                                                    */
     202             : /* _ (Word32) core_brate : Core bitrate Q0                               */
     203             : /* _ (Word16) Opt_AMR_WB : flag indicating AMR-WB IO mode  Q0            */
     204             : /* _ (Word16) L_frame : length of the frame  Q0                          */
     205             : /* _ (Word16) i_subfr : length of the frame  Q0                          */
     206             : /* _ (Word16) coder_type :  coding type                                  */
     207             : /* _ (Word16) L_subfr : subframe length                                  */
     208             : /* _ (Word16) sharpFlag :  formant sharpening flag                       */
     209             : /* _ (Word16) tc_subfr : TC subframe index                               */
     210             : /* _ (Word16 *) p_Aq : LP filter coefficients Q12                        */
     211             : /* _ (Word16) tilt_code : tilt of the excitation of previous subframe Q15*/
     212             : /* _ (Word16) pt_pitch :   current subframe fractional pitch Q6          */
     213             : /*-----------------------------------------------------------------------*/
     214             : /* OUTPUT ARGUMENTS :                                                    */
     215             : /* _ (Word16 *[]) code : subframe length Q12                             */
     216             : /* _ (Word16 []) index_buf_4T : subframe length                          */
     217             : /*-----------------------------------------------------------------------*/
     218             : /* INPUT OUTPUT ARGUMENTS                                                */
     219             : /*-----------------------------------------------------------------------*/
     220             : 
     221             : /*-----------------------------------------------------------------------*/
     222             : /* RETURN ARGUMENTS :                                                    */
     223             : /* _ None                                                                */
     224             : /*=======================================================================*/
     225             : 
     226           0 : void inov_decode_ivas_fx(
     227             :     Decoder_State *st_fx,    /* i/o: decoder state structure */
     228             :     const Word32 core_brate, /* i  : core bitrate Q0                                */
     229             :     const Word16 Opt_AMR_WB, /* i  : flag indicating AMR-WB IO mode Q0              */
     230             :     const Word16 L_frame,    /* i  : length of the frame Q0                         */
     231             :     const Word16 sharpFlag,  /* i  : formant sharpening flag Q0                     */
     232             :     const Word16 i_subfr,    /* i  : subframe index Q0                              */
     233             :     const Word16 *p_Aq,      /* i  : LP filter coefficients Q12                  */
     234             :     const Word16 tilt_code,  /* i  : tilt of the excitation of previous subframe Q15 */
     235             :     const Word16 pt_pitch,   /* i  : pointer to current subframe fractional pitch Q6*/
     236             :     Word16 *code,            /* o  : algebraic excitation Q12                        */
     237             :     const Word16 L_subfr     /* i  : subframe length Q0                             */
     238             : )
     239             : {
     240             :     Word16 nBits;
     241             :     Word16 g1, g2;
     242             : 
     243           0 :     IF( EQ_16( L_frame, L_FRAME ) )
     244             :     {
     245           0 :         g1 = FORMANT_SHARPENING_G1;
     246           0 :         move16();
     247           0 :         g2 = FORMANT_SHARPENING_G2;
     248           0 :         move16();
     249             :     }
     250             :     ELSE
     251             :     {
     252           0 :         g1 = FORMANT_SHARPENING_G1_16k;
     253           0 :         move16();
     254           0 :         g2 = FORMANT_SHARPENING_G2_16k;
     255           0 :         move16();
     256             :     }
     257             : 
     258           0 :     IF( !Opt_AMR_WB )
     259             :     {
     260           0 :         IF( st_fx->acelp_cfg.fcb_mode )
     261             :         {
     262             :             Word16 i;
     263             :             Word16 indexing_indices[8], wordcnt, bitcnt;
     264             :             PulseConfig config;
     265           0 :             test();
     266           0 :             test();
     267           0 :             test();
     268           0 :             IF( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_subfr] >= 0 )
     269             :             {
     270           0 :                 IF( EQ_16( L_subfr, 2 * L_SUBFR ) )
     271             :                 {
     272           0 :                     nBits = st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_subfr]; // Q0
     273           0 :                     move16();
     274             : 
     275           0 :                     IF( EQ_16( nBits, 8 ) )
     276             :                     {
     277           0 :                         dec_acelp_1t64_fx( st_fx, code, L_subfr );
     278             :                     }
     279             :                     ELSE
     280             :                     {
     281           0 :                         dec_acelp_fast_fx( st_fx, nBits, code, L_subfr );
     282             :                     }
     283             :                 }
     284           0 :                 ELSE IF( ( EQ_16( st_fx->idchan, 1 ) && LE_16( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], 7 ) ) || ( ( st_fx->idchan == 0 ) && LE_16( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], 3 ) ) )
     285             :                 {
     286           0 :                     IF( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] == 0 )
     287             :                     {
     288           0 :                         dec_acelp_1t64_fx( st_fx, code, L_SUBFR );
     289             :                     }
     290             :                     ELSE
     291             :                     {
     292           0 :                         dec_acelp_fast_fx( st_fx, st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], code, L_SUBFR );
     293             :                     }
     294             :                 }
     295             :                 ELSE
     296             :                 {
     297           0 :                     wordcnt = shr( ACELP_FIXED_CDK_BITS( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] ), 4 ); // Q0
     298           0 :                     move16();
     299           0 :                     bitcnt = s_and( ACELP_FIXED_CDK_BITS( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] ), 15 ); // Q0
     300           0 :                     move16();
     301             : 
     302           0 :                     FOR( i = 0; i < wordcnt; i++ )
     303             :                     {
     304           0 :                         indexing_indices[i] = get_next_indice_fx( st_fx, 16 ); // Q0
     305           0 :                         move16();
     306             :                     }
     307           0 :                     IF( bitcnt )
     308             :                     {
     309           0 :                         indexing_indices[i] = get_next_indice_fx( st_fx, bitcnt ); // Q0
     310           0 :                         move16();
     311             :                     }
     312           0 :                     config = PulseConfTable[st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR]];
     313           0 :                     D_ACELP_indexing_fx( code, config, NB_TRACK_FCB_4T, indexing_indices, &st_fx->BER_detect );
     314             :                 }
     315             :             }
     316             :             ELSE
     317             :             {
     318           0 :                 set16_fx( code, 0, L_SUBFR );
     319             :             }
     320             :         }
     321             :         ELSE
     322             :         {
     323           0 :             nBits = st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR]; // Q0
     324           0 :             move16();
     325             : 
     326           0 :             IF( EQ_16( nBits, 7 ) )
     327             :             {
     328           0 :                 dec_acelp_1t64_fx( st_fx, code, L_SUBFR );
     329             :             }
     330           0 :             ELSE IF( EQ_16( nBits, 12 ) )
     331             :             {
     332           0 :                 dec_acelp_2t32_fx( st_fx, code );
     333             :             }
     334             :             ELSE
     335             :             {
     336           0 :                 dec_acelp_4t64_fx( st_fx, nBits, code, Opt_AMR_WB );
     337             :             }
     338             :         }
     339             :     }
     340             :     ELSE
     341             :     {
     342           0 :         IF( EQ_32( core_brate, ACELP_6k60 ) )
     343             :         {
     344           0 :             dec_acelp_2t32_fx( st_fx, code );
     345             :         }
     346           0 :         ELSE IF( EQ_32( core_brate, ACELP_8k85 ) )
     347             :         {
     348           0 :             dec_acelp_4t64_fx( st_fx, 20, code, Opt_AMR_WB );
     349             :         }
     350           0 :         ELSE IF( EQ_32( core_brate, ACELP_12k65 ) )
     351             :         {
     352           0 :             dec_acelp_4t64_fx( st_fx, 36, code, Opt_AMR_WB );
     353             :         }
     354           0 :         ELSE IF( EQ_32( core_brate, ACELP_14k25 ) )
     355             :         {
     356           0 :             dec_acelp_4t64_fx( st_fx, 44, code, Opt_AMR_WB );
     357             :         }
     358           0 :         ELSE IF( EQ_32( core_brate, ACELP_15k85 ) )
     359             :         {
     360           0 :             dec_acelp_4t64_fx( st_fx, 52, code, Opt_AMR_WB );
     361             :         }
     362           0 :         ELSE IF( EQ_32( core_brate, ACELP_18k25 ) )
     363             :         {
     364           0 :             dec_acelp_4t64_fx( st_fx, 64, code, Opt_AMR_WB );
     365             :         }
     366           0 :         ELSE IF( EQ_32( core_brate, ACELP_19k85 ) )
     367             :         {
     368           0 :             dec_acelp_4t64_fx( st_fx, 72, code, Opt_AMR_WB );
     369             :         }
     370             :         ELSE
     371             :         {
     372           0 :             dec_acelp_4t64_fx( st_fx, 88, code, Opt_AMR_WB );
     373             :         }
     374             :     }
     375             : 
     376           0 :     cb_shape_fx( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, code, tilt_code, shr( add( pt_pitch, 26 ), 6 ), 0, L_subfr );
     377           0 :     return;
     378             : }

Generated by: LCOV version 1.14