Loading lib_com/ACcontextMapping.c +9 −9 Original line number Diff line number Diff line Loading @@ -67,21 +67,21 @@ int16_t get_next_coeff_mapped_ivas( } #else Word16 get_next_coeff_mapped_ivas( Word16 ii[2], /* i/o: coefficient indexes */ Word32 *pp, /* o : peak(1)/hole(0) indicator */ Word16 *idx, /* o : index in unmapped domain */ Word16 ii[2], /* i/o: coefficient indexes Q0*/ Word32 *pp, /* o : peak(1)/hole(0) indicator Q0*/ Word16 *idx, /* o : index in unmapped domain Q0*/ CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ ) { UWord32 p; p = s_and( sub( ii[1], hm_cfg->numPeakIndices ), sub( hm_cfg->indexBuffer[ii[1]], hm_cfg->indexBuffer[ii[0]] ) ); p = UL_lshr( p, sub( sizeof( p ) * 8, 1 ) ); *pp = p; p = s_and( sub( ii[1], hm_cfg->numPeakIndices ), sub( hm_cfg->indexBuffer[ii[1]], hm_cfg->indexBuffer[ii[0]] ) ); /* Q0 */ p = UL_lshr( p, sub( sizeof( p ) * 8, 1 ) ); /* Q0 */ *pp = p; /* Q0 */ move32(); *idx = ii[p]; *idx = ii[p]; /* Q0 */ move16(); ii[p] = add( ii[p], 1 ); ii[p] = add( ii[p], 1 ); /* Q0 */ move16(); return hm_cfg->indexBuffer[*idx]; Loading lib_com/ACcontextMapping_fx.c +28 −22 Original line number Diff line number Diff line Loading @@ -11,15 +11,15 @@ /* Returns: index of next coefficient */ Word16 get_next_coeff_mapped( Word16 ii[2], /* i/o: coefficient indexes */ Word16 *pp, /* o : peak(1)/hole(0) indicator */ Word16 *idx, /* o : index in unmapped domain */ Word16 ii[2], /* i/o: coefficient indexes Q0*/ Word16 *pp, /* o : peak(1)/hole(0) indicator Q0*/ Word16 *idx, /* o : index in unmapped domain Q0*/ CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ ) { Word16 p; p = s_and( sub( ii[1], hm_cfg->numPeakIndices ), sub( hm_cfg->indexBuffer[ii[1]], hm_cfg->indexBuffer[ii[0]] ) ); p = s_and( sub( ii[1], hm_cfg->numPeakIndices ), sub( hm_cfg->indexBuffer[ii[1]], hm_cfg->indexBuffer[ii[0]] ) ); /* Q0 */ if ( p > 0 ) { p = 0; Loading @@ -30,63 +30,69 @@ Word16 get_next_coeff_mapped( p = 1; move16(); } *pp = p; *pp = p; /* Q0 */ move16(); *idx = ii[p]; *idx = ii[p]; /* Q0 */ move16(); ii[p] = add( ii[p], 1 ); ii[p] = add( ii[p], 1 ); /* Q0 */ move16(); return hm_cfg->indexBuffer[*idx]; } /* Returns: index of next coefficient */ Word16 get_next_coeff_unmapped( Word16 ii[2], /* i/o: coefficient indexes */ Word16 *pp, /* o : peak(1)/hole(0) indicator */ Word16 *idx, /* o : index in unmapped domain */ Word16 ii[2], /* i/o: coefficient indexes Q0*/ Word16 *pp, /* o : peak(1)/hole(0) indicator Q0*/ Word16 *idx, /* o : index in unmapped domain Q0*/ CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ ) { (void) pp; (void) hm_cfg; *idx = ii[0]; *idx = ii[0]; /* Q0 */ move16(); ii[0] = add( ii[0], 1 ); ii[0] = add( ii[0], 1 ); /* Q0 */ move16(); return *idx; } Word16 update_mixed_context( Word16 ctx, Word16 a ) Word16 update_mixed_context( Word16 ctx, /* Q0 */ Word16 a /* Q0 */ ) { Word32 t32; Word16 t = 0; /* initialize just to avoid compiler warning */ t32 = L_mac0( 1 - 13, s_and( a, ~1 ), add( shr( a, 2 ), 1 ) ); t32 = L_mac0( 1 - 13, s_and( a, ~1 ), add( shr( a, 2 ), 1 ) ); /* Q0 */ if ( t32 <= 0 ) { t = extract_l( t32 ); t = extract_l( t32 ); /* Q0 */ } a = shr( a, 3 ); if ( t32 > 0 ) { t = s_min( a, 2 ); t = s_min( a, 2 ); /* Q0 */ } return add( shl( s_and( ctx, 0xf ), 4 ), add( t, 13 ) ); } #ifdef IVAS_FLOAT_FIXED Word32 update_mixed_context_ivas_fx( Word32 ctx, Word16 a ) Word32 update_mixed_context_ivas_fx( Word32 ctx, /* Q0 */ Word16 a /* Q0 */ ) { Word32 t32; t32 = L_mac0( 1 - 13, s_and( a, ~1 ), add( shr( a, 2 ), 1 ) ); t32 = L_mac0( 1 - 13, s_and( a, ~1 ), add( shr( a, 2 ), 1 ) ); /* Q0 */ a = shr( a, 3 ); a = shr( a, 3 ); /* Q0 */ IF( t32 > 0 ) { t32 = L_min( a, 2 ); t32 = L_min( a, 2 ); /* Q0 */ } return L_add( L_shl( L_and( ctx, 0xf ), 4 ), L_add( t32, 13 ) ); } Loading lib_com/ari_fx.c +4 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,10 @@ Word32 L_multi31x16_X2( Word16 xh, Word16 xl, Word16 y ) * * \return r*c */ Word32 mul_sbc_14bits( Word32 r, Word16 c ) Word32 mul_sbc_14bits( Word32 r, /* Q0 */ Word16 c /* Q0 */ ) { Word32 ret; Loading lib_com/ari_hm.c +73 −71 Original line number Diff line number Diff line Loading @@ -101,12 +101,13 @@ void UnmapIndex_ivas( } void UnmapIndex_fx( const Word16 PeriodicityIndex, const Word16 Bandwidth, const Word16 LtpPitchLag, const Word8 SmallerLags, Word16 *FractionalResolution, Word32 *Lag ) const Word16 PeriodicityIndex, /* Q0 */ const Word16 Bandwidth, /* Q0 */ const Word16 LtpPitchLag, /* Q0 */ const Word8 SmallerLags, /* Q0 */ Word16 *FractionalResolution, /* Q0 */ Word32 *Lag /* Q0 */ ) { Word16 LtpPitchIndex, Multiplier; Word16 Lag16; Loading @@ -114,54 +115,54 @@ void UnmapIndex_fx( test(); IF( ( LtpPitchLag > 0 ) && ( s_and( PeriodicityIndex, kLtpHmFlag ) != 0 ) ) { LtpPitchIndex = shr( PeriodicityIndex, 9 ); Multiplier = s_and( PeriodicityIndex, 0xff ); LtpPitchIndex = shr( PeriodicityIndex, 9 ); /* Q0 */ Multiplier = s_and( PeriodicityIndex, 0xff ); /* Q0 */ assert( 0 <= LtpPitchIndex && LtpPitchIndex <= 16 ); assert( 1 <= Multiplier && Multiplier <= ( 1 << NumRatioBits[Bandwidth][LtpPitchIndex] ) ); *FractionalResolution = kLtpHmFractionalResolution; *FractionalResolution = kLtpHmFractionalResolution; /* Q0 */ move16(); *Lag = L_shr( L_mult0( LtpPitchLag, Ratios_fx[Bandwidth][LtpPitchIndex][Multiplier - 1] ), 8 ); *Lag = L_shr( L_mult0( LtpPitchLag, Ratios_fx[Bandwidth][LtpPitchIndex][Multiplier - 1] ), 8 ); /* Q0 */ move32(); } ELSE { IF( LT_16( PeriodicityIndex, 16 ) ) { *FractionalResolution = 3; *FractionalResolution = 3; /* Q0 */ move16(); Lag16 = add( PeriodicityIndex, GET_ADJ2( 0, 6, 3 ) ); Lag16 = add( PeriodicityIndex, GET_ADJ2( 0, 6, 3 ) ); /* Q0 */ } ELSE IF( LT_16( PeriodicityIndex, 80 ) ) { *FractionalResolution = 4; *FractionalResolution = 4; /* Q0 */ move16(); Lag16 = add( PeriodicityIndex, GET_ADJ2( 16, 8, 4 ) ); Lag16 = add( PeriodicityIndex, GET_ADJ2( 16, 8, 4 ) ); /* Q0 */ } ELSE IF( LT_16( PeriodicityIndex, 208 ) ) { *FractionalResolution = 3; *FractionalResolution = 3; /* Q0 */ move16(); Lag16 = add( PeriodicityIndex, GET_ADJ2( 80, 12, 3 ) ); Lag16 = add( PeriodicityIndex, GET_ADJ2( 80, 12, 3 ) ); /* Q0 */ } ELSE { test(); IF( LT_16( PeriodicityIndex, 224 ) || SmallerLags != 0 ) { *FractionalResolution = 1; *FractionalResolution = 1; /* Q0 */ move16(); Lag16 = add( PeriodicityIndex, GET_ADJ2( 208, 28, 1 ) ); Lag16 = add( PeriodicityIndex, GET_ADJ2( 208, 28, 1 ) ); /* Q0 */ } ELSE { *FractionalResolution = 0; move16(); Lag16 = add( PeriodicityIndex, GET_ADJ2( 224, 188, 0 ) ); Lag16 = add( PeriodicityIndex, GET_ADJ2( 224, 188, 0 ) ); /* Q0 */ } } *Lag = L_deposit_l( Lag16 ); *Lag = L_deposit_l( Lag16 ); /* Q0 */ } } Loading Loading @@ -262,19 +263,20 @@ int16_t CountIndexBits_ivas( } Word16 CountIndexBits_fx( Word16 Bandwidth, Word16 PeriodicityIndex ) Word16 Bandwidth, /* Q0 */ Word16 PeriodicityIndex /* Q0 */ ) { Word16 result; Word16 PeriodicityIndexS; result = 8; result = 8; /* Q0 */ move16(); PeriodicityIndexS = shr( PeriodicityIndex, 9 ); PeriodicityIndexS = shr( PeriodicityIndex, 9 ); /* Q0 */ if ( s_and( PeriodicityIndex, kLtpHmFlag ) != 0 ) { result = NumRatioBits[Bandwidth][PeriodicityIndexS]; result = NumRatioBits[Bandwidth][PeriodicityIndexS]; /* Q0 */ move16(); } Loading @@ -290,9 +292,9 @@ Word16 CountIndexBits_fx( *-------------------------------------------------------------------*/ Word16 tcx_hm_render_ivas( const Word16 lag, /* i : pitch lag */ const Word16 fract_res, /* i : fractional resolution of the lag */ Word16 p[] /* o : harmonic model (Q13) */ const Word16 lag, /* i : pitch lag Q0*/ const Word16 fract_res, /* i : fractional resolution of the lag Q0*/ Word16 p[] /* o : harmonic model Q13*/ ) { Word16 k; Loading @@ -305,13 +307,13 @@ Word16 tcx_hm_render_ivas( tmp32 = Mpy_32_16_1( f0, -26474 ); tmp32 = L_shr_r( BASOP_Util_InvLog2( L_shl( tmp32, 7 ) ), 2 ); tmp32 = L_sub( 603979776L, tmp32 ); tmp32 = L_add( L_add( tmp32, tmp32 ), Mpy_32_16_1( tmp32, 26214 ) ); tmp32 = L_sub( 603979776L /* 1.125 in Q29 */, tmp32 ); /* Q29 */ tmp32 = L_add( L_add( tmp32, tmp32 ), Mpy_32_16_1( tmp32, 26214 /* 0.8 in Q15 */ ) ); /* Q29 */ height = round_fx( tmp32 ); /* Q13 */ tmp32 = Mpy_32_16_1( f0, -18910 ); tmp32 = L_shr_r( BASOP_Util_InvLog2( L_shl( tmp32, 7 ) ), 2 ); tmp32 = L_sub( 1395864371L, tmp32 ); tmp32 = L_shr_r( BASOP_Util_InvLog2( L_shl( tmp32, 7 ) ), 2 ); /* Q30 */ tmp32 = L_sub( 1395864371L /* 1.3 in Q30 */, tmp32 ); /* Q30 */ PeakDeviation = round_fx( tmp32 ); /* Q14 */ IF( sub( 13915, PeakDeviation ) > 0 ) Loading @@ -321,22 +323,22 @@ Word16 tcx_hm_render_ivas( } ELSE { tmp = div_s( 13915, PeakDeviation ); tmp = div_s( 13915, PeakDeviation ); /* Q15 */ tmp = mult_r( tmp, tmp ); /* Q15 */ } /* Render the prototype peak */ p[kTcxHmParabolaHalfWidth] = height; p[kTcxHmParabolaHalfWidth] = height; /* Q13 */ move16(); FOR( k = 1; k <= kTcxHmParabolaHalfWidth; ++k ) { p[kTcxHmParabolaHalfWidth + k] = round_fx( Mpy_32_16_1( BASOP_Util_InvLog2( L_shl( L_mult0( mult0( negate( k ), k ), tmp ), 10 ) ), height ) ); p[kTcxHmParabolaHalfWidth + k] = round_fx( Mpy_32_16_1( BASOP_Util_InvLog2( L_shl( L_mult0( mult0( negate( k ), k ), tmp ), 10 ) ), height ) ); /* Q13 */ } /* Mirror */ FOR( k = -kTcxHmParabolaHalfWidth; k < 0; ++k ) { p[kTcxHmParabolaHalfWidth + k] = p[kTcxHmParabolaHalfWidth - k]; p[kTcxHmParabolaHalfWidth + k] = p[kTcxHmParabolaHalfWidth - k]; /* Q13 */ } return 0; Loading @@ -356,14 +358,14 @@ Word32 tcx_hm_render_fx( f0 = L_shl( lag, sub( 15, fract_res ) ); /* Q31 */ tmp32 = Mpy_32_16_1( f0, -26474 ); tmp32 = L_shr_r( BASOP_Util_InvLog2( L_shl( tmp32, 7 ) ), 2 ); tmp32 = L_sub( 603979776L, tmp32 ); tmp32 = L_add( L_add( tmp32, tmp32 ), Mpy_32_16_1( tmp32, 26214 ) ); tmp32 = L_shr_r( BASOP_Util_InvLog2( L_shl( tmp32, 7 ) ), 2 ); /* Q29 */ tmp32 = L_sub( 603979776L /* 1.125 in Q29 */, tmp32 ); /* Q29 */ tmp32 = L_add( L_add( tmp32, tmp32 ), Mpy_32_16_1( tmp32, 26214 /* 0.8 in Q15 */ ) ); /* Q29 */ height = round_fx( tmp32 ); /* Q13 */ tmp32 = Mpy_32_16_1( f0, -18910 ); tmp32 = L_shr_r( BASOP_Util_InvLog2( L_shl( tmp32, 7 ) ), 2 ); tmp32 = L_sub( 1395864371L, tmp32 ); tmp32 = L_shr_r( BASOP_Util_InvLog2( L_shl( tmp32, 7 ) ), 2 ); /* Q30 */ tmp32 = L_sub( 1395864371L /* 1.3 in Q30 */, tmp32 ); /* Q30 */ PeakDeviation = round_fx( tmp32 ); /* Q14 */ IF( GT_16( 13915, PeakDeviation ) ) Loading @@ -373,11 +375,11 @@ Word32 tcx_hm_render_fx( } ELSE { tmp = div_s( 13915, PeakDeviation ); tmp = div_s( 13915, PeakDeviation ); /* Q15 */ tmp = mult_r( tmp, tmp ); /* Q15 */ } tmp = div_s( 13915, PeakDeviation ); tmp = div_s( 13915, PeakDeviation ); /* Q15 */ tmp = mult_r( tmp, tmp ); /* Q15 */ /* Render the prototype peak */ Loading @@ -386,12 +388,12 @@ Word32 tcx_hm_render_fx( FOR( k = 1; k <= kTcxHmParabolaHalfWidth; ++k ) { p[kTcxHmParabolaHalfWidth + k] = round_fx( Mpy_32_16_1( BASOP_Util_InvLog2( L_shl( L_mult0( i_mult2( negate( k ), k ), tmp ), 10 ) ), height ) ); p[kTcxHmParabolaHalfWidth + k] = round_fx( Mpy_32_16_1( BASOP_Util_InvLog2( L_shl( L_mult0( i_mult2( negate( k ), k ), tmp ), 10 ) ), height ) ); /* Q13 */ } /* Mirror */ FOR( k = -kTcxHmParabolaHalfWidth; k < 0; ++k ) { p[kTcxHmParabolaHalfWidth + k] = p[kTcxHmParabolaHalfWidth - k]; p[kTcxHmParabolaHalfWidth + k] = p[kTcxHmParabolaHalfWidth - k]; /* Q13 */ move16(); } Loading @@ -405,12 +407,12 @@ Word32 tcx_hm_render_fx( *-------------------------------------------------------------------*/ void tcx_hm_modify_envelope_ivas( const Word16 gain, /* i : HM gain (Q11) */ const Word16 lag, const Word16 fract_res, const Word16 p[], /* i : harmonic model (Q13) */ Word32 env[], /* i/o: envelope (Q16) */ const Word16 L_frame /* i : number of spectral lines */ const Word16 gain, /* i : HM gain Q11*/ const Word16 lag, /* Q0 */ const Word16 fract_res, /* Q0 */ const Word16 p[], /* i : harmonic model Q13*/ Word32 env[], /* i/o: envelope Q16*/ const Word16 L_frame /* i : number of spectral lines Q0*/ ) { Word16 k, h, x; Loading @@ -423,7 +425,7 @@ void tcx_hm_modify_envelope_ivas( FOR( k = 0; k < 2 * kTcxHmParabolaHalfWidth + 1; ++k ) { inv_shape[k] = div_s( 512, add( 512, round_fx( L_mult( gain, p[k] ) ) ) ); inv_shape[k] = div_s( 512 /* 1 in Q24 */, add( 512 /* 1 in Q24 */, round_fx( L_mult( gain, p[k] ) ) ) ); /* Q15 */ move16(); } Loading @@ -435,11 +437,11 @@ void tcx_hm_modify_envelope_ivas( FOR( x = max( 0, k - kTcxHmParabolaHalfWidth ); x <= min( k + kTcxHmParabolaHalfWidth, L_frame - 1 ); ++x ) { env[x] = Mpy_32_16_1( env[x], inv_shape[x - k + kTcxHmParabolaHalfWidth] ); env[x] = Mpy_32_16_1( env[x], inv_shape[x - k + kTcxHmParabolaHalfWidth] ); /* Q16 */ move32(); } ++h; k = extract_l( L_shr( L_mult0( h, lag ), fract_res ) ); h = add( h, 1 ); /* Q0 */ k = extract_l( L_shr( L_mult0( h, lag ), fract_res ) ); /* Q0 */ } return; Loading @@ -465,7 +467,7 @@ void tcx_hm_modify_envelope_fx( FOR( k = 0; k < 2 * kTcxHmParabolaHalfWidth + 1; ++k ) { /* Q24 = Q11 * Q13; 512 = 1.0 in Q24 format */ inv_shape[k] = div_s( 512, add( 512, mult_r( gain, p[k] ) ) ); inv_shape[k] = div_s( 512, add( 512, mult_r( gain, p[k] ) ) ); /* Q15 */ move16(); } Loading @@ -473,21 +475,21 @@ void tcx_hm_modify_envelope_fx( move16(); k = extract_l( L_shr( lag, fract_res ) ); L_frame_m1 = sub( L_frame, 1 ); L_frame_for_loop = add( L_frame, kTcxHmParabolaHalfWidth - 1 ); L_frame_m1 = sub( L_frame, 1 ); /* Q0 */ L_frame_for_loop = add( L_frame, kTcxHmParabolaHalfWidth - 1 ); /* Q0 */ WHILE( LE_16( k, L_frame_for_loop ) ) WHILE( k <= L_frame_for_loop ) { l1 = s_max( 0, sub( k, kTcxHmParabolaHalfWidth ) ); l2 = s_min( add( k, kTcxHmParabolaHalfWidth ), L_frame_m1 ); l1 = s_max( 0, sub( k, kTcxHmParabolaHalfWidth ) ); /* Q0 */ l2 = s_min( add( k, kTcxHmParabolaHalfWidth ), L_frame_m1 ); /* Q0 */ FOR( x = l1; x <= l2; ++x ) { env[x] = Mpy_32_16_1( env[x], inv_shape[x - k + kTcxHmParabolaHalfWidth] ); env[x] = Mpy_32_16_1( env[x], inv_shape[x - k + kTcxHmParabolaHalfWidth] ); /* Q16 */ move32(); } h = add( h, 1 ); k = extract_l( L_shr( imult3216( lag, h ), fract_res ) ); h = add( h, 1 ); /* Q0 */ k = extract_l( L_shr( imult3216( lag, h ), fract_res ) ); /* Q0 */ } } Loading lib_com/ari_hm_fx.c +65 −63 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
lib_com/ACcontextMapping.c +9 −9 Original line number Diff line number Diff line Loading @@ -67,21 +67,21 @@ int16_t get_next_coeff_mapped_ivas( } #else Word16 get_next_coeff_mapped_ivas( Word16 ii[2], /* i/o: coefficient indexes */ Word32 *pp, /* o : peak(1)/hole(0) indicator */ Word16 *idx, /* o : index in unmapped domain */ Word16 ii[2], /* i/o: coefficient indexes Q0*/ Word32 *pp, /* o : peak(1)/hole(0) indicator Q0*/ Word16 *idx, /* o : index in unmapped domain Q0*/ CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ ) { UWord32 p; p = s_and( sub( ii[1], hm_cfg->numPeakIndices ), sub( hm_cfg->indexBuffer[ii[1]], hm_cfg->indexBuffer[ii[0]] ) ); p = UL_lshr( p, sub( sizeof( p ) * 8, 1 ) ); *pp = p; p = s_and( sub( ii[1], hm_cfg->numPeakIndices ), sub( hm_cfg->indexBuffer[ii[1]], hm_cfg->indexBuffer[ii[0]] ) ); /* Q0 */ p = UL_lshr( p, sub( sizeof( p ) * 8, 1 ) ); /* Q0 */ *pp = p; /* Q0 */ move32(); *idx = ii[p]; *idx = ii[p]; /* Q0 */ move16(); ii[p] = add( ii[p], 1 ); ii[p] = add( ii[p], 1 ); /* Q0 */ move16(); return hm_cfg->indexBuffer[*idx]; Loading
lib_com/ACcontextMapping_fx.c +28 −22 Original line number Diff line number Diff line Loading @@ -11,15 +11,15 @@ /* Returns: index of next coefficient */ Word16 get_next_coeff_mapped( Word16 ii[2], /* i/o: coefficient indexes */ Word16 *pp, /* o : peak(1)/hole(0) indicator */ Word16 *idx, /* o : index in unmapped domain */ Word16 ii[2], /* i/o: coefficient indexes Q0*/ Word16 *pp, /* o : peak(1)/hole(0) indicator Q0*/ Word16 *idx, /* o : index in unmapped domain Q0*/ CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ ) { Word16 p; p = s_and( sub( ii[1], hm_cfg->numPeakIndices ), sub( hm_cfg->indexBuffer[ii[1]], hm_cfg->indexBuffer[ii[0]] ) ); p = s_and( sub( ii[1], hm_cfg->numPeakIndices ), sub( hm_cfg->indexBuffer[ii[1]], hm_cfg->indexBuffer[ii[0]] ) ); /* Q0 */ if ( p > 0 ) { p = 0; Loading @@ -30,63 +30,69 @@ Word16 get_next_coeff_mapped( p = 1; move16(); } *pp = p; *pp = p; /* Q0 */ move16(); *idx = ii[p]; *idx = ii[p]; /* Q0 */ move16(); ii[p] = add( ii[p], 1 ); ii[p] = add( ii[p], 1 ); /* Q0 */ move16(); return hm_cfg->indexBuffer[*idx]; } /* Returns: index of next coefficient */ Word16 get_next_coeff_unmapped( Word16 ii[2], /* i/o: coefficient indexes */ Word16 *pp, /* o : peak(1)/hole(0) indicator */ Word16 *idx, /* o : index in unmapped domain */ Word16 ii[2], /* i/o: coefficient indexes Q0*/ Word16 *pp, /* o : peak(1)/hole(0) indicator Q0*/ Word16 *idx, /* o : index in unmapped domain Q0*/ CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ ) { (void) pp; (void) hm_cfg; *idx = ii[0]; *idx = ii[0]; /* Q0 */ move16(); ii[0] = add( ii[0], 1 ); ii[0] = add( ii[0], 1 ); /* Q0 */ move16(); return *idx; } Word16 update_mixed_context( Word16 ctx, Word16 a ) Word16 update_mixed_context( Word16 ctx, /* Q0 */ Word16 a /* Q0 */ ) { Word32 t32; Word16 t = 0; /* initialize just to avoid compiler warning */ t32 = L_mac0( 1 - 13, s_and( a, ~1 ), add( shr( a, 2 ), 1 ) ); t32 = L_mac0( 1 - 13, s_and( a, ~1 ), add( shr( a, 2 ), 1 ) ); /* Q0 */ if ( t32 <= 0 ) { t = extract_l( t32 ); t = extract_l( t32 ); /* Q0 */ } a = shr( a, 3 ); if ( t32 > 0 ) { t = s_min( a, 2 ); t = s_min( a, 2 ); /* Q0 */ } return add( shl( s_and( ctx, 0xf ), 4 ), add( t, 13 ) ); } #ifdef IVAS_FLOAT_FIXED Word32 update_mixed_context_ivas_fx( Word32 ctx, Word16 a ) Word32 update_mixed_context_ivas_fx( Word32 ctx, /* Q0 */ Word16 a /* Q0 */ ) { Word32 t32; t32 = L_mac0( 1 - 13, s_and( a, ~1 ), add( shr( a, 2 ), 1 ) ); t32 = L_mac0( 1 - 13, s_and( a, ~1 ), add( shr( a, 2 ), 1 ) ); /* Q0 */ a = shr( a, 3 ); a = shr( a, 3 ); /* Q0 */ IF( t32 > 0 ) { t32 = L_min( a, 2 ); t32 = L_min( a, 2 ); /* Q0 */ } return L_add( L_shl( L_and( ctx, 0xf ), 4 ), L_add( t32, 13 ) ); } Loading
lib_com/ari_fx.c +4 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,10 @@ Word32 L_multi31x16_X2( Word16 xh, Word16 xl, Word16 y ) * * \return r*c */ Word32 mul_sbc_14bits( Word32 r, Word16 c ) Word32 mul_sbc_14bits( Word32 r, /* Q0 */ Word16 c /* Q0 */ ) { Word32 ret; Loading
lib_com/ari_hm.c +73 −71 Original line number Diff line number Diff line Loading @@ -101,12 +101,13 @@ void UnmapIndex_ivas( } void UnmapIndex_fx( const Word16 PeriodicityIndex, const Word16 Bandwidth, const Word16 LtpPitchLag, const Word8 SmallerLags, Word16 *FractionalResolution, Word32 *Lag ) const Word16 PeriodicityIndex, /* Q0 */ const Word16 Bandwidth, /* Q0 */ const Word16 LtpPitchLag, /* Q0 */ const Word8 SmallerLags, /* Q0 */ Word16 *FractionalResolution, /* Q0 */ Word32 *Lag /* Q0 */ ) { Word16 LtpPitchIndex, Multiplier; Word16 Lag16; Loading @@ -114,54 +115,54 @@ void UnmapIndex_fx( test(); IF( ( LtpPitchLag > 0 ) && ( s_and( PeriodicityIndex, kLtpHmFlag ) != 0 ) ) { LtpPitchIndex = shr( PeriodicityIndex, 9 ); Multiplier = s_and( PeriodicityIndex, 0xff ); LtpPitchIndex = shr( PeriodicityIndex, 9 ); /* Q0 */ Multiplier = s_and( PeriodicityIndex, 0xff ); /* Q0 */ assert( 0 <= LtpPitchIndex && LtpPitchIndex <= 16 ); assert( 1 <= Multiplier && Multiplier <= ( 1 << NumRatioBits[Bandwidth][LtpPitchIndex] ) ); *FractionalResolution = kLtpHmFractionalResolution; *FractionalResolution = kLtpHmFractionalResolution; /* Q0 */ move16(); *Lag = L_shr( L_mult0( LtpPitchLag, Ratios_fx[Bandwidth][LtpPitchIndex][Multiplier - 1] ), 8 ); *Lag = L_shr( L_mult0( LtpPitchLag, Ratios_fx[Bandwidth][LtpPitchIndex][Multiplier - 1] ), 8 ); /* Q0 */ move32(); } ELSE { IF( LT_16( PeriodicityIndex, 16 ) ) { *FractionalResolution = 3; *FractionalResolution = 3; /* Q0 */ move16(); Lag16 = add( PeriodicityIndex, GET_ADJ2( 0, 6, 3 ) ); Lag16 = add( PeriodicityIndex, GET_ADJ2( 0, 6, 3 ) ); /* Q0 */ } ELSE IF( LT_16( PeriodicityIndex, 80 ) ) { *FractionalResolution = 4; *FractionalResolution = 4; /* Q0 */ move16(); Lag16 = add( PeriodicityIndex, GET_ADJ2( 16, 8, 4 ) ); Lag16 = add( PeriodicityIndex, GET_ADJ2( 16, 8, 4 ) ); /* Q0 */ } ELSE IF( LT_16( PeriodicityIndex, 208 ) ) { *FractionalResolution = 3; *FractionalResolution = 3; /* Q0 */ move16(); Lag16 = add( PeriodicityIndex, GET_ADJ2( 80, 12, 3 ) ); Lag16 = add( PeriodicityIndex, GET_ADJ2( 80, 12, 3 ) ); /* Q0 */ } ELSE { test(); IF( LT_16( PeriodicityIndex, 224 ) || SmallerLags != 0 ) { *FractionalResolution = 1; *FractionalResolution = 1; /* Q0 */ move16(); Lag16 = add( PeriodicityIndex, GET_ADJ2( 208, 28, 1 ) ); Lag16 = add( PeriodicityIndex, GET_ADJ2( 208, 28, 1 ) ); /* Q0 */ } ELSE { *FractionalResolution = 0; move16(); Lag16 = add( PeriodicityIndex, GET_ADJ2( 224, 188, 0 ) ); Lag16 = add( PeriodicityIndex, GET_ADJ2( 224, 188, 0 ) ); /* Q0 */ } } *Lag = L_deposit_l( Lag16 ); *Lag = L_deposit_l( Lag16 ); /* Q0 */ } } Loading Loading @@ -262,19 +263,20 @@ int16_t CountIndexBits_ivas( } Word16 CountIndexBits_fx( Word16 Bandwidth, Word16 PeriodicityIndex ) Word16 Bandwidth, /* Q0 */ Word16 PeriodicityIndex /* Q0 */ ) { Word16 result; Word16 PeriodicityIndexS; result = 8; result = 8; /* Q0 */ move16(); PeriodicityIndexS = shr( PeriodicityIndex, 9 ); PeriodicityIndexS = shr( PeriodicityIndex, 9 ); /* Q0 */ if ( s_and( PeriodicityIndex, kLtpHmFlag ) != 0 ) { result = NumRatioBits[Bandwidth][PeriodicityIndexS]; result = NumRatioBits[Bandwidth][PeriodicityIndexS]; /* Q0 */ move16(); } Loading @@ -290,9 +292,9 @@ Word16 CountIndexBits_fx( *-------------------------------------------------------------------*/ Word16 tcx_hm_render_ivas( const Word16 lag, /* i : pitch lag */ const Word16 fract_res, /* i : fractional resolution of the lag */ Word16 p[] /* o : harmonic model (Q13) */ const Word16 lag, /* i : pitch lag Q0*/ const Word16 fract_res, /* i : fractional resolution of the lag Q0*/ Word16 p[] /* o : harmonic model Q13*/ ) { Word16 k; Loading @@ -305,13 +307,13 @@ Word16 tcx_hm_render_ivas( tmp32 = Mpy_32_16_1( f0, -26474 ); tmp32 = L_shr_r( BASOP_Util_InvLog2( L_shl( tmp32, 7 ) ), 2 ); tmp32 = L_sub( 603979776L, tmp32 ); tmp32 = L_add( L_add( tmp32, tmp32 ), Mpy_32_16_1( tmp32, 26214 ) ); tmp32 = L_sub( 603979776L /* 1.125 in Q29 */, tmp32 ); /* Q29 */ tmp32 = L_add( L_add( tmp32, tmp32 ), Mpy_32_16_1( tmp32, 26214 /* 0.8 in Q15 */ ) ); /* Q29 */ height = round_fx( tmp32 ); /* Q13 */ tmp32 = Mpy_32_16_1( f0, -18910 ); tmp32 = L_shr_r( BASOP_Util_InvLog2( L_shl( tmp32, 7 ) ), 2 ); tmp32 = L_sub( 1395864371L, tmp32 ); tmp32 = L_shr_r( BASOP_Util_InvLog2( L_shl( tmp32, 7 ) ), 2 ); /* Q30 */ tmp32 = L_sub( 1395864371L /* 1.3 in Q30 */, tmp32 ); /* Q30 */ PeakDeviation = round_fx( tmp32 ); /* Q14 */ IF( sub( 13915, PeakDeviation ) > 0 ) Loading @@ -321,22 +323,22 @@ Word16 tcx_hm_render_ivas( } ELSE { tmp = div_s( 13915, PeakDeviation ); tmp = div_s( 13915, PeakDeviation ); /* Q15 */ tmp = mult_r( tmp, tmp ); /* Q15 */ } /* Render the prototype peak */ p[kTcxHmParabolaHalfWidth] = height; p[kTcxHmParabolaHalfWidth] = height; /* Q13 */ move16(); FOR( k = 1; k <= kTcxHmParabolaHalfWidth; ++k ) { p[kTcxHmParabolaHalfWidth + k] = round_fx( Mpy_32_16_1( BASOP_Util_InvLog2( L_shl( L_mult0( mult0( negate( k ), k ), tmp ), 10 ) ), height ) ); p[kTcxHmParabolaHalfWidth + k] = round_fx( Mpy_32_16_1( BASOP_Util_InvLog2( L_shl( L_mult0( mult0( negate( k ), k ), tmp ), 10 ) ), height ) ); /* Q13 */ } /* Mirror */ FOR( k = -kTcxHmParabolaHalfWidth; k < 0; ++k ) { p[kTcxHmParabolaHalfWidth + k] = p[kTcxHmParabolaHalfWidth - k]; p[kTcxHmParabolaHalfWidth + k] = p[kTcxHmParabolaHalfWidth - k]; /* Q13 */ } return 0; Loading @@ -356,14 +358,14 @@ Word32 tcx_hm_render_fx( f0 = L_shl( lag, sub( 15, fract_res ) ); /* Q31 */ tmp32 = Mpy_32_16_1( f0, -26474 ); tmp32 = L_shr_r( BASOP_Util_InvLog2( L_shl( tmp32, 7 ) ), 2 ); tmp32 = L_sub( 603979776L, tmp32 ); tmp32 = L_add( L_add( tmp32, tmp32 ), Mpy_32_16_1( tmp32, 26214 ) ); tmp32 = L_shr_r( BASOP_Util_InvLog2( L_shl( tmp32, 7 ) ), 2 ); /* Q29 */ tmp32 = L_sub( 603979776L /* 1.125 in Q29 */, tmp32 ); /* Q29 */ tmp32 = L_add( L_add( tmp32, tmp32 ), Mpy_32_16_1( tmp32, 26214 /* 0.8 in Q15 */ ) ); /* Q29 */ height = round_fx( tmp32 ); /* Q13 */ tmp32 = Mpy_32_16_1( f0, -18910 ); tmp32 = L_shr_r( BASOP_Util_InvLog2( L_shl( tmp32, 7 ) ), 2 ); tmp32 = L_sub( 1395864371L, tmp32 ); tmp32 = L_shr_r( BASOP_Util_InvLog2( L_shl( tmp32, 7 ) ), 2 ); /* Q30 */ tmp32 = L_sub( 1395864371L /* 1.3 in Q30 */, tmp32 ); /* Q30 */ PeakDeviation = round_fx( tmp32 ); /* Q14 */ IF( GT_16( 13915, PeakDeviation ) ) Loading @@ -373,11 +375,11 @@ Word32 tcx_hm_render_fx( } ELSE { tmp = div_s( 13915, PeakDeviation ); tmp = div_s( 13915, PeakDeviation ); /* Q15 */ tmp = mult_r( tmp, tmp ); /* Q15 */ } tmp = div_s( 13915, PeakDeviation ); tmp = div_s( 13915, PeakDeviation ); /* Q15 */ tmp = mult_r( tmp, tmp ); /* Q15 */ /* Render the prototype peak */ Loading @@ -386,12 +388,12 @@ Word32 tcx_hm_render_fx( FOR( k = 1; k <= kTcxHmParabolaHalfWidth; ++k ) { p[kTcxHmParabolaHalfWidth + k] = round_fx( Mpy_32_16_1( BASOP_Util_InvLog2( L_shl( L_mult0( i_mult2( negate( k ), k ), tmp ), 10 ) ), height ) ); p[kTcxHmParabolaHalfWidth + k] = round_fx( Mpy_32_16_1( BASOP_Util_InvLog2( L_shl( L_mult0( i_mult2( negate( k ), k ), tmp ), 10 ) ), height ) ); /* Q13 */ } /* Mirror */ FOR( k = -kTcxHmParabolaHalfWidth; k < 0; ++k ) { p[kTcxHmParabolaHalfWidth + k] = p[kTcxHmParabolaHalfWidth - k]; p[kTcxHmParabolaHalfWidth + k] = p[kTcxHmParabolaHalfWidth - k]; /* Q13 */ move16(); } Loading @@ -405,12 +407,12 @@ Word32 tcx_hm_render_fx( *-------------------------------------------------------------------*/ void tcx_hm_modify_envelope_ivas( const Word16 gain, /* i : HM gain (Q11) */ const Word16 lag, const Word16 fract_res, const Word16 p[], /* i : harmonic model (Q13) */ Word32 env[], /* i/o: envelope (Q16) */ const Word16 L_frame /* i : number of spectral lines */ const Word16 gain, /* i : HM gain Q11*/ const Word16 lag, /* Q0 */ const Word16 fract_res, /* Q0 */ const Word16 p[], /* i : harmonic model Q13*/ Word32 env[], /* i/o: envelope Q16*/ const Word16 L_frame /* i : number of spectral lines Q0*/ ) { Word16 k, h, x; Loading @@ -423,7 +425,7 @@ void tcx_hm_modify_envelope_ivas( FOR( k = 0; k < 2 * kTcxHmParabolaHalfWidth + 1; ++k ) { inv_shape[k] = div_s( 512, add( 512, round_fx( L_mult( gain, p[k] ) ) ) ); inv_shape[k] = div_s( 512 /* 1 in Q24 */, add( 512 /* 1 in Q24 */, round_fx( L_mult( gain, p[k] ) ) ) ); /* Q15 */ move16(); } Loading @@ -435,11 +437,11 @@ void tcx_hm_modify_envelope_ivas( FOR( x = max( 0, k - kTcxHmParabolaHalfWidth ); x <= min( k + kTcxHmParabolaHalfWidth, L_frame - 1 ); ++x ) { env[x] = Mpy_32_16_1( env[x], inv_shape[x - k + kTcxHmParabolaHalfWidth] ); env[x] = Mpy_32_16_1( env[x], inv_shape[x - k + kTcxHmParabolaHalfWidth] ); /* Q16 */ move32(); } ++h; k = extract_l( L_shr( L_mult0( h, lag ), fract_res ) ); h = add( h, 1 ); /* Q0 */ k = extract_l( L_shr( L_mult0( h, lag ), fract_res ) ); /* Q0 */ } return; Loading @@ -465,7 +467,7 @@ void tcx_hm_modify_envelope_fx( FOR( k = 0; k < 2 * kTcxHmParabolaHalfWidth + 1; ++k ) { /* Q24 = Q11 * Q13; 512 = 1.0 in Q24 format */ inv_shape[k] = div_s( 512, add( 512, mult_r( gain, p[k] ) ) ); inv_shape[k] = div_s( 512, add( 512, mult_r( gain, p[k] ) ) ); /* Q15 */ move16(); } Loading @@ -473,21 +475,21 @@ void tcx_hm_modify_envelope_fx( move16(); k = extract_l( L_shr( lag, fract_res ) ); L_frame_m1 = sub( L_frame, 1 ); L_frame_for_loop = add( L_frame, kTcxHmParabolaHalfWidth - 1 ); L_frame_m1 = sub( L_frame, 1 ); /* Q0 */ L_frame_for_loop = add( L_frame, kTcxHmParabolaHalfWidth - 1 ); /* Q0 */ WHILE( LE_16( k, L_frame_for_loop ) ) WHILE( k <= L_frame_for_loop ) { l1 = s_max( 0, sub( k, kTcxHmParabolaHalfWidth ) ); l2 = s_min( add( k, kTcxHmParabolaHalfWidth ), L_frame_m1 ); l1 = s_max( 0, sub( k, kTcxHmParabolaHalfWidth ) ); /* Q0 */ l2 = s_min( add( k, kTcxHmParabolaHalfWidth ), L_frame_m1 ); /* Q0 */ FOR( x = l1; x <= l2; ++x ) { env[x] = Mpy_32_16_1( env[x], inv_shape[x - k + kTcxHmParabolaHalfWidth] ); env[x] = Mpy_32_16_1( env[x], inv_shape[x - k + kTcxHmParabolaHalfWidth] ); /* Q16 */ move32(); } h = add( h, 1 ); k = extract_l( L_shr( imult3216( lag, h ), fract_res ) ); h = add( h, 1 ); /* Q0 */ k = extract_l( L_shr( imult3216( lag, h ), fract_res ) ); /* Q0 */ } } Loading
lib_com/ari_hm_fx.c +65 −63 File changed.Preview size limit exceeded, changes collapsed. Show changes