LCOV - code coverage report
Current view: top level - lib_com - codec_tcx_common_fx.c (source / functions) Hit Total Coverage
Test: Coverage on main -- dec/rend @ 6c320724ac154bae0b720af82641e0df71ffdfc7 Lines: 153 297 51.5 %
Date: 2025-07-01 04:22:09 Functions: 6 8 75.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 <assert.h>
       7             : #include <math.h>
       8             : #include "options.h"
       9             : #include "prot_fx.h"
      10             : #include "basop_util.h"
      11             : #include "rom_basop_util.h"
      12             : #include "rom_com.h"
      13             : 
      14             : #define inv_int InvIntTable
      15             : 
      16      759903 : Word16 tcxGetNoiseFillingTilt(
      17             :     const Word16 A[],
      18             :     const Word16 lpcorder,
      19             :     const Word16 L_frame,
      20             :     const Word16 mode,
      21             :     Word16 *noiseTiltFactor /*Q15*/
      22             : )
      23             : {
      24             :     Word16 firstLine;
      25             :     Word32 tmp;
      26             :     Word16 As[M + 1];
      27             : 
      28             : 
      29      759903 :     IF( mode != 0 )
      30             :     {
      31      733401 :         firstLine = idiv1616U( L_frame, 6 );
      32      733401 :         *noiseTiltFactor = 18432 /*0.5625f Q15*/;
      33      733401 :         move16();
      34             :     }
      35             :     ELSE
      36             :     {
      37       26502 :         firstLine = shr( L_frame, 3 );
      38             : 
      39       26502 :         Copy_Scale_sig( A, As, add( lpcorder, 1 ), sub( norm_s( A[0] ), 2 ) ); // Q(12)
      40       26502 :         tmp = get_gain( As + 1, As, lpcorder );
      41             :         BASOP_SATURATE_WARNING_OFF_EVS;
      42       26502 :         *noiseTiltFactor = add_sat( round_fx_sat( L_shl_sat( tmp, 15 ) ), 3072 /*0.09375f Q15*/ );
      43       26502 :         move16();
      44             :         BASOP_SATURATE_WARNING_ON_EVS;
      45             :     }
      46             : 
      47             : 
      48      759903 :     return firstLine;
      49             : }
      50             : 
      51             : 
      52           0 : void tcxFormantEnhancement(
      53             :     Word16 xn_buf[],        // Q(15-xn_buf_e)
      54             :     const Word16 gainlpc[], // Q(15-gainlpc_e)
      55             :     const Word16 gainlpc_e[],
      56             :     Word32 spectrum[], // Q(31-spectrum_e)
      57             :     Word16 *spectrum_e,
      58             :     const Word16 L_frame,
      59             :     const Word16 L_frameTCX )
      60             : {
      61             :     Word16 i, j, k, l, n;
      62             :     Word16 fac, fac0, fac1, fac_e, d, tmp;
      63             :     Word16 xn_buf_e, xn_one, m, e;
      64             : #ifdef BASOP_NOGLOB_DECLARE_LOCAL
      65           0 :     Flag Overflow = 0;
      66           0 :     move32();
      67             : #endif
      68             : 
      69           0 :     k = shr( L_frame, 6 ); /* FDNS_NPTS = 64 */
      70           0 :     l = 0;
      71           0 :     move16();
      72             : 
      73             :     /* get exponent */
      74           0 :     xn_buf_e = 0;
      75           0 :     move16();
      76           0 :     FOR( i = 0; i < FDNS_NPTS; i++ )
      77             :     {
      78           0 :         xn_buf_e = s_max( xn_buf_e, gainlpc_e[i] );
      79             :     }
      80           0 :     xn_buf_e = shr( add( xn_buf_e, 1 ), 1 );    /* max exponent after sqrt */
      81           0 :     xn_one = shr( 0x4000, sub( xn_buf_e, 1 ) ); /* 1.0 scaled to xn_buf_e */
      82             : 
      83             :     /* Formant enhancement via square root of the LPC gains */
      84           0 :     e = gainlpc_e[0];
      85           0 :     move16();
      86           0 :     m = Sqrt16( gainlpc[0], &e );
      87           0 :     xn_buf[0] = shl( m, sub( e, xn_buf_e ) ); // Q(15-xn_buf_e)
      88           0 :     move16();
      89             : 
      90           0 :     e = gainlpc_e[1];
      91           0 :     move16();
      92           0 :     m = Sqrt16( gainlpc[1], &e );
      93           0 :     xn_buf[1] = shl( m, sub( e, xn_buf_e ) ); // Q(15-xn_buf_e)
      94           0 :     move16();
      95             : 
      96           0 :     fac0 = s_min( xn_buf[0], xn_buf[1] );
      97           0 :     fac_e = xn_buf_e;
      98           0 :     move16();
      99           0 :     fac0 = Inv16( fac0, &fac_e );
     100             : 
     101           0 :     FOR( i = 1; i < FDNS_NPTS - 1; i++ )
     102             :     {
     103           0 :         e = gainlpc_e[i + 1];
     104           0 :         move16();
     105           0 :         m = Sqrt16( gainlpc[i + 1], &e );
     106           0 :         xn_buf[i + 1] = shl( m, sub( e, xn_buf_e ) ); // Q(15-xn_buf_e)
     107           0 :         move16();
     108             : 
     109           0 :         test();
     110           0 :         IF( ( LE_16( xn_buf[i - 1], xn_buf[i] ) ) && ( LE_16( xn_buf[i + 1], xn_buf[i] ) ) )
     111             :         {
     112           0 :             m = s_max( xn_buf[i - 1], xn_buf[i + 1] );
     113           0 :             e = xn_buf_e;
     114           0 :             move16();
     115           0 :             m = Inv16( m, &e );
     116             : 
     117           0 :             fac1 = m;
     118           0 :             move16();
     119           0 :             tmp = sub( e, fac_e );
     120             : 
     121           0 :             IF( tmp > 0 )
     122           0 :             fac0 = shr( fac0, tmp );
     123           0 :             IF( tmp < 0 )
     124           0 :             fac1 = shl( fac1, tmp );
     125             : 
     126           0 :             if ( tmp > 0 )
     127             :             {
     128           0 :                 fac_e = e;
     129           0 :                 move16();
     130             :             }
     131             : 
     132           0 :             d = sub( fac1, fac0 );
     133           0 :             n = sub( i, l );
     134           0 :             assert( n <= 64 );
     135             : 
     136           0 :             xn_buf[l] = xn_one;
     137           0 :             move16();
     138           0 :             FOR( j = 1; j < n; j++ )
     139             :             {
     140           0 :                 fac = add( fac0, mult( d, extract_l( L_mult0( j, inv_int[n] ) ) ) );
     141             :                 BASOP_SATURATE_WARNING_OFF_EVS;
     142           0 :                 xn_buf[l + j] = s_min( xn_one, shl_o( mult( xn_buf[l + j], fac ), fac_e, &Overflow ) );
     143           0 :                 move16();
     144             :                 BASOP_SATURATE_WARNING_ON_EVS;
     145             :             }
     146             : 
     147           0 :             l = i;
     148           0 :             move16();
     149             : 
     150           0 :             fac0 = m;
     151           0 :             move16();
     152           0 :             fac_e = e;
     153           0 :             move16();
     154             :         }
     155             :     }
     156             :     /* i = FDNS_NPTS - 1; Completing changes to gains */
     157           0 :     m = s_min( xn_buf[i - 1], xn_buf[i] );
     158           0 :     e = xn_buf_e;
     159           0 :     move16();
     160           0 :     m = Inv16( m, &e );
     161             : 
     162           0 :     fac1 = m;
     163           0 :     move16();
     164           0 :     tmp = sub( e, fac_e );
     165             : 
     166           0 :     IF( tmp > 0 )
     167           0 :     fac0 = shr( fac0, tmp );
     168           0 :     IF( tmp < 0 )
     169           0 :     fac1 = shl( fac1, tmp );
     170             : 
     171           0 :     if ( tmp > 0 )
     172             :     {
     173           0 :         fac_e = e;
     174           0 :         move16();
     175             :     }
     176             : 
     177           0 :     d = sub( fac1, fac0 );
     178           0 :     n = sub( i, l );
     179           0 :     assert( n <= 64 );
     180             : 
     181           0 :     xn_buf[l] = xn_one;
     182           0 :     move16();
     183           0 :     FOR( j = 1; j < n; j++ )
     184             :     {
     185           0 :         fac = add( fac0, mult( d, extract_l( L_mult0( j, inv_int[n] ) ) ) );
     186             :         BASOP_SATURATE_WARNING_OFF_EVS;
     187           0 :         xn_buf[l + j] = s_min( xn_one, shl_sat( mult( xn_buf[l + j], fac ), fac_e ) );
     188           0 :         move16();
     189             :         BASOP_SATURATE_WARNING_ON_EVS;
     190             :     }
     191             : 
     192           0 :     xn_buf[i] = xn_one;
     193           0 :     move16();
     194             : 
     195             :     /* Application of changed gains onto decoded MDCT lines */
     196           0 :     FOR( i = 0; i < L_frame; i += k )
     197             :     {
     198           0 :         FOR( l = 0; l < k; l++ )
     199             :         {
     200           0 :             *spectrum = Mpy_32_16_1( *spectrum, *xn_buf ); // Q(15-xn_buf_e)+Q(31-spectrum_e)+1 -16
     201           0 :             move32();
     202           0 :             spectrum++;
     203             :         }
     204           0 :         xn_buf++;
     205             :     }
     206             : 
     207           0 :     tmp = sub( L_frameTCX, L_frame );
     208           0 :     FOR( i = 0; i < tmp; i++ )
     209             :     {
     210           0 :         spectrum[i] = L_shr( spectrum[i], xn_buf_e ); // Q(31-(specturm_e+xn_buf_e))
     211           0 :         move32();
     212             :     }
     213           0 :     *spectrum_e = add( *spectrum_e, xn_buf_e );
     214           0 :     move16();
     215           0 : }
     216             : 
     217       26386 : void tcxFormantEnhancement_with_shift(
     218             :     Word16 xn_buf[], // Q(15-xn_buf_e_out)
     219             :     Word16 *xn_buf_e_out,
     220             :     const Word16 gainlpc[], // Q(15-gainlpc_e)
     221             :     const Word16 gainlpc_e[],
     222             :     Word32 spectrum[], // Q(31-spectrum_e)
     223             :     Word16 *spectrum_e,
     224             :     const Word16 L_frame,
     225             :     const Word16 L_frameTCX )
     226             : {
     227             :     Word16 i, j, k, l, n;
     228             :     Word16 fac, fac0, fac1, fac_e, d, tmp;
     229             :     Word16 xn_buf_e, xn_one, m, e;
     230             : #ifdef BASOP_NOGLOB_DECLARE_LOCAL
     231       26386 :     Flag Overflow = 0;
     232       26386 :     move32();
     233             : #endif
     234             : 
     235       26386 :     k = shr( L_frame, 6 ); /* FDNS_NPTS = 64 */
     236       26386 :     l = 0;
     237       26386 :     move16();
     238             : 
     239             :     /* get exponent */
     240       26386 :     xn_buf_e = 0;
     241       26386 :     move16();
     242     1715090 :     FOR( i = 0; i < FDNS_NPTS; i++ )
     243             :     {
     244     1688704 :         xn_buf_e = s_max( xn_buf_e, gainlpc_e[i] );
     245             :     }
     246       26386 :     xn_buf_e = shr( add( xn_buf_e, 1 ), 1 );    /* max exponent after sqrt */
     247       26386 :     xn_one = shr( 0x4000, sub( xn_buf_e, 1 ) ); /* 1.0 scaled to xn_buf_e */
     248             : 
     249             :     /* Formant enhancement via square root of the LPC gains */
     250       26386 :     e = gainlpc_e[0];
     251       26386 :     move16();
     252       26386 :     m = Sqrt16( gainlpc[0], &e );
     253       26386 :     xn_buf[0] = shl( m, sub( e, xn_buf_e ) ); // Q(15-xn_buf_e)
     254       26386 :     move16();
     255             : 
     256       26386 :     e = gainlpc_e[1];
     257       26386 :     move16();
     258       26386 :     m = Sqrt16( gainlpc[1], &e );
     259       26386 :     xn_buf[1] = shl( m, sub( e, xn_buf_e ) ); // Q(15-xn_buf_e)
     260       26386 :     move16();
     261             : 
     262       26386 :     fac0 = s_min( xn_buf[0], xn_buf[1] );
     263       26386 :     fac_e = xn_buf_e;
     264       26386 :     move16();
     265       26386 :     fac0 = Inv16( fac0, &fac_e );
     266             : 
     267     1662318 :     FOR( i = 1; i < FDNS_NPTS - 1; i++ )
     268             :     {
     269     1635932 :         e = gainlpc_e[i + 1];
     270     1635932 :         move16();
     271     1635932 :         m = Sqrt16( gainlpc[i + 1], &e );
     272     1635932 :         xn_buf[i + 1] = shl( m, sub( e, xn_buf_e ) ); // Q(15-xn_buf_e)
     273     1635932 :         move16();
     274             : 
     275     1635932 :         test();
     276     1635932 :         IF( ( LE_16( xn_buf[i - 1], xn_buf[i] ) ) && ( LE_16( xn_buf[i + 1], xn_buf[i] ) ) )
     277             :         {
     278       79543 :             m = s_max( xn_buf[i - 1], xn_buf[i + 1] );
     279       79543 :             e = xn_buf_e;
     280       79543 :             move16();
     281       79543 :             m = Inv16( m, &e );
     282             : 
     283       79543 :             fac1 = m;
     284       79543 :             move16();
     285       79543 :             tmp = sub( e, fac_e );
     286             : 
     287       79543 :             IF( tmp > 0 )
     288             :             {
     289       26342 :                 fac0 = shr( fac0, tmp );
     290             :             }
     291       79543 :             IF( tmp < 0 )
     292             :             {
     293        6762 :                 fac1 = shl( fac1, tmp );
     294             :             }
     295             : 
     296       79543 :             IF( tmp > 0 )
     297             :             {
     298       26342 :                 fac_e = e;
     299       26342 :                 move16();
     300             :             }
     301             : 
     302       79543 :             d = sub( fac1, fac0 );
     303       79543 :             n = sub( i, l );
     304       79543 :             assert( n <= 64 );
     305             : 
     306       79543 :             xn_buf[l] = xn_one;
     307       79543 :             move16();
     308     1176444 :             FOR( j = 1; j < n; j++ )
     309             :             {
     310     1096901 :                 fac = add( fac0, mult( d, extract_l( L_mult0( j, inv_int[n] ) ) ) );
     311             :                 BASOP_SATURATE_WARNING_OFF_EVS;
     312     1096901 :                 xn_buf[l + j] = s_min( xn_one, shl_o( mult( xn_buf[l + j], fac ), fac_e, &Overflow ) );
     313     1096901 :                 move16();
     314             :                 BASOP_SATURATE_WARNING_ON_EVS;
     315             :             }
     316             : 
     317       79543 :             l = i;
     318       79543 :             move16();
     319             : 
     320       79543 :             fac0 = m;
     321       79543 :             move16();
     322       79543 :             fac_e = e;
     323       79543 :             move16();
     324             :         }
     325             :     }
     326             :     /* i = FDNS_NPTS - 1; Completing changes to gains */
     327       26386 :     m = s_min( xn_buf[i - 1], xn_buf[i] );
     328       26386 :     e = xn_buf_e;
     329       26386 :     move16();
     330       26386 :     m = Inv16( m, &e );
     331             : 
     332       26386 :     fac1 = m;
     333       26386 :     move16();
     334       26386 :     tmp = sub( e, fac_e );
     335             : 
     336       26386 :     IF( tmp > 0 )
     337       12188 :     fac0 = shr( fac0, tmp );
     338       26386 :     IF( tmp < 0 )
     339         155 :     fac1 = shl( fac1, tmp );
     340             : 
     341       26386 :     if ( tmp > 0 )
     342             :     {
     343       12188 :         fac_e = e;
     344       12188 :         move16();
     345             :     }
     346             : 
     347       26386 :     d = sub( fac1, fac0 );
     348       26386 :     n = sub( i, l );
     349       26386 :     assert( n <= 64 );
     350             : 
     351       26386 :     xn_buf[l] = xn_one;
     352       26386 :     move16();
     353      485874 :     FOR( j = 1; j < n; j++ )
     354             :     {
     355      459488 :         fac = add( fac0, mult( d, extract_l( L_mult0( j, inv_int[n] ) ) ) );
     356             :         BASOP_SATURATE_WARNING_OFF_EVS;
     357      459488 :         xn_buf[l + j] = s_min( xn_one, shl_o( mult( xn_buf[l + j], fac ), fac_e, &Overflow ) );
     358      459488 :         move16();
     359             :         BASOP_SATURATE_WARNING_ON_EVS;
     360             :     }
     361             : 
     362       26386 :     xn_buf[i] = xn_one;
     363       26386 :     move16();
     364             : 
     365             :     /* Application of changed gains onto decoded MDCT lines */
     366     1715090 :     FOR( i = 0; i < L_frame; i += k )
     367             :     {
     368     8554880 :         FOR( l = 0; l < k; l++ )
     369             :         {
     370     6866176 :             *spectrum = Mpy_32_16_1( *spectrum, *xn_buf ); // Q(15-xn_buf_e)+Q(31-spectrum_e)+1 -16
     371     6866176 :             move32();
     372     6866176 :             spectrum++;
     373             :         }
     374     1688704 :         xn_buf++;
     375             :     }
     376             : 
     377       26386 :     tmp = sub( L_frameTCX, L_frame );
     378    17297570 :     FOR( i = 0; i < tmp; i++ )
     379             :     {
     380    17271184 :         spectrum[i] = L_shr( spectrum[i], xn_buf_e ); // Q(31-(specturm_e+xn_buf_e))
     381    17271184 :         move32();
     382             :     }
     383       26386 :     *spectrum_e = add( *spectrum_e, xn_buf_e );
     384       26386 :     move16();
     385             : 
     386       26386 :     *xn_buf_e_out = xn_buf_e;
     387       26386 :     move16();
     388       26386 : }
     389             : 
     390           0 : void tcxInvertWindowGrouping(
     391             :     TCX_CONFIG_HANDLE hTcxCfg, /* i  : configuration of TCX               */
     392             :     Word32 xn_buf[],           // Qx
     393             :     Word32 spectrum[],         // Qx
     394             :     const Word16 L_frame,
     395             :     const Word8 fUseTns,
     396             :     const Word16 last_core,
     397             :     const Word16 index,
     398             :     const Word16 frame_cnt,
     399             :     const Word16 bfi )
     400             : {
     401             :     Word16 i, L_win, L_spec;
     402             :     Word32 *p;
     403             : 
     404             : 
     405           0 :     L_win = shr( L_frame, 1 );
     406           0 :     L_spec = hTcxCfg->tnsConfig[0][0].iFilterBorders[0];
     407           0 :     move16();
     408             : 
     409           0 :     test();
     410           0 :     test();
     411           0 :     if ( ( frame_cnt != 0 ) && ( bfi == 0 ) && ( last_core != ACELP_CORE ) ) /* fix sub-window overlap */
     412             :     {
     413           0 :         hTcxCfg->tcx_last_overlap_mode = hTcxCfg->tcx_curr_overlap_mode;
     414           0 :         move16();
     415             :     }
     416           0 :     test();
     417           0 :     test();
     418           0 :     test();
     419           0 :     test();
     420           0 :     test();
     421           0 :     test();
     422           0 :     test();
     423           0 :     IF( ( ( bfi == 0 ) && ( ( hTcxCfg->tcx_last_overlap_mode != FULL_OVERLAP ) ||
     424             :                             ( ( hTcxCfg->tcx_curr_overlap_mode == FULL_OVERLAP ) && ( frame_cnt == 0 ) && ( index == 0 ) ) ) ) ||
     425             :         ( ( bfi != 0 ) && ( ( hTcxCfg->tcx_last_overlap_mode != FULL_OVERLAP ) &&
     426             :                             !( hTcxCfg->tcx_curr_overlap_mode == FULL_OVERLAP ) ) ) )
     427             :     {
     428             :         /* ungroup sub-windows: deinterleave MDCT bins into separate windows */
     429           0 :         p = xn_buf;
     430           0 :         FOR( i = 1; i < L_win; i += 2 )
     431             :         {
     432           0 :             *p++ = spectrum[i];
     433           0 :             move32();
     434             :         }
     435             : 
     436           0 :         p = spectrum;
     437           0 :         FOR( i = 0; i < L_frame; i += 2 )
     438             :         {
     439           0 :             *p++ = spectrum[i];
     440           0 :             move32();
     441             :         }
     442             : 
     443           0 :         p = spectrum + sub( L_frame, 1 );
     444           0 :         FOR( i = L_frame - 1; i > L_win; i -= 2 )
     445             :         {
     446           0 :             *p-- = spectrum[i];
     447           0 :             move32();
     448             :         }
     449           0 :         Copy32( xn_buf, spectrum + L_win, shr( L_win, 1 ) );
     450             : 
     451           0 :         test();
     452           0 :         test();
     453           0 :         IF( ( hTcxCfg->fIsTNSAllowed != 0 ) && ( bfi == 0 ) && ( fUseTns != 0 ) )
     454             :         {
     455             :             /* rearrange LF sub-window lines prior to TNS synthesis filtering */
     456           0 :             IF( LT_16( L_spec, L_frame ) )
     457             :             {
     458           0 :                 Copy32( spectrum + 8, spectrum + 16, sub( shr( L_spec, 1 ), 8 ) );
     459           0 :                 Copy32( spectrum + shr( L_frame, 1 ), spectrum + 8, 8 );
     460           0 :                 Copy32( spectrum + add( shr( L_frame, 1 ), 8 ), spectrum + add( shr( L_spec, 1 ), 8 ), sub( shr( L_spec, 1 ), 8 ) );
     461             :             }
     462             :             ELSE
     463             :             {
     464           0 :                 Copy32( spectrum + L_win, xn_buf, 8 );
     465           0 :                 Copy32( spectrum + 8, spectrum + 16, sub( L_win, 8 ) );
     466           0 :                 Copy32( xn_buf, spectrum + 8, 8 );
     467             :             }
     468             :         }
     469             :     }
     470           0 : }
     471             : 
     472             : /*-------------------------------------------------------------------*
     473             :  * tcx5SpectrumInterleaving()
     474             :  *
     475             :  *
     476             :  *-------------------------------------------------------------------*/
     477             : 
     478             : 
     479       15095 : void tcx5SpectrumInterleaving_fx(
     480             :     const Word16 tcx5Size,
     481             :     Word32 *spectrum // Qx
     482             : )
     483             : {
     484             :     Word16 i;
     485             :     Word32 interleaveBuf[N_TCX10_MAX];
     486             : 
     487       15095 :     set32_fx( interleaveBuf, 0, N_TCX10_MAX );
     488             : 
     489             :     /* group sub-windows: interleave bins according to their frequencies */
     490     3175815 :     FOR( i = 0; i < tcx5Size; i++ )
     491             :     {
     492     3160720 :         interleaveBuf[2 * i] = spectrum[i];
     493     3160720 :         interleaveBuf[2 * i + 1] = spectrum[tcx5Size + i];
     494     3160720 :         move32();
     495     3160720 :         move32();
     496             :     }
     497             : 
     498       15095 :     Copy32( interleaveBuf, spectrum, shl( tcx5Size, 1 ) );
     499             : 
     500       15095 :     return;
     501             : }
     502             : 
     503             : /*-------------------------------------------------------------------*
     504             :  * tcx5SpectrumDeinterleaving_fx()
     505             :  *
     506             :  *
     507             :  *-------------------------------------------------------------------*/
     508             : 
     509       30265 : void tcx5SpectrumDeinterleaving_fx(
     510             :     const Word16 tcx5Size,
     511             :     Word32 *spectrum // Qx
     512             : )
     513             : {
     514             :     Word16 i;
     515             :     Word32 interleaveBuf[N_TCX10_MAX];
     516             : 
     517       30265 :     set32_fx( interleaveBuf, 0, N_TCX10_MAX );
     518             : 
     519             :     /* ungroup sub-windows: interleave bins according to their frequencies */
     520     6392025 :     FOR( i = 0; i < tcx5Size; i++ )
     521             :     {
     522     6361760 :         interleaveBuf[i] = spectrum[2 * i];
     523     6361760 :         interleaveBuf[tcx5Size + i] = spectrum[2 * i + 1];
     524     6361760 :         move32();
     525     6361760 :         move32();
     526             :     }
     527             : 
     528       30265 :     Copy32( interleaveBuf, spectrum, shl( tcx5Size, 1 ) );
     529             : 
     530       30265 :     return;
     531             : }
     532             : 
     533             : /*-------------------------------------------------------------------*
     534             :  * tcx5TnsGrouping()
     535             :  *
     536             :  *
     537             :  *-------------------------------------------------------------------*/
     538             : 
     539       11540 : void tcx5TnsGrouping_fx(
     540             :     const Word16 L_frame, /* i  : frame length (TCX5)                                 */
     541             :     const Word16 L_spec,  /* i  : coded spec length (TCX5, derived from filter borders*/
     542             :     Word32 *spectrum      /*Qx*/
     543             : )
     544             : {
     545             :     /* rearrange LF sub-window lines prior to TNS synthesis filtering */
     546       11540 :     IF( LT_16( L_spec, L_frame ) )
     547             :     {
     548        6360 :         Copy32( spectrum + 8, spectrum + 16, sub( L_spec, 8 ) );
     549        6360 :         Copy32( spectrum + L_frame, spectrum + 8, 8 );
     550        6360 :         Copy32( spectrum + add( L_frame, 8 ), spectrum + add( L_spec, 8 ), sub( L_spec, 8 ) );
     551             :     }
     552             :     ELSE
     553             :     {
     554             :         Word32 buff[8]; /* Buffer for the rearrangement of LF TCX5 */
     555        5180 :         Copy32( spectrum + L_spec, buff, 8 );
     556        5180 :         Copy32( spectrum + 8, spectrum + 16, sub( L_spec, 8 ) );
     557        5180 :         Copy32( buff, spectrum + 8, 8 );
     558             :     }
     559             : 
     560       11540 :     return;
     561             : }
     562             : 
     563             : /*-------------------------------------------------------------------*
     564             :  * tcx5TnsUngrouping()
     565             :  *
     566             :  *
     567             :  *-------------------------------------------------------------------*/
     568             : 
     569       11540 : void tcx5TnsUngrouping_fx(
     570             :     const Word16 L_frame, /* i  : frame length (TCX5)                                 */
     571             :     const Word16 L_spec,  /* i  : coded spec length (TCX5, derived from filter borders*/
     572             :     Word32 *spectrum,     /*Qx*/
     573             :     const Word16 enc_dec  /* i  : 0: encoder, else decoder                            */
     574             : )
     575             : {
     576             :     /* undo rearrangement of LF sub-window lines prior to TNS analysis */
     577       11540 :     IF( LT_16( L_spec, L_frame ) )
     578             :     {
     579        7297 :         Copy32( spectrum + L_spec + 8, spectrum + add( L_frame, 8 ), sub( L_spec, 8 ) );
     580        7297 :         Copy32( spectrum + 8, spectrum + L_frame, 8 );
     581        7297 :         Copy32( spectrum + 16, spectrum + 8, sub( L_spec, 8 ) );
     582        7297 :         set32_fx( spectrum + L_spec, 0, sub( L_frame, L_spec ) );
     583        7297 :         set32_fx( spectrum + add( L_frame, L_spec ), 0, sub( L_frame, L_spec ) );
     584             :     }
     585             :     ELSE
     586             :     {
     587             :         Word32 buff[8]; /* Buffer for the rearrangement of LF TCX5 */
     588             : 
     589        4243 :         Copy32( spectrum + 8, buff, 8 );
     590             : 
     591        4243 :         IF( enc_dec == ENC )
     592             :         {
     593           0 :             Copy32( spectrum + 16, spectrum + 8, sub( L_frame, 8 ) );
     594           0 :             Copy32( buff, spectrum + L_frame, 8 );
     595             :         }
     596             :         ELSE
     597             :         {
     598        4243 :             Copy32( spectrum + 16, spectrum + 8, sub( L_spec, 8 ) );
     599        4243 :             Copy32( buff, spectrum + L_spec, 8 );
     600             :         }
     601             :     }
     602             : 
     603       11540 :     return;
     604             : }

Generated by: LCOV version 1.14