diff --git a/apps/decoder.c b/apps/decoder.c index a5927d06e4adbe65cf9735f1e2a1420d00ba2a9a..fb053dba8f5a4ddfd62e176f13c1d0e6651a2e72 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1616,6 +1616,38 @@ static void usage_dec( void ) } +/*---------------------------------------------------------------------* + * resetHeadRotation() + * + * + *---------------------------------------------------------------------*/ + +static void resetHeadRotation( + const int16_t num_subframes, /* i : number of subframes */ + IVAS_QUATERNION *pQuaternion, /* o : head-tracking data */ + IVAS_VECTOR3 *pPos /* o : listener position */ + +) +{ + int16_t i; + + for ( i = 0; i < num_subframes; i++ ) + { + pQuaternion[i].w_fx = -12582912; + pQuaternion[i].x_fx = 0; + pQuaternion[i].y_fx = 0; + pQuaternion[i].z_fx = 0; + pQuaternion[i].q_fact = 22; + pPos[i].x_fx = 0; + pPos[i].y_fx = 0; + pPos[i].z_fx = 0; + pPos[i].q_fact = 25; + } + + return; +} + + /*---------------------------------------------------------------------* * initOnFirstGoodFrame() * @@ -2093,7 +2125,6 @@ static ivas_error decodeG192( while ( 1 ) { - /* Read next frame if not enough samples availble */ /* reference vector */ if ( arg.enableReferenceVectorTracking && vec_pos_update == 0 ) { @@ -2140,18 +2171,7 @@ static ivas_error decodeG192( { if ( headRotReader == NULL ) { - for ( i = 0; i < (int16_t) num_subframes; i++ ) - { - Quaternions[i].w_fx = -12582912; - Quaternions[i].x_fx = 0; - Quaternions[i].y_fx = 0; - Quaternions[i].z_fx = 0; - Quaternions[i].q_fact = 22; - Pos[i].x_fx = 0; - Pos[i].y_fx = 0; - Pos[i].z_fx = 0; - Pos[i].q_fact = 25; - } + resetHeadRotation( num_subframes, Quaternions, Pos ); } else { @@ -2327,9 +2347,6 @@ static ivas_error decodeG192( fprintf( stderr, "\nError in IVAS_DEC_GetSplitBinauralBitstream: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } - - nSamplesRendered += nSamplesRendered_loop; - nSamplesToRender -= nSamplesRendered_loop; } else { @@ -2338,12 +2355,13 @@ static ivas_error decodeG192( fprintf( stderr, "\nError in IVAS_DEC_GetSamplesRenderer(): %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } - nSamplesRendered += nSamplesRendered_loop; - nSamplesToRender -= nSamplesRendered_loop; } + + nSamplesRendered += nSamplesRendered_loop; + nSamplesToRender -= nSamplesRendered_loop; + if ( needNewFrame ) { - frame++; if ( !arg.quietModeEnabled ) { @@ -2352,7 +2370,6 @@ static ivas_error decodeG192( } } while ( nSamplesRendered < nOutSamples && error == IVAS_ERR_OK ); - if ( error == IVAS_ERR_END_OF_FILE ) { break; @@ -2412,7 +2429,7 @@ static ivas_error decodeG192( } } - /* Write ISm metadata to external file(s) */ + /* Write ISM metadata to external file(s) */ if ( decodedGoodFrame && arg.outputConfig == IVAS_AUDIO_CONFIG_EXTERNAL ) { if ( bsFormat == IVAS_DEC_BS_OBJ || bsFormat == IVAS_DEC_BS_MASA_ISM || bsFormat == IVAS_DEC_BS_SBA_ISM ) @@ -2452,6 +2469,7 @@ static ivas_error decodeG192( { fprintf( stderr, "\nUnable to get delay of decoder: %s\n", ivas_error_to_string( error ) ); } + if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 0 ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -2486,8 +2504,6 @@ static ivas_error decodeG192( { int16_t nSamplesFlushed; - /* Feed into decoder */ - /* reference vector */ if ( arg.enableReferenceVectorTracking ) { @@ -2553,7 +2569,7 @@ static ivas_error decodeG192( } } - /* decode and get samples */ + /* flush remaining audio */ if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_VoIP_Flush: %s\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -2567,7 +2583,7 @@ static ivas_error decodeG192( goto cleanup; } - /* Write ISm metadata to external file(s) */ + /* Write ISM metadata to external file(s) */ if ( decodedGoodFrame && arg.outputConfig == IVAS_AUDIO_CONFIG_EXTERNAL ) { if ( bsFormat == IVAS_DEC_BS_OBJ || bsFormat == IVAS_DEC_BS_MASA_ISM || bsFormat == IVAS_DEC_BS_SBA_ISM ) @@ -2606,6 +2622,7 @@ static ivas_error decodeG192( { fprintf( stderr, "\nUnable to get delay of decoder: %s\n", ivas_error_to_string( error ) ); } + if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 0 ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -2708,14 +2725,22 @@ cleanup: return error; } - #ifdef SUPPORT_JBM_TRACEFILE -static ivas_error writeJbmTraceFileFrameWrapper( const void *data, void *writer ) + +/*---------------------------------------------------------------------* + * writeJbmTraceFileFrameWrapper() + * + * + *---------------------------------------------------------------------*/ + +static ivas_error writeJbmTraceFileFrameWrapper( + const void *data, + void *writer ) { return JbmTraceFileWriter_writeFrame( data, writer ); } -#endif +#endif /*---------------------------------------------------------------------* * decodeVoIP() @@ -2813,11 +2838,13 @@ static ivas_error decodeVoIP( fprintf( stderr, "\nError getting render frame size in samples\n" ); return error; } + if ( ( error = IVAS_DEC_GetRenderFramesizeSamples( hIvasDec, &nOutSamples ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError getting render frame size in samples\n" ); return error; } + if ( ( error = IVAS_DEC_GetReferencesUpdateFrequency( hIvasDec, &vec_pos_len ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError getting render frame size in samples\n" ); @@ -2983,18 +3010,7 @@ static ivas_error decodeVoIP( { if ( headRotReader == NULL ) { - for ( i = 0; i < (int16_t) num_subframes; i++ ) - { - Quaternions[i].w_fx = -12582912; - Quaternions[i].x_fx = 0; - Quaternions[i].y_fx = 0; - Quaternions[i].z_fx = 0; - Quaternions[i].q_fact = 22; - Pos[i].x = 0.0f; - Pos[i].y = 0.0f; - Pos[i].z = 0.0f; - Pos[i].q_fact = 25; - } + resetHeadRotation( num_subframes, Quaternions, Pos ); } else { @@ -3030,8 +3046,7 @@ static ivas_error decodeVoIP( if ( ( error = ExternalOrientationFileReading( externalOrientationFileReader, &Quaternions[i], &enableHeadRotation[i], &enableExternalOrientation[i], &enableRotationInterpolation[i], &numFramesToTargetOrientation[i] ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nError %s while reading external orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), - RotationFileReader_getFilePath( externalOrientationFileReader ) ); + fprintf( stderr, "\nError %s while reading external orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), RotationFileReader_getFilePath( externalOrientationFileReader ) ); goto cleanup; } } @@ -3347,6 +3362,7 @@ static ivas_error decodeVoIP( { fprintf( stderr, "\nUnable to get delay of decoder: %s\n", ivas_error_to_string( error ) ); } + if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 1 ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -3418,7 +3434,7 @@ static ivas_error decodeVoIP( goto cleanup; } - /* Write ISm metadata to external file(s) */ + /* Write ISM metadata to external file(s) */ if ( decodedGoodFrame && arg.outputConfig == IVAS_AUDIO_CONFIG_EXTERNAL ) { if ( bsFormat == IVAS_DEC_BS_OBJ || bsFormat == IVAS_DEC_BS_MASA_ISM || bsFormat == IVAS_DEC_BS_SBA_ISM ) @@ -3458,6 +3474,7 @@ static ivas_error decodeVoIP( { fprintf( stderr, "\nUnable to get delay of decoder: %s\n", ivas_error_to_string( error ) ); } + if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 0 ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) ); diff --git a/lib_com/ari_hm_fx.c b/lib_com/ari_hm_fx.c index e35416e5ff223ad28cf3713e3fac1f745df2aee0..8a8df6f61be57a566705bc44b38a04a001e6349d 100644 --- a/lib_com/ari_hm_fx.c +++ b/lib_com/ari_hm_fx.c @@ -191,9 +191,9 @@ Word16 CountIndexBits( #define WMC_TOOL_SKIP Word32 tcx_hm_render( - Word32 lag, /* i: pitch lag Q0 */ - Word16 fract_res, /* i: fractional resolution of the lag Q0 */ - Word16 p[] /* o: harmonic model Q13 */ + Word32 lag, /* i : pitch lag Q0 */ + Word16 fract_res, /* i : fractional resolution of the lag Q0 */ + Word16 p[] /* o : harmonic model Q13 */ ) { Word16 k, tmp, height; @@ -249,12 +249,12 @@ Word32 tcx_hm_render( void tcx_hm_modify_envelope( - Word16 gain, /* i: HM gain Q11 */ - Word32 lag, /* i: pitch lag Q0 */ - Word16 fract_res, /* i: fractional resolution of the lag Q0 */ - Word16 p[], /* i: harmonic model Q13 */ + Word16 gain, /* i : HM gain Q11 */ + Word32 lag, /* i : pitch lag Q0 */ + Word16 fract_res, /* i : fractional resolution of the lag Q0 */ + Word16 p[], /* i : harmonic model Q13 */ Word32 env[], /* i/o: envelope Q16 */ - Word16 L_frame /* i: number of spectral lines Q0 */ + Word16 L_frame /* i : number of spectral lines Q0 */ ) { Word16 k, h, x, l1, l2, L_frame_m1, L_frame_for_loop; @@ -292,6 +292,8 @@ void tcx_hm_modify_envelope( h = add( h, 1 ); /* Q0 */ k = extract_l( L_shr( imult3216( lag, h ), fract_res ) ); /* Q0 */ } + + return; } #undef WMC_TOOL_SKIP diff --git a/lib_com/arith_coder_fx.c b/lib_com/arith_coder_fx.c index 173e4faf3583ca941cc5cfe36f852c36f4a9947b..112eb5f795a491c9cd7dd24bb01a43e83d1bfb9e 100644 --- a/lib_com/arith_coder_fx.c +++ b/lib_com/arith_coder_fx.c @@ -11,9 +11,10 @@ #include "cnst.h" /* Fixed point implementation of exp(negate()) */ -Word32 expfp( /* o: Q31 */ - const Word16 x, /* i: mantissa Q-e */ - const Word16 x_e ) /* i: exponent Q0 */ +/* o: Q31 */ +Word32 expfp( + const Word16 x, /* i : mantissa Q-e */ + const Word16 x_e ) /* i : exponent Q0 */ { Word16 xi, xf, tmp; Word16 b0, b1, b2, b3; @@ -177,14 +178,15 @@ void powfp_odd2( * NOTE: This function must be bit-exact on all platforms such that encoder * and decoder remain synchronized. *-------------------------------------------------------------------------*/ + void tcx_arith_scale_envelope( - const Word16 L_spec_core, /* i: number of lines to scale Q0 */ - Word16 L_frame, /* i: number of lines Q0 */ - const Word32 env[], /* i: unscaled envelope Q16 */ - Word16 target_bits, /* i: number of available bits Q0 */ - const Word16 low_complexity, /* i: low-complexity flag Q0 */ - Word16 s_env[], /* o: scaled envelope Q15-e */ - Word16 *s_env_e /* o: scaled envelope exponent Q0 */ + const Word16 L_spec_core, /* i : number of lines to scale Q0 */ + Word16 L_frame, /* i : number of lines Q0 */ + const Word32 env[], /* i : unscaled envelope Q16 */ + Word16 target_bits, /* i : number of available bits Q0 */ + const Word16 low_complexity, /* i : low-complexity flag Q0 */ + Word16 s_env[], /* o : scaled envelope Q15-e */ + Word16 *s_env_e /* o : scaled envelope exponent Q0 */ ) { Word32 ienv[N_MAX_ARI]; @@ -412,8 +414,11 @@ void tcx_arith_scale_envelope( s_env[k] = round_fx( L_tmp ); /* Q15 - e */ move16(); } + + return; } + /*------------------------------------------------------------------------ * Function: tcx_arith_render_envelope * @@ -426,14 +431,15 @@ void tcx_arith_scale_envelope( * NOTE: This function must be bit-exact on all platforms such that encoder * and decoder remain synchronized. *-------------------------------------------------------------------------*/ + void tcx_arith_render_envelope( - const Word16 A_ind[], /* i: LPC coefficients of signal envelope Q12*/ - const Word16 L_frame, /* i: number of spectral lines Q0*/ + const Word16 A_ind[], /* i : LPC coefficients of signal envelope Q12*/ + const Word16 L_frame, /* i : number of spectral lines Q0*/ const Word16 L_spec, /* Q0 */ - const Word16 preemph_fac, /* i: pre-emphasis factor Q15*/ - const Word16 gamma_w, /* i: A_ind -> weighted envelope factor Q15*/ - const Word16 gamma_uw, /* i: A_ind -> non-weighted envelope factor Q14*/ - Word32 env[] /* o: shaped signal envelope Q16*/ + const Word16 preemph_fac, /* i : pre-emphasis factor Q15*/ + const Word16 gamma_w, /* i : A_ind -> weighted envelope factor Q15*/ + const Word16 gamma_uw, /* i : A_ind -> non-weighted envelope factor Q14*/ + Word32 env[] /* o : shaped signal envelope Q16*/ ) { Word16 k; @@ -463,10 +469,7 @@ void tcx_arith_render_envelope( /* Adaptive low frequency emphasis */ set32_fx( env, 0x10000 /* 1 in Q16 */, L_frame ); - AdaptLowFreqDeemph( env, 15, - 1, - gainlpc, gainlpc_e, - L_frame, NULL ); + AdaptLowFreqDeemph( env, 15, 1, gainlpc, gainlpc_e, L_frame, NULL ); /* Scale from FDNS_NPTS to L_frame and multiply LFE gains */ mdct_noiseShaping_interp( env, L_frame, signal_env, signal_env_e ); @@ -476,6 +479,8 @@ void tcx_arith_render_envelope( env[k] = env[k - 1]; /* Q16 */ move32(); } + + return; } #define WMC_TOOL_SKIP diff --git a/lib_com/bits_alloc_fx.c b/lib_com/bits_alloc_fx.c index 1045f7495bdbdea4cbeadd08d22fbbb6ba72b6f4..9a57728e2c57a41b0b9c55933b8a57e5d02da6d8 100644 --- a/lib_com/bits_alloc_fx.c +++ b/lib_com/bits_alloc_fx.c @@ -109,6 +109,8 @@ void BITS_ALLOC_init_config_acelp( pConfigAcelp->formant_tilt = 0; pConfigAcelp->voice_tilt = 2; } + + return; } @@ -120,9 +122,9 @@ void BITS_ALLOC_init_config_acelp( * return: bit demand */ Word16 BITS_ALLOC_config_acelp( - const Word16 bits_frame, /* i: remaining bit budget for the frame*/ - const Word16 coder_type, /* i: acelp coder type*/ - ACELP_config *pConfigAcelp, /* i/o: configuration structure of ACELP*/ + const Word16 bits_frame, /* i : remaining bit budget for the frame */ + const Word16 coder_type, /* i : acelp coder type */ + ACELP_config *pConfigAcelp, /* i/o: configuration structure of ACELP */ const Word16 narrowBand, /* i : narrowband flag */ const Word16 nb_subfr /* i : number of subframes */ ) @@ -132,7 +134,6 @@ Word16 BITS_ALLOC_config_acelp( Word16 i; Word16 remaining_bits, bits; - move16(); move16(); move16(); @@ -244,7 +245,6 @@ Word16 BITS_ALLOC_config_acelp( } bits = add( bits, pConfigAcelp->ltf_bits ); - FOR( i = 0; i < nb_subfr; i++ ) { pConfigAcelp->gains_mode[i] = ACELP_GAINS_MODE[mode_index][band_index][coder_type]; @@ -267,7 +267,6 @@ Word16 BITS_ALLOC_config_acelp( } /*Innovation*/ - IF( LT_16( bits_frame, bits ) ) { printf( "Warning: bits per frame too low\n" ); @@ -317,7 +316,7 @@ Word16 BITS_ALLOC_config_acelp( static Word16 BITS_ALLOC_adjust_generic( - const Word16 bits_frame, /*i: bit budget*/ + const Word16 bits_frame, /*i : bit budget*/ Word16 *fixed_cdk_index, const Word16 nb_subfr, const Word16 *pulseconfigbits, @@ -394,17 +393,16 @@ static Word16 BITS_ALLOC_adjust_generic( return mult_r( bitsused, inb_subfr ); } + static Word16 BITS_ALLOC_adjust_acelp_fixed_cdk( - const Word16 bits_frame, /*i: bit budget*/ + const Word16 bits_frame, /*i : bit budget*/ Word16 *fixed_cdk_index, const Word16 nb_subfr ) { Word16 bitsused; - bitsused = BITS_ALLOC_adjust_generic( bits_frame, fixed_cdk_index, nb_subfr, ACELP_CDK_BITS, ACELP_FIXED_CDK_NB ); - return bitsused; } diff --git a/lib_com/bitstream_fx.c b/lib_com/bitstream_fx.c index 8f985c6ce3aab483a1616de0a45e73e92ad04d00..634659c7f4c5d1d069847b96a7215018a9ba2761 100644 --- a/lib_com/bitstream_fx.c +++ b/lib_com/bitstream_fx.c @@ -4929,7 +4929,7 @@ void getPartialCopyInfo( *-------------------------------------------------------------------*/ void get_rfFlag( - Decoder_State *st, /* i: decoder state structure */ + Decoder_State *st, /* i : decoder state structure */ Word16 *rf_flag, /* o : check for the RF flag */ Word16 *nBits, Word16 *ind ) diff --git a/lib_com/hq2_core_com_fx.c b/lib_com/hq2_core_com_fx.c index 1331b31a172c7d0a914341f5288751c76e1ece2d..b8ae7880de966f9c8f81877cd86ac98214a53533 100644 --- a/lib_com/hq2_core_com_fx.c +++ b/lib_com/hq2_core_com_fx.c @@ -491,14 +491,14 @@ void reverse_transient_frame_energies_fx( *--------------------------------------------------------------------------*/ void spt_shorten_domain_pre_fx( - const Word16 band_start[], /* i: Starting position of sub band Q0*/ - const Word16 band_end[], /* i: End position of sub band Q0*/ - const Word16 prev_SWB_peak_pos[], /* i: Spectral peak Q0*/ - const Word16 BANDS, /* i: total number of bands Q0*/ - const Word32 L_bwe_br, /* i: bitrate information Q0*/ - Word16 new_band_start[], /* o: Starting position of new shorten sub band Q0*/ - Word16 new_band_end[], /* o: End position of new shorten sub band Q0*/ - Word16 new_band_width[] /* o: new sub band bandwidth Q0*/ + const Word16 band_start[], /* i : Starting position of sub band Q0*/ + const Word16 band_end[], /* i : End position of sub band Q0*/ + const Word16 prev_SWB_peak_pos[], /* i : Spectral peak Q0*/ + const Word16 BANDS, /* i : total number of bands Q0*/ + const Word32 L_bwe_br, /* i : bitrate information Q0*/ + Word16 new_band_start[], /* o : Starting position of new shorten sub band Q0*/ + Word16 new_band_end[], /* o : End position of new shorten sub band Q0*/ + Word16 new_band_width[] /* o : new sub band bandwidth Q0*/ ) { Word16 j; @@ -574,13 +574,13 @@ void spt_shorten_domain_pre_fx( *--------------------------------------------------------------------------*/ void spt_shorten_domain_band_save_fx( - const Word16 bands, /* i: total subband Q0*/ - const Word16 band_start[], /* i: starting position of subband Q0*/ - const Word16 band_end[], /* i: end position of subband Q0*/ - const Word16 band_width[], /* i: band width of subband Q0*/ - Word16 org_band_start[], /* o: starting position of subband Q0*/ - Word16 org_band_end[], /* o: end position of subband Q0*/ - Word16 org_band_width[] /* o: band width of subband Q0*/ + const Word16 bands, /* i : total subband Q0*/ + const Word16 band_start[], /* i : starting position of subband Q0*/ + const Word16 band_end[], /* i : end position of subband Q0*/ + const Word16 band_width[], /* i : band width of subband Q0*/ + Word16 org_band_start[], /* o : starting position of subband Q0*/ + Word16 org_band_end[], /* o : end position of subband Q0*/ + Word16 org_band_width[] /* o : band width of subband Q0*/ ) { Word16 k; @@ -605,17 +605,17 @@ void spt_shorten_domain_band_save_fx( /*--------------------------------------------------------------------------* * spt_shorten_domain_band_restore() * - * Restrore the subband information + * Restore the subband information *--------------------------------------------------------------------------*/ void spt_shorten_domain_band_restore_fx( - const Word16 bands, /* i: total subband Q0*/ - Word16 band_start[], /* i/o: starting position of subband Q0*/ - Word16 band_end[], /* i/o: end position of subband Q0*/ + const Word16 bands, /* i : total subband Q0*/ + Word16 band_start[], /* i/o: starting position of subband Q0*/ + Word16 band_end[], /* i/o: end position of subband Q0*/ Word16 band_width[], /* i/o: band width of subband Q0*/ - const Word16 org_band_start[], /* o: starting position of subband Q0*/ - const Word16 org_band_end[], /* o: end position of subband Q0*/ - const Word16 org_band_width[] /* o: band width of subband Q0*/ + const Word16 org_band_start[], /* o : starting position of subband Q0*/ + const Word16 org_band_end[], /* o : end position of subband Q0*/ + const Word16 org_band_width[] /* o : band width of subband Q0*/ ) { Word16 k; @@ -644,11 +644,11 @@ void spt_shorten_domain_band_restore_fx( *--------------------------------------------------------------------------*/ void spt_swb_peakpos_tmp_save_fx( - const Word32 L_y2[], /* i: coded spectral information Qx*/ - const Word16 bands, /* i: total number of bands Q0*/ - const Word16 band_start[], /* i: starting position of subband Q0*/ - const Word16 band_end[], /* i: end position of subband Q0*/ - Word16 prev_SWB_peak_pos_tmp[] /* o: spectral peaks Q0*/ + const Word32 L_y2[], /* i : coded spectral information Qx*/ + const Word16 bands, /* i : total number of bands Q0*/ + const Word16 band_start[], /* i : starting position of subband Q0*/ + const Word16 band_end[], /* i : end position of subband Q0*/ + Word16 prev_SWB_peak_pos_tmp[] /* o : spectral peaks Q0*/ ) { diff --git a/lib_com/index_pvq_opt_fx.c b/lib_com/index_pvq_opt_fx.c index e17e9c23eccb7ee8f2ff46888134c841be9f54ee..8e22672278a721c76821f6e4439b12487384bf29 100644 --- a/lib_com/index_pvq_opt_fx.c +++ b/lib_com/index_pvq_opt_fx.c @@ -364,18 +364,22 @@ static void a_u_fwd_fx( UWord32 *a_u_in, /*o Q0*/ u_kp1 = UL_lshr( a_u_in[k_val_in], 1 ); a_u_in[mem_size_m1] = UL_addNsD( 1U, UL_addNsD( u_kp1_prev, UL_addNsD( u_k_prev, u_kp1 ) ) ); /*Q0*/ move32(); + return; } + /*-------------------------------------------------------------------* * nm_h_prep_opt_fx() * * find and return N_MPVQ(n,k) and also offsets A(n, 0 to k ) and U(n,k+1). *-------------------------------------------------------------------*/ -static UWord32 nm_h_prep_opt_fx( /* o: Q0 msize for dim */ - Word16 dim_in, /* i: dimension */ - Word16 k_val_in, /* i: nb unit pulses */ - UWord32 *h /* o: Q0 A/U offsets array */ + +/* o: Q0 msize for dim */ +static UWord32 nm_h_prep_opt_fx( + Word16 dim_in, /* i : dimension */ + Word16 k_val_in, /* i : nb unit pulses */ + UWord32 *h /* o : Q0 A/U offsets array */ ) { Word16 mem_size_m1, k_val, tmp; @@ -489,11 +493,12 @@ static UWord32 nm_h_prep_opt_fx( /* o: Q0 msize for dim */ find first offset in range 0..k_val_in that is less than ind_in using a tree search with direct function calls [ or memory iteration] */ -static Word16 find_amp_split_offset_func_mem_fx( /* o: Q0 found k_value */ - UWord32 ind_in, - Word16 high, /* i: k_val_in (high bound) */ - H_FUNCM h_func_ptr, /* i: offset function pointer */ - UWord32 *UL_tmp_offset ) /* o: Q0 offset found */ +/* o: Q0 found k_value */ +static Word16 find_amp_split_offset_func_mem_fx( + UWord32 ind_in, + Word16 high, /* i : k_val_in (high bound) */ + H_FUNCM h_func_ptr, /* i : offset function pointer */ + UWord32 *UL_tmp_offset ) /* o : Q0 offset found */ { Word16 not_ready, low, k_test = 0; move16(); @@ -564,12 +569,12 @@ static Word16 get_lead_sign_fx( UWord32 *ind ) /*-------------------------------------------------------------------* * mind2vec_one_fx() *-------------------------------------------------------------------*/ + static void mind2vec_one_fx( - Word16 k_val_in, /* i: nb unit pulses */ - Word16 leading_sign, /* i: leading sign -1, 0, 1*/ - UWord32 ind, - /* i: index */ /* parameter needed as it is used in a function array */ - Word16 *vec_out /* o: pulse train */ + Word16 k_val_in, /* i : nb unit pulses */ + Word16 leading_sign, /* i : leading sign -1, 0, 1*/ + UWord32 ind, /* i : index ,* parameter needed as it is used in a function array */ + Word16 *vec_out /* o : pulse train */ ) { /* NB input k_val_in can be zero */ @@ -587,10 +592,10 @@ static void mind2vec_one_fx( } static void mind2vec_two_fx( - Word16 k_val_in, /* i: nb unit pulses */ - Word16 leading_sign, /* i: leading sign -1,0, 1 */ - UWord32 ind_in, /* i: index */ - Word16 *vec_out /* o: Q0 pulse train */ + Word16 k_val_in, /* i : nb unit pulses */ + Word16 leading_sign, /* i : leading sign -1,0, 1 */ + UWord32 ind_in, /* i : index */ + Word16 *vec_out /* o : Q0 pulse train */ ) { UWord32 UL_ind_tmp; @@ -623,11 +628,12 @@ static void mind2vec_two_fx( } } -static Word16 setval_update_sign_fx( Word16 k_delta, - Word16 k_max_local, - Word16 *leading_sign, - UWord32 *ind_in, - Word16 *vec_out ) +static Word16 setval_update_sign_fx( + Word16 k_delta, + Word16 k_max_local, + Word16 *leading_sign, + UWord32 *ind_in, + Word16 *vec_out ) { IF( k_delta != 0 ) { @@ -636,17 +642,20 @@ static Word16 setval_update_sign_fx( Word16 k_delta, move16(); k_max_local = sub( k_max_local, k_delta ); /*Q0*/ } + return k_max_local; /*Q0*/ } + /*-------------------------------------------------------------------* * mind2vec_three_fx() *-------------------------------------------------------------------*/ + static void mind2vec_three_fx( - Word16 k_max_local, /* i: nb unit pulses */ - Word16 leading_sign, /* i: leading sign */ - UWord32 ind_in, /* i: index */ - Word16 *vec_out /* Q0 o: pulse train */ + Word16 k_max_local, /* i : nb unit pulses */ + Word16 leading_sign, /* i : leading sign */ + UWord32 ind_in, /* i : index */ + Word16 *vec_out /* o : pulse train */ ) { /* @@ -672,21 +681,24 @@ static void mind2vec_three_fx( /* vec_out[0]= leading_sign*k_max_local; */ mind2vec_one_fx( k_max_local, leading_sign, ind_in, vec_out ); } + return; } + /*-------------------------------------------------------------------* * mind2vec_direct_fx , general function for direct decoding using direct funstions (no memory recursion) *-------------------------------------------------------------------*/ + static void mind2vec_direct_fx( - Word16 k_max_local, /* i: nb unit pulses */ - Word16 leading_sign, /* i: leading sign */ - UWord32 ind, /* i: index */ - H_FUNCM h_func_ptr, /* i : offset function */ - NDIM_FUNCM nd_func_ptr, /* i : next dimension function */ - Word16 *vec_out /* Q0 o: pulse train */ + Word16 k_max_local, /* i : nb unit pulses */ + Word16 leading_sign, /* i : leading sign */ + UWord32 ind, /* i : index */ + H_FUNCM h_func_ptr, /* i : offset function */ + NDIM_FUNCM nd_func_ptr, /* i : next dimension function */ + Word16 *vec_out /* o : pulse train */ ) { @@ -708,47 +720,54 @@ static void mind2vec_direct_fx( { mind2vec_one_fx( k_max_local, leading_sign, ind, vec_out ); } + return; } + /*-------------------------------------------------------------------* * mind2vec_four_fx() *-------------------------------------------------------------------*/ + static void mind2vec_four_fx( - Word16 k_val_in, /* i: nb unit pulses */ - Word16 leading_sign, /* i: leading sign */ - UWord32 ind_in, /* i: index */ - Word16 *vec_out /* Q0 o: pulse train */ + Word16 k_val_in, /* i : nb unit pulses */ + Word16 leading_sign, /* i : leading sign */ + UWord32 ind_in, /* i : index */ + Word16 *vec_out /* o : pulse train */ ) { mind2vec_direct_fx( k_val_in, leading_sign, ind_in, a_four_fx, mind2vec_three_fx, vec_out ); + return; } /*-------------------------------------------------------------------* * mind2vec_five_fx() *-------------------------------------------------------------------*/ + static void mind2vec_five_fx( - Word16 k_val_in, /* i: nb unit pulses */ - Word16 leading_sign, /* i: leading sign */ - UWord32 ind_in, /* i: index */ - Word16 *vec_out /* o: pulse train */ + Word16 k_val_in, /* i : nb unit pulses */ + Word16 leading_sign, /* i : leading sign */ + UWord32 ind_in, /* i : index */ + Word16 *vec_out /* o : pulse train */ ) { mind2vec_direct_fx( k_val_in, leading_sign, ind_in, a_five_fx, mind2vec_four_fx, vec_out ); + return; } /*-------------------------------------------------------------------* * mind2vec_fx() *-------------------------------------------------------------------*/ + static void mind2vec_fx( - Word16 dim_in, /* i: dimension */ - Word16 k_max_local, /* i: nb unit pulses */ - Word16 leading_sign, /* i: leading sign */ - UWord32 ind, /* i: index */ - Word16 *vec_out, /* Q0 o: pulse train */ - UWord32 *h_in /* i: offset vector A=1+2U */ + Word16 dim_in, /* i : dimension */ + Word16 k_max_local, /* i : nb unit pulses */ + Word16 leading_sign, /* i : leading sign */ + UWord32 ind, /* i : index */ + Word16 *vec_out, /* o : pulse train */ + UWord32 *h_in /* i : offset vector A=1+2U */ ) { Word16 pos, k_acc, k_delta; @@ -801,10 +820,12 @@ static void mind2vec_fx( * unsigned int h_mem[1 + KMAX +1 ]; * example using fixed size of offset vector input help variable *-------------------------------------------------------------------*/ -PvqEntry get_size_mpvq_calc_offset_fx( /* o : size, dim, k_val */ - Word16 dim_in, /* i : dimension */ - Word16 k_val_in, /* i : nb unit pulses */ - UWord32 *h_mem /* Q0 o : offsets */ + +/* o : size, dim, k_val */ +PvqEntry get_size_mpvq_calc_offset_fx( + Word16 dim_in, /* i : dimension */ + Word16 k_val_in, /* i : nb unit pulses */ + UWord32 *h_mem /* o : offsets */ ) { PvqEntry entry; @@ -832,13 +853,15 @@ PvqEntry get_size_mpvq_calc_offset_fx( /* o : size, dim, k_val return entry; /*Q0*/ } + /*-------------------------------------------------------------------* * mpvq_decode_vec_fx() *-------------------------------------------------------------------*/ -void mpvq_decode_vec_fx( /* o : void */ - const PvqEntry *entry, /* i : sign_ind, index, dim, k_val */ - UWord32 *h_mem, /* i : A/U offsets */ - Word16 *vec_out /* Q0 o : pulse train */ + +void mpvq_decode_vec_fx( + const PvqEntry *entry, /* i : sign_ind, index, dim, k_val */ + UWord32 *h_mem, /* i : A/U offsets */ + Word16 *vec_out /* o : pulse train */ ) { Word16 i, leading_sign; @@ -875,15 +898,16 @@ void mpvq_decode_vec_fx( /* o : void return; } + /*-------------------------------------------------------------------* * vec2mind_one_fx() *-------------------------------------------------------------------*/ + static void vec2mind_one_fx( - const Word16 *vec_in, /* i : PVQ pulse train */ - Word16 *k_val_out_ptr, - /* Q0 o : number of unit pulses */ /* parameter needed as it is used in a function array */ - UWord32 *next_sign_ind, /* i/o: next sign ind */ - UWord32 *ind /* Q0 o: MPVQ index */ + const Word16 *vec_in, /* i : PVQ pulse train */ + Word16 *k_val_out_ptr, /* o : number of unit pulses, parameter needed as it is used in a function array */ + UWord32 *next_sign_ind, /* i/o: next sign ind */ + UWord32 *ind /* o : MPVQ index */ ) { *ind = (Word32) ( *k_val_out_ptr ); /* dummy assignment to avoid gcc "unused parameter" warning for *k_val_out_ptr, i.e no move32 needed() */ @@ -898,17 +922,19 @@ static void vec2mind_one_fx( *next_sign_ind = UL_deposit_l( 1 ); /*single basicop */ /*Q0*/ move32(); } + return; } /*-------------------------------------------------------------------* * vec2mind_two_fx() *-------------------------------------------------------------------*/ + static void vec2mind_two_fx( - const Word16 *vec_in, /* i : PVQ pulse train */ - Word16 *k_val_out_ptr, /* Q0 o : number of unit pulses */ - UWord32 *next_sign_ind, /* Q0 i/o: next sign ind */ - UWord32 *ind /* Q0 o: MPVQ index */ + const Word16 *vec_in, /* i : PVQ pulse train */ + Word16 *k_val_out_ptr, /* o : number of unit pulses */ + UWord32 *next_sign_ind, /* i/o: next sign ind */ + UWord32 *ind /* o : MPVQ index */ ) { UWord32 lead_sign_ind_add; @@ -967,10 +993,14 @@ static void vec2mind_two_fx( move32(); } } + return; } -static void enc_push_sign( Word16 val, UWord32 *next_sign_ind, UWord32 *index ) +static void enc_push_sign( + Word16 val, + UWord32 *next_sign_ind, + UWord32 *index ) { /* % Check if the leading sign 'bit' is to be added @@ -996,6 +1026,8 @@ static void enc_push_sign( Word16 val, UWord32 *next_sign_ind, UWord32 *index ) *next_sign_ind = UL_deposit_l( 0 ); /* single basicop */ move32(); } + + return; } /*-------------------------------------------------------------------* @@ -1004,12 +1036,12 @@ static void enc_push_sign( Word16 val, UWord32 *next_sign_ind, UWord32 *index ) *-------------------------------------------------------------------*/ static void vec2mind_gen345_fx( - const Word16 *vec_in, /* i : PVQ abs pulse train */ - Word16 *k_val_out_ptr, /* Q0 o : number of unit pulses */ + const Word16 *vec_in, /* i : PVQ abs pulse train */ + Word16 *k_val_out_ptr, /* o : number of unit pulses */ UWord32 *next_sign_ind, /* i/o: next sign ind */ - UWord32 *index, /* Q0 o: MPVQ index */ - VEC2INDFUNCM vec2indfunc_ptr, /* i: */ - H_FUNCM a_func_ptr /*i: offset function */ + UWord32 *index, /* o : MPVQ index */ + VEC2INDFUNCM vec2indfunc_ptr, /* i : */ + H_FUNCM a_func_ptr /* i : offset function */ ) { Word16 tmp_val; @@ -1035,13 +1067,14 @@ static void vec2mind_gen345_fx( * vec2mind_three_fx() *-------------------------------------------------------------------*/ static void vec2mind_three_fx( - const Word16 *vec_in, /* i : PVQ pulse train */ - Word16 *k_val_out_ptr, /* Q0 o : number of unit pulses */ - UWord32 *next_sign_ind, /* Q0 i/o: next sign ind */ - UWord32 *index /* Q0 o: MPVQ index */ + const Word16 *vec_in, /* i : PVQ pulse train */ + Word16 *k_val_out_ptr, /* o : number of unit pulses */ + UWord32 *next_sign_ind, /* i/o: next sign ind */ + UWord32 *index /* o : MPVQ index */ ) { vec2mind_gen345_fx( vec_in, k_val_out_ptr, next_sign_ind, index, vec2mind_two_fx, a_three_fx ); + return; } @@ -1050,13 +1083,14 @@ static void vec2mind_three_fx( * vec2mind_four_fx() *-------------------------------------------------------------------*/ static void vec2mind_four_fx( - const Word16 *vec_in, /* i : PVQ pulse train */ - Word16 *k_val_out_ptr, /* Q0 o : number of unit pulses */ - UWord32 *next_sign_ind, /* Q0 i/o: next sign ind */ - UWord32 *index /* Q0 o: MPVQ index */ + const Word16 *vec_in, /* i : PVQ pulse train */ + Word16 *k_val_out_ptr, /* o : number of unit pulses */ + UWord32 *next_sign_ind, /* i/o: next sign ind */ + UWord32 *index /* o : MPVQ index */ ) { vec2mind_gen345_fx( vec_in, k_val_out_ptr, next_sign_ind, index, vec2mind_three_fx, a_four_fx ); + return; } @@ -1077,13 +1111,16 @@ static void vec2mind_five_fx( /*-------------------------------------------------------------------* * vec2mind_fx() *-------------------------------------------------------------------*/ -static void vec2mind_fx( Word16 dim_in, /* i : dim */ - Word16 k_val_in, /* i : number of unit pulses */ - const Word16 *vec_in, /* i : PVQ pulse train */ - UWord32 *next_sign_ind, /* Q0 o : pushed leading sign */ - UWord32 *index, /* Q0 o : MPVQ index */ - UWord32 *N_MPVQ_ptr, /* Q0 o : size(N_MPVQ(dim,K_val_in))*/ - UWord32 *h_mem ) /* Q0 o : offsets */ + +static void vec2mind_fx( + Word16 dim_in, /* i : dim */ + Word16 k_val_in, /* i : number of unit pulses */ + const Word16 *vec_in, /* i : PVQ pulse train */ + UWord32 *next_sign_ind, /* o : pushed leading sign */ + UWord32 *index, /* o : MPVQ index */ + UWord32 *N_MPVQ_ptr, /* o : size(N_MPVQ(dim,K_val_in))*/ + UWord32 *h_mem /* o : offsets */ +) { Word16 pos, mem_size_m1, k_val_acc, tmp_val; UWord32 tmp_h; @@ -1148,10 +1185,11 @@ static void vec2mind_fx( Word16 dim_in, /* i : dim * returns struct with lead sign index, MPVQ-index, dim and N_MPVQ size *-------------------------------------------------------------------------*/ -PvqEntry mpvq_encode_vec_fx( /* Q0 o : leading_sign_index, index, size, k_val */ - const Word16 *vec_in, /* i : signed pulse train */ - Word16 dim_in, /* i : dimension */ - Word16 k_val_local /* i : nb unit pulses */ +/* Q0 o : leading_sign_index, index, size, k_val */ +PvqEntry mpvq_encode_vec_fx( + const Word16 *vec_in, /* i : signed pulse train */ + Word16 dim_in, /* i : dimension */ + Word16 k_val_local /* i : nb unit pulses */ ) { PvqEntry result; diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index d017628a80bdb2b0453c186a10d2768d82a18053..ecf28ae6dfe8d7d9cedeed34ab92b2a0e7c91c7a 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -704,7 +704,7 @@ enum #define ECLVQ_GLOBAL_GAIN_FACTOR_Q26 1893961218 /* ( 20.0f * 127.0f / 90.0f ) in Q26 */ #define ECLVQ_INV_GLOBAL_GAIN_FACTOR_Q24 594468 /* ( 1.0f / ( 20.0f * 127.0f / 90.0f ) ) in Q24 */ -/* the currently defined configuration indexes are: +/* the defined configuration indexes are: 0: un-optimized using uniform 4 bit parameters (reserved) 1: optimized for 32 kbps target SNR 2: optimized for 32 kbps target bits @@ -1035,8 +1035,6 @@ typedef enum #define IVAS_SPAR_P_LOWERTRI ((IVAS_SPAR_MAX_CH - 1) * (IVAS_SPAR_MAX_CH - 2)) >> 1 #define IVAS_SPAR_MAX_C_COEFF (IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS) * ( IVAS_SPAR_MAX_DMX_CHS - 1) -#define IVAS_SPAR_HOA3_NP_CHS 8 /* number of higher order non-planar channels */ - #define SPAR_NUM_CODING_STRAT_BITS 3 /* AGC constants */ @@ -1110,20 +1108,13 @@ enum #define IVAS_DECORR_PARM_APD_TAU 42949673 /* Q31 */ /* IVAS SBA PCA */ -#define IVAS_PCA_NB_SUBR 20 /* 80 -> 0.25 ms, 40 -> 0.5 ms... */ #define IVAS_PCA_QBITS 19 #define IVAS_PCA_N1 91 -#define IVAS_PCA_N1_EQ ( (IVAS_PCA_N1-1)/2 ) -#define IVAS_PCA_BIT_LEN ( 1 + ( IVAS_PCA_QBITS - 1 + IVAS_PCA_QBITS ) ) #define IVAS_PCA_INTERP 4 #define IVAS_PCA_N_SLOTS 40 #define IVAS_PCA_LEN_INTERP_Q ( IVAS_PCA_INTERP * IVAS_PCA_N_SLOTS ) #define IVAS_PCA_DELAY_CMP 24 #define IVAS_PCA_LEN_INTERP_EIG_DEC ( (IVAS_PCA_N_SLOTS+IVAS_PCA_DELAY_CMP)*16) -#define IVAS_PCA_QUAT_EPS_FX 215 /* 1e-7f in Q31 */ -#define IVAS_PCA_THRES_MIN_DOT_FX 1717986918 /* 0.8 in Q31 */ -#define IVAS_PCA_THRES_MIN_DOT2_FX 0 -#define IVAS_PCA_THRES_DIST_ALT_FX 1610612736 /* 6 in Q28 */ typedef enum { @@ -1227,8 +1218,6 @@ enum #define HR_MASA_ER_LEVELS 16 #define MAX_REDUCED_NBANDS 18 /* max number of subbands that is less than the default value 24 */ -#define LIMIT_ER_ELEVATION_ENC 4 -#define LIMIT_ER_SIMPLE_ENC 6 #define LIMIT_USE_COMMON 3 #define MASA_COHERENCE_TOLERANCE_FX 3277 /* 0.1 Q15 */ @@ -1248,18 +1237,11 @@ enum #define MASA_LIMIT_IDX_AVG_AZI 4 #define MASA_NO_POINTS_EQUATOR 430 -#define MASA_NO_CIRCLES 121 -#define MASA_NO_CIRCLES_Q23 1015021568 /* Q23 */ -#define MASA_ASIN_OFFSET_Q15 211 /* 0.0064471690266724975f in Q15 */ -#define MASA_NTOT2_FAC_Q15 1073741952 /* 32768.00566947353f in Q15 */ -#define MASA_ANGLE_AT_EQUATOR_Q31 27690572 /* 0.012894427382667f in Q31 */ -#define MASA_ANGLE_AT_EQUATOR_DEG_Q31 1586552905l /* 0.738796268264740f in Q31 */ #define MASA_STEREO_MIN_BITRATE IVAS_24k4 #define MAXIMUM_OMASA_FREQ_BANDS 8 /* Corresponds to maximum number of coding bands at 32 kbps */ #define OMASA_STEREO_SW_CNT_MAX 100 #define MASA_BIT_REDUCT_PARAM 10 #define MASA_MAXIMUM_TWO_DIR_BANDS 24 -#define NBITS_HR_COH 4 #define OMASA_TDREND_MATCHING_GAIN_FX 26026 #define OMASA_GAIN_EDIT_THR_Q12 246 /* OMASA gain change threshold, 0.06f in Q12 */ diff --git a/lib_com/ivas_dirac_com_fx.c b/lib_com/ivas_dirac_com_fx.c index cf256b3681fa7f3f4b1b245a1ac1532b9519babf..a6aa486f287121891a105174a5c341014782d452 100644 --- a/lib_com/ivas_dirac_com_fx.c +++ b/lib_com/ivas_dirac_com_fx.c @@ -69,11 +69,14 @@ Word16 ivas_get_hodirac_flag_fx( return 0; } } + + /*------------------------------------------------------------------------- * ivas_dirac_sba_config() * * DirAC Configuration function; used also in MASA decoder *------------------------------------------------------------------------*/ + ivas_error ivas_dirac_config_fx( void *st_ivas, /* i/o: IVAS encoder/decoder state structure */ const Word16 enc_dec /* i : encoder or decoder flag */ @@ -367,7 +370,7 @@ void ivas_get_dirac_sba_max_md_bits_fx( Word16 *metadata_max_bits, Word16 *qmetadata_max_bit_req, const Word16 nbands, - IVAS_FORMAT ivas_format ) + const IVAS_FORMAT ivas_format ) { IF( LE_32( sba_total_brate, IVAS_13k2 ) ) { @@ -504,12 +507,13 @@ void ivas_get_dirac_sba_max_md_bits_fx( *------------------------------------------------------------------------*/ ivas_error ivas_dirac_sba_config_fx( - IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ - Word16 *element_mode, /* i/o: element mode of the core coder */ - Word32 sba_total_brate, /* i : SBA total bitrate */ - const Word16 sba_order, /* i : Ambisonic (SBA) order */ - const Word16 nbands, /* i : number of frequency bands */ - IVAS_FORMAT ivas_format ) + IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ + Word16 *element_mode, /* i/o: element mode of the core coder */ + Word32 sba_total_brate, /* i : SBA total bitrate */ + const Word16 sba_order, /* i : Ambisonic (SBA) order */ + const Word16 nbands, /* i : number of frequency bands */ + const IVAS_FORMAT ivas_format /* i : IVAS format */ +) { Word16 nbands_coded; Word16 hodirac_flag; diff --git a/lib_com/ivas_entropy_coder_common_fx.c b/lib_com/ivas_entropy_coder_common_fx.c index 0ea623d294e90e12c4a6860ef9bac28ad7ce479f..fcf388b0c73fd84166c1fe0e8a12445a2ac0682f 100644 --- a/lib_com/ivas_entropy_coder_common_fx.c +++ b/lib_com/ivas_entropy_coder_common_fx.c @@ -76,7 +76,7 @@ void ivas_wrap_arround_fx( * get cumulative frequency model *-----------------------------------------------------------------------------------------*/ -void ivas_get_cum_freq_model_fx( +static void ivas_get_cum_freq_model_fx( const Word16 *pFreq_model, const Word16 length, Word16 *pCum_freq_model ) @@ -102,12 +102,13 @@ void ivas_get_cum_freq_model_fx( * Map the ivas_arith_pred_r_consts and ivas_huff_pred_r_consts tables *-----------------------------------------------------------------------------------------*/ -Word16 ivas_map_num_pred_r_to_idx_fx( +static Word16 ivas_map_num_pred_r_to_idx_fx( const Word16 num_quant_points_pred_r, const Word16 active_w_flag ) { Word16 pred_r_to_idx = -1; move16(); + IF( active_w_flag == 0 ) { SWITCH( num_quant_points_pred_r ) @@ -169,11 +170,12 @@ Word16 ivas_map_num_pred_r_to_idx_fx( * Map the ivas_arith_drct_r_consts and ivas_huff_drct_r_consts tables *-----------------------------------------------------------------------------------------*/ -Word16 ivas_map_num_drct_r_to_idx_fx( +static Word16 ivas_map_num_drct_r_to_idx_fx( const Word16 num_quant_points_drct_r ) { Word16 drct_r_to_idx = -1; move16(); + SWITCH( num_quant_points_drct_r ) { case 1: @@ -206,7 +208,7 @@ Word16 ivas_map_num_drct_r_to_idx_fx( * Map the ivas_arith_decd_r_consts and ivas_huff_decd_r_consts tables *-----------------------------------------------------------------------------------------*/ -Word16 ivas_map_num_decd_r_to_idx_fx( +static Word16 ivas_map_num_decd_r_to_idx_fx( const Word16 num_quant_points_decd_r ) { Word16 decd_r_to_idx = -1; diff --git a/lib_com/ivas_ism_com_fx.c b/lib_com/ivas_ism_com_fx.c index 840949990c2b2f6bc0f7d32473e1ddcbaf9d5710..43cdf441f8f908a61cc1a0d40d65f78be9443823 100644 --- a/lib_com/ivas_ism_com_fx.c +++ b/lib_com/ivas_ism_com_fx.c @@ -161,7 +161,7 @@ ivas_error ivas_ism_config_fx( move16(); bitbudget_to_brate( bits_element, element_brate, n_ISms ); - /* count ISm common signaling bits */ + /* count ISM common signaling bits */ IF( hIsmMeta != NULL ) { nb_bits_metadata[0] = add( nb_bits_metadata[0], add( imult1616( n_ISms, ISM_METADATA_FLAG_BITS ), nchan_ism ) ); diff --git a/lib_com/ivas_masa_com_fx.c b/lib_com/ivas_masa_com_fx.c index eb08f15bb858955b336bdbfea9db609efaf6e9d0..d83ae1d32c90c32b7484529809f6ed8f43ba58df 100644 --- a/lib_com/ivas_masa_com_fx.c +++ b/lib_com/ivas_masa_com_fx.c @@ -46,8 +46,14 @@ *---------------------------------------------------------------*/ #define MASA_EXTRA_BAND_META_BITS 40 +#define MASA_SMALL_INC_META_BITS 10 -#define MASA_SMALL_INC_META_BITS 10 +#define MASA_NO_CIRCLES 121 +#define MASA_NO_CIRCLES_Q23 1015021568 /* Q23 */ +#define MASA_ASIN_OFFSET_Q15 211 /* 0.0064471690266724975f in Q15 */ +#define MASA_NTOT2_FAC_Q15 1073741952 /* 32768.00566947353f in Q15 */ +#define MASA_ANGLE_AT_EQUATOR_Q31 27690572 /* 0.012894427382667f in Q31 */ +#define MASA_ANGLE_AT_EQUATOR_DEG_Q31 1586552905l /* 0.738796268264740f in Q31 */ /*--------------------------------------------------------------- @@ -67,7 +73,7 @@ static Word16 quantize_phi_masa_fx( const Word16 n /* i : azimuth codebook size */ ); -static Word32 estim_round[MASA_NO_CIRCLES + 1] = { +static const Word32 estim_round[MASA_NO_CIRCLES + 1] = { /* Q0 */ -423, 0, @@ -193,7 +199,7 @@ static Word32 estim_round[MASA_NO_CIRCLES + 1] = { 32552 }; -static Word32 estim_ceil[MASA_NO_CIRCLES + 1] = { +static const Word32 estim_ceil[MASA_NO_CIRCLES + 1] = { /* Q0 */ -422, 0, diff --git a/lib_com/ivas_pca_tools_fx.c b/lib_com/ivas_pca_tools_fx.c index 4669b86a36742dc5e4850cd869503be72e2b9867..115bf0b69e2779227cf55dd778bbf4611e09f70d 100644 --- a/lib_com/ivas_pca_tools_fx.c +++ b/lib_com/ivas_pca_tools_fx.c @@ -39,6 +39,15 @@ #include "prot_fx.h" #include "ivas_prot_fx.h" + +/*---------------------------------------------------------------------* + * Local constants + *---------------------------------------------------------------------*/ + +#define IVAS_PCA_QUAT_EPS_FX 215 /* 1e-7f in Q31 */ +#define IVAS_PCA_N1_EQ ( ( IVAS_PCA_N1 - 1 ) / 2 ) + + /*---------------------------------------------------------------------* * eye_matrix() * @@ -875,6 +884,8 @@ void quat_shortestpath_fx( return; } + + /*---------------------------------------------------------------------* * mat_det4() * @@ -929,9 +940,11 @@ Word16 mat_det4_fx( return d; // Q15 } -static Word32 dotp16_fixed_guarded_fx( const Word16 x[], /* i : vector x[] Qx */ - const Word16 y[], /* i : vector y[] Qy */ - const Word16 n /* i : vector length */ ) + +static Word32 dotp16_fixed_guarded_fx( + const Word16 x[], /* i : vector x[] Qx */ + const Word16 y[], /* i : vector y[] Qy */ + const Word16 n /* i : vector length */ ) { Word16 i; Word32 suma; diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index ff41c4ae0ac94cd1f795877c6c8d7e26c46138ae..4b943135e478cbb59193f2ba23e2690b7d883154 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1467,7 +1467,7 @@ void ivas_get_dirac_sba_max_md_bits_fx( Word16 *metadata_max_bits, Word16 *qmetadata_max_bit_req, const Word16 nbands, - IVAS_FORMAT ivas_format + const IVAS_FORMAT ivas_format ); ivas_error ivas_dirac_sba_config_fx( @@ -1476,7 +1476,7 @@ ivas_error ivas_dirac_sba_config_fx( Word32 sba_total_brate, /* i : SBA total bitrate */ const Word16 sba_order, /* i : Ambisonic (SBA) order */ const Word16 nbands, /* i : number of frequency bands */ - IVAS_FORMAT ivas_format + const IVAS_FORMAT ivas_format /* i : IVAS format */ ); ivas_error ivas_dirac_config_fx( @@ -2243,9 +2243,9 @@ void ivas_dirac_dec_render_sf_fx( void ivas_dirac_dec_render_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const Word16 nchan_transport, /* i : number of transport channels */ - const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ - UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */ - UWord16 *nSamplesAvailableNext, /* o : number of CLDFB slots still to render */ + const UWord16 nSamplesAsked, /* i : number of samples requested */ + UWord16 *nSamplesRendered, /* o : number of samples rendered */ + UWord16 *nSamplesAvailableNext, /* o : number of samples still to render */ Word32 *output_fx[] /* o : rendered time signal */ ); @@ -2423,7 +2423,7 @@ Word16 ivas_sba_spar_sid_bitlen_fx( void ivas_sba_get_spar_hoa_ch_ind_fx( const Word16 num_md_chs, /* i : number of MD channels */ const Word32 ivas_total_brate, /* i : IVAS total bitrate */ - Word16 HOA_md_ind[IVAS_SPAR_MAX_CH] + Word16 HOA_md_ind[IVAS_SPAR_MAX_CH] /* o : channel indexes */ ); void ivas_sba_get_spar_hoa_md_flag_fx( @@ -2477,25 +2477,6 @@ void ivas_wrap_arround_fx( const Word16 length ); -void ivas_get_cum_freq_model_fx( - const Word16 *pFreq_model, - const Word16 length, - Word16 *pCum_freq_model -); - -Word16 ivas_map_num_pred_r_to_idx_fx( - const Word16 num_quant_points_pred_r, - const Word16 active_w_flag -); - -Word16 ivas_map_num_drct_r_to_idx_fx( - const Word16 num_quant_points_drct_r -); - -Word16 ivas_map_num_decd_r_to_idx_fx( - const Word16 num_quant_points_decd_r -); - void ivas_spar_arith_coeffs_com_init_fx( ivas_arith_coeffs_t *pArith_coeffs, ivas_spar_md_com_cfg *pSpar_cfg, @@ -3636,7 +3617,7 @@ ivas_error ivas_allocate_binaural_hrtf_fx( void ivas_binRenderer_fx( BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ - const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i : pose correction data handle */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle*/ const Word16 numTimeSlots, /* i : number of time slots to render */ Word32 Cldfb_RealBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ @@ -3769,9 +3750,9 @@ ivas_error ivas_osba_data_open_fx( ivas_error ivas_osba_dirac_td_binaural_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ - UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */ - UWord16 *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + const UWord16 nSamplesAsked, /* i : number of samples requested */ + UWord16 *nSamplesRendered, /* o : number of samples rendered */ + UWord16 *nSamplesAvailable, /* o : number of samples still to render */ Word32 *output_fx[] /* o : rendered time signal */ ); @@ -4162,9 +4143,9 @@ void ivas_param_ism_dec_prepare_renderer_fx( void ivas_param_ism_dec_render_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ - UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */ - UWord16 *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + const UWord16 nSamplesAsked, /* i : number of samples requested */ + UWord16 *nSamplesRendered, /* o : number of samples rendered */ + UWord16 *nSamplesAvailable, /* o : number of samples still to render */ Word32 *output_fx[] /* i/o: synthesized core-coder TCs / rendered signal*/ ); @@ -4926,9 +4907,9 @@ void ivas_mc_paramupmix_enc_fx( void ivas_mc_paramupmix_dec_render_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ - UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */ - UWord16 *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + const UWord16 nSamplesAsked, /* i : number of samples requested */ + UWord16 *nSamplesRendered, /* o : number of samples rendered */ + UWord16 *nSamplesAvailable, /* o : number of samples still to render */ Word32 *input_fx[], /* i : core-coder transport channels */ Word32 *output_fx[] /* i/o: synthesized core-coder transport channels */ ); @@ -4964,9 +4945,9 @@ void ivas_param_mc_dec_prepare_renderer( void ivas_param_mc_dec_render_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ - UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */ - UWord16 *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + const UWord16 nSamplesAsked, /* i : number of samples requested */ + UWord16 *nSamplesRendered, /* o : number of samples rendered */ + UWord16 *nSamplesAvailable, /* o : number of samples still to render */ Word32 *output_fx[], /* o : rendered time signal */ Word16 channel_active_fx[MAX_OUTPUT_CHANNELS] ); @@ -5091,7 +5072,7 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open_fx( const Word16 max_band_decorr, /* i : uppermost frequency band where decorrelation is applied */ const Word16 interp_length, /* i : length for interpolating the mixing matrices in time slots */ const Word16 num_param_bands, /* i : number of parameter bands */ - const Word16 num_param_bands_residual, /* i : number of parameter bands with a residual mixing matrix (i.e. decorrelation */ + const Word16 num_param_bands_residual, /* i : number of parameter bands with a residual mixing matrix (i.e. decorrelation) */ const Word16 nchan_in, /* i : number of input (transport) channels */ const Word16 nchan_out, /* i : number of output channels */ const Word32 *proto_matrix /* i : the prototype (upmix) matrix (only used if mode == 1) */ @@ -5107,7 +5088,7 @@ void ivas_dirac_dec_output_synthesis_cov_init_fx( const Word16 nchan_in, /* i : number of input (tranport) channels */ const Word16 nchan_out, /* i : number of output channels */ const Word16 n_param_bands, /* i : number of total parameter bands */ - const Word16 n_param_bands_res /* i : number of parameter bands with a residual mixing matrix (i.e. decorrelation */ + const Word16 n_param_bands_res /* i : number of parameter bands with a residual mixing matrix (i.e. decorrelation)*/ ); void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx( @@ -5253,9 +5234,9 @@ void ivas_sba_dec_digest_tc_fx( ivas_error ivas_sba_dec_render_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ - UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */ - UWord16 *nSamplesAvailableNext, /* o : number of CLDFB slots still to render */ + const UWord16 nSamplesAsked, /* i : number of samples requested */ + UWord16 *nSamplesRendered, /* o : number of samples rendered */ + UWord16 *nSamplesAvailableNext, /* o : number of samples still to render */ Word32 *output_fx[] /* o : rendered time signal Q11*/ ); @@ -6100,7 +6081,7 @@ void ivas_dec_prepare_renderer_fx( ); ivas_error ivas_jbm_dec_set_discard_samples_fx( - Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ + Decoder_Struct *st_ivas /* i/o: main IVAS decoder structure */ ); void ivas_dec_get_adapted_linear_interpolator_fx( @@ -6693,7 +6674,7 @@ ivas_error ivas_mono_dmx_renderer_open( ); void ivas_mono_dmx_renderer_close( - MONO_DOWNMIX_RENDERER_HANDLE *hMonoDmxRenderer /* i/ i/o: Mono downmix structure */ + MONO_DOWNMIX_RENDERER_HANDLE *hMonoDmxRenderer /* i/o: Mono downmix structure */ ); diff --git a/lib_com/ivas_sba_config_fx.c b/lib_com/ivas_sba_config_fx.c index 2658644cccfbd82d4c43785bdb980684baebae4b..57bd35f838c7a3fb44c365f6ff7b45afd5baf7de 100644 --- a/lib_com/ivas_sba_config_fx.c +++ b/lib_com/ivas_sba_config_fx.c @@ -230,11 +230,11 @@ Word16 ivas_sba_get_nchan_metadata_fx( * *-------------------------------------------------------------------*/ -/*! r: flag indicating to code SPAR HOA MD for all bands */ void ivas_sba_get_spar_hoa_ch_ind_fx( - const Word16 num_md_chs, /* i : number of MD channels */ - const Word32 ivas_total_brate, /* i : IVAS total bitrate */ - Word16 HOA_md_ind[IVAS_SPAR_MAX_CH] ) + const Word16 num_md_chs, /* i : number of MD channels */ + const Word32 ivas_total_brate, /* i : IVAS total bitrate */ + Word16 HOA_md_ind[IVAS_SPAR_MAX_CH] /* o : channel indexes */ +) { Word16 ch; const Word16 *hoa_ind; @@ -303,6 +303,7 @@ void ivas_sba_get_spar_hoa_md_flag_fx( * * Zero vertical Ambisonics components *-------------------------------------------------------------------*/ + void ivas_sba_zero_vert_comp_fx( Word32 *sba_data[], /* i : SBA signals q_data */ const Word16 sba_order, /* i : SBA order */ diff --git a/lib_com/log2.c b/lib_com/log2.c index 6f398df1e66c198ca82f8208c0e496ce788fabd6..6b8b402c3455041f3d94e635e003356b3e3f7e97 100644 --- a/lib_com/log2.c +++ b/lib_com/log2.c @@ -51,8 +51,10 @@ * 5- fraction = table[i]<<16 - (table[i] - table[i+1]) * a * 2 * *************************************************************************/ -Word16 Log2_norm_lc( /* (o) : Fractional part of Log2. (range: 0<=val<1) Q15*/ - Word32 L_x /* (i) : input value (normalized) Qx*/ + +/* o : Fractional part of Log2. (range: 0<=val<1) Q15*/ +Word16 Log2_norm_lc( + Word32 L_x /* i : input value (normalized) Qx*/ ) { Word16 i, a; @@ -74,7 +76,10 @@ Word16 Log2_norm_lc( /* (o) : Fractional part of Log2. (range: 0<=val return y; } -Word32 log10_fx( Word32 Linput ) /*o : Q23, i: 2Q13*/ + +/*o : Q23, i: 2Q13*/ +Word32 log10_fx( + const Word32 Linput ) { Word16 n1, frac, p1, p2, q1; Word16 idx; @@ -125,10 +130,14 @@ Word32 log10_fx( Word32 Linput ) /*o : Q23, i: 2Q13*/ q1 = extract_h( Ltemp1 ); Ltemp1 = L_mult( q1, 0x6054 ); Ltemp1 = L_msu( Ltemp1, 0x6054, n1 ); + return ( L_shr( Ltemp1, 1 ) ); } -Word32 pow_10( Word32 x, Word16 *Q ) /*o : Q15, i: Q26*/ + +Word32 pow_10( + const Word32 x, + Word16 *Q ) /*o : Q15, i: Q26*/ { Word16 xl, xh, t1, t2, n; Word32 Ltemp1; @@ -212,15 +221,19 @@ Word32 pow_10( Word32 x, Word16 *Q ) /*o : Q15, i: Q26*/ return ( L_shl( Lacc, sub( n, count ) ) ); } -Word16 Log2_lc( /* (o) : Fractional part of Log2. (range: 0<=val<1) Q15 - exponent*/ - Word32 L_x, /* (i) : input value */ - Word16 *exponent /* (o) : Integer part of Log2. (range: 0<=val<=30) */ + +/* o: Fractional part of Log2. (range: 0<=val<1) Q15 - exponent*/ +Word16 Log2_lc( + Word32 L_x, /* i : input value */ + Word16 *exponent /* o : Integer part of Log2. (range: 0<=val<=30) */ ) { Word16 exp; if ( L_x <= 0 ) + { L_x = L_deposit_l( 0x1 ); + } exp = norm_l( L_x ); *exponent = sub( 30, exp ); diff --git a/lib_com/log2.h b/lib_com/log2.h index d87f677b550d0a38a80aa71387582a498620799c..582d4ef745ebf9f853d1dce0a46c9d7794f01a89 100644 --- a/lib_com/log2.h +++ b/lib_com/log2.h @@ -26,14 +26,17 @@ * DECLARATION OF PROTOTYPES ******************************************************************************** */ -Word16 Log2_norm_lc( /* (o) : Fractional part of Log2. (range: 0<=val<1) Q15 */ - Word32 L_x /* (i) : input value (normalized) Qx */ + +/* o : Fractional part of Log2. (range: 0<=val<1) Q15 */ +Word16 Log2_norm_lc( + Word32 L_x /* i : input value (normalized) Qx */ ); -Word32 log10_fx( Word32 Linput ); /*o : Q23, i: 2Q13*/ -Word32 pow_10( Word32 x, Word16 *Q ); /*o : Q15, i: Q26*/ -Word16 Log2_lc( /* (o) : Fractional part of Log2. (range: 0<=val<1) Q15 - exponent */ - Word32 L_x, /* (i) : input value */ - Word16 *exponent /* (o) : Integer part of Log2. (range: 0<=val<=30) */ +Word32 log10_fx( const Word32 Linput ); /* o : Q23, i: 2Q13*/ +Word32 pow_10( const Word32 x, Word16 *Q ); /* o : Q15, i: Q26*/ +/* o : Fractional part of Log2. (range: 0<=val<1) Q15 - exponent */ +Word16 Log2_lc( + Word32 L_x, /* i : input value */ + Word16 *exponent /* o : Integer part of Log2. (range: 0<=val<=30) */ ); #endif diff --git a/lib_com/lsf_dec_bfi_fx.c b/lib_com/lsf_dec_bfi_fx.c index 491802f6be544fd1891f4105ca6e80ae2bd7e2da..41db2c647d5d73b15d06785fa99053a4bcfd83f9 100644 --- a/lib_com/lsf_dec_bfi_fx.c +++ b/lib_com/lsf_dec_bfi_fx.c @@ -17,18 +17,18 @@ * Bad frame, all active speech coders *---------------------------------------------------------------------*/ void lsf_dec_bfi( - const Word16 codec_mode, /* i: : codec mode: MODE1 | MODE2 */ - Word16 *lsf, /*!< o : 14Q1*1.28 quantized ISFs */ - const Word16 *lsfold, /*!< i : 14Q1*1.28 past quantized ISF */ - Word16 *lsf_adaptive_mean, /*!< i : 14Q1*1.28 ISF adaptive mean, updated when BFI==0 */ + const Word16 codec_mode, /* i : codec mode: MODE1 | MODE2 */ + Word16 *lsf, /* o : 14Q1*1.28 quantized ISFs */ + const Word16 *lsfold, /* i : 14Q1*1.28 past quantized ISF */ + Word16 *lsf_adaptive_mean, /* i : 14Q1*1.28 ISF adaptive mean, updated when BFI==0 */ const Word16 lsfBase[], /* i : base for differential lsf coding */ - Word16 *mem_MA, /*!< i/o: 14Q1*1.28 quantizer memory for MA model */ - Word16 *mem_AR, /*!< i/o: 14Q1*1.28 quantizer memory for MA model */ - Word16 stab_fac, /*!< i : ISF stability factor (shifted right by 1) Q15*/ - const Word16 last_coder_type, /*!< i : coding type in last good received fr. */ + Word16 *mem_MA, /* i/o: 14Q1*1.28 quantizer memory for MA model */ + Word16 *mem_AR, /* i/o: 14Q1*1.28 quantizer memory for MA model */ + Word16 stab_fac, /* i : ISF stability factor (shifted right by 1) Q15*/ + const Word16 last_coder_type, /* i : coding type in last good received fr. */ Word16 L_frame, - const Word16 last_good, /*!< i : last good received frame */ - const Word16 nbLostCmpt, /*!< i : counter of consecutive bad frames */ + const Word16 last_good, /* i : last good received frame */ + const Word16 nbLostCmpt, /* i : counter of consecutive bad frames */ const Word8 plcBackgroundNoiseUpdated, /* i : background noise already updated?*/ Word16 *lsf_q_cng, /* o : quantized ISFs for background noise (14Q1*1.28) */ Word16 *lsf_cng, /* Q2.56 */ @@ -251,7 +251,6 @@ FOR( i = 0; i < M; i++ ) move16(); } - return; } diff --git a/lib_com/lsf_msvq_ma_fx.c b/lib_com/lsf_msvq_ma_fx.c index d705177fc3591440db44305e2d8f179f84b9d6d4..538a20bec60f7dcfc28f65c291c8c3b09f465092 100644 --- a/lib_com/lsf_msvq_ma_fx.c +++ b/lib_com/lsf_msvq_ma_fx.c @@ -24,10 +24,10 @@ * *---------------------------------------------------------------------*/ void midlsf_dec( - const Word16 qlsf0[], /* i: quantized lsf coefficients (3Q12) */ - const Word16 qlsf1[], /* i: quantized lsf coefficients (3Q12) */ - const Word16 idx, /* i: codebook index */ - Word16 qlsf[], /* o: decoded lsf coefficients (3Q12) */ + const Word16 qlsf0[], /* i : quantized lsf coefficients (3Q12) */ + const Word16 qlsf1[], /* i : quantized lsf coefficients (3Q12) */ + const Word16 idx, /* i : codebook index */ + Word16 qlsf[], /* o : decoded lsf coefficients (3Q12) */ const Word16 coder_type, Word16 *mid_lsf_int, /*Q0*/ const Word16 prev_bfi, diff --git a/lib_com/lsf_tools_fx.c b/lib_com/lsf_tools_fx.c index c1638a26948fbcd99d94666bdf1e153c29d409dc..c61a2785380cb32904ccb9e686beef661b2c0d79 100644 --- a/lib_com/lsf_tools_fx.c +++ b/lib_com/lsf_tools_fx.c @@ -1488,6 +1488,8 @@ void lsp_weights_fx( *Qout = sub( 9, n_max ); move16(); + + return; } void lsp_weights_ivas_fx( @@ -1562,6 +1564,8 @@ void lsp_weights_ivas_fx( *Qout = sub( q_min, 16 ); move16(); + + return; } /* @@ -1581,7 +1585,10 @@ void lsp_weights_ivas_fx( * Returns: * void */ -void E_LPC_isf_isp_conversion( const Word16 isf[], Word16 isp[], const Word16 m ) +void E_LPC_isf_isp_conversion( + const Word16 isf[], + Word16 isp[], + const Word16 m ) { Word16 i; @@ -1596,7 +1603,6 @@ void E_LPC_isf_isp_conversion( const Word16 isf[], Word16 isp[], const Word16 m *isp = xsf_to_xsp( shl( *isf, 1 ) ); move16(); - return; } @@ -1649,7 +1655,6 @@ Word16 xsp_to_xsf( Word16 lsp ) Word16 ind, tmp; Word32 L_tmp; - /*------------------------------------------------------* * find value in table that is just greater than lsp *------------------------------------------------------*/ @@ -1696,19 +1701,20 @@ Word16 xsp_to_xsf( Word16 lsp ) L_tmp = L_shr( L_tmp, 12 ); /* (lsp-cos_table_129[ind]) * acos_slope[ind]) >> 11 */ L_tmp = L_mac0( L_tmp, ind, 128 ); - return extract_l( L_tmp ); } + /*-------------------------------------------------------------------* * a2rc() * * Convert from LPC to reflection coeff *-------------------------------------------------------------------*/ -void a2rc_fx( const Word16 *a, /* i: can be any Q */ - Word16 *refl, /* o: Q15 */ - Word16 lpcorder ) +void a2rc_fx( + const Word16 *a, /* i: can be any Q */ + Word16 *refl, /* o: Q15 */ + Word16 lpcorder ) { Word16 f_fx[M]; @@ -1807,17 +1813,18 @@ void a2rc_fx( const Word16 *a, /* i: can be any Q */ move16(); } - return; } + + Word16 vq_dec_lvq_fx( Word16 sf_flag, /* i : safety net flag */ Word16 x[], /* o : Decoded vector Q(x2.56)*/ Word16 indices[], /* i : Indices */ Word16 stages, /* i : Number of stages */ Word16 N, /* i : Vector dimension */ - Word16 mode, /* (i): mode_lvq, or mode_lvq_p */ - Word16 no_bits, /* (i): no. bits for lattice */ + Word16 mode, /* i : mode_lvq, or mode_lvq_p */ + Word16 no_bits, /* i : no. bits for lattice */ Word32 *p_offset_scale1, Word32 *p_offset_scale2, Word32 *p_offset_scale1_p, @@ -1871,8 +1878,8 @@ Word16 vq_dec_lvq_ivas_fx( Word16 indices[], /* i : Indices */ Word16 stages, /* i : Number of stages */ Word16 N, /* i : Vector dimension */ - Word16 mode, /* (i): mode_lvq, or mode_lvq_p */ - Word16 no_bits /* (i): no. bits for lattice */ + Word16 mode, /* i : mode_lvq, or mode_lvq_p */ + Word16 no_bits /* i : no. bits for lattice */ ) { Word16 x_lvq[M]; @@ -2077,13 +2084,13 @@ ivas_error lsf_allocate_fx( } ivas_error find_pred_mode( - Word16 *predmode, /* o: prediction mode */ - const Word16 coder_type, /* i: coding type */ - const Word16 bwidth, /* i: bandwidth index */ - const Word32 int_fs, /* i: sampling frequency */ - Word16 *p_mode_lvq, /* o: index of LSF codebooks in safety net mode */ - Word16 *p_mode_lvq_p, /* o: index of LSF codebooks in predictive mode (AR or MA) */ - Word32 core_brate /* i: core bit rate */ + Word16 *predmode, /* o : prediction mode */ + const Word16 coder_type, /* i : coding type */ + const Word16 bwidth, /* i : bandwidth index */ + const Word32 int_fs, /* i : sampling frequency */ + Word16 *p_mode_lvq, /* o : index of LSF codebooks in safety net mode */ + Word16 *p_mode_lvq_p, /* o : index of LSF codebooks in predictive mode (AR or MA) */ + Word32 core_brate /* i : core bit rate */ ) { Word16 idx; @@ -2877,27 +2884,27 @@ Word16 qlsf_ARSN_tcvq_Dec_16k_fx( /*======================================================================*/ void lsf_syn_mem_backup_fx( - Encoder_State *st_fx, /* o: state structure */ - Word16 *btilt_code_fx, /* i: Q15 */ - Word32 *gc_threshold_fx, /* i: Q16 */ - Word16 *clip_var_bck_fx, /* i: Q(2.56), Q14, Q7, Q0, Q14, Q14 */ - Word16 *next_force_sf_bck_fx, /* i: */ - Word16 *lsp_new, /* o: LSP vector to quantize Q15 */ - Word16 *lsf_new, /* i: quantized LSF vector Q15 */ - Word16 *lsp_mid, /* o: mid-frame LSP vector Q15 */ - Word16 *clip_var, /* i: pitch clipping state var Q(2.56) */ - Word16 *mem_AR, /* i: quantizer memory for AR model 2.56 */ - Word16 *mem_MA, /* i: quantizer memory for MA model 2.56 */ - Word16 *lsp_new_bck, /* i: LSP vector to quantize- backup Q15 */ - Word16 *lsf_new_bck, /* o: quantized LSF vector - backup Q15 */ - Word16 *lsp_mid_bck, /* i: mid-frame LSP vector - backup Q15 */ - Word16 *mCb1, /* o: counter for stationary frame after a transition frame */ - Word32 *Bin_E, /* i: FFT Bin energy 128 *2 sets q_bin */ - Word32 *Bin_E_old, /* i: FFT Bin energy 128 sets q_bin */ - Word16 *mem_syn_bck, /* i: synthesis filter memory q */ - Word16 *mem_w0_bck, /* i: memory of the weighting filter q */ - Word16 *streaklimit, /* i:LSF quantizer Q15 */ - Word16 *pstreaklen /* i:LSF quantizer */ + Encoder_State *st_fx, /* o : state structure */ + Word16 *btilt_code_fx, /* i : Q15 */ + Word32 *gc_threshold_fx, /* i : Q16 */ + Word16 *clip_var_bck_fx, /* i : Q(2.56), Q14, Q7, Q0, Q14, Q14 */ + Word16 *next_force_sf_bck_fx, /* i : */ + Word16 *lsp_new, /* o : LSP vector to quantize Q15 */ + Word16 *lsf_new, /* i : quantized LSF vector Q15 */ + Word16 *lsp_mid, /* o : mid-frame LSP vector Q15 */ + Word16 *clip_var, /* i : pitch clipping state var Q(2.56) */ + Word16 *mem_AR, /* i : quantizer memory for AR model 2.56 */ + Word16 *mem_MA, /* i : quantizer memory for MA model 2.56 */ + Word16 *lsp_new_bck, /* i : LSP vector to quantize- backup Q15 */ + Word16 *lsf_new_bck, /* o : quantized LSF vector - backup Q15 */ + Word16 *lsp_mid_bck, /* i : mid-frame LSP vector - backup Q15 */ + Word16 *mCb1, /* o : counter for stationary frame after a transition frame */ + Word32 *Bin_E, /* i : FFT Bin energy 128 *2 sets q_bin */ + Word32 *Bin_E_old, /* i : FFT Bin energy 128 sets q_bin */ + Word16 *mem_syn_bck, /* i : synthesis filter memory q */ + Word16 *mem_w0_bck, /* i : memory of the weighting filter q */ + Word16 *streaklimit, /* i : LSF quantizer Q15 */ + Word16 *pstreaklen /* i : LSF quantizer */ ) { Word16 i; @@ -3019,27 +3026,27 @@ void lsf_update_memory( /*======================================================================*/ void lsf_syn_mem_restore_fx( - Encoder_State *st_fx, /* o: state structure */ - Word16 btilt_code_fx, /* i: Q15 */ - Word32 gc_threshold_fx, /* i: Q16 */ - Word16 *clip_var_bck_fx, /* i: Q(2.56), Q14, Q7, Q0, Q14, Q14 */ - Word16 next_force_sf_bck_fx, /* i: */ - Word16 *lsp_new, /* o: LSP vector to quantize Q15 */ - Word16 *lsf_new, /* o: quantized LSF vector Q15 */ - Word16 *lsp_mid, /* o: mid-frame LSP vector Q15 */ - Word16 clip_var, /* i: pitch clipping state var Q(2.56) */ - Word16 *mem_AR, /* i: quantizer memory for AR model Q15 */ - Word16 *mem_MA, /* i: quantizer memory for MA model Q15 */ - Word16 *lsp_new_bck, /* i: LSP vector to quantize- backup Q15 */ - Word16 *lsf_new_bck, /* i: quantized LSF vector - backup Q15 */ - Word16 *lsp_mid_bck, /* i: mid-frame LSP vector - backup Q15 */ - Word16 mCb1, /* i: counter for stationary frame after a transition frame */ - Word32 *Bin_E, /* i: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */ - Word32 *Bin_E_old, /* i: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */ - Word16 *mem_syn_bck, /* i: synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */ - Word16 mem_w0_bck, /* i: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */ - Word16 streaklimit, /* i:LSF quantizer Q15 */ - Word16 pstreaklen /* i:LSF quantizer */ + Encoder_State *st_fx, /* o : state structure */ + Word16 btilt_code_fx, /* i : Q15 */ + Word32 gc_threshold_fx, /* i : Q16 */ + Word16 *clip_var_bck_fx, /* i : Q(2.56), Q14, Q7, Q0, Q14, Q14 */ + Word16 next_force_sf_bck_fx, /* i : */ + Word16 *lsp_new, /* o : LSP vector to quantize Q15 */ + Word16 *lsf_new, /* o : quantized LSF vector Q15 */ + Word16 *lsp_mid, /* o : mid-frame LSP vector Q15 */ + Word16 clip_var, /* i : pitch clipping state var Q(2.56) */ + Word16 *mem_AR, /* i : quantizer memory for AR model Q15 */ + Word16 *mem_MA, /* i : quantizer memory for MA model Q15 */ + Word16 *lsp_new_bck, /* i : LSP vector to quantize- backup Q15 */ + Word16 *lsf_new_bck, /* i : quantized LSF vector - backup Q15 */ + Word16 *lsp_mid_bck, /* i : mid-frame LSP vector - backup Q15 */ + Word16 mCb1, /* i : counter for stationary frame after a transition frame */ + Word32 *Bin_E, /* i : FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */ + Word32 *Bin_E_old, /* i : FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */ + Word16 *mem_syn_bck, /* i : synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */ + Word16 mem_w0_bck, /* i : memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */ + Word16 streaklimit, /* i : LSF quantizer Q15 */ + Word16 pstreaklen /* i : LSF quantizer */ ) { Word16 i; @@ -3109,7 +3116,7 @@ void lsf_syn_mem_restore_fx( /* Returns: codebook index */ Word16 tcxlpc_get_cdk( - Word16 acelp_ext_mode /* (I) GC/VC indicator */ + Word16 acelp_ext_mode /* i : GC/VC indicator */ ) { Word16 cdk; @@ -3212,7 +3219,10 @@ void msvq_dec( * Returns: * energy of prediction error */ -void E_LPC_lsp_lsf_conversion( const Word16 lsp[], Word16 lsf[], const Word16 m ) +void E_LPC_lsp_lsf_conversion( + const Word16 lsp[], + Word16 lsf[], + const Word16 m ) { Word16 i; @@ -3246,7 +3256,10 @@ void E_LPC_lsp_lsf_conversion( const Word16 lsp[], Word16 lsf[], const Word16 m * Returns: * void */ -void E_LPC_lsf_lsp_conversion( const Word16 lsf[], Word16 lsp[], const Word16 m ) +void E_LPC_lsf_lsp_conversion( + const Word16 lsf[], + Word16 lsp[], + const Word16 m ) { Word16 i; @@ -3264,27 +3277,28 @@ void E_LPC_lsf_lsp_conversion( const Word16 lsf[], Word16 lsp[], const Word16 m } /*==========================================================================*/ -/* FUNCTION : void sub_lsp2lsf_fx () */ +/* FUNCTION : void sub_lsp2lsf_fx () */ /*--------------------------------------------------------------------------*/ -/* PURPOSE : */ +/* PURPOSE : */ /* * Transformation of LSPs to LSFs */ /* * LSP are line spectral pair in cosine domain (-1 to 1). */ /* * LSF are line spectral frequencies (0 to fs/2). */ /*--------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* Word16 lsp_i i : lsp[m] (range: -1<=val<1) Q15 */ -/* Word16 m i : LPC order Q0 */ +/* INPUT ARGUMENTS : */ +/* Word16 lsp_i i : lsp[m] (range: -1<=val<1) Q15 */ +/* Word16 m i : LPC order Q0 */ /*--------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ +/* OUTPUT ARGUMENTS : */ /* Word32 lsf[] o : lsf[m] normalized (range: 0.0<=val<=0.5) Q(x2.56)<<16 */ /*--------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ +/* INPUT/OUTPUT ARGUMENTS : */ /*--------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ +/* RETURN ARGUMENTS : */ +/* _ None */ /*--------------------------------------------------------------------------*/ -/* CALLED FROM : */ +/* CALLED FROM : */ /*==========================================================================*/ + Word32 sub_lsp2lsf_fx( const Word16 lsp_i /* i : lsp[m] (range: -1<=val<1) Q15*/ ) @@ -3364,10 +3378,11 @@ Word32 sub_lsp2lsf_fx( /* P(z)=(1+z^-1)*PI(j=1to(order/2)) (1 - 2*z^-1*cos(2*pi*w(2j-1)) + z^-2) */ /* Q(z)=(1-z^-1)*PI(j=1to(order/2)) (1 - 2*z^-1*cos(2*pi*w(2j)) + z^-2) */ /*===================================================================*/ + void compute_poly_product_fx( - Word16 *coef, /* i : LSP coefficients, Q15 */ - Word32 *p, /* o : output sequence, Q24 */ - Word16 order /* i : order */ + Word16 *coef, /* i : LSP coefficients, Q15 */ + Word32 *p, /* o : output sequence, Q24 */ + Word16 order /* i : order */ ) { Word16 i, len; @@ -3413,6 +3428,8 @@ void compute_poly_product_fx( move32(); } } + + return; } /*===================================================================*/ @@ -3445,6 +3462,7 @@ void compute_poly_product_fx( /* the rest have the form X( i-1) + X( i)*S + X( i+1). */ /* Final output sequence is ( 1 X1 X2 X3 X4 X5 X4) */ /*===================================================================*/ + void lsp_convolve_fx( Word32 x, Word32 *p1, @@ -3485,6 +3503,8 @@ void lsp_convolve_fx( p2[i + 1] = p2[i - 1]; move32(); + + return; } @@ -3512,8 +3532,8 @@ void lsp_convolve_fx( /* c3=-.198074182E-3, and c4=.2601903036E-5 */ /*===================================================================*/ - -Word32 poscos_fx( Word16 w ) +Word32 poscos_fx( + Word16 w ) { Word16 a, z, z2, z3, z5, z7, z9; Word32 Ltemp; @@ -3549,6 +3569,8 @@ Word32 poscos_fx( Word16 w ) return L_negate( Lacc ); /* return -cos( w), Q30 */ } /* end else */ } + + /*===================================================================*/ /* FUNCTION : root_search_fx ( ) */ /*-------------------------------------------------------------------*/ @@ -3571,11 +3593,12 @@ Word32 poscos_fx( Word16 w ) /* _ ( Word16) root in Q15, or 0xffff if no root is found */ /*===================================================================*/ -Word16 root_search_fx( Word16 low, - Word16 high, - Word32 *v_low, - Word32 *coef, - Word16 order ) +Word16 root_search_fx( + Word16 low, + Word16 high, + Word32 *v_low, + Word32 *coef, + Word16 order ) { Word16 f; Word32 v_high, vh; @@ -3668,6 +3691,7 @@ Word16 root_search_fx( Word16 low, return ( shl( high, 6 ) ); /* return exact root at high in Q15 */ } + /*===================================================================*/ /* FUNCTION : calc_weight( ) */ /*-------------------------------------------------------------------*/ @@ -3741,9 +3765,10 @@ Word32 calc_weight( /*===================================================================*/ /* 40-32 bit conversion */ -Word32 polynomial_eval_fx( Word16 f, - Word32 *coef, - Word16 order ) +Word32 polynomial_eval_fx( + Word16 f, + Word32 *coef, + Word16 order ) { Word16 i, idx; Word16 dh, dl, coslut; @@ -3791,12 +3816,14 @@ Word32 polynomial_eval_fx( Word16 f, return ( L_add( Ltemp, L_shr( Lacc, 15 ) ) ); /* Q25 */ } + /*----------------------------------------------------------------------------------* * v_sort: * * This is very fast with almost ordered vectors. The first 15 ISF values * are almost always sorted. *----------------------------------------------------------------------------------*/ + void v_sort( Word16 *r, /* i/o: Vector to be sorted in place */ const Word16 lo, /* i : Low limit of sorting range */ @@ -3806,7 +3833,6 @@ void v_sort( Word16 i, j; Word16 tempr; - FOR( i = sub( up, 1 ); i >= lo; i-- ) { tempr = r[i]; @@ -3824,7 +3850,6 @@ void v_sort( move16(); } - return; } diff --git a/lib_com/lsp_conv_poly_fx.c b/lib_com/lsp_conv_poly_fx.c index 834f7b0aab8566467ad90cc849fa69bf28bf0846..3bbf811379afff77e0a7c3fc3516344d4be3111a 100644 --- a/lib_com/lsp_conv_poly_fx.c +++ b/lib_com/lsp_conv_poly_fx.c @@ -173,12 +173,12 @@ Word16 lsp_convert_poly_fx( *---------------------------------------------------------------------*/ void powerspect_fx( - const Word16 x[], /* i: Q15 Grid points x[0:m-1] */ - Word16 N, /* i: Number of grid points */ - Word32 R[], /* i: Q20 Coefficients of R(x) in R[0:NC] */ - Word32 S[], /* i: Q20 Coefficients of S(x) in S[0:NC] */ - Word32 G[], /* o: Q15 Power spectrum G[0:N] */ - Word16 mode /* i: Flag for up or down conversion */ + const Word16 x[], /* i : Q15 Grid points x[0:m-1] */ + Word16 N, /* i : Number of grid points */ + Word32 R[], /* i : Q20 Coefficients of R(x) in R[0:NC] */ + Word32 S[], /* i : Q20 Coefficients of S(x) in S[0:NC] */ + Word32 G[], /* o : Q15 Power spectrum G[0:N] */ + Word16 mode /* i : Flag for up or down conversion */ ) { Word32 s0, se, so, r0, re, ro; @@ -479,11 +479,11 @@ static Word32 inv_pow( *---------------------------------------------------------------------*/ static void spectautocorr_fx( - const Word16 x[], /* i: Grid points x[0:m-1] */ - const Word16 N, /* i: Number of grid points */ - const Word32 G[], /* i: Power spectrum G[0:N-1] */ - Word16 rh[], /* o: Autocorrelation r[0:M] */ - Word16 rl[] /* o: Autocorrelation r[0:M] */ + const Word16 x[], /* i : Grid points x[0:m-1] */ + const Word16 N, /* i : Number of grid points */ + const Word32 G[], /* i : Power spectrum G[0:N-1] */ + Word16 rh[], /* o : Autocorrelation r[0:M] */ + Word16 rl[] /* o : Autocorrelation r[0:M] */ ) { Word16 c[M + 1]; /* c[j] = cos(j*w) */ @@ -630,10 +630,11 @@ static void spectautocorr_fx( * The polynomial coefficients are returned in R[0:n/2-1] and * S[0:n/2-1]. The leading coefficients are in R[0] and S[0]. *---------------------------------------------------------------------*/ + static void zeros2poly_fx( - Word16 x[], /* i: Q15 Zeros of R(x) and S(x) */ - Word32 R[], /* o: Q22 Coefficients of R(x) */ - Word32 S[] /* o: Q22 Coefficients of S(x) */ + Word16 x[], /* i : Q15 Zeros of R(x) and S(x) */ + Word32 R[], /* o : Q22 Coefficients of R(x) */ + Word32 S[] /* o : Q22 Coefficients of S(x) */ ) { Word16 xr, xs; @@ -695,9 +696,9 @@ static void zeros2poly_fx( *---------------------------------------------------------------------*/ static void polydecomp_fx( - Word16 A[], /* i: Q12 linear prediction coefficients */ - Word32 R[], /* o: Q20 coefficients of R(x) */ - Word32 S[] /* o: Q20 coefficients of S(x) */ + Word16 A[], /* i : Q12 linear prediction coefficients */ + Word32 R[], /* o : Q20 coefficients of R(x) */ + Word32 S[] /* o : Q20 coefficients of S(x) */ ) { Word16 scale; diff --git a/lib_com/mslvq_com_fx.c b/lib_com/mslvq_com_fx.c index 956f87251ad66b0f988ddb344df30c2a8a6a52a4..76a6395393560b5cd50ad4acb74f35deb72def1e 100644 --- a/lib_com/mslvq_com_fx.c +++ b/lib_com/mslvq_com_fx.c @@ -53,28 +53,11 @@ static void put_value_fx( Word16 *cv, Word16 *p, Word16 val, Word16 dim, Word16 static void decode_leaders_fx( Word16 index, Word16 idx_lead, Word16 *cv ); static void idx2c_fx( Word16 n, Word16 *p, Word16 k, Word16 val ); static void divide_64_32_fx( Word16 *xs, Word32 y, Word32 *result, Word32 *rem ); -static Word16 -decode_indexes_fx( Word16 *index, Word16 no_bits, const Word16 *p_scales, Word16 *p_no_scales, Word32 *p_offset_scale1, Word32 *p_offset_scale2, Word16 *x_lvq, Word16 mode_glb, Word16 *scales ); -static Word16 decode_indexes_ivas_fx( - Word16 *index, - const Word16 no_bits, - const Word16 *p_scales, // Q11 - const Word16 prediction_flag, - Word16 *x_lvq, // Q0 - const Word16 mode_glb, - Word16 *scales_mslvq /* o: scale values for the decoded MSLVQ LSF codevector Q11*/ -); +static Word16 decode_indexes_fx( Word16 *index, Word16 no_bits, const Word16 *p_scales, Word16 *p_no_scales, Word32 *p_offset_scale1, Word32 *p_offset_scale2, Word16 *x_lvq, Word16 mode_glb, Word16 *scales ); +static Word16 decode_indexes_ivas_fx( Word16 *index, const Word16 no_bits, const Word16 *p_scales, const Word16 prediction_flag, Word16 *x_lvq, const Word16 mode_glb, Word16 *scales_mslvq ); static Word32 divide_32_32_fx( Word32 y, Word32 x, Word32 *rem ); static Word16 divide_16_16_fx( Word16 y, Word16 x, Word16 *rem ); -static Word16 decode_indexes_ivas_fx( - Word16 *index, - const Word16 no_bits, - const Word16 *p_scales, // Q11 - const Word16 prediction_flag, - Word16 *x_lvq, // Q0 - const Word16 mode_glb, - Word16 *scales_mslvq /* o: scale values for the decoded MSLVQ LSF codevector Q11*/ -); +static Word16 decode_indexes_ivas_fx( Word16 *index, const Word16 no_bits, const Word16 *p_scales, const Word16 prediction_flag, Word16 *x_lvq, const Word16 mode_glb, Word16 *scales_mslvq ); /* used in CNG-LP coding */ void permute_fx( @@ -117,12 +100,12 @@ void permute_fx( void init_lvq_fx( - Word32 offset_scale1[][MAX_NO_SCALES + 1], /* o: lattice truncation index offset for the first LSF subvector - safety net structures*/ - Word32 offset_scale2[][MAX_NO_SCALES + 1], /* o: lattice truncation index offset for the second LSF subvector - safety net structures*/ - Word32 offset_scale1_p[][MAX_NO_SCALES + 1], /* o: lattice truncation index offset for the first LSF subvector - predictive structures*/ - Word32 offset_scale2_p[][MAX_NO_SCALES + 1], /* o: lattice truncation index offset for the second LSF subvector - predictive structures*/ - Word16 no_scales[][2], /* o: number of truncations for each LSF subvector at each MSLVQ structure - safety net */ - Word16 no_scales_p[][2] /* o: number of truncations for each LSF subvector at each MSLVQ structure - predictive */ + Word32 offset_scale1[][MAX_NO_SCALES + 1], /* o : lattice truncation index offset for the first LSF subvector - safety net structures*/ + Word32 offset_scale2[][MAX_NO_SCALES + 1], /* o : lattice truncation index offset for the second LSF subvector - safety net structures*/ + Word32 offset_scale1_p[][MAX_NO_SCALES + 1], /* o : lattice truncation index offset for the first LSF subvector - predictive structures*/ + Word32 offset_scale2_p[][MAX_NO_SCALES + 1], /* o : lattice truncation index offset for the second LSF subvector - predictive structures*/ + Word16 no_scales[][2], /* o : number of truncations for each LSF subvector at each MSLVQ structure - safety net */ + Word16 no_scales_p[][2] /* o : number of truncations for each LSF subvector at each MSLVQ structure - predictive */ ) { Word16 i, j; @@ -195,17 +178,21 @@ void init_lvq_fx( no_scales_p[i][1] = k; move16(); } + /* index offsets for each truncation */ init_offset_fx( offset_scale1, offset_scale2, offset_scale1_p, offset_scale2_p, no_scales, no_scales_p ); + + return; } + /* make_offset_scale_fx() - calculates scale offset values for a particular MSLVQ structure */ static void make_offset_scale_fx( - Word16 j, /* i: MSLVQ structure index */ - const Word32 tab_no_cv[], /* i: cummulated number of codevectors in each leader class */ - const Word16 no_ld[], /* i: number of leaders in each truncation for the MSLVQ structure j*/ - Word16 no_scl, /* i: number of truncations in the MSLVQ structure j */ - Word32 offset_scale[][MAX_NO_SCALES + 1] /* o: offset values */ + Word16 j, /* i : MSLVQ structure index */ + const Word32 tab_no_cv[], /* i : cummulated number of codevectors in each leader class */ + const Word16 no_ld[], /* i : number of leaders in each truncation for the MSLVQ structure j*/ + Word16 no_scl, /* i : number of truncations in the MSLVQ structure j */ + Word32 offset_scale[][MAX_NO_SCALES + 1] /* o : offset values */ ) { Word16 i; @@ -221,6 +208,7 @@ static void make_offset_scale_fx( return; } + static void make_offset_scale( const UWord32 tab_no_cv[], const Word8 *no_ld, @@ -240,13 +228,14 @@ static void make_offset_scale( return; } + void init_offset_fx( - Word32 offset_scale1[][MAX_NO_SCALES + 1], /* o: lattice truncation index offset for the first LSF subvector - safety net structures*/ - Word32 offset_scale2[][MAX_NO_SCALES + 1], /* o: lattice truncation index offset for the second LSF subvector - safety net structures*/ - Word32 offset_scale1_p[][MAX_NO_SCALES + 1], /* o: lattice truncation index offset for the first LSF subvector - predictive structures*/ - Word32 offset_scale2_p[][MAX_NO_SCALES + 1], /* o: lattice truncation index offset for the second LSF subvector - predictive structures*/ - Word16 no_scales[][2], /* i: number of truncations for each LSF subvector at each MSLVQ structure - safety net */ - Word16 no_scales_p[][2] /* i: number of truncations for each LSF subvector at each MSLVQ structure - predictive */ + Word32 offset_scale1[][MAX_NO_SCALES + 1], /* o : lattice truncation index offset for the first LSF subvector - safety net structures*/ + Word32 offset_scale2[][MAX_NO_SCALES + 1], /* o : lattice truncation index offset for the second LSF subvector - safety net structures*/ + Word32 offset_scale1_p[][MAX_NO_SCALES + 1], /* o : lattice truncation index offset for the first LSF subvector - predictive structures*/ + Word32 offset_scale2_p[][MAX_NO_SCALES + 1], /* o : lattice truncation index offset for the second LSF subvector - predictive structures*/ + Word16 no_scales[][2], /* i : number of truncations for each LSF subvector at each MSLVQ structure - safety net */ + Word16 no_scales_p[][2] /* i : number of truncations for each LSF subvector at each MSLVQ structure - predictive */ ) { Word16 j; @@ -275,18 +264,17 @@ void init_offset_fx( return; } -static Word16 -decode_indexes_fx( - Word16 *index, /* i: LSF vector index, written as array of Word16 because it generally uses more than 16 bits */ - Word16 no_bits, /* i: number of bits for the index */ - const Word16 *p_scales, /* i: scale values for the MSLVQ structures */ - Word16 *p_no_scales, /* i: number of truncations for each MSLVQ structure */ - Word32 *p_offset_scale1, /* i: scale index offset for first LSF subvector */ - Word32 *p_offset_scale2, /* i: scale index offset for second LSF subvector */ - Word16 *x_lvq, /* o: decoded LSF vector in Q1 */ - Word16 mode_glb, /* i: index of LSLVQ structure */ - // note_ : renamed from scales - Word16 *scales_mslvq /* o: scale values for the decoded MSLVQ LSF codevector */ + +static Word16 decode_indexes_fx( + Word16 *index, /* i : LSF vector index, written as array of Word16 because it generally uses more than 16 bits */ + Word16 no_bits, /* i : number of bits for the index */ + const Word16 *p_scales, /* i : scale values for the MSLVQ structures */ + Word16 *p_no_scales, /* i : number of truncations for each MSLVQ structure */ + Word32 *p_offset_scale1, /* i : scale index offset for first LSF subvector */ + Word32 *p_offset_scale2, /* i : scale index offset for second LSF subvector */ + Word16 *x_lvq, /* o : decoded LSF vector in Q1 */ + Word16 mode_glb, /* i : index of LSLVQ structure */ + Word16 *scales_mslvq /* o : scale values for the decoded MSLVQ LSF codevector */ ) { Word32 index1 = 0, index2 = 0; @@ -433,7 +421,7 @@ static Word16 decode_indexes_ivas_fx( const Word16 prediction_flag, Word16 *x_lvq, // Q1 const Word16 mode_glb, - Word16 *scales_mslvq /* o: scale values for the decoded MSLVQ LSF codevector Q11*/ + Word16 *scales_mslvq /* o : scale values for the decoded MSLVQ LSF codevector Q11*/ ) { Word32 index1 = 0, index2, idx_scale; @@ -722,8 +710,7 @@ Word16 deindex_lvq_ivas_fx( // ber_flag = // decode_indexes_fx(index, no_bits, p_scales, p_no_scales, offset_scale1, // offset_scale2, x_lvq, mode_glb, scales_mslvq); /* x_lvq is here Q1 */ - ber_flag = - decode_indexes_ivas_fx( index, no_bits, p_scales, 1 - sf_flag, x_lvq, mode_glb, scales_mslvq ); /* x_lvq is here Q1 */ + ber_flag = decode_indexes_ivas_fx( index, no_bits, p_scales, 1 - sf_flag, x_lvq, mode_glb, scales_mslvq ); /* x_lvq is here Q1 */ IF( EQ_16( sf_flag, 1 ) ) @@ -788,13 +775,13 @@ Word16 deindex_lvq_ivas_fx( *----------------------------------------------------------------------------------------------------*/ Word16 deindex_lvq_cng_fx( - Word16 *index, /* i: index to be decoded, as an array of 3 short */ - Word16 *x_lvq, /* o: decoded codevector Q9 */ - Word16 idx_cv, /* i: relative mode_lvq, wrt START_CNG */ - Word16 no_bits, /* i: number of bits for lattice */ - Word32 *p_offset_scale1, /* i: scale index offset for first LSF subvector */ - Word32 *p_offset_scale2, /* i: scale index offset for second LSF subvector */ - Word16 *p_no_scales /* i: number of scales for each MSLVQ structure and each subvector */ + Word16 *index, /* i : index to be decoded, as an array of 3 short */ + Word16 *x_lvq, /* o : decoded codevector Q9 */ + Word16 idx_cv, /* i : relative mode_lvq, wrt START_CNG */ + Word16 no_bits, /* i : number of bits for lattice */ + Word32 *p_offset_scale1, /* i : scale index offset for first LSF subvector */ + Word32 *p_offset_scale2, /* i : scale index offset for second LSF subvector */ + Word16 *p_no_scales /* i : number of scales for each MSLVQ structure and each subvector */ ) { Word16 i; @@ -849,10 +836,10 @@ Word16 deindex_lvq_cng_fx( *----------------------------------------------------------------------------------------------------*/ Word16 deindex_lvq_cng_ivas_fx( - Word16 *index, /* i: index to be decoded, as an array of 3 short */ - Word16 *x_lvq, /* o: decoded codevector Q9 */ - Word16 idx_cv, /* i: relative mode_lvq, wrt START_CNG */ - Word16 no_bits /* i: number of bits for lattice */ + Word16 *index, /* i : index to be decoded, as an array of 3 short */ + Word16 *x_lvq, /* o : decoded codevector Q9 */ + Word16 idx_cv, /* i : relative mode_lvq, wrt START_CNG */ + Word16 no_bits /* i : number of bits for lattice */ ) { Word16 i; @@ -1073,9 +1060,10 @@ static void decode_leaders_fx( } /* divide_32_32_fx() :Division reminder - rem is the reminder of the division between y and x. */ -static Word32 divide_32_32_fx( Word32 y, /* i */ - Word32 x, /* i */ - Word32 *rem /* o */ +static Word32 divide_32_32_fx( + Word32 y, /* i */ + Word32 x, /* i */ + Word32 *rem /* o */ ) { Word32 result, t, L_tmp; @@ -1133,15 +1121,15 @@ static Word32 divide_32_32_fx( Word32 y, /* i */ } /* divide_32_32_fx() :Division reminder for Word16 - rem is the reminder of the division between y and x. */ -static Word16 divide_16_16_fx( Word16 y, /* i */ - Word16 x, /* i */ - Word16 *rem /* o */ +static Word16 divide_16_16_fx( + Word16 y, /* i */ + Word16 x, /* i */ + Word16 *rem /* o */ ) { Word16 result, t, tmp; Word16 i, ny, nx, nyx; - IF( LT_32( y, x ) ) { result = 0; @@ -1191,9 +1179,11 @@ static Word16 divide_16_16_fx( Word16 y, /* i */ *rem = t; move16(); } + return result; } + static void divide_64_32_fx( Word16 *xs, /* i : denominator as array of two int32 */ Word32 y, /* i : nominator on 32 bits */ @@ -1245,7 +1235,7 @@ static void divide_64_32_fx( } static void put_value_fx( - Word16 *cv, /* i/o : input codevector Q1*/ + Word16 *cv, /* i/o: input codevector Q1*/ Word16 *p, /* i : array with positions */ Word16 val, /* i : value to be inserted Q1*/ Word16 dim, /* i : vector dimension */ @@ -1388,6 +1378,7 @@ void sort_desc_ind_32_fx( return; } + void deindex_lvq_SHB_fx( UWord32 index, Word16 *out, diff --git a/lib_com/nelp_fx.c b/lib_com/nelp_fx.c index 03b80f7ded5afa86d2613cc93a55e9f030d636f7..4a4cb66b121dec3ac1fdc6054836618411a69c2d 100644 --- a/lib_com/nelp_fx.c +++ b/lib_com/nelp_fx.c @@ -39,8 +39,8 @@ /* FUNCTION : dequantize_uvg_fx() */ /*-------------------------------------------------------------------*/ /* PURPOSE : This function returns the quantized gain - vector given the indices in the gain - quantization tables */ + vector given the indices in the gain + quantization tables */ /*-------------------------------------------------------------------*/ /* INPUT ARGUMENTS : */ /* _ (Word16) iG1 : index into UVG1CB_fx table (Q0) */ @@ -56,11 +56,12 @@ /* RETURN ARGUMENTS : */ /* _ None. */ /*===================================================================*/ + Word16 dequantize_uvg_fx( - const Word16 iG1, /* i: gain 1 index */ - const Word16 *iG2, /* i: gain 2 index */ - Word16 *G, /* o: quantized gain */ - const Word16 bwidth_fx, /* i: bandwidth */ + const Word16 iG1, /* i : gain 1 index */ + const Word16 *iG2, /* i : gain 2 index */ + Word16 *G, /* o : quantized gain */ + const Word16 bwidth_fx, /* i : bandwidth */ const Word16 do_scale ) { Word16 i, k; @@ -148,15 +149,15 @@ Word16 dequantize_uvg_fx( /* FUNCTION : generate_nelp_excitation_fx */ /*-------------------------------------------------------------------*/ /* PURPOSE : This function computes the random - excitation scaled by gain */ + excitation scaled by gain */ /*-------------------------------------------------------------------*/ /* INPUT ARGUMENTS : */ -/* _ (Word16*) Gains : Gain vector (Q_exc) */ +/* _ (Word16*) Gains : Gain vector (Q_exc) */ /* _ (Word16) gain_fac : gain factor (Q14) */ /*-------------------------------------------------------------------*/ /* OUTPUT ARGUMENTS : */ /* _ (Word16*) seed : Random seed (Q0) */ -/* _ (Word16*) output : excitation output (Q_exc) */ +/* _ (Word16*) output : excitation output (Q_exc) */ /*-------------------------------------------------------------------*/ /* INPUT/OUTPUT ARGUMENTS : */ /* _ None. */ @@ -164,6 +165,7 @@ Word16 dequantize_uvg_fx( /* RETURN ARGUMENTS : */ /* _ None. */ /*===================================================================*/ + void generate_nelp_excitation_fx( Word16 *seed, /* i/o: random number seed */ const Word16 *Gains, /* i : excitation gains Q_exc*/ @@ -247,4 +249,6 @@ void generate_nelp_excitation_fx( move16(); } } + + return; } diff --git a/lib_com/pred_lt4_fx.c b/lib_com/pred_lt4_fx.c index b04456870275c50cc5f02f259d093d6f1c991319..f4f68f58ad74765c49c99791613e772db871df47 100644 --- a/lib_com/pred_lt4_fx.c +++ b/lib_com/pred_lt4_fx.c @@ -156,10 +156,11 @@ void pred_lt4( /* RETURN ARGUMENTS : */ /* NONE */ /*=======================================================================*/ + void pred_lt4_tc_fx( Word16 exc[], /* i/o: excitation buffer Q0*/ const Word16 T0, /* i : integer pitch lag Q0*/ - Word16 frac, /* i: fraction of lag Q0*/ + Word16 frac, /* i : fraction of lag Q0*/ const Word16 *win, /* i : interpolation window Q14*/ const Word16 imp_pos, /* i : glottal impulse position Q0*/ const Word16 i_subfr /* i : subframe index Q0*/ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index a4a32366e6dc07bb41847717659e3d5eb48f0c2b..6c88c2a257fadab19f9bca8fbb2748933ae24a46 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -889,31 +889,31 @@ void msvq_dec( ); Word16 tcxlpc_get_cdk( - Word16 coder_type /* (I) VOICED indicator */ + Word16 coder_type /* i : VOICED indicator */ ); void lsf_syn_mem_restore_fx( - Encoder_State *st_fx, /* o: state structure */ - Word16 btilt_code_fx, /* i: Q15 */ - Word32 gc_threshold_fx, /* i: Q16 */ - Word16 *clip_var_bck_fx, /* i: Q(2.56), Q14, Q7, Q0, Q14, Q14 */ - Word16 next_force_sf_bck_fx, /* i: */ - Word16 *lsp_new, /* o: LSP vector to quantize Q15 */ - Word16 *lsf_new, /* o: quantized LSF vector Q15 */ - Word16 *lsp_mid, /* o: mid-frame LSP vector Q15 */ - Word16 clip_var, /* i: pitch clipping state var Q(2.56) */ - Word16 *mem_AR, /* i: quantizer memory for AR model Q15 */ - Word16 *mem_MA, /* i: quantizer memory for MA model Q15 */ - Word16 *lsp_new_bck, /* i: LSP vector to quantize- backup Q15 */ - Word16 *lsf_new_bck, /* i: quantized LSF vector - backup Q15 */ - Word16 *lsp_mid_bck, /* i: mid-frame LSP vector - backup Q15 */ - Word16 mCb1, /* i: counter for stationary frame after a transition frame */ - Word32 *Bin_E, /* i: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */ - Word32 *Bin_E_old, /* i: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */ - Word16 *mem_syn_bck, /* i: synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */ - Word16 mem_w0_bck, /* i: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */ - Word16 streaklimit, /* i:LSF quantizer Q15 */ - Word16 pstreaklen /* i:LSF quantizer */ + Encoder_State *st_fx, /* o : state structure */ + Word16 btilt_code_fx, /* i : Q15 */ + Word32 gc_threshold_fx, /* i : Q16 */ + Word16 *clip_var_bck_fx, /* i : Q(2.56), Q14, Q7, Q0, Q14, Q14 */ + Word16 next_force_sf_bck_fx, /* i : */ + Word16 *lsp_new, /* o : LSP vector to quantize Q15 */ + Word16 *lsf_new, /* o : quantized LSF vector Q15 */ + Word16 *lsp_mid, /* o : mid-frame LSP vector Q15 */ + Word16 clip_var, /* i : pitch clipping state var Q(2.56) */ + Word16 *mem_AR, /* i : quantizer memory for AR model Q15 */ + Word16 *mem_MA, /* i : quantizer memory for MA model Q15 */ + Word16 *lsp_new_bck, /* i : LSP vector to quantize- backup Q15 */ + Word16 *lsf_new_bck, /* i : quantized LSF vector - backup Q15 */ + Word16 *lsp_mid_bck, /* i : mid-frame LSP vector - backup Q15 */ + Word16 mCb1, /* i : counter for stationary frame after a transition frame */ + Word32 *Bin_E, /* i : FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */ + Word32 *Bin_E_old, /* i : FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */ + Word16 *mem_syn_bck, /* i : synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */ + Word16 mem_w0_bck, /* i : memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */ + Word16 streaklimit, /* i : LSF quantizer Q15 */ + Word16 pstreaklen /* i : LSF quantizer */ ); void lsf_update_memory( @@ -925,25 +925,25 @@ void lsf_update_memory( ); void lsf_syn_mem_backup_fx( - Encoder_State *st_fx, /* i: state structure */ - Word16 *btilt_code, /* i: tilt code */ - Word32 *bgc_threshold, /* i: */ - Word16 *clip_var_bck, /* o: */ - Word16 *next_force_sf_bck, /* o: */ - Word16 *lsp_new, /* i: LSP vector to quantize */ - Word16 *lsf_new, /* i: quantized LSF vector */ - Word16 *lsp_mid, /* i: mid-frame LSP vector */ - Word16 *clip_var, /* o: pitch clipping state var */ - Word16 *mem_AR, /* o: quantizer memory for AR model */ - Word16 *mem_MA, /* o: quantizer memory for AR model */ - Word16 *lsp_new_bck, /* o: LSP vector to quantize- backup */ - Word16 *lsf_new_bck, /* o: quantized LSF vector - backup */ - Word16 *lsp_mid_bck, /* o: mid-frame LSP vector - backup */ - Word16 *mCb1, /* o: counter for stationary frame after a transition frame */ - Word32 *Bin_E, /* o: FFT Bin energy 128 *2 sets */ - Word32 *Bin_E_old, /* o: FFT Bin energy 128 sets */ - Word16 *mem_syn_bck, /* o: synthesis filter memory */ - Word16 *mem_w0_bck, /* o: memory of the weighting filter */ + Encoder_State *st_fx, /* i : state structure */ + Word16 *btilt_code, /* i : tilt code */ + Word32 *bgc_threshold, /* i : */ + Word16 *clip_var_bck, /* o : */ + Word16 *next_force_sf_bck, /* o : */ + Word16 *lsp_new, /* i : LSP vector to quantize */ + Word16 *lsf_new, /* i : quantized LSF vector */ + Word16 *lsp_mid, /* i : mid-frame LSP vector */ + Word16 *clip_var, /* o : pitch clipping state var */ + Word16 *mem_AR, /* o : quantizer memory for AR model */ + Word16 *mem_MA, /* o : quantizer memory for AR model */ + Word16 *lsp_new_bck, /* o : LSP vector to quantize- backup */ + Word16 *lsf_new_bck, /* o : quantized LSF vector - backup */ + Word16 *lsp_mid_bck, /* o : mid-frame LSP vector - backup */ + Word16 *mCb1, /* o : counter for stationary frame after a transition frame */ + Word32 *Bin_E, /* o : FFT Bin energy 128 *2 sets */ + Word32 *Bin_E_old, /* o : FFT Bin energy 128 sets */ + Word16 *mem_syn_bck, /* o : synthesis filter memory */ + Word16 *mem_w0_bck, /* o : memory of the weighting filter */ Word16 *streaklimit, Word16 *pstreaklen ); @@ -3356,12 +3356,6 @@ void GetSinCosTab_fx( Word16 *sinTab, Word16 *cosTab ); -void r_fft_4_fx( - Word16 *farray_ptr_fx, - Word16 size, - Word16 stage, - Word16 isign ); - void copy_phase_fx( DTFS_STRUCTURE *X1_fx, DTFS_STRUCTURE X2_fx, diff --git a/lib_com/range_com_fx.c b/lib_com/range_com_fx.c index 94eb888b72567ff1f3e746a7ec3062d4ba394b3d..d437494f73e7b490acb832827f5fb83a81ed8991 100644 --- a/lib_com/range_com_fx.c +++ b/lib_com/range_com_fx.c @@ -13,9 +13,10 @@ * Get number of bits needed to finalize range coder *-------------------------------------------------------------------*/ -Word16 rc_get_bits2_fx( /* o: Number of bits needed Q0*/ - const Word16 N, /* i: Number of bits currently used Q0*/ - const UWord32 range /* i: Range of range coder Q0*/ +/* o: Number of bits needed Q0*/ +Word16 rc_get_bits2_fx( + const Word16 N, /* i : Number of bits currently used Q0*/ + const UWord32 range /* i : Range of range coder Q0*/ ) { return add( add( N, 2 ), norm_ul( range ) ); diff --git a/lib_com/scale_mem_fx.c b/lib_com/scale_mem_fx.c index 9047c7ea4a40903db214b7ed79988d908a241c66..01c2442a8eb73da4686608a77743e259c61a995f 100644 --- a/lib_com/scale_mem_fx.c +++ b/lib_com/scale_mem_fx.c @@ -185,12 +185,12 @@ Word16 Rescale_exc( * Rescale excitation related memories *-------------------------------------------------------------------*/ void Rescale_mem( - const Word16 Q_exc, /* i : current excitation scaling (>=0) */ - Word16 *prev_Q_syn, /* i/o : scaling factor of previous frame */ - Word16 *Q_syn, /* i/o : scaling factor of frame */ - Word16 *mem_syn2, /* i/o : modified synthesis memory Qexp_scale */ - Word16 *mem_syn_clas_estim_fx, /* i/o : old 12k8 core memory for classification Qexp_scale*/ - const Word16 MaxScaling, /* i: Minimal difference between excitation scaling and synthesis scaling */ + const Word16 Q_exc, /* i : current excitation scaling (>=0) */ + Word16 *prev_Q_syn, /* i/o: scaling factor of previous frame */ + Word16 *Q_syn, /* i/o: scaling factor of frame */ + Word16 *mem_syn2, /* i/o: modified synthesis memory Qexp_scale */ + Word16 *mem_syn_clas_estim_fx, /* i/o: old 12k8 core memory for classification Qexp_scale*/ + const Word16 MaxScaling, /* i : Minimal difference between excitation scaling and synthesis scaling */ Word16 *mem_deemph, /* i/o: speech deemph filter memory Qexp_scale */ Word16 *pst_old_syn, /* i/o: psfiler Qexp_scale*/ Word16 *pst_mem_deemp_err, /* i/o: psfiler Qexp_scale */ @@ -246,7 +246,6 @@ void Rescale_mem( tmp = sub( add( norm_s( tmp ), *Q_syn ), 2 ); /* -2 ... 12 */ } - IF( Vad_flag != 0 ) { new_Q = s_min( sub( Q_exc, 2 ), tmp ); @@ -288,7 +287,7 @@ void Rescale_mem( return; } -// note_ : also present in tools_fx.c which one to take is an issue? + /*-------------------------------------------------------------------* * Scale_sig32 * Note: In order to save complexity, call function only, if exp0 != 0 @@ -312,6 +311,8 @@ void scale_sig32( i = lg; } } + + return; } void scale_sig32_r( @@ -332,6 +333,8 @@ void scale_sig32_r( i = lg; } } + + return; } /*-------------------------------------------------------------------* diff --git a/lib_com/swb_bwe_com_lr_fx.c b/lib_com/swb_bwe_com_lr_fx.c index 4baf7f9a2e33c153d8da706de9389ded6ebc48d7..9b6c6cd8e021ac2dff10fb1a42a1d353fba12f79 100644 --- a/lib_com/swb_bwe_com_lr_fx.c +++ b/lib_com/swb_bwe_com_lr_fx.c @@ -35,7 +35,6 @@ #include "cnst.h" #include "prot_fx.h" #include "rom_com.h" - #include /*-------------------------------------------------------------------* @@ -43,13 +42,14 @@ * * Routine for calculating the predicted signal *-------------------------------------------------------------------*/ + void GetPredictedSignal_fx( - const Word16 *predBuf_fx, /* i: Q8 */ - Word32 *L_outBuf, /* o: Q9 */ - const Word16 lag_fx, /* i: Q0 */ - const Word16 fLen_fx, /* i: Q0 */ - const Word16 lagGains_fx, /* i: Qgain */ - const Word16 Qgain /* i: Q0 */ + const Word16 *predBuf_fx, /* i : Q8 */ + Word32 *L_outBuf, /* o : Q9 */ + const Word16 lag_fx, /* i : Q0 */ + const Word16 fLen_fx, /* i : Q0 */ + const Word16 lagGains_fx, /* i : Qgain */ + const Word16 Qgain /* i : Q0 */ ) { Word16 i; @@ -65,24 +65,28 @@ void GetPredictedSignal_fx( *p_L_outBuf++ = L_shr( L_mult( *p_predBuf++, lagGains_fx ), Qgain ); move32(); } + + return; } + /*-------------------------------------------------------------------* * est_freq_har_decis_fx() * * Harmonic frequency decision matrix *-------------------------------------------------------------------*/ + static void est_freq_har_decis_fx( - Word16 *har_freq_est1, /* o: harmonic analysis 1 */ - Word16 *har_freq_est2, /* o: harmonic analysis 2 */ - Word16 sharp, /* i: pka-avg for group 1 */ - Word16 sharp1, /* i: pka-avg for group 2 */ - Word16 hfe_est_countk1, /* i: group pks count 1 */ - Word16 hfe_est_countk2, /* i: group pks count 2 */ - Word16 k, /* i: group count */ - Word16 k1, /* i: */ - Word16 k2, /* i: */ - Word16 *prev_frm_hfe2 /* i: harmonic estimation */ + Word16 *har_freq_est1, /* o : harmonic analysis 1 */ + Word16 *har_freq_est2, /* o : harmonic analysis 2 */ + Word16 sharp, /* i : pka-avg for group 1 */ + Word16 sharp1, /* i : pka-avg for group 2 */ + Word16 hfe_est_countk1, /* i : group pks count 1 */ + Word16 hfe_est_countk2, /* i : group pks count 2 */ + Word16 k, /* i : group count */ + Word16 k1, /* i : */ + Word16 k2, /* i : */ + Word16 *prev_frm_hfe2 /* i : harmonic estimation */ ) { Word16 temp_hfe2 = 0; @@ -1755,9 +1759,10 @@ void GetSynthesizedSpecThinOut_fx( * compute division with Word16 Q0. ex. 10/2 -> 5 *--------------------------------------------------------------------------*/ -Word16 div_s_ss( /* o: result of division (Word16 Q0) */ - const Word16 n, /* i: numerator (Word16 Q0 */ - const Word16 d /* i: denominator (Word16 Q0) */ +/* o: result of division (Word16 Q0) */ +Word16 div_s_ss( + const Word16 n, /* i : numerator (Word16 Q0 */ + const Word16 d /* i : denominator (Word16 Q0) */ ) { Word16 norm_n, norm_d; @@ -1781,11 +1786,14 @@ Word16 div_s_ss( /* o: result of division (Word16 Q0) */ return res; } + + /*-------------------------------------------------------------------* * hf_parinitiz() * * *-------------------------------------------------------------------*/ + void hf_parinitiz_fx( const Word32 L_total_brate, const Word16 hqswb_clas_fx, @@ -1882,17 +1890,18 @@ void hf_parinitiz_fx( return; } + void GetlagGains_fx( - const Word16 *predBuf_fx, /* i: Qss Low freq. Smoothed Spectrum */ - const Word16 Qss, /* i: Q0 Q value of predBuf */ - const Word32 *L_band_energy, /* i: Qbe Band Energy */ - const Word16 Qbe, /* i: Q0 Q value of band energy */ - const Word16 nBands, /* i: Q0 number of SWB subbands */ - const Word16 *sbWidth, /* i: Q0 width of SWB subbands */ - const Word16 *lagIndices, /* i: Q0 lagIndices */ - const Word16 predBufLen, /* i: Q0 length of predBuf */ - Word16 *lagGains_fx, /* o: QlagGains lagGains */ - Word16 *QlagGains /* o: Q0 Q value of lagGains */ + const Word16 *predBuf_fx, /* i : Qss Low freq. Smoothed Spectrum */ + const Word16 Qss, /* i : Q0 Q value of predBuf */ + const Word32 *L_band_energy, /* i : Qbe Band Energy */ + const Word16 Qbe, /* i : Q0 Q value of band energy */ + const Word16 nBands, /* i : Q0 number of SWB subbands */ + const Word16 *sbWidth, /* i : Q0 width of SWB subbands */ + const Word16 *lagIndices, /* i : Q0 lagIndices */ + const Word16 predBufLen, /* i : Q0 length of predBuf */ + Word16 *lagGains_fx, /* o : QlagGains lagGains */ + Word16 *QlagGains /* o : Q0 Q value of lagGains */ ) { Word16 i; @@ -2726,16 +2735,19 @@ void norm_vec_32_16_scale_fx( vec_out_fx[i] = round_fx( L_shl( L_vec_in[i], exp_shift ) ); move16(); } + + return; } + void get_sigma_fx_har( - const Word32 L_x_abs[], /* i: Qi absolute input */ - const Word16 Qi, /* i: Q0 Q value of x_abs */ - const Word16 avg_fx, /* i: Qavg average of x_abs */ - const Word16 Qavg, /* i: Q0 Q value of avg */ - const Word16 length_fx, /* i: Q0 length */ - Word16 *sigma_fx, /* o: Qsigma sigma */ - Word16 *Qsigma /* o: Q0 Q value of sigma */ + const Word32 L_x_abs[], /* i : Qi absolute input */ + const Word16 Qi, /* i : Q0 Q value of x_abs */ + const Word16 avg_fx, /* i : Qavg average of x_abs */ + const Word16 Qavg, /* i : Q0 Q value of avg */ + const Word16 length_fx, /* i : Q0 length */ + Word16 *sigma_fx, /* o : Qsigma sigma */ + Word16 *Qsigma /* o : Q0 Q value of sigma */ ) { Word16 i; @@ -2834,9 +2846,11 @@ void get_sigma_fx_har( } move16(); move16(); + return; } + void FindNBiggest2_simple_fx_har( const Word32 *L_inBuf, /* i : input buffer (searched) */ const Word16 Qabs_in, /* i : Q value of input buffer */ @@ -3000,22 +3014,26 @@ void FindNBiggest2_simple_fx_har( *n_fx = peak_cnt_fx; move16(); + + return; } /*--------------------------------------------------------------------------* * spectrumsmooth_noiseton() * Spectrum normalization for the the core coder *--------------------------------------------------------------------------*/ -Word16 spectrumsmooth_noiseton_fx( /* o : Qss ss_min */ - Word32 L_spectra[], /* i : Qs core coder */ - /*Word16 Qs,*/ /* i : Q0 Q value for spectra, spectra_ni */ - const Word32 L_spectra_ni[], /* i : Qs core coder with sparse filling */ - Word16 sspectra_fx[], /* o : Qss Smoothed tonal information from core coder */ - Word16 sspectra_diff_fx[], /* o : Qss non tonal infomration for gap filling */ - Word16 sspectra_ni_fx[], /* o : Qss smoothed core coder */ - Word16 *Qss, /* o : Q0 Q value for sspectra* */ - const Word16 fLenLow_fx, /* i : Q0 low frequency boundaries */ - Word16 *ni_seed_fx /* io : Q0 random seed */ + +/* o : Qss ss_min */ +Word16 spectrumsmooth_noiseton_fx( + Word32 L_spectra[], /* i : Qs core coder */ + /*Word16 Qs,*/ /* i : Q0 Q value for spectra, spectra_ni */ + const Word32 L_spectra_ni[], /* i : Qs core coder with sparse filling */ + Word16 sspectra_fx[], /* o : Qss Smoothed tonal information from core coder */ + Word16 sspectra_diff_fx[], /* o : Qss non tonal infomration for gap filling */ + Word16 sspectra_ni_fx[], /* o : Qss smoothed core coder */ + Word16 *Qss, /* o : Q0 Q value for sspectra* */ + const Word16 fLenLow_fx, /* i : Q0 low frequency boundaries */ + Word16 *ni_seed_fx /* io : Q0 random seed */ ) { Word16 i; @@ -3034,7 +3052,6 @@ Word16 spectrumsmooth_noiseton_fx( /* o : Qss ss_ move32(); Word16 rand_a_fx[L_FRAME32k]; - /* pre-prepare random array for float-fix interoperability */ FOR( i = 0; i < fLenLow_fx; i++ ) { @@ -3042,7 +3059,6 @@ Word16 spectrumsmooth_noiseton_fx( /* o : Qss ss_ move16(); } - /*Get the pulse resolution for the core coder*/ pcnt_fx = 0; move16(); @@ -3153,10 +3169,12 @@ Word16 spectrumsmooth_noiseton_fx( /* o : Qss ss_ return ( ss_min_fx ); } + /*--------------------------------------------------------------------------* * noiseinj_hf() * level adjustments for the missing bands in the core coder *--------------------------------------------------------------------------*/ + void noiseinj_hf_fx( Word32 L_xSynth_har[], /* i/o : Qs gap filled information */ Word16 Qs, /* i : Q0 Q value for xSynth_har */ @@ -3338,22 +3356,23 @@ return; * * *--------------------------------------------------------------------------*/ + void updat_prev_frm_fx( Word32 L_y2[], /* i/o: core coder buffer */ - Word32 L_t_audio[], /* o: core coder buffer */ - Word32 L_bwe_br, /* i: core bitrate */ - Word16 length_fx, /* i: frame length coded bw */ - const Word16 inner_frame_fx, /* i: input frame length */ - Word16 bands_fx, /* i: sub band resolution */ - Word16 bwidth_fx, /* i: NB/WB/SWB indicator */ - const Word16 is_transient_fx, /* i: signal class information */ - Word16 hqswb_clas_fx, /* i: signal class information */ - Word16 *prev_hqswb_clas, /* o: update signal class information */ - Word16 prev_SWB_peak_pos_fx[], /* o: update core coder last coded peaks*/ - Word16 prev_SWB_peak_pos_tmp_fx[], /* o: update core coder last coded peaks*/ - Word16 *prev_frm_hfe2, /* o: update harmonics */ - Word16 *prev_stab_hfe2, /* o: update harmonics */ - Word16 bws_cnt_fx /* i: band width detector */ + Word32 L_t_audio[], /* o : core coder buffer */ + Word32 L_bwe_br, /* i : core bitrate */ + Word16 length_fx, /* i : frame length coded bw */ + const Word16 inner_frame_fx, /* i : input frame length */ + Word16 bands_fx, /* i : sub band resolution */ + Word16 bwidth_fx, /* i : NB/WB/SWB indicator */ + const Word16 is_transient_fx, /* i : signal class information */ + Word16 hqswb_clas_fx, /* i : signal class information */ + Word16 *prev_hqswb_clas, /* o : update signal class information */ + Word16 prev_SWB_peak_pos_fx[], /* o : update core coder last coded peaks*/ + Word16 prev_SWB_peak_pos_tmp_fx[], /* o : update core coder last coded peaks*/ + Word16 *prev_frm_hfe2, /* o : update harmonics */ + Word16 *prev_stab_hfe2, /* o : update harmonics */ + Word16 bws_cnt_fx /* i : band width detector */ ) { Word16 i, j, k; diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 8a9aad1a642f3e4037edb48820a834ec6f5926f3..96db4fb331317f6b16924f9b4ef919ba9ba65e6b 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -325,12 +325,7 @@ void flip_and_downmix_generic_fx( } /* Hilber transform stage - 0 - single precision */ - Hilbert_transform_sp_fx( tmp_16, /* i: Real component of HB */ - tmp_16, /* i: Imag component of HB */ - tmpi_R, /* o: Real component of HB */ - tmpi_I, /* o: Imag. component of HB */ - length, /* i: length of the spectra */ - 0 ); /* i: HB transform stage */ + Hilbert_transform_sp_fx( tmp_16, tmp_16, tmpi_R, tmpi_I, length, 0 ); FOR( i = 0; i < HILBERT_ORDER1; i++ ) { @@ -342,34 +337,19 @@ void flip_and_downmix_generic_fx( Copy32( mem3_ext, tmpi2_I, HILBERT_ORDER2 ); /* Hilber transform stage - 1 */ - Hilbert_transform_fx( tmpi_R, /* i: Real component of HB */ - tmpi_I, /* i: Imag component of HB */ - tmpi2_R, /* o: Real component of HB */ - tmpi2_I, /* o: Imag. component of HB */ - length, /* i: length of the spectra */ - 1 ); /* i: HB transform stage */ + Hilbert_transform_fx( tmpi_R, tmpi_I, tmpi2_R, tmpi2_I, length, 1 ); Copy32( mem2_ext + HILBERT_ORDER2, tmp_R, HILBERT_ORDER2 ); Copy32( mem3_ext + HILBERT_ORDER2, tmp_I, HILBERT_ORDER2 ); /* Hilber transform stage - 2 */ - Hilbert_transform_fx( tmpi2_R, /* i: Real component of HB */ - tmpi2_I, /* i: Imag component of HB */ - tmpi_R, /* o: Real component of HB */ - tmpi_I, /* o: Imag. component of HB */ - length, /* i: length of the spectra */ - 2 ); /* i: HB transform stage */ + Hilbert_transform_fx( tmpi2_R, tmpi2_I, tmpi_R, tmpi_I, length, 2 ); Copy32( tmpi2_R + length, mem2_ext, HILBERT_ORDER2 ); Copy32( tmpi2_I + length, mem3_ext, HILBERT_ORDER2 ); /* Hilber transform stage - 3 */ - Hilbert_transform_fx( tmpi_R, /* i: Real component of HB */ - tmpi_I, /* i: Imag component of HB */ - tmp_R, /* o: Real component of HB */ - tmp_I, /* o: Imag. component of HB */ - length, /* i: length of the spectra */ - 3 ); /* i: HB transform stage */ + Hilbert_transform_fx( tmpi_R, tmpi_I, tmp_R, tmp_I, length, 3 ); Copy32( tmp_R + length, mem2_ext + HILBERT_ORDER2, HILBERT_ORDER2 ); Copy32( tmp_I + length, mem3_ext + HILBERT_ORDER2, HILBERT_ORDER2 ); @@ -412,9 +392,9 @@ void flip_and_downmix_generic_fx( void flip_and_downmix_generic_fx32( - Word32 input[], /* i : input spectrum Qx*/ - Word32 output[], /* o : output spectrum Qx*/ - const Word16 length, /* i : length of spectra */ + Word32 input[], /* i : input spectrum Qx*/ + Word32 output[], /* o : output spectrum Qx*/ + const Word16 length, /* i : length of spectra */ Word32 mem1_ext[HILBERT_ORDER1], /* i/o: memory Qx*/ Word32 mem2_ext[2 * HILBERT_ORDER2], /* i/o: memory Qx*/ Word32 mem3_ext[2 * HILBERT_ORDER2], /* i/o: memory Qx*/ @@ -449,46 +429,27 @@ void flip_and_downmix_generic_fx32( Copy32( mem1_ext, tmp, HILBERT_ORDER1 ); /* Hilber transform stage - 0 - single precision */ - Hilbert_transform_fx( tmp, /* i: Real component of HB */ - tmp, /* i: Imag component of HB */ - tmpi_R, /* o: Real component of HB */ - tmpi_I, /* o: Imag. component of HB */ - length, /* i: length of the spectra */ - 0 ); /* i: HB transform stage */ + Hilbert_transform_fx( tmp, tmp, tmpi_R, tmpi_I, length, 0 ); Copy32( mem2_ext, tmpi2_R, HILBERT_ORDER2 ); Copy32( mem3_ext, tmpi2_I, HILBERT_ORDER2 ); /* Hilber transform stage - 1 */ - Hilbert_transform_fx( tmpi_R, /* i: Real component of HB */ - tmpi_I, /* i: Imag component of HB */ - tmpi2_R, /* o: Real component of HB */ - tmpi2_I, /* o: Imag. component of HB */ - length, /* i: length of the spectra */ - 1 ); /* i: HB transform stage */ + Hilbert_transform_fx( tmpi_R, tmpi_I, tmpi2_R, tmpi2_I, length, 1 ); + Copy32( tmp + length, mem1_ext, HILBERT_ORDER1 ); Copy32( mem2_ext + HILBERT_ORDER2, tmp_R, HILBERT_ORDER2 ); Copy32( mem3_ext + HILBERT_ORDER2, tmp_I, HILBERT_ORDER2 ); /* Hilber transform stage - 2 */ - Hilbert_transform_fx( tmpi2_R, /* i: Real component of HB */ - tmpi2_I, /* i: Imag component of HB */ - tmpi_R, /* o: Real component of HB */ - tmpi_I, /* o: Imag. component of HB */ - length, /* i: length of the spectra */ - 2 ); /* i: HB transform stage */ + Hilbert_transform_fx( tmpi2_R, tmpi2_I, tmpi_R, tmpi_I, length, 2 ); Copy32( tmpi2_R + length, mem2_ext, HILBERT_ORDER2 ); Copy32( tmpi2_I + length, mem3_ext, HILBERT_ORDER2 ); /* Hilber transform stage - 3 */ - Hilbert_transform_fx( tmpi_R, /* i: Real component of HB */ - tmpi_I, /* i: Imag component of HB */ - tmp_R, /* o: Real component of HB */ - tmp_I, /* o: Imag. component of HB */ - length, /* i: length of the spectra */ - 3 ); /* i: HB transform stage */ + Hilbert_transform_fx( tmpi_R, tmpi_I, tmp_R, tmp_I, length, 3 ); Copy32( tmp_R + length, mem2_ext + HILBERT_ORDER2, HILBERT_ORDER2 ); Copy32( tmp_I + length, mem3_ext + HILBERT_ORDER2, HILBERT_ORDER2 ); @@ -526,19 +487,22 @@ void flip_and_downmix_generic_fx32( *phase_state = j; move16(); + return; } + /*---------------------------------------------- * Hilbert transform - Double precision *------------------------------------------------*/ + static void Hilbert_transform_fx( - Word32 tmp_R[], /* i: Real component of HB */ - Word32 tmp_I[], /* i: Real component of HB */ - Word32 tmpi_R[], /* o: Real component of HB */ - Word32 tmpi_I[], /* o: Imag. component of HB */ - const Word16 length, /* i: input length */ - const Word16 HB_stage_id /* i: HB transform stage */ + Word32 tmp_R[], /* i : Real component of HB */ + Word32 tmp_I[], /* i : Real component of HB */ + Word32 tmpi_R[], /* o : Real component of HB */ + Word32 tmpi_I[], /* o : Imag. component of HB */ + const Word16 length, /* i : input length */ + const Word16 HB_stage_id /* i : HB transform stage */ ) { Word16 i, hb_filter_stage, offset; @@ -588,19 +552,22 @@ static void Hilbert_transform_fx( move32(); /*Qx+16 */ } } + + return; } /*---------------------------------------------- * Hilbert transform - Single precision Stage 0 *------------------------------------------------*/ + static void Hilbert_transform_sp_fx( - Word16 tmp_R[], /* i: Real component of HB */ - Word16 tmp_I[], /* i: Real component of HB */ - Word32 tmpi_R[], /* o: Real component of HB */ - Word32 tmpi_I[], /* o: Imag. component of HB */ - const Word16 length, /* i: input length */ - const Word16 HB_stage_id /* i: HB transform stage */ + Word16 tmp_R[], /* i : Real component of HB */ + Word16 tmp_I[], /* i : Real component of HB */ + Word32 tmpi_R[], /* o : Real component of HB */ + Word32 tmpi_I[], /* o : Imag. component of HB */ + const Word16 length, /* i : input length */ + const Word16 HB_stage_id /* i : HB transform stage */ ) { Word16 i, hb_filter_stage, offset; @@ -2002,34 +1969,35 @@ void find_td_envelope_fx( /*--------------------------------------------------------------------------------------*/ /* CALLED FROM : RX */ /*======================================================================================*/ + void GenShapedSHBExcitation_fx( - Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ - const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ - Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc */ + Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ + const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ + Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc */ Word32 *mem_csfilt, /* i/o: memory */ Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */ Word16 *state_lpc_syn, /* i/o: memory */ - const Word16 coder_type, /* i : coding type */ - const Word16 element_mode, /* i : element mode */ - const Word16 *bwe_exc_extended, /* i : bwidth extended excitation */ + const Word16 coder_type, /* i : coding type */ + const Word16 element_mode, /* i : element mode */ + const Word16 *bwe_exc_extended, /* i : bwidth extended excitation */ Word16 bwe_seed[], /* i/o: random number generator seed */ - Word16 voice_factors[], /* i : voicing factor*/ - const Word16 extl, /* i : extension layer */ + Word16 voice_factors[], /* i : voicing factor*/ + const Word16 extl, /* i : extension layer */ Word16 *tbe_demph, /* i/o: de-emphasis memory */ Word16 *tbe_premph, /* i/o: pre-emphasis memory */ - Word16 *lpc_shb_sf, /* i: LP coefficients */ - const Word32 shb_ener_sf_32, /* i: input shb ener, Q31 */ - Word16 *shb_res_gshape, /* i: input res gain shape, Q14 */ + Word16 *lpc_shb_sf, /* i : LP coefficients */ + const Word32 shb_ener_sf_32, /* i : input shb ener, Q31 */ + Word16 *shb_res_gshape, /* i : input res gain shape, Q14 */ Word16 *shb_res, Word16 *vf_ind, - const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ + const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ Word16 fb_state_lpc_syn[], /* i/o: memory */ Word16 *fb_tbe_demph, /* i/o: fb de-emphasis memory */ Word16 *Q_bwe_exc, Word16 *Q_bwe_exc_fb, const Word16 Q_shb, - Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ - Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ + Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ + Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ const Word32 bitrate, const Word16 prev_bfi ) { diff --git a/lib_com/tcx_utils_fx.c b/lib_com/tcx_utils_fx.c index 7caf1b778ce27abfde805f9f00b2d31f29065e77..6ebd1dbf5b02b650624a82e4c978d605c4fc4a80 100644 --- a/lib_com/tcx_utils_fx.c +++ b/lib_com/tcx_utils_fx.c @@ -17,8 +17,10 @@ * * *-------------------------------------------------------------------*/ -Word16 getInvFrameLen( /* returns 1/L_frame in Q21 format */ - const Word16 L_frame ) + +/* returns 1/L_frame in Q21 format */ +Word16 getInvFrameLen( + const Word16 L_frame ) { Word16 idx, s; @@ -30,23 +32,24 @@ Word16 getInvFrameLen( /* returns 1/L_frame in Q21 format */ idx = mult_r( idx, 0x10 ); /* idx = shr(add(idx, 0x0400), 11); */ idx = s_and( idx, 7 ); - return shl( L_frame_inv[idx], sub( s, 7 ) ); } + + /*-------------------------------------------------------------------* *tcx_get_windows() * * * ------------------------------------------------------------------ - */ void tcx_get_windows( - TCX_CONFIG_HANDLE hTcxCfg, /* i : TCX configuration */ - const Word16 left_mode, /* i: overlap mode of left window half Q0*/ - const Word16 right_mode, /* i: overlap mode of right window half Q0*/ - Word16 *left_overlap, /* o: left overlap length Q0*/ - const PWord16 **left_win, /* o: left overlap window Q15*/ - Word16 *right_overlap, /* o: right overlap length Q0*/ - const PWord16 **right_win, /* o: right overlap window Q15*/ - const Word8 fullband /* i: fullband flag Q0*/ + TCX_CONFIG_HANDLE hTcxCfg, /* i : TCX configuration */ + const Word16 left_mode, /* i : overlap mode of left window half Q0*/ + const Word16 right_mode, /* i : overlap mode of right window half Q0*/ + Word16 *left_overlap, /* o : left overlap length Q0*/ + const PWord16 **left_win, /* o : left overlap window Q15*/ + Word16 *right_overlap, /* o : right overlap length Q0*/ + const PWord16 **right_win, /* o : right overlap window Q15*/ + const Word8 fullband /* i : fullband flag Q0*/ ) { /* LFE is only FULL_OVERLAP*/ IF( fullband == 0 ) @@ -161,16 +164,18 @@ void tcx_get_windows( assert( !"Not supported overlap" ); } } + + return; } static void tcx_windowing_analysis( - Word16 const *signal, /* i: signal vector Qx*/ - Word16 L_frame, /* i: frame length Q0*/ - Word16 left_overlap, /* i: left overlap length Q0*/ - PWord16 const *left_win, /* i: left overlap window Q15*/ - Word16 right_overlap, /* i: right overlap length Q0*/ - PWord16 const *right_win, /* i: right overlap window Q15*/ - Word16 *output /* o: windowed signal vector Qx*/ + Word16 const *signal, /* i : signal vector Qx*/ + Word16 L_frame, /* i : frame length Q0*/ + Word16 left_overlap, /* i : left overlap length Q0*/ + PWord16 const *left_win, /* i : left overlap window Q15*/ + Word16 right_overlap, /* i : right overlap length Q0*/ + PWord16 const *right_win, /* i : right overlap window Q15*/ + Word16 *output /* o : windowed signal vector Qx*/ ) { Word16 w, n; @@ -208,31 +213,35 @@ static void tcx_windowing_analysis( *output++ = mult_r( *signal++, right_win[n - 1 - w].v.im ); /*Qx*/ move16(); } + + return; } + + /*-------------------------------------------------------------------* * WindowSignal() * * *-------------------------------------------------------------------*/ + void WindowSignal( - TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ - Word16 offset, /* i : left folding point offset relative to the input signal pointer Q0*/ - const Word16 left_overlap_mode, /* i : overlap mode of left window half Q0*/ - Word16 right_overlap_mode, /* i : overlap mode of right window half Q0*/ - Word16 *left_overlap_length, /* o : TCX window left overlap length Q0*/ - Word16 *right_overlap_length, /* o : TCX window right overlap length Q0*/ - const Word16 in[], /* i : input signal Qx*/ - Word16 *L_frame, /* i/o: frame length Q0*/ - Word16 out[], /* o : output windowed signal Qx*/ + TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ + Word16 offset, /* i : left folding point offset relative to the input signal pointer Q0*/ + const Word16 left_overlap_mode, /* i : overlap mode of left window half Q0*/ + Word16 right_overlap_mode, /* i : overlap mode of right window half Q0*/ + Word16 *left_overlap_length, /* o : TCX window left overlap length Q0*/ + Word16 *right_overlap_length, /* o : TCX window right overlap length Q0*/ + const Word16 in[], /* i : input signal Qx*/ + Word16 *L_frame, /* i/o: frame length Q0*/ + Word16 out[], /* o : output windowed signal Qx*/ const Word16 truncate_aldo, /* i : nonzero to truncate long ALDO slope Q0*/ - const Word8 fullband /* i : fullband flag Q0*/ + const Word8 fullband /* i : fullband flag Q0*/ ) { Word16 l, r; PWord16 const *left_win; PWord16 const *right_win; - /*-----------------------------------------------------------* * Init * *-----------------------------------------------------------*/ @@ -296,7 +305,11 @@ void WindowSignal( move16(); *right_overlap_length = r; move16(); + + return; } + + /*-------------------------------------------------------------------* * tcx_windowing_synthesis_current_frame() * @@ -305,15 +318,15 @@ void WindowSignal( void tcx_windowing_synthesis_current_frame( Word16 *signal, /* i/o: signal vector Qx*/ - const PWord16 *window, /* i: TCX window vector Q15*/ - const PWord16 *window_half, /* i: TCX window vector for half-overlap window Q15*/ - const PWord16 *window_min, /* i: TCX minimum overlap window Q15*/ - const Word16 window_length, /* i: TCX window length Q0*/ - const Word16 window_half_length, /* i: TCX half window length Q0*/ - const Word16 window_min_length, /* i: TCX minimum overlap length Q0*/ - const Word16 left_rect, /* i: left part is rectangular Q0*/ - const Word16 left_mode, /* i: overlap mode of left window half Q0*/ - Word16 *acelp_zir, /* i: acelp ZIR Qx*/ + const PWord16 *window, /* i : TCX window vector Q15*/ + const PWord16 *window_half, /* i : TCX window vector for half-overlap window Q15*/ + const PWord16 *window_min, /* i : TCX minimum overlap window Q15*/ + const Word16 window_length, /* i : TCX window length Q0*/ + const Word16 window_half_length, /* i : TCX half window length Q0*/ + const Word16 window_min_length, /* i : TCX minimum overlap length Q0*/ + const Word16 left_rect, /* i : left part is rectangular Q0*/ + const Word16 left_mode, /* i : overlap mode of left window half Q0*/ + Word16 *acelp_zir, /* i : acelp ZIR Qx*/ const Word16 *old_syn, /*Qx*/ const Word16 *syn_overl, /*Qx*/ const Word16 *A_zir, /*Q12*/ @@ -324,7 +337,6 @@ void tcx_windowing_synthesis_current_frame( const Word8 last_is_cng, /*Q0*/ const Word16 fullbandScale /*Q0*/ ) { - Word16 i, overlap, n, tmp, tmp2; Word16 tmp_buf[L_FRAME_MAX / 2]; Word32 L_tmp; @@ -575,21 +587,26 @@ void tcx_windowing_synthesis_current_frame( } /* Right part asymmetric window : with ALDO do nothing->can be skipped*/ + + return; } + + /*-------------------------------------------------------------------* * tcx_windowing_synthesis_past_frame() * * *-------------------------------------------------------------------*/ + void tcx_windowing_synthesis_past_frame( - Word16 *signal, /* i/o: signal vector Qx*/ - const PWord16 *window, /* i: TCX window vector Q15*/ - const PWord16 *window_half, /* i: TCX window vector for half-overlap window Q15*/ - const PWord16 *window_min, /* i: TCX minimum overlap window Q15*/ - const Word16 window_length, /* i: TCX window length Q0*/ - const Word16 window_half_length, /* i: TCX half window length Q0*/ - const Word16 window_min_length, /* i: TCX minimum overlap length Q0*/ - const Word16 right_mode /* i: overlap mode (left_mode of current frame) Q0*/ + Word16 *signal, /* i/o: signal vector Qx*/ + const PWord16 *window, /* i : TCX window vector Q15*/ + const PWord16 *window_half, /* i : TCX window vector for half-overlap window Q15*/ + const PWord16 *window_min, /* i : TCX minimum overlap window Q15*/ + const Word16 window_length, /* i : TCX window length Q0*/ + const Word16 window_half_length, /* i : TCX half window length Q0*/ + const Word16 window_min_length, /* i : TCX minimum overlap length Q0*/ + const Word16 right_mode /* i : overlap mode (left_mode of current frame) Q0*/ ) { @@ -657,7 +674,11 @@ void tcx_windowing_synthesis_past_frame( signal[window_length - 1 - i] = mult_r( signal[window_length - 1 - i], window[i].v.im ); /*Qx*/ } } + + return; } + + /*-------------------------------------------------------------------* * lpc2mdct() * @@ -799,8 +820,11 @@ void lpc2mdct( k = add( k, 1 ); } } + + return; } + void lpc2mdct_2( Word16 *lpcCoeffs, /*Q12*/ const Word16 lpcOrder, /*Q0*/ @@ -954,6 +978,8 @@ void lpc2mdct_2( return; } + + /** * \brief Perform mdct shaping. In the floating point software there are two functions, * mdct_noiseShaping and mdct_preShaping, which are combined here into a single function. @@ -970,7 +996,6 @@ void mdct_shaping( /*const Word16 nBands*/ /*Parameter added in IVAS, but always equal to FDNS_NPTS */ ) { - Word16 i, k, l; Word16 m, n, k1, k2, j; Word32 *px = x; /*Qx*/ @@ -1053,6 +1078,8 @@ void mdct_shaping( } } } + + return; } void mdct_shaping_16( @@ -1107,8 +1134,11 @@ void mdct_shaping_16( y[i] = L_shl( L_mult( x[i], gains[FDNS_NPTS - 1] ), gain_exp ); /*Qx*/ move32(); } + + return; } + void mdct_noiseShaping_ivas_fx( Word32 x_fx[], /*Q31 - x_e*/ Word16 *x_e, @@ -1215,7 +1245,6 @@ void mdct_noiseShaping_interp( Word16 i, j, jp, jn, k, l; Word16 g, pg, ng, e, tmp; - assert( lg % FDNS_NPTS == 0 ); k = shr( lg, 6 ); /* FDNS_NPTS = 64 Q0*/ @@ -1360,8 +1389,11 @@ void mdct_noiseShaping_interp( } } } + + return; } + void PsychAdaptLowFreqDeemph( Word32 x[], /*Qx*/ const Word16 lpcGains[], /*Q15 - lpcGains_e*/ @@ -1433,8 +1465,11 @@ void PsychAdaptLowFreqDeemph( fac = mult_r( fac, tmp ); /* Q15 */ } } + + return; } + void AdaptLowFreqDeemph( Word32 x[], /*Q31 - x_e*/ Word16 x_e, @@ -1621,8 +1656,11 @@ void AdaptLowFreqDeemph( { PsychAdaptLowFreqDeemph( x, lpcGains, lpcGains_e, lf_deemph_factors ); } /*if(!tcx_lpc_shaped_ari)*/ + + return; } + void tcx_noise_filling( Word32 *Q, /*Q31 - Q_e*/ Word16 Q_e, @@ -1644,7 +1682,6 @@ void tcx_noise_filling( Word16 tmp1, tmp2, s; Word32 tmp32; - /* get inverse frame length */ tmp1 = getInvFrameLen( L_frame ); /*Q21*/ @@ -1761,6 +1798,8 @@ void tcx_noise_filling( move32(); } } + + return; } void tcx_noise_filling_with_shift( @@ -1965,6 +2004,8 @@ void tcx_noise_filling_with_shift( *Q_e = max_e; move16(); + + return; } @@ -1972,7 +2013,6 @@ void tcx_noise_filling_with_shift( * InitTnsConfigs() *--------------------------------------------------------------*/ - void InitTnsConfigs_fx( const Word16 bwidth, /*Q0*/ const Word16 L_frame, /*Q0*/ @@ -1986,10 +2026,15 @@ void InitTnsConfigs_fx( { InitTnsConfiguration_fx( bwidth, shr( L_frame, 1 ), &tnsConfig[0][0], igfStopFreq, total_brate, element_mode, MCT_flag ); } + InitTnsConfiguration_fx( bwidth, L_frame, &tnsConfig[1][0], igfStopFreq, total_brate, element_mode, MCT_flag ); + InitTnsConfiguration_fx( bwidth, add( L_frame, shr( L_frame, 2 ) ), &tnsConfig[1][1], igfStopFreq, total_brate, element_mode, MCT_flag ); + + return; } + void SetTnsConfig( TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ const Word16 isTCX20, /*Q0*/ @@ -1998,6 +2043,8 @@ void SetTnsConfig( move16(); hTcxCfg->pCurrentTnsConfig = &hTcxCfg->tnsConfig[isTCX20][isAfterACELP]; assert( hTcxCfg->pCurrentTnsConfig != NULL ); + + return; } /*-------------------------------------------------------------------* @@ -2019,19 +2066,21 @@ void SetAllowTnsOnWhite( move16(); tnsConfig[1][1].allowTnsOnWhite = allowTnsOnWhite; move16(); + return; } + void tcx_get_gain( - Word32 *x, /* i: spectrum 1 Q31 - x_e*/ - Word16 x_e, /* i: spectrum 1 exponent */ - Word32 *y, /* i: spectrum 2 Q31 - y_e*/ - Word16 y_e, /* i: spectrum 2 exponent */ - Word16 n, /* i: length Q0*/ - Word16 *gain, /* o: gain Q15 - gain_e*/ - Word16 *gain_e, /* o: gain exponent */ - Word32 *en_y, /* o: energy of y (optional) Q31 - en_y_e*/ - Word16 *en_y_e /* o: energy of y exponent (optional) */ + Word32 *x, /* i : spectrum 1 Q31 - x_e*/ + Word16 x_e, /* i : spectrum 1 exponent */ + Word32 *y, /* i : spectrum 2 Q31 - y_e*/ + Word16 y_e, /* i : spectrum 2 exponent */ + Word16 n, /* i : length Q0*/ + Word16 *gain, /* o : gain Q15 - gain_e*/ + Word16 *gain_e, /* o : gain exponent */ + Word32 *en_y, /* o : energy of y (optional) Q31 - en_y_e*/ + Word16 *en_y_e /* o : energy of y exponent (optional) */ ) { Word32 maxX, minX, maxY, minY; @@ -2103,7 +2152,11 @@ void tcx_get_gain( *en_y_e = ener_e; move16(); } + + return; } + + void init_TCX_config( TCX_CONFIG_HANDLE hTcxCfg, Word16 L_frame, /*Q0*/ @@ -2151,4 +2204,6 @@ void init_TCX_config( /*ALDO windows for MODE2*/ mdct_window_aldo( hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, L_frame ); mdct_window_aldo( hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, L_frameTCX ); + + return; } diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index 1f491ced83fbf403917adf35f4bad4309812994f..ea87bb5f9ffa6cd163a4a9824cc38dd6580c6775 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -837,9 +837,9 @@ void sort( /* Qx*/ Word16 usdequant_fx( - const Word16 idx, /* i: quantizer index Q0*/ - const Word16 qlow, /* i: lowest codebook entry (index 0) Qx*/ - const Word16 delta /* i: quantization step Qx-1*/ + const Word16 idx, /* i : quantizer index Q0*/ + const Word16 qlow, /* i : lowest codebook entry (index 0) Qx*/ + const Word16 delta /* i : quantization step Qx-1*/ ) { Word16 g; @@ -854,9 +854,9 @@ Word16 usdequant_fx( /* Qx*/ Word32 usdequant32_fx( - const Word16 idx, /* i: quantizer index Q0*/ - const Word32 qlow, /* i: lowest codebook entry (index 0) Qx*/ - const Word32 delta /* i: quantization step Qx-1*/ + const Word16 idx, /* i : quantizer index Q0*/ + const Word32 qlow, /* i : lowest codebook entry (index 0) Qx*/ + const Word32 delta /* i : quantization step Qx-1*/ ) { Word32 g; @@ -890,11 +890,11 @@ Word32 usdequant32_fx( /* o: index of the winning codeword */ Word16 usquant_fx( - const Word16 x, /* i: scalar value to quantize Qx*/ - Word16 *xq, /* o: quantized value Qx*/ - const Word16 qlow, /* i: lowest codebook entry (index 0) Qx*/ - const Word16 delta, /* i: quantization step Qx-1*/ - const Word16 cbsize /* i: codebook size */ + const Word16 x, /* i : scalar value to quantize Qx*/ + Word16 *xq, /* o : quantized value Qx*/ + const Word16 qlow, /* i : lowest codebook entry (index 0) Qx*/ + const Word16 delta, /* i : quantization step Qx-1*/ + const Word16 cbsize /* i : codebook size */ ) { Word16 idx; @@ -2100,9 +2100,9 @@ Word32 sum32_sat( /* o: variance of vector Qx+16*/ Word32 var_fx_32( - const Word16 *x, /* i: input vector Qx*/ + const Word16 *x, /* i : input vector Qx*/ const Word16 Qx, - const Word16 len /* i: length of inputvector */ + const Word16 len /* i : length of inputvector */ ) { Word16 m; @@ -2135,9 +2135,9 @@ Word32 var_fx_32( /* o: variance of vector Qx*/ Word32 var_fx_32in_32out( - const Word32 *x, /* i: input vector Qx*/ - Word16 *Qx, /*i/o:Q for input/output */ - const Word16 len, /* i: length of inputvector */ + const Word32 *x, /* i : input vector Qx*/ + Word16 *Qx, /* i/o:Q for input/output */ + const Word16 len, /* i : length of inputvector */ const Word16 gb ) { Word16 i; @@ -2235,9 +2235,9 @@ Flag conv_fx_32( /* o: variance of vector Qx*/ Word16 var_fx( - const Word16 *x, /* i: input vector Qx*/ + const Word16 *x, /* i : input vector Qx*/ const Word16 Qx, - const Word16 len /* i: length of inputvector */ + const Word16 len /* i : length of inputvector */ ) { Word16 m; @@ -2279,8 +2279,8 @@ Word16 var_fx( /* o: standard deviation */ Word16 std_fx( - const Word16 x[], /* i: input vector */ - const Word16 len /* i: length of the input vector */ + const Word16 x[], /* i : input vector */ + const Word16 len /* i : length of the input vector */ ) { Word16 i; @@ -2382,12 +2382,12 @@ void Vr_subt( /* o: index of the winning codevector */ Word16 vquant_fx_32( - Word32 x[], /* i: vector to quantize Q25 */ - const Word32 x_mean[], /* i: vector mean to subtract (0 if none) Q25 */ - Word32 xq[], /* o: quantized vector Q25 */ - const Word32 cb[], /* i: codebook Q25 */ - const Word16 dim, /* i: dimension of codebook vectors */ - const Word16 cbsize /* i: codebook size */ + Word32 x[], /* i : vector to quantize Q25 */ + const Word32 x_mean[], /* i : vector mean to subtract (0 if none) Q25 */ + Word32 xq[], /* o : quantized vector Q25 */ + const Word32 cb[], /* i : codebook Q25 */ + const Word16 dim, /* i : dimension of codebook vectors */ + const Word16 cbsize /* i : codebook size */ ) { Word16 c, d, idx, j; @@ -2453,12 +2453,12 @@ Word16 vquant_fx_32( /* o: index of the winning codevector */ Word16 vquant_fx( - Word16 x[], /* i: vector to quantize Q13 */ - const Word16 x_mean[], /* i: vector mean to subtract (0 if none) Q13 */ - Word16 xq[], /* o: quantized vector Q13 */ - const Word16 cb[], /* i: codebook Q13 */ - const Word16 dim, /* i: dimension of codebook vectors */ - const Word16 cbsize /* i: codebook size */ + Word16 x[], /* i : vector to quantize Q13 */ + const Word16 x_mean[], /* i : vector mean to subtract (0 if none) Q13 */ + Word16 xq[], /* o : quantized vector Q13 */ + const Word16 cb[], /* i : codebook Q13 */ + const Word16 dim, /* i : dimension of codebook vectors */ + const Word16 cbsize /* i : codebook size */ ) { Word16 tmp; @@ -2535,13 +2535,13 @@ Word16 vquant_fx( *-------------------------------------------------------------------*/ Word16 w_vquant_fx( - Word16 x[], /* i: vector to quantize in Q10 */ + Word16 x[], /* i : vector to quantize in Q10 */ Word16 Qx, - const Word16 weights[], /* i: error weights in Q0 */ - Word16 xq[], /* o: quantized vector in Q15 */ - const Word16 cb[], /* i: codebook in Q15 */ - const Word16 cbsize, /* i: codebook size */ - const Word16 rev_vect /* i: reverse codebook vectors */ + const Word16 weights[], /* i : error weights in Q0 */ + Word16 xq[], /* o : quantized vector in Q15 */ + const Word16 cb[], /* i : codebook in Q15 */ + const Word16 cbsize, /* i : codebook size */ + const Word16 rev_vect /* i : reverse codebook vectors */ ) { Word16 tmp; @@ -3453,10 +3453,10 @@ void v_sub_16( /* o: index of the winning codeword */ Word16 squant_fx( - const Word16 x, /* i: scalar value to quantize */ - Word16 *xq, /* o: quantized value */ - const Word16 cb[], /* i: codebook */ - const Word16 cbsize /* i: codebook size */ + const Word16 x, /* i : scalar value to quantize */ + Word16 *xq, /* o : quantized value */ + const Word16 cb[], /* i : codebook */ + const Word16 cbsize /* i : codebook size */ ) { Word16 tmp; @@ -3859,11 +3859,11 @@ void add_vec_fx( /* o: Result (Normalized) */ Word32 Add_flt32_flt32( - Word32 a, /* i: 1st Value */ - Word16 exp_a, /* i: Exponent of 1st Value (Q of Value) */ - Word32 b, /* i: 2nd Value */ - Word16 exp_b, /* i: Exponent of 2nd Value (Q of Value) */ - Word16 *exp_out /* o: Exponent of Result */ + Word32 a, /* i : 1st Value */ + Word16 exp_a, /* i : Exponent of 1st Value (Q of Value) */ + Word32 b, /* i : 2nd Value */ + Word16 exp_b, /* i : Exponent of 2nd Value (Q of Value) */ + Word16 *exp_out /* o : Exponent of Result */ ) { Word16 temp, temp2; @@ -3898,9 +3898,9 @@ Word32 Add_flt32_flt32( /* o: Result (Normalized) */ Word32 Mul_flt32_Q15( - Word32 value, /* i: Pseudo_float Value */ - Word16 *exp_v, /*i/o: Exponent of Value (Q of Value) */ - Word16 frac /* i: Q15 value */ + Word32 value, /* i : Pseudo_float Value */ + Word16 *exp_v, /* i/o: Exponent of Value (Q of Value) */ + Word16 frac /* i : Q15 value */ ) { Word16 temp; @@ -3925,11 +3925,11 @@ Word32 Mul_flt32_Q15( /* o: Result (Normalized) */ Word32 Div_flt32_flt32( - Word32 a, /* i: 1st Value */ - Word16 exp_a, /* i: Exponent of 1st Value (Q of Value) */ - Word32 b, /* i: 2nd Value */ - Word16 exp_b, /* i: Exponent of 2nd Value (Q of Value) */ - Word16 *exp_out /* o: Exponent of Result */ + Word32 a, /* i : 1st Value */ + Word16 exp_a, /* i : Exponent of 1st Value (Q of Value) */ + Word32 b, /* i : 2nd Value */ + Word16 exp_b, /* i : Exponent of 2nd Value (Q of Value) */ + Word16 *exp_out /* o : Exponent of Result */ ) { Word16 temp, temp2; @@ -3957,10 +3957,10 @@ Word32 Div_flt32_flt32( /* o: Result (Energy) */ Word32 Calc_Energy_Autoscaled( - const Word16 *signal, /* i: Signal */ - Word16 signal_exp, /* i: Exponent of Signal (Q of Signal) */ - Word16 len, /* i: Frame Length */ - Word16 *energy_exp /* o: Exponent of Energy (Q of Energy) */ + const Word16 *signal, /* i : Signal */ + Word16 signal_exp, /* i : Exponent of Signal (Q of Signal) */ + Word16 len, /* i : Frame Length */ + Word16 *energy_exp /* o : Exponent of Energy (Q of Energy) */ ) { Word16 temp, temp2; @@ -4067,11 +4067,11 @@ Word16 Find_Max_Norm32( /* o: Result in Q31 */ Word32 Sqrt_Ratio32( - Word32 L_val1, /* i: Mantisa of Val1 */ - Word16 exp1, /* i: Exp of Val1 (>0: Val was Left Shifted, <0:Right Shifted) */ - Word32 L_val2, /* i: Mantisa of Val2 */ - Word16 exp2, /* i: Exp of Val2 (same as exp1) */ - Word16 *exp /* o: Exp of Result (# of 'L_shl' Req to get to Final Value) */ + Word32 L_val1, /* i : Mantisa of Val1 */ + Word16 exp1, /* i : Exp of Val1 (>0: Val was Left Shifted, <0:Right Shifted) */ + Word32 L_val2, /* i : Mantisa of Val2 */ + Word16 exp2, /* i : Exp of Val2 (same as exp1) */ + Word16 *exp /* o : Exp of Result (# of 'L_shl' Req to get to Final Value) */ ) { Word16 temp; @@ -4754,10 +4754,10 @@ void E_UTIL_f_convolve( *----------------------------------------------------------------------------*/ void floating_point_add( - Word32 *mx, /* io: mantissa of the addend Q31 */ - Word16 *ex, /* io: exponent of the addend Q0 */ - const Word32 my, /* i: mantissa of the adder Q31 */ - const Word16 ey /* i: exponent of the adder Q0 */ + Word32 *mx, /* i/o: mantissa of the addend Q31 */ + Word16 *ex, /* i/o: exponent of the addend Q0 */ + const Word32 my, /* i : mantissa of the adder Q31 */ + const Word16 ey /* i : exponent of the adder Q0 */ ) { Word32 accX, accY; diff --git a/lib_com/weight_a_fx.c b/lib_com/weight_a_fx.c index cb537a7d6ffed300a3f4d0b7fed2039150224a4c..eac5ee6b39ff2fb93cd2a932c46c77a9260d9581 100644 --- a/lib_com/weight_a_fx.c +++ b/lib_com/weight_a_fx.c @@ -40,9 +40,9 @@ void weight_a_subfr_fx( /* PURPOSE : Weighting of LP filter coefficients, ap[i] = a[i] * (gamma^i)*/ /*------------------------------------------------------------------------------*/ /* INPUT ARGUMENTS : */ -/* const Word16 a[], i: LP filter coefficients Q12 */ -/* const Word16 *gammatbl, i: weighting factor Q15 */ -/* const Word16 m i: order of LP filter Q0 */ +/* const Word16 a[], i : LP filter coefficients Q12 */ +/* const Word16 *gammatbl, i : weighting factor Q15 */ +/* const Word16 m i : order of LP filter Q0 */ /*------------------------------------------------------------------------------*/ /* OUTPUT ARGUMENTS : */ /* Word16 ap[], o: weighted LP filter coefficients Q12 */ @@ -51,11 +51,12 @@ void weight_a_subfr_fx( /*------------------------------------------------------------------------------*/ /* CALLED FROM : TX/RX */ /*==============================================================================*/ + void weight_a_lc_fx( - const Word16 a[], /* i: LP filter coefficients Q12 */ - Word16 ap[], /* o: weighted LP filter coefficients Q12 */ - const Word16 *gammatbl, /* i: weighting factor Q15 */ - const Word16 m /* i: order of LP filter Q0 */ + const Word16 a[], /* i : LP filter coefficients Q12 */ + Word16 ap[], /* o : weighted LP filter coefficients Q12 */ + const Word16 *gammatbl, /* i : weighting factor Q15 */ + const Word16 m /* i : order of LP filter Q0 */ ) { Word16 i; @@ -91,10 +92,10 @@ void weight_a_lc_fx( * Weighting of LP filter coefficients, ap[i] = a[i] * (gamma^i) *------------------------------------------------------------------*/ void weight_a_fx( - const Word16 a[], /* i: LP filter coefficients Q12 */ - Word16 ap[], /* o: weighted LP filter coefficients Q12 */ - const Word16 gamma, /* i: weighting factor Q15 */ - const Word16 m /* i: order of LP filter Q0 */ + const Word16 a[], /* i : LP filter coefficients Q12 */ + Word16 ap[], /* o : weighted LP filter coefficients Q12 */ + const Word16 gamma, /* i : weighting factor Q15 */ + const Word16 m /* i : order of LP filter Q0 */ ) { Word16 i, fac; diff --git a/lib_com/wi_fx.c b/lib_com/wi_fx.c index b583150cecd7d354b01b574112d853162fe91f1b..b8ffef3058ca9c667b64644ff2093f88f46e4c09 100644 --- a/lib_com/wi_fx.c +++ b/lib_com/wi_fx.c @@ -11,16 +11,15 @@ /*-------------------------------------------------------------------* * Local constants *-------------------------------------------------------------------*/ + #define WARP_OS_RATE 8 #define LL 256 #define LL_OS ( WARP_OS_RATE * LL ) #define OSLENGTH 12 #define CUTFREE_ABS_RANGE 6 -#define CUTFREE_REL_RANGE 0.25 #define CUTFREE_ABS_RANGE_Q3 48 -#define CUTFREE_REL_RANGE_Q2 1 -#define WI_THRESHLD 0.8 -#define WI_SAMPLE_THLD 20 +#define CUTFREE_REL_RANGE_Q2 1 /* 0.25 */ +#define WI_SAMPLE_THLD 20 /* 0.8 */ /*#define _POLY1(x, c) ((c)[0] * (x) + (c)[1]) */ /*#define _POLY2(x, c) (_POLY1((x), (c)) * (x) + (c)[2]) */ @@ -31,18 +30,19 @@ *--------------------------------------------------------------------*/ static Word32 DTFS_setEngy_fx( DTFS_STRUCTURE *X_DTFS_FX, Word32 en2_fx ); +static void r_fft_4_fx( Word16 *farray_ptr_fx /*Q0*/, Word16 size, Word16 stage, Word16 isign ); + /*-------------------------------------------------------------------* * DTFS_new_fx() * * DTFS structure initialization. *-------------------------------------------------------------------*/ + ivas_error DTFS_new_fx( DTFS_STRUCTURE **dtfs_out ) { - Word16 i; - DTFS_STRUCTURE *dtfs_fx = NULL; #ifdef FIX_2431_AVOID_CALLOC dtfs_fx = (DTFS_STRUCTURE *) malloc( sizeof( DTFS_STRUCTURE ) ); @@ -75,8 +75,11 @@ ivas_error DTFS_new_fx( move16(); } *dtfs_out = dtfs_fx; + return IVAS_ERR_OK; } + + /*-------------------------------------------------------------------* * DTFS_copy_fx() * @@ -84,12 +87,10 @@ ivas_error DTFS_new_fx( *-------------------------------------------------------------------*/ void DTFS_copy_fx( - DTFS_STRUCTURE *Xout_fx, /* o: DTFS structure */ - DTFS_STRUCTURE Xinp_fx /* i: DTFS structure */ + DTFS_STRUCTURE *Xout_fx, /* o : DTFS structure */ + DTFS_STRUCTURE Xinp_fx /* i : DTFS structure */ ) - { - Word16 k; FOR( k = 0; k < MAXLAG_WI; k++ ) { @@ -115,6 +116,7 @@ void DTFS_copy_fx( move16(); Xout_fx->Q = Xinp_fx.Q; move16(); + return; } @@ -124,10 +126,11 @@ void DTFS_copy_fx( * * Subtract one DTFS STRUCTURE from another. *-------------------------------------------------------------------*/ + void DTFS_sub_fx( - DTFS_STRUCTURE *tmp, /* o: X1 - X2 */ - DTFS_STRUCTURE X1, /* i: DTFS input 1 */ - DTFS_STRUCTURE X2 /* i: DTFS input 2 */ + DTFS_STRUCTURE *tmp, /* o : X1 - X2 */ + DTFS_STRUCTURE X1, /* i : DTFS input 1 */ + DTFS_STRUCTURE X2 /* i : DTFS input 2 */ ) { Word16 i, sft, tmp_loop; @@ -171,15 +174,22 @@ void DTFS_sub_fx( move16(); tmp->upper_cut_off_freq_fx = X1.upper_cut_off_freq_fx; move16(); + return; } + + /*-------------------------------------------------------------------* * DTFS_fast_fs_inv() * * DTFS inverse. *-------------------------------------------------------------------*/ -static void DTFS_fast_fs_inv_fx( DTFS_STRUCTURE *X_fx, Word16 *out_fx /* Q0 */, Word16 N_fx, Word16 LOG2N ) +static void DTFS_fast_fs_inv_fx( + DTFS_STRUCTURE *X_fx, + Word16 *out_fx /* Q0 */, + Word16 N_fx, + Word16 LOG2N ) { Word16 i, M_2, N_2, s; Word16 dbuf_fx[256 + 1]; @@ -226,8 +236,8 @@ static void DTFS_fast_fs_inv_fx( DTFS_STRUCTURE *X_fx, Word16 *out_fx /* Q0 */, /* PURPOSE : search for alignment */ /*-------------------------------------------------------------------*/ /* INPUT ARGUMENTS : */ -/* _ (struct DTFS_STRUCTURE) X1_fx : a/b in X1.Q */ -/* _ (struct DTFS_STRUCTURE) X2_fx : a/b in X2.Q */ +/* _ (struct DTFS_STRUCTURE) X1_fx : a/b in X1.Q */ +/* _ (struct DTFS_STRUCTURE) X2_fx : a/b in X2.Q */ /* _ (Word16) Eshift: Q7 */ /* _ (Word16 *) LPC1: lpc coefficients. Q12 */ /* _ (Word16 *) LPC2: lpc coefficients. Q12 */ @@ -383,13 +393,13 @@ static Word16 DTFS_alignment_weight_fx( /*===========================================================================*/ -/* FUNCTION : DTFS_alignment_full_fx () */ +/* FUNCTION : DTFS_alignment_full_fx () */ /*---------------------------------------------------------------------------*/ /* PURPOSE : search for alignment */ /*---------------------------------------------------------------------------*/ /* INPUT ARGUMENTS : */ -/* _ (struct DTFS_STRUCTURE) X1_DTFS_fx : a_fx/b_fx in X1_DTFS_fx.Q */ -/* _ (struct DTFS_STRUCTURE) X2_DTFS_fx : a_fx/b_fx in X2_DTFS_fx.Q */ +/* _ (struct DTFS_STRUCTURE) X1_DTFS_fx : a_fx/b_fx in X1_DTFS_fx.Q */ +/* _ (struct DTFS_STRUCTURE) X2_DTFS_fx : a_fx/b_fx in X2_DTFS_fx.Q */ /* _ (Word16 *) S_fx: sin(2pi*n/(4*lag)) table, Q15 */ /* _ (Word16 *) C_fx: cos(2pi*n/(4*lag)) table, Q15 */ /*---------------------------------------------------------------------------*/ @@ -494,8 +504,10 @@ Word16 DTFS_alignment_full_fx( return fshift_fx; /*Q1*/ } + + /*===================================================================*/ -/* FUNCTION : DTFS_phaseShift_fx () */ +/* FUNCTION : DTFS_phaseShift_fx () */ /*-------------------------------------------------------------------*/ /* PURPOSE : Phase is shifted by 2pi*ph/Lag */ /*-------------------------------------------------------------------*/ @@ -509,14 +521,19 @@ Word16 DTFS_alignment_full_fx( /* _ None. */ /*-------------------------------------------------------------------*/ /* INPUT/OUTPUT ARGUMENTS : */ -/* _ (struct DTFS_fx) X1 : a/b in X1.Q */ +/* _ (struct DTFS_fx) X1 : a/b in X1.Q */ /*-------------------------------------------------------------------*/ /* RETURN ARGUMENTS : _ None. */ /*-------------------------------------------------------------------*/ /* CALLED FROM : TX/RX */ /*===================================================================*/ -void DTFS_phaseShift_fx( DTFS_STRUCTURE *X_fx, Word16 ph, Word16 Lag, Word16 *S_fx, Word16 *C_fx ) +void DTFS_phaseShift_fx( + DTFS_STRUCTURE *X_fx, + Word16 ph, + Word16 Lag, + Word16 *S_fx, + Word16 *C_fx ) { Word16 k; Word16 temp, HalfLag; @@ -552,9 +569,11 @@ void DTFS_phaseShift_fx( DTFS_STRUCTURE *X_fx, Word16 ph, Word16 Lag, Word16 *S_ L_temp2 = L_add( L_temp2, ph ); } } + return; } + /*===================================================================*/ /* FUNCTION : Q2phaseShift_fx () */ /*-------------------------------------------------------------------*/ @@ -570,7 +589,7 @@ void DTFS_phaseShift_fx( DTFS_STRUCTURE *X_fx, Word16 ph, Word16 Lag, Word16 *S_ /* _ None. */ /*-------------------------------------------------------------------*/ /* INPUT/OUTPUT ARGUMENTS : */ -/* _ (struct DTFS_STRUCTURE) X_fx : a/b in X_fx->Q */ +/* _ (struct DTFS_STRUCTURE) X_fx : a/b in X_fx->Q */ /*-------------------------------------------------------------------*/ /* RETURN ARGUMENTS : _ None. */ /*-------------------------------------------------------------------*/ @@ -618,7 +637,11 @@ void Q2phaseShift_fx( move16(); } } + + return; } + + /*===================================================================*/ /* FUNCTION : DTFS_zeroPadd_fx () */ /*-------------------------------------------------------------------*/ @@ -631,7 +654,7 @@ void Q2phaseShift_fx( /* _ None. */ /*-------------------------------------------------------------------*/ /* INPUT/OUTPUT ARGUMENTS : */ -/* _ (struct DTFS_STRUCTURE) X_fx : a/b in X_fx.Q i.e Q6 */ +/* _ (struct DTFS_STRUCTURE) X_fx : a/b in X_fx.Q i.e Q6 */ /* _ (Word16) lag: pitch lag of *X_fx, Q0 */ /*-------------------------------------------------------------------*/ /* RETURN ARGUMENTS : _ None. */ @@ -674,7 +697,11 @@ void DTFS_zeroPadd_fx( X_fx->nH_fx = add( X_fx->nH_fx, 1 ); move16(); } + + return; } + + /*===================================================================*/ /* FUNCTION : to_fs_fx () */ /*-------------------------------------------------------------------*/ @@ -683,15 +710,15 @@ void DTFS_zeroPadd_fx( /* INPUT ARGUMENTS : */ /* _ (Word16 *) x: input time domain series. Q0 */ /* _ (Word16) N: Lag */ -/* _ (struct DTFS_STRUCTURE) PREVCW_FX: a/b in PREVCW_FX.Q */ +/* _ (struct DTFS_STRUCTURE) PREVCW_FX: a/b in PREVCW_FX.Q */ /* _ (Word16 *) S_fx: sin(2pi*n/(4*lag)) table, Q15 */ /* _ (Word16 *) C_fx: cos(2pi*n/(4*lag)) table, Q15 */ /*-------------------------------------------------------------------*/ /* OUTPUT ARGUMENTS : */ -/* _ (struct DTFS_STRUCTURE) (Word16 a[]) : in Q */ -/* _ (struct DTFS_STRUCTURE) (Word16 b[]) : in Q */ -/* _ (struct DTFS_STRUCTURE) (Word16 lag) : Q0 */ -/* _ (struct DTFS_STRUCTURE) (Word16 Q ) : Q value of a/b */ +/* _ (struct DTFS_STRUCTURE) (Word16 a[]) : in Q */ +/* _ (struct DTFS_STRUCTURE) (Word16 b[]) : in Q */ +/* _ (struct DTFS_STRUCTURE) (Word16 lag) : Q0 */ +/* _ (struct DTFS_STRUCTURE) (Word16 Q ) : Q value of a/b */ /*-------------------------------------------------------------------*/ /* INPUT/OUTPUT ARGUMENTS : */ /* _ None. */ @@ -700,12 +727,13 @@ void DTFS_zeroPadd_fx( /*-------------------------------------------------------------------*/ /* CALLED FROM : TX/RX */ /*===================================================================*/ + void DTFS_to_fs_fx( - const Word16 *x, /* i : time domain signal */ - Word16 N, /* i : Length of input vector */ - DTFS_STRUCTURE *X_fx, /* o : DTFS structure with a, b, lag */ - const Word16 Fs, /* i : sampling rate */ - const Word16 FR_flag, /* i : FR flag */ + const Word16 *x, /* i : time domain signal */ + Word16 N, /* i : Length of input vector */ + DTFS_STRUCTURE *X_fx, /* o : DTFS structure with a, b, lag */ + const Word16 Fs, /* i : sampling rate */ + const Word16 FR_flag, /* i : FR flag */ Word16 *S_fx, Word16 *C_fx ) @@ -915,8 +943,8 @@ void DTFS_to_fs_fx( /* PURPOSE : */ /*-------------------------------------------------------------------*/ /* INPUT ARGUMENTS : */ -/* _ (struct DTFS_STRUCTURE) X_fx: a/b in X1.Q, lag in Q0 */ -/* _ (struct DTFS_STRUCTURE) X2_fx. a/b in X2.Q, lag in Q0 */ +/* _ (struct DTFS_STRUCTURE) X_fx: a/b in X1.Q, lag in Q0 */ +/* _ (struct DTFS_STRUCTURE) X2_fx. a/b in X2.Q, lag in Q0 */ /* _ (Word16 *) phase_fx: 2pi normalized, Q12 */ /* _ (Word16) N: length of series. */ /*-------------------------------------------------------------------*/ @@ -930,13 +958,14 @@ void DTFS_to_fs_fx( /*-------------------------------------------------------------------*/ /* CALLED FROM : TX/RX */ /*===================================================================*/ + static void DTFS_transform_fx( - DTFS_STRUCTURE X_fx, /* i : Starting DTFS to use in WI */ - DTFS_STRUCTURE X2_fx, /* i : Ending DTFS to use in WI */ - const Word32 *phase_fx, /* i : Phase contour */ - Word16 *out_fx, /* o : Output time domain waveform */ - Word16 N, /* i : Number of samples to generate */ - const Word16 FR_flag /* i : Flag to indicate called in FR context */ + DTFS_STRUCTURE X_fx, /* i : Starting DTFS to use in WI */ + DTFS_STRUCTURE X2_fx, /* i : Ending DTFS to use in WI */ + const Word32 *phase_fx, /* i : Phase contour */ + Word16 *out_fx, /* o : Output time domain waveform */ + Word16 N, /* i : Number of samples to generate */ + const Word16 FR_flag /* i : Flag to indicate called in FR context */ ) { @@ -1375,8 +1404,11 @@ void DTFS_poleFilter_fx_9( X_fx->Q = add( X_fx->Q, Qmin ); move16(); + return; } + + /*===================================================================*/ /* FUNCTION : DTFS_adjustLag_fx () */ /*-------------------------------------------------------------------*/ @@ -1397,8 +1429,8 @@ void DTFS_poleFilter_fx_9( /*===================================================================*/ void DTFS_adjustLag_fx( - DTFS_STRUCTURE *X_DTFS_FX, /* i/o : DTFS to adjust lag for */ - Word16 N_fx /* i : Target lag */ + DTFS_STRUCTURE *X_DTFS_FX, /* i/o: DTFS to adjust lag for */ + Word16 N_fx /* i : Target lag */ ) { Word32 en_fx; @@ -1471,6 +1503,8 @@ void DTFS_adjustLag_fx( } return; } + + /*===================================================================*/ /* FUNCTION : DTFS_getEngy_fx () */ /*-------------------------------------------------------------------*/ @@ -1489,7 +1523,6 @@ void DTFS_adjustLag_fx( /* CALLED FROM : TX/RX */ /*===================================================================*/ - Word32 DTFS_getEngy_fx( DTFS_STRUCTURE *X_fx ) { @@ -1534,7 +1567,7 @@ Word32 DTFS_getEngy_fx( /* PURPOSE : */ /*-------------------------------------------------------------------*/ /* INPUT ARGUMENTS : */ -/* _ (struct DTFS_STRUCTURE) : a/b in X_fx.Q, lag in Q0 */ +/* _ (struct DTFS_STRUCTURE) : a/b in X_fx.Q, lag in Q0 */ /*-------------------------------------------------------------------*/ /* OUTPUT ARGUMENTS : _ None */ /*-------------------------------------------------------------------*/ @@ -1567,6 +1600,7 @@ Word32 DTFS_getEngy_P2A_fx( en_fx = L_mac0_sat( en_fx, X_fx->a_fx[k], X_fx->a_fx[k] ); en_fx = L_mac0_sat( en_fx, X_fx->b_fx[k], X_fx->b_fx[k] ); } + return en_fx; /* 2*X1.Q */ } @@ -1583,7 +1617,7 @@ Word32 DTFS_getEngy_P2A_fx( /* _ (Word40) en1_fx : 2*X1.Q+1 i.e. Q13 */ /*-------------------------------------------------------------------*/ /* INPUT/OUTPUT ARGUMENTS : */ -/* _ (struct DTFS_STRUCTURE) X_DTFS_FX : a/b in X1.Q i.e. Q6, */ +/* _ (struct DTFS_STRUCTURE) X_DTFS_FX : a/b in X1.Q i.e. Q6, */ /* lag in Q0 */ /*-------------------------------------------------------------------*/ /* RETURN ARGUMENTS : _ None. */ @@ -1650,10 +1684,10 @@ static Word32 DTFS_setEngy_fx( move16(); } - return en1_fx; /* 2*X1.Q+1 = Q13 */ } + /*===================================================================*/ /* FUNCTION : struct DTFS_car2pol_fx () */ /*-------------------------------------------------------------------*/ @@ -1661,13 +1695,13 @@ static Word32 DTFS_setEngy_fx( /* returning amplitudes and 0 phases */ /*-------------------------------------------------------------------*/ /* INPUT ARGUMENTS : */ -/* _ (struct DTFS_STRUCTURE) X_fx : prototype in Cartesian domain*/ +/* _ (struct DTFS_STRUCTURE) X_fx : prototype in Cartesian domain */ /* (Word16) lag: length of prototype in time domain */ -/* (Word16 []) a,b: re/im of harmonics, normalized */ -/* (Word16) Q: norm factor of a/b */ +/* (Word16 []) a,b: re/im of harmonics, normalized */ +/* (Word16) Q: norm factor of a/b */ /*-------------------------------------------------------------------*/ /* OUTPUT ARGUMENTS : */ -/* _ (struct DTFS_STRUCTURE) X_fx : prototype in polar domain */ +/* _ (struct DTFS_STRUCTURE) X_fx : prototype in polar domain */ /* (Word16) lag: length of prototype in time domain */ /* (Word16 []) a: amplitude of harmonics, normalized */ /* (Word16 []) b: phase of harmonics,cleared to 0 */ @@ -1684,10 +1718,10 @@ static Word32 DTFS_setEngy_fx( /* When phases are needed, such as in QPPP, instead uses the */ /* Cartesian representation to avoid computing phases by arctan*/ /*===================================================================*/ + void DTFS_car2pol_fx( DTFS_STRUCTURE *X_fx /* i/o : DTFS structure a, b, lag */ ) - { Word16 k, HalfLag_fx; Word32 Ltemp_fx; @@ -1772,7 +1806,7 @@ void DTFS_car2pol_fx( /* _ (Word16) Qa_fx: Q value of output a[]. */ /*----------------------------------------------------------------------------- -*/ /* INPUT/OUTPUT ARGUMENTS : */ -/* _(struct DTFS_STRUCTURE) : a_fx[] in X1_fx.Q at start, then changed to */ +/* _(struct DTFS_STRUCTURE) : a_fx[] in X1_fx.Q at start, then changed to */ /* *Qa later. */ /*---------------------------------------------------------------------------- --*/ /* RETURN ARGUMENTS : _ None. */ @@ -1789,7 +1823,7 @@ Word32 DTFS_setEngyHarm_fx( Word16 g1_fx, /* i : lower band freq of output to control energy */ Word16 g2_fx, /* i : upper band freq of output to control energy */ Word32 en2_fx, /* i : Target Energy to set the DTFS to */ - Word16 Qen2_fx, /* i : Input Q format for en2 */ + Word16 Qen2_fx, /* i : Input Q format for en2 */ Word16 *Qa_fx, /* i : Output Q format for x->a */ DTFS_STRUCTURE *X_fx /* i/o: DTFS to adjust the energy of */ ) @@ -1912,6 +1946,8 @@ Word32 DTFS_setEngyHarm_fx( return en1_fx; /* Q(2*X1.Q) */ } + + /*===================================================================*/ /* FUNCTION : cubicPhase_fx () */ /*-------------------------------------------------------------------*/ @@ -1936,6 +1972,7 @@ Word32 DTFS_setEngyHarm_fx( /*===================================================================*/ /* NOTE: This function outputs phase in (-1,1) */ /*===================================================================*/ + static void cubicPhase_fx( Word16 ph1_fx, /* i : phase offset */ Word16 ph2_fx, /* i : phase 2 */ @@ -2177,7 +2214,6 @@ static void cubicPhase_fx( } ELSE { - FOR( n = 1; n < 181; n++ ) { /* phOut_fx[n] = _POLY3(n,coef) ; */ @@ -2230,16 +2266,18 @@ static void cubicPhase_fx( phOut_fx[n] = Ltemp; move32(); /* Q27 */ } + return; } + /*===================================================================*/ /* FUNCTION : DTFS_to_erb_fx () */ /*-------------------------------------------------------------------*/ /* PURPOSE : Convert harmonics to erb bands */ /*-------------------------------------------------------------------*/ /* INPUT ARGUMENTS : */ -/* _ (struct DTFS_STRUCTURE) X_fx : prototype in polar domain */ +/* _ (struct DTFS_STRUCTURE) X_fx : prototype in polar domain */ /* (Word16) lag_fx: length of prototype in time domain*/ /* (Word16 []) a_fx: amplitude, normalized */ /* (Word16) Q_fx: norm factor of a */ @@ -2254,9 +2292,10 @@ static void cubicPhase_fx( /*-------------------------------------------------------------------*/ /* CALLED FROM : TX/RX */ /*===================================================================*/ + void DTFS_to_erb_fx( - const DTFS_STRUCTURE X_fx, /* i : DTFS input */ - Word16 *out_fx /* o : ERB output */ + const DTFS_STRUCTURE X_fx, /* i : DTFS input */ + Word16 *out_fx /* o : ERB output */ ) { @@ -2327,7 +2366,6 @@ void DTFS_to_erb_fx( n = sub( 29, X_fx.Q ); j = negate( X_fx.Q ); - FOR( i = 0; i < num_erb_fx; i++ ) { out_fx[i] = round_fx_sat( L_shl_sat( sum_a_fx[i], n ) ); /* Q13 */ //?�sat @@ -2363,8 +2401,11 @@ void DTFS_to_erb_fx( move16(); } } + return; } + + /*===================================================================*/ /* FUNCTION : erb_slot_fx () */ /*-------------------------------------------------------------------*/ @@ -2386,6 +2427,7 @@ void DTFS_to_erb_fx( /*===================================================================*/ /* NOTE: Frequency is normalized by 12800, i.e. 1=12800Hz */ /*===================================================================*/ + void erb_slot_fx( Word16 lag_fx, /* i : input lag */ Word16 *out_fx, /* o : ERB slots */ @@ -2438,10 +2480,8 @@ void erb_slot_fx( move16(); } - L_tmp = L_mult0( diff_fx, nH_band_fx ); /* Q0 */ - IF( GE_32( L_sub( upper_cut_off_freq_fx, L_tmp ), L_deposit_l( diff_fx ) ) ) /* Q0 compare */ { nH_band_fx = add( nH_band_fx, 1 ); /* Q0 */ @@ -2508,8 +2548,11 @@ void erb_slot_fx( move16(); } } + return; } + + /*===================================================================*/ /* FUNCTION : DTFS_erb_inv_fx () */ /*-------------------------------------------------------------------*/ @@ -2519,11 +2562,11 @@ void erb_slot_fx( /* _ (Word16 []) in_fx : erb output, Q13 */ /* _ (Word16 []) slot_fx : number of harmonics in the ERB bins, Q0 */ /* _ (Word16 []) mfreq_fx : frequency bounds of the ERB bins, Q15 */ -/* _ (struct DTFS_STRUCTURE) (Word16) lag_fx: length of */ +/* _ (struct DTFS_STRUCTURE) (Word16) lag_fx: length of */ /* prototype in time domain */ /*-------------------------------------------------------------------*/ /* OUTPUT ARGUMENTS : */ -/* _ (struct DTFS_STRUCTURE) : prototype in polar domain */ +/* _ (struct DTFS_STRUCTURE) : prototype in polar domain */ /* (Word16 []) a_fx: amplitude, normalized */ /* (Word16) Q: norm factor of a */ /*-------------------------------------------------------------------*/ @@ -2536,14 +2579,13 @@ void erb_slot_fx( /*===================================================================*/ void DTFS_erb_inv_fx( - Word16 *in_fx, /* i : ERB inpt */ - Word16 *slot_fx, /* i : ERB slots filled based on lag */ - Word16 *mfreq_fx, /* i : erb frequence edges */ - DTFS_STRUCTURE *X_fx, /* o : DTFS after erb-inv */ - Word16 num_erb_fx /* i : Number of ERB bands */ + Word16 *in_fx, /* i : ERB inpt */ + Word16 *slot_fx, /* i : ERB slots filled based on lag */ + Word16 *mfreq_fx, /* i : erb frequence edges */ + DTFS_STRUCTURE *X_fx, /* o : DTFS after erb-inv */ + Word16 num_erb_fx /* i : Number of ERB bands */ ) { - Word16 i, j, m_fx = 0, n, HalfLag_fx; Word16 diff_fx; /* 1/lag, Q19 */ Word16 d1, d2, q[MAXLAG_WI], min_q = 0; @@ -2718,7 +2760,6 @@ void erb_add_fx( move16(); /* Q13 */ } - IF( GT_16( pl_fx, l_fx ) ) { tmp_fx = t_prev_erb_fx[0]; @@ -2804,6 +2845,7 @@ void erb_add_fx( move16(); } } + return; } @@ -2823,7 +2865,7 @@ void erb_add_fx( /* _ (Word16[]) target: Power of 2 bands for quantization, Q11 */ /*-------------------------------------------------------------------*/ /* INPUT/OUTPUT ARGUMENTS : */ -/* _ (struct DTFS_fx) X : prototype in polar domain */ +/* _ (struct DTFS_fx) X : prototype in polar domain */ /* (Word16) lag: length of prototype in time domain */ /* (Word16 []) a: amplitude of harmonics, normalized */ /* (Word16) Q: norm factor of a */ @@ -2835,7 +2877,14 @@ void erb_add_fx( /*===================================================================*/ /* NOTE: This function is used by quant_cw_fx and quant_cw_memless_fx*/ /*===================================================================*/ -void quant_target_fx( DTFS_STRUCTURE *X_fx, const Word16 *curr_lpc, Word16 *w, Word16 *target, Word16 *sin_tab, Word16 *cos_tab ) + +void quant_target_fx( + DTFS_STRUCTURE *X_fx, + const Word16 *curr_lpc, + Word16 *w, + Word16 *target, + Word16 *sin_tab, + Word16 *cos_tab ) { Word16 tmp, n, exp; Word16 Ql, Qh; @@ -2913,8 +2962,11 @@ void quant_target_fx( DTFS_STRUCTURE *X_fx, const Word16 *curr_lpc, Word16 *w, W { rshiftHarmBand_fx( X_fx, 0, 2828, sub( Qh, Ql ) ); } + + return; } + /*==========================================================================*/ /* FUNCTION : WIsyn_fx () */ /*--------------------------------------------------------------------------*/ @@ -2938,6 +2990,7 @@ void quant_target_fx( DTFS_STRUCTURE *X_fx, const Word16 *curr_lpc, Word16 *w, W /*--------------------------------------------------------------------------*/ /* RETURN ARGUMENTS : _ None. */ /*==========================================================================*/ + ivas_error WIsyn_fx( DTFS_STRUCTURE PREVCW_FX, /* i : Prev frame DTFS */ DTFS_STRUCTURE *CURRCW_DTFS_out, /* i/o: Curr frame DTFS */ @@ -2965,8 +3018,6 @@ ivas_error WIsyn_fx( Word16 exp, tmp; Word32 L_tmp; /* prev_lsp_fx; */ - - DTFS_STRUCTURE *CURRCW_DTFS_FX; ivas_error error; @@ -2992,7 +3043,6 @@ ivas_error WIsyn_fx( move16(); } - IF( LT_16( CURRCW_DTFS_out->Q, PREVCW_FX.Q ) ) { temp = sub( PREVCW_FX.Q, CURRCW_DTFS_out->Q ); @@ -3021,7 +3071,6 @@ ivas_error WIsyn_fx( find_rem( (Word16) N, shr( add( PREVCW_FX.lag_fx, CURRCW_DTFS_FX->lag_fx ), 1 ), &temp ); temp = add( shl( temp, 7 ), alignment_fx ); /* Q7 */ - IF( temp < 0 ) { temp = add( temp, shl( CURRCW_DTFS_FX->lag_fx, 7 ) ); /* Q7 */ @@ -3041,7 +3090,6 @@ ivas_error WIsyn_fx( alignment_fx = shl( alignment_fx, 6 ); } - IF( GE_16( alignment_fx, shl( CURRCW_DTFS_FX->lag_fx, 7 ) ) ) { temp = sub( alignment_fx, shl( CURRCW_DTFS_FX->lag_fx, 7 ) ); @@ -3088,9 +3136,7 @@ ivas_error WIsyn_fx( DTFS_transform_fx( PREVCW_FX, *CURRCW_DTFS_FX, phase_fx, out_fx, N, 1 ); } - /* Adjust the phase offset and wrap it between 0 and 2pi */ - IF( EQ_16( flag, 2 ) ) { L_temp = L_shr( L_mult( tmp_fx, I ), 1 ); /* Q15 */ @@ -3100,7 +3146,6 @@ ivas_error WIsyn_fx( L_temp = L_deposit_l( tmp_fx ); /* Q15 */ } - FOR( ; L_temp < 0; L_temp += 0x8000L ) { /* empty loop */ @@ -3112,6 +3157,7 @@ ivas_error WIsyn_fx( /* free(phase_fx) ; */ free( CURRCW_DTFS_FX ); + return error; } @@ -3133,14 +3179,15 @@ ivas_error WIsyn_fx( /* INPUT/OUTPUT ARGUMENTS : */ /* _ None */ /*-------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ (Word16) spike_near_edge : Q0 */ +/* RETURN ARGUMENTS : */ +/* _ (Word16) spike_near_edge : Q0 */ /*===================================================================*/ + Word16 ppp_extract_pitch_period_fx( - const Word16 *in, /* i : input residual */ - Word16 *out, /* o : output residual */ - Word16 l, /* i : lag */ - Word16 *out_of_bound, /* o : out of bound flag */ + const Word16 *in, /* i : input residual */ + Word16 *out, /* o : output residual */ + Word16 l, /* i : lag */ + Word16 *out_of_bound, /* o : out of bound flag */ Word16 Qres ) @@ -3230,7 +3277,6 @@ Word16 ppp_extract_pitch_period_fx( return spike_near_edge; } - tmp = extract_l( ( L_max( L_mult( CUTFREE_REL_RANGE_Q2, l ), CUTFREE_ABS_RANGE_Q3 ) ) ); /* Q3 */ IF( tmp > 0 ) @@ -3316,7 +3362,6 @@ Word16 ppp_extract_pitch_period_fx( Lacc = L_mac0_sat( Lacc, out[i], out[i] ); /* Q0 */ } - IF( LT_32( en1, Lacc ) ) { /* Ltmp=sqrt_divide_dp(en1, Lacc, 0, &n,1); */ @@ -3346,15 +3391,18 @@ Word16 ppp_extract_pitch_period_fx( move16(); } } + return spike_near_edge; } + + /*===========================================================================*/ /* FUNCTION : DTFS_peaktoaverage_fx () */ /*---------------------------------------------------------------------------*/ /* PURPOSE : */ /*---------------------------------------------------------------------------*/ /* INPUT ARGUMENTS : */ -/* _ (struct DTFS_STRUCTURE) X_fx: a_fx/b_fx in Q(X_fx.Q), lag in Q0 */ +/* _ (struct DTFS_STRUCTURE) X_fx: a_fx/b_fx in Q(X_fx.Q), lag in Q0 */ /*---------------------------------------------------------------------------*/ /* OUTPUT ARGUMENTS : */ /* _ (Word32 *) pos_fx : in *Qpos */ @@ -3367,7 +3415,13 @@ Word16 ppp_extract_pitch_period_fx( /*---------------------------------------------------------------------------*/ /* RETURN ARGUMENTS : _ None. */ /*===========================================================================*/ -void DTFS_peaktoaverage_fx( DTFS_STRUCTURE X_fx, Word32 *pos_fx, Word16 *Qpos, Word32 *neg_fx, Word16 *Qneg ) + +void DTFS_peaktoaverage_fx( + DTFS_STRUCTURE X_fx, + Word32 *pos_fx, + Word16 *Qpos, + Word32 *neg_fx, + Word16 *Qneg ) { Word32 L_sum; Word32 maxPosEn_fx = 0, maxNegEn_fx = 0, L_temp; @@ -3402,7 +3456,6 @@ void DTFS_peaktoaverage_fx( DTFS_STRUCTURE X_fx, Word32 *pos_fx, Word16 *Qpos, W } } - IF( L_sum == 0 ) { *pos_fx = *neg_fx = 0; @@ -3479,8 +3532,11 @@ void DTFS_peaktoaverage_fx( DTFS_STRUCTURE X_fx, Word32 *pos_fx, Word16 *Qpos, W move16(); } } + + return; } + /*===================================================================*/ /* FUNCTION : struct DTFS_fx:: rshiftHarmBand_fx() */ /*-------------------------------------------------------------------*/ @@ -3507,7 +3563,12 @@ void DTFS_peaktoaverage_fx( DTFS_STRUCTURE X_fx, Word32 *pos_fx, Word16 *Qpos, W /* to setEngyHarm_fx, because the norm factor outputs from */ /* the two previous calls might be different */ /*===================================================================*/ -void rshiftHarmBand_fx( DTFS_STRUCTURE *X_fx, Word16 lband_fx, Word16 hband_fx, Word16 shift_fx ) + +void rshiftHarmBand_fx( + DTFS_STRUCTURE *X_fx, + Word16 lband_fx, + Word16 hband_fx, + Word16 shift_fx ) { Word16 k_fx, HalfLag_fx; Word16 low_fx, high_fx; @@ -3521,6 +3582,8 @@ void rshiftHarmBand_fx( DTFS_STRUCTURE *X_fx, Word16 lband_fx, Word16 hband_fx, X_fx->a_fx[k_fx] = shl_r( X_fx->a_fx[k_fx], shift_fx ); move16(); /* right shift and round */ } + + return; } /*===================================================================*/ @@ -3546,7 +3609,11 @@ void rshiftHarmBand_fx( DTFS_STRUCTURE *X_fx, Word16 lband_fx, Word16 hband_fx, /*===================================================================*/ /* NOTE: This function interpolates cos_table for better accuracy */ /*===================================================================*/ -void GetSinCosTab_fx( Word16 L, Word16 *sinTab, Word16 *cosTab ) + +void GetSinCosTab_fx( + Word16 L, + Word16 *sinTab, + Word16 *cosTab ) { Word16 i, L4; Word16 dl, t1, w, dt; @@ -3623,7 +3690,11 @@ void GetSinCosTab_fx( Word16 L, Word16 *sinTab, Word16 *cosTab ) * imaginary part for each sample. The counters are therefore * incremented by two to access the complex valued samples. */ -static void c_fft_wi_fx( Word16 *farray_ptr_fx, Word16 size, Word16 stage, Word16 isign ) +static void c_fft_wi_fx( + Word16 *farray_ptr_fx, + Word16 size, + Word16 stage, + Word16 isign ) { Word16 i, j, k, ii, jj, kk, ji, kj; @@ -3679,8 +3750,6 @@ static void c_fft_wi_fx( Word16 *farray_ptr_fx, Word16 size, Word16 stage, Word1 } /* The FFT part */ - - IF( EQ_16( isign, 1 ) ) { FOR( i = 0; i < stage; i++ ) /* i is stage counter */ @@ -3778,10 +3847,15 @@ static void c_fft_wi_fx( Word16 *farray_ptr_fx, Word16 size, Word16 stage, Word1 } } -} /* end of c_fft () */ + return; +} -void r_fft_4_fx( Word16 *farray_ptr_fx /*Q0*/, Word16 size, Word16 stage, Word16 isign ) +static void r_fft_4_fx( + Word16 *farray_ptr_fx /*Q0*/, + Word16 size, + Word16 stage, + Word16 isign ) { Word16 ftmp1_real_fx, ftmp1_imag_fx, ftmp2_real_fx, ftmp2_imag_fx; @@ -3850,7 +3924,6 @@ void r_fft_4_fx( Word16 *farray_ptr_fx /*Q0*/, Word16 size, Word16 stage, Word16 } ELSE { - /* First, handle the DC and foldover frequencies */ move16(); @@ -3901,6 +3974,8 @@ void r_fft_4_fx( Word16 *farray_ptr_fx /*Q0*/, Word16 size, Word16 stage, Word16 /* Perform the complex IFFT */ c_fft_wi_fx( farray_ptr_fx, size, stage, isign ); } + + return; } @@ -3938,7 +4013,11 @@ void r_fft_4_fx( Word16 *farray_ptr_fx /*Q0*/, Word16 size, Word16 stage, Word16 /* X.a[k]=2*X2.a[k]/sqrt(X1.a[k]^2+X1.b[k]^2)*X1.a[k] */ /* X.b[k]=2*X2.a[k]/sqrt(X1.a[k]^2+X1.b[k]^2)*X1.b[k] */ /*===================================================================*/ -void copy_phase_fx( DTFS_STRUCTURE *X1_fx, DTFS_STRUCTURE X2_fx, DTFS_STRUCTURE *retX_fx ) + +void copy_phase_fx( + DTFS_STRUCTURE *X1_fx, + DTFS_STRUCTURE X2_fx, + DTFS_STRUCTURE *retX_fx ) { /* DTFS_fx X; */ Word16 k, q, sn, cn, HalfLag; @@ -4011,7 +4090,6 @@ void copy_phase_fx( DTFS_STRUCTURE *X1_fx, DTFS_STRUCTURE X2_fx, DTFS_STRUCTURE } k = sub( k, 1 ); - IF( s_and( X1_fx->lag_fx, 1 ) == 0 ) { retX_fx->a_fx[k] = shr( retX_fx->a_fx[k], 1 ); @@ -4019,6 +4097,8 @@ void copy_phase_fx( DTFS_STRUCTURE *X1_fx, DTFS_STRUCTURE X2_fx, DTFS_STRUCTURE retX_fx->b_fx[k] = shr( retX_fx->b_fx[k], 1 ); move16(); } + + return; } @@ -4028,7 +4108,7 @@ void copy_phase_fx( DTFS_STRUCTURE *X1_fx, DTFS_STRUCTURE X2_fx, DTFS_STRUCTURE /* PURPOSE : Get band energy */ /*-------------------------------------------------------------------*/ /* INPUT ARGUMENTS : */ -/* _ (struct DTFS_STRUCTURE) X_fx : prototype in polar domain */ +/* _ (struct DTFS_STRUCTURE) X_fx : prototype in polar domain */ /* (Word16) lag: length of prototype in time domain */ /* (Word16 []) a: amplitude of harmonics, normalized */ /* (Word16) Q: norm factor of a */ @@ -4050,7 +4130,14 @@ void copy_phase_fx( DTFS_STRUCTURE *X1_fx, DTFS_STRUCTURE X2_fx, DTFS_STRUCTURE /*-------------------------------------------------------------------*/ /* CALLED FROM : TX */ /*===================================================================*/ -Word32 getSpEngyFromResAmp_fx( DTFS_STRUCTURE *X_fx, Word16 lband, Word16 hband, const Word16 *curr_lpc, Word16 *sin_tab, Word16 *cos_tab ) + +Word32 getSpEngyFromResAmp_fx( + DTFS_STRUCTURE *X_fx, + Word16 lband, + Word16 hband, + const Word16 *curr_lpc, + Word16 *sin_tab, + Word16 *cos_tab ) { Word16 i, k, k4, n, M_fx, HalfLag; Word16 fdiff, freq; @@ -4153,6 +4240,8 @@ Word32 getSpEngyFromResAmp_fx( DTFS_STRUCTURE *X_fx, Word16 lband, Word16 hband, } return ( en ); /* en in 2Q-13 */ } + + /*===================================================================*/ /* FUNCTION : DTFS_poleFilter_fx() */ /*-------------------------------------------------------------------*/ @@ -4177,7 +4266,13 @@ Word32 getSpEngyFromResAmp_fx( DTFS_STRUCTURE *X_fx, Word16 lband, Word16 hband, /*-------------------------------------------------------------------*/ /* CALLED FROM : TX/RX */ /*===================================================================*/ -void DTFS_poleFilter_fx( DTFS_STRUCTURE *X_fx, Word16 *LPC, Word16 N, Word16 *S_fx, Word16 *C_fx ) + +void DTFS_poleFilter_fx( + DTFS_STRUCTURE *X_fx, + Word16 *LPC, + Word16 N, + Word16 *S_fx, + Word16 *C_fx ) { Word16 temp, temp1, temp2, HalfLag; Word32 sum1_fx, sum2_fx; @@ -4278,7 +4373,11 @@ void DTFS_poleFilter_fx( DTFS_STRUCTURE *X_fx, Word16 *LPC, Word16 N, Word16 *S_ X_fx->Q = Qmin; move16(); + + return; } + + /*===================================================================*/ /* FUNCTION : poleFilter_setup_fx() */ /*-------------------------------------------------------------------*/ @@ -4302,7 +4401,17 @@ void DTFS_poleFilter_fx( DTFS_STRUCTURE *X_fx, Word16 *LPC, Word16 N, Word16 *S_ /*-------------------------------------------------------------------*/ /* CALLED FROM : TX/RX */ /*===================================================================*/ -void poleFilter_setup_fx( const Word16 *LPC, Word16 N, DTFS_STRUCTURE X_fx, Word16 *S_fx, Word16 *C_fx, Word16 *pf_temp1, Word16 *pf_temp2, Word16 *pf_temp, Word16 *pf_n2_temp1 ) + +void poleFilter_setup_fx( + const Word16 *LPC, + Word16 N, + DTFS_STRUCTURE X_fx, + Word16 *S_fx, + Word16 *C_fx, + Word16 *pf_temp1, + Word16 *pf_temp2, + Word16 *pf_temp, + Word16 *pf_n2_temp1 ) { Word16 temp1, temp2, HalfLag; Word32 sum1_fx, sum2_fx; @@ -4367,11 +4476,13 @@ void poleFilter_setup_fx( const Word16 *LPC, Word16 N, DTFS_STRUCTURE X_fx, Word pf_temp[k] = (Word16) sum; move16(); /* Q15+exp */ } + + return; } /*=================================================================================*/ -/* FUNCTION : DTFS_getEngy_band_wb_fx (Word16 lband, Word16 hband) */ +/* FUNCTION : DTFS_getEngy_band_wb_fx (Word16 lband, Word16 hband) */ /*---------------------------------------------------------------------------------*/ /* PURPOSE : compute the energy of X1.a[k] and X2.b[k] */ /* Get DTFS energy in the specified range from lband to hband. */ @@ -4381,7 +4492,7 @@ void poleFilter_setup_fx( const Word16 *LPC, Word16 N, DTFS_STRUCTURE X_fx, Word /* function. */ /*---------------------------------------------------------------------------------*/ /* INPUT ARGUMENTS : */ -/* _ (struct DTFS_STRUCTURE) X_fx : a_fx/b_fx in X_fx.Q, lag in Q0 */ +/* _ (struct DTFS_STRUCTURE) X_fx : a_fx/b_fx in X_fx.Q, lag in Q0 */ /* _ (Word16) lband: Q0 */ /* _ (Word16) hband: Q0 */ /*---------------------------------------------------------------------------------*/ @@ -4395,7 +4506,11 @@ void poleFilter_setup_fx( const Word16 *LPC, Word16 N, DTFS_STRUCTURE X_fx, Word /*---------------------------------------------------------------------------------*/ /* CALLED FROM : TX */ /*=================================================================================*/ -Word32 DTFS_getEngy_band_wb_fx( DTFS_STRUCTURE X_fx, Word16 lband, Word16 hband ) + +Word32 DTFS_getEngy_band_wb_fx( + DTFS_STRUCTURE X_fx, + Word16 lband, + Word16 hband ) { Word16 k, lk, hk, HalfLag; Word32 freq_fx, L_lband, L_hband; diff --git a/lib_com/window_fx.c b/lib_com/window_fx.c index df92abadeb50e9014c2cb14b27afb51a78c07458..74582520e396aaf38f5eca09e3a1efb3d8ab5157 100644 --- a/lib_com/window_fx.c +++ b/lib_com/window_fx.c @@ -2,11 +2,14 @@ EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ - #include #include "options.h" #include #include "basop_util.h" +#include "options.h" +#include "rom_basop_util.h" +#include "prot_fx.h" + #define PI_HALF_0Q15 51472 /* ~=round(pi/2*2^15) */ #define PI2_15Q16 0x0006487F /* ~=round(2*PI*2^16) */ @@ -16,20 +19,16 @@ #define P54_0Q15 17695 /* ~=round(0.54*2^15) */ #define P46_0Q15 15073 /* ~=round(0.46*2^15) */ #define P92_0Q15 30147 /* ~=round(0.92*2^15) */ -#include "options.h" -#include "rom_basop_util.h" -#include "prot_fx.h" void ham_cos_window( - Word16 *fh, /* o: 0Q15 */ - const Word16 n1, /* i: */ - const Word16 n2 /* i: */ + Word16 *fh, /* o : 0Q15 */ + const Word16 n1, /* i : */ + const Word16 n2 /* i : */ ) { Word16 i; Word32 cte, cc; - assert( n1 >= 102 ); /* if n1 is too low -> overflow in div_l */ /* cte = PI2/(Float32)(2*n1 - 1); */ BASOP_SATURATE_WARNING_OFF_EVS @@ -64,14 +63,13 @@ void ham_cos_window( } BASOP_SATURATE_WARNING_ON_EVS - return; } void ham_cos_window_ivas( - Word16 *fh, /* o: 0Q15 */ - const Word16 n1, /* i: */ - const Word16 n2 /* i: */ + Word16 *fh, /* o : 0Q15 */ + const Word16 n1, /* i : */ + const Word16 n2 /* i : */ ) { Word16 cc_fx; // Q15 diff --git a/lib_com/wtda_fx.c b/lib_com/wtda_fx.c index c285d88839db98375e926999334b926e69f695ff..ddbd244a78fe788f8b68378409b893200a341017 100644 --- a/lib_com/wtda_fx.c +++ b/lib_com/wtda_fx.c @@ -15,6 +15,7 @@ * * *--------------------------------------------------------------------------*/ + static void mvs2s_inv( const Word16 *in, /* i : input vector */ Word16 *out, /* o : output vector */ @@ -32,7 +33,11 @@ static void mvs2s_inv( in += decimate; out--; } + + return; } + + /*--------------------------------------------------------------------------* * mvr2r_dec() * @@ -82,7 +87,11 @@ static void copy_win( mvs2s_dec( in_win, out_win + nb_zero, win_lenght, decimate ); set16_fx( out_win + add( nb_zero, win_lenght ), 32767, nb_one ); // Q15 } + + return; } + + /*--------------------------------------------------------------------------* * tcx_get_windows_mode1() * @@ -90,13 +99,13 @@ static void copy_win( *--------------------------------------------------------------------------*/ void tcx_get_windows_mode1( - const Word16 left_mode, /* i: overlap mode of left window half */ - const Word16 right_mode, /* i: overlap mode of right window half */ - Word16 *left_win, /* o: left overlap window */ - Word16 *right_win, /* o: right overlap window */ - Word16 *left_win_int, /* o: left overlap window */ - Word16 *right_win_int, /* o: right overlap window */ - const Word16 L /* i : length */ + const Word16 left_mode, /* i : overlap mode of left window half */ + const Word16 right_mode, /* i : overlap mode of right window half */ + Word16 *left_win, /* o : left overlap window */ + Word16 *right_win, /* o : right overlap window */ + Word16 *left_win_int, /* o : left overlap window */ + Word16 *right_win_int, /* o : right overlap window */ + const Word16 L /* i : length */ ) { /* Left part */ @@ -190,6 +199,8 @@ void tcx_get_windows_mode1( { /* assert(!"Window not supported");*/ } + + return; } /*--------------------------------------------------------------------------* @@ -412,9 +423,11 @@ void wtda_fx( Copy( new_audio, old_wtda, L ); } + return; } + void wtda_fx32( const Word32 *new_audio, /* i : input audio Q11 */ Word32 *wtda_audio, /* o : windowed audio Q11 */ @@ -590,6 +603,7 @@ void wtda_fx32( return; } + void wtda_ext_fx( const Word16 *new_audio, /* i : input audio (Q_in) */ Word16 *wtda_audio, /* o : windowed audio (Q_in - 1) */ diff --git a/lib_dec/ACcontextMapping_dec_fx.c b/lib_dec/ACcontextMapping_dec_fx.c index 2fc562d0be3c8238a8050ece13f2b9ef5a4caebb..a483972ff03667aecefb49b507754601b6314db9 100644 --- a/lib_dec/ACcontextMapping_dec_fx.c +++ b/lib_dec/ACcontextMapping_dec_fx.c @@ -11,8 +11,9 @@ #include "cnst.h" #include "prot_fx.h" #include "ivas_prot_fx.h" - #include "ivas_rom_com.h" + + /*-------------------------------------------------------------------* * ACcontextMapping_decode2_no_mem_s17_LC() * @@ -21,11 +22,11 @@ Word16 ACcontextMapping_decode2_no_mem_s17_LC( Decoder_State *st, /* i/o: decoder state */ - Word16 *x, /* o: decoded spectrum Q0*/ - Word16 nt, /* i: size of spectrum */ - Word16 nbbits, /* i: bit budget */ - Word16 resQMaxBits, /* i: residual coding maximum bits*/ - CONTEXT_HM_CONFIG *hm_cfg /* i: context-based harmonic model configuration */ + Word16 *x, /* o : decoded spectrum Q0*/ + Word16 nt, /* i : size of spectrum */ + Word16 nbbits, /* i : bit budget */ + Word16 resQMaxBits, /* i : residual coding maximum bits*/ + CONTEXT_HM_CONFIG *hm_cfg /* i : context-based harmonic model configuration */ ) { Tastat as; diff --git a/lib_dec/FEC_HQ_phase_ecu_fx.c b/lib_dec/FEC_HQ_phase_ecu_fx.c index 497e76ec8fc7568f18097ac25642d5a55244396e..8b9710af9f4f2bd06e21c8c13cda6a70d333186c 100644 --- a/lib_dec/FEC_HQ_phase_ecu_fx.c +++ b/lib_dec/FEC_HQ_phase_ecu_fx.c @@ -1160,6 +1160,8 @@ static void peakfinder_fx( } } } + + return; } /*----------------------------------------------------------------------------- @@ -1167,9 +1169,11 @@ static void peakfinder_fx( * * Get interpolated maximum position *-----------------------------------------------------------------------------*/ -static Word16 imax_fx( /* o: The location, relative to the middle of the 3 given data point, of the maximum. (Q15) */ - const Word16 *y, /* i: The 3 given data points. */ - const Word16 special /* i: -1 = left edge special case, 0 = normal, +1 = right edge special case */ + +/* o: The location, relative to the middle of the 3 given data point, of the maximum. (Q15) */ +static Word16 imax_fx( + const Word16 *y, /* i : The 3 given data points. */ + const Word16 special /* i : -1 = left edge special case, 0 = normal, +1 = right edge special case */ ) { Word16 posi; @@ -4887,8 +4891,9 @@ void hq_ecu_fx( * plot(err); ******************************************************************************/ -static Word16 sqrt2ndOrder( /* o: in Q15 (2nd order least square approx.) */ - const Word16 x /* i: x must be in between 0.5 and 1.0 (Q15). */ +/* o: in Q15 (2nd order least square approx.) */ +static Word16 sqrt2ndOrder( + const Word16 x /* i : x must be in between 0.5 and 1.0 (Q15). */ ) { Word32 acc; @@ -4900,9 +4905,11 @@ static Word16 sqrt2ndOrder( /* o: in Q15 (2nd order least square acc = 682030261L; /* 0.317595089462249 in Q31 */ move32(); z = mac_r( acc, z, x ); /* in Q15 */ + return z; } + /*----------------------------------------------------------------------------- * windowing() * @@ -4911,12 +4918,13 @@ static Word16 sqrt2ndOrder( /* o: in Q15 (2nd order least square * rectLength signifies the length of the rectangular part of the Hamming-Rectangular * window. *--------------------------------------------------------------------------- */ + static void windowing( - const Word16 *x, /* i: Input signal Qx*/ - Word16 *y, /* o: Windowed output Qx*/ - const Word16 *win, /* i: Window coefficients Q15*/ - const Word16 rectLength, /* i: Offset in between the 1st and 2nd symmetric halves of the Hamming window */ - const Word16 halfLength /* i: Half of the total length of a complete Hamming window. */ + const Word16 *x, /* i : Input signal Qx*/ + Word16 *y, /* o : Windowed output Qx*/ + const Word16 *win, /* i : Window coefficients Q15*/ + const Word16 rectLength, /* i : Offset in between the 1st and 2nd symmetric halves of the Hamming window */ + const Word16 halfLength /* i : Half of the total length of a complete Hamming window. */ ) { Word16 i; @@ -4954,12 +4962,13 @@ static void windowing( * 4. 1st half of the right half of the Hamming window * 5. 2nd half of the right half of the Hamming window *----------------------------------------------------------------------------*/ + static void windowing_ROM_optimized( - const Word16 *x, /* i: Input signal Qin*/ - Word16 *y, /* o: Windowed output Qin*/ - const Word16 downSamples, /* i: Offset in accessing the sine table. */ - const Word16 rectLength, /* i: Length of the rectangular portion (excluding the Hamming window part) */ - const Word16 halfLength /* i: Half of the total length of the Hamming (excluding rectangular part) window */ + const Word16 *x, /* i : Input signal Qin*/ + Word16 *y, /* o : Windowed output Qin*/ + const Word16 downSamples, /* i : Offset in accessing the sine table. */ + const Word16 rectLength, /* i : Length of the rectangular portion (excluding the Hamming window part) */ + const Word16 halfLength /* i : Half of the total length of the Hamming (excluding rectangular part) window */ ) { Word16 i, hamm, quarterLen, initOffset; @@ -5019,4 +5028,6 @@ static void windowing_ROM_optimized( move16(); pSine += downSamples; /* Increment address counter */ } + + return; } diff --git a/lib_dec/FEC_scale_syn_fx.c b/lib_dec/FEC_scale_syn_fx.c index a0e0b3981f01b78f7c96a4c19ca2867a4fe8242d..32d7b569ab3b063edc3e827a3b4b9e1b5930ad9f 100644 --- a/lib_dec/FEC_scale_syn_fx.c +++ b/lib_dec/FEC_scale_syn_fx.c @@ -52,33 +52,33 @@ void FEC_scale_syn_fx( const Word16 L_frame, /* i : length of the frame */ - Word16 *update_flg, /* o: flag indicating re-synthesis after scaling*/ + Word16 *update_flg, /* o : flag indicating re-synthesis after scaling*/ Word16 clas, /* i/o: frame classification */ - const Word16 last_good, /* i: last good frame classification */ + const Word16 last_good, /* i : last good frame classification */ Word16 *synth, /* i/o: synthesized speech at Fs = 12k8 Hz Q_syn*/ - const Word16 *pitch, /* i: pitch values for each subframe Q0*/ - Word32 L_enr_old, /* i: energy at the end of previous frame */ - Word32 L_enr_q, /* i: transmitted energy for current frame */ - const Word16 coder_type, /* i: coder type */ + const Word16 *pitch, /* i : pitch values for each subframe Q0*/ + Word32 L_enr_old, /* i : energy at the end of previous frame */ + Word32 L_enr_q, /* i : transmitted energy for current frame */ + const Word16 coder_type, /* i : coder type */ const Word16 LSF_Q_prediction, /* i : LSF prediction mode */ Word16 *scaling_flag, /* i/o: flag to indicate energy control of syn */ Word32 *lp_ener_FEC_av, /* i/o: averaged voiced signal energy Q0*/ Word32 *lp_ener_FEC_max, /* i/o: averaged voiced signal energy Q0*/ - const Word16 bfi, /* i: current frame BFI */ - const Word32 total_brate, /* i: total bitrate */ - const Word16 prev_bfi, /* i: previous frame BFI */ - const Word32 last_core_brate, /* i: previous frame core bitrate */ + const Word16 bfi, /* i : current frame BFI */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 prev_bfi, /* i : previous frame BFI */ + const Word32 last_core_brate, /* i : previous frame core bitrate */ Word16 *exc, /* i/o: excitation signal without enhancement */ Word16 *exc2, /* i/o: excitation signal with enhancement */ Word16 Aq[], /* i/o: LP filter coefs (can be modified if BR) Q12*/ Word16 *old_enr_LP, /* i/o: LP filter E of last good voiced frame Q3*/ - const Word16 *mem_tmp, /* i: temp. initial synthesis filter states Q_syn*/ - Word16 *mem_syn, /* o: initial synthesis filter states Q_syn*/ + const Word16 *mem_tmp, /* i : temp. initial synthesis filter states Q_syn*/ + Word16 *mem_syn, /* o : initial synthesis filter states Q_syn*/ Word16 Q_exc, Word16 Q_syn, const Word16 element_mode, /* i : element mode */ const Word16 avoid_lpc_burst_on_recovery, /* i : if true the excitation energy is limited if LP has big gain */ - const Word16 force_scaling /* i: force scaling */ + const Word16 force_scaling /* i : force scaling */ ) { Word16 i; @@ -247,7 +247,6 @@ void FEC_scale_syn_fx( /*mean_pitch /= (float)(NB_SUBFR);*/ mean_pitch = extract_h( L_shl( L_mean_pitch, 4 ) ); /*Q4*/ - test(); test(); test(); @@ -585,6 +584,7 @@ void FEC_scale_syn_fx( move16(); } } + /*-----------------------------------------------------------------* * Update low-pass filtered energy for voiced frames *-----------------------------------------------------------------*/ @@ -617,6 +617,7 @@ void FEC_scale_syn_fx( /*-----------------------------------------------------------------* * Update the LP filter energy for voiced frames *-----------------------------------------------------------------*/ + test(); if ( GE_16( clas, VOICED_TRANSITION ) && LT_16( clas, INACTIVE_CLAS ) ) { diff --git a/lib_dec/LD_music_post_filter_fx.c b/lib_dec/LD_music_post_filter_fx.c index fe643376858fc44c1117d3175da2ba38ebf0738d..fc3a94a77f54dc0d326ea7198ece000da7f1a8c8 100644 --- a/lib_dec/LD_music_post_filter_fx.c +++ b/lib_dec/LD_music_post_filter_fx.c @@ -410,12 +410,12 @@ void LD_music_post_filter_fx( static void spectrum_mod_dct_fx( const Word16 Qdct, /* i : scaling factor Q0 */ Word16 data[], /* i/o: dct spectrum Qdct */ - const Word32 lf_E[], /* i: per bin E for first 46 bins (without DC) 2*Qdct+10 */ + const Word32 lf_E[], /* i : per bin E for first 46 bins (without DC) 2*Qdct+10 */ Word32 lf_EO[], /* i/o: old per bin E for previous half frame 2*Qdct+10 */ - const Word32 noiseE[], /* i: per band background noise energy estimate 2*Qdct+10 */ - const Word16 minGain, /* i: minimum suppression gain Q15 */ + const Word32 noiseE[], /* i : per band background noise energy estimate 2*Qdct+10 */ + const Word16 minGain, /* i : minimum suppression gain Q15 */ Word16 lp_gbin[], /* i/o: Smoothed suppression gain, per FFT bin Q14*/ - const Word16 music_flag, /* i: music ? 1:0 */ + const Word16 music_flag, /* i : music ? 1:0 */ Word16 min_band, /* i : minimum band */ const Word16 MAX_GN, /* i : Maximum gain overshoot */ const Word16 MAX_band /* i : minimum band */ @@ -662,11 +662,11 @@ static void spectrum_mod_dct_fx( *----------------------------------------------------------------------------------*/ static void analy_sp_dct_fx( - const Word16 *dct_buf, /* i input dct spectrum */ - Word32 *fr_bands, /* o: energy in critical frequency bands 2*Qdct+10 */ - Word32 *lf_E, /* o: per bin E for first... 2*Qdct+10 */ - Word16 *etot, /* o: total input energy Q8 */ - const Word16 Qdct /* i: Scaling of dct */ + const Word16 *dct_buf, /* i : input dct spectrum */ + Word32 *fr_bands, /* o : energy in critical frequency bands 2*Qdct+10 */ + Word32 *lf_E, /* o : per bin E for first... 2*Qdct+10 */ + Word16 *etot, /* o : total input energy Q8 */ + const Word16 Qdct /* i : Scaling of dct */ ) { Word32 Letot = 0; @@ -677,6 +677,7 @@ static void analy_sp_dct_fx( /*-----------------------------------------------------------------* * find energy per critical frequency band and total energy in dB *-----------------------------------------------------------------*/ + find_enr_dct_fx( dct_buf, fr_bands, lf_E, &Letot, 0, MBANDS_GN_LD, Qdct, BIN_16kdct_fx ); /* find average log total energy over both half-frames */ @@ -882,15 +883,18 @@ void Prep_music_postP_fx( return; } + + /*------------------------------------------------------------------------* * norm_lfe() * * Energy bins normalisation *------------------------------------------------------------------------*/ + static Word16 norm_lfe( - const Word32 Lfe, /* i: energy bin to normalize 2*Qdct+10 */ - const Word16 m_norm, /* i: Normalisation factor Q e_norm */ - const Word16 e_norm /* i: Exponent of the normalisation factor */ + const Word32 Lfe, /* i : energy bin to normalize 2*Qdct+10 */ + const Word16 m_norm, /* i : Normalisation factor Q e_norm */ + const Word16 e_norm /* i : Exponent of the normalisation factor */ ) { Word32 Ltmp; @@ -937,14 +941,14 @@ void Post_music_postP_fx( Word16 *prev_Q_syn, /* i : previsous frame synthesis scaling */ Word16 *Q_syn, /* i : Current frame synthesis scaling */ Word16 *mem_syn_clas_estim_fx, /* i : old 12k8 synthesis used for frame classification Q_syn*/ - const Word16 IsIO, /* i: Flag to indicate IO mode */ - Word16 *mem_deemph, /* i/o: speech deemph filter memory Q_syn*/ - Word16 *st_pst_old_syn_fx, /* i/o: psfiler Q_syn*/ - Word16 *st_pst_mem_deemp_err_fx, /* i/o: psfiler Q_syn*/ + const Word16 IsIO, /* i : Flag to indicate IO mode */ + Word16 *mem_deemph, /* i/o: speech deemph filter memory Q_syn*/ + Word16 *st_pst_old_syn_fx, /* i/o: psfiler Q_syn*/ + Word16 *st_pst_mem_deemp_err_fx, /* i/o: psfiler Q_syn*/ Word16 *mem_agc, /* Q_syn */ PFSTAT *pf_stat, /* i/o: All memories related to NB post filter */ - const Word16 *tmp_buffer, /* tmp_buffer in Q-1 */ - Word16 *mem_tmp2 /* Temporary memory used with scale_syn Q_syn*/ + const Word16 *tmp_buffer, /* tmp_buffer in Q-1 */ + Word16 *mem_tmp2 /* Temporary memory used with scale_syn Q_syn*/ ) { Word16 exc16[DCT_L_POST]; diff --git a/lib_dec/TonalComponentDetection_fx.c b/lib_dec/TonalComponentDetection_fx.c index be1245c9ec8b32dccd9694c6b0e0b5dba58da923..e0fd08107fdc8938f00079eb2559cbdeefc5c6e3 100644 --- a/lib_dec/TonalComponentDetection_fx.c +++ b/lib_dec/TonalComponentDetection_fx.c @@ -57,9 +57,9 @@ void ivas_DetectTonalComponents_fx( const Word16 secondLastPowerSpectrum_e, const Word16 nSamples, const Word16 nSamplesCore, - Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins Q0*/ + Word16 floorPowerSpectrum, /* i : lower limit for power spectrum bins Q0*/ const PsychoacousticParameters *psychParamsCurrent, - Word16 element_mode /* i: element mode */ + Word16 element_mode /* i : element mode */ ) { Word16 F0; @@ -121,6 +121,8 @@ void ivas_DetectTonalComponents_fx( /* Find peaks in the second last frame */ ivas_findTonalComponents_fx( indexOfTonalPeak, lowerIndex, upperIndex, pNumIndexes, nSamples, secondLastPowerSpectrum, secondLastPowerSpectrum_e, F0, thresholdModification, element_mode ); + + return; } void DetectTonalComponents( @@ -138,7 +140,7 @@ void DetectTonalComponents( const Word32 secondLastPowerSpectrum[], /*Qx*/ const Word16 nSamples, const Word16 nSamplesCore, - Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins Q0*/ + Word16 floorPowerSpectrum, /* i : lower limit for power spectrum bins Q0*/ Word16 element_mode ) { Word16 F0; @@ -157,6 +159,8 @@ void DetectTonalComponents( /* Find peaks in the second last frame */ findTonalComponents( indexOfTonalPeak, lowerIndex, upperIndex, pNumIndexes, nSamples, secondLastPowerSpectrum, F0, thresholdModification, element_mode ); + + return; } /*-------------------------------------------------------------------* @@ -186,7 +190,7 @@ void RefineTonalComponents( const Word32 secondLastPowerSpectrum[], /*Qx*/ const Word16 nSamples, const Word16 nSamplesCore, - const Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins Q0*/ + const Word16 floorPowerSpectrum, /* i : lower limit for power spectrum bins Q0*/ Word16 element_mode ) { Word16 newIndexOfTonalPeak[MAX_NUMBER_OF_IDX]; /*Q0*/ @@ -196,7 +200,6 @@ void RefineTonalComponents( Word16 iNew, iOld, j; Word16 *pOldPhase, *pNewPhase; - DetectTonalComponents( newIndexOfTonalPeak, newLowerIndex, newUpperIndex, &newNumIndexes, lastPitchLag, currentPitchLag, lastMDCTSpectrum, lastMDCTSpectrum_exp, scaleFactors, scaleFactors_exp, scaleFactors_max_e, secondLastPowerSpectrum, nSamples, nSamplesCore, floorPowerSpectrum, element_mode ); @@ -252,6 +255,7 @@ void RefineTonalComponents( } *pNumIndexes = nPreservedPeaks; /*Q0*/ move16(); + return; } @@ -273,7 +277,7 @@ void ivas_RefineTonalComponents_fx( const Word16 secondLastPowerSpectrum_e, const Word16 nSamples, const Word16 nSamplesCore, - const Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins Q0*/ + const Word16 floorPowerSpectrum, /* i : lower limit for power spectrum bins Q0*/ Word16 element_mode, const PsychoacousticParameters *psychParamsCurrent ) { @@ -284,7 +288,6 @@ void ivas_RefineTonalComponents_fx( Word16 iNew, iOld, j; Word16 *pOldPhase, *pNewPhase; - ivas_DetectTonalComponents_fx( newIndexOfTonalPeak, newLowerIndex, newUpperIndex, &newNumIndexes, lastPitchLag, currentPitchLag, lastMDCTSpectrum, lastMDCTSpectrum_exp, scaleFactors, scaleFactors_exp, scaleFactors_max_e, secondLastPowerSpectrum, secondLastPowerSpectrum_e, nSamples, nSamplesCore, floorPowerSpectrum, psychParamsCurrent, element_mode ); @@ -341,25 +344,27 @@ void ivas_RefineTonalComponents_fx( } *pNumIndexes = nPreservedPeaks; /*Q0*/ move16(); + return; } + /*-------------------------------------------------------------------* * Local functions *-------------------------------------------------------------------*/ + static void calcPseudoSpec( - const Word32 *mdctSpec, /* i: MDCT spectrum */ - const Word16 mdctSpec_exp, /* i: exponent of MDCT spectrum */ - const Word16 nSamples, /* i: frame size */ - Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins Q0*/ - Word32 *powerSpec, /* o: estimated power spectrum */ - Word16 *powerSpec_exp /* o: exponent of estimated power spectrum */ + const Word32 *mdctSpec, /* i : MDCT spectrum */ + const Word16 mdctSpec_exp, /* i : exponent of MDCT spectrum */ + const Word16 nSamples, /* i : frame size */ + Word16 floorPowerSpectrum, /* i : lower limit for power spectrum bins Q0*/ + Word32 *powerSpec, /* o : estimated power spectrum */ + Word16 *powerSpec_exp /* o : exponent of estimated power spectrum */ ) { Word16 k; Word32 x, L_tmp, L_tmp_floor; Word16 tmp_loop; - *powerSpec_exp = add( add( mdctSpec_exp, mdctSpec_exp ), 5 ); move16(); @@ -395,16 +400,18 @@ static void calcPseudoSpec( move32(); powerSpec[nSamples - 1] = L_shr( powerSpec[nSamples - 2], 1 ); /*0.5f * powerSpec[nSamples - 2]*/ move32(); + return; } + #define LEVEL_EXP 3 /*+4*/ static void getEnvelope( - const Word16 nSamples, /*i: Q0 */ - const Word32 *powerSpec, /*i: powerSpec_exp */ - Word16 F0, /*i: 5Q10*/ - Word32 *envelope, /*o: powerSpec_exp + LEVEL_EXP Q28*/ - Word32 *smoothedSpectrum /*o: powerSpec_exp + LEVEL_EXP Q28*/ + const Word16 nSamples, /*i : Q0 */ + const Word32 *powerSpec, /*i : powerSpec_exp */ + Word16 F0, /*i : 5Q10*/ + Word32 *envelope, /*o : powerSpec_exp + LEVEL_EXP Q28*/ + Word32 *smoothedSpectrum /*o : powerSpec_exp + LEVEL_EXP Q28*/ ) { Word16 nFilterLength, nHalfFilterLength, nSecondHalfFilterLength, n1, n2; @@ -490,9 +497,11 @@ static void getEnvelope( move32(); smoothedSpectrum[0] = L_add( Mpy_32_16_1( powerSpec[1], 3072 /*0.75f Q12*/ ), L_shr( powerSpec[0], LEVEL_EXP ) ); /*Q28*/ smoothedSpectrum[nSamples - 1] = L_add( Mpy_32_16_1( powerSpec[nSamples - 2], 3072 /*0.75f Q12*/ ), L_shr( powerSpec[nSamples - 1], LEVEL_EXP ) ); /**/ + return; } + static void GetF0( Word16 /*short*/ const nSamples, /*i - Q0 */ Word16 /*short*/ const nSamplesCore, /*i - Q0 */ @@ -536,7 +545,6 @@ static void GetF0( BASOP_Util_Divide_MantExp( tmp, 15, *pF0, 5, &nTotalHarmonics, &tmp ); nTotalHarmonics = shl( nTotalHarmonics, sub( tmp, 15 ) ); - /* Get in rgiStrongHarmonics all i for which i*F0 are the strongest harmonics */ findStrongestHarmonics( nSamples, powerSpectrum, *pF0, nTotalHarmonics, rgiStrongHarmonics, &nStrongHarmonics ); @@ -549,9 +557,11 @@ static void GetF0( *pF0 = 0; *pOrigF0 = 0; } + return; } + static void ivas_GetF0_fx( Word16 /*short*/ const nSamples, /*i - Q0 */ Word16 /*short*/ const nSamplesCore, /*i - Q0 */ @@ -566,7 +576,6 @@ static void ivas_GetF0_fx( Word16 /*short*/ nTotalHarmonics, nStrongHarmonics; Word16 tmp; - assert( LAST_HARMONIC_POS_TO_CHECK <= nSamplesCore ); /* Use only F0 >= 100 Hz */ @@ -608,6 +617,7 @@ static void ivas_GetF0_fx( *pF0 = 0; *pOrigF0 = 0; } + return; } @@ -839,9 +849,11 @@ static void CorrectF0( *pF0 = F0; move16(); } + return; } + static void ivas_CorrectF0_fx( const Word16 /*short*/ *pHarmonicIndexes, /*I - Q0 */ const Word16 /*short*/ nHarmonics, /*I - Q0 */ @@ -992,9 +1004,11 @@ static void ivas_CorrectF0_fx( *pF0 = F0; move16(); } + return; } + static void modifyThreshold( Word16 /*short*/ i, /*I - Q0 */ Word16 /*short*/ F0, /*I - Q10*/ @@ -1006,7 +1020,6 @@ static void modifyThreshold( Word16 k /*Q0*/; Word16 twoTimesFract /*Q10*/; - harmonic = L_mult( shl( i, 5 ), F0 ); /*Q0 * Q10 = 15Q16*/ k = extract_h( harmonic ); /*Q0*/ fractional = lshr( extract_l( harmonic ), 1 ); /* Fractional part of the i*F0 */ /*Q15*/ @@ -1018,9 +1031,11 @@ static void modifyThreshold( thresholdModification[k - 1] = add( threshold /*Q10*/, twoTimesFract /*Q10*/ ); /*Q10*/ move16(); thresholdModification[k + 1] = add( threshold /*Q10*/, sub( 2048 /*2 in Q10*/, twoTimesFract /*Q10*/ ) /*Q10*/ ); /*Q10*/ + return; } + static void modifyThresholds( Word16 /*short*/ F0, /*I - Q10*/ Word16 /*short*/ origF0, /*I - Q10*/ @@ -1029,7 +1044,6 @@ static void modifyThresholds( Word16 /*int*/ i, /*int*/ nHarmonics; Word16 tmp, tmpM, tmpE; - IF( origF0 > 0 ) { IF( F0 == 0 ) @@ -1059,15 +1073,17 @@ static void modifyThresholds( } } } + return; } + static void findCandidates( - const Word16 nSamples, /* i: frame size */ - const Word32 *MDCTSpectrum, /* i: MDCT spectrum */ - const Word16 MDCTSpectrum_exp, /* i: exponent of MDCT spectrum */ - Word16 *thresholdModificationNew, /* o: threshold modification Q10 */ - Word16 floorPowerSpectrum /* i: lower limit for power spectrum bins Q0*/ + const Word16 nSamples, /* i : frame size */ + const Word32 *MDCTSpectrum, /* i : MDCT spectrum */ + const Word16 MDCTSpectrum_exp, /* i : exponent of MDCT spectrum */ + Word16 *thresholdModificationNew, /* o : threshold modification Q10 */ + Word16 floorPowerSpectrum /* i : lower limit for power spectrum bins Q0*/ ) { Word32 powerSpectrum[L_FRAME_MAX]; @@ -1079,7 +1095,6 @@ static void findCandidates( Word32 biggerNeighbor; Word16 tmp_loop1, tmp_loop2, tmp_loop3; - calcPseudoSpec( MDCTSpectrum, MDCTSpectrum_exp, nSamples, floorPowerSpectrum, powerSpectrum, &powerSpectrum_exp ); getEnvelope( nSamples, powerSpectrum, 0, envelope, smoothedSpectrum ); @@ -1192,9 +1207,11 @@ static void findCandidates( } k = add( k, 1 ); } + return; } + static void RefineThresholdsUsingPitch( const Word16 nSamples, const Word16 nSamplesCore, @@ -1232,9 +1249,11 @@ static void RefineThresholdsUsingPitch( *pF0 = 0; move16(); } + return; } + static void ivas_findTonalComponents_fx( Word16 *indexOfTonalPeak, /* OUT Q0*/ Word16 *lowerIndex, /* OUT Q0*/ @@ -1257,7 +1276,6 @@ static void ivas_findTonalComponents_fx( getEnvelope( nSamples, powerSpectrum, F0, envelope, smoothedSpectrum ); - nrOfFIS = 0; move16(); lowerBound = 0; @@ -1396,6 +1414,7 @@ static void ivas_findTonalComponents_fx( *numIndexes = nrOfFIS; move16(); + return; } @@ -1437,8 +1456,11 @@ static void ivas_RefineThresholdsUsingPitch_fx( *pF0 = 0; move16(); } + return; } + + static void findTonalComponents( Word16 *indexOfTonalPeak, /* OUT Q0*/ Word16 *lowerIndex, /* OUT Q0*/ @@ -1460,7 +1482,6 @@ static void findTonalComponents( getEnvelope( nSamples, powerSpectrum, F0, envelope, smoothedSpectrum ); - nrOfFIS = 0; move16(); lowerBound = 0; @@ -1594,5 +1615,6 @@ static void findTonalComponents( *numIndexes = nrOfFIS; move16(); + return; } diff --git a/lib_dec/ari_hm_dec_fx.c b/lib_dec/ari_hm_dec_fx.c index f2b1a011021a6c53d1d0e368b2ce14179ce8064f..2d02da71a8655d9ed77242dcf112ac90968bf1b9 100644 --- a/lib_dec/ari_hm_dec_fx.c +++ b/lib_dec/ari_hm_dec_fx.c @@ -88,9 +88,9 @@ DecodeIndex_fx( *-------------------------------------------------------------------*/ static Word16 tcx_hm_dequantize_gain_fx( - Word16 coder_type, /* i : coder type Q0 */ - Word16 gain_idx, /* i: quantization index Q0 */ - Word16 *gain /* o: dequantized gain Q11 */ + Word16 coder_type, /* i : coder type Q0 */ + Word16 gain_idx, /* i : quantization index Q0 */ + Word16 *gain /* o : dequantized gain Q11 */ ) { diff --git a/lib_dec/arith_coder_dec_fx.c b/lib_dec/arith_coder_dec_fx.c index e91ac4ed0201b33814a3989abcd89222a50a3e8e..c69c65e031774982dd0f008a4ccabc9c7810ba6b 100644 --- a/lib_dec/arith_coder_dec_fx.c +++ b/lib_dec/arith_coder_dec_fx.c @@ -13,14 +13,14 @@ /* Returns: number of bits consumed */ static Word16 tcx_arith_decode_fx( - Word16 L_frame, /* i: number of spectral lines Q0 */ - const Word16 envelope[], /* i: scaled envelope Q15-e */ - Word16 envelope_e, /* i: scaled envelope exponent Q0 */ - Word16 target_bits, /* i: target bit budget Q0 */ - Word16 prm[], /* i: bit-stream Q0 */ - Word32 q_spectrum[], /* o: scalar quantized spectrum Q31-e */ - Word16 *q_spectrum_e, /* o: spectrum exponent Q0 */ - Word16 *nf_seed /* o: noise filling seed Q0 */ + Word16 L_frame, /* i : number of spectral lines Q0 */ + const Word16 envelope[], /* i : scaled envelope Q15-e */ + Word16 envelope_e, /* i : scaled envelope exponent Q0 */ + Word16 target_bits, /* i : target bit budget Q0 */ + Word16 prm[], /* i : bit-stream Q0 */ + Word32 q_spectrum[], /* o : scalar quantized spectrum Q31-e */ + Word16 *q_spectrum_e, /* o : spectrum exponent Q0 */ + Word16 *nf_seed /* o : noise filling seed Q0 */ ) { Word16 bp, k, q, s; @@ -91,21 +91,21 @@ static Word16 tcx_arith_decode_fx( } void tcx_arith_decode_envelope_fx( - Word32 q_spectrum[], /* o: quantised MDCT coefficients Q31-e */ - Word16 *q_spectrum_e, /* o: MDCT exponent Q0 */ - Word16 L_frame, /* i: frame or MDCT length Q0 */ - Word16 L_spec, /* i: length w/o BW limitation Q0 */ - Decoder_State *st, - const Word16 A_ind[], /* i: quantised LPC coefficients Q12 */ - Word16 target_bits, /* i: number of available bits Q0 */ - Word16 prm[], /* i: bitstream parameters Q0 */ - Word8 use_hm, /* i: use HM in current frame? */ - Word16 prm_hm[], /* i: HM parameter area Q0 */ - Word16 tcxltp_pitch, /* i: TCX LTP pitch in FD, -1 if n/a Q0*/ - Word16 *arith_bits, /* o: bits used for ari. coding Q0 */ - Word16 *signaling_bits, /* o: bits used for signaling Q0 */ - Word16 *nf_seed, /* o: noise filling seed Q0 */ - Word16 low_complexity /* i: low-complexity flag Q0 */ + Word32 q_spectrum[], /* o : quantised MDCT coefficients Q31-e */ + Word16 *q_spectrum_e, /* o : MDCT exponent Q0 */ + Word16 L_frame, /* i : frame or MDCT length Q0 */ + Word16 L_spec, /* i : length w/o BW limitation Q0 */ + Decoder_State *st, /* i/o: coder state */ + const Word16 A_ind[], /* i : quantised LPC coefficients Q12 */ + Word16 target_bits, /* i : number of available bits Q0 */ + Word16 prm[], /* i : bitstream parameters Q0 */ + Word8 use_hm, /* i : use HM in current frame? */ + Word16 prm_hm[], /* i : HM parameter area Q0 */ + Word16 tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a Q0 */ + Word16 *arith_bits, /* o : bits used for ari. coding Q0 */ + Word16 *signaling_bits, /* o : bits used for signaling Q0 */ + Word16 *nf_seed, /* o : noise filling seed Q0 */ + Word16 low_complexity /* i : low-complexity flag Q0 */ ) { Word32 env[N_MAX_ARI]; /* unscaled envelope */ diff --git a/lib_dec/dec4t64_fx.c b/lib_dec/dec4t64_fx.c index 23313262ce1b2ac1f9c9e08a59df85e9114a1686..062157dca37009729e075ec50cb67c91981b56f3 100644 --- a/lib_dec/dec4t64_fx.c +++ b/lib_dec/dec4t64_fx.c @@ -234,15 +234,18 @@ void dec_acelp_4t64_fx( return; } + + /*-------------------------------------------------------* * add_pulses() * * Add decoded pulses to the codeword *-------------------------------------------------------*/ + static void add_pulses_fx( - const Word16 pos[], /* i: pulse position */ - const Word16 nb_pulse, /* i: nb. of pulses */ - const Word16 track, /* i: no. of the tracks */ + const Word16 pos[], /* i : pulse position */ + const Word16 nb_pulse, /* i : nb. of pulses */ + const Word16 track, /* i : no. of the tracks */ Word16 code[] /* i/o: decoded codevector Q9*/ ) { @@ -278,11 +281,12 @@ static void add_pulses_fx( * * Decode 1 pulse with N+1 bits *-------------------------------------------------------*/ + void dec_1p_N1_fx( - const Word32 index, /* i: quantization index */ - const Word16 N, /* i: nb. of bits */ - const Word16 offset, /* i: pulse position offset */ - Word16 pos[] /* o: pulse position */ + const Word32 index, /* i : quantization index */ + const Word16 N, /* i : nb. of bits */ + const Word16 offset, /* i : pulse position offset */ + Word16 pos[] /* o : pulse position */ ) { Word16 pos1; @@ -303,7 +307,11 @@ void dec_1p_N1_fx( } pos[0] = pos1; move16(); + + return; } + + /*-------------------------------------------------------* * dec_2p_2N1() * @@ -311,13 +319,12 @@ void dec_1p_N1_fx( *-------------------------------------------------------*/ void dec_2p_2N1_fx( - const Word32 index, /* i: quantization index */ - const Word16 N, /* i: nb. of bits */ - const Word16 offset, /* i: pulse position offset */ - Word16 pos[] /* o: pulse position */ + const Word32 index, /* i : quantization index */ + const Word16 N, /* i : nb. of bits */ + const Word16 offset, /* i : pulse position offset */ + Word16 pos[] /* o : pulse position */ ) { - Word16 pos1, pos2, tmp; Word32 mask, i; @@ -335,7 +342,6 @@ void dec_2p_2N1_fx( pos2 = add( extract_l( index & mask ), offset ); logic16(); - IF( LT_16( pos2, pos1 ) ) { IF( i != 0 ) @@ -363,11 +369,14 @@ void dec_2p_2N1_fx( return; } + + /*-------------------------------------------------------* * Dec_3p_3N1 * * Decode 3 pulses with 3*N+1 bits: *-------------------------------------------------------*/ + static void dec_3p_3N1_fx( const Word32 index, /* i : quantization index */ const Word16 N, /* i : nb. of bits */ @@ -400,6 +409,8 @@ static void dec_3p_3N1_fx( logic16(); dec_1p_N1_fx( idx, N, offset, pos + 2 ); + + return; } /*-------------------------------------------------------* @@ -407,6 +418,7 @@ static void dec_3p_3N1_fx( * * Decode 4 pulses with 4*N+1 bits: *-------------------------------------------------------*/ + static void dec_4p_4N1_fx( const Word32 index, /* i : quantization index */ const Word16 N, /* i : nb. of bits */ @@ -438,6 +450,8 @@ static void dec_4p_4N1_fx( idx = L_shr( index, shl( N, 1 ) ) & mask; logic16(); /* idx = (index >> (2*N)) & mask; */ dec_2p_2N1_fx( idx, N, offset, pos + 2 ); /* Dec_2p_2N1(idx, N, offset, pos+2); */ + + return; } @@ -446,6 +460,7 @@ static void dec_4p_4N1_fx( * * Decode 4 pulses with 4*N bits: *-------------------------------------------------------*/ + static void dec_4p_4N_fx( const Word32 index, /* i : quantization index */ const Word16 N, /* i : nb. of bits */ @@ -496,6 +511,8 @@ static void dec_4p_4N_fx( move16(); BREAK; } + + return; } @@ -504,6 +521,7 @@ static void dec_4p_4N_fx( * * Decode 5 pulses with 5*N bits: *-------------------------------------------------------*/ + static void dec_5p_5N_fx( const Word32 index, /* i : quantization index */ const Word16 N, /* i : nb. of bits */ @@ -533,6 +551,8 @@ static void dec_5p_5N_fx( dec_2p_2N1_fx( index, N, offset, pos + 3 ); move16(); } + + return; } /*-------------------------------------------------------* @@ -540,6 +560,7 @@ static void dec_5p_5N_fx( * * Decode 6 pulses with 6*N+2 bits: *-------------------------------------------------------*/ + static void dec_6p_6N2_fx( const Word32 index, /* i : quantization index */ const Word16 N, /* i : nb. of bits */ @@ -593,13 +614,16 @@ static void dec_6p_6N2_fx( dec_3p_3N1_fx( index, n_1, j, pos + 3 ); BREAK; } + + return; } -static Word32 fcb_decode_class_all_p_fx( /* o: The index of pulse positions */ - Word32 *code_index, /* i: fcb index information */ - Word16 sector_6p_num[], /* o: Number of pulses for each position */ - Word16 pulse_num, /* i: Number of pulses on a track. */ - Word16 *pos_num /* o: Number of positions which have pulses on the track.*/ +/* o: The index of pulse positions */ +static Word32 fcb_decode_class_all_p_fx( + Word32 *code_index, /* i : fcb index information */ + Word16 sector_6p_num[], /* o : Number of pulses for each position */ + Word16 pulse_num, /* i : Number of pulses on a track. */ + Word16 *pos_num /* o : Number of positions which have pulses on the track.*/ ) { Word16 i; @@ -674,9 +698,9 @@ return mn9; } static void fcb_decode_position_fx( - Word32 index, /* i: position index information */ - Word16 pos_vector[], /* o: the positon vector */ - Word16 pos_num /* i: number of positions */ + Word32 index, /* i : position index information */ + Word16 pos_vector[], /* o : the positon vector */ + Word16 pos_num /* i : number of positions */ ) { Word32 i, k, l; @@ -710,10 +734,11 @@ static void fcb_decode_position_fx( return; } -static void fcb_decode_PI_fx( /* o: return pulse position number */ - Word32 code_index, /* i: fcb index information */ - Word16 sector_6p[], /* o: decoded pulse position */ - Word16 pulse_num /* i: pulse number for the track */ +/* o: return pulse position number */ +static void fcb_decode_PI_fx( + Word32 code_index, /* i : fcb index information */ + Word16 sector_6p[], /* o : decoded pulse position */ + Word16 pulse_num /* i : pulse number for the track */ ) { Word16 i, l, j; @@ -760,7 +785,10 @@ static void fcb_decode_PI_fx( /* o: return pulse position * Read FCB index * *---------------------------------------------------------------------*/ -void D_ACELP_decode_43bit_fx( UWord16 idxs[], Word16 code[], Word16 *pulsestrack ) +void D_ACELP_decode_43bit_fx( + UWord16 idxs[], + Word16 code[], + Word16 *pulsestrack ) { Word32 ps[8]; Word16 pos[7]; diff --git a/lib_dec/dec_higher_acelp_fx.c b/lib_dec/dec_higher_acelp_fx.c index 5e02f9913af51236c2fd65bef4eb000879738288..842749fa411665f0da5ffffda9c534e278ce87cf 100644 --- a/lib_dec/dec_higher_acelp_fx.c +++ b/lib_dec/dec_higher_acelp_fx.c @@ -245,10 +245,10 @@ void transf_cdbk_dec_fx( /* * range using the specified number of levels. */ /*--------------------------------------------------------------------------*/ /* INPUT ARGUMENTS : */ -/* Word16 index i: quantization index */ +/* Word16 index i : quantization index */ /* Word16 min_val i : value of lower limit */ /* Word16 max_val i : value of upper limit */ -/* Word16 bits i : number of bits to dequantize */ +/* Word16 bits i : number of bits to dequantize */ /*--------------------------------------------------------------------------*/ /* OUTPUT ARGUMENTS : */ /* _Word16 *expg o : */ @@ -260,12 +260,14 @@ void transf_cdbk_dec_fx( /*--------------------------------------------------------------------------*/ /* CALLED FROM : */ /*==========================================================================*/ -Word16 gain_dequant_fx( /* o: decoded gain */ - Word16 index, /* i: quantization index */ - const Word16 min_val, /* i: value of lower limit */ - const Word16 max_val, /* i: value of upper limit */ - const Word16 bits, /* i: number of bits to dequantize */ - Word16 *expg ) + +/* o: decoded gain */ +Word16 gain_dequant_fx( + Word16 index, /* i : quantization index */ + const Word16 min_val, /* i : value of lower limit */ + const Word16 max_val, /* i : value of upper limit */ + const Word16 bits, /* i : number of bits to dequantize */ + Word16 *expg ) { Word16 gain, c_min, c_max; Word16 levels; diff --git a/lib_dec/er_util_fx.c b/lib_dec/er_util_fx.c index 66477ddb18de57e53037fdbe56aa7e23aa4c3476..e07a0717d0e54e0043d4516d98bc93012fd930c4 100644 --- a/lib_dec/er_util_fx.c +++ b/lib_dec/er_util_fx.c @@ -176,6 +176,8 @@ void minimumStatistics_fx( *noiseEstimate = f; /*Qx*/ move16(); + + return; } /*----------------------------------------------------------------------* @@ -183,20 +185,16 @@ void minimumStatistics_fx( * PLC: getLevelSynDeemph_fx: derives on frame or subframe basis the level * of LPC synthesis and deeemphasis based on the given input *----------------------------------------------------------------------*/ -Word16 getLevelSynDeemph_fx( /*10Q5*/ - Word16 h1Init[], - /* i: input value or vector to be processed */ /* Q15 */ - Word16 const A[], - /* i: LPC coefficients */ /* Qx */ - Word16 const lpcorder, - /* i: LPC order */ /* Q0 */ - Word16 const lenLpcExc, - /* i: length of the LPC excitation buffer */ /* Q0 */ - Word16 const preemph_fac, - /* i: preemphasis factor */ /* Q15 */ - Word16 const numLoops, - /* i: number of loops */ /* Q0 */ - Word16 *Exp /* o: exponent of return value Q15 */ + +/*10Q5*/ +Word16 getLevelSynDeemph_fx( + Word16 h1Init[], /* i : input value or vector to be processed Q15 */ + Word16 const A[], /* i : LPC coefficients Qx */ + Word16 const lpcorder, /* i : LPC order Q0 */ + Word16 const lenLpcExc, /* i : length of the LPC excitation buffer Q0 */ + Word16 const preemph_fac, /* i : preemphasis factor Q15 */ + Word16 const numLoops, /* i : number of loops Q0 */ + Word16 *Exp /* o : exponent of return value Q15 */ ) { Word32 levelSynDeemphSub; @@ -208,7 +206,6 @@ Word16 getLevelSynDeemph_fx( /*10Q5*/ Word16 s16, tmp16, Hr16; Word16 Q_h1; - levelSynDeemphSub = L_deposit_l( 0 ); levelSynDeemph = L_deposit_l( 0 ); tmp = 0; @@ -266,7 +263,7 @@ Word16 getLevelSynDeemph_fx( /*10Q5*/ return round_fx_sat( levelSynDeemph ); /*Q15*/ } -/* BASOP version: up to date with rev 7422 */ + void genPlcFiltBWAdap_fx( const Word32 sr_core, /* i : core sampling rate Q0*/ Word16 *lpFiltAdapt, /* o : filter coefficients for filtering codebooks in case of flc Q15*/ @@ -276,7 +273,6 @@ void genPlcFiltBWAdap_fx( { Word16 a, b, exp; - assert( type == 0 || type == 1 ); IF( EQ_32( sr_core, INT_FS_16k ) ) @@ -333,6 +329,8 @@ void genPlcFiltBWAdap_fx( move16(); } } + + return; } @@ -340,13 +338,13 @@ void genPlcFiltBWAdap_fx( * PLC: [ACELP: general] * PLC: high pass filtering *-----------------------------------------------------------------*/ -/*VERSIONINFO: This port is up to date with trunk rev. 32434*/ + void highPassFiltering_fx( - const Word16 last_good, /* i: short last classification type Q0*/ - const Word16 L_buffer, /* i: int buffer length Q0*/ + const Word16 last_good, /* i : short last classification type Q0*/ + const Word16 L_buffer, /* i : int buffer length Q0*/ Word16 exc2[], /* i/o: Qx unvoiced excitation before the high pass filtering */ - const Word16 hp_filt[], /* i: Q15 high pass filter coefficients */ - const Word16 l_fir_fer ) /* i: high pass filter length Q0*/ + const Word16 hp_filt[], /* i : Q15 high pass filter coefficients */ + const Word16 l_fir_fer ) /* i : high pass filter length Q0*/ { Word16 i; /*int*/ @@ -359,6 +357,8 @@ void highPassFiltering_fx( move16(); } } + + return; } /*----------------------------------------------------------------------------------* @@ -626,6 +626,7 @@ Word16 GetPLCModeDecision_fx( } } } + return core; } #endif // !HARMONIZE_2427_GETPLC diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 471600ca384bdf57eb243d35a22f4ea120904fde..213962d4307f87e4df7eb83d21b57db2d73c8ebb 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -1139,8 +1139,8 @@ Word16 ApplyFdCng_fx( Parameters: - timeDomainInput, i: pointer to time domain input - bitrate, i: bitrate + timeDomainInput, i : pointer to time domain input + bitrate, i : bitrate st i/o: FD_CNG structure containing all buffers and variables Function: @@ -1150,7 +1150,7 @@ Word16 ApplyFdCng_fx( void */ void perform_noise_estimation_dec_fx( - const Word16 *timeDomainInput, /* i: pointer to time domain input Q*/ + const Word16 *timeDomainInput, /* i : pointer to time domain input Q*/ const Word16 Q, HANDLE_FD_CNG_DEC hFdCngDec /* i/o: FD_CNG structure containing all buffers and variables */ ) @@ -1310,7 +1310,7 @@ void perform_noise_estimation_dec_fx( } void perform_noise_estimation_dec_ivas_fx( - const Word16 *timeDomainInput, /* i: pointer to time domain input Q*/ + const Word16 *timeDomainInput, /* i : pointer to time domain input Q*/ const Word16 Q, Word32 *power_spectrum, /*Q_power_spectrum*/ Word16 Q_power_spectrum, diff --git a/lib_dec/hf_synth_fx.c b/lib_dec/hf_synth_fx.c index 153b760804e41756ed7400e9d6731de8e8332579..7b1124d5805bff94df9efcd8ac3759b4dac18c68 100644 --- a/lib_dec/hf_synth_fx.c +++ b/lib_dec/hf_synth_fx.c @@ -246,9 +246,6 @@ static void hf_synthesis_fx( hp400_12k8_ivas_fx( synth, L_SUBFR, hBWE_zero->mem_hp400_fx ); - /* i: mem_hp400 in Q_syn */ - /* i: synth in Q_syn */ - /* o: synth in Q_syn-3 */ prod = W_mac0_16_16( 1L, synth[0], synth[0] ); /* 2*(Q_syn-3) */ FOR( i = 1; i < L_SUBFR; i++ ) { @@ -312,9 +309,6 @@ static void hf_synthesis_fx( move16(); filt_6k_7k_scale_fx( HF_exc, L_SUBFR16k, hBWE_zero->mem_hf_fx, tmp, exp2 ); - /* i: input HF_exc is scaled in float, here scaling is done inside this filter */ - /* i: mem_hf in Q-2 */ - /* o: HF_exc in Q0 */ /*-----------------------------------------------------------------* * synthesis of noise: 4.8kHz..5.6kHz --> 6kHz..7kHz diff --git a/lib_dec/hq_lr_dec_fx.c b/lib_dec/hq_lr_dec_fx.c index 3fe586a26d3bf9fc7a11127f7413c3ab695e4818..7ec1d15db8f0c23719b047d6ddce8b52e86d542d 100644 --- a/lib_dec/hq_lr_dec_fx.c +++ b/lib_dec/hq_lr_dec_fx.c @@ -50,15 +50,15 @@ static Word16 Calc_inv( Word32 L_tmp, Word16 *exp ) *--------------------------------------------------------------------------*/ static void spt_shorten_domain_set_dec_fx( - Decoder_State *st_fx, /* i: encoder state structure */ - const Word16 p2a_flags[], /* i: p2a anlysis information Q0*/ - const Word16 new_band_start[], /* i: new band start position Q0*/ - const Word16 new_band_end[], /* i: new band end position Q0*/ - const Word16 new_band_width[], /* i: new subband band width Q0*/ - const Word16 bands, /* i: total number of subbands Q0*/ - Word16 band_start[], /* o: band start position Q0*/ - Word16 band_end[], /* o: band end position Q0*/ - Word16 band_width[], /* o: sub band band width Q0*/ + Decoder_State *st_fx, /* i : encoder state structure */ + const Word16 p2a_flags[], /* i : p2a anlysis information Q0*/ + const Word16 new_band_start[], /* i : new band start position Q0*/ + const Word16 new_band_end[], /* i : new band end position Q0*/ + const Word16 new_band_width[], /* i : new subband band width Q0*/ + const Word16 bands, /* i : total number of subbands Q0*/ + Word16 band_start[], /* o : band start position Q0*/ + Word16 band_end[], /* o : band end position Q0*/ + Word16 band_width[], /* o : sub band band width Q0*/ Word16 *bit_budget /* i/o: bit budget Q0*/ ) { @@ -175,7 +175,6 @@ void hq_lr_dec_fx( Word16 adjustFlag; Word16 bw_low, bw_high; - HQ_DEC_HANDLE hHQ_core = st_fx->hHQ_core; tmp2 = 0; /* to avoid compilation flags */ @@ -289,7 +288,6 @@ void hq_lr_dec_fx( bit_budget_fx = sub( sub( num_bits, ebits_fx ), round_fx( L_shl( L_mult( Ngq_fx, gqbits_fx ), 15 ) ) ); /* (*num_bits) - (short) ceil (ebits) - Ngq * gqbits; Q0*/ - pbits_fx = 0; move16(); test(); @@ -577,9 +575,9 @@ void hq_lr_dec_fx( move32(); } } - hq2_bit_alloc_fx( - L_band_energy_tmp, bands_fx, L_Rk, &bit_budget_fx, p2a_flags_fx, bit_alloc_weight_fx, band_width, - num_bits, hqswb_clas_fx, st_fx->bwidth, *is_transient_fx ); + + hq2_bit_alloc_fx( L_band_energy_tmp, bands_fx, L_Rk, &bit_budget_fx, p2a_flags_fx, bit_alloc_weight_fx, band_width, + num_bits, hqswb_clas_fx, st_fx->bwidth, *is_transient_fx ); } ELSE IF( *is_transient_fx == 0 && EQ_16( inner_frame, L_FRAME16k ) ) { @@ -613,6 +611,7 @@ void hq_lr_dec_fx( bw_low = sub( band_start[highband], band_start[lowband] ); /* Q0 */ bw_high = sub( add( band_end[bands_fx - 1], 1 ), band_start[highband] ); /* Q0 */ } + /* calculate the the low band/high band energy and the variance/avrage of the envelopes */ enerL_fx = L_deposit_l( 0 ); enerH_fx = L_deposit_l( 0 ); @@ -774,7 +773,6 @@ void hq_lr_dec_fx( } } - L_tmp = Mult_32_16( Ep_peak_fx, 24576 ); /*Q(15+13-15 = 13) lowband = 6; */ L_tmp2 = Mult_32_16( Ep_peak_fx, 19661 ); /*Q(15+14-15 = 14) */ L_tmp3 = Mult_32_16( Ep_avrgL_fx, 24576 ); /*Q(15+12-15 = 12) */ @@ -802,9 +800,8 @@ void hq_lr_dec_fx( } } - hq2_bit_alloc_fx( - L_band_energy_tmp, bands_fx, L_Rk, &bit_budget_fx, p2a_flags_fx, bit_alloc_weight_fx, band_width, - num_bits, hqswb_clas_fx, st_fx->bwidth, *is_transient_fx ); + hq2_bit_alloc_fx( L_band_energy_tmp, bands_fx, L_Rk, &bit_budget_fx, p2a_flags_fx, bit_alloc_weight_fx, band_width, + num_bits, hqswb_clas_fx, st_fx->bwidth, *is_transient_fx ); } ELSE IF( EQ_16( st_fx->bwidth, SWB ) && EQ_16( hqswb_clas_fx, HQ_HARMONIC ) && ( EQ_32( L_bwe_br, HQ_16k40 ) || EQ_32( L_bwe_br, HQ_13k20 ) ) ) { @@ -812,9 +809,8 @@ void hq_lr_dec_fx( } ELSE { - hq2_bit_alloc_fx( - L_band_energy, bands_fx, L_Rk, &bit_budget_fx, p2a_flags_fx, bit_alloc_weight_fx, band_width, - num_bits, hqswb_clas_fx, st_fx->bwidth, *is_transient_fx ); + hq2_bit_alloc_fx( L_band_energy, bands_fx, L_Rk, &bit_budget_fx, p2a_flags_fx, bit_alloc_weight_fx, band_width, + num_bits, hqswb_clas_fx, st_fx->bwidth, *is_transient_fx ); } IF( bit_budget_fx < 0 ) @@ -824,6 +820,7 @@ void hq_lr_dec_fx( bit_budget_fx = 0; move16(); } + tcq_core_LR_dec_fx( st_fx, /*inp_vector*/ inp_vector_fx, bit_budget_fx, bands_fx, band_start, band_width, /*Rk, */ L_Rk, npulses_fx, k_sort_fx, p2a_flags_fx, p2a_bands_fx, last_bitalloc_max_band, inner_frame, adjustFlag, is_transient_fx ); @@ -961,11 +958,12 @@ static Word16 small_symbol_dec_tran_fx( * Huffman decoding of differential energies (MSB and LSB) *--------------------------------------------------------------------------*/ -static Word16 small_symbol_dec_fx( /* o : bits Q0*/ - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *qbidx, /* o : output of dequantized differential energy Q0*/ - const Word16 bands, /* i : number of bands Q0*/ - const Word16 is_transient ) +/* o : bits Q0*/ +static Word16 small_symbol_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *qbidx, /* o : output of dequantized differential energy Q0*/ + const Word16 bands, /* i : number of bands Q0*/ + const Word16 is_transient ) { Word16 i, LSB, bits; Word16 difidx[BANDS_MAX]; @@ -1022,10 +1020,11 @@ static Word16 decode_huff_8s_fx( return negate( *hufftab ); } -static Word16 large_symbol_dec_fx( /* o : bits */ - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *qbidx, /* o : output of dequantized differential energy Q0*/ - const Word16 bands /* i : number of bands Q0*/ +/* o : bits */ +static Word16 large_symbol_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *qbidx, /* o : output of dequantized differential energy Q0*/ + const Word16 bands /* i : number of bands Q0*/ ) { Word16 i, bits; diff --git a/lib_dec/igf_scf_dec_fx.c b/lib_dec/igf_scf_dec_fx.c index a8aa13e73dbb8f46754bc72183918a2cc77c489f..71a4b1e7720bd2cc0116d6710073a98b425af384 100644 --- a/lib_dec/igf_scf_dec_fx.c +++ b/lib_dec/igf_scf_dec_fx.c @@ -15,6 +15,7 @@ /**********************************************************************/ /** initialization of an instance of this module **************************************************************************/ + void IGFSCFDecoderOpen( IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i : handle to public data */ H_IGF_INFO hIgfInfo, /* i : IGF info handle */ @@ -36,11 +37,13 @@ void IGFSCFDecoderOpen( move16(); /* protect against the invalid request of starting decoding with a dependent block */ IGFCommonFuncsIGFGetCFTables_fx( total_brate, bwidth, element_mode, rf_mode, &hPublicData->cf_se00, &hPublicData->cf_se01, &hPublicData->cf_off_se01, &hPublicData->cf_se02, &hPublicData->cf_off_se02, &hPublicData->cf_se10, &hPublicData->cf_off_se10, &hPublicData->cf_se11, &hPublicData->cf_off_se11 ); + + return; } static Word16 quant_ctx_fx( - Word16 ctx /* i: the context value to be quantized */ + Word16 ctx /* i : the context value to be quantized */ ) { /* @@ -62,7 +65,7 @@ static Word16 quant_ctx_fx( static Word16 arith_decode_bits_fx( IGFSCFDEC_INSTANCE_HANDLE hPrivateData, /* i/o: instance handle */ Decoder_State *st, /* i/o: pointer to bitstream decoder state */ - Word16 nBits /* i: number of bits to decode */ + Word16 nBits /* i : number of bits to decode */ ) { Word16 i; @@ -89,8 +92,8 @@ static Word16 arith_decode_bits_fx( static Word16 arith_decode_residual_fx( IGFSCFDEC_INSTANCE_HANDLE hPrivateData, /* i/o: instance handle */ Decoder_State *st, /* i/o: pointer to decoder state */ - const UWord16 *cumulativeFrequencyTable, /* i: cumulative frequency table to be used Q0 */ - Word16 tableOffset /* i: offset used to align the table */ + const UWord16 *cumulativeFrequencyTable, /* i : cumulative frequency table to be used Q0 */ + Word16 tableOffset /* i : offset used to align the table */ ) { Word16 val; @@ -150,17 +153,18 @@ static void arith_decode_flush_fx( Decoder_State *st /* i/o: pointer to decoder state */ ) { - get_next_indice_tmp_fx( st, -14 ); /* return back the least significant 14 bits to the bitstream */ + + return; } static void decode_sfe_vector_fx( IGFSCFDEC_INSTANCE_HANDLE hPrivateData, /* i/o: instance handle */ Decoder_State *st, /* i/o: pointer to decoder state */ - Word16 t, /* i: counter reset to 0 at each independent block */ - Word16 *prev_x, /* i: previous vector */ - Word16 *x, /* o: current vector to decode */ - Word16 length /* i: number of elements to decode */ + Word16 t, /* i : counter reset to 0 at each independent block */ + Word16 *prev_x, /* i : previous vector */ + Word16 *x, /* o : current vector to decode */ + Word16 length /* i : number of elements to decode */ ) { /* @@ -180,7 +184,6 @@ static void decode_sfe_vector_fx( Word32 index1; Word32 index2; - FOR( f = 0; f < length; ++f ) { IF( t == 0 ) @@ -278,26 +281,30 @@ static void decode_sfe_vector_fx( move16(); } } + + return; } /**********************************************************************/ /** resets the internal decoder memory (context memory) **************************************************************************/ + void IGFSCFDecoderReset( IGFSCFDEC_INSTANCE_HANDLE hPublicData /* i/o: handle to public data */ ) { - - /* reset of coder */ hPublicData->t = 0; /* indicate that an independent block follows */ move16(); /* we do not need to fill hPublicData->prev with zeros, because when t = 0 no previous information is used */ + + return; } /**********************************************************************/ /** main decoder function **************************************************************************/ + void IGFSCFDecoderDecode( IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i/o: handle to public data or NULL in case there was no instance created */ Decoder_State *st, /* i/o: pointer to decoder state */ @@ -323,7 +330,6 @@ void IGFSCFDecoderDecode( arith_decode_flush_fx( st ); /* finish AC decoding */ - /* advance history */ Copy( sfe, hPublicData->prev, hPublicData->scfCountLongBlock[igfGridIdx] ); hPublicData->t = add( hPublicData->t, 1 ); @@ -331,4 +337,6 @@ void IGFSCFDecoderDecode( hPublicData->bitsRead = sub( st->next_bit_pos, hPublicData->bitsRead ); move16(); + + return; } diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index 45007974483505fb416b1075b6e00456be83df21..6f787a8bdcb2c17f0dd96778fe9733c6f8d7fb77 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -79,9 +79,6 @@ ivas_error ivas_cpe_dec_fx( Word32 cpe_brate; Word32 element_brate_ref; - error = IVAS_ERR_OK; - move32(); - push_wmops( "ivas_cpe_dec" ); ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; @@ -238,7 +235,6 @@ ivas_error ivas_cpe_dec_fx( } ELSE { - /* Note: This only works for stereo operation. If DTX would be applied for multiple CPEs a different bitrate signaling is needed */ IF( LE_32( ivas_total_brate, IVAS_SID_5k2 ) ) { stereo_dft_config_fx( hConfigDft, ivas_total_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); @@ -707,7 +703,7 @@ ivas_error ivas_cpe_dec_fx( pop_wmops(); - return error; + return IVAS_ERR_OK; } @@ -927,9 +923,6 @@ ivas_error create_cpe_dec( ivas_error error; Word32 cpe_brate; - error = IVAS_ERR_OK; - move32(); - /*-----------------------------------------------------------------* * Allocate CPE handle *-----------------------------------------------------------------*/ @@ -1261,7 +1254,7 @@ ivas_error create_cpe_dec( st_ivas->hCPE[cpe_id] = hCPE; - return error; + return IVAS_ERR_OK; } diff --git a/lib_dec/ivas_dec_render_fx.c b/lib_dec/ivas_dec_render_fx.c index 4bbc2d0fa14f5b3ecf4386aab756c99e1330e77e..8c056a23dd93614d78c9c805a6aafc8fec1c4d72 100644 --- a/lib_dec/ivas_dec_render_fx.c +++ b/lib_dec/ivas_dec_render_fx.c @@ -1340,7 +1340,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( *--------------------------------------------------------------------------*/ ivas_error ivas_jbm_dec_set_discard_samples_fx( - Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ + Decoder_Struct *st_ivas /* i/o: main IVAS decoder structure */ ) { Word16 nMaxSlotsPerSubframe, nSlotsInFirstSubframe; diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index d61e3ff4bdc9101c4923d27fc65744d464110fe9..7d25477b42aa76389d1197c65bac45ca7be3472c 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -48,8 +48,8 @@ *-----------------------------------------------------------------------*/ static ivas_error ivas_dirac_dec_config_internal_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const DIRAC_CONFIG_FLAG flag_config_inp /* i/ : Flag determining if we open or reconfigure the DirAC decoder */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const DIRAC_CONFIG_FLAG flag_config_inp /* i : Flag determining if we open or reconfigure the DirAC decoder */ ) { DIRAC_DEC_HANDLE hDirAC; @@ -125,8 +125,8 @@ static ivas_error ivas_dirac_dec_config_internal_fx( } static ivas_error ivas_dirac_rend_config_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const DIRAC_CONFIG_FLAG flag_config_inp, /* i/ : Flag determining if we open or reconfigure the DirAC decoder */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const DIRAC_CONFIG_FLAG flag_config_inp, /* i : Flag determining if we open or reconfigure the DirAC decoder */ const Word16 dec_param_estim_old ) { DIRAC_DEC_HANDLE hDirAC; @@ -967,8 +967,8 @@ static ivas_error ivas_dirac_rend_config_fx( *-------------------------------------------------------------------------*/ ivas_error ivas_dirac_dec_config_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const DIRAC_CONFIG_FLAG flag_config_inp /* i/ : Flag determining if we open or reconfigure the DirAC decoder */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const DIRAC_CONFIG_FLAG flag_config_inp /* i : Flag determining if we open or reconfigure the DirAC decoder */ ) { ivas_error error; @@ -2062,10 +2062,10 @@ void ivas_dirac_dec_set_md_map_fx( void ivas_dirac_dec_render_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const Word16 nchan_transport, /* i : number of transport channels */ - const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ - UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */ - UWord16 *nSamplesAvailableNext, /* o : number of CLDFB slots still to render */ - Word32 *output_fx[] /* o : rendered time signal Q(6-1)*/ + const UWord16 nSamplesAsked, /* i : number of samples requested */ + UWord16 *nSamplesRendered, /* o : number of samples rendered */ + UWord16 *nSamplesAvailableNext, /* o : number of samples still to render */ + Word32 *output_fx[] /* o : rendered time signal Q(6-1)*/ ) { Word16 slots_to_render, first_sf, last_sf, subframe_idx; diff --git a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c index b18a76052527644f20421b0cc1edc650b383f22f..358d5eba61d1b6e91cb8369c242a9b7eb3f59d4a 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c @@ -64,7 +64,7 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open_fx( const Word16 max_band_decorr, /* i : uppermost frequency band where decorrelation is applied */ const Word16 interp_length, /* i : length for interpolating the mixing matrices in time slots */ const Word16 num_param_bands, /* i : number of parameter bands */ - const Word16 num_param_bands_residual, /* i : number of parameter bands with a residual mixing matrix (i.e. decorrelation */ + const Word16 num_param_bands_residual, /* i : number of parameter bands with a residual mixing matrix (i.e. decorrelation) */ const Word16 nchan_in, /* i : number of input (transport) channels */ const Word16 nchan_out, /* i : number of output channels */ const Word32 *proto_matrix /* i : the prototype (upmix) matrix (only used if mode == 1) Q(15-proto_matrix_e) */ @@ -238,7 +238,7 @@ void ivas_dirac_dec_output_synthesis_cov_init_fx( const Word16 nchan_in, /* i : number of input (tranport) channels */ const Word16 nchan_out, /* i : number of output channels */ const Word16 n_param_bands, /* i : number of total parameter bands */ - const Word16 n_param_bands_res /* i : number of parameter bands with a residual mixing matrix (i.e. decorrelation */ + const Word16 n_param_bands_res /* i : number of parameter bands with a residual mixing matrix (i.e. decorrelation)*/ ) { diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 4a7cd31dc8d4b081329e736d336680806d8de796..2a295091e9790e87a56d2aa60d52407c884aa1f3 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -55,7 +55,7 @@ static AUDIO_CONFIG ivas_set_audio_config_from_sba_order( const Word16 sba_order /*-------------------------------------------------------------------* * ivas_set_audio_config_from_sba_order() * - * + * Set audio configuration from the SBA order *-------------------------------------------------------------------*/ /*! r: audio configuration */ diff --git a/lib_dec/ivas_ism_dec_fx.c b/lib_dec/ivas_ism_dec_fx.c index be53e67bd28f6491b7dd38fc75cb9d0ae6760880..8691a6546ec86f5ed28cc03ab0a9a9d3223ecb7a 100644 --- a/lib_dec/ivas_ism_dec_fx.c +++ b/lib_dec/ivas_ism_dec_fx.c @@ -57,6 +57,11 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( Word16 numCldfbAnalyses_old, numCldfbSyntheses_old, ism_mode; Word16 tc_granularity_new; Word16 nchan_out_buff; + Word16 tc_nchan_full_new; + TC_BUFFER_MODE tc_buffer_mode_new; + Word16 tc_nchan_rend_new; + Word16 tc_nchan_allocate_new; + DECODER_TC_BUFFER_HANDLE hTcBuffer; nCPE_old = st_ivas->nCPE; move16(); @@ -309,12 +314,6 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( * TC buffer *-----------------------------------------------------------------*/ - Word16 tc_nchan_full_new; - TC_BUFFER_MODE tc_buffer_mode_new; - Word16 tc_nchan_rend_new; - Word16 tc_nchan_allocate_new; - DECODER_TC_BUFFER_HANDLE hTcBuffer; - hTcBuffer = st_ivas->hTcBuffer; tc_buffer_mode_new = ivas_dec_get_tc_buffer_mode_fx( st_ivas ); tc_nchan_rend_new = ivas_dec_get_num_tc_channels_fx( st_ivas ); diff --git a/lib_dec/ivas_ism_metadata_dec_fx.c b/lib_dec/ivas_ism_metadata_dec_fx.c index e937b9dfe606c3389e295ffd22ca8efbde647b35..542e25b677df0d6d9af2819b8cfeadb1980047f9 100644 --- a/lib_dec/ivas_ism_metadata_dec_fx.c +++ b/lib_dec/ivas_ism_metadata_dec_fx.c @@ -1189,13 +1189,14 @@ void ivas_ism_metadata_sid_dec_fx( IF( !bfi ) { /*----------------------------------------------------------------* - * ISm common signaling + * ISM common signaling *----------------------------------------------------------------*/ /* number of objects was already read in ivas_ism_get_dtx_dec() */ /* update the position in the bitstream */ st0->next_bit_pos = add( st0->next_bit_pos, nchan_ism ); move16(); + /* read SID metadata flag( one per object ) */ FOR( ch = 0; ch < nchan_ism; ch++ ) { diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index ff726c989d48c70799777f1e663e0a8e97e5bf69..e7affdb36b1b742db89347e559edc957adf8ee75 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1718,9 +1718,9 @@ static void ivas_ism_param_dec_render_sf_fx( void ivas_param_ism_dec_render_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ - UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */ - UWord16 *nSamplesAvailableNext, /* o : number of CLDFB slots still to render */ + const UWord16 nSamplesAsked, /* i : number of samples requested */ + UWord16 *nSamplesRendered, /* o : number of samples rendered */ + UWord16 *nSamplesAvailableNext, /* o : number of samples still to render */ Word32 *output_fx[] /* i/o: synthesized core-coder TCs / rendered signal Q11*/ ) { diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index 140eb764de581bae399a18050ec25be7ec8da890..91f6dda9cf5ed4e55c2c491e9feef183ed22c4f0 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -1877,7 +1877,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( IF( st_ivas->hDiracDecBin[pos_idx] != NULL ) { /* regularization factor is bitrate-dependent */ - st_ivas->hDiracDecBin[pos_idx]->reqularizationFactor_fx = configure_reqularization_factor_fx( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); + st_ivas->hDiracDecBin[pos_idx]->reqularizationFactor_fx = configure_reqularization_factor_fx( st_ivas->ivas_format, ivas_total_brate ); move16(); } } @@ -1891,7 +1891,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( IF( st_ivas->hDiracDecBin[0] != NULL ) { - IF( NE_32( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin[0]->hTdDecorr ), &( st_ivas->hDiracDecBin[0]->useTdDecorr ) ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin[0]->hTdDecorr ), &( st_ivas->hDiracDecBin[0]->useTdDecorr ) ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index fcfc9f911109b5a2429f3d85b3502f0e4a51f832..b929e3a98a3a6426defabef3409181d54452414b 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -1857,9 +1857,9 @@ void ivas_param_mc_dec_prepare_renderer( void ivas_param_mc_dec_render_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ - UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */ - UWord16 *nSamplesAvailableNext, /* o : number of CLDFB slots still to render */ + const UWord16 nSamplesAsked, /* i : number of samples requested */ + UWord16 *nSamplesRendered, /* o : number of samples rendered */ + UWord16 *nSamplesAvailableNext, /* o : number of samples still to render */ Word32 *output_fx[], /* o : rendered time signal Q11*/ Word16 channel_active_fx[MAX_OUTPUT_CHANNELS] ) { @@ -2362,7 +2362,7 @@ static void param_mc_protoSignalComputation_fx( Word32 *proto_frame_f_fx, /* o : interleaved complex prototype CLDFB samples */ const PARAM_MC_DIFF_PROTO_INFO *diff_proto_info, /* i : prototype generation information */ const Word16 num_freq_bands, /* i : number of frequency bands for the prototypes */ - const Word16 Cldfb_Real_Imag_exp, /*i: Exponent of real and imag buffers */ + const Word16 Cldfb_Real_Imag_exp, /* i : Exponent of real and imag buffers */ Word16 *proto_frame_f_fx_q ) { Word16 band; diff --git a/lib_dec/ivas_mc_paramupmix_dec_fx.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c index 608644c7246dbebee4c9893f8b29e81ec5a1a889..ecd8418f13c735ce46af13c2a85dba89b540fee4 100644 --- a/lib_dec/ivas_mc_paramupmix_dec_fx.c +++ b/lib_dec/ivas_mc_paramupmix_dec_fx.c @@ -233,14 +233,14 @@ void ivas_mc_paramupmix_dec_digest_tc_fx( void ivas_mc_paramupmix_dec_render_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ - UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */ - UWord16 *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + const UWord16 nSamplesAsked, /* i : number of samples requested */ + UWord16 *nSamplesRendered, /* o : number of samples rendered */ + UWord16 *nSamplesAvailable, /* o : number of samples still to render */ Word32 *input_fx[], /* i : core-coder transport channels Qx*/ Word32 *output_fx[] /* i/o: synthesized core-coder transport channels Qx*/ ) { - Word16 slots_to_render, first_sf, last_sf, subframe_idx; + Word16 slots_to_render, first_sf, last_sf, subframe_idx, n_samples_sf; UWord16 slot_size, ch; Word32 *output_local_fx[MAX_OUTPUT_CHANNELS]; MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix; @@ -277,24 +277,21 @@ void ivas_mc_paramupmix_dec_render_fx( slots_to_render = sub( slots_to_render, st_ivas->hTcBuffer->subframe_nbslots[last_sf] ); last_sf = add( last_sf, 1 ); } + + FOR( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { + n_samples_sf = imult1616( (Word16) slot_size, st_ivas->hTcBuffer->subframe_nbslots[subframe_idx] ); + ivas_mc_paramupmix_dec_sf( st_ivas, output_local_fx ); - FOR( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) + Word16 num_ch = s_min( MAX_OUTPUT_CHANNELS, ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 ) ); + FOR( ch = 0; ch < num_ch; ch++ ) { - Word16 n_samples_sf = imult1616( (Word16) slot_size, st_ivas->hTcBuffer->subframe_nbslots[subframe_idx] ); - - ivas_mc_paramupmix_dec_sf( st_ivas, output_local_fx ); - - Word16 num_ch = s_min( MAX_OUTPUT_CHANNELS, ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 ) ); - FOR( ch = 0; ch < num_ch; ch++ ) - { - output_local_fx[ch] += n_samples_sf; - } - - /* update combined orientation access index */ - ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); + output_local_fx[ch] += n_samples_sf; } + + /* update combined orientation access index */ + ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); } *nSamplesAvailable = imult1616( sub( st_ivas->hTcBuffer->num_slots, st_ivas->hTcBuffer->slots_rendered ), (Word16) slot_size ); diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index dd889e83b3c2ab415635b729a742bcb0c5feb988..450d9e39dc3f38a49fb5c93f5317ba20bc50d529 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -1603,7 +1603,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( } } - /* transfer subframe info from central TC buffer to ParamMC or McMASA (DirAC) */ + /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */ IF( st_ivas->hSpatParamRendCom != NULL ) { st_ivas->hSpatParamRendCom->nb_subframes = hTcBuffer->nb_subframes; diff --git a/lib_dec/ivas_mono_dmx_renderer_fx.c b/lib_dec/ivas_mono_dmx_renderer_fx.c index 36d5bd48aa7446b2c8c58386c7cb4d701a9a3d58..eedd4b48dea32c929bb42ea658e87d8a2167a297 100644 --- a/lib_dec/ivas_mono_dmx_renderer_fx.c +++ b/lib_dec/ivas_mono_dmx_renderer_fx.c @@ -82,7 +82,7 @@ ivas_error ivas_mono_dmx_renderer_open( *-------------------------------------------------------------------------*/ void ivas_mono_dmx_renderer_close( - MONO_DOWNMIX_RENDERER_HANDLE *hMonoDmxRenderer /* i/ i/o: Mono downmix structure */ + MONO_DOWNMIX_RENDERER_HANDLE *hMonoDmxRenderer /* i/o: Mono downmix structure */ ) { test(); diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index d13e17c1f33d50104cdd949c4964b90a3672b638..3e7664bd7fb7b649a0cb5970185e949ea55229c2 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -1193,10 +1193,9 @@ ivas_error ivas_omasa_dirac_td_binaural_fx( } /* Delay the object signals to match the CLDFB delay. Delay the whole buffer with the first rendering call of the stretched buffer. */ - ivas_dirac_dec_binaural_render_fx( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailable, nchan_transport, output_fx ); - /* reset combined orientation access index before calling the td renderer */ + /* update combined orientation access index before calling the td renderer */ ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) diff --git a/lib_dec/ivas_osba_dec_fx.c b/lib_dec/ivas_osba_dec_fx.c index c2a9d6bbfc0f09e43550639a25226cb5428bdcc4..2359d9e2aa5c6227344bc8ededde8f6e6300dc73 100644 --- a/lib_dec/ivas_osba_dec_fx.c +++ b/lib_dec/ivas_osba_dec_fx.c @@ -125,10 +125,10 @@ void ivas_osba_data_close_fx( *--------------------------------------------------------------------------*/ ivas_error ivas_osba_dirac_td_binaural_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ - UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */ - UWord16 *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const UWord16 nSamplesAsked, /* i : number of samples requested */ + UWord16 *nSamplesRendered, /* o : number of samples rendered */ + UWord16 *nSamplesAvailable, /* o : number of samples still to render */ Word32 *output_fx[] /* o : rendered time signal Q11*/ ) { @@ -157,7 +157,9 @@ ivas_error ivas_osba_dirac_td_binaural_fx( return error; } + /* update combined orientation access index */ ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); + IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { Word16 slot_idx, num_cldfb_bands, nchan_transport_orig; diff --git a/lib_dec/ivas_rom_dec.h b/lib_dec/ivas_rom_dec.h index 04613f1a541c1d04490915680f1e5935a5ba0451..aafe3bce983565f66d416a2ad2e9fc450951eca2 100644 --- a/lib_dec/ivas_rom_dec.h +++ b/lib_dec/ivas_rom_dec.h @@ -98,4 +98,4 @@ extern const HUFF_NODE_TABLE ivas_mc_paramupmix_huff_nodes_df0; extern const HUFF_NODE_TABLE ivas_mc_paramupmix_huff_nodes_df; extern const HUFF_NODE_TABLE ivas_mc_paramupmix_huff_nodes_dt; -#endif +#endif /* IVAS_ROM_DEC_H */ diff --git a/lib_dec/ivas_sba_dec_fx.c b/lib_dec/ivas_sba_dec_fx.c index 789c0e954b36e8f0c2fecc64cdd3af5192fc8bbf..24dcdce224f29f4e7c618a70c6c9a57113d23842 100644 --- a/lib_dec/ivas_sba_dec_fx.c +++ b/lib_dec/ivas_sba_dec_fx.c @@ -113,6 +113,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( { Word16 nchan_transport_old, nSCE_old, nCPE_old, nchan_hp20_old; AUDIO_CONFIG intern_config_old; + Word16 sba_order_internal; Word16 numCldfbAnalyses_old, numCldfbSyntheses_old; Word16 sba_dirac_stereo_flag_old; Word32 ivas_total_brate; @@ -123,7 +124,14 @@ ivas_error ivas_sba_dec_reconfigure_fx( ivas_error error; ISM_MODE ism_mode_old; Word16 granularity_new; + DECODER_TC_BUFFER_HANDLE hTcBuffer; + SPAR_DEC_HANDLE hSpar; Word16 nchan_transport; + DIRAC_CONFIG_FLAG flag_config; + Word16 band_grouping[IVAS_MAX_NUM_BANDS + 1]; + + hTcBuffer = st_ivas->hTcBuffer; + hSpar = st_ivas->hSpar; ism_mode_old = st_ivas->ism_mode; hDecoderConfig = st_ivas->hDecoderConfig; @@ -170,7 +178,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->sba_order ); - granularity_new = st_ivas->hTcBuffer->n_samples_granularity; /*Q0*/ + granularity_new = hTcBuffer->n_samples_granularity; /*Q0*/ move16(); /* we may need to flush only for binaural and OSBA and TSM */ @@ -183,11 +191,11 @@ ivas_error ivas_sba_dec_reconfigure_fx( granularity_new = ivas_dec_get_render_granularity_fx( st_ivas->renderer_type, ivas_renderer_secondary_select_fx( st_ivas ), st_ivas->hDecoderConfig->output_Fs ); /* flush renderer on granularity change form 5ms to 1.25ms, again only possible for binaural rendering */ - IF( LT_16( granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) + IF( LT_16( granularity_new, hTcBuffer->n_samples_granularity ) ) { /* flush already done in IVAS_DEC_ReadFormat() */ } - ELSE IF( GT_16( granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) + ELSE IF( GT_16( granularity_new, hTcBuffer->n_samples_granularity ) ) { if ( NE_32( ( error = ivas_jbm_dec_set_discard_samples_fx( st_ivas ) ), IVAS_ERR_OK ) ) { @@ -197,41 +205,41 @@ ivas_error ivas_sba_dec_reconfigure_fx( /* make sure the changed number of slots in the last subframe is not lost in the following steps */ IF( st_ivas->hSpatParamRendCom != NULL ) { - st_ivas->hSpatParamRendCom->subframe_nbslots[st_ivas->hSpatParamRendCom->nb_subframes - 1] = st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1]; /*Q0*/ + st_ivas->hSpatParamRendCom->subframe_nbslots[st_ivas->hSpatParamRendCom->nb_subframes - 1] = hTcBuffer->subframe_nbslots[hTcBuffer->nb_subframes - 1]; /*Q0*/ move32(); } - st_ivas->hSpar->subframe_nbslots[st_ivas->hSpar->nb_subframes - 1] = st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1]; /*Q0*/ + hSpar->subframe_nbslots[hSpar->nb_subframes - 1] = hTcBuffer->subframe_nbslots[hTcBuffer->nb_subframes - 1]; /*Q0*/ move32(); } } /* save old */ - IF( NE_16( ism_mode_old, ISM_SBA_MODE_DISC ) && NE_16( st_ivas->hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_BUFFER ) ) + IF( NE_16( ism_mode_old, ISM_SBA_MODE_DISC ) && NE_16( hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_BUFFER ) ) { test(); - IF( st_ivas->hDirAC == NULL && st_ivas->hSpar != NULL ) + IF( st_ivas->hDirAC == NULL && hSpar != NULL ) { - st_ivas->hTcBuffer->num_slots = st_ivas->hSpar->num_slots; + hTcBuffer->num_slots = hSpar->num_slots; move16(); - st_ivas->hTcBuffer->nb_subframes = st_ivas->hSpar->nb_subframes; + hTcBuffer->nb_subframes = hSpar->nb_subframes; move16(); - st_ivas->hTcBuffer->slots_rendered = st_ivas->hSpar->slots_rendered; + hTcBuffer->slots_rendered = hSpar->slots_rendered; move16(); - st_ivas->hTcBuffer->subframes_rendered = st_ivas->hSpar->subframes_rendered; + hTcBuffer->subframes_rendered = hSpar->subframes_rendered; move16(); - Copy( st_ivas->hSpar->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); /*Q0*/ + Copy( hSpar->subframe_nbslots, hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); /*Q0*/ } ELSE IF( st_ivas->hSpatParamRendCom != NULL ) { - st_ivas->hTcBuffer->num_slots = st_ivas->hSpatParamRendCom->num_slots; + hTcBuffer->num_slots = st_ivas->hSpatParamRendCom->num_slots; move16(); - st_ivas->hTcBuffer->nb_subframes = st_ivas->hSpatParamRendCom->nb_subframes; + hTcBuffer->nb_subframes = st_ivas->hSpatParamRendCom->nb_subframes; move16(); - st_ivas->hTcBuffer->slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered; + hTcBuffer->slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered; move16(); - st_ivas->hTcBuffer->subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered; + hTcBuffer->subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered; move16(); - Copy( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); /*Q0*/ + Copy( st_ivas->hSpatParamRendCom->subframe_nbslots, hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); /*Q0*/ } } @@ -239,10 +247,6 @@ ivas_error ivas_sba_dec_reconfigure_fx( * Allocate, initialize, and configure SBA handles *-----------------------------------------------------------------*/ - Word16 sba_order_internal; - SPAR_DEC_HANDLE hSpar; - hSpar = st_ivas->hSpar; - sba_order_internal = s_min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); /*Q0*/ IF( hSpar != NULL ) @@ -251,7 +255,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( test(); IF( ( hSpar->hPCA != NULL ) && ( NE_32( hDecoderConfig->ivas_total_brate, PCA_BRATE ) || NE_16( st_ivas->sba_order, 1 ) ) ) { - free( st_ivas->hSpar->hPCA ); + free( hSpar->hPCA ); hSpar->hPCA = NULL; } @@ -262,7 +266,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( test(); IF( NE_16( nchan_transport_old, ivas_get_sba_num_TCs_fx( ivas_total_brate, sba_order_internal ) ) || ( GE_32( last_ivas_total_brate, IVAS_512k ) && LT_32( ivas_total_brate, IVAS_512k ) ) || ( LT_32( last_ivas_total_brate, IVAS_512k ) && GE_32( ivas_total_brate, IVAS_512k ) ) ) { - ivas_spar_dec_close_fx( &( st_ivas->hSpar ), hDecoderConfig->output_Fs, 1 ); + ivas_spar_dec_close_fx( &( hSpar ), hDecoderConfig->output_Fs, 1 ); if ( NE_32( ( error = ivas_spar_dec_open_fx( st_ivas, 1 ) ), IVAS_ERR_OK ) ) { @@ -271,12 +275,12 @@ ivas_error ivas_sba_dec_reconfigure_fx( } ELSE IF( LT_32( last_ivas_total_brate, IVAS_24k4 ) && GE_32( ivas_total_brate, IVAS_24k4 ) ) { - num_channels = st_ivas->hSpar->hMdDec->spar_md_cfg.num_umx_chs; /*Q0*/ + num_channels = hSpar->hMdDec->spar_md_cfg.num_umx_chs; /*Q0*/ move16(); - ivas_spar_md_dec_matrix_close_fx( st_ivas->hSpar->hMdDec, num_channels ); + ivas_spar_md_dec_matrix_close_fx( hSpar->hMdDec, num_channels ); num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order_internal, ivas_total_brate, st_ivas->last_active_ivas_total_brate ); - if ( NE_32( ( error = ivas_spar_md_dec_matrix_open_fx( st_ivas->hSpar->hMdDec, num_channels, num_md_sub_frames ) ), IVAS_ERR_OK ) ) + if ( NE_32( ( error = ivas_spar_md_dec_matrix_open_fx( hSpar->hMdDec, num_channels, num_md_sub_frames ) ), IVAS_ERR_OK ) ) { return error; } @@ -306,7 +310,6 @@ ivas_error ivas_sba_dec_reconfigure_fx( } } - hSpar = st_ivas->hSpar; st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); move16(); @@ -377,8 +380,6 @@ ivas_error ivas_sba_dec_reconfigure_fx( IF( ( ( NE_16( st_ivas->renderer_type, RENDERER_DISABLE ) ) && ( NE_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_DEC ) ) ) || ( ( NE_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) ) && ( NE_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) ) && ( NE_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) ) ) ) { - DIRAC_CONFIG_FLAG flag_config; - flag_config = DIRAC_OPEN; if ( st_ivas->hDirAC != NULL ) { @@ -392,13 +393,11 @@ ivas_error ivas_sba_dec_reconfigure_fx( } ELSE { - Word16 band_grouping[IVAS_MAX_NUM_BANDS + 1]; - - st_ivas->hSpar->enc_param_start_band = s_min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); /*Q0*/ + hSpar->enc_param_start_band = s_min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); /*Q0*/ move16(); IF( ivas_get_hodirac_flag_fx( ivas_total_brate, st_ivas->sba_analysis_order ) ) { - st_ivas->hSpar->enc_param_start_band = 0; + hSpar->enc_param_start_band = 0; move16(); set_c( (Word8 *) st_ivas->hQMetaData->twoDirBands, (Word8) 1, st_ivas->hQMetaData->q_direction[0].cfg.nbands ); /*Q0*/ @@ -407,11 +406,11 @@ ivas_error ivas_sba_dec_reconfigure_fx( } ivas_dirac_config_bands_fx( band_grouping, IVAS_MAX_NUM_BANDS, (Word16) ( L_add( st_ivas->hDecoderConfig->output_Fs, 400 ) / CLDFB_BANDWIDTH ), - st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0, 1 ); + hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, hSpar->enc_param_start_band, 0, 1 ); if ( st_ivas->hDirAC ) { - st_ivas->hDirAC->hConfig->enc_param_start_band = st_ivas->hSpar->enc_param_start_band; + st_ivas->hDirAC->hConfig->enc_param_start_band = hSpar->enc_param_start_band; move16(); } } @@ -426,7 +425,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( if ( st_ivas->hDirAC != NULL ) { - st_ivas->hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band; + hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band; move16(); } @@ -650,7 +649,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( test(); test(); test(); - IF( NE_16( tc_nchan_tc, st_ivas->hTcBuffer->nchan_transport_rend ) || NE_16( tc_nchan_to_allocate, st_ivas->hTcBuffer->nchan_transport_internal ) || NE_16( tc_buffer_mode, st_ivas->hTcBuffer->tc_buffer_mode ) || NE_16( granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) + IF( NE_16( tc_nchan_tc, hTcBuffer->nchan_transport_rend ) || NE_16( tc_nchan_to_allocate, hTcBuffer->nchan_transport_internal ) || NE_16( tc_buffer_mode, hTcBuffer->tc_buffer_mode ) || NE_16( granularity_new, hTcBuffer->n_samples_granularity ) ) { if ( NE_32( ( error = ivas_dec_tc_buffer_reconfigure_fx( st_ivas, tc_buffer_mode, tc_nchan_tc, tc_nchan_to_allocate, tc_nchan_to_allocate, granularity_new ) ), IVAS_ERR_OK ) ) { @@ -661,31 +660,31 @@ ivas_error ivas_sba_dec_reconfigure_fx( /* resync SPAR and DirAC info from TC Buffer */ test(); - IF( st_ivas->hSpatParamRendCom != NULL && EQ_16( st_ivas->hSpatParamRendCom->slot_size, st_ivas->hTcBuffer->n_samples_granularity ) ) + IF( st_ivas->hSpatParamRendCom != NULL && EQ_16( st_ivas->hSpatParamRendCom->slot_size, hTcBuffer->n_samples_granularity ) ) { - Copy( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); /*Q0*/ - st_ivas->hSpatParamRendCom->nb_subframes = st_ivas->hTcBuffer->nb_subframes; + Copy( hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); /*Q0*/ + st_ivas->hSpatParamRendCom->nb_subframes = hTcBuffer->nb_subframes; move16(); - st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; + st_ivas->hSpatParamRendCom->subframes_rendered = hTcBuffer->subframes_rendered; move16(); } - Copy( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpar->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); /*Q0*/ - st_ivas->hSpar->nb_subframes = st_ivas->hTcBuffer->nb_subframes; + Copy( hTcBuffer->subframe_nbslots, hSpar->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); /*Q0*/ + hSpar->nb_subframes = hTcBuffer->nb_subframes; move16(); - st_ivas->hSpar->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; + hSpar->subframes_rendered = hTcBuffer->subframes_rendered; move16(); test(); test(); IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) && EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { - Word16 granularityMultiplier = idiv1616( st_ivas->hTcBuffer->n_samples_granularity, st_ivas->hSpatParamRendCom->slot_size ); /*Q0*/ + Word16 granularityMultiplier = idiv1616( hTcBuffer->n_samples_granularity, st_ivas->hSpatParamRendCom->slot_size ); /*Q0*/ Word16 n; FOR( n = 0; n < MAX_JBM_SUBFRAMES_5MS; n++ ) { - st_ivas->hSpatParamRendCom->subframe_nbslots[n] = i_mult( st_ivas->hTcBuffer->subframe_nbslots[n], granularityMultiplier ); /*Q0*/ + st_ivas->hSpatParamRendCom->subframe_nbslots[n] = i_mult( hTcBuffer->subframe_nbslots[n], granularityMultiplier ); /*Q0*/ move16(); - st_ivas->hSpar->subframe_nbslots[n] = st_ivas->hSpatParamRendCom->subframe_nbslots[n]; + hSpar->subframe_nbslots[n] = st_ivas->hSpatParamRendCom->subframe_nbslots[n]; move16(); } } @@ -695,7 +694,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( *-----------------------------------------------------------------*/ nchan_out_buff = ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); /*Q0*/ - IF( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff, hDecoderConfig->Opt_tsm, st_ivas->hTcBuffer ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff, hDecoderConfig->Opt_tsm, hTcBuffer ) ) != IVAS_ERR_OK ) { return error; } @@ -815,9 +814,9 @@ void ivas_sba_dec_digest_tc_fx( ivas_error ivas_sba_dec_render_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested Q0*/ - UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered Q0*/ - UWord16 *nSamplesAvailableNext, /* o : number of CLDFB slots still to render Q0*/ + const UWord16 nSamplesAsked, /* i : number of samples requested Q0*/ + UWord16 *nSamplesRendered, /* o : number of samples rendered Q0*/ + UWord16 *nSamplesAvailableNext, /* o : number of samples still to render Q0*/ Word32 *output_fx[] /* o : rendered time signal Q11*/ ) { diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c index eebed32c85a15a4ea861b6269d81d64bb0b93f97..a07f5b50853f2387c084a263339e17a280abb578 100644 --- a/lib_dec/ivas_sce_dec_fx.c +++ b/lib_dec/ivas_sce_dec_fx.c @@ -56,12 +56,9 @@ ivas_error ivas_sce_dec_fx( Word32 outputHB[1][L_FRAME48k]; /*Word32 buffer for output HB synthesis, one channel */ SCE_DEC_HANDLE hSCE; Decoder_State *st; - Word32 ivas_total_brate, last_ivas_total_brate; + Word32 ivas_total_brate; ivas_error error; - error = IVAS_ERR_OK; - move32(); - push_wmops( "ivas_sce_dec" ); hSCE = st_ivas->hSCE[sce_id]; @@ -72,8 +69,6 @@ ivas_error ivas_sce_dec_fx( ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; /*Q0*/ move32(); - last_ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate; /*Q0*/ - move32(); IF( EQ_16( (Word16) st_ivas->ivas_format, ISM_FORMAT ) ) { @@ -109,7 +104,7 @@ ivas_error ivas_sce_dec_fx( st->total_brate = FRAME_NO_DATA; move32(); } - ELSE IF( !st_ivas->bfi && NE_16( (Word16) st_ivas->ivas_format, ISM_FORMAT ) && LE_32( last_ivas_total_brate, IVAS_SID_5k2 ) ) + ELSE IF( !st_ivas->bfi && NE_16( (Word16) st_ivas->ivas_format, ISM_FORMAT ) && LE_32( st_ivas->hDecoderConfig->last_ivas_total_brate, IVAS_SID_5k2 ) ) { st->total_brate = L_sub( hSCE->element_brate, L_mult0( nb_bits_metadata, FRAMES_PER_SEC ) ); /*Q0*/ move32(); @@ -313,7 +308,7 @@ ivas_error ivas_sce_dec_fx( move32(); /*----------------------------------------------------------------* - * LB synthesis synchronization between IVAS formats + * LB synthesis synchronization between coding tools *----------------------------------------------------------------*/ delay_signal32_fx( output[0], output_frame, st->prev_synth_buffer32_fx, NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ) ); @@ -341,9 +336,8 @@ ivas_error ivas_sce_dec_fx( st_ivas->BER_detect = s_or( st_ivas->BER_detect, st->BER_detect ); /*Q0*/ move16(); - pop_wmops(); - return error; + return IVAS_ERR_OK; } @@ -364,8 +358,6 @@ ivas_error create_sce_dec( ivas_error error; Word16 output_frame; - error = IVAS_ERR_OK; - move16(); output_frame = extract_l( Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, INV_FRAME_PER_SEC_Q15 ) ); /*Q0*/ /*-----------------------------------------------------------------* @@ -481,7 +473,7 @@ ivas_error create_sce_dec( hSCE->hCoreCoder[0] = st; st_ivas->hSCE[sce_id] = hSCE; - return error; + return IVAS_ERR_OK; } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 1f406c3380e16b4b8e0dd1d9e9937bfc629abd33..a3e0390227acba3bcd975b452a4a0e620c92ede2 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1106,6 +1106,7 @@ typedef struct Decoder_Struct Word16 codec_mode; /* Mode 1 or 2 */ Word16 ini_frame; /* initialization frames counter */ Word16 ini_active_frame; /* initialization active frames counter */ + Word32 last_active_ivas_total_brate; Word16 bfi; /* FEC - bad frame indicator */ Word16 BER_detect; /* BER detect flag */ @@ -1116,8 +1117,6 @@ typedef struct Decoder_Struct Word32 **mem_hp20_out_fx; /* output signals HP filter memories */ IVAS_LIMITER_HANDLE hLimiter; /* Limiter handle */ - Word32 *p_output_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; /* Word32-output audio buffers */ - /* core-decoder modules */ Word16 nSCE; /* number of total SCEs */ Word16 nCPE; /* number of total CPEs */ @@ -1146,6 +1145,7 @@ typedef struct Decoder_Struct Word16 sba_planar; /* Ambisonic (SBA) planar flag */ Word16 sba_analysis_order; /* Ambisonic (SBA) order used for analysis and coding */ Word16 sba_dirac_stereo_flag; /* flag indicating stereo output for SBA DirAC modes with 1 TC */ + Word16 flag_omasa_brate; /* OMASA bitrate adjustment flag */ /* rendering modules */ RENDERER_TYPE renderer_type; /* renderer type */ @@ -1180,15 +1180,13 @@ typedef struct Decoder_Struct IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pAcousticEnvironments; /* Acoustic environment array */ Word16 acousticEnvironmentsCount; /* Number of acoustic environments in the array*/ - Word16 flag_omasa_brate; - ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; /* ISAR split binaural rendering handle */ BINAURAL_TD_OBJECT_RENDERER_HANDLE hTdRendHandles[MAX_HEAD_ROT_POSES - 1]; /* TD object renderer handles */ + Word32 *p_output_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; /* Word32-output audio buffers */ DECODER_TC_BUFFER_HANDLE hTcBuffer; /* transport channels (TC) structure */ JBM_METADATA_HANDLE hJbmMetadata; /* Structure for metadata buffering in JBM */ - Word32 last_active_ivas_total_brate; Word16 ism_extmeta_active; /* Extended metadata active in decoder */ Word16 ism_extmeta_cnt; /* Change frame counter for extended metadata */ diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index d89bd37c28613a70e06089f7d33ad7c0061cd3f9..c42dd0a093274c587f87fa3422d723fa356379b0 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -158,7 +158,7 @@ ivas_error IVAS_DEC_GetSamplesDecoder( /*! r: decoder error code */ ivas_error IVAS_DEC_GetSamplesRenderer( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const Word16 nSamplesAsked, /* i : number of samples wanted by the caller */ + const Word16 nSamplesAsked, /* i : number of samples requested */ Word16 *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels Q0 */ Word16 *nOutSamples, /* o : number of samples per channel written to output buffer */ bool *needNewFrame /* o : indication that the decoder needs a new frame */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 84cdc1b6a0a917b842c53a54474bfca329f1a066..732d3000bb36ba995ade156166c3309e640e3c92 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1379,10 +1379,10 @@ static ivas_error isar_generate_metadata_and_bitstream( ivas_error IVAS_DEC_GetSamplesRenderer( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const Word16 nSamplesAsked, /* i : number of samples wanted by the caller */ + const Word16 nSamplesAsked, /* i : number of samples requested */ Word16 *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels Q0 */ Word16 *nOutSamples, /* o : number of samples per channel written to output buffer */ - bool *needNewFrame /* o :indication that the decoder needs a new frame */ + bool *needNewFrame /* o : indication that the decoder needs a new frame */ ) { ivas_error error; diff --git a/lib_dec/pit_dec_fx.c b/lib_dec/pit_dec_fx.c index dc3e6277d09bbf8cbd05a263b8610fb8faa3f0ad..98dfc5d202001b776c61f6383d7dfbced4d19556 100644 --- a/lib_dec/pit_dec_fx.c +++ b/lib_dec/pit_dec_fx.c @@ -16,24 +16,25 @@ * Decode pitch lag *----------------------------------------------------------*/ -Word32 Mode2_pit_decode( /* o: pitch value Q16 */ - const Word16 coder_type, /* i: coding model */ - Word16 i_subfr, /* i: subframe index */ - Word16 L_subfr, - Word16 **pt_indice, /* i/o: quantization indices pointer */ - Word16 *T0, /* i/o: close loop integer pitch Q0 */ - Word16 *T0_frac, /* o: close loop fractional part of the pitch Q0 */ - Word16 *T0_res, /* i/o: pitch resolution Q0 */ - Word16 *T0_min, /* i/o: lower limit for close-loop search Q0 */ - Word16 *T0_min_frac, /* i/o: lower limit for close-loop search Q0 */ - Word16 *T0_max, /* i/o: higher limit for close-loop search Q0 */ - Word16 *T0_max_frac, /* i/o: higher limit for close-loop search Q0 */ - Word16 pit_min, - Word16 pit_fr1, - Word16 pit_fr1b, - Word16 pit_fr2, - Word16 pit_max, - Word16 pit_res_max ) +/* o: pitch value Q16 */ +Word32 Mode2_pit_decode( + const Word16 coder_type, /* i : coding model */ + Word16 i_subfr, /* i : subframe index */ + Word16 L_subfr, + Word16 **pt_indice, /* i/o: quantization indices pointer */ + Word16 *T0, /* i/o: close loop integer pitch Q0 */ + Word16 *T0_frac, /* o : close loop fractional part of the pitch Q0 */ + Word16 *T0_res, /* i/o: pitch resolution Q0 */ + Word16 *T0_min, /* i/o: lower limit for close-loop search Q0 */ + Word16 *T0_min_frac, /* i/o: lower limit for close-loop search Q0 */ + Word16 *T0_max, /* i/o: higher limit for close-loop search Q0 */ + Word16 *T0_max_frac, /* i/o: higher limit for close-loop search Q0 */ + Word16 pit_min, + Word16 pit_fr1, + Word16 pit_fr1b, + Word16 pit_fr2, + Word16 pit_max, + Word16 pit_res_max ) { Word32 pitch; @@ -249,11 +250,11 @@ void Mode2_abs_pit_dec( * Decode delta pitch *---------------------------------------------------------------------*/ void Mode2_delta_pit_dec( - Word16 *T0, /* o: integer pitch lag Q0 */ - Word16 *T0_frac, /* o: pitch fraction Q0 */ - Word16 T0_res, /* i: pitch resolution Q0 */ + Word16 *T0, /* o : integer pitch lag Q0 */ + Word16 *T0_frac, /* o : pitch fraction Q0 */ + Word16 T0_res, /* i : pitch resolution Q0 */ Word16 *T0_min, /* i/o: delta search min Q0 */ - Word16 *T0_min_frac, /* i: delta search min Q0 */ + Word16 *T0_min_frac, /* i : delta search min Q0 */ Word16 **pt_indice /* i/o: pointer to Vector of Q indexes */ ) { @@ -780,6 +781,7 @@ void pit16k_Q_dec_fx( return; } + /*----------------------------------------------------------* * abs_pit_dec_fx() * @@ -787,11 +789,11 @@ void pit16k_Q_dec_fx( *----------------------------------------------------------*/ void abs_pit_dec_fx( - const Word16 fr_steps, /* i: fractional resolution steps (0, 2, 4) */ - Word16 pitch_index, /* i: pitch index */ - const Word16 limit_flag, /* i : restrained(0) or extended(1) limits */ - Word16 *T0, /* o: integer pitch lag */ - Word16 *T0_frac /* o: pitch fraction */ + const Word16 fr_steps, /* i : fractional resolution steps (0, 2, 4) */ + Word16 pitch_index, /* i : pitch index */ + const Word16 limit_flag, /* i : restrained(0) or extended(1) limits */ + Word16 *T0, /* o : integer pitch lag */ + Word16 *T0_frac /* o : pitch fraction */ ) { Word16 temp; @@ -979,7 +981,6 @@ void delta_pit_dec_fx( const Word16 T0_min /* i : delta search min */ ) { - Word16 temp; IF( fr_steps == 0 ) { diff --git a/lib_dec/pitch_extr_fx.c b/lib_dec/pitch_extr_fx.c index d6608cb33fc8a69d59f6f606156dae6f31c49443..bddaac82bdb6f3230c176188406becf5a31ba6df 100644 --- a/lib_dec/pitch_extr_fx.c +++ b/lib_dec/pitch_extr_fx.c @@ -2,7 +2,6 @@ EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ - #include #include #include "options.h" @@ -10,39 +9,24 @@ #include "prot_fx.h" #include "basop_util.h" -/*-------------------------------------------------------------------* - * - num x 32768 - * ------------------- Q15 - * PIT_MAX x Fact - *-------------------------------------------------------------------*/ /*-----------------------------------------------------------------* * Pitch prediction for frame erasure using linear fitting * *-----------------------------------------------------------------*/ -/*port is up to date with trunk 38840*/ + void pitch_pred_linear_fit( - const Word16 /*short*/ bfi_cnt, - /* i: bfi counter */ /*Q0 */ - const Word16 /*short*/ last_good, - /* i: last classification type */ /*Q0 */ - Word32 /*Word32*/ *old_pitch_buf, - /* i: pitch lag buffer */ /*Q16*/ - Word32 /*Word32*/ *old_fpitch, - /* i: */ /*Q16*/ - Word32 /*Word32*/ *T0_out, - /* o: estimated close loop pitch */ /*Q16*/ - Word16 /* int*/ pit_min, - /* i: Minimum pitch lag */ /*Q0 */ - Word16 /* int*/ pit_max, - /* i: Maximum pitch lag */ /*Q0 */ - Word16 /*Word16*/ *mem_pitch_gain, - /* i: pitch gain [0] is the most recent subfr gain */ /*Q14*/ + const Word16 /*short*/ bfi_cnt, /* i : bfi counter Q0 */ + const Word16 /*short*/ last_good, /* i : last classification type Q0 */ + Word32 /*Word32*/ *old_pitch_buf, /* i : pitch lag buffer Q16*/ + Word32 /*Word32*/ *old_fpitch, /* i : Q16*/ + Word32 /*Word32*/ *T0_out, /* o : estimated close loop pitch Q16*/ + Word16 /* int*/ pit_min, /* i : Minimum pitch lag Q0 */ + Word16 /* int*/ pit_max, /* i : Maximum pitch lag Q0 */ + Word16 /*Word16*/ *mem_pitch_gain, /* i : pitch gain [0] is the most recent subfr gain Q14*/ Word16 /* int*/ limitation, - Word16 /*short*/ plc_use_future_lag, - /* i: */ /*Q0 */ - Word16 /*short*/ *extrapolationFailed, - /* o: flag if extrap decides not to change the pitch */ /*Q0 */ - Word16 nb_subfr /* i: number of ACELP subframes*/ + Word16 /*short*/ plc_use_future_lag, /* i : Q0 */ + Word16 /*short*/ *extrapolationFailed, /* o : flag if extrap decides not to change the pitch Q0 */ + Word16 nb_subfr /* i : number of ACELP subframes*/ ) { Word32 pit, a, b, pita, pitb; @@ -64,7 +48,6 @@ void pitch_pred_linear_fit( Word16 a_e, b_e, sum0_q; Word32 mem_lag[2 * NB_SUBFR16k + 2]; - /* Inverse the order the pitch lag memory */ IF( EQ_16( nb_subfr, 4 ) ) { @@ -313,15 +296,12 @@ void pitch_pred_linear_fit( return; } -/* up to date with rev 8158*/ + void get_subframe_pitch( - Word16 nSubframes, - /* i: number of subframes */ /* Q0 */ - Word32 pitchStart, - /* i: starting pitch lag (in subframe -1) */ /*15Q16*/ - Word32 pitchEnd, - /* i: ending pitch lag (in subframe nSubframes-1) */ /*15Q16*/ - Word32 *pitchBuf /* o: interpolated pitch lag per subframe */ /*15Q16*/ + Word16 nSubframes, /* i : number of subframes Q0 */ + Word32 pitchStart, /* i : starting pitch lag (in subframe -1) 15Q16*/ + Word32 pitchEnd, /* i : ending pitch lag (in subframe nSubframes-1) 15Q16*/ + Word32 *pitchBuf /* o : interpolated pitch lag per subframe 15Q16*/ ) { Word16 i, s; @@ -339,4 +319,6 @@ void get_subframe_pitch( pitchBuf[i] = L_add( pitchBuf[i - 1], pitchDelta ); move32(); } + + return; } diff --git a/lib_dec/pvq_decode_fx.c b/lib_dec/pvq_decode_fx.c index cf815e4e974729bed273748767bc954adc84103d..30fb67c356341fe87bd84ae6fe58934541f6b4e4 100644 --- a/lib_dec/pvq_decode_fx.c +++ b/lib_dec/pvq_decode_fx.c @@ -8,7 +8,7 @@ #include "rom_com.h" /*-------------------------------------------------------------------* - * Function pvq_decode_fx() * + * Function pvq_decode_fx() * * * * PVQ subvector decoding algorithm * *-------------------------------------------------------------------*/ @@ -16,11 +16,11 @@ void pvq_decode_fx( Decoder_State *st_fx, PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - Word16 *xq, /* o: decoded vector (Q15) */ - Word16 *y, /* o: decoded vector (non-scaled int) */ - const Word16 k_val, /* i: number of allocated pulses */ - const Word16 dim, /* i: Length of vector */ - const Word16 neg_gain /* i: Gain (negated to fit 1.0 in Q15 as -1.0) */ + Word16 *xq, /* o : decoded vector (Q15) */ + Word16 *y, /* o : decoded vector (non-scaled int) */ + const Word16 k_val, /* i : number of allocated pulses */ + const Word16 dim, /* i : Length of vector */ + const Word16 neg_gain /* i : Gain (negated to fit 1.0 in Q15 as -1.0) */ ) { Word16 i; @@ -36,7 +36,6 @@ void pvq_decode_fx( entry = get_size_mpvq_calc_offset_fx( dim, k_val, h_mem ); /* get size & prepare H(adaptive table for entry.size=N_MPVQ(dim,k_val) */ - IF( NE_16( dim, 1 ) ) { entry.lead_sign_ind = (Word16) rc_dec_bits_fx( st_fx, hPVQ, 1 ); @@ -105,6 +104,5 @@ void pvq_decode_fx( } } - return; } diff --git a/lib_dec/swb_bwe_dec_hr_fx.c b/lib_dec/swb_bwe_dec_hr_fx.c index 813a26ea6aa28f4b5493fa3eae45d16421eafcb7..ed4fcbbccef5bf80ab1f7221f538c4c39d373e54 100644 --- a/lib_dec/swb_bwe_dec_hr_fx.c +++ b/lib_dec/swb_bwe_dec_hr_fx.c @@ -11,6 +11,8 @@ #define Q_GUARD 1 #define Q_32_BITS 14 /* scaling of 't_audio32' */ #define MAKE_PSEUDO_FLT( v, e ) ( ( ( (Word32) ( v ) ) << 16 ) + ( e ) ) + + /*-----------------------------------------------------------* * Gain_Dequant_HR() * @@ -25,11 +27,12 @@ two functions would be less efficient (Performance Wise) since the function here doesn't use 'Log2_norm_lc' at all versus gain_dequant_fx() which does. */ -static Word16 Gain_Dequant_HR( /* o: decoded gain (Q13) */ - Word16 index, /* i: quantization index */ - const Word16 min, /* i: value of lower limit (Q13) */ - const Word16 bits, /* i: number of bits to dequantize */ - Word16 *exp /* o: exponent of Decoded Gain */ +/* o: decoded gain (Q13) */ +static Word16 Gain_Dequant_HR( + Word16 index, /* i : quantization index */ + const Word16 min, /* i : value of lower limit (Q13) */ + const Word16 bits, /* i : number of bits to dequantize */ + Word16 *exp /* o : exponent of Decoded Gain */ ) { Word32 L_mini, L_fact; @@ -120,11 +123,12 @@ static Word16 Gain_Dequant_HR( /* o: decoded gain (Q13) * post processing in time domain for td/fd switching *-------------------------------------------------------------------*/ -static Word16 TD_Postprocess( /* o : gain in Q15 */ - Word16 hb_synth_fx[], /* i/o: high-band synthesis Q(15 - hb_synth_fx_exp) */ - const Word16 hb_synth_fx_exp, /* i : Q of high-band synthesis */ - const Word16 input_frame, /* i : frame length */ - const Word16 last_extl /* i : last extension layer */ +/* o : gain in Q15 */ +static Word16 TD_Postprocess( + Word16 hb_synth_fx[], /* i/o: high-band synthesis Q(15 - hb_synth_fx_exp) */ + const Word16 hb_synth_fx_exp, /* i : Q of high-band synthesis */ + const Word16 input_frame, /* i : frame length */ + const Word16 last_extl /* i : last extension layer */ ) { Word16 i; @@ -239,14 +243,15 @@ static Word16 TD_Postprocess( /* o : gain in Q15 * HR SWB BWE decoder *-------------------------------------------------------------------*/ -Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB synthesis */ - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *syn_12k8_16k_fx, /* i : ACELP core synthesis @16kHz : Q(15 - exp) */ - const Word16 exp, /* i : Exponent of core synthesis */ - Word16 *hb_synth_fx, /* o : SHB synthesis : Q(15 - hb_synth_fx_exp)*/ - const Word16 output_frame, /* i : frame length */ - const Word16 unbits, /* i : number of core unused bits */ - const Word16 pitch_buf[] /* i : pitch buffer : Q6 */ +/* o : Exponent of SHB synthesis */ +Word16 swb_bwe_dec_hr_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 *syn_12k8_16k_fx, /* i : ACELP core synthesis @16kHz : Q(15 - exp) */ + const Word16 exp, /* i : Exponent of core synthesis */ + Word16 *hb_synth_fx, /* o : SHB synthesis : Q(15 - hb_synth_fx_exp)*/ + const Word16 output_frame, /* i : frame length */ + const Word16 unbits, /* i : number of core unused bits */ + const Word16 pitch_buf[] /* i : pitch buffer : Q6 */ ) { Word16 i, j, k, nBits, nBits_total, nBits_block, Nsv, Nsv2, width_noncoded; @@ -291,7 +296,6 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB hBWE_FD_HR->bwe_highrate_seed_fx = extract_l( L_mult0( pitch_buf[0], pitch_buf[3] ) ); move16(); - /*---------------------------------------------------------------------* * initializations *---------------------------------------------------------------------*/ @@ -1510,6 +1514,7 @@ Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB * * Initialize HR BWE state structure at the decoder *-------------------------------------------------------------------*/ + void hr_bwe_dec_init( HR_BWE_DEC_HANDLE hBWE_FD_HR /* i/o: HR BWE data handle */ ) diff --git a/lib_dec/syn_outp_fx.c b/lib_dec/syn_outp_fx.c index 07f356665e4204a5e43e3ec1e3778c21e72196e0..82d5b1cabaf1276e6d4dbadd29693bfa3d10fc9a 100644 --- a/lib_dec/syn_outp_fx.c +++ b/lib_dec/syn_outp_fx.c @@ -51,18 +51,21 @@ void syn_output_fx( return; } + + /*-------------------------------------------------------------------* * Local function * unscale_AGC * * Output synthesis signal with compensation for saturation *-------------------------------------------------------------------*/ + void unscale_AGC( - const Word16 x[], /* i: 16kHz synthesis Qx */ - const Word16 Qx, /* i: scale factor of x */ - Word16 y[], /* o: output vector Q0 */ + const Word16 x[], /* i : 16kHz synthesis Qx */ + const Word16 Qx, /* i : scale factor of x */ + Word16 y[], /* o : output vector Q0 */ Word16 mem[], /* i/o: mem[2] should be init to [0,0] Q0 */ - const Word16 n /* i: vector size */ + const Word16 n /* i : vector size */ ) { Word16 i, fac, tmp, frame_fac, max_val; @@ -117,4 +120,6 @@ void unscale_AGC( move16(); mem[1] = shr( x[i - 1], 1 ); move16(); + + return; } diff --git a/lib_dec/tcx_utils_dec_fx.c b/lib_dec/tcx_utils_dec_fx.c index b688fa30ac8b2699478c85b8001ac715e2fdf78a..2c35ec0bcfca62730e61a17a1f1b0dcc7ac1a345 100644 --- a/lib_dec/tcx_utils_dec_fx.c +++ b/lib_dec/tcx_utils_dec_fx.c @@ -18,12 +18,13 @@ * * *--------------------------------------------------------------*/ + void tcx_decoder_memory_update( Word16 *xn_buf, /* i/o: mdct output buffer used also as temporary buffer : Q0 */ - Word16 *synthout, /* o: synth : Q0 */ - Word16 *A, /* i: Quantized LPC coefficients : Q12*/ + Word16 *synthout, /* o : synth : Q0 */ + Word16 *A, /* i : Quantized LPC coefficients : Q12*/ Decoder_State *st, /* i/o: decoder memory state */ - Word8 fb /* i: fullband flag */ + Word8 fb /* i : fullband flag */ ) { Word16 tmp; @@ -104,14 +105,14 @@ void tcx_decoder_memory_update( /* Returns: number of bits used (including "bits") */ Word16 tcx_ari_res_invQ_spec( - Word32 x_Q[], /* i/o: quantized spectrum Q(31-x_Q_e) */ - Word16 x_Q_e, /* i: quantized spectrum exponent Q0 */ - Word16 L_frame, /* i: number of lines Q0 */ - const Word16 prm[], /* i: bitstream Q0 */ - Word16 target_bits, /* i: number of bits available Q0 */ - Word16 bits, /* i: number of bits used so far Q0 */ - Word16 deadzone, /* i: quantizer deadzone Q15 */ - const Word16 x_fac[] /* i: spectrum post-quantization factors Q14 */ + Word32 x_Q[], /* i/o: quantized spectrum Q(31-x_Q_e) */ + Word16 x_Q_e, /* i : quantized spectrum exponent Q0 */ + Word16 L_frame, /* i : number of lines Q0 */ + const Word16 prm[], /* i : bitstream Q0 */ + Word16 target_bits, /* i : number of bits available Q0 */ + Word16 bits, /* i : number of bits used so far Q0 */ + Word16 deadzone, /* i : quantizer deadzone Q15 */ + const Word16 x_fac[] /* i : spectrum post-quantization factors Q14 */ ) { Word16 i, j, num_zeros, zeros[L_FRAME_PLUS], fac_p, sign, s; @@ -181,16 +182,19 @@ Word16 tcx_ari_res_invQ_spec( return bits; } + + /*--------------------------------------------------------------- * tcx_res_invQ_gain() * * *--------------------------------------------------------------*/ + Word16 tcx_res_invQ_gain( Word16 *gain_tcx, /* i/o : gain_tcx_e*/ Word16 *gain_tcx_e, - Word16 *prm, /*i : Q0 */ - Word16 resQBits /*i : Q0 */ + Word16 *prm, /*i : Q0 */ + Word16 resQBits /*i : Q0 */ ) { Word16 bits, gain, tmp1, tmp2; @@ -235,6 +239,7 @@ Word16 tcx_res_invQ_gain( * * *--------------------------------------------------------------*/ + Word16 tcx_res_invQ_spec( Word32 *x, /*Q(31 - x_e)*/ Word16 x_e, @@ -242,8 +247,8 @@ Word16 tcx_res_invQ_spec( Word16 *prm, Word16 resQBits, Word16 bits, - Word16 sq_round, /*i : sq deadzone Q15*/ - const Word16 lf_deemph_factors[] /*i : LF deemphasis factors Q14*/ ) + Word16 sq_round, /*i : sq deadzone Q15*/ + const Word16 lf_deemph_factors[] /*i : LF deemphasis factors Q14*/ ) { Word16 i; Word16 fac_m, fac_p; diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c index 93a5ab064261ff067116cc0ae0b1a43c248c0735..0a8892dba66e3c48550589467d92630990a2aa8f 100644 --- a/lib_dec/tonalMDCTconcealment_fx.c +++ b/lib_dec/tonalMDCTconcealment_fx.c @@ -556,10 +556,10 @@ void TonalMDCTConceal_UpdateState( /* o: currenc phase [-pi;pi] 2Q13 */ static void FindPhases( - TonalMDCTConcealPtr const hTonalMDCTConc, /* i: pointer to internal structure */ - Word32 secondLastMDCT[], /* i: MDST spectrum data Qx +31 -diff_exp */ - Word32 secondLastMDST[], /* i: MDCT spectrum data Qx */ - Word16 diff_exp ) /* i: exp_MDST - exp_MDCT */ + TonalMDCTConcealPtr const hTonalMDCTConc, /* i : pointer to internal structure */ + Word32 secondLastMDCT[], /* i : MDST spectrum data Qx +31 -diff_exp */ + Word32 secondLastMDST[], /* i : MDCT spectrum data Qx */ + Word16 diff_exp ) /* i : exp_MDST - exp_MDCT */ { Word16 i; Word16 l; @@ -583,18 +583,18 @@ static void FindPhases( return; } -#define BANDWIDTH 7.0f -#define G 789516047l /*1.0/(2*1.36) Q31*/ -#define MAXRATIO 22938 /*44.8f Q9*/ /* Maximum ratio |ODFT[k-1]|/|ODFT[k+1]| is 16.5 dB, that is maximum ratio (for fractional = 0) is (cos(PI/bandwidth)/cos(3PI/bandwidth))^1.36 */ -#define MM 1934815907 /* FL2WORD32(cos(EVS_PI/BANDWIDTH)); */ -#define SS 29166 /* FL2WORD16(cos((3*EVS_PI)/BANDWIDTH)*4); Q17*/ -#define N 931758243 /* FL2WORD32(sin(EVS_PI/BANDWIDTH)); */ -#define J 31946 /* FL2WORD16(sin((3*EVS_PI)/BANDWIDTH)); */ +/*#define BANDWIDTH 7.0f*/ +#define G 789516047l /*1.0/(2*1.36) Q31*/ +#define MAXRATIO 22938 /*44.8f Q9*/ /* Maximum ratio |ODFT[k-1]|/|ODFT[k+1]| is 16.5 dB, that is maximum ratio (for fractional = 0) is (cos(PI/bandwidth)/cos(3PI/bandwidth))^1.36 */ +#define MM 1934815907 /* FL2WORD32(cos(EVS_PI/BANDWIDTH)); */ +#define SS 29166 /* FL2WORD16(cos((3*EVS_PI)/BANDWIDTH)*4); Q17*/ +#define N 931758243 /* FL2WORD32(sin(EVS_PI/BANDWIDTH)); */ +#define J 31946 /* FL2WORD16(sin((3*EVS_PI)/BANDWIDTH)); */ /* o: Phase difference [-pi;pi] 2Q13*/ static void FindPhaseDifferences( - TonalMDCTConcealPtr const hTonalMDCTConc, /* i: Pointer to internal structure */ - Word32 powerSpectrum[] ) /* i: Power spectrum data Qx */ + TonalMDCTConcealPtr const hTonalMDCTConc, /* i : Pointer to internal structure */ + Word32 powerSpectrum[] ) /* i : Power spectrum data Qx */ { Word16 i, k; Word16 *phaseDiff; @@ -2795,6 +2795,8 @@ void TonalMDCTConceal_SaveTimeSignal( return; } + + void TonalMDCTConceal_SaveTimeSignal_ivas_fx( TonalMDCTConcealPtr hTonalMDCTConc, Word16 *timeSignal, // q_timeSignal @@ -2822,20 +2824,21 @@ void TonalMDCTConceal_SaveTimeSignal_ivas_fx( return; } + + static void CalcPowerSpec( - const Word32 *mdctSpec, /* i: MDCT spectrum Q31-mdctSpec_exp */ - const Word16 mdctSpec_exp, /* i: exponent of MDCT spectrum */ - const Word32 *mdstSpec, /* i: MDST spectrum Q31-mdstSpec_exp */ - const Word16 mdstSpec_exp, /* i: exponent of MDST spectrum */ - const Word16 nSamples, /* i: frame size */ - const Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins Q0 */ - Word32 *powerSpec, /* o: power spectrum Q31- powerSpec_exp */ - Word16 *powerSpec_exp ) /* o: exponent of power spectrum */ + const Word32 *mdctSpec, /* i : MDCT spectrum Q31-mdctSpec_exp */ + const Word16 mdctSpec_exp, /* i : exponent of MDCT spectrum */ + const Word32 *mdstSpec, /* i : MDST spectrum Q31-mdstSpec_exp */ + const Word16 mdstSpec_exp, /* i : exponent of MDST spectrum */ + const Word16 nSamples, /* i : frame size */ + const Word16 floorPowerSpectrum, /* i : lower limit for power spectrum bins Q0 */ + Word32 *powerSpec, /* o : power spectrum Q31- powerSpec_exp */ + Word16 *powerSpec_exp ) /* o : exponent of power spectrum */ { Word16 k, s1, s2, tmp; Word32 x, L_tmp, L_tmp_floor; - k = s_max( mdctSpec_exp, mdstSpec_exp ); *powerSpec_exp = add( add( k, k ), 3 ); /*extra 3 bits of headroom for MA filter in getEnvelope*/ move16(); diff --git a/lib_dec/vlpc_1st_dec_fx.c b/lib_dec/vlpc_1st_dec_fx.c index 45fd00390aa85c2069a22724090211692c7871ad..b77d7fce272422eedbb1c9e6a3455d7088cadd42 100644 --- a/lib_dec/vlpc_1st_dec_fx.c +++ b/lib_dec/vlpc_1st_dec_fx.c @@ -9,8 +9,8 @@ #include "rom_com.h" void vlpc_1st_dec( - Word16 index, /* input: codebook index */ - Word16 *lsfq ) /* i/o: i:prediction o:quantized lsf 14Q1*1.28 */ + Word16 index, /* i : codebook index */ + Word16 *lsfq ) /* i/o: i:prediction o:quantized lsf 14Q1*1.28 */ { Word16 i; const Word16 *p_dico; @@ -24,4 +24,6 @@ void vlpc_1st_dec( move16(); p_dico++; } + + return; } diff --git a/lib_dec/vlpc_2st_dec_fx.c b/lib_dec/vlpc_2st_dec_fx.c index 562cce4cf40daa5015e262ba3c37c6e36cbb6081..74a1520032ca95876d8677172430d0b9694ec00a 100644 --- a/lib_dec/vlpc_2st_dec_fx.c +++ b/lib_dec/vlpc_2st_dec_fx.c @@ -6,9 +6,8 @@ #include #include "options.h" #include "prot_fx.h" -//#ifdef DEBUGGING to be removed #include -//#endif + void vlpc_2st_dec( Word16 *lsfq, /* i/o: i:1st stage o:1st+2nd stage 14Q1*1.28*/ @@ -33,7 +32,6 @@ void vlpc_2st_dec( FOR( i = 0; i < M; i++ ) { - //#ifdef DEBUGGING to be removed assert( abs_s( xq[i] ) <= 32 ); /* If xq > 32 for IVAS, we might need a different loop implementation */ //#endif lsfq[i] = add( lsfq[i], shl( mult_r( w[i], shl_sat( xq[i], 10 ) ), 2 ) ); /*14Q1*1.28*/ @@ -62,8 +60,8 @@ void vlpc_2st_dec( gap = 34; move16(); } - reorder_lsf_fx( lsfq, gap, M, INT_FS_FX ); + reorder_lsf_fx( lsfq, gap, M, INT_FS_FX ); return; } diff --git a/lib_dec/waveadjust_fec_dec_fx.c b/lib_dec/waveadjust_fec_dec_fx.c index 1776d31a236c3d7bf2be8f6be3ce7be37bff2e3f..8ac2be1675cf84edd0e1aad2b19976a105d2299c 100644 --- a/lib_dec/waveadjust_fec_dec_fx.c +++ b/lib_dec/waveadjust_fec_dec_fx.c @@ -108,7 +108,10 @@ void concealment_update_x( } -static Word16 zero_pass_w32_x( const Word16 *s, const Word16 N ) /* i: Qx*/ /* o: 2*Qx-31*/ +/* i: Qx*/ /* o: 2*Qx-31*/ +static Word16 zero_pass_w32_x( + const Word16 *s, + const Word16 N ) { Word16 i; Word32 temp, zp = L_deposit_l( 0 ); @@ -121,7 +124,9 @@ static Word16 zero_pass_w32_x( const Word16 *s, const Word16 N ) /* i: Qx*/ /* o return extract_l( zp ); } -Word16 Sqrt_x_fast( Word32 value /*Qvalue*/ ) /*o : Q11-(2*norm+1)*/ +/*o : Q11-(2*norm+1)*/ +Word16 Sqrt_x_fast( + Word32 value /*Qvalue*/ ) { Word16 norm; Word16 result, index; @@ -129,10 +134,16 @@ Word16 Sqrt_x_fast( Word32 value /*Qvalue*/ ) /*o : Q11-(2*norm+1)*/ norm = sub( 23, norm_l( value ) ); index = extract_l( L_shr_r( value, add( norm, s_and( norm, 1 ) ) ) ); result = shr( sqrt_table_pitch_search[index], sub( 11, shr( add( norm, 1 ), 1 ) ) ); // Q11-(2*norm+1) + return result; } -Word32 dot_w32_accuracy_x( Word16 *s1 /*Qs1*/, Word16 *s2 /*Qs2*/, Word16 nbits, Word16 N ) + +Word32 dot_w32_accuracy_x( + Word16 *s1 /*Qs1*/, + Word16 *s2 /*Qs2*/, + Word16 nbits, + Word16 N ) { Word16 i; Word32 eng = L_deposit_l( 0 ), temp; @@ -147,12 +158,15 @@ Word32 dot_w32_accuracy_x( Word16 *s1 /*Qs1*/, Word16 *s2 /*Qs2*/, Word16 nbits, } -Word16 int_div_s_x( Word16 a, Word16 b ) /*i/o : Q0*/ +Word16 int_div_s_x( + Word16 a, + Word16 b ) /*i/o : Q0*/ { Word16 result = 0; Word16 norm, left = 0, i; move16(); move16(); + test(); IF( LT_16( a, b ) || b == 0 ) { @@ -179,7 +193,10 @@ Word16 int_div_s_x( Word16 a, Word16 b ) /*i/o : Q0*/ return result; } -Word16 GetW32Norm_x( Word32 *s, Word16 N ) /*i : Qx, o: Q0*/ + +Word16 GetW32Norm_x( + Word32 *s, + Word16 N ) /*i : Qx, o: Q0*/ { Word32 smax = L_deposit_l( 0 ); Word16 smax_norm, i; @@ -194,7 +211,11 @@ Word16 GetW32Norm_x( Word32 *s, Word16 N ) /*i : Qx, o: Q0*/ return smax_norm; } -Word16 harmo_x( Word32 *X, Word16 Framesize, Word16 pitch ) /*i : Qx, o: Q15*/ + +Word16 harmo_x( + Word32 *X, + Word16 Framesize, + Word16 pitch ) /*i : Qx, o: Q15*/ { Word16 h, k, result = 0; Word32 ener = L_deposit_l( 0 ), ener_harmo = L_deposit_l( 0 ); @@ -211,8 +232,7 @@ Word16 harmo_x( Word32 *X, Word16 Framesize, Word16 pitch ) /*i : Qx, o: Q15*/ d1 = extract_h( L_shl( X[h], norm1 ) ); d2 = extract_h( L_shl( X[h + 1], norm1 ) ); - ener_harmo = L_add( ener_harmo, - L_shr( L_mac0( L_mult0( d1, d1 ), d2, d2 ), nbits ) ); + ener_harmo = L_add( ener_harmo, L_shr( L_mac0( L_mult0( d1, d1 ), d2, d2 ), nbits ) ); } FOR( k = 0; k < Framesize; k++ ) @@ -235,12 +255,16 @@ Word16 harmo_x( Word32 *X, Word16 Framesize, Word16 pitch ) /*i : Qx, o: Q15*/ return 0; } result = div_s( ener_harmo_w, ener_w ); + return result; } -static Word16 get_low_freq_eng_rate_x( Word32 *mdct_data, /*i: Qx*/ /*o: Q0*/ - Word16 curr_mode, - Word16 N ) + +static Word16 get_low_freq_eng_rate_x( + Word32 *mdct_data, + /*i : Qx*/ /*o : Q0*/ + const Word16 curr_mode, + const Word16 N ) { Word16 N1, N2, i; Word32 low_eng = L_deposit_l( 0 ), eng = L_deposit_l( 0 ), smax = L_deposit_l( 0 ); @@ -285,7 +309,11 @@ static Word16 get_low_freq_eng_rate_x( Word32 *mdct_data, /*i: Qx*/ /*o: Q0*/ return ( L_sub( low_eng, smax ) <= 0 ); } -void LpFilter2_x( Word16 *x, Word16 *y, Word16 N ) /*i/o : Qx*/ + +void LpFilter2_x( + Word16 *x, + Word16 *y, + Word16 N ) /*i/o : Qx*/ { Word16 i; Word16 smax, norm; @@ -312,9 +340,16 @@ void LpFilter2_x( Word16 *x, Word16 *y, Word16 N ) /*i/o : Qx*/ y[i] = add( mult( y[i - 2], a1 ), add( mult( y[i - 1], a2 ), mult( shl( x[i], norm ), a1 ) ) ); move16(); } + + return; } -void sig_tilt_x( Word16 *s /*Qx*/, Word16 FrameSize, Word32 *enr1 /*2*Qx-nbits*/, Word32 *enr2 /*2*Qx-nbits*/ ) + +void sig_tilt_x( + Word16 *s /*Qx*/, + Word16 FrameSize, + Word32 *enr1 /*2*Qx-nbits*/, + Word32 *enr2 /*2*Qx-nbits*/ ) { Word16 subFrameSize, shIFt; Word16 *p1, *p2; @@ -330,9 +365,19 @@ void sig_tilt_x( Word16 *s /*Qx*/, Word16 FrameSize, Word32 *enr1 /*2*Qx-nbits*/ move32(); *enr2 = dot_w32_accuracy_x( p1, p1, nbits, shIFt ); move32(); + + return; } -void get_maxConv_and_pitch_x( Word16 *s_LP /*Qx*/, Word16 s /*Q0*/, Word16 e /*Q0*/, Word16 N, Word32 *maxConv /*2*Qx-nbits*/, Word16 *maxConv_bits, Word16 *pitch /*Q0*/ ) + +void get_maxConv_and_pitch_x( + Word16 *s_LP /*Qx*/, + Word16 s /*Q0*/, + Word16 e /*Q0*/, + Word16 N, + Word32 *maxConv /*2*Qx-nbits*/, + Word16 *maxConv_bits, + Word16 *pitch /*Q0*/ ) { Word16 t, cov_size, size = N; Word32 tmp_sigma = L_deposit_l( 0 ), cov_max_sigma = L_deposit_l( 0 ); @@ -406,9 +451,17 @@ void get_maxConv_and_pitch_x( Word16 *s_LP /*Qx*/, Word16 s /*Q0*/, Word16 e /*Q move32(); *maxConv_bits = nbits; move16(); + + return; } -Word16 get_voicing_x( Word16 *s_LP /*Qx*/, Word16 pitch /*Q0*/, Word32 covMax /*2*Qx-nbits*/, Word16 maxConv_bits, Word16 Framesize ) /*o : Q15*/ + +Word16 get_voicing_x( + Word16 *s_LP /*Qx*/, + Word16 pitch /*Q0*/, + Word32 covMax /*2*Qx-nbits*/, + Word16 maxConv_bits, + Word16 Framesize ) /*o : Q15*/ { Word32 eng1 = L_deposit_l( 0 ), eng2 = L_deposit_l( 0 ); Word16 voicing, norm; @@ -456,7 +509,12 @@ Word16 get_voicing_x( Word16 *s_LP /*Qx*/, Word16 pitch /*Q0*/, Word32 covMax /* } } -void pitch_modify_x( Word16 *s_LP /*Qx*/, Word16 *voicing /*Q15*/, Word16 *pitch /*Q0*/, Word16 FrameSize ) + +void pitch_modify_x( + Word16 *s_LP /*Qx*/, + Word16 *voicing /*Q15*/, + Word16 *pitch /*Q0*/, + Word16 FrameSize ) { Word32 eng1, eng2, eng3; Word16 shIFt = shr( *pitch, 1 ); @@ -515,9 +573,19 @@ void pitch_modify_x( Word16 *s_LP /*Qx*/, Word16 *voicing /*Q15*/, Word16 *pitch *voicing = voicing2; move16(); } + + return; } -Word16 Is_Periodic_x( Word32 *mdct_data /*Qx*/, Word16 cov_max /*Q15*/, Word16 zp, Word32 ener /*Q8*/, Word32 ener_mean /*Q8*/, Word16 pitch /*Q0*/, Word16 Framesize ) /*o: Q0*/ + +Word16 Is_Periodic_x( + Word32 *mdct_data /*Qx*/, + Word16 cov_max /*Q15*/, + Word16 zp, + Word32 ener /*Q8*/, + Word32 ener_mean /*Q8*/, + Word16 pitch /*Q0*/, + Word16 Framesize ) /*o: Q0*/ { Word16 flag = 0; Word16 harm; @@ -565,7 +633,11 @@ Word16 Is_Periodic_x( Word32 *mdct_data /*Qx*/, Word16 cov_max /*Q15*/, Word16 z return flag; } -Word16 get_conv_relation_x( Word16 *s_LP /*Qx*/, Word16 shIFt, Word16 N ) /*o :Q0*/ + +Word16 get_conv_relation_x( + Word16 *s_LP /*Qx*/, + Word16 shIFt, + Word16 N ) /*o :Q0*/ { Word32 eng1, eng2, eng3; Word16 eng1_w, eng2_w; @@ -672,9 +744,7 @@ static Word16 pitch_search_fx( mdctPtr = mdct_data + shr( Framesize, 1 ); } - low_freq_rate_result = get_low_freq_eng_rate_x( mdctPtr, - curr_mode, - Framesize ); + low_freq_rate_result = get_low_freq_eng_rate_x( mdctPtr, curr_mode, Framesize ); IF( low_freq_rate_result ) { @@ -776,9 +846,11 @@ static Word16 pitch_search_fx( pitch = 0; move16(); } + return pitch; } + void concealment_init_x( const Word16 L_frameTCX, T_PLCInfo_HANDLE hPlcInfo ) @@ -840,14 +912,16 @@ void concealment_init_x( } -static Word16 own_random_fix( /* o : output random value */ - Word16 *seed /* i/o: random seed Q0 */ +/* o : output random value */ +static Word16 own_random_fix( + Word16 *seed /* i/o: random seed Q0 */ ) { *seed = extract_l( L_mac0( 13849L, *seed, 31821 ) ); return ( *seed ); } + void concealment_decode_fix( Word16 curr_mode, Word32 *invkoef /*Qinvkoef_scale*/, @@ -894,7 +968,10 @@ void concealment_decode_fix( } -Word16 Spl_GetScalingSquare_x( const Word16 *in_vector /*Qin_vector*/, const Word16 in_vector_length, Word16 times ) /*o : Q0*/ +Word16 Spl_GetScalingSquare_x( + const Word16 *in_vector /*Qin_vector*/, + const Word16 in_vector_length, + Word16 times ) /*o : Q0*/ { Word16 nbits = sub( 15, norm_s( times ) ) /*Spl_GetSizeInBits_x(times)*/; Word16 i; @@ -927,7 +1004,10 @@ Word16 Spl_GetScalingSquare_x( const Word16 *in_vector /*Qin_vector*/, const Wor } -Word32 Spl_Energy_x( const Word16 *vector /*Qvector*/, const Word16 vector_length, Word16 *scale_factor ) +Word32 Spl_Energy_x( + const Word16 *vector /*Qvector*/, + const Word16 vector_length, + Word16 *scale_factor ) { Word32 en = L_deposit_l( 0 ); Word32 i; @@ -944,7 +1024,11 @@ Word32 Spl_Energy_x( const Word16 *vector /*Qvector*/, const Word16 vector_lengt return en; } -void Log10OfEnergy_x( const Word16 *s /* Qs */, Word32 *enerlogval /* Q8 */, const Word16 len ) + +void Log10OfEnergy_x( + const Word16 *s /* Qs */, + Word32 *enerlogval /* Q8 */, + const Word16 len ) { Word32 energy = L_deposit_l( 0 ), tmp2 = L_deposit_l( 0 ); Word16 shfts = 0; @@ -965,9 +1049,13 @@ void Log10OfEnergy_x( const Word16 *s /* Qs */, Word32 *enerlogval /* Q8 */, con *enerlogval = -25600; move32(); } + + return; } -static Word32 fnLog2( Word32 L_Input /*QL_Input*/ ) /*o :Q26*/ + +static Word32 fnLog2( + Word32 L_Input /*QL_Input*/ ) /*o :Q26*/ { Word16 swC0 = -0x2b2a, swC1 = 0x7fc5, swC2 = -0x54d0; @@ -976,11 +1064,6 @@ static Word32 fnLog2( Word32 L_Input /*QL_Input*/ ) /*o :Q26*/ move16(); move16(); move16(); - /*_________________________________________________________________________ - | | - | Executable Code | - |_________________________________________________________________________| - */ /* normalize input and store shIFts required */ /* ----------------------------------------- */ @@ -1021,17 +1104,14 @@ static Word32 fnLog2( Word32 L_Input /*QL_Input*/ ) /*o :Q26*/ return ( LwIn ); } -static Word32 fnLog10( Word32 L_Input /*QL_Input*/ ) /*o :Q26*/ + +static Word32 fnLog10( + Word32 L_Input /*QL_Input*/ ) /*o :Q26*/ { Word16 Scale = 9864; /* 0.30103 = log10(2) */ Word32 LwIn; move16(); - /*_________________________________________________________________________ - | | - | Executable Code | - |_________________________________________________________________________| - */ /* 0.30103*log2(x) */ /* ------------------- */ @@ -1042,7 +1122,10 @@ static Word32 fnLog10( Word32 L_Input /*QL_Input*/ ) /*o :Q26*/ return ( LwIn ); } -Word32 con_Log10( Word32 i_s32Val /*Qi_s32Val*/, Word16 i_s16Q /*Q0*/ ) /*o; Q26*/ + +Word32 con_Log10( + Word32 i_s32Val /*Qi_s32Val*/, + Word16 i_s16Q /*Q0*/ ) /*o; Q26*/ { Word32 s32Out; Word32 s32Correct; /* corrected (31-q)*log10(2) */ @@ -1065,6 +1148,7 @@ Word32 con_Log10( Word32 i_s32Val /*Qi_s32Val*/, Word16 i_s16Q /*Q0*/ ) /*o; Q26 return s32Out; } + void concealment_update2_x( const Word16 *outx_new /*Qoutx_new*/, T_PLCInfo_HANDLE hPlcInfo, @@ -1085,6 +1169,7 @@ void concealment_update2_x( return; } + static Word16 array_max_indx_fx( Word16 *s /*Qs*/, Word16 N ) @@ -1102,14 +1187,15 @@ static Word16 array_max_indx_fx( return indx; } -Word16 ffr_getSfWord16( /* o: measured headroom in range [0..15], 0 IF all x[i] == 0 */ - Word16 *x, /* i: array containing 16-bit data Qx*/ - Word16 len_x ) /* i: length of the array to scan */ + +/* o: measured headroom in range [0..15], 0 IF all x[i] == 0 */ +Word16 ffr_getSfWord16( + Word16 *x, /* i : array containing 16-bit data Qx*/ + Word16 len_x ) /* i : length of the array to scan */ { Word16 i, i_min, i_max; Word16 x_min, x_max; - x_max = 0; move16(); x_min = 0; @@ -1147,7 +1233,13 @@ Word16 ffr_getSfWord16( /* o: measured headroom in range [0..15], return i; } -static Word16 OverlapAdd_fx( Word16 *pitch125_data /*Qx*/, Word16 *sbuf /*Qx*/, Word16 n, Word16 pitch /*Q0*/, Word16 Framesize ) + +static Word16 OverlapAdd_fx( + Word16 *pitch125_data /*Qx*/, + Word16 *sbuf /*Qx*/, + Word16 n, + Word16 pitch /*Q0*/, + Word16 Framesize ) { Word16 n1, n2, s, s16MaxCoefNorm, s16MaxCoefNorm2, tmp16; Word16 i; @@ -1194,13 +1286,15 @@ static Word16 OverlapAdd_fx( Word16 *pitch125_data /*Qx*/, Word16 *sbuf /*Qx*/, return pitch; } -static void add_noise( Word16 *const sbuf, /*Qsbuf*/ - Word16 *const outx_new_n1, /*Q0*/ - Word16 const *const noise_seg, /*Q0*/ - Word16 const Len, - Word16 *const gain, /*Q15*/ - Word16 const *const gain_n, /*Q15*/ - Word8 const firstFrame ) + +static void add_noise( + Word16 *const sbuf, /*Qsbuf*/ + Word16 *const outx_new_n1, /*Q0*/ + Word16 const *const noise_seg, /*Q0*/ + Word16 const Len, + Word16 *const gain, /*Q15*/ + Word16 const *const gain_n, /*Q15*/ + Word8 const firstFrame ) { Word16 i; Word16 temp_OUT; @@ -1227,6 +1321,7 @@ static void add_noise( Word16 *const sbuf, /*Qsbuf*/ return; } + static Word16 waveform_adj_fix( T_PLCInfo_HANDLE hPlcInfo, Word16 *overlapbuf, /*Qoverlapbuf*/ @@ -1538,6 +1633,7 @@ void waveform_adj2_fix( } } } + return; } @@ -1605,5 +1701,6 @@ void concealment_signal_tuning_fx( move16(); } } + return; } diff --git a/lib_enc/acelp_enc_util_fx.c b/lib_enc/acelp_enc_util_fx.c index cd93c7f13973c4ee3e1c3b801b96fba2483e925d..83c8a8676a0a02fa5dff29db6729eafb54cec59d 100644 --- a/lib_enc/acelp_enc_util_fx.c +++ b/lib_enc/acelp_enc_util_fx.c @@ -103,10 +103,10 @@ Word16 E_ACELP_toeplitz_mul_fx( } void E_ACELP_weighted_code( - const Word16 code[], /* i: code Q9*/ - const Word16 H[], /* i: impulse response Q*/ - Word16 Q, /* i: Q format of H */ - Word16 y[] /* o: weighted code Q9*/ + const Word16 code[], /* i : code Q9*/ + const Word16 H[], /* i : impulse response Q*/ + Word16 Q, /* i : Q format of H */ + Word16 y[] /* o : weighted code Q9*/ ) { Word16 i, j, k, one, n, nz[L_SUBFR]; @@ -230,12 +230,14 @@ void E_ACELP_build_code( ind[i] = index; /* Q0 */ move16(); } + + return; } void E_ACELP_setup_pulse_search_pos( - const PulseConfig *config, /* i: pulse configuration */ - Word16 k, /* i: interation number Q0*/ - UWord8 ipos[] /* o: pulse search positions Q0*/ + const PulseConfig *config, /* i : pulse configuration */ + Word16 k, /* i : interation number Q0*/ + UWord8 ipos[] /* o : pulse search positions Q0*/ ) { Word16 restpulses, iPulse; diff --git a/lib_enc/ari_enc_fx.c b/lib_enc/ari_enc_fx.c index 0c44f113e95dc5ef0895032792288305ade7fb42..afeba274c1fb78428c792b639b72ea04a68b87c2 100644 --- a/lib_enc/ari_enc_fx.c +++ b/lib_enc/ari_enc_fx.c @@ -5,13 +5,12 @@ #include #include "assert.h" #include "options.h" -//#include "basop_mpy.h" #include "cnst.h" #include "rom_com.h" -//#include "prot_fx.h" #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ + /*--------------------------------------------------------------- * ari_copy_states_fx() * @@ -20,7 +19,10 @@ * * \return none *-------------------------------------------------------------*/ -void ari_copy_states_fx( TastatEnc *source, TastatEnc *dest ) + +void ari_copy_states_fx( + TastatEnc *source, + TastatEnc *dest ) { dest->low = source->low; move32(); @@ -28,6 +30,8 @@ void ari_copy_states_fx( TastatEnc *source, TastatEnc *dest ) move32(); dest->value = source->value; move16(); + + return; } /*--------------------------------------------------------------- @@ -42,24 +46,30 @@ void ari_copy_states_fx( TastatEnc *source, TastatEnc *dest ) * * \return none *-------------------------------------------------------------*/ -void ari_start_encoding_14bits_fx( TastatEnc *s ) + +void ari_start_encoding_14bits_fx( + TastatEnc *s ) { s->low = L_deposit_l( 0 ); s->high = ari_q4new + 1; move32(); s->value = 0; move16(); + + return; } + /*--------------------------------------------------------------- * Ari encoder 14 bits routines * Returns: new bit-stream position *-------------------------------------------------------------*/ + Word16 ari_put_bit_plus_follow( - Word16 ptr[], /* o: bit-stream Q0*/ - Word16 bp, /* i: bit-stream position Q0*/ - Word16 bits_to_follow, /* i: number of opposite bits to follow 'bit' Q0*/ - Word16 bit /* i: bit to send Q0*/ + Word16 ptr[], /* o : bit-stream Q0*/ + Word16 bp, /* i : bit-stream position Q0*/ + Word16 bits_to_follow, /* i : number of opposite bits to follow 'bit' Q0*/ + Word16 bit /* i : bit to send Q0*/ ) { assert( bit == 0 || bit == 1 ); @@ -71,9 +81,11 @@ Word16 ari_put_bit_plus_follow( ptr[bp++] = bit; /* send inverted bit Q0*/ move16(); } + return bp; } + /*-------------------------------------------------------------- - *ari_done_encoding_14bits_fx() * @@ -115,6 +127,7 @@ Word16 ari_done_encoding_14bits_fx( * * \return bit consumption * ------------------------------------------------------------ - */ + Word16 ari_encode_14bits_ext_fx( Word16 *ptr, /* Q0 */ Word16 bp, /* Q0 */ @@ -193,12 +206,16 @@ Word16 ari_encode_14bits_ext_fx( return bp; } + + /*------------------------------------------------------------------------ * Function: ari_encode_overflow_fx() * * *-------------------------------------------------------------------------*/ -Word16 ari_encode_overflow_fx( TastatEnc *s ) + +Word16 ari_encode_overflow_fx( + TastatEnc *s ) { return L_sub( L_sub( s->high, 1 ), s->low ) <= 0; } @@ -208,6 +225,7 @@ Word16 ari_encode_overflow_fx( TastatEnc *s ) * * *-------------------------------------------------------------------------*/ + static Word16 ari_encode_14bits_high_low( Word16 *ptr, /* Q0 */ Word16 bp, /* Q0 */ @@ -271,6 +289,7 @@ static Word16 ari_encode_14bits_high_low( return bp; } + /*------------------------------------------------------------------------ * Function: ari_encode_14bits_range_fx * @@ -302,6 +321,7 @@ Word16 ari_encode_14bits_range_fx( * * Encode a sign with equal probabilities. *-------------------------------------------------------------------------*/ + Word16 ari_encode_14bits_sign_fx( Word16 *ptr, /* Q0 */ Word16 bp, /* Q0 */ @@ -330,11 +350,13 @@ Word16 ari_encode_14bits_sign_fx( return ari_encode_14bits_high_low( ptr, bp, bits, s, high, low ); } + /*------------------------------------------------------------------------ * Function: ari_done_cbr_encoding_14bits_fx * * Finish up encoding in CBR mode. *-------------------------------------------------------------------------*/ + Word16 ari_done_cbr_encoding_14bits_fx( Word16 *ptr, /* Q0 */ Word16 bp, /* Q0 */ @@ -365,6 +387,7 @@ Word16 ari_done_cbr_encoding_14bits_fx( return bp; } + void ari_start_encoding_14bits_ivas_fx( Tastat *s ) { @@ -379,6 +402,7 @@ void ari_start_encoding_14bits_ivas_fx( return; } + /*--------------------------------------------------------------- * ari_done_encoding_14bits_ivas_fx() * @@ -408,6 +432,7 @@ Word16 ari_done_encoding_14bits_ivas_fx( * encode function for extended proba tables: less branches needed for coding * *-------------------------------------------------------------*/ + Word16 ari_encode_14bits_ext_ivas_fx( Word16 *ptr, /* Q0 */ Word16 bp, /* Q0 */ @@ -555,11 +580,13 @@ static Word16 ari_encode_14bits_high_low_ivas_fx( return bp; } + /*------------------------------------------------------------------------ * Function: ari_encode_14bits_sign_ivas_fx() * * Encode a sign with equal probabilities. *-------------------------------------------------------------------------*/ + Word16 ari_encode_14bits_sign_ivas_fx( Word16 *ptr, /* Q0 */ Word16 bp, /* Q0 */ diff --git a/lib_enc/ari_hm_enc_fx.c b/lib_enc/ari_hm_enc_fx.c index 69b355300d4678d2d1a61502036dd12c56319eca..f57c0639c0bbd8d8c79a180a468ed5c86ddb8b25 100644 --- a/lib_enc/ari_hm_enc_fx.c +++ b/lib_enc/ari_hm_enc_fx.c @@ -2,7 +2,6 @@ EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ - #include #include #include "options.h" @@ -13,6 +12,7 @@ #include "prot_fx.h" #include "prot_fx_enc.h" /* Function prototypes */ + /*-------------------------------------------------------------------* * EncodeIndex_fx() * @@ -21,7 +21,7 @@ /*ari_hm_enc.c*/ /* Q13 format */ -const Word16 kLowPeriodicityThr_fx[2] = { 4096 /*0.5f Q13*/, 1638 /*0.2f Q13*/ }; +static const Word16 kLowPeriodicityThr_fx[2] = { 4096 /*0.5f Q13*/, 1638 /*0.2f Q13*/ }; Word16 EncodeIndex_fx( const Word16 Bandwidth, @@ -86,6 +86,7 @@ Word16 EncodeIndex_ivas_fx( * * *-------------------------------------------------------------------*/ + static Word16 SearchPeriodicityIndex_Single( const Word16 AbsMdct3[], // Qx const Word16 NumToConsider, @@ -97,7 +98,6 @@ static Word16 SearchPeriodicityIndex_Single( Word32 Limit, OldIndex, i; Word16 Result, tmp1, tmp2; - Limit = L_deposit_l( sub( NumToConsider, 1 ) ); Limit = L_shl( Limit, FractionalResolution ); AbsMeanCurrent3 = L_deposit_l( 0 ); @@ -125,11 +125,14 @@ static Word16 SearchPeriodicityIndex_Single( return Result; } + + /*-------------------------------------------------------------------* * SearchPeriodicityIndex_Range() * * *-------------------------------------------------------------------*/ + static void SearchPeriodicityIndex_Range( const Word16 AbsMdct3[], // Qx const Word16 NumToConsider, @@ -213,8 +216,11 @@ static void SearchPeriodicityIndex_Range( *Score = BestScore; move16(); + + return; } + /*-------------------------------------------------------------------* * SearchPeriodicityIndex_fx() * @@ -467,6 +473,8 @@ Word16 SearchPeriodicityIndex_fx( return PeriodicityIndex; } + + /*-------------------------------------------------------------------* * PeakFilter() * @@ -475,7 +483,7 @@ Word16 SearchPeriodicityIndex_fx( static void PeakFilter( const Word32 x[], /* i : absolute spectrum Qx */ - Word32 y[], /* O : filtered absolute spectrum, must not alias x[] Q(x-4)*/ + Word32 y[], /* o : filtered absolute spectrum, must not alias x[] Q(x-4)*/ const Word16 L_frame /* i : number of spectral lines */ ) { @@ -515,21 +523,25 @@ static void PeakFilter( move32(); a = L_sub( a, L_shr( x[i - flen], 4 ) ); } + + return; } + /*-------------------------------------------------------------------* * tcx_hm_get_re() * * *-------------------------------------------------------------------*/ + static Word32 tcx_hm_get_re( - const Word16 x[], /* i: absolute spectrum */ - const Word16 gain, /* o: quantized harmonic model gain Q11 */ - const Word32 lag, /* i: pitch lag Q0 */ - const Word16 fract_res, /* i: fractional resolution of the lag Q0 */ - Word16 p[], /* i: harmonic model Q13 */ - const Word32 env[], /* i: envelope Q16 */ - const Word16 L_frame /* i: number of spectral lines Q0 */ + const Word16 x[], /* i : absolute spectrum */ + const Word16 gain, /* o : quantized harmonic model gain Q11 */ + const Word32 lag, /* i : pitch lag Q0 */ + const Word16 fract_res, /* i : fractional resolution of the lag Q0 */ + Word16 p[], /* i : harmonic model Q13 */ + const Word32 env[], /* i : envelope Q16 */ + const Word16 L_frame /* i : number of spectral lines Q0 */ ) { Word16 i, inv_G, tmp; @@ -544,13 +556,10 @@ static Word32 tcx_hm_get_re( Copy32( env, ne, L_frame ); - tcx_hm_modify_envelope( - gain, - lag, - fract_res, - p, - ne, - L_frame ); + tcx_hm_modify_envelope( gain, + lag, + fract_res, p, + ne, L_frame ); /* Normalize **************************************************************/ @@ -586,6 +595,8 @@ static Word32 tcx_hm_get_re( return e; } + + /*-------------------------------------------------------------------* * tcx_hm_quantize_gain() * @@ -593,17 +604,17 @@ static Word32 tcx_hm_get_re( *-------------------------------------------------------------------*/ static void tcx_hm_quantize_gain( - const Word32 x[], /* i: absolute spectrum Q31-x_e */ - const Word16 *x_e, /* i: absolute spectrum exponent Q0 */ - const Word32 env[], /* i: envelope Q16 */ - const Word32 lag, /* i: pitch lag Q0 */ - const Word16 fract_res, /* i: fractional resolution of the lag Q0 */ - Word16 p[], /* i: harmonic model Q13 */ - const Word16 L_frame, /* i: number of spectral lines Q0 */ - const Word16 coder_type, /* i: coder_type Q0 */ - Word16 relative_score, /* i: periodicity score Q13 */ - Word16 *gain_idx, /* o: quantization index Q0 */ - Word16 *gain /* o: quantized harmonic model gain Q11 */ + const Word32 x[], /* i : absolute spectrum Q31-x_e */ + const Word16 *x_e, /* i : absolute spectrum exponent Q0 */ + const Word32 env[], /* i : envelope Q16 */ + const Word32 lag, /* i : pitch lag Q0 */ + const Word16 fract_res, /* i : fractional resolution of the lag Q0 */ + Word16 p[], /* i : harmonic model Q13 */ + const Word16 L_frame, /* i : number of spectral lines Q0 */ + const Word16 coder_type, /* i : coder_type Q0 */ + Word16 relative_score, /* i : periodicity score Q13 */ + Word16 *gain_idx, /* o : quantization index Q0 */ + Word16 *gain /* o : quantized harmonic model gain Q11 */ ) { Word16 g; @@ -614,7 +625,6 @@ static void tcx_hm_quantize_gain( Word16 x16[N_MAX_ARI], s_x; Word16 s; - assert( coder_type == VOICED || coder_type == GENERIC ); s = 0; move16(); @@ -673,14 +683,12 @@ static void tcx_hm_quantize_gain( /* Iterate over all possible gain values */ FOR( g = 0; g < ( 1 << kTcxHmNumGainBits ); ++g ) { - e = tcx_hm_get_re( - x16, - qGains[s][g], - lag, - fract_res, - p, - env, - L_frame ); + e = tcx_hm_get_re( x16, + qGains[s][g], lag, + fract_res, + p, + env, + L_frame ); /* Add bit penalty */ pe = 16384 /*1.0 Q14*/; @@ -703,15 +711,18 @@ static void tcx_hm_quantize_gain( } } } + + return; } + static Word16 tcx_hm_search( - const Word32 abs_spectrum[], /* i: absolute spectrum Q31-e */ - const Word16 L_frame, /* i: number of spectral lines Q0 */ - const Word16 targetBits, /* i: target bit budget Q0 */ - const Word16 LtpPitchLag, /* i: LTP pitch lag or -1 if none Q0 */ - const Word16 LtpGain, /* i: LTP gain Q15 */ - Word16 *RelativeScore /* o: Energy concentration factor Q13 */ + const Word32 abs_spectrum[], /* i : absolute spectrum Q31-e */ + const Word16 L_frame, /* i : number of spectral lines Q0 */ + const Word16 targetBits, /* i : target bit budget Q0 */ + const Word16 LtpPitchLag, /* i : LTP pitch lag or -1 if none Q0 */ + const Word16 LtpGain, /* i : LTP gain Q15 */ + Word16 *RelativeScore /* o : Energy concentration factor Q13 */ ) { Word32 fspec[N_MAX_ARI]; @@ -720,27 +731,21 @@ static Word16 tcx_hm_search( PeakFilter( abs_spectrum, fspec, L_frame ); /* Get the best lag index */ - return SearchPeriodicityIndex_fx( - fspec, - abs_spectrum, - L_frame, - targetBits, - LtpPitchLag, - LtpGain, - RelativeScore ); + return SearchPeriodicityIndex_fx( fspec, abs_spectrum, L_frame, targetBits, LtpPitchLag, LtpGain, RelativeScore ); } + void tcx_hm_analyse_fx( - const Word32 abs_spectrum[], /* i: absolute spectrum Q31-e */ - const Word16 *spectrum_e, /* i: absolute spectrum exponent Q0 */ - const Word16 L_frame, /* i: number of spectral lines Q0 */ + const Word32 abs_spectrum[], /* i : absolute spectrum Q31-e */ + const Word16 *spectrum_e, /* i : absolute spectrum exponent Q0 */ + const Word16 L_frame, /* i : number of spectral lines Q0 */ Word32 env[], /* i/o: envelope shape Q16 */ - const Word16 targetBits, /* i: target bit budget Q0 */ - const Word16 coder_type, /* i: coder type Q0 */ - Word16 prm_hm[], /* o: HM parameters Q0 */ - const Word16 LtpPitchLag, /* i: LTP pitch lag or -1 if none Q0 */ - const Word16 LtpGain, /* i: LTP gain Q15 */ - Word16 *hm_bits_out /* o: bit consumption Q0 */ + const Word16 targetBits, /* i : target bit budget Q0 */ + const Word16 coder_type, /* i : oder type Q0 */ + Word16 prm_hm[], /* o : HM parameters Q0 */ + const Word16 LtpPitchLag, /* i : LTP pitch lag or -1 if none Q0 */ + const Word16 LtpGain, /* i : LTP gain Q15 */ + Word16 *hm_bits_out /* o : bit consumption Q0 */ ) { Word32 lag; @@ -750,7 +755,6 @@ void tcx_hm_analyse_fx( Word16 p[2 * kTcxHmParabolaHalfWidth + 1]; /* Q13 */ Word16 hm_bits, bw_flag; - /* Disable HM for non-GENERC, VOICED coder types */ if ( LT_16( coder_type, VOICED ) ) { @@ -774,46 +778,20 @@ void tcx_hm_analyse_fx( hm_bits = 1; move16(); move16(); - prm_hm[1] = tcx_hm_search( - abs_spectrum, - L_frame, - sub( targetBits, hm_bits ), - LtpPitchLag, - LtpGain, - &RelativeScore ); + prm_hm[1] = tcx_hm_search( abs_spectrum, L_frame, sub( targetBits, hm_bits ), LtpPitchLag, LtpGain, &RelativeScore ); /* Convert the index to lag */ - UnmapIndex( - prm_hm[1], - bw_flag, - LtpPitchLag, - ( ( LE_16( sub( targetBits, hm_bits ), kSmallerLagsTargetBitsThreshold ) ) || !bw_flag ), - &fract_res, - &lag ); + UnmapIndex( prm_hm[1], bw_flag, LtpPitchLag, ( ( LE_16( sub( targetBits, hm_bits ), kSmallerLagsTargetBitsThreshold ) ) || !bw_flag ), &fract_res, &lag ); test(); /* Render harmonic model */ - tcx_hm_render( - lag, - fract_res, - p ); + tcx_hm_render( lag, fract_res, p ); /* Calculate and quantize gain */ gain = 0; move16(); - tcx_hm_quantize_gain( - abs_spectrum, - spectrum_e, - env, - lag, - fract_res, - p, - L_frame, - coder_type, - RelativeScore, - &prm_hm[2], - &gain ); + tcx_hm_quantize_gain( abs_spectrum, spectrum_e, env, lag, fract_res, p, L_frame, coder_type, RelativeScore, &prm_hm[2], &gain ); /* Decision */ IF( gain > 0 ) @@ -828,13 +806,7 @@ void tcx_hm_analyse_fx( hm_bits = add( hm_bits, kTcxHmNumGainBits ); } - tcx_hm_modify_envelope( - gain, - lag, - fract_res, - p, - env, - L_frame ); + tcx_hm_modify_envelope( gain, lag, fract_res, p, env, L_frame ); } ELSE { @@ -848,4 +820,6 @@ void tcx_hm_analyse_fx( *hm_bits_out = hm_bits; move16(); + + return; } diff --git a/lib_enc/arith_coder_enc_fx.c b/lib_enc/arith_coder_enc_fx.c index b8c55ee1b82080e409abbe126116fe3d1cac4e74..17183543e6127e744ed5b895a098bf22294babdc 100644 --- a/lib_enc/arith_coder_enc_fx.c +++ b/lib_enc/arith_coder_enc_fx.c @@ -37,13 +37,14 @@ typedef struct Heap * * Returns: estimated SQ scale Q15-e *-------------------------------------------------------------------*/ + static Word16 tcx_arith_estimate_scale( - const Word32 abs_spectrum[], /* i: absolute MDCT coefficients Q31-e */ - const Word16 abs_spectrum_e, /* i: MDCT exponent Q0 */ - const Word16 L_frame, /* i: number of spectral lines Q0 */ - const Word16 envelope[], /* i: scaled envelope Q15-e */ - const Word16 envelope_e, /* i: scaled envelope exponent Q0 */ - Word16 *scale_e /* o: scale exponent Q0 */ + const Word32 abs_spectrum[], /* i : absolute MDCT coefficients Q31-e */ + const Word16 abs_spectrum_e, /* i : MDCT exponent Q0 */ + const Word16 L_frame, /* i : number of spectral lines Q0 */ + const Word16 envelope[], /* i : scaled envelope Q15-e */ + const Word16 envelope_e, /* i : scaled envelope exponent Q0 */ + Word16 *scale_e /* o : scale exponent Q0 */ ) { Word16 scale, tmp, k, s, s1; @@ -100,12 +101,16 @@ static Word16 tcx_arith_estimate_scale( return scale; } + /*-------------------------------------------------------------------* * MinHeapify_i() * * *-------------------------------------------------------------------*/ -static void MinHeapify_i( Heap *H, Word16 i ) + +static void MinHeapify_i( + Heap *H, + Word16 i ) { Word16 left, right, largest; HeapElem T; @@ -161,21 +166,27 @@ static void MinHeapify_i( Heap *H, Word16 i ) move16(); } } + + return; } + + /*-------------------------------------------------------------------* * tcx_arith_find_max_scale() * * *-------------------------------------------------------------------*/ -static Word16 tcx_arith_find_max_scale( /* Q15-e */ - const Word32 abs_spectrum[], /* i: absolute MDCT coefficients Q31-e */ - const Word16 abs_spectrum_e, /* i: MDCT exponent Q0 */ - const Word16 L_frame, /* i: number of spectral lines Q0 */ - const Word16 envelope[], /* i: scaled envelope Q15-e */ - const Word16 envelope_e, /* i: scaled envelope exponent Q0 */ - const Word16 exps[], /* i: expfp(-(int)envelope[]/2) Q15 */ - const Word16 deadzone, /* i: deadzone (0.5f = no deadzone) Q15 */ - Word16 *scale_e /* o: scale exponent Q0 */ + +/* Q15-e */ +static Word16 tcx_arith_find_max_scale( + const Word32 abs_spectrum[], /* i : absolute MDCT coefficients Q31-e */ + const Word16 abs_spectrum_e, /* i : MDCT exponent Q0 */ + const Word16 L_frame, /* i : number of spectral lines Q0 */ + const Word16 envelope[], /* i : scaled envelope Q15-e */ + const Word16 envelope_e, /* i : scaled envelope exponent Q0 */ + const Word16 exps[], /* i : expfp(-(int)envelope[]/2) Q15 */ + const Word16 deadzone, /* i : deadzone (0.5f = no deadzone) Q15 */ + Word16 *scale_e /* o : scale exponent Q0 */ ) { Word16 i, k, q, scale, tmp, s; @@ -184,6 +195,7 @@ static Word16 tcx_arith_find_max_scale( /* Q15-e * Word16 tmpi1, tmpi2; const Word32 limit = -325614240l /*-9.70406052784f Q25*/; /* = ln(1/16384): log of smallest allowed probability */ move32(); + /* Find the top most offending lines according to probability estimates */ FOR( i = 0; i < kMaxNumHeapElems; i++ ) { @@ -286,29 +298,30 @@ static Word16 tcx_arith_find_max_scale( /* Q15-e * } } - return scale; } + + /*-------------------------------------------------------------------* * tcx_arith_find_kMax() * * * Returns: index of highest freq. nonzero line (-1 if all zeros) *-------------------------------------------------------------------*/ + static Word16 tcx_arith_find_kMax( - const Word32 abs_spectrum[], /* i: absolute MDCT coefficients Q31-e */ - const Word16 abs_spectrum_e, /* i: MDCT exponent Q0 */ - const Word16 L_frame, /* i: number of spectral lines Q0 */ - const Word16 scale, /* i: scalar quantizer scale Q15-e */ - const Word16 scale_e, /* i: scale exponent Q0 */ - const Word16 deadzone, /* i: deadzone (0.5f = no deadzone) Q15 */ - const Word8 deadzone_flags[] /* i: line-wise deadzone control */ + const Word32 abs_spectrum[], /* i : absolute MDCT coefficients Q31-e */ + const Word16 abs_spectrum_e, /* i : MDCT exponent Q0 */ + const Word16 L_frame, /* i : number of spectral lines Q0 */ + const Word16 scale, /* i : scalar quantizer scale Q15-e */ + const Word16 scale_e, /* i : scale exponent Q0 */ + const Word16 deadzone, /* i : deadzone (0.5f = no deadzone) Q15 */ + const Word8 deadzone_flags[] /* i : line-wise deadzone control */ ) { Word16 kMax; Word32 tmp[2]; - move32(); move32(); tmp[0] = L_shr( L_mac( 0x7FFFFFFF, deadzone, (Word16) 0x8000 ), abs_spectrum_e ); /* 1.0f - deadzone scaled to MDCT exponent */ @@ -322,28 +335,29 @@ static Word16 tcx_arith_find_kMax( } } - return kMax; } + /*-------------------------------------------------------------------* * tcx_arith_rateloop() * * * Returns: best scale Q15-e *-------------------------------------------------------------------*/ + static Word16 tcx_arith_rateloop( - const Word32 abs_spectrum[], /* i: absolute MDCT coefficients Q31-e */ - const Word16 abs_spectrum_e, /* i: MDCT exponent Q0 */ - const Word16 L_frame, /* i: number of spectral lines Q0 */ - const Word16 envelope[], /* i: scaled envelope Q15-e */ - const Word16 envelope_e, /* i: scaled envelope exponent Q0 */ - const Word16 exps[], /* i: expfp(-(int)envelope[]/2) Q15 */ - const Word16 target_bits, /* i: target bit budget Q0 */ - const Word16 deadzone, /* i: deadzone (0.5f = no deadzone) Q15 */ - const Word8 deadzone_flags[], /* i: line-wise deadzone control Q0 */ - Word16 *target_bits_fac, /* i/o: scale estimator compensation Q14 */ - Word16 *scale_e /* o: scale exponent Q0 */ + const Word32 abs_spectrum[], /* i : absolute MDCT coefficients Q31-e */ + const Word16 abs_spectrum_e, /* i : MDCT exponent Q0 */ + const Word16 L_frame, /* i : number of spectral lines Q0 */ + const Word16 envelope[], /* i : scaled envelope Q15-e */ + const Word16 envelope_e, /* i : scaled envelope exponent Q0 */ + const Word16 exps[], /* i : expfp(-(int)envelope[]/2) Q15 */ + const Word16 target_bits, /* i : target bit budget Q0 */ + const Word16 deadzone, /* i : deadzone (0.5f = no deadzone) Q15 */ + const Word8 deadzone_flags[], /* i : line-wise deadzone control Q0 */ + Word16 *target_bits_fac, /* i/o: scale estimator compensation Q14 */ + Word16 *scale_e /* o : scale exponent Q0 */ ) { Word16 k, kMax, q; @@ -497,20 +511,23 @@ static Word16 tcx_arith_rateloop( return scale_best; } + + /*-------------------------------------------------------------------* * tcx_arith_encode() * * * Returns: number of bits consumed *-------------------------------------------------------------------*/ + static Word16 tcx_arith_encode( - Word16 q_abs_spectrum[], /* i/o: scalar quantized absolute spectrum Q0 */ - const Word16 signs[], /* i: signs */ - const Word16 kMax, /* i: number of nonzero spectral lines to code Q0 */ - Word16 L_frame, /* i: nominal number of spectral lines Q0 */ - const Word16 exps[], /* i: expfp(-(int)envelope[]/2) Q15 */ - Word16 target_bits, /* i: target bit budget Q0 */ - Word16 prm[] /* o: bit-stream Q0 */ + Word16 q_abs_spectrum[], /* i/o: scalar quantized absolute spectrum Q0 */ + const Word16 signs[], /* i : signs */ + const Word16 kMax, /* i : number of nonzero spectral lines to code Q0 */ + Word16 L_frame, /* i : nominal number of spectral lines Q0 */ + const Word16 exps[], /* i : expfp(-(int)envelope[]/2) Q15*/ + Word16 target_bits, /* i : target bit budget Q0 */ + Word16 prm[] /* o : bit-stream Q0 */ ) { TastatEnc as, as_lastgood; @@ -519,7 +536,6 @@ static Word16 tcx_arith_encode( Word16 kEncoded; Word16 tmpi1, tmpi2; - /* Final coding */ ari_start_encoding_14bits_fx( &as ); ari_copy_states_fx( &as, &as_lastgood ); @@ -551,6 +567,7 @@ static Word16 tcx_arith_encode( bp = ari_encode_14bits_range_fx( prm, bp, target_bits, &as, shr( tmpi2, 1 ), shr( tmpi1, 1 ) ); bp = ari_encode_14bits_sign_fx( prm, bp, target_bits, &as, signs[k] ); } + /* Check bit budget status */ IF( ari_encode_overflow_fx( &as ) ) /* no bits left */ { @@ -631,30 +648,34 @@ static Word16 tcx_arith_encode( /* Limit target bits to actually needed bits */ target_bits = add( add( bp, 16 ), extract_l( as.value ) ); } + return ari_done_cbr_encoding_14bits_fx( prm, bp, target_bits, &as ); } + + /*-------------------------------------------------------------------* * tcx_arith_encode_envelope_fx() * * *-------------------------------------------------------------------*/ + void tcx_arith_encode_envelope_fx( - Word32 spectrum[], /* i/o: MDCT coefficients Q31-e */ - Word16 *spectrum_e, /* i/o: MDCT exponent Q0 */ - Word16 signs[], /* o: signs (spectrum[.]<0) Q0 */ - const Word16 L_frame, /* i: frame or MDCT length Q0 */ - const Word16 L_spec, /* i: frame or MDCT length Q0 */ - Encoder_State *st, /* i/o: coder state */ - const Word16 A_ind[], /* i: quantised LPC coefficients Q12 */ - Word16 target_bits, /* i: number of available bits Q0 */ - Word16 prm[], /* o: bitstream parameters Q0 */ - const Word8 use_hm, /* i: use HM in current frame? */ - Word16 prm_hm[], /* o: HM parameter area Q0 */ - const Word16 tcxltp_pitch, /* i: TCX LTP pitch in FD, -1 if n/a Q0*/ - Word16 *arith_bits, /* o: bits used for ari. coding Q0 */ - Word16 *signaling_bits, /* o: bits used for signaling Q0 */ - Word16 *nf_seed, /* o: noise filling seed Q0 */ - const Word16 low_complexity /* i: low-complexity flag Q0 */ + Word32 spectrum[], /* i/o: MDCT coefficients Q31-e */ + Word16 *spectrum_e, /* i/o: MDCT exponent Q0 */ + Word16 signs[], /* o : signs (spectrum[.]<0) Q0 */ + const Word16 L_frame, /* i : frame or MDCT length Q0 */ + const Word16 L_spec, /* i : frame or MDCT length Q0 */ + Encoder_State *st, /* i/o: coder state */ + const Word16 A_ind[], /* i : quantised LPC coefficients Q12 */ + Word16 target_bits, /* i : number of available bits Q0 */ + Word16 prm[], /* o : bitstream parameters Q0 */ + const Word8 use_hm, /* i : use HM in current frame? */ + Word16 prm_hm[], /* o : HM parameter area Q0 */ + const Word16 tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a Q0*/ + Word16 *arith_bits, /* o : bits used for ari. coding Q0 */ + Word16 *signaling_bits, /* o : bits used for signaling Q0 */ + Word16 *nf_seed, /* o : noise filling seed Q0 */ + const Word16 low_complexity /* i : low-complexity flag Q0 */ ) { Word32 env[N_MAX_ARI]; /* unscaled envelope (Q16) */ @@ -776,24 +797,27 @@ void tcx_arith_encode_envelope_fx( /* noise filling seed */ *nf_seed = extract_l( W_extract_l( W_tmp2 ) ); move16(); + + return; } + void tcx_arith_encode_envelope_ivas_fx( - Word32 spectrum[], /* i/o: MDCT coefficients Q31-e */ - Word16 *spectrum_e, /* i/o: MDCT exponent Q0 */ - Word16 signs[], /* o: signs (spectrum[.]<0) Q0 */ - const Word16 L_frame, /* i: frame or MDCT length Q0 */ - const Word16 L_spec, /* i: frame or MDCT length Q0 */ - Encoder_State *st, /* i/o: coder state */ - const Word16 A_ind[], /* i: quantised LPC coefficients Q12 */ - Word16 target_bits, /* i: number of available bits Q0 */ - Word16 prm[], /* o: bitstream parameters Q0 */ - const Word8 use_hm, /* i: use HM in current frame? */ - Word16 prm_hm[], /* o: HM parameter area Q0 */ - const Word16 tcxltp_pitch, /* i: TCX LTP pitch in FD, -1 if n/a Q0*/ - Word16 *arith_bits, /* o: bits used for ari. coding Q0 */ - Word16 *signaling_bits, /* o: bits used for signaling Q0 */ - const Word16 low_complexity /* i: low-complexity flag Q0 */ + Word32 spectrum[], /* i/o: MDCT coefficients Q31-e */ + Word16 *spectrum_e, /* i/o: MDCT exponent Q0 */ + Word16 signs[], /* o : signs (spectrum[.]<0) Q0 */ + const Word16 L_frame, /* i : frame or MDCT length Q0 */ + const Word16 L_spec, /* i : frame or MDCT length Q0 */ + Encoder_State *st, /* i/o: coder state */ + const Word16 A_ind[], /* i : quantised LPC coefficients Q12 */ + Word16 target_bits, /* i : number of available bits Q0 */ + Word16 prm[], /* o : bitstream parameters Q0 */ + const Word8 use_hm, /* i : use HM in current frame? */ + Word16 prm_hm[], /* o : HM parameter area Q0 */ + const Word16 tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a Q0*/ + Word16 *arith_bits, /* o : bits used for ari. coding Q0 */ + Word16 *signaling_bits, /* o : bits used for signaling Q0 */ + const Word16 low_complexity /* i : low-complexity flag Q0 */ ) { Word32 env[N_MAX_ARI]; /* unscaled envelope (Q16) */ @@ -904,7 +928,10 @@ void tcx_arith_encode_envelope_ivas_fx( spectrum[k] = L_tmp; move32(); } + *spectrum_e = SPEC_EXP_DEC; move16(); set32_fx( spectrum + k, 0, sub( s_max( L_frame, L_spec ), k ) ); + + return; } diff --git a/lib_enc/cod4t64_fx.c b/lib_enc/cod4t64_fx.c index ac494e1604e858bc94d80eaee0a18abc5f543945..f485463a4f65e6658e4f5601d2a04e3d1a7a2339 100644 --- a/lib_enc/cod4t64_fx.c +++ b/lib_enc/cod4t64_fx.c @@ -573,9 +573,9 @@ static Word32 fcb_encode_class_fx( /* o: return index of the positions which have pulse*/ static Word32 fcb_encode_position_fx( - const Word16 pos_vector[], /* i: position of the pulse on a track */ + const Word16 pos_vector[], /* i : position of the pulse on a track */ Word32 n, - const Word32 pos_num, /* i: the number of position which have pulse */ + const Word32 pos_num, /* i : the number of position which have pulse */ const Word32 flag ) { Word32 i; diff --git a/lib_enc/enc_acelp_fx.c b/lib_enc/enc_acelp_fx.c index 0f4e772534fcb5eb5a9ff452ca4899210a21de8e..52e42582c3ce33e25db2f2105b03646f7eb01624 100644 --- a/lib_enc/enc_acelp_fx.c +++ b/lib_enc/enc_acelp_fx.c @@ -1553,11 +1553,11 @@ void E_ACELP_4t_fx( static void E_ACELP_indexing_shift( - Word16 wordcnt, /* i: 16-bit word count including the newly shifted-in bits Q0*/ - Word16 shift_bits, /* i: number of bits to shift in from the lsb Q0*/ - UWord16 lsb_bits, /* i: bits to shift in from the lsb Q0*/ - const UWord16 src[], /* i: source buffer Q0*/ - UWord16 dst[] /* o: destination buffer Q(shift_bits)*/ + Word16 wordcnt, /* i : 16-bit word count including the newly shifted-in bits Q0*/ + Word16 shift_bits, /* i : number of bits to shift in from the lsb Q0*/ + UWord16 lsb_bits, /* i : bits to shift in from the lsb Q0*/ + const UWord16 src[], /* i : source buffer Q0*/ + UWord16 dst[] /* o : destination buffer Q(shift_bits)*/ ) { Word16 right_shift, i; diff --git a/lib_enc/enc_gen_voic_rf_fx.c b/lib_enc/enc_gen_voic_rf_fx.c index 82794098a07a30943cc926d68f25395a3a8a8766..cf4b3825999b595f31aa53689685102ef88fbae2 100644 --- a/lib_enc/enc_gen_voic_rf_fx.c +++ b/lib_enc/enc_gen_voic_rf_fx.c @@ -14,7 +14,7 @@ void reset_rf_indices_fx( - Encoder_State *st /* i: state structure - contains partial RF indices */ + Encoder_State *st /* i : state structure - contains partial RF indices */ ) { RF_ENC_HANDLE hRF = st->hRF; @@ -112,17 +112,18 @@ void reset_rf_indices_fx( * * Encode excitation signal (partial redundancy) *-------------------------------------------------------------------*/ + void coder_acelp_rf_fx( - ACELP_config *acelp_cfg, /*input/output: configuration of the ACELP coding*/ - const Word16 coder_type, /* input: coding type Q0*/ - const Word16 A[], /* input: coefficients 4xAz[M+1] Q12*/ - const Word16 Aq[], /* input: coefficients 4xAz_q[M+1] Q12*/ - Word16 speech[], /* input: speech[-M..lg] Q_new-1*/ - const Word16 voicing[], /* input: open-loop LTP gain Q15*/ - const Word16 T_op[], /* input: open-loop LTP lag Q0*/ + ACELP_config *acelp_cfg, /* i/o: configuration of the ACELP coding*/ + const Word16 coder_type, /* i : coding type Q0*/ + const Word16 A[], /* i : coefficients 4xAz[M+1] Q12*/ + const Word16 Aq[], /* i : coefficients 4xAz_q[M+1] Q12*/ + Word16 speech[], /* i : speech[-M..lg] Q_new-1*/ + const Word16 voicing[], /* i : open-loop LTP gain Q15*/ + const Word16 T_op[], /* i : open-loop LTP lag Q0*/ Word16 stab_fac, /* Q15 */ Encoder_State *st, - Word16 target_bits, /* i/o : coder memory state Q0*/ + Word16 target_bits, /* i/o: coder memory state Q0*/ const Word16 rf_frame_type, /* i : rf_frame_type Q0*/ Word16 *exc_rf, /* i/o: pointer to RF excitation Q_new*/ Word16 *syn_rf, /* i/o: pointer to RF synthesis Q_new-1*/ @@ -192,11 +193,13 @@ void coder_acelp_rf_fx( /*-----------------------------------------------------------------------* * Configure ACELP partial copy * *------------------------------------------------------------------------*/ + tmp2 = BITS_ALLOC_config_acelp( target_bits, rf_frame_type, &( hRF->acelp_cfg_rf ), 0, st->nb_subfr ); /* Q0 */ /* Init Framing parameters */ L_frame = st->L_frame; /* Q0 */ move16(); + /*------------------------------------------------------------------------* * Initialize buffers * *------------------------------------------------------------------------*/ @@ -289,6 +292,7 @@ void coder_acelp_rf_fx( * Gain clipping test to avoid unstable synthesis on frame erasure * or in case of floating point encoder & fixed p. decoder *-----------------------------------------------------------------*/ + /* full frame nelp partial copy encoding */ IF( EQ_16( rf_frame_type, RF_NELP ) ) { @@ -368,10 +372,10 @@ void coder_acelp_rf_fx( move16(); } - /*----------------------------------------------------------------------* * Encode the algebraic innovation * *----------------------------------------------------------------------*/ + IF( acelp_cfg->fixed_cdk_index[i_subfr / L_SUBFR] >= 0 ) { prm_rf = &hRF->rf_indx_fcb[0][nSubfr]; @@ -398,6 +402,7 @@ void coder_acelp_rf_fx( /*----------------------------------------------------------------------* * Add Gaussian excitation * *----------------------------------------------------------------------*/ + gain_code2 = L_deposit_l( 0 ); set16_fx( code2, 0, L_SUBFR ); set16_fx( y22, 0, L_SUBFR ); @@ -510,9 +515,7 @@ void coder_acelp_rf_fx( move16(); } - } /* end of subframe loop */ - return; } diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c index 18e3e503c04f0557e41127afecef36acab14d946..395fdbf532cb9339036ad3d4f5479f5c29e28073 100644 --- a/lib_enc/ext_sig_ana_fx.c +++ b/lib_enc/ext_sig_ana_fx.c @@ -20,7 +20,7 @@ *-------------------------------------------------------------------*/ void core_signal_analysis_high_bitrate_fx( - const Word16 *new_samples, /*i: 0Q15*/ + const Word16 *new_samples, /*i : 0Q15*/ const Word16 T_op[3], /* i : open-loop pitch values for quantiz. Q0*/ Word16 lsp_new[], /* Q15 */ Word16 lsp_mid[], /* Q15 */ @@ -469,7 +469,7 @@ void core_signal_analysis_high_bitrate_fx( *-------------------------------------------------------------------*/ void core_signal_analysis_high_bitrate_ivas_fx( - const Word16 *new_samples, /*i: Q0 */ + const Word16 *new_samples, /*i : Q0 */ const Word16 T_op[3], /* i : open-loop pitch values for quantiz. Q0*/ Word16 lsp_new[], /* Q15 */ Word16 lsp_mid[], /* Q15 */ diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index 5075dd46cbf3b31293a9fd40614c2c047f775e38..279abc887e7d5c0d38a6e5ebc0cb4815672ebbbe 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -169,7 +169,7 @@ void initFdCngEnc_fx( void configureFdCngEnc_fx( HANDLE_FD_CNG_ENC hsEnc, /* i/o: Contains the variables related to the FD-based CNG process */ - const Word16 bandwidth, /* i: bandwidth Q0*/ + const Word16 bandwidth, /* i : bandwidth Q0*/ const Word32 bitrate /* Q0 */ ) { @@ -531,6 +531,8 @@ void resetFdCngEnc_fx( st->fd_cng_reset_flag = 0; move16(); } + + return; } /* @@ -538,12 +540,12 @@ void resetFdCngEnc_fx( Parameters: - band_energies i: energy in critical bands without minimum noise floor MODE2_E_MIN - band_energies_exp i: exponent for energy in critical bands without minimum noise floor MODE2_E_MIN - cldfbBufferReal, i: real part of the CLDFB buffer - cldfbBufferImag, i: imaginary part of the CLDFB buffer - cldfbBufferExp, i: exponent for CLDFB buffer - bitrate i: bitrate + band_energies i : energy in critical bands without minimum noise floor MODE2_E_MIN + band_energies_exp i : exponent for energy in critical bands without minimum noise floor MODE2_E_MIN + cldfbBufferReal, i : real part of the CLDFB buffer + cldfbBufferImag, i : imaginary part of the CLDFB buffer + cldfbBufferExp, i : exponent for CLDFB buffer + bitrate i : bitrate st i/o: FD_CNG structure containing all buffers and variables Function: @@ -552,11 +554,12 @@ void resetFdCngEnc_fx( Returns: void */ -void perform_noise_estimation_enc_fx( Word32 *band_energies, /* i: energy in critical bands without minimum noise floor MODE2_E_MIN band_energies_exp*/ - Word16 band_energies_exp, /* i: exponent for energy in critical bands without minimum noise floor MODE2_E_MIN */ - Word32 *enerBuffer, /* enerBuffer_exp */ - Word16 enerBuffer_exp, - HANDLE_FD_CNG_ENC st /* i/o: FD_CNG structure containing all buffers and variables */ +void perform_noise_estimation_enc_fx( + Word32 *band_energies, /* i : energy in critical bands without minimum noise floor MODE2_E_MIN band_energies_exp*/ + Word16 band_energies_exp, /* i : exponent for energy in critical bands without minimum noise floor MODE2_E_MIN */ + Word32 *enerBuffer, /* enerBuffer_exp */ + Word16 enerBuffer_exp, + HANDLE_FD_CNG_ENC st /* i/o: FD_CNG structure containing all buffers and variables */ ) { Word16 i, j, s, s1, s2; @@ -571,7 +574,6 @@ void perform_noise_estimation_enc_fx( Word32 *band_energies, /* i: energy in Word32 *ptr_per; Word32 *msPeriodog; - nFFTpart = st->hFdCngCom->nFFTpart; move16(); nCLDFBpart = st->hFdCngCom->nCLDFBpart; @@ -690,6 +692,8 @@ void perform_noise_estimation_enc_fx( Word32 *band_energies, /* i: energy in /* Expand MS outputs */ expand_range( st->msLogNoiseEst_fx, st->msNoiseEst_fx, &st->msNoiseEst_fx_exp, st->hFdCngCom->npart ); + + return; } /* @@ -832,7 +836,6 @@ Word16 AdjustFirstSID_fx( move16(); } - return 0; } @@ -858,14 +861,15 @@ Word16 AdjustFirstSID_fx( Returns: void */ -static void msvq_encoder( const Word16 *const cb[], /* i : Codebook (indexed cb[*stages][levels][p]) scaled with 8 bits Q9.7*/ - Word16 u[], /* i : Vector to be encoded (prediction and mean removed) Q9.7*/ - const Word16 levels[], /* i : Number of levels in each stage Q0*/ - Word16 maxC, /* i : Tree search size Q0*/ - Word16 stages, /* i : Number of stages Q0*/ - Word16 N, /* i : Vector dimension Q0*/ - Word16 maxN, /* i : Codebook vector dimension Q0*/ - Word16 Idx[] /* o : Indices Q0*/ +static void msvq_encoder( + const Word16 *const cb[], /* i : Codebook (indexed cb[*stages][levels][p]) scaled with 8 bits Q9.7*/ + Word16 u[], /* i : Vector to be encoded (prediction and mean removed) Q9.7*/ + const Word16 levels[], /* i : Number of levels in each stage Q0*/ + Word16 maxC, /* i : Tree search size Q0*/ + Word16 stages, /* i : Number of stages Q0*/ + Word16 N, /* i : Vector dimension Q0*/ + Word16 maxN, /* i : Codebook vector dimension Q0*/ + Word16 Idx[] /* o : Indices Q0*/ ) { Word32 *dist[2]; @@ -879,7 +883,6 @@ static void msvq_encoder( const Word16 *const cb[], /* i : Codebook (indexed cb Word16 resid_buf[2 * MBEST_MAX * M_MAX]; Word16 idx_buf[2 * MBEST_MAX * NSTAGES_MAX]; - /*----------------------------------------------------------------* * Allocate memory for previous (parent) and current nodes. * Parent node is indexed [0], current node is indexed [1]. @@ -1046,6 +1049,8 @@ static void msvq_encoder( const Word16 *const cb[], /* i : Codebook (indexed cb } Copy( indices[1] + c2 * stages, Idx, stages ); + + return; } @@ -1068,9 +1073,10 @@ static void msvq_encoder( const Word16 *const cb[], /* i : Codebook (indexed cb Returns: void */ -void FdCng_encodeSID_fx( HANDLE_FD_CNG_ENC stenc, /* i/o: pointer to FD_CNG structure containing all buffers and variables */ - Encoder_State *corest, - Word16 preemph_fac /* i : preemphase factor */ +void FdCng_encodeSID_fx( + HANDLE_FD_CNG_ENC stenc, /* i/o: pointer to FD_CNG structure containing all buffers and variables */ + Encoder_State *corest, + Word16 preemph_fac /* i : preemphase factor */ ) { Word16 i, index, N; @@ -1119,7 +1125,6 @@ void FdCng_encodeSID_fx( HANDLE_FD_CNG_ENC stenc, /* i/o: pointer to FD_CNG stru } e = L_shl( Mpy_32_16_1( e, shl( normFacN, sub( normShiftN, 1 ) ) ), 1 ); - /* Normalize MSVQ input */ /* gain: Q9.23 format */ @@ -1135,19 +1140,17 @@ void FdCng_encodeSID_fx( HANDLE_FD_CNG_ENC stenc, /* i/o: pointer to FD_CNG stru v16[i] = extract_h( L_sub( v[i], gain ) ); } - { - /* MSVQ encoder */ - msvq_encoder( cdk_37bits, v16, levels_37bits, maxC_37bits, stages_37bits, N, maxN_37bits, indices ); + /* MSVQ encoder */ + msvq_encoder( cdk_37bits, v16, levels_37bits, maxC_37bits, stages_37bits, N, maxN_37bits, indices ); + + /* MSVQ decoder */ + msvq_decoder( cdk_37bits, stages_37bits, N, maxN_37bits, indices, v16 ); - /* MSVQ decoder */ - msvq_decoder( cdk_37bits, stages_37bits, N, maxN_37bits, indices, v16 ); - } FOR( i = 0; i < N; i++ ) { v[i] = L_deposit_h( v16[i] ); } - /* Compute gain, Q9.23 format */ gain = 0; FOR( i = 0; i < N; i++ ) @@ -1268,14 +1271,16 @@ void FdCng_encodeSID_fx( HANDLE_FD_CNG_ENC stenc, /* i/o: pointer to FD_CNG stru st->cngNoiseLevelExp = st->sidNoiseEstExp; move16(); - lpc_from_spectrum( st, stenc->startBandDec, stenc->stopFFTbinDec, preemph_fac ); + + return; } -void generate_comfort_noise_enc_fx( Encoder_State *stcod, - Word16 Q_new, - Word16 gen_exc ) +void generate_comfort_noise_enc_fx( + Encoder_State *stcod, + Word16 Q_new, + Word16 gen_exc ) { Word16 i, s, sn, cnt; Word16 startBand2; @@ -1459,7 +1464,6 @@ void generate_comfort_noise_enc_fx( Encoder_State *stcod, Word16 noise[640], normShiftP2; Word16 Q_exc, Q_syn; - assert( st->frameSize <= 640 ); seed_loc = st->seed; @@ -1652,11 +1656,15 @@ void generate_comfort_noise_enc_fx( Encoder_State *stcod, } } } + + return; } -void generate_comfort_noise_enc_ivas_fx( Encoder_State *stcod, - Word16 Q_new, - Word16 gen_exc ) + +void generate_comfort_noise_enc_ivas_fx( + Encoder_State *stcod, + Word16 Q_new, + Word16 gen_exc ) { Word16 i, s, sn, cnt; Word16 startBand2; @@ -1845,7 +1853,6 @@ void generate_comfort_noise_enc_ivas_fx( Encoder_State *stcod, Word16 noise[640], normShiftP2; Word16 Q_exc, Q_syn; - assert( st->frameSize <= 640 ); seed_loc = st->seed; @@ -2040,8 +2047,11 @@ void generate_comfort_noise_enc_ivas_fx( Encoder_State *stcod, } } } + + return; } + /*-------------------------------------------------------------------* * cng_energy_fx() * @@ -2134,6 +2144,7 @@ Word16 cng_energy_fx( } enr = sub( enr, att ); } + return enr; } @@ -2231,11 +2242,13 @@ Word16 cng_energy_ivas_fx( } enr = sub( enr, att ); } + return enr; } + void perform_noise_estimation_enc_ivas_fx( - Word32 *band_energies, /* i: energy in critical bands without minimum noise floor MODE2_E_MIN band_energies_exp*/ + Word32 *band_energies, /* i : energy in critical bands without minimum noise floor MODE2_E_MIN band_energies_exp*/ Word16 band_energies_exp, Word32 *enerBuffer, /* enerBuffer_exp */ Word16 enerBuffer_exp, diff --git a/lib_enc/guided_plc_enc_fx.c b/lib_enc/guided_plc_enc_fx.c index db33f6c6301524cb28f44dfe811e584af092315c..826d8e0f3561b00825bcc16480fa4162230f7637 100644 --- a/lib_enc/guided_plc_enc_fx.c +++ b/lib_enc/guided_plc_enc_fx.c @@ -18,11 +18,11 @@ * *-------------------------------------------------------------------*/ static void coderLookAheadInnovation( - Word16 A_3Q12[], /* input: coefficients NxAz[M+1] Q12*/ - Word16 *pT, /* out: pitch Q0*/ - PLC_ENC_EVS_HANDLE st, /* i/o: coder memory state */ - Word16 *speechLookAhead_Qx, /* i: input speech in Q(st->Qold) */ - Word16 *old_exc, /* i: input excitation in Q(st->Qold) */ + Word16 A_3Q12[], /* i : coefficients NxAz[M+1] Q12*/ + Word16 *pT, /* o : pitch Q0*/ + PLC_ENC_EVS_HANDLE st, /* i/o: coder memory state */ + Word16 *speechLookAhead_Qx, /* i : input speech in Q(st->Qold) */ + Word16 *old_exc, /* i : input excitation in Q(st->Qold) */ Word16 L_frame ) { Word16 i; diff --git a/lib_enc/hq_lr_enc_fx.c b/lib_enc/hq_lr_enc_fx.c index 74a3a15dfe24a4ef7a0d5b1530454c8f28e7ccc9..7da3d34158db7fdc5f847c9e783b9573567833c6 100644 --- a/lib_enc/hq_lr_enc_fx.c +++ b/lib_enc/hq_lr_enc_fx.c @@ -30,16 +30,16 @@ static void mdct_spectrum_fine_gain_enc_fx( Encoder_State *st_fx, const Word32 L *--------------------------------------------------------------------------*/ static void spt_shorten_domain_set_fx( - Encoder_State *st_fx, /* i: encoder state structure */ - const Word32 L_t_audio[], /* i: input spectrum Q12*/ - const Word16 p2a_flags[], /* i: p2a anlysis information Q0*/ - const Word16 new_band_start[], /* i: new band start position Q0*/ - const Word16 new_band_end[], /* i: new band end position Q0*/ - const Word16 new_band_width[], /* i: new subband band width Q0*/ - const Word16 bands, /* i: total number of subbands Q0*/ + Encoder_State *st_fx, /* i : encoder state structure */ + const Word32 L_t_audio[], /* i : input spectrum Q12*/ + const Word16 p2a_flags[], /* i : p2a anlysis information Q0*/ + const Word16 new_band_start[], /* i : new band start position Q0*/ + const Word16 new_band_end[], /* i : new band end position Q0*/ + const Word16 new_band_width[], /* i : new subband band width Q0*/ + const Word16 bands, /* i : total number of subbands Q0*/ Word16 band_start[], /* i/o: band start position Q0*/ Word16 band_end[], /* i/o: band end position Q0*/ - Word16 band_width[], /* i: sub band band width Q0*/ + Word16 band_width[], /* i : sub band band width Q0*/ Word16 *bit_budget /* i/o: bit budget Q0*/ ) { @@ -1009,13 +1009,14 @@ void hq_lr_enc_fx( * if flag_pack = 0, estimatng else packing bits *--------------------------------------------------------------------------*/ -static Word16 small_symbol_enc_tran_fx( /* o : bits */ - BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */ - const Word16 *qbidx, /* i : input of dequantized differential energy Q0*/ - const Word16 BANDS, /* i : number of bands Q0*/ - Word16 *hLCmode, /* i/o: LC mode info Q0*/ - const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0*/ - const Word16 is_transient /* Q0 */ ) +/* o : bits */ +static Word16 small_symbol_enc_tran_fx( + BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */ + const Word16 *qbidx, /* i : input of dequantized differential energy Q0*/ + const Word16 BANDS, /* i : number of bands Q0*/ + Word16 *hLCmode, /* i/o: LC mode info Q0*/ + const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0*/ + const Word16 is_transient /* Q0 */ ) { Word16 i, bits; Word16 difidx[BANDS_MAX]; @@ -1059,17 +1060,18 @@ static Word16 small_symbol_enc_tran_fx( /* o : bits * * Huffman encoding of differential energies, estimating or packing bits * if flag_pack = 0, LC mode info. is output else LC mode info. is input - * if flag_pack = 0, estimatng else packing bits + * if flag_pack = 0, estimating else packing bits *--------------------------------------------------------------------------*/ /* o : bits */ static Word16 small_symbol_enc_fx( - BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */ - const Word16 *qbidx, /* i : input of dequantized differential energy Q0*/ - const Word16 BANDS, /* i : number of bands Q0*/ - Word16 *hLCmode, /* i/o: LC mode info Q0*/ - const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0*/ - const Word16 is_transient /* Q0 */ ) + BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */ + const Word16 *qbidx, /* i : input of dequantized differential energy Q0*/ + const Word16 BANDS, /* i : number of bands Q0*/ + Word16 *hLCmode, /* i/o: LC mode info Q0*/ + const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0*/ + const Word16 is_transient /* Q0 */ +) { Word16 i, bits; Word16 difidx[BANDS_MAX], LSB[BANDS_MAX]; diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index 72a26b2482533cde5902e0b020ed60d1f0ca799b..ac7cabe02f36b21df61eed027997dd19cd02f0f3 100755 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -69,6 +69,7 @@ static void IGF_write_bits( /**********************************************************************/ /* envelope estimation **************************************************************************/ + static void IGF_CalculateEnvelope( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ Word32 *pMDCTSpectrum, /**< in: Q31 | MDCT spectrum */ @@ -117,7 +118,6 @@ static void IGF_CalculateEnvelope( zeroNrg = 0; move16(); - IF( pPowerSpectrum != NULL ) { FOR( tile_idx = 0; tile_idx < hGrid->nTiles; tile_idx++ ) @@ -136,51 +136,20 @@ static void IGF_CalculateEnvelope( } } } - IGFCommonFuncsCalcSfbEnergyPowerSpec( hGrid->startSfb, - hGrid->stopSfb, - hGrid->swb_offset, - pPowerSpectrum, - &PowerSpectrum_e, - sfbEnergyC, - sfbEnergyC_exp ); - IGFCommonFuncsCalcSfbEnergyPowerSpec( hGrid->startSfb, - hGrid->stopSfb, - hGrid->swb_offset, - LFPowerSpectrum, - &PowerSpectrum_e, - sfbEnergyTileC, - sfbEnergyTileC_exp ); - IGFCommonFuncsMDCTSquareSpec( hGrid->startLine, - hGrid->stopLine, - LFMDCTSpectrum, - MDCTSpectrum_e, - LFMDCTSpectrum, - &LFMDCTSpectrum_exp, - 0 ); - IGFCommonFuncsCalcSfbEnergyPowerSpec( hGrid->startSfb, - hGrid->stopSfb, - hGrid->swb_offset, - LFMDCTSpectrum, - &LFMDCTSpectrum_exp, - sfbEnergyTileR, - sfbEnergyTileR_exp ); + + IGFCommonFuncsCalcSfbEnergyPowerSpec( hGrid->startSfb, hGrid->stopSfb, hGrid->swb_offset, pPowerSpectrum, &PowerSpectrum_e, sfbEnergyC, sfbEnergyC_exp ); + + IGFCommonFuncsCalcSfbEnergyPowerSpec( hGrid->startSfb, hGrid->stopSfb, hGrid->swb_offset, LFPowerSpectrum, &PowerSpectrum_e, sfbEnergyTileC, sfbEnergyTileC_exp ); + + IGFCommonFuncsMDCTSquareSpec( hGrid->startLine, hGrid->stopLine, LFMDCTSpectrum, MDCTSpectrum_e, LFMDCTSpectrum, &LFMDCTSpectrum_exp, 0 ); + + IGFCommonFuncsCalcSfbEnergyPowerSpec( hGrid->startSfb, hGrid->stopSfb, hGrid->swb_offset, LFMDCTSpectrum, &LFMDCTSpectrum_exp, sfbEnergyTileR, sfbEnergyTileR_exp ); } ELSE { - IGFCommonFuncsMDCTSquareSpec( hGrid->startLine, - hGrid->stopLine, - pMDCTSpectrum, - MDCTSpectrum_e, - LFMDCTSpectrum, - &LFMDCTSpectrum_exp, - 0 ); - IGFCommonFuncsCalcSfbEnergyPowerSpec( hGrid->startSfb, - hGrid->stopSfb, - hGrid->swb_offset, - LFMDCTSpectrum, - &LFMDCTSpectrum_exp, - sfbEnergyR, - sfbEnergyR_exp ); + IGFCommonFuncsMDCTSquareSpec( hGrid->startLine, hGrid->stopLine, pMDCTSpectrum, MDCTSpectrum_e, LFMDCTSpectrum, &LFMDCTSpectrum_exp, 0 ); + + IGFCommonFuncsCalcSfbEnergyPowerSpec( hGrid->startSfb, hGrid->stopSfb, hGrid->swb_offset, LFMDCTSpectrum, &LFMDCTSpectrum_exp, sfbEnergyR, sfbEnergyR_exp ); } FOR( tile_idx = 0; tile_idx < hGrid->nTiles; tile_idx++ ) @@ -188,8 +157,6 @@ static void IGF_CalculateEnvelope( FOR( sfb = hGrid->sfbWrap[tile_idx]; sfb < hGrid->sfbWrap[tile_idx + 1]; sfb++ ) { - - width = sub( swb_offset[sfb + 1], swb_offset[sfb] ); L_tmp = 0; move16(); @@ -242,12 +209,7 @@ static void IGF_CalculateEnvelope( zeroNrg = 1; move16(); } - BASOP_Util_Divide_MantExp( round_fx_sat( sfbEnergyR[sfb] ), - sfbEnergyR_exp[sfb], - width, - 15, - &gain, - &gain_exp ); + BASOP_Util_Divide_MantExp( round_fx_sat( sfbEnergyR[sfb] ), sfbEnergyR_exp[sfb], width, 15, &gain, &gain_exp ); L_tmp = L_deposit_h( gain ); } @@ -292,12 +254,12 @@ writes IGF SCF values /**< out: Q0 | number of bits writen */ static void IGF_WriteEnvelope( - const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ + const IGF_ENC_INSTANCE_HANDLE hInstance, /* i : | instance handle of IGF Encoder */ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 *pBitOffset, /**< in: | ptr to bitOffset counter */ - const Word16 igfGridIdx, /**< in: Q0 | igf grid index see declaration of IGF_GRID_IDX for details */ - const Word16 isIndepFlag, /**< in: Q0 | if 1 frame is independent, 0 = frame is coded with data from previous frame */ - Word16 *igfAllZero /**< in: Q0 | returns 1 if all IGF scfs are zero, else 0 */ + Word16 *pBitOffset, /* i : | ptr to bitOffset counter */ + const Word16 igfGridIdx, /* i : Q0 | igf grid index see declaration of IGF_GRID_IDX for details */ + const Word16 isIndepFlag, /* i : Q0 | if 1 frame is independent, 0 = frame is coded with data from previous frame */ + Word16 *igfAllZero /* i : Q0 | returns 1 if all IGF scfs are zero, else 0 */ ) { IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData; @@ -348,17 +310,22 @@ static void IGF_WriteEnvelope( IGFSCFEncoderRestoreContextState_fx( &hPrivateData->hIGFSCFArithEnc, igfGridIdx ); } } + + return; } + /**********************************************************************/ /* identifies significant spectral content **************************************************************************/ -void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< out: | exponent of highPassEner */ - const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ - Word32 *pSpectrum, /**< in/out: | MDCT spectrum */ - Word32 *pPowerSpectrum, /**< in/out: | power spectrum */ - Word16 pPowerSpectrum_exp, /**< in: | exponent of power spectrum */ - const Word16 igfGridIdx /**< in: Q0 | IGF grid index */ + +void IGF_ErodeSpectrum( + Word16 *highPassEner_exp, /* o : exponent of highPassEner */ + const IGF_ENC_INSTANCE_HANDLE hInstance, /* i : instance handle of IGF Encoder */ + Word32 *pSpectrum, /* i/o: MDCT spectrum */ + Word32 *pPowerSpectrum, /* i/o: power spectrum */ + Word16 pPowerSpectrum_exp, /* i : exponent of power spectrum */ + const Word16 igfGridIdx /* i : IGF grid index */ ) { IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData; @@ -520,14 +487,18 @@ void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< ou move16(); } } + + return; } -void IGF_ErodeSpectrum_ivas_fx( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ - Word32 *pSpectrum, /**< in/out: | MDCT spectrum Qx*/ - Word32 *pPowerSpectrum, /**< in/out: | power spectrum */ - Word16 pPowerSpectrum_exp, /**< in: | exponent of power spectrum */ - const Word16 igfGridIdx, /**< in: Q0 | IGF grid index */ - const Word16 mct_on ) + +void IGF_ErodeSpectrum_ivas_fx( + const IGF_ENC_INSTANCE_HANDLE hInstance, /* i : instance handle of IGF Encoder */ + Word32 *pSpectrum, /* i/o: MDCT spectrum Qx*/ + Word32 *pPowerSpectrum, /* i/o: power spectrum */ + Word16 pPowerSpectrum_exp, /* i : exponent of power spectrum */ + const Word16 igfGridIdx, /* i : IGF grid index */ + const Word16 mct_on ) { IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData; H_IGF_GRID hGrid; @@ -698,12 +669,14 @@ void IGF_ErodeSpectrum_ivas_fx( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in /**********************************************************************/ /* crest factor calculation **************************************************************************/ -Word16 IGF_getCrest( /**< out: Q15| crest factor */ - Word16 *crest_exp, /**< out: | exponent of crest factor */ - const Word32 *powerSpectrum, /**< in: Q31 | power spectrum */ - const Word16 powerSpectrum_exp, /**< in: | exponent of power spectrum */ - const Word16 start, /**< in: Q0 | start subband index */ - const Word16 stop /**< in: Q0 | stop subband index */ + +/* o: Q15| crest factor */ +Word16 IGF_getCrest( + Word16 *crest_exp, /* o : exponent of crest factor */ + const Word32 *powerSpectrum, /* i : Q31 | power spectrum */ + const Word16 powerSpectrum_exp, /* i : exponent of power spectrum */ + const Word16 start, /* i : Q0 | start subband index */ + const Word16 stop /* i : Q0 | stop subband index */ ) { Word16 i; @@ -779,12 +752,14 @@ Word16 IGF_getCrest( /**< ou return crest; } -Word16 IGF_getCrest_ivas( /**< out: Q15| crest factor */ - Word16 *crest_exp, /**< out: | exponent of crest factor */ - const Word32 *powerSpectrum, /**< in: Q31 | power spectrum */ - const Word16 *powerSpectrum_exp, /**< in: | exponent of power spectrum */ - const Word16 start, /**< in: Q0 | start subband index */ - const Word16 stop /**< in: Q0 | stop subband index */ + +/* o: Q15| crest factor */ +Word16 IGF_getCrest_ivas( + Word16 *crest_exp, /* o : | exponent of crest factor */ + const Word32 *powerSpectrum, /* i : Q31 | power spectrum */ + const Word16 *powerSpectrum_exp, /* i : | exponent of power spectrum */ + const Word16 start, /* i : Q0 | start subband index */ + const Word16 stop /* i : Q0 | stop subband index */ ) { Word16 i; @@ -860,15 +835,18 @@ Word16 IGF_getCrest_ivas( /**< out: Q15| crest return crest; } + /************************************************************************* calculates spectral flatness measurment **************************************************************************/ -Word16 IGF_getSFM( /**< out: Q15| SFM value */ - Word16 *SFM_exp, /**< out: | exponent of SFM Factor */ - const Word32 *energy, /**< in: Q31| energies */ - const Word16 *energy_exp, /**< in: | exponent of energies */ - const Word16 start, /**< in: Q0 | start subband index */ - const Word16 stop /**< in: Q0 | stop subband index */ + +/* o: Q15| SFM value */ +Word16 IGF_getSFM( + Word16 *SFM_exp, /* o : | exponent of SFM Factor */ + const Word32 *energy, /* i : Q31| energies */ + const Word16 *energy_exp, /* i : | exponent of energies */ + const Word16 start, /* i : Q0 | start subband index */ + const Word16 stop /* i : Q0 | stop subband index */ ) { Word16 n, i, s; @@ -967,12 +945,14 @@ Word16 IGF_getSFM( /**< out: Q15| SFM value /************************************************************************* calculates spectral flatness measurment **************************************************************************/ -Word16 IGF_getSFM_ivas_fx( /**< out: Q15| SFM value */ - Word16 *SFM_exp, /**< out: | exponent of SFM Factor */ - const Word32 *energy, /**< in: Q31| energies */ - const Word16 *energy_exp, /**< in: | exponent of energies */ - const Word16 start, /**< in: Q0 | start subband index */ - const Word16 stop /**< in: Q0 | stop subband index */ + +/* o: Q15| SFM value */ +Word16 IGF_getSFM_ivas_fx( + Word16 *SFM_exp, /* o : | exponent of SFM Factor */ + const Word32 *energy, /* i : Q31| energies */ + const Word16 *energy_exp, /* i : | exponent of energies */ + const Word16 start, /* i : Q0 | start subband index */ + const Word16 stop /* i : Q0 | stop subband index */ ) { Word16 n, i, s; @@ -1061,15 +1041,18 @@ Word16 IGF_getSFM_ivas_fx( /**< out: Q15| SFM value return SFM /*Q15*/; } + /**********************************************************************/ /* calculates the IGF whitening levels by SFM and crest **************************************************************************/ -static void IGF_Whitening( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ - Word32 *powerSpectrum, /**< in: Q31 | MDCT/MDST power spectrum */ - const Word16 powerSpectrum_exp, /**< in: | exponent of powerspectrum */ - const Word16 igfGridIdx, /**< in: Q0 | IGF grid index */ - Word16 isTransient, /**< in: Q0 | boolean, indicating if transient is detected */ - Word16 last_core_acelp /**< in: Q0 | indictaor if last frame was acelp coded */ + +static void IGF_Whitening( + const IGF_ENC_INSTANCE_HANDLE hInstance, /* i : | instance handle of IGF Encoder */ + Word32 *powerSpectrum, /* i : Q31 | MDCT/MDST power spectrum */ + const Word16 powerSpectrum_exp, /* i : | exponent of powerspectrum */ + const Word16 igfGridIdx, /* i : Q0 | IGF grid index */ + Word16 isTransient, /* i : Q0 | boolean, indicating if transient is detected */ + Word16 last_core_acelp /* i : Q0 | indictaor if last frame was acelp coded */ ) { IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData; @@ -1229,11 +1212,11 @@ static void IGF_Whitening( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in write whitening levels into bitstream **************************************************************************/ -/**< out: Q0 | number of bits written */ +/* o: Q0 | number of bits written */ static void IGF_WriteWhiteningTile_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 *pBitOffset, /**< in: | ptr to bitOffset counter */ - Word16 whiteningLevel /**< in: Q0 | whitening levels to write */ + Word16 *pBitOffset, /* i : | ptr to bitOffset counter */ + Word16 whiteningLevel /* i : Q0 | whitening levels to write */ ) { IF( EQ_32( whiteningLevel, IGF_WHITENING_MID ) ) @@ -1256,15 +1239,18 @@ static void IGF_WriteWhiteningTile_fx( return; } -/**********************************************************************/ /* - writes the whitening levels - **************************************************************************/ -static void IGF_WriteWhiteningLevels_fx( /**< out: Q0 | total number of bits written */ - const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF encoder */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 *pBitOffset, /**< in: | ptr to bitOffset counter */ - const Word16 igfGridIdx, /**< in: Q0 | igf grid index see declaration of IGF_GRID_IDX for details */ - const Word16 isIndepFlag /**< in: Q0 | if 1 frame is independent, 0 = frame is coded with data from previous frame */ + +/**********************************************************************/ /* +writes the whitening levels +**************************************************************************/ + +/* o: Q0 | total number of bits written */ +static void IGF_WriteWhiteningLevels_fx( + const IGF_ENC_INSTANCE_HANDLE hInstance, /* i : | instance handle of IGF encoder */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 *pBitOffset, /* i : | ptr to bitOffset counter */ + const Word16 igfGridIdx, /* i : Q0 | igf grid index see declaration of IGF_GRID_IDX for details */ + const Word16 isIndepFlag /* i : Q0 | if 1 frame is independent, 0 = frame is coded with data from previous frame */ ) { IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData; @@ -1274,7 +1260,6 @@ static void IGF_WriteWhiteningLevels_fx( Word16 isSame; Word32 tmp32; - isSame = 1; move16(); hPrivateData = &hInstance->igfData; @@ -1352,31 +1337,39 @@ static void IGF_WriteWhiteningLevels_fx( IGF_write_bits( hBstr, pBitOffset, 0, 1 ); } } + + return; } -/**********************************************************************/ /* - write flattening trigger - **************************************************************************/ -static void IGF_WriteFlatteningTrigger_fx( /**< out: | number of bits written */ - const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 *pBitOffset /**< in: | ptr to bitOffset counter */ + +/**********************************************************************/ /* +write flattening trigger +**************************************************************************/ + +/* o: number of bits written */ +static void IGF_WriteFlatteningTrigger_fx( + const IGF_ENC_INSTANCE_HANDLE hInstance, /* i : instance handle of IGF Encoder */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 *pBitOffset /* i : ptr to bitOffset counter */ ) { Word16 flatteningTrigger; - flatteningTrigger = hInstance->flatteningTrigger; move16(); IGF_write_bits( hBstr, pBitOffset, flatteningTrigger, 1 ); + + return; } /**********************************************************************/ /* updates the start/stop frequency of IGF according to igfGridIdx **************************************************************************/ -void IGF_UpdateInfo( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ - const Word16 igfGridIdx /**< in: Q0 | IGF grid index */ + +void IGF_UpdateInfo( + const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ + const Word16 igfGridIdx /**< in: Q0 | IGF grid index */ ) { IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData; @@ -1397,15 +1390,18 @@ void IGF_UpdateInfo( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in return; } + /**********************************************************************/ /* IGF bitsream writer **************************************************************************/ -Word16 IGFEncWriteBitstream_fx( /**< out: | number of bits written per frame */ - const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 *pBitOffset, /**< in: | ptr to bitOffset counter */ - const Word16 igfGridIdx, /**< in: Q0 | igf grid index see declaration of IGF_GRID_IDX for details */ - const Word16 isIndepFlag /**< in: Q0 | if 1 frame is independent, 0 = frame is coded with data from previous frame */ + +/**< out: | number of bits written per frame */ +Word16 IGFEncWriteBitstream_fx( + const IGF_ENC_INSTANCE_HANDLE hInstance, /* i : instance handle of IGF Encoder */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 *pBitOffset, /* i : ptr to bitOffset counter */ + const Word16 igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ + const Word16 isIndepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */ ) { Word16 igfAllZero; @@ -1423,33 +1419,25 @@ Word16 IGFEncWriteBitstream_fx( /**< ou move16(); } - IGF_WriteEnvelope( hInstance, /* i: instance handle of IGF Encoder */ - hBstr, /* i: encoder state */ - pBitOffset, /* i: ptr to bitOffset counter */ - igfGridIdx, /* i: igf grid index see definition of IGF_GRID_IDX for details */ - isIndepFlag, /* i: if 1 frame is independent, 0 = frame is coded with data from previous frame */ - &igfAllZero ); /* o: *igfAllZero */ + IGF_WriteEnvelope( hInstance, hBstr, pBitOffset, igfGridIdx, isIndepFlag, &igfAllZero ); - IGF_WriteWhiteningLevels_fx( hInstance, /* i: instance handle of IGF Encoder */ - hBstr, /* i: encoder state */ - pBitOffset, /* i: ptr to bitOffset counter */ - igfGridIdx, /* i: igf grid index see definition of IGF_GRID_IDX for details */ - isIndepFlag ); /* i: if 1 frame is independent, 0 = frame is coded with data from previous frame */ + IGF_WriteWhiteningLevels_fx( hInstance, hBstr, pBitOffset, igfGridIdx, isIndepFlag ); - IGF_WriteFlatteningTrigger_fx( hInstance, /* i: instance handle of IGF Encoder */ - hBstr, /* i: encoder state */ - pBitOffset ); /* i: ptr to bitOffset counter */ + IGF_WriteFlatteningTrigger_fx( hInstance, hBstr, pBitOffset ); hInstance->infoTotalBitsPerFrameWritten = sub( *pBitOffset, startBitCount ); hInstance->infoTotalBitsWritten = add( hInstance->infoTotalBitsWritten, hInstance->infoTotalBitsPerFrameWritten ); move16(); move16(); + return hInstance->infoTotalBitsPerFrameWritten; } + /**********************************************************************/ /* sets the IGF mode according to given bitrate **************************************************************************/ + void IGFEncSetMode_fx( const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i/o: instance handle of IGF Encoder */ const Word32 total_brate, /* i : encoder total bitrate */ @@ -1520,9 +1508,11 @@ void IGFEncSetMode_fx( hIGFEnc->tns_predictionGain = 0; move16(); set32_fx( hIGFEnc->spec_be_igf, 0, N_MAX_TCX - IGF_START_MN ); + return; } + /*-------------------------------------------------------------------* * pack_bit() * @@ -1565,9 +1555,10 @@ static void pack_bit_fx( * IGF bitstream concatenation for TCX10 modes *-------------------------------------------------------------------*/ -void IGFEncConcatenateBitstream_ivas_fx( const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ - const Word16 bsBits, /* i : number of IGF bits written to list of indices */ - BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */ +void IGFEncConcatenateBitstream_ivas_fx( + const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ + const Word16 bsBits, /* i : number of IGF bits written to list of indices */ + BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */ ) { Word16 i; @@ -1628,9 +1619,9 @@ return; IGF write concatenated bitsream for TCX10 modes **************************************************************************/ -/**< out: Q0 | total number of bits written */ +/* o: Q0 | total number of bits written */ Word16 IGFEncWriteConcatenatedBitstream_fx( - const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ + const IGF_ENC_INSTANCE_HANDLE hInstance, /* i : instance handle of IGF Encoder */ BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ ) { @@ -1657,9 +1648,12 @@ Word16 IGFEncWriteConcatenatedBitstream_fx( return hInstance->infoTotalBitsWritten; } -Word16 IGFEncWriteConcatenatedBitstream_ivas_fx( /**< out: Q0 | total number of bits written */ - const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ - BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ + + +/**< out: Q0 | total number of bits written */ +Word16 IGFEncWriteConcatenatedBitstream_ivas_fx( + const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ + BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ ) { IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData; @@ -1689,23 +1683,24 @@ Word16 IGFEncWriteConcatenatedBitstream_ivas_fx( /**********************************************************************/ /* apply the IGF encoder, main encoder interface **************************************************************************/ -void IGFEncApplyMono_fx( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ - const Word16 igfGridIdx, /**< in: Q0 | IGF grid index */ - Encoder_State *st, /**< in: | Encoder state */ - Word32 *pMDCTSpectrum, /**< in: Q31 | MDCT spectrum */ - Word16 MDCTSpectrum_e, /**< in: | exponent of MDCT spectrum */ - Word32 *pPowerSpectrum, /**< in: Q31 | MDCT^2 + MDST^2 spectrum, or estimate */ - Word16 PowerSpectrum_e, /**< in: | exponent of pPowerSpectrum */ - Word16 isTCX20, /**< in: Q0 | flag indicating if the input is TCX20 or TCX10/2xTCX5 */ - Word16 isTNSActive, /**< in: Q0 | flag indicating if the TNS is active */ - Word16 last_core_acelp /**< in: Q0 | indicator if last frame was acelp coded */ + +void IGFEncApplyMono_fx( + const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ + const Word16 igfGridIdx, /**< in: Q0 | IGF grid index */ + Encoder_State *st, /**< in: | Encoder state */ + Word32 *pMDCTSpectrum, /**< in: Q31 | MDCT spectrum */ + Word16 MDCTSpectrum_e, /**< in: | exponent of MDCT spectrum */ + Word32 *pPowerSpectrum, /**< in: Q31 | MDCT^2 + MDST^2 spectrum, or estimate */ + Word16 PowerSpectrum_e, /**< in: | exponent of pPowerSpectrum */ + Word16 isTCX20, /**< in: Q0 | flag indicating if the input is TCX20 or TCX10/2xTCX5 */ + Word16 isTNSActive, /**< in: Q0 | flag indicating if the TNS is active */ + Word16 last_core_acelp /**< in: Q0 | indicator if last frame was acelp coded */ ) { Word32 *pPowerSpectrumParameter; /* If it is NULL it informs a function that specific handling is needed */ Word32 *pPowerSpectrumParameterWhitening; /* If it is NULL it informs a function that specific handling is needed */ Word16 highPassEner_exp; /*exponent of highpass energy - maybe not needed*/ - pPowerSpectrumParameter = NULL; test(); if ( ( isTNSActive == 0 ) && ( isTCX20 != 0 ) ) @@ -1718,24 +1713,11 @@ void IGFEncApplyMono_fx( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in pPowerSpectrumParameterWhitening = pPowerSpectrum; } - IGF_UpdateInfo( hInstance, /* i: instance handle of IGF Encoder */ - igfGridIdx ); /* i: IGF grid index */ - - IGF_CalculateEnvelope( hInstance, /* i: instance handle of IGF Encoder */ - pMDCTSpectrum, /* i: MDCT spectrum */ - MDCTSpectrum_e, /* i: exponent of MDCT spectrum */ - pPowerSpectrumParameter, /* i: MDCT^2 + MDST^2 spectrum, or estimate */ - PowerSpectrum_e, /* i: exponent of pPowerSpectrum */ - igfGridIdx /* i: IGF grid index */ - ); + IGF_UpdateInfo( hInstance, igfGridIdx ); + IGF_CalculateEnvelope( hInstance, pMDCTSpectrum, MDCTSpectrum_e, pPowerSpectrumParameter, PowerSpectrum_e, igfGridIdx ); - IGF_Whitening( hInstance, /* i: instance handle of IGF Encoder */ - pPowerSpectrumParameterWhitening, /* i: MDCT^2 + MDST^2 spectrum, or estimate */ - PowerSpectrum_e, /* i: exponent of powerSpectrum */ - igfGridIdx, /* i: IGF grid index */ - ( st->hTranDet->transientDetector.bIsAttackPresent == 1 ), - last_core_acelp ); /* i: last frame was acelp indicator */ + IGF_Whitening( hInstance, pPowerSpectrumParameterWhitening, PowerSpectrum_e, igfGridIdx, ( st->hTranDet->transientDetector.bIsAttackPresent == 1 ), last_core_acelp ); pPowerSpectrumParameter = NULL; if ( isTCX20 != 0 ) @@ -1743,13 +1725,9 @@ void IGFEncApplyMono_fx( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in pPowerSpectrumParameter = pPowerSpectrum; } - IGF_ErodeSpectrum( /* o: highpass energy */ - &highPassEner_exp, /* o: exponent of highPassEner */ - hInstance, /* i: instance handle of IGF Encoder */ - pMDCTSpectrum, /* i: MDCT spectrum */ - pPowerSpectrumParameter, /* i: MDCT^2 + MDST^2 spectrum, or estimate */ - PowerSpectrum_e, /* i: exponent of pPowerSpectrum */ - igfGridIdx ); /* i: IGF grid index */ + IGF_ErodeSpectrum( &highPassEner_exp, hInstance, pMDCTSpectrum, pPowerSpectrumParameter, PowerSpectrum_e, igfGridIdx ); + + return; } @@ -3652,6 +3630,7 @@ static void IGF_Whitening_ivas_fx( break; } } + test(); test(); test(); @@ -3712,8 +3691,8 @@ static void IGF_Whitening_ivas_fx( /*! r: number of bits written */ static Word16 IGF_WriteWhiteningTile_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 *pBitOffset, /**< in: | ptr to bitOffset counter */ - Word16 whiteningLevel /**< in: Q0 | whitening levels to write */ + Word16 *pBitOffset, /* i : ptr to bitOffset counter */ + Word16 whiteningLevel /* i : whitening levels to write, Q0 */ ) { Word16 totBitCount; @@ -3752,13 +3731,13 @@ static Word16 IGF_WriteWhiteningTile_ivas_fx( * writes the whitening levels *-------------------------------------------------------------------*/ -/**< out: Q0 | total number of bits written */ +/* o: Q0 | total number of bits written */ static Word16 IGF_WriteWhiteningLevels_ivas_fx( - const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF encoder */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 *pBitOffset, /**< in: | ptr to bitOffset counter */ - const Word16 igfGridIdx, /**< in: Q0 | igf grid index see declaration of IGF_GRID_IDX for details */ - const Word16 isIndepFlag /**< in: Q0 | if 1 frame is independent, 0 = frame is coded with data from previous frame */ + const IGF_ENC_INSTANCE_HANDLE hInstance, /* i : instance handle of IGF encoder */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 *pBitOffset, /* i : ptr to bitOffset counter */ + const Word16 igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details, Q0 */ + const Word16 isIndepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame, Q0 */ ) { IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData; @@ -3875,13 +3854,12 @@ static Word16 IGF_WriteWhiteningLevels_ivas_fx( /*! r: number of bits written */ static Word16 IGF_WriteFlatteningTrigger_ivas_fx( - const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ + const IGF_ENC_INSTANCE_HANDLE hInstance, /* i : instance handle of IGF Encoder */ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 *pBitOffset /**< in: | ptr to bitOffset counter */ + Word16 *pBitOffset /* i : ptr to bitOffset counter */ ) { Word16 flatteningTrigger; - Word16 totBitCount; Word16 startBitCount; totBitCount = 0; @@ -3927,22 +3905,11 @@ Word16 IGFEncWriteBitstream_ivas_fx( move16(); } - IGF_WriteEnvelope_ivas( hIGFEnc, /* i: instance handle of IGF Encoder */ - hBstr, /* i: encoder state */ - pBitOffset, /* i: ptr to bitOffset counter */ - igfGridIdx, /* i: igf grid index see definition of IGF_GRID_IDX for details */ - isIndepFlag, /* i: if 1 frame is independent, 0 = frame is coded with data from previous frame */ - &igfAllZero ); /* o: *igfAllZero */ + IGF_WriteEnvelope_ivas( hIGFEnc, hBstr, pBitOffset, igfGridIdx, isIndepFlag, &igfAllZero ); - IGF_WriteWhiteningLevels_ivas_fx( hIGFEnc, /* i: instance handle of IGF Encoder */ - hBstr, /* i: encoder state */ - pBitOffset, /* i: ptr to bitOffset counter */ - igfGridIdx, /* i: igf grid index see definition of IGF_GRID_IDX for details */ - isIndepFlag ); /* i: if 1 frame is independent, 0 = frame is coded with data from previous frame */ + IGF_WriteWhiteningLevels_ivas_fx( hIGFEnc, hBstr, pBitOffset, igfGridIdx, isIndepFlag ); - IGF_WriteFlatteningTrigger_ivas_fx( hIGFEnc, /* i: instance handle of IGF Encoder */ - hBstr, /* i: encoder state */ - pBitOffset ); /* i: ptr to bitOffset counter */ + IGF_WriteFlatteningTrigger_ivas_fx( hIGFEnc, hBstr, pBitOffset ); hIGFEnc->infoTotalBitsPerFrameWritten = sub( *pBitOffset, startBitCount ); hIGFEnc->infoTotalBitsWritten = add( hIGFEnc->infoTotalBitsWritten, hIGFEnc->infoTotalBitsPerFrameWritten ); @@ -4089,12 +4056,12 @@ void IGFEncResetTCX10BitCounter_fx( void IGFEncApplyMono_ivas_fx( Encoder_State *st, /* i : Encoder state */ - Word16 powerSpectrum_len, /* i: length of pPowerSpectrum_fx buffer */ + Word16 powerSpectrum_len, /* i : length of pPowerSpectrum_fx buffer */ const Word16 igfGridIdx, /* i : IGF grid index */ Word32 *pMDCTSpectrum_fx, /* i/o: MDCT spectrum */ - Word16 e_mdct, /* i : exponent of pMDCTspectrum */ + Word16 e_mdct, /* i : exponent of pMDCTspectrum */ Word32 *pPowerSpectrum_fx, /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ - Word16 *e_ps, /* i : exponent of pPowerSpectrum */ + Word16 *e_ps, /* i : exponent of pPowerSpectrum */ const Word16 isTCX20, /* i : flag indicating if the input is TCX20 or TCX10/2xTCX5 */ const Word8 isTNSActive, /* i : flag indicating if the TNS is active */ const Word16 sp_aud_decision0, /* i : first stage switching decision */ diff --git a/lib_enc/igf_scf_enc.c b/lib_enc/igf_scf_enc.c index c9a549e5a383a37e05cae2b9700969e77afd7784..c39de507ce7194805473814768aee28f34284319 100644 --- a/lib_enc/igf_scf_enc.c +++ b/lib_enc/igf_scf_enc.c @@ -81,14 +81,13 @@ static Word16 quant_ctx( static void arith_encode_bits( IGFSCFENC_INSTANCE_HANDLE hPrivateData, /* i/o: instance handle */ Word16 *ptr, /* i/o: pointer to expanded bit buffer, one bit in each Word16 */ - Word16 x, /* i: value to encode */ - Word16 nBits /* i: number of bits to encode */ + Word16 x, /* i : value to encode */ + Word16 nBits /* i : number of bits to encode */ ) { Word16 i; Word16 bit; - FOR( i = nBits - 1; i >= 0; --i ) /* nBits > 0 */ { bit = s_and( shr( x, i ), 1 ); @@ -99,6 +98,8 @@ static void arith_encode_bits( bit ); move16(); } + + return; } @@ -111,16 +112,15 @@ static void arith_encode_bits( static void arith_encode_residual( IGFSCFENC_INSTANCE_HANDLE hPrivateData, /* i/o: instance handle */ Word16 *ptr, /* i/o: pointer to expanded bit buffer, one bit in each Word16 */ - Word16 x, /* i: residual value to encode */ - const UWord16 *cumulativeFrequencyTable, /* i: cumulative frequency table to be used */ - Word16 tableOffset /* i: offset used to align the table */ + Word16 x, /* i : residual value to encode */ + const UWord16 *cumulativeFrequencyTable, /* i : cumulative frequency table to be used */ + Word16 tableOffset /* i : offset used to align the table */ ) { Word16 extra; Word16 extra_tmp; Word16 extra_safety; - x = add( x, tableOffset ); test(); @@ -185,6 +185,8 @@ static void arith_encode_residual( arith_encode_bits( hPrivateData, ptr, extra_safety, 7 ); } } + + return; } @@ -193,6 +195,7 @@ static void arith_encode_residual( * * *---------------------------------------------------------------------*/ + static void encode_sfe_vector( IGFSCFENC_INSTANCE_HANDLE hPrivateData, /* i/o: instance handle */ Word16 *ptr, /* i : pointer to expanded bit buffer, one bit in each short */ diff --git a/lib_enc/igf_scf_enc_fx.c b/lib_enc/igf_scf_enc_fx.c index d1341a98af3f27cc8846dcb3db7e735ea9597d7c..eab151d7eee9402996a00938f1026583efa5c115 100644 --- a/lib_enc/igf_scf_enc_fx.c +++ b/lib_enc/igf_scf_enc_fx.c @@ -55,11 +55,13 @@ void IGFSCFEncoderOpen_fx( move16(); /* protect against the invalid request of starting encoding with a dependent block */ IGFCommonFuncsIGFGetCFTables_fx( total_brate, bwidth, element_mode, rf_mode, &hPublicData->cf_se00, &hPublicData->cf_se01, &hPublicData->cf_off_se01, &hPublicData->cf_se02, &hPublicData->cf_off_se02, &hPublicData->cf_se10, &hPublicData->cf_off_se10, &hPublicData->cf_se11, &hPublicData->cf_off_se11 ); + + return; } static Word16 quant_ctx( - Word16 ctx /* i: the context value to be quantized */ + Word16 ctx /* i : the context value to be quantized */ ) { /* @@ -82,14 +84,13 @@ static Word16 quant_ctx( static void arith_encode_bits( IGFSCFENC_INSTANCE_HANDLE hPrivateData, /* i/o: instance handle */ Word16 *ptr, /* i/o: pointer to expanded bit buffer, one bit in each Word16 */ - Word16 x, /* i: value to encode */ - Word16 nBits /* i: number of bits to encode */ + Word16 x, /* i : value to encode */ + Word16 nBits /* i : number of bits to encode */ ) { Word16 i; Word16 bit; - FOR( i = nBits - 1; i >= 0; --i ) /* nBits > 0 */ { bit = s_and( shr( x, i ), 1 ); @@ -100,21 +101,23 @@ static void arith_encode_bits( bit ); move16(); } + + return; } + static void arith_encode_residual( IGFSCFENC_INSTANCE_HANDLE hPrivateData, /* i/o: instance handle */ Word16 *ptr, /* i/o: pointer to expanded bit buffer, one bit in each Word16 */ - Word16 x, /* i: residual value to encode */ - const UWord16 *cumulativeFrequencyTable, /* i: cumulative frequency table to be used */ - Word16 tableOffset /* i: offset used to align the table */ + Word16 x, /* i : residual value to encode */ + const UWord16 *cumulativeFrequencyTable, /* i : cumulative frequency table to be used */ + Word16 tableOffset /* i : offset used to align the table */ ) { Word16 extra; Word16 extra_tmp; Word16 extra_safety; - x = add( x, tableOffset ); test(); @@ -178,6 +181,8 @@ static void arith_encode_residual( arith_encode_bits( hPrivateData, ptr, extra_safety, 7 ); } } + + return; } @@ -207,7 +212,6 @@ static void encode_sfe_vector( Word32 index1; Word32 index2; - FOR( f = 0; f < length; ++f ) { IF( t == 0 ) @@ -291,12 +295,15 @@ static void encode_sfe_vector( } } } + + return; } /**********************************************************************/ /** resets the internal encoder memory (context memory) **************************************************************************/ + void IGFSCFEncoderReset_fx( IGFSCFENC_INSTANCE_HANDLE hPublicData /* i/o: handle to public data */ ) @@ -307,11 +314,14 @@ void IGFSCFEncoderReset_fx( hPublicData->t = 0; move16(); /* indicate that an independent block follows */ /* we do not need to fill hPublicData->prev with zeros, because when t = 0 no previous information is used */ + + return; } /**********************************************************************/ /** main encoder function **************************************************************************/ + Word16 IGFSCFEncoderEncode_fx( IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i : handle to public data or NULL in case there was no instance created */ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ @@ -369,6 +379,7 @@ Word16 IGFSCFEncoderEncode_fx( /**********************************************************************/ /** for a closed loop encoder, the SCF encoder needs to memorize the context **************************************************************************/ + void IGFSCFEncoderSaveContextState_fx( IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i/o: handle to public data */ const Word16 igfGridIdx /* i : igf grid index see declaration of IGF_GRID_IDX for details */ @@ -376,21 +387,25 @@ void IGFSCFEncoderSaveContextState_fx( { hPublicData->Tsave = hPublicData->t; move16(); + Copy( hPublicData->prev, hPublicData->prevSave, hPublicData->scfCountLongBlock[igfGridIdx] ); + + return; } /**********************************************************************/ /** for a closed loop encoder, the SCF encoder needs to memorize the context **************************************************************************/ + void IGFSCFEncoderRestoreContextState_fx( IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i/o: handle to public data */ const Word16 igfGridIdx /* i : igf grid index see declaration of IGF_GRID_IDX for details */ ) { - - hPublicData->t = hPublicData->Tsave; move16(); Copy( hPublicData->prevSave, hPublicData->prev, hPublicData->scfCountLongBlock[igfGridIdx] ); + + return; } diff --git a/lib_enc/ivas_agc_enc_fx.c b/lib_enc/ivas_agc_enc_fx.c index 52e5fbea5e8ef01b0d96bfb7a6bab2bfdd9a3b87..4d003b56855c5ac3eaed71baea7dd6ac78e637fc 100644 --- a/lib_enc/ivas_agc_enc_fx.c +++ b/lib_enc/ivas_agc_enc_fx.c @@ -80,11 +80,11 @@ static Word16 BASOP_Util_Cmp_Mant32Exp_sat /*!< o: flag: result of comparison */ /* 0, if a == b */ /* 1, if a > b */ /* -1, if a < b */ - ( Word32 a_m, /*!< i: Mantissa of 1st operand a */ - Word16 a_e, /*!< i: Exponent of 1st operand a */ - Word32 b_m, /*!< i: Mantissa of 2nd operand b */ - Word16 b_e ) /*!< i: Exponent of 2nd operand b */ - + ( Word32 a_m, /* i : Mantissa of 1st operand a */ + Word16 a_e, /* i : Exponent of 1st operand a */ + Word32 b_m, /* i : Mantissa of 2nd operand b */ + Word16 b_e /* i : Exponent of 2nd operand b */ + ) { Word32 diff_m; Word16 diff_e, shift, result; diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 577b11c1b43451b3d327cf64593dcd96470e3427..cfcf16338e628f5781741d069bad8c775f84b315 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -600,7 +600,7 @@ void pre_proc_front_ivas_fx( move16(); } } - ELSE /* IVAS_SCE or IVAS_CPE_MDCT */ + ELSE /* IVAS_SCE */ { preemph_copy_32fx2( new_inp_12k8_fx, sig_out, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx_q_inp ); dummy_fx = st->mem_preemph_fx_q_inp; diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index 493b21a50df0724e6bf216f9379f8c310ff7de45..af1d17041437e5ffb9692d9f501f3d9e7419fb57 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -133,8 +133,6 @@ ivas_error ivas_cpe_enc_fx( Word16 input_frame_2; Word16 i, j, q_com, shift, q_min, gb; - error = IVAS_ERR_OK; - move32(); push_wmops( "ivas_cpe_enc" ); hCPE = st_ivas->hCPE[cpe_id]; @@ -265,7 +263,6 @@ ivas_error ivas_cpe_enc_fx( /*----------------------------------------------------------------* * Stereo technology selection - * Front-VAD on input L and R channels *----------------------------------------------------------------*/ test(); @@ -289,10 +286,14 @@ ivas_error ivas_cpe_enc_fx( stereo_mode_combined_format_enc_fx( st_ivas, hCPE ); + /*----------------------------------------------------------------* + * Front-VAD on input L and R channels + *----------------------------------------------------------------*/ + Word16 Q_inp = 0; move16(); - Word16 Q_add = 2; + Word16 Q_add = Q2; move16(); Word16 front_create_flag = 0; move16(); @@ -321,7 +322,7 @@ ivas_error ivas_cpe_enc_fx( FOR( n = 0; n < CPE_CHANNELS; n++ ) { - Q_buffer[n] = 15; + Q_buffer[n] = Q15; move16(); } test(); @@ -399,7 +400,6 @@ ivas_error ivas_cpe_enc_fx( return error; } - /*----------------------------------------------------------------* * Resets/updates in case of stereo switching *----------------------------------------------------------------*/ @@ -547,7 +547,6 @@ ivas_error ivas_cpe_enc_fx( } ELSE { - /* note; "bits_frame_nominal" needed in TD stereo as well */ stereo_dft_config_fx( hConfigDft, hCPE->element_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); } } @@ -1312,16 +1311,14 @@ ivas_error ivas_cpe_enc_fx( Copy( Q_new, Q_new_out, CPE_CHANNELS ); } - #ifdef DEBUG_MODE_INFO { float tmpF = ivas_total_brate / 1000.0f; dbgwrite( &tmpF, sizeof( float ), 1, input_frame, fname( debug_dir, "element_brate", 0, cpe_id, ENC ) ); } #endif - pop_wmops(); - return error; + return IVAS_ERR_OK; } @@ -1345,10 +1342,7 @@ ivas_error create_cpe_enc_fx( ENCODER_CONFIG_HANDLE hEncoderConfig; ivas_error error; - error = IVAS_ERR_OK; - hEncoderConfig = st_ivas->hEncoderConfig; - ivas_format = hEncoderConfig->ivas_format; move16(); element_mode_init = hEncoderConfig->element_mode_init; /* Q0 */ @@ -1395,6 +1389,7 @@ ivas_error create_cpe_enc_fx( hCPE->brate_surplus = 0; move16(); + /*-----------------------------------------------------------------* * Input memory buffer: allocate and initialize *-----------------------------------------------------------------*/ @@ -1630,7 +1625,7 @@ ivas_error create_cpe_enc_fx( st_ivas->hCPE[cpe_id] = hCPE; - return error; + return IVAS_ERR_OK; } diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index 28498c891a8830bb6a6f73d3443f9f4758c10401..e4506609f015fb358a85e4ae784ddc8ef926cf17 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -172,7 +172,7 @@ ivas_error front_vad_fx( } } test(); - /* Only run VAD if DTX is on and TD stereo or unified stereo is selected */ + /* Only run VAD if DTX is on and Unified stereo is selected */ IF( hFrontVads[0] != NULL && NE_16( element_mode, IVAS_CPE_MDCT ) ) { diff --git a/lib_enc/ivas_ism_metadata_enc_fx.c b/lib_enc/ivas_ism_metadata_enc_fx.c index f4866c7f3646cc40a7038015354f92b41e4ec313..ff8a47f5eccdae09c0691ccf190909ebb8defa93 100644 --- a/lib_enc/ivas_ism_metadata_enc_fx.c +++ b/lib_enc/ivas_ism_metadata_enc_fx.c @@ -664,7 +664,7 @@ ivas_error ivas_ism_metadata_enc_fx( } IF( EQ_16( ism_mode, ISM_MODE_PARAM ) ) { - /* Keep the metdata transmission as is during active parts */ + /* Keep the metadata transmission as is during active parts */ /* But send the flag with 1 bit */ push_next_indice( hBstr, hParamIsm->flag_noisy_speech, 1 ); @@ -1037,12 +1037,12 @@ ivas_error ivas_ism_metadata_enc_create_fx( * Radius index encoding *-------------------------------------------------------------------------*/ static void encode_radius_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - Word16 *last_radius_idx, /* i/o: last radius index */ - Word16 *radius_diff_cnt, /* i/o: radius diff coding counter */ - const Word16 last_ism_metadata_flag, /* last frame ism_metadata_flag */ - const Word16 idx_radius_abs, /* i : Azimuth index */ - Word16 *flag_abs_radius /* o : Radius encoding mode */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + Word16 *last_radius_idx, /* i/o: last radius index */ + Word16 *radius_diff_cnt, /* i/o: radius diff coding counter */ + const Word16 last_ism_metadata_flag, /* i : last frame ism_metadata_flag */ + const Word16 idx_radius_abs, /* i : Azimuth index */ + Word16 *flag_abs_radius /* o : Radius encoding mode */ ) { Word16 idx_radius, nbits_diff_radius, diff; @@ -1456,7 +1456,7 @@ void ivas_ism_metadata_sid_enc_fx( move16(); /*----------------------------------------------------------------* - * Write ISm common signaling + * Write ISM common signaling *----------------------------------------------------------------*/ /* write number of objects - unary coding */ diff --git a/lib_enc/ivas_ism_param_enc_fx.c b/lib_enc/ivas_ism_param_enc_fx.c index 2d149d030af4f91ae78853ccb0387c4ec7f327ee..62a88ed999ad10d497a096a91d40608d32c4bae2 100644 --- a/lib_enc/ivas_ism_param_enc_fx.c +++ b/lib_enc/ivas_ism_param_enc_fx.c @@ -443,9 +443,6 @@ ivas_error ivas_param_ism_enc_open_fx( Word32 input_Fs; ivas_error error; - error = IVAS_ERR_OK; - move32(); - /* Assign memory to Param Object handle */ if ( ( hParamIsm = (PARAM_ISM_CONFIG_HANDLE) malloc( sizeof( PARAM_ISM_CONFIG_DATA ) ) ) == NULL ) { @@ -490,7 +487,7 @@ ivas_error ivas_param_ism_enc_open_fx( st_ivas->hParamIsm = hParamIsm; - return error; + return IVAS_ERR_OK; } diff --git a/lib_enc/ivas_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c index 3b30558bee542d00124505f039fe451155a767d3..5779ea017816e2f036f63face051da59e5b019c7 100644 --- a/lib_enc/ivas_masa_enc_fx.c +++ b/lib_enc/ivas_masa_enc_fx.c @@ -74,7 +74,7 @@ static void average_masa_metadata_fx( const UWord8 useSphGrid ); static void copy_masa_metadata_subframe_fx( - const MASA_METADATA_HANDLE hMetaFrom, /* i : MASA frame metdata to be copied */ + const MASA_METADATA_HANDLE hMetaFrom, /* i : MASA frame metadata to be copied */ const UWord8 sfFrom, /* i : subframe index of the copy source */ MASA_METADATA_HANDLE hMetaTo, /* o : MASA frame metadata copy destination */ const UWord8 sfTo /* i : subframe index of the copy target */ @@ -3192,7 +3192,7 @@ static void average_masa_metadata_fx( *-------------------------------------------------------------------*/ static void copy_masa_metadata_subframe_fx( - const MASA_METADATA_HANDLE hMetaFrom, /* i : MASA frame metdata to be copied */ + const MASA_METADATA_HANDLE hMetaFrom, /* i : MASA frame metadata to be copied */ const UWord8 sfFrom, /* i : subframe index of the copy source */ MASA_METADATA_HANDLE hMetaTo, /* o : MASA frame metadata copy destination */ const UWord8 sfTo /* i : subframe index of the copy target */ diff --git a/lib_enc/ivas_omasa_enc_fx.c b/lib_enc/ivas_omasa_enc_fx.c index f49e9ebbc984da60aeb5c08fd0ada843eac7b34a..330dd40386f39f573d7fbfab0774f20164b7df48 100644 --- a/lib_enc/ivas_omasa_enc_fx.c +++ b/lib_enc/ivas_omasa_enc_fx.c @@ -1053,16 +1053,16 @@ static void ivas_omasa_param_est_enc_fx( OMASA_ENC_HANDLE hOMasa, OMASA_ENCODER_DATA_HANDLE hOmasaData, ISM_METADATA_HANDLE hIsmMeta[], - Word32 *data[], /*i:q_data*/ - Word32 elevation_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /*o:q22*/ - Word32 azimuth_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /*o:q22*/ - Word32 energyRatio_fx[MASA_FREQUENCY_BANDS], /*o:Q30*/ - Word16 spreadCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /*o:Q15*/ - Word16 surroundingCoherence_fx[MASA_FREQUENCY_BANDS], /*o:Q15*/ - Word32 diffuseness_m_fx[MASA_FREQUENCY_BANDS], /*o:q30*/ + Word32 *data[], /*i : q_data*/ + Word32 elevation_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /*o : q22*/ + Word32 azimuth_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /*o : q22*/ + Word32 energyRatio_fx[MASA_FREQUENCY_BANDS], /*o : Q30*/ + Word16 spreadCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /*o : Q15*/ + Word16 surroundingCoherence_fx[MASA_FREQUENCY_BANDS], /*o : Q15*/ + Word32 diffuseness_m_fx[MASA_FREQUENCY_BANDS], /*o : q30*/ const Word16 input_frame, const Word16 nchan_ism, - Word16 q_data /*i: Qfactor for data*/ + Word16 q_data /*i : Qfactor for data*/ ) { Word32 reference_power_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; // Q(31-ref_exp) @@ -1371,10 +1371,10 @@ static void ivas_omasa_param_est_enc_fx( static void ivas_omasa_energy_and_ratio_est_fx( OMASA_ENC_HANDLE hOMasa, OMASA_ENCODER_DATA_HANDLE hOmasaData, - Word32 *data_fx[], /*i: q_data*/ + Word32 *data_fx[], /* i : q_data*/ const Word16 input_frame, const Word16 nchan_ism, - const Word16 q_data /*i: stoes the q for data_fx*/ + const Word16 q_data /*i : stoes the q for data_fx*/ ) { Word16 ts, i, j, k; diff --git a/lib_enc/ivas_osba_enc_fx.c b/lib_enc/ivas_osba_enc_fx.c index 1f19fa21d47bec73cb81253e7eedbef5fc3a2dcc..a71a8598495b807dc8e9d4c0c105e28a6e6da88e 100644 --- a/lib_enc/ivas_osba_enc_fx.c +++ b/lib_enc/ivas_osba_enc_fx.c @@ -102,9 +102,7 @@ ivas_error ivas_osba_enc_open_fx( Word16 i; OSBA_ENC_HANDLE hOSba; Word16 input_frame; - ivas_error error; Word16 len; - error = IVAS_ERR_OK; IF( ( hOSba = (OSBA_ENC_HANDLE) malloc( sizeof( OSBA_ENC_DATA ) ) ) == NULL ) { @@ -142,7 +140,7 @@ ivas_error ivas_osba_enc_open_fx( } st_ivas->hOSba = hOSba; - return error; + return IVAS_ERR_OK; } @@ -157,6 +155,7 @@ void ivas_osba_enc_close_fx( ) { Word16 n; + test(); IF( hOSba == NULL || *hOSba == NULL ) { diff --git a/lib_enc/ivas_pca_enc_fx.c b/lib_enc/ivas_pca_enc_fx.c index 7228d134e5157f78944584fe048128d57b06f8dc..04c7033931e85f86688fb59c0692c8f486e9b731 100644 --- a/lib_enc/ivas_pca_enc_fx.c +++ b/lib_enc/ivas_pca_enc_fx.c @@ -43,11 +43,16 @@ * Local constants *-----------------------------------------------------------------------*/ -#define IVAS_PCA_SM_FAC 0.0234375f #define IVAS_PCA_N_ITER_QR 10 -#define IVAS_PCA_SM_FAC_FX 50331648 // Q31 +#define IVAS_PCA_SM_FAC_FX 50331648 // 0.0234375f in Q31 #define ONE_MINUS_IVAS_PCA_SM_FAC_FX 2097152000 // MAX_32 - IVAS_PCA_SM_FAC_FX -> Q31 + +#define IVAS_PCA_THRES_MIN_DOT_FX 1717986918 /* 0.8 in Q31 */ +#define IVAS_PCA_THRES_MIN_DOT2_FX 0 +#define IVAS_PCA_THRES_DIST_ALT_FX 1610612736 /* 6 in Q28 */ + + /*-----------------------------------------------------------------------* * Local function definitions *-----------------------------------------------------------------------*/ @@ -305,6 +310,7 @@ void ivas_pca_enc_fx( ivas_total_brate = hEncoderConfig->ivas_total_brate; move32(); + /* if PCA is disabled, just pass-through */ IF( hEncoderConfig->Opt_PCA_ON == 0 ) { @@ -355,7 +361,6 @@ void ivas_pca_enc_fx( ptr_sig_fx[k] = &data_fx[k][i]; // Q11 } - cov_subfr_fx( ptr_sig_fx, r_fx_64, n_channels, shr( input_frame, 1 ) ); Word16 tmp_q[FOA_CHANNELS * FOA_CHANNELS]; FOR( Word16 idx = 0; idx < FOA_CHANNELS * FOA_CHANNELS; idx++ ) @@ -369,7 +374,6 @@ void ivas_pca_enc_fx( move16(); } - q = tmp_q[0]; move16(); FOR( Word16 idx = 1; idx < FOA_CHANNELS * FOA_CHANNELS; idx++ ) @@ -381,7 +385,6 @@ void ivas_pca_enc_fx( } } - FOR( Word16 idx = 0; idx < FOA_CHANNELS * FOA_CHANNELS; idx++ ) { r_fx[idx] = L_shr( r_fx[idx], ( sub( tmp_q[idx], q ) ) ); // q @@ -421,10 +424,10 @@ void ivas_pca_enc_fx( move32(); } - /*-----------------------------------------------------------------* * Eigenvalue decomposition *-----------------------------------------------------------------*/ + eig_qr_fx( r_sm_fx, hPCA->old_r_sm_q, IVAS_PCA_N_ITER_QR, eigVec_fx, D_fx, n_channels ); /* force positive eigenvalues */ @@ -462,14 +465,12 @@ void ivas_pca_enc_fx( fac_D_fx = L_shl( L_deposit_h( tmp ), exp ); // Q31 } - FOR( k = 0; k < n_channels; k++ ) { D_fx[k] = Mpy_32_32( fac_D_fx, D_fx[k] ); move32(); } - /* sorting (sanity check) with SPAR inversion of last two channels */ sort4_D_eigVec_fx( D_fx, eigVec_fx ); @@ -642,7 +643,6 @@ void ivas_pca_enc_fx( move16(); } - /* if PCA is inactive */ IF( EQ_16( bypass_decision, PCA_MODE_INACTIVE ) ) { @@ -673,7 +673,6 @@ void ivas_pca_enc_fx( } /* force ql to have first component with positive sign */ - IF( ql_fx[0] < 0 ) { FOR( i = 0; i < 4; i++ ) @@ -689,7 +688,6 @@ void ivas_pca_enc_fx( pca_enc_s3_fx( ql_fx, &index[0] ); pca_enc_s3_fx( qr_fx, &index[1] ); - /* write bypass flag to bitstream to indicate active mode */ push_next_indice( hMetaData, PCA_MODE_ACTIVE, 1 ); @@ -697,7 +695,6 @@ void ivas_pca_enc_fx( ivas_bitstream_write_int32( hMetaData, index[1], IVAS_PCA_QBITS ); /* transform */ - pca_enc_transform_fx( hPCA, ql_fx, qr_fx, data_fx, input_frame, n_channels ); /*-----------------------------------------------------------------* @@ -707,5 +704,6 @@ void ivas_pca_enc_fx( hPCA->prev_bypass_decision = bypass_decision; move16(); pca_update_state_fx( hPCA, ql_fx, qr_fx, eigVec_fx16, n_channels ); + return; } diff --git a/lib_enc/ivas_sce_enc_fx.c b/lib_enc/ivas_sce_enc_fx.c index 17635449055476fe4d1f31472934d2561af8dc6f..13ede99bccdafc285a86ffeedaa5b5a9301fbec6 100644 --- a/lib_enc/ivas_sce_enc_fx.c +++ b/lib_enc/ivas_sce_enc_fx.c @@ -49,7 +49,6 @@ * * Single Channel Element (SCE) encoding routine *-------------------------------------------------------------------*/ -Indice ind_list[MAX_NUM_INDICES]; ivas_error ivas_sce_enc_fx( Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ @@ -105,9 +104,6 @@ ivas_error ivas_sce_enc_fx( push_wmops( "ivas_sce_enc" ); - error = IVAS_ERR_OK; - move32(); - hSCE = st_ivas->hSCE[sce_id]; st = hSCE->hCoreCoder[0]; ivas_format = st_ivas->hEncoderConfig->ivas_format; @@ -175,6 +171,7 @@ ivas_error ivas_sce_enc_fx( /*---------------------------------------------------------------* * Time Domain Transient Detector *---------------------------------------------------------------*/ + test(); IF( NE_32( ivas_format, MC_FORMAT ) || NE_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) ) { @@ -240,8 +237,6 @@ ivas_error ivas_sce_enc_fx( dbgwrite( st->input_fx - NS2SA( st->input_Fs, ACELP_LOOK_NS ), sizeof( Word16 ), input_frame, 1, "res/input_DMX" ); dbgwrite( &st->element_mode, sizeof( int16_t ), 1, input_frame, fname( debug_dir, "element_mode", 0, st->id_element, ENC ) ); #endif - - /*----------------------------------------------------------------* * Front Pre-processing *----------------------------------------------------------------*/ @@ -353,13 +348,15 @@ ivas_error ivas_sce_enc_fx( /* modify the coder_type depending on the total_brate per channel */ coder_type_modif_fx( st, relE_fx[0] ); + /*----------------------------------------------------------------* * Encoder *----------------------------------------------------------------*/ Scale_sig( old_wsp_fx[0], L_WSP, sub( e_old_wsp[0], Q16 ) ); // Q(15-16) - e_old_wsp[0] = 16; + e_old_wsp[0] = Q16; move16(); + IF( NE_32( ( error = ivas_core_enc_fx( hSCE, NULL, NULL, 1, old_inp_12k8_fx, old_inp_16k_fx, Q_new, ener_fx, A_fx, Aw_fx, epsP_fx, epsP_fx_q, lsp_new_fx, lsp_mid_fx, vad_hover_flag, attack_flag, realBuffer_fx, imagBuffer_fx, &q_re_im_buf, old_wsp_fx, e_old_wsp, loc_harm, cor_map_sum_fx, vad_flag_dtx, enerBuffer_fx, enerBuffer_fx_exp, fft_buff_fx, 0, ivas_format, flag_16k_smc ) ), IVAS_ERR_OK ) ) { return error; @@ -389,10 +386,9 @@ ivas_error ivas_sce_enc_fx( dbgwrite( &tmpF, sizeof( float ), 1, input_frame, fname( debug_dir, "element_brate", 0, sce_id, ENC ) ); } #endif - pop_wmops(); - return error; + return IVAS_ERR_OK; } @@ -412,9 +408,6 @@ ivas_error create_sce_enc_fx( Encoder_State *st; ivas_error error; - error = IVAS_ERR_OK; - move32(); - /*-----------------------------------------------------------------* * Allocate SCE handle *-----------------------------------------------------------------*/ @@ -490,7 +483,7 @@ ivas_error create_sce_enc_fx( st_ivas->hSCE[sce_id] = hSCE; - return error; + return IVAS_ERR_OK; } diff --git a/lib_enc/lib_enc_fx.c b/lib_enc/lib_enc_fx.c index 3c6baff395c7e4df02b65aa2ba3dff41244226c0..3832ce22ea7d78733c2e68b3bc32dcc57a663ba7 100644 --- a/lib_enc/lib_enc_fx.c +++ b/lib_enc/lib_enc_fx.c @@ -101,7 +101,7 @@ ivas_error IVAS_ENC_Open( { Encoder_Struct *st_ivas; - if ( phIvasEnc == NULL ) + IF( phIvasEnc == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } @@ -730,6 +730,12 @@ ivas_error IVAS_ENC_FeedMasaMetadata( IVAS_MASA_METADATA_HANDLE hMasaMetadata /* i : MASA metadata for current frame */ ) { + test(); + IF( hIvasEnc == NULL || hIvasEnc->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + IF( !hIvasEnc->isConfigured ) { return IVAS_ERR_NOT_CONFIGURED; @@ -1161,6 +1167,8 @@ static ivas_error configureEncoder( return error; } + + /*---------------------------------------------------------------------* * IVAS_ENC_GetDelay() * @@ -1172,6 +1180,12 @@ ivas_error IVAS_ENC_GetDelay( Word16 *delay /* o : encoder delay Q0*/ ) { + test(); + IF( hIvasEnc == NULL || hIvasEnc->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + ENCODER_CONFIG_HANDLE hEncoderConfig; hEncoderConfig = hIvasEnc->st_ivas->hEncoderConfig; @@ -1201,6 +1215,7 @@ ivas_error IVAS_ENC_GetDelay( * * *---------------------------------------------------------------------*/ + static Word16 getInputBufferSize_fx( const Encoder_Struct *st_ivas /* i : IVAS encoder handle */ ) @@ -1208,18 +1223,21 @@ static Word16 getInputBufferSize_fx( return extract_l( Mpy_32_32( imult3216( st_ivas->hEncoderConfig->input_Fs, st_ivas->hEncoderConfig->nchan_inp ), ONE_BY_FRAMES_PER_SEC_Q31 ) ); } + /*---------------------------------------------------------------------* * IVAS_ENC_GetNumInChannels() * * *---------------------------------------------------------------------*/ + ivas_error IVAS_ENC_GetNumInChannels( const IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ Word16 *numInChannels /* o : total number of samples expected in the input buffer for current encoder configuration */ ) { test(); - IF( hIvasEnc == NULL || numInChannels == NULL ) + test(); + IF( hIvasEnc == NULL || hIvasEnc->st_ivas == NULL || numInChannels == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } @@ -1241,6 +1259,7 @@ ivas_error IVAS_ENC_GetNumInChannels( * * *---------------------------------------------------------------------*/ + ivas_error IVAS_ENC_GetInputBufferSize( const IVAS_ENC_HANDLE hIvasEnc, /* i : IVAS encoder handle */ Word16 *inputBufferSize /* o : total number of samples expected in the input buffer for current encoder configuration */ @@ -1251,7 +1270,9 @@ ivas_error IVAS_ENC_GetInputBufferSize( return IVAS_ERR_NOT_CONFIGURED; } - IF( inputBufferSize == NULL ) + test(); + test(); + IF( hIvasEnc == NULL || hIvasEnc->st_ivas == NULL || inputBufferSize == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } @@ -1268,6 +1289,7 @@ ivas_error IVAS_ENC_GetInputBufferSize( * * Main function to encode one frame to a serial bitstream *---------------------------------------------------------------------*/ + ivas_error IVAS_ENC_EncodeFrameToSerial( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ Word16 *inputBuffer, /* i : PCM input, Q0 Q0*/ @@ -1285,6 +1307,15 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( error = IVAS_ERR_OK; move32(); + test(); + test(); + test(); + test(); + IF( hIvasEnc == NULL || hIvasEnc->st_ivas == NULL || inputBuffer == NULL || outputBitStream == NULL || numOutBits == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + IF( !hIvasEnc->isConfigured ) { return IVAS_ERR_NOT_CONFIGURED; @@ -1684,7 +1715,8 @@ ivas_error IVAS_ENC_SetForcedMode( * *---------------------------------------------------------------------*/ -IVAS_ENC_BANDWIDTH IVAS_ENC_GetDefaultBandwidth( const bool isEVS ) +IVAS_ENC_BANDWIDTH IVAS_ENC_GetDefaultBandwidth( + const bool isEVS ) { IVAS_ENC_BANDWIDTH bwidth = IVAS_ENC_BANDWIDTH_FB; @@ -1703,7 +1735,8 @@ IVAS_ENC_BANDWIDTH IVAS_ENC_GetDefaultBandwidth( const bool isEVS ) * *---------------------------------------------------------------------*/ -IVAS_ENC_DTX_CONFIG IVAS_ENC_GetDefaultDtxConfig( void ) +IVAS_ENC_DTX_CONFIG IVAS_ENC_GetDefaultDtxConfig( + void ) { IVAS_ENC_DTX_CONFIG defaultDtxConfig; defaultDtxConfig.enabled = false; @@ -1721,7 +1754,8 @@ IVAS_ENC_DTX_CONFIG IVAS_ENC_GetDefaultDtxConfig( void ) * *---------------------------------------------------------------------*/ -IVAS_ENC_CHANNEL_AWARE_CONFIG IVAS_ENC_GetDefaultChannelAwareConfig( void ) +IVAS_ENC_CHANNEL_AWARE_CONFIG IVAS_ENC_GetDefaultChannelAwareConfig( + void ) { IVAS_ENC_CHANNEL_AWARE_CONFIG defaultCaConfig; defaultCaConfig.channelAwareModeEnabled = 0; @@ -1762,6 +1796,12 @@ static ivas_error printConfigInfo_enc( Word16 newBandwidthApi; ivas_error error; + test(); + IF( hIvasEnc == NULL || hIvasEnc->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + st_ivas = hIvasEnc->st_ivas; hEncoderConfig = st_ivas->hEncoderConfig; @@ -2221,6 +2261,12 @@ static ivas_error sanitizeBandwidth_fx( ENCODER_CONFIG_HANDLE hEncoderConfig; Word16 max_bwidth_tmp; + test(); + IF( hIvasEnc == NULL || hIvasEnc->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + hEncoderConfig = hIvasEnc->st_ivas->hEncoderConfig; max_bwidth_tmp = hIvasEnc->newBandwidthApi; @@ -2364,6 +2410,12 @@ static ivas_error setBandwidth_fx( Word16 newBandwidth; ENCODER_CONFIG_HANDLE hEncoderConfig; + test(); + IF( hIvasEnc == NULL || hIvasEnc->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + hEncoderConfig = hIvasEnc->st_ivas->hEncoderConfig; /* Convert bandwidth from API type */ diff --git a/lib_enc/lsf_msvq_ma_enc_fx.c b/lib_enc/lsf_msvq_ma_enc_fx.c index 2f9f2b7c7a87fe1557a842fd5001e1c9eda70836..ca05ac59d934fecf449933c9f458b55c0f2d14eb 100644 --- a/lib_enc/lsf_msvq_ma_enc_fx.c +++ b/lib_enc/lsf_msvq_ma_enc_fx.c @@ -1520,11 +1520,11 @@ Word16 lsf_msvq_ma_encprm_fx( *--------------------------------------------------------------------------*/ void midlsf_enc_fx( - const Word16 qlsf0[], /* i: quantized lsf coefficients (3Q12) */ - const Word16 qlsf1[], /* i: quantized lsf coefficients (3Q12) */ - const Word16 lsf[], /* i: lsf coefficients (3Q12) */ - Word16 *idx, /* o: codebook index */ - const Word16 lpcorder, /* i: order of the lpc */ + const Word16 qlsf0[], /* i : quantized lsf coefficients (3Q12) */ + const Word16 qlsf1[], /* i : quantized lsf coefficients (3Q12) */ + const Word16 lsf[], /* i : lsf coefficients (3Q12) */ + Word16 *idx, /* o : codebook index */ + const Word16 lpcorder, /* i : order of the lpc */ const Word32 *Bin_Ener_128_fx, // Q_ener const Word16 Q_ener, const Word8 narrowBand, diff --git a/lib_enc/mdct_classifier_fx.c b/lib_enc/mdct_classifier_fx.c index e5b45a6b06be0dcc1da8e76b10dae786c8fc3b60..c24673ca1b03df33016426b93c59e65974c2dd7f 100644 --- a/lib_enc/mdct_classifier_fx.c +++ b/lib_enc/mdct_classifier_fx.c @@ -80,18 +80,21 @@ static void dft_mag_square_fx( move32(); return; } + + /*-------------------------------------------------------------------* * mdct_classifier() * * MDCT signal classifier for HQ_CORE/TCX_20_CORE *-------------------------------------------------------------------*/ -Word16 mdct_classifier_fx( /* o: MDCT A/B decision */ - const Word16 *fft_buff, /* i: re[0], re[1], ..., re[n/2], im[n/2 - 1], im[n/2 - 2], ..., im[1] */ - Encoder_State *st_fx, /* i/o: Encoder state variable */ - Word32 *cldfbBuf_Ener, // enerBuffer_exp - Word16 enerBuffer_exp, - const Word32 brate /* i : current brate, IVAS: nominal bitrate, EVS: st->total_brate */ +/* o: MDCT A/B decision */ +Word16 mdct_classifier_fx( + const Word16 *fft_buff, /* i : re[0], re[1], ..., re[n/2], im[n/2 - 1], im[n/2 - 2], ..., im[1] */ + Encoder_State *st_fx, /* i/o: Encoder state variable */ + Word32 *cldfbBuf_Ener, // enerBuffer_exp + Word16 enerBuffer_exp, + const Word32 brate /* i : current brate, IVAS: nominal bitrate, EVS: st->total_brate */ ) { Word16 c; diff --git a/lib_enc/mslvq_enc_fx.c b/lib_enc/mslvq_enc_fx.c index 0b2f9703d221bbf631f285d7c1d7b1ced2c959fd..ab7122ad2ac932945bae5cad4f5b0b24d5628563 100644 --- a/lib_enc/mslvq_enc_fx.c +++ b/lib_enc/mslvq_enc_fx.c @@ -96,17 +96,17 @@ Word32 mslvq_fx( *-----------------------------------------------------------------*/ static Word32 q_data_fx( - Word16 *pTmp1, /* i: M-dimensional input vector x2.56 */ - const Word16 *w1, /* i: M-dimensional weight vector Q8 */ - Word16 *quant, /* o: quantized vector x2.56 */ - Word16 *cv_out, /* o: non-scaled lattice codevector x2.56 */ - Word16 *idx_lead, /* o: leader indexes for each subvector */ - Word16 *idx_scale, /* o: scale indexes for each subvector */ - const Word16 *p_sigma, /* i: standard deviation x2.56 */ - const Word16 *p_inv_sigma, /* i: inverse standard deviation Q15 */ - const Word16 *p_scales, /* i: scale values Q11 */ - Word16 *p_no_scales, /* i: number of scales/truncations for each subvector */ - const Word16 *p_no_lead /* i: number of leaders for each truncation and each subvector */ + Word16 *pTmp1, /* i : M-dimensional input vector x2.56 */ + const Word16 *w1, /* i : M-dimensional weight vector Q8 */ + Word16 *quant, /* o : quantized vector x2.56 */ + Word16 *cv_out, /* o : non-scaled lattice codevector x2.56 */ + Word16 *idx_lead, /* o : leader indexes for each subvector */ + Word16 *idx_scale, /* o : scale indexes for each subvector */ + const Word16 *p_sigma, /* i : standard deviation x2.56 */ + const Word16 *p_inv_sigma, /* i : inverse standard deviation Q15 */ + const Word16 *p_scales, /* i : scale values Q11 */ + Word16 *p_no_scales, /* i : number of scales/truncations for each subvector */ + const Word16 *p_no_lead /* i : number of leaders for each truncation and each subvector */ ) { Word32 dist, L_tmp; @@ -125,16 +125,16 @@ static Word32 q_data_fx( } static Word32 q_data_ivas_fx( - Word16 *pTmp1, /* i: M-dimensional input vector x2.56 */ - const Word16 *w1, /* i: M-dimensional weight vector Q8 */ - Word16 *quant, /* o: quantized vector x2.56 */ - Word16 *cv_out, /* o: non-scaled lattice codevector x2.56 */ - Word16 *idx_lead, /* o: leader indexes for each subvector */ - Word16 *idx_scale, /* o: scale indexes for each subvector */ - const Word16 *p_sigma, /* i: standard deviation x2.56 */ - const Word16 *p_inv_sigma, /* i: inverse standard deviation Q15 */ - const Word16 *p_scales, /* i: scale values Q11 */ - const Word16 *p_no_lead /* i: number of leaders for each truncation and each subvector */ + Word16 *pTmp1, /* i : M-dimensional input vector x2.56 */ + const Word16 *w1, /* i : M-dimensional weight vector Q8 */ + Word16 *quant, /* o : quantized vector x2.56 */ + Word16 *cv_out, /* o : non-scaled lattice codevector x2.56 */ + Word16 *idx_lead, /* o : leader indexes for each subvector */ + Word16 *idx_scale, /* o : scale indexes for each subvector */ + const Word16 *p_sigma, /* i : standard deviation x2.56 */ + const Word16 *p_inv_sigma, /* i : inverse standard deviation Q15 */ + const Word16 *p_scales, /* i : scale values Q11 */ + const Word16 *p_no_lead /* i : number of leaders for each truncation and each subvector */ ) { Word32 dist, L_tmp; @@ -151,6 +151,8 @@ static Word32 q_data_ivas_fx( return dist; } + + /*-----------------------------------------------------------------* * mslvq_cng() * @@ -158,7 +160,6 @@ static Word32 q_data_ivas_fx( * LVQ has separate codebook for each individual first stage index *-----------------------------------------------------------------*/ - Word32 mslvq_cng_fx( Word16 idx_cv, /* i : index of cv from previous stage */ Word16 *pTmp, /* i : 16 dimensional input vector x2.56*/ @@ -222,6 +223,7 @@ Word32 mslvq_cng_fx( return dist; } + Word32 mslvq_cng_ivas_fx( Word16 idx_cv, /* i : index of cv from previous stage */ Word16 *pTmp, /* i : 16 dimensional input vector x2.56*/ @@ -298,26 +300,28 @@ Word32 mslvq_cng_ivas_fx( return dist; } + + /*-----------------------------------------------------------------* * prepare_data_fx() * *-----------------------------------------------------------------*/ + static void prepare_data_fx( - Word16 *xsort, /* o: normalized absolute valued input vector Q10 */ - Word16 *sign, /* o: signs of input vector */ - Word16 *data, /* i: input vector x2.56 */ - Word32 *w, /* o; scaled weights Q-4 */ - const Word16 *w_in, /* i: input weights Q8 */ - const Word16 *sigma, /* i: standard deviation x2.56 */ - const Word16 *inv_sigma, /* i: inverse standard deviation Q15 */ - Word16 *p_sig /* o: parity of input vector */ + Word16 *xsort, /* o : normalized absolute valued input vector Q10 */ + Word16 *sign, /* o : signs of input vector */ + Word16 *data, /* i : input vector x2.56 */ + Word32 *w, /* o ; scaled weights Q-4 */ + const Word16 *w_in, /* i : input weights Q8 */ + const Word16 *sigma, /* i : standard deviation x2.56 */ + const Word16 *inv_sigma, /* i : inverse standard deviation Q15 */ + Word16 *p_sig /* o : parity of input vector */ ) { Word16 j, sig; Word16 s, inv_s; Word32 L_in; - /* scale data */ FOR( j = 0; j < LATTICE_DIM; j++ ) { @@ -358,20 +362,22 @@ move16(); return; } + /*-----------------------------------------------------------------* * calculate_min_dist() * *-----------------------------------------------------------------*/ + static Word32 calculate_min_dist_fx( - Word16 cv_pot[LATTICE_DIM], /* i: sorted absolute valued normalized input vector Q10 */ - Word16 no_scales, /* i: number of scales */ - const Word16 *scale, /* i: scale values Q11 */ - const Word32 *w, /* i: scaled weights Q-4 */ - Word16 *p_best_scale, /* o: pointer to obtained scale value */ - Word16 *p_best_idx, /* o: pointer to obtained leader index */ - const Word16 *no_leaders, /* i: number of leaders for each truncation */ - Word16 sig, /* i: parity of input vector */ - Word16 *indx /* i: permutation vector indicating the order of the sorted input vector */ + Word16 cv_pot[LATTICE_DIM], /* i : sorted absolute valued normalized input vector Q10 */ + Word16 no_scales, /* i : number of scales */ + const Word16 *scale, /* i : scale values Q11 */ + const Word32 *w, /* i : scaled weights Q-4 */ + Word16 *p_best_scale, /* o : pointer to obtained scale value */ + Word16 *p_best_idx, /* o : pointer to obtained leader index */ + const Word16 *no_leaders, /* i : number of leaders for each truncation */ + Word16 sig, /* i : parity of input vector */ + Word16 *indx /* i : permutation vector indicating the order of the sorted input vector */ ) { Word16 k, l, j, best_scale = -1, best_idx = -1; @@ -379,7 +385,6 @@ static Word32 calculate_min_dist_fx( Word32 tmp_dist, min_dist; Word32 w_norm[LATTICE_DIM]; - Word16 wx[LATTICE_DIM]; const Word16 *pl_crt; Word32 sum1[NO_LEADERS], sum2[NO_LEADERS]; @@ -543,12 +548,12 @@ static Word32 calculate_min_dist_fx( return min_dist; } + /*-----------------------------------------------------------------* * quantize_data_fx() * *-----------------------------------------------------------------*/ - static Word32 quantize_data_fx( Word16 *data, /* i : residual LSF data to quantize x2.56*/ const Word16 *w_in, /* i : weights Q10*/ @@ -813,15 +818,16 @@ static void sort_desc_ind_fx( * * sorts in descending order and computes indices in the sorted vector *-----------------------------------------------------------------*/ + void index_lvq_fx( - Word16 *quant, /* i : codevector to be indexed (2 8-dim subvectors) Q13*/ - Word16 *idx_lead, /* i : leader class index for each subvector */ - Word16 *idx_scale, /* i :scale index for each subvector */ - Word16 mode, /* i : integer signalling the quantizer structure for the current bitrate */ - Word16 *index, /* o : encoded index (represented on 3 short each with 15 bits ) */ - Word32 *p_offset_scale1, /* i : scales for first subvector */ - Word32 *p_offset_scale2, /* i : scales for second subvector */ - Word16 *p_no_scales /* i : number of scales for each subvector */ + Word16 *quant, /* i : codevector to be indexed (2 8-dim subvectors) Q13*/ + Word16 *idx_lead, /* i : leader class index for each subvector */ + Word16 *idx_scale, /* i : scale index for each subvector */ + Word16 mode, /* i : integer signalling the quantizer structure for the current bitrate */ + Word16 *index, /* o : encoded index (represented on 3 short each with 15 bits ) */ + Word32 *p_offset_scale1, /* i : scales for first subvector */ + Word32 *p_offset_scale2, /* i : scales for second subvector */ + Word16 *p_no_scales /* i : number of scales for each subvector */ ) { Word32 index1, index2; @@ -862,12 +868,13 @@ void index_lvq_fx( return; } + void index_lvq_ivas_fx( - Word16 *quant, /* i : codevector to be indexed (2 8-dim subvectors) Q13*/ - Word16 *idx_lead, /* i : leader class index for each subvector */ - Word16 *idx_scale, /* i :scale index for each subvector */ - Word16 mode, /* i : integer signalling the quantizer structure for the current bitrate */ - Word16 *index, /* o : encoded index (represented on 3 short each with 15 bits ) */ + Word16 *quant, /* i : codevector to be indexed (2 8-dim subvectors) Q13*/ + Word16 *idx_lead, /* i : leader class index for each subvector */ + Word16 *idx_scale, /* i : scale index for each subvector */ + Word16 mode, /* i : integer signalling the quantizer structure for the current bitrate */ + Word16 *index, /* o : encoded index (represented on 3 short each with 15 bits ) */ const Word16 prediction_flag ) { Word32 index1, index2; @@ -908,15 +915,18 @@ void index_lvq_ivas_fx( return; } + + /*-----------------------------------------------------------------* * encode_comb() * * creates an index for the lattice codevector *-----------------------------------------------------------------*/ -Word32 encode_comb_fx( /* o : index of the absolute valued codevector*/ - Word16 *cv, /* i : codevector to be indexed Q13*/ - Word16 idx_lead /* i : leader class index, to know the values */ +/* o: index of the absolute valued codevector */ +Word32 encode_comb_fx( + Word16 *cv, /* i : codevector to be indexed Q13*/ + Word16 idx_lead /* i : leader class index, to know the values */ ) { Word16 idx_sign, idx_ld_class; @@ -938,10 +948,11 @@ Word32 encode_comb_fx( /* o : index of the absolute valued code * gives the index in a class of leaders without considering the sign yet *-----------------------------------------------------------------*/ -static Word16 index_leaders_fx( /* o : index */ - Word16 *cv, /* i : codevector to be indexed Q13*/ - Word16 idx_lead, /* i : leader class index */ - Word16 dim /* i : vector dimension */ +/* o : index */ +static Word16 index_leaders_fx( + Word16 *cv, /* i : codevector to be indexed Q13*/ + Word16 idx_lead, /* i : leader class index */ + Word16 dim /* i : vector dimension */ ) { Word16 index; @@ -1009,11 +1020,12 @@ static Word16 index_leaders_fx( /* o : index * It returns the number of such positions and their values in the array 'p'. *-----------------------------------------------------------------*/ -Word16 find_pos_fx( /* o : number of positions */ - Word16 *c, /* i : input vector Q13*/ - Word16 len, /* i : input vector dim */ - Word16 arg, /* i : argument to be compared with Q13*/ - Word16 *p /* o : vector of positions */ +/* o : number of positions */ +Word16 find_pos_fx( + Word16 *c, /* i : input vector Q13*/ + Word16 len, /* i : input vector dim */ + Word16 arg, /* i : argument to be compared with Q13*/ + Word16 *p /* o : vector of positions */ ) { Word16 i = 0, j = 0; @@ -1030,6 +1042,8 @@ Word16 find_pos_fx( /* o : number of positions */ return j; } + + /*-----------------------------------------------------------------* * encode_sign_pc1() * @@ -1037,9 +1051,11 @@ Word16 find_pos_fx( /* o : number of positions */ * Gives the index of the signs - binary representation where negative sign stands for 1 * and positive sign stands for 1. *-----------------------------------------------------------------*/ -static Word16 encode_sign_pc1_fx( /* o : index of signs */ - Word16 parity, /* i : parity of the leader class to which the codevector belongs */ - Word16 *cv /* i : input codevector Q13*/ + +/* o : index of signs */ +static Word16 encode_sign_pc1_fx( + Word16 parity, /* i : parity of the leader class to which the codevector belongs */ + Word16 *cv /* i : input codevector Q13*/ ) { Word16 idx_sign; @@ -1072,6 +1088,7 @@ static Word16 encode_sign_pc1_fx( /* o : index of signs return idx_sign; } + /*-----------------------------------------------------------------* * take_out_val() * @@ -1102,15 +1119,18 @@ static void take_out_val_fx( return; } + /*-----------------------------------------------------------------------* * c2idx() * Indexing of vectors having k non-nul positions located in the positions * given by the array p. *-----------------------------------------------------------------------*/ -Word16 c2idx_fx( /* o: index */ - Word16 n, /* i: vector lenght */ - Word16 *p, /* i: non null value positions */ - Word16 k /* i: non-nullnumber of values */ + +/* o: index */ +Word16 c2idx_fx( + Word16 n, /* i : vector lenght */ + Word16 *p, /* i : non null value positions */ + Word16 k /* i : non-nullnumber of values */ ) { Word16 skip, i, p0; @@ -1147,6 +1167,7 @@ Word16 c2idx_fx( /* o: index */ * Encodes the LSF residual *-----------------------------------------------------------------*/ +/*Return dist in q 22*/ Word32 mslvq_ivas_16( Word16 *pTmp, /* i : M-dimensional input vector */ Word16 *quant, /* o : quantized vector */ @@ -1157,7 +1178,6 @@ Word32 mslvq_ivas_16( const Word16 mode, /* i : number indicating the coding type (V/UV/G...)*/ const Word16 mode_glb, /* i : LVQ coding mode */ const Word16 pred_flag /* i : prediction flag (0: safety net, 1,2 - predictive )*/ - /*Retunr dist in q 22*/ ) { Word32 dist, L_tmp; diff --git a/lib_enc/pitch_ol_fx.c b/lib_enc/pitch_ol_fx.c index 571b73500c617f58570d1a3fda4de7fb9a2957a6..9e8434cfc160e92ea6c00ba85b6e3a060e57e468 100644 --- a/lib_enc/pitch_ol_fx.c +++ b/lib_enc/pitch_ol_fx.c @@ -2051,8 +2051,8 @@ static Word16 pitch_coherence_fx( *-----------------------------------------------------------------*/ static void LP_Decim2_Copy( - const Word16 x[], /* i: signal to process */ - Word16 y[], /* o: signal to process */ + const Word16 x[], /* i : signal to process */ + Word16 y[], /* o : signal to process */ Word16 l, /* i : size of filtering */ Word16 mem[] /* i/o: memory (size=3) */ ) diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 619068099dc15b32252807cd3fefe563ae533b2c..8f99230c38de989d8b73e77cb2b9c68792ec3e13 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -63,11 +63,11 @@ void analy_lp_fx( /*1 r: comfort noise gain factor */ void AVQ_cod_fx( - const Word16 xri[], /* i: vector to quantize */ - Word16 xriq[], /* o: quantized normalized vector (assuming the bit budget is enough) */ - const Word16 NB_BITS, /* i: number of allocated bits */ - const Word16 Nsv, /* i: number of subvectors (lg=Nsv*8) */ - const Word16 Q_in_ref /* i: Scaling i */ + const Word16 xri[], /* i : vector to quantize */ + Word16 xriq[], /* o : quantized normalized vector (assuming the bit budget is enough) */ + const Word16 NB_BITS, /* i : number of allocated bits */ + const Word16 Nsv, /* i : number of subvectors (lg=Nsv*8) */ + const Word16 Q_in_ref /* i : Scaling i */ ); void AVQ_encmux_fx( @@ -76,7 +76,7 @@ void AVQ_encmux_fx( Word16 xriq[], /* i/o: rounded subvectors [0..8*Nsv-1] followed by rounded bit allocations [8*Nsv..8*Nsv+Nsv-1] */ Word16 *nb_bits, /* i/o: number of allocated bits */ - const Word16 Nsv, /* i: number of subvectors */ + const Word16 Nsv, /* i : number of subvectors */ Word16 nq_out[], /* o : AVQ nq index */ Word16 avq_bit_sFlag, /* i : flag for AVQ bit saving solution */ Word16 trgtSvPos /* i : target SV for AVQ bit savings */ @@ -246,7 +246,7 @@ void ivas_long_enr_fx( /* o: MDCT A/B decision */ Word16 mdct_classifier_fx( - const Word16 *Y, /* i: re[0], re[1], ..., re[n/2], im[n/2 - 1], im[n/2 - 2], ..., im[1] */ + const Word16 *Y, /* i : re[0], re[1], ..., re[n/2], im[n/2 - 1], im[n/2 - 2], ..., im[1] */ Encoder_State *st_fx, /* i/o: Encoder state variable */ Word32 *cldfbBuf_Ener, Word16 enerBuffer_exp, @@ -642,7 +642,7 @@ void vad_param_updt_fx( const Word16 old_pitch1, /* i : OL pitch value from last frame */ const Word16 corr_shift, /* i : correlation shift Q15*/ const Word16 corr_shiftR, /* i : correlation shift */ - const Word16 Az[], /* i: a coeffs Q12 */ + const Word16 Az[], /* i : a coeffs Q12 */ FRONT_VAD_ENC_HANDLE hFrontVad[], /* i/o: front-VAD handles */ const Word16 n_channels /* i : number of channels */ ); @@ -767,9 +767,9 @@ void fcb_pulse_track_joint_fx( Word16 gain_quant_fx( Word32 *gain, /* i/o: quantized gain */ Word16 *gain16, - const Word16 c_min, /* i: log10 of lower limit in Q14 */ - const Word16 c_max, /* i: log10 of upper limit in Q13 */ - const Word16 bits, /* i: number of bits to quantize */ + const Word16 c_min, /* i : log10 of lower limit in Q14 */ + const Word16 c_max, /* i : log10 of upper limit in Q13 */ + const Word16 bits, /* i : number of bits to quantize */ Word16 *expg ); void gsc_enc_fx( @@ -1174,14 +1174,14 @@ Word16 SQ_gain_estimate_fx( ); void tcx_scalar_quantization_fx( - Word32 *x, /* i: i coefficients */ - Word16 x_e, /* i: exponent */ - Word16 *xq, /* o: quantized coefficients */ - Word16 L_frame, /* i: frame length */ - Word16 gain, /* i: quantization gain */ - Word16 gain_e, /* i: quantization gain exponent */ - Word16 offset, /* i: rounding offset (deadzone) */ - Word8 const *memQuantZeros, /* i: coefficients to be set to 0 */ + Word32 *x, /* i : i coefficients */ + Word16 x_e, /* i : exponent */ + Word16 *xq, /* o : quantized coefficients */ + Word16 L_frame, /* i : frame length */ + Word16 gain, /* i : quantization gain */ + Word16 gain_e, /* i : quantization gain exponent */ + Word16 offset, /* i : rounding offset (deadzone) */ + Word8 const *memQuantZeros, /* i : coefficients to be set to 0 */ const Word16 alfe_flag ); Word16 tcx_scalar_quantization_rateloop_fx( @@ -1226,38 +1226,38 @@ Word16 tcx_scalar_quantization_rateloop_ivas_fx( const Word16 element_mode ); void tcx_noise_factor_fx( - Word32 *x_orig, /* i: unquantized mdct coefficients */ - Word16 x_orig_e, /* i: exponent */ - Word32 *sqQ, /* i: quantized mdct coefficients */ - Word16 iFirstLine, /* i: first coefficient to be considered */ - Word16 lowpassLine, /* i: last nonzero coefficients after low-pass */ - Word16 nTransWidth, /* i: minimum size of hole to be checked */ - Word16 L_frame, /* i: frame length */ - Word16 gain_tcx, /* i: tcx gain */ - Word16 gain_tcx_e, /* i: gain exponent */ - Word16 tiltCompFactor, /* i: LPC tilt compensation factor */ - Word16 *fac_ns, /* o: noise factor */ - Word16 *quantized_fac_ns /* o: quantized noise factor */ + Word32 *x_orig, /* i : unquantized mdct coefficients */ + Word16 x_orig_e, /* i : exponent */ + Word32 *sqQ, /* i : quantized mdct coefficients */ + Word16 iFirstLine, /* i : first coefficient to be considered */ + Word16 lowpassLine, /* i : last nonzero coefficients after low-pass */ + Word16 nTransWidth, /* i : minimum size of hole to be checked */ + Word16 L_frame, /* i : frame length */ + Word16 gain_tcx, /* i : tcx gain */ + Word16 gain_tcx_e, /* i : gain exponent */ + Word16 tiltCompFactor, /* i : LPC tilt compensation factor */ + Word16 *fac_ns, /* o : noise factor */ + Word16 *quantized_fac_ns /* o : quantized noise factor */ ); void tcx_noise_factor_ivas_fx( - Word32 *x_orig, /* i: unquantized mdct coefficients */ - Word16 x_orig_e, /* i: exponent */ - Word32 *sqQ, /* i: quantized mdct coefficients, exponent = x_orig_e */ - Word16 iFirstLine, /* i: first coefficient to be considered */ - Word16 lowpassLine, /* i: last nonzero coefficients after low-pass */ - Word16 nTransWidth, /* i: minimum size of hole to be checked */ - Word16 L_frame, /* i: frame length */ - Word16 gain_tcx, /* i: tcx gain */ - Word16 gain_tcx_e, /* i: gain exponent */ - Word16 tiltCompFactor, /* i: LPC tilt compensation factor */ - Word16 *fac_ns, /* o: noise factor, Q15 */ - Word16 *quantized_fac_ns, /* o: quantized noise factor, Q0 */ - Word16 element_mode /* i: element mode */ + Word32 *x_orig, /* i : unquantized mdct coefficients */ + Word16 x_orig_e, /* i : exponent */ + Word32 *sqQ, /* i : quantized mdct coefficients, exponent = x_orig_e */ + Word16 iFirstLine, /* i : first coefficient to be considered */ + Word16 lowpassLine, /* i : last nonzero coefficients after low-pass */ + Word16 nTransWidth, /* i : minimum size of hole to be checked */ + Word16 L_frame, /* i : frame length */ + Word16 gain_tcx, /* i : tcx gain */ + Word16 gain_tcx_e, /* i : gain exponent */ + Word16 tiltCompFactor, /* i : LPC tilt compensation factor */ + Word16 *fac_ns, /* o : noise factor, Q15 */ + Word16 *quantized_fac_ns, /* o : quantized noise factor, Q0 */ + Word16 element_mode /* i : element mode */ ); void tcx_encoder_memory_update_ivas_fx( - Word16 *wsig, /* i : target weighted signal, Q_new */ + Word16 *wsig, /* i : target weighted signal, Q_new */ Word16 *xn_buf, /* i/o: mdct output buffer/time domain weigthed synthesis, Q_new */ Word16 L_frame_glob, /* i : global frame length */ const Word16 *Ai, /* i : Unquantized (interpolated) LPC coefficients, Q12 */ @@ -1269,48 +1269,48 @@ void tcx_encoder_memory_update_ivas_fx( Word16 Q_new ); void tcx_encoder_memory_update_fx( - Word16 *wsig, /* i: targert weighted signal */ - Word16 *xn_buf, /* i/o: mdct output buffer/TD weigthed synthesis */ - Word16 L_frame_glob, /* i: global frame length */ - const Word16 *Ai, /* i: Unquantized (interpolated) LPC coefficients */ - const Word16 *A, /* i: Quantized LPC coefficients */ - Word16 preemph, /* i: preemphasis factor */ - LPD_state *LPDmem, /* i/o: coder memory state */ + Word16 *wsig, /* i : targert weighted signal */ + Word16 *xn_buf, /* i/o: mdct output buffer/TD weigthed synthesis */ + Word16 L_frame_glob, /* i : global frame length */ + const Word16 *Ai, /* i : Unquantized (interpolated) LPC coefficients */ + const Word16 *A, /* i : Quantized LPC coefficients */ + Word16 preemph, /* i : preemphasis factor */ + LPD_state *LPDmem, /* i/o: coder memory state */ Encoder_State *st, - Word16 *synthout, /* o: synthesis signal */ + Word16 *synthout, /* o : synthesis signal */ Word16 Q_new, Word16 shift ); Word16 tcx_ari_res_Q_spec_fx( - const Word32 x_orig[], /* i: original spectrum Q31-e */ - Word16 x_orig_e, /* i: original spectrum exponent Q0 */ - const Word16 signs[], /* i: signs (x_orig[.]<0) Q0 */ - Word32 x_Q[], /* i/o: quantized spectrum Q31-e */ - Word16 x_Q_e, /* i: quantized spectrum exponent Q0 */ - Word16 L_frame, /* i: number of lines Q0 */ - Word16 gain, /* i: TCX gain Q15-e */ - Word16 gain_e, /* i: TCX gain exponent Q0 */ - Word16 prm[], /* o: bit-stream Q0 */ - Word16 target_bits, /* i: number of bits available Q0 */ - Word16 bits, /* i: number of bits used so far Q0 */ - Word16 deadzone, /* i: quantizer deadzone Q15 */ - const Word16 x_fac[] /* i: spectrum post-quantization factors Q14 */ + const Word32 x_orig[], /* i : original spectrum Q31-e */ + Word16 x_orig_e, /* i : original spectrum exponent Q0 */ + const Word16 signs[], /* i : signs (x_orig[.]<0) Q0 */ + Word32 x_Q[], /* i/o: quantized spectrum Q31-e */ + Word16 x_Q_e, /* i : quantized spectrum exponent Q0 */ + Word16 L_frame, /* i : number of lines Q0 */ + Word16 gain, /* i : TCX gain Q15-e */ + Word16 gain_e, /* i : TCX gain exponent Q0 */ + Word16 prm[], /* o : bit-stream Q0 */ + Word16 target_bits, /* i : number of bits available Q0 */ + Word16 bits, /* i : number of bits used so far Q0 */ + Word16 deadzone, /* i : quantizer deadzone Q15 */ + const Word16 x_fac[] /* i : spectrum post-quantization factors Q14 */ ); Word16 tcx_ari_res_Q_spec_ivas_fx( - const Word32 x_orig[], /* i: original spectrum Q31-e */ - Word16 x_orig_e, /* i: original spectrum exponent Q0 */ - const Word16 signs[], /* i: signs (x_orig[.]<0) Q0 */ - Word32 x_Q[], /* i/o: quantized spectrum Q31-e */ - Word16 x_Q_e, /* i: quantized spectrum exponent Q0 */ - Word16 L_frame, /* i: number of lines Q0 */ - Word16 gain, /* i: TCX gain Q15-e */ - Word16 gain_e, /* i: TCX gain exponent Q0 */ - Word16 prm[], /* o: bit-stream Q0 */ - Word16 target_bits, /* i: number of bits available Q0 */ - Word16 bits, /* i: number of bits used so far Q0 */ - Word16 deadzone, /* i: quantizer deadzone Q15 */ - const Word16 x_fac[] /* i: spectrum post-quantization factors Q14 */ + const Word32 x_orig[], /* i : original spectrum Q31-e */ + Word16 x_orig_e, /* i : original spectrum exponent Q0 */ + const Word16 signs[], /* i : signs (x_orig[.]<0) Q0 */ + Word32 x_Q[], /* i/o: quantized spectrum Q31-e */ + Word16 x_Q_e, /* i : quantized spectrum exponent Q0 */ + Word16 L_frame, /* i : number of lines Q0 */ + Word16 gain, /* i : TCX gain Q15-e */ + Word16 gain_e, /* i : TCX gain exponent Q0 */ + Word16 prm[], /* o : bit-stream Q0 */ + Word16 target_bits, /* i : number of bits available Q0 */ + Word16 bits, /* i : number of bits used so far Q0 */ + Word16 deadzone, /* i : quantizer deadzone Q15 */ + const Word16 x_fac[] /* i : spectrum post-quantization factors Q14 */ ); Word16 tcx_res_Q_gain_fx( @@ -1593,10 +1593,10 @@ Word16 ari_encode_14bits_ext_fx( ); Word16 ari_put_bit_plus_follow( - Word16 ptr[], /* o: bit-stream Q0*/ - Word16 bp, /* i: bit-stream position Q0*/ - Word16 bits_to_follow, /* i: number of opposite bits to follow 'bit' Q0*/ - Word16 bit /* i: bit to send Q0*/ + Word16 ptr[], /* o : bit-stream Q0*/ + Word16 bp, /* i : bit-stream position Q0*/ + Word16 bits_to_follow, /* i : number of opposite bits to follow 'bit' Q0*/ + Word16 bit /* i : bit to send Q0*/ ); Word16 ari_done_encoding_14bits_fx( @@ -1605,7 +1605,7 @@ Word16 ari_done_encoding_14bits_fx( TastatEnc *s ); void reset_rf_indices_fx( - Encoder_State *st /* i: state structure - contains partial RF indices */ + Encoder_State *st /* i : state structure - contains partial RF indices */ ); void CNG_enc_fx( @@ -1739,13 +1739,13 @@ void initFdCngEnc_fx( void configureFdCngEnc_fx( HANDLE_FD_CNG_ENC hs, /* i/o: Contains the variables related to the CLDFB-based CNG process */ - const Word16 bandwidth, /* i: bandwidth Q0*/ + const Word16 bandwidth, /* i : bandwidth Q0*/ const Word32 bitrate /* Q0 */ ); /* Perform noise estimation */ void perform_noise_estimation_enc_fx( - Word32 *band_energies, /* i: energy in critical bands without minimum noise floor MODE2_E_MIN exp_band_energies*/ + Word32 *band_energies, /* i : energy in critical bands without minimum noise floor MODE2_E_MIN exp_band_energies*/ Word16 exp_band_energies, Word32 *enerBuffer, /* enerBuffer_exp */ Word16 enerBuffer_exp, @@ -1753,7 +1753,7 @@ void perform_noise_estimation_enc_fx( ); void perform_noise_estimation_enc_ivas_fx( - Word32 *band_energies, /* i: energy in critical bands without minimum noise floor MODE2_E_MIN band_energies_exp*/ + Word32 *band_energies, /* i : energy in critical bands without minimum noise floor MODE2_E_MIN band_energies_exp*/ Word16 band_energies_exp, Word32 *enerBuffer, /* enerBuffer_exp */ Word16 enerBuffer_exp, @@ -1764,17 +1764,17 @@ void perform_noise_estimation_enc_ivas_fx( /* Adjust the noise estimator at the beginning of each CNG phase (encoder-side) */ Word16 AdjustFirstSID_fx( - Word16 npart, /* i : number of parts Q0*/ - Word32 *msPeriodog, /* i : pointer to periodog vector msPeriodog_exp */ - Word16 msPeriodog_exp, /* i : exponent of periodog vector */ - Word32 *energy_ho, /* i/o : pointer to energy energy_ho_exp*/ - Word16 *energy_ho_exp, /* i/o : pointer to exponent of energy */ - Word32 *msNoiseEst, /* i/o : pointer to estimated noise msNoiseEst_exp*/ - Word16 *msNoiseEst_exp, /* i/o : pointer to exponent of estimated noise */ - Word32 *msNoiseEst_old, /* i/o : pointer to old estimated noise msNoiseEst_old_exp*/ - Word16 *msNoiseEst_old_exp, /* i/o : pointer to exponent of old estimated noise */ - Word16 *active_frame_counter, /* i/o : pointer to active frame counter Q0*/ - Encoder_State *stcod /* i : pointer to Coder_State_Plus structure */ + Word16 npart, /* i : number of parts Q0*/ + Word32 *msPeriodog, /* i : pointer to periodog vector msPeriodog_exp */ + Word16 msPeriodog_exp, /* i : exponent of periodog vector */ + Word32 *energy_ho, /* i/o: pointer to energy energy_ho_exp*/ + Word16 *energy_ho_exp, /* i/o: pointer to exponent of energy */ + Word32 *msNoiseEst, /* i/o: pointer to estimated noise msNoiseEst_exp*/ + Word16 *msNoiseEst_exp, /* i/o: pointer to exponent of estimated noise */ + Word32 *msNoiseEst_old, /* i/o: pointer to old estimated noise msNoiseEst_old_exp*/ + Word16 *msNoiseEst_old_exp, /* i/o: pointer to exponent of old estimated noise */ + Word16 *active_frame_counter, /* i/o: pointer to active frame counter Q0*/ + Encoder_State *stcod /* i : pointer to Coder_State_Plus structure */ ); void FdCng_encodeSID_ivas_fx( @@ -1977,16 +1977,16 @@ Word16 ari_done_cbr_encoding_14bits_fx( TastatEnc *s ); void tcx_hm_analyse_fx( - const Word32 abs_spectrum[], /* i: absolute spectrum Q31-e */ - const Word16 *spectrum_e, /* i: absolute spectrum exponent Q0 */ - const Word16 L_frame, /* i: number of spectral lines Q0 */ + const Word32 abs_spectrum[], /* i : absolute spectrum Q31-e */ + const Word16 *spectrum_e, /* i : absolute spectrum exponent Q0 */ + const Word16 L_frame, /* i : number of spectral lines Q0 */ Word32 env[], /* i/o: envelope shape Q16 */ - const Word16 targetBits, /* i: target bit budget Q0 */ - const Word16 coder_type, /* i: coder type Q0 */ - Word16 prm_hm[], /* o: HM parameters Q0 */ - const Word16 LtpPitchLag, /* i: LTP pitch lag or -1 if none Q0 */ - const Word16 LtpGain, /* i: LTP gain Q15 */ - Word16 *hm_bits_out /* o: bit consumption Q0 */ + const Word16 targetBits, /* i : target bit budget Q0 */ + const Word16 coder_type, /* i : coder type Q0 */ + Word16 prm_hm[], /* o : HM parameters Q0 */ + const Word16 LtpPitchLag, /* i : LTP pitch lag or -1 if none Q0 */ + const Word16 LtpGain, /* i : LTP gain Q15 */ + Word16 *hm_bits_out /* o : bit consumption Q0 */ ); void E_ACELP_4tsearchx_fx( @@ -1999,10 +1999,10 @@ void E_ACELP_4tsearchx_fx( const Word16 element_mode ); void E_ACELP_weighted_code( - const Word16 code[], /* i: code Q9*/ - const Word16 H[], /* i: impulse response Q*/ - Word16 Q, /* i: Q format of H */ - Word16 y[] /* o: weighted code Q9*/ + const Word16 code[], /* i : code Q9*/ + const Word16 H[], /* i : impulse response Q*/ + Word16 Q, /* i : Q format of H */ + Word16 y[] /* o : weighted code Q9*/ ); void find_targets_fx( @@ -2122,40 +2122,40 @@ Word16 ACcontextMapping_encode2_estimate_no_mem_s17_LC_fx( CONTEXT_HM_CONFIG *hm_cfg ); void tcx_arith_encode_envelope_fx( - Word32 spectrum[], /* i/o: MDCT coefficients Q31-e */ - Word16 *spectrum_e, /* i/o: MDCT exponent Q0 */ - Word16 signs[], /* o: signs (spectrum[.]<0) Q0 */ - const Word16 L_frame, /* i: frame or MDCT length Q0 */ - const Word16 L_spec, /* i: frame or MDCT length Q0 */ - Encoder_State *st, /* i/o: coder state */ - const Word16 A_ind[], /* i: quantised LPC coefficients Q12 */ - Word16 target_bits, /* i: number of available bits Q0 */ - Word16 prm[], /* o: bitstream parameters Q0 */ - const Word8 use_hm, /* i: use HM in current frame? */ - Word16 prm_hm[], /* o: HM parameter area Q0 */ - const Word16 tcxltp_pitch, /* i: TCX LTP pitch in FD, -1 if n/a Q0*/ - Word16 *arith_bits, /* o: bits used for ari. coding Q0 */ - Word16 *signaling_bits, /* o: bits used for signaling Q0 */ - Word16 *nf_seed, /* o: noise filling seed Q0 */ - const Word16 low_complexity /* i: low-complexity flag Q0 */ + Word32 spectrum[], /* i/o: MDCT coefficients Q31-e */ + Word16 *spectrum_e, /* i/o: MDCT exponent Q0 */ + Word16 signs[], /* o : signs (spectrum[.]<0) Q0 */ + const Word16 L_frame, /* i : frame or MDCT length Q0 */ + const Word16 L_spec, /* i : frame or MDCT length Q0 */ + Encoder_State *st, /* i/o: coder state */ + const Word16 A_ind[], /* i : quantised LPC coefficients Q12 */ + Word16 target_bits, /* i : number of available bits Q0 */ + Word16 prm[], /* o : bitstream parameters Q0 */ + const Word8 use_hm, /* i : use HM in current frame? */ + Word16 prm_hm[], /* o : HM parameter area Q0 */ + const Word16 tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a Q0*/ + Word16 *arith_bits, /* o : bits used for ari. coding Q0 */ + Word16 *signaling_bits, /* o : bits used for signaling Q0 */ + Word16 *nf_seed, /* o : noise filling seed Q0 */ + const Word16 low_complexity /* i : low-complexity flag Q0 */ ); void tcx_arith_encode_envelope_ivas_fx( - Word32 spectrum[], /* i/o: MDCT coefficients Q31-e */ - Word16 *spectrum_e, /* i/o: MDCT exponent Q0 */ - Word16 signs[], /* o: signs (spectrum[.]<0) Q0 */ - const Word16 L_frame, /* i: frame or MDCT length Q0 */ - const Word16 L_spec, /* i: frame or MDCT length Q0 */ - Encoder_State *st, /* i/o: coder state */ - const Word16 A_ind[], /* i: quantised LPC coefficients Q12 */ - Word16 target_bits, /* i: number of available bits Q0 */ - Word16 prm[], /* o: bitstream parameters Q0 */ - const Word8 use_hm, /* i: use HM in current frame? */ - Word16 prm_hm[], /* o: HM parameter area Q0 */ - const Word16 tcxltp_pitch, /* i: TCX LTP pitch in FD, -1 if n/a Q0*/ - Word16 *arith_bits, /* o: bits used for ari. coding Q0 */ - Word16 *signaling_bits, /* o: bits used for signaling Q0 */ - const Word16 low_complexity /* i: low-complexity flag Q0 */ + Word32 spectrum[], /* i/o: MDCT coefficients Q31-e */ + Word16 *spectrum_e, /* i/o: MDCT exponent Q0 */ + Word16 signs[], /* o : signs (spectrum[.]<0) Q0 */ + const Word16 L_frame, /* i : frame or MDCT length Q0 */ + const Word16 L_spec, /* i : frame or MDCT length Q0 */ + Encoder_State *st, /* i/o: coder state */ + const Word16 A_ind[], /* i : quantised LPC coefficients Q12 */ + Word16 target_bits, /* i : number of available bits Q0 */ + Word16 prm[], /* o : bitstream parameters Q0 */ + const Word8 use_hm, /* i : use HM in current frame? */ + Word16 prm_hm[], /* o : HM parameter area Q0 */ + const Word16 tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a Q0*/ + Word16 *arith_bits, /* o : bits used for ari. coding Q0 */ + Word16 *signaling_bits, /* o : bits used for signaling Q0 */ + const Word16 low_complexity /* i : low-complexity flag Q0 */ ); void QuantizeGain( @@ -2165,7 +2165,7 @@ void QuantizeGain( Word16 *pQuantizedGain ); void core_signal_analysis_high_bitrate_fx( - const Word16 *new_samples, /*i: 0Q15*/ + const Word16 *new_samples, /*i : 0Q15*/ const Word16 T_op[3], /* i : open-loop pitch values for quantiz. Q0*/ Word16 lsp_new[], /* Q15 */ Word16 lsp_mid[], /* Q15 */ @@ -2183,7 +2183,7 @@ void core_signal_analysis_high_bitrate_fx( Word16 *Q_new ); void core_signal_analysis_high_bitrate_ivas_fx( - const Word16 *new_samples, /*i: Q0 */ + const Word16 *new_samples, /*i : Q0 */ const Word16 T_op[3], /* i : open-loop pitch values for quantiz. Q0*/ Word16 lsp_new[], /* Q15 */ Word16 lsp_mid[], /* Q15 */ @@ -2214,11 +2214,11 @@ void ShapeSpectrum_fx( Encoder_State *st ); void ShapeSpectrum_ivas_fx( - TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ - Word16 A[], /* input: quantized coefficients NxAz_q[M+1], Q = 14 - norm(A[0])*/ - Word16 gainlpc[], /* output: MDCT gains for the previous frame */ - Word16 gainlpc_e[], /* output: MDCT gains exponents */ - Word16 L_frame_glob, /* input: frame length */ + TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ + Word16 A[], /* i : quantized coefficients NxAz_q[M+1], Q = 14 - norm(A[0])*/ + Word16 gainlpc[], /* o : MDCT gains for the previous frame */ + Word16 gainlpc_e[], /* o : MDCT gains exponents */ + Word16 L_frame_glob, /* i : frame length */ Word16 L_spec, Word32 spectrum[], /* i/o: MDCT spectrum */ Word16 *spectrum_e, /* i/o: MDCT spectrum exponent */ @@ -2237,8 +2237,8 @@ void QuantizeSpectrum_fx( Word16 L_frame_glob, /* i : frame length */ Word16 L_frameTCX_glob, Word16 L_spec, - Word16 nb_bits, /*i : bit budget*/ - Word8 tcxonly, /*i : only TCX flag*/ + Word16 nb_bits, /* i : bit budget*/ + Word8 tcxonly, /* i : only TCX flag*/ Word32 spectrum[], /* i/o: MDCT spectrum, i is shaped MDCT spectrum */ Word16 *spectrum_e, /* i/o: MDCT spectrum exponent */ STnsData *pTnsData, /* i : Tns data */ @@ -2420,21 +2420,21 @@ void GplcTcxEncSetup_fx( Word16 Q_new ); Word16 bass_pf_enc_fx( - const Word16 *orig, /* i : 12.8kHz original signal Q0 */ - const Word16 *syn, /* i : 12.8kHz synthesis to postfilter Q0 */ - const Word16 *T_sf, /* i : Pitch period for all subframes (T_sf[16]) Q0 */ - const Word16 *gainT_sf, /* i : Pitch gain for all subframes (gainT_sf[16]) Q14 */ - const Word16 l_frame, /* i : frame length (should be multiple of l_subfr) Q0 */ - const Word16 l_subfr, /* i : sub-frame length (60/64) Q0 */ - Word16 *gain_factor_param, /* o : quantized gain factor Q0 */ - const Word16 mode, /* i : coding mode of adapt bpf */ - struct MEM_BPF *mem_bpf /* i/o: memory state */ + const Word16 *orig, /* i : 12.8kHz original signal Q0 */ + const Word16 *syn, /* i : 12.8kHz synthesis to postfilter Q0 */ + const Word16 *T_sf, /* i : Pitch period for all subframes (T_sf[16]) Q0 */ + const Word16 *gainT_sf, /* i : Pitch gain for all subframes (gainT_sf[16]) Q14 */ + const Word16 l_frame, /* i : frame length (should be multiple of l_subfr) Q0 */ + const Word16 l_subfr, /* i : sub-frame length (60/64) Q0 */ + Word16 *gain_factor_param, /* o : quantized gain factor Q0 */ + const Word16 mode, /* i : coding mode of adapt bpf */ + struct MEM_BPF *mem_bpf /* i/o: memory state */ ); Word16 vlpc_1st_cod_fx( - const Word16 *lsf, /* i : vector to quantize */ - Word16 *lsfq, /* i/o: i:prediction o:quantized lsf */ - Word16 *wout, /* o : lsf weights */ + const Word16 *lsf, /* i : vector to quantize */ + Word16 *lsfq, /* i/o: i:prediction o:quantized lsf */ + Word16 *wout, /* o : lsf weights */ Word16 rf_mode ); void tcx_ltp_encode_fx( @@ -2509,9 +2509,9 @@ void E_ACELP_findcandidates( Word16 pos_max[] /*Q0*/ ); void E_ACELP_setup_pulse_search_pos( - const PulseConfig *config, /* i: pulse configuration */ - Word16 k, /* i: interation number Q0*/ - UWord8 ipos[] /* o: pulse search positions Q0*/ + const PulseConfig *config, /* i : pulse configuration */ + Word16 k, /* i : interation number Q0*/ + UWord8 ipos[] /* o : pulse search positions Q0*/ ); void E_ACELP_build_code( @@ -2739,7 +2739,7 @@ void IGF_UpdateInfo( const Word16 igfGridIdx /* i : Q0 | IGF grid index */ ); -/**< out: Q15| crest factor */ +/* o: Q15| crest factor */ Word16 IGF_getCrest( Word16 *crest_exp, /**< out: | exponent of crest factor */ const Word32 *powerSpectrum, /**< in: Q31 | power spectrum */ @@ -2748,72 +2748,71 @@ Word16 IGF_getCrest( const Word16 stop /**< in: Q0 | stop subband index */ ); -/**< out: Q15| crest factor */ +/* o: Q15| crest factor */ Word16 IGF_getCrest_ivas( - Word16 *crest_exp, /**< out: | exponent of crest factor */ - const Word32 *powerSpectrum, /**< in: Q31 | power spectrum */ - const Word16 *powerSpectrum_exp, /**< in: | exponent of power spectrum */ - const Word16 start, /**< in: Q0 | start subband index */ - const Word16 stop /**< in: Q0 | stop subband index */ + Word16 *crest_exp, /* o : | exponent of crest factor */ + const Word32 *powerSpectrum, /* i : Q31 | power spectrum */ + const Word16 *powerSpectrum_exp, /* i : | exponent of power spectrum */ + const Word16 start, /* i : Q0 | start subband index */ + const Word16 stop /* i : Q0 | stop subband index */ ); -/**< out: Q15| SFM value */ +/* o: Q15| SFM value */ Word16 IGF_getSFM( - Word16 *SFM_exp, /**< out: | exponent of SFM Factor */ - const Word32 *energy, /**< in: Q31| energies */ - const Word16 *energy_exp, /**< in: | exponent of energies */ - const Word16 start, /**< in: Q0 | start subband index */ - const Word16 stop /**< in: Q0 | stop subband index */ + Word16 *SFM_exp, /* o : | exponent of SFM Factor */ + const Word32 *energy, /* i : Q31| energies */ + const Word16 *energy_exp, /* i : | exponent of energies */ + const Word16 start, /* i : Q0 | start subband index */ + const Word16 stop /* i : Q0 | stop subband index */ ); -/**< out: Q15| SFM value */ +/* o: Q15| SFM value */ Word16 IGF_getSFM_ivas_fx( - Word16 *SFM_exp, /**< out: | exponent of SFM Factor */ - const Word32 *energy, /**< in: Q31| energies */ - const Word16 *energy_exp, /**< in: | exponent of energies */ - const Word16 start, /**< in: Q0 | start subband index */ - const Word16 stop /**< in: Q0 | stop subband index */ + Word16 *SFM_exp, /* o : | exponent of SFM Factor */ + const Word32 *energy, /* i : Q31| energies */ + const Word16 *energy_exp, /* i : | exponent of energies */ + const Word16 start, /* i : Q0 | start subband index */ + const Word16 stop /* i : Q0 | stop subband index */ ); -/* IGFEnc.c */ void IGF_ErodeSpectrum( - Word16 *highPassEner_exp, /**< out: | exponent of highPassEner */ - const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ - Word32 *pSpectrum, /**< in/out: | MDCT spectrum */ - Word32 *pPowerSpectrum, /**< in/out: | power spectrum */ - Word16 pPowerSpectrum_exp, /**< in: | exponent of power spectrum */ - const Word16 igfGridIdx /**< in: Q0 | IGF grid index */ + Word16 *highPassEner_exp, /* o : exponent of highPassEner */ + const IGF_ENC_INSTANCE_HANDLE hInstance, /* i : instance handle of IGF Encoder */ + Word32 *pSpectrum, /* i/o: MDCT spectrum */ + Word32 *pPowerSpectrum, /* i/o: power spectrum */ + Word16 pPowerSpectrum_exp, /* i : exponent of power spectrum */ + const Word16 igfGridIdx /* i : IGF grid index */ ); void IGF_ErodeSpectrum_ivas_fx( - const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ - Word32 *pSpectrum, /**< in/out: | MDCT spectrum */ - Word32 *pPowerSpectrum, /**< in/out: | power spectrum */ - Word16 pPowerSpectrum_exp, /**< in: | exponent of power spectrum */ - const Word16 igfGridIdx, /**< in: Q0 | IGF grid index */ + const IGF_ENC_INSTANCE_HANDLE hInstance, /* i : instance handle of IGF Encoder */ + Word32 *pSpectrum, /* i/o: MDCT spectrum */ + Word32 *pPowerSpectrum, /* i/o: power spectrum */ + Word16 pPowerSpectrum_exp, /* i : exponent of power spectrum */ + const Word16 igfGridIdx, /* i : IGF grid index */ const Word16 mct_on ); void IGFEncApplyMono_fx( - const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ - const Word16 igfGridIdx, /**< in: Q0 | IGF grid index */ - Encoder_State *st, /**< in: | Encoder state */ - Word32 *pMDCTSpectrum, /**< in: Q31 | MDCT spectrum */ - Word16 MDCTSpectrum_e, /**< in: | exponent of MDCT spectrum */ - Word32 *pPowerSpectrum, /**< in: Q31 | MDCT^2 + MDST^2 spectrum, or estimate */ - Word16 PowerSpectrum_e, /**< in: | exponent of pPowerSpectrum */ - Word16 isTCX20, /**< in: Q0 | flag indicating if the i is TCX20 or TCX10/2xTCX5 */ - Word16 isTNSActive, /**< in: Q0 | flag indicating if the TNS is active */ - Word16 last_core_acelp /**< in: Q0 | indictaor if last frame was acelp coded */ + const IGF_ENC_INSTANCE_HANDLE hInstance, /* i : | instance handle of IGF Encoder */ + const Word16 igfGridIdx, /* i : Q0 | IGF grid index */ + Encoder_State *st, /* i : | Encoder state */ + Word32 *pMDCTSpectrum, /* i : Q31 | MDCT spectrum */ + Word16 MDCTSpectrum_e, /* i : | exponent of MDCT spectrum */ + Word32 *pPowerSpectrum, /* i : Q31 | MDCT^2 + MDST^2 spectrum, or estimate */ + Word16 PowerSpectrum_e, /* i : | exponent of pPowerSpectrum */ + Word16 isTCX20, /* i : Q0 | flag indicating if the i is TCX20 or TCX10/2xTCX5 */ + Word16 isTNSActive, /* i : Q0 | flag indicating if the TNS is active */ + Word16 last_core_acelp /* i : Q0 | indictaor if last frame was acelp coded */ ); void IGFEncApplyMono_ivas_fx( Encoder_State *st, /* i : Encoder state */ - Word16 powerSpectrum_len, /* i: length of pPowerSpectrum_fx*/ + Word16 powerSpectrum_len, /* i : length of pPowerSpectrum_fx */ const Word16 igfGridIdx, /* i : IGF grid index */ Word32 *pMDCTSpectrum_fx, /* i/o: MDCT spectrum */ - Word16 e_mdct, /* i : exponent of pMDCTspectrum */ + Word16 e_mdct, /* i : exponent of pMDCTspectrum */ Word32 *pPowerSpectrum_fx, /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ - Word16 *e_ps, /* i : exponent of pPowerSpectrum */ + Word16 *e_ps, /* i : exponent of pPowerSpectrum */ const Word16 isTCX20, /* i : flag indicating if the input is TCX20 or TCX10/2xTCX5 */ const Word8 isTNSActive, /* i : flag indicating if the TNS is active */ const Word16 sp_aud_decision0, /* i : first stage switching decision */ @@ -2827,14 +2826,13 @@ void IGFEncConcatenateBitstream_ivas_fx( ); void IGFEncConcatenateBitstream_fx( - const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ - Word16 bsBits, /**< in: Q0 | number of IGF bits written to list of indices */ - Word16 *next_ind, /**< in/out: | pointer to actual bit indice */ - Word16 *nb_bits, /**< in/out: | total number of bits already written */ - Indice *ind_list_fx /**< in: | pointer to list of indices */ + const IGF_ENC_INSTANCE_HANDLE hInstance, /* i : instance handle of IGF Encoder */ + Word16 bsBits, /* i : number of IGF bits written to list of indices */ + Word16 *next_ind, /* i/o: pointer to actual bit indice */ + Word16 *nb_bits, /* i/o: total number of bits already written */ + Indice *ind_list_fx /* i : pointer to list of indices */ ); -/*isf_msvq_ma.c, lsf_msvq_ma.c*/ void msvq_enc_fx( const Word16 *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) (0Q15) */ const Word16 dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */ @@ -2866,11 +2864,11 @@ void msvq_enc_lsf_fx64( ); void midlsf_enc_fx( - const Word16 qlsf0[], /* i: quantized lsf coefficients (3Q12) */ - const Word16 qlsf1[], /* i: quantized lsf coefficients (3Q12) */ - const Word16 lsf[], /* i: lsf coefficients (3Q12) */ - Word16 *idx, /* o: codebook index */ - const Word16 lpcorder, /* i: order of the lpc */ + const Word16 qlsf0[], /* i : quantized lsf coefficients (3Q12) */ + const Word16 qlsf1[], /* i : quantized lsf coefficients (3Q12) */ + const Word16 lsf[], /* i : lsf coefficients (3Q12) */ + Word16 *idx, /* o : codebook index */ + const Word16 lpcorder, /* i : order of the lpc */ const Word32 *Bin_Ener_128_fx, const Word16 Q_ener, const Word8 narrowBand, @@ -3428,16 +3426,16 @@ Flag conv_fx( ivas_error ppp_voiced_encoder_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ SC_VBR_ENC_HANDLE hSC_VBR, - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 last_coder_type_raw, /* i : raw last_coder_type */ - const Word16 old_pitch_buf[], /* i : buffer of old subframe pitch values */ - Word16 *in_fx, /* i : residual signal */ - Word16 *out_fx, /* o : Quantized residual signal */ - Word16 delay_fx, /* i : open loop pitch */ - Word16 *lpc1_fx, /* i : prev frame de-emphasized LPC */ - Word16 *lpc2_fx, /* i : current frame de-emphasized LPC */ - Word16 *exc_fx, /* i: previous frame quantized excitation */ - Word16 *pitch_fx, /* o: floating pitch values for each subframe */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 last_coder_type_raw, /* i : raw last_coder_type */ + const Word16 old_pitch_buf[], /* i : buffer of old subframe pitch values */ + Word16 *in_fx, /* i : residual signal */ + Word16 *out_fx, /* o : Quantized residual signal */ + Word16 delay_fx, /* i : open loop pitch */ + Word16 *lpc1_fx, /* i : prev frame de-emphasized LPC */ + Word16 *lpc2_fx, /* i : current frame de-emphasized LPC */ + Word16 *exc_fx, /* i : previous frame quantized excitation */ + Word16 *pitch_fx, /* o : floating pitch values for each subframe */ Word16 Qres ); void signalling_enc_fx( diff --git a/lib_enc/pvq_encode_fx.c b/lib_enc/pvq_encode_fx.c index 8db3fc5b4ea8d25bfd323e0e36e0b6598a922c13..53c18e3abb7238e0f018dc63c70211d311c0c452 100644 --- a/lib_enc/pvq_encode_fx.c +++ b/lib_enc/pvq_encode_fx.c @@ -166,20 +166,23 @@ static Word16 one_pulse_search( return imax; } + + /*-----------------------------------------------------------------------* * Function pvq_encode_fx() * * * *-----------------------------------------------------------------------*/ + void pvq_encode_ivas_fx( BSTR_ENC_HANDLE hBstr, - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - const Word16 *x, /* i: vector to quantize Q15-3=>Q12 */ - Word16 *y, /* o: raw pulses (non-scaled short) Q0 */ - Word16 *xq, /* o: quantized vector Q15 */ - Word32 *L_xq, /* o: quantized vector Q31 fot eval */ - const Word16 pulses, /* i: number of allocated pulses */ - const Word16 dim, /* i: Length of vector */ - const Word16 neg_gain /* i: - Gain use - negative gain in Q15 0..1 */ + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + const Word16 *x, /* i : vector to quantize Q15-3=>Q12 */ + Word16 *y, /* o : raw pulses (non-scaled short) Q0 */ + Word16 *xq, /* o : quantized vector Q15 */ + Word32 *L_xq, /* o : quantized vector Q31 fot eval */ + const Word16 pulses, /* i : number of allocated pulses */ + const Word16 dim, /* i : Length of vector */ + const Word16 neg_gain /* i : Gain use - negative gain in Q15 0..1 */ ) { Word16 i; @@ -377,14 +380,14 @@ void pvq_encode_ivas_fx( void pvq_encode_fx( BSTR_ENC_HANDLE hBstr, - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - const Word16 *x, /* i: vector to quantize Q15-3=>Q12 */ - Word16 *y, /* o: raw pulses (non-scaled short) Q0 */ - Word16 *xq, /* o: quantized vector Q15 */ - Word32 *L_xq, /* o: quantized vector Q31 fot eval */ - const Word16 pulses, /* i: number of allocated pulses */ - const Word16 dim, /* i: Length of vector */ - const Word16 neg_gain /* i: - Gain use - negative gain in Q15 0..1 */ + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + const Word16 *x, /* i : vector to quantize Q15-3=>Q12 */ + Word16 *y, /* o : raw pulses (non-scaled short) Q0 */ + Word16 *xq, /* o : quantized vector Q15 */ + Word32 *L_xq, /* o : quantized vector Q31 fot eval */ + const Word16 pulses, /* i : number of allocated pulses */ + const Word16 dim, /* i : Length of vector */ + const Word16 neg_gain /* i : Gain use - negative gain in Q15 0..1 */ ) { Word16 i; diff --git a/lib_enc/set_impulse_fx.c b/lib_enc/set_impulse_fx.c index 3ee47938446f08090fed1158c832946d166eadb6..4c867dd179e004b48cbb174a30235c6c59145141 100644 --- a/lib_enc/set_impulse_fx.c +++ b/lib_enc/set_impulse_fx.c @@ -51,6 +51,7 @@ static void convolve_tc2_fx( const Word16 g[], const Word16 h[], Word16 y[], con * Notice: gain = gain_trans * gain_pit (computed in trans_enc() function) * * * *---------------------------------------------------------------------------------------*/ + void set_impulse_fx( const Word16 xn_fx[], /* i : target signal Q_new-1+shift*/ const Word16 h_orig_fx[], /* i : impulse response of weighted synthesis filter Q(14+shift)*/ @@ -188,9 +189,11 @@ void set_impulse_fx( correlate_tc_fx( xn_fx, &dd_fx[L_IMPULSE2], gh_fx, sub( start2, L_IMPULSE2 ), L_SUBFR, sub( end1, L_IMPULSE2 ) ); } + /*------------------------------------------------------------* * maxim. criterion *------------------------------------------------------------*/ + FOR( i = start1; i < end1; i++ ) { /* krit = (float)(dd[i]*dd[i])/rr[i] */ @@ -240,6 +243,7 @@ void set_impulse_fx( /*---------------------------------------------------------------* * Form filtered excitation, find gain_trans *---------------------------------------------------------------*/ + convolve_tc2_fx( exc_fx, h_orig_fx, yy1_fx, *imp_pos ); /* Find the ACELP correlations and the pitch gain (for current subframe) */ @@ -264,15 +268,19 @@ void set_impulse_fx( gain16 = i_mult2( gain16, tmp16 ); /* apply sign */ *gain_trans_fx = L_shr( L_deposit_l( gain16 ), i ); // Q7 move32(); + + return; } + /*-------------------------------------------------------------------* * convolve_tc_fx: * * convolution for different vectors' lengths *-------------------------------------------------------------------*/ + static void convolve_tc_fx( - const Word16 g[], /* i : input vector Qx */ - const Word16 h[], /* i : impulse response (or second input vector) Q15 */ + const Word16 g[], /* i : input vector Qx */ + const Word16 h[], /* i : impulse response (or second input vector) Q15 */ Word16 y[], /* o : output vector (result of convolution) 12 bits */ const Word16 L_1, /* i : vector h size Q0 */ const Word16 L_2 /* i : vector g size Q0 */ @@ -292,17 +300,21 @@ static void convolve_tc_fx( y[n] = round_fx_sat( L_sum ); /* Qx */ } + + return; } + + /*-------------------------------------------------------------------* * convolve_tc2_fx: * * convolution for one vector with only L_IMPULSE nonzero coefficients *-------------------------------------------------------------------*/ static void convolve_tc2_fx( - const Word16 g[], /* i : input vector Qx */ - const Word16 h[], /* i : impulse response (or second input vector) Q15 */ + const Word16 g[], /* i : input vector Qx */ + const Word16 h[], /* i : impulse response (or second input vector) Q15 */ Word16 y[], /* o : output vector (result of convolution) 12 bits */ - const Word16 pos_max /* o : artificial impulse position Q0 */ + const Word16 pos_max /* o : artificial impulse position Q0 */ ) { Word32 temp; @@ -326,19 +338,24 @@ static void convolve_tc2_fx( } y[n] = round_fx( temp ); // Qx } + + return; } + + /*-------------------------------------------------------------------* * correlate_tc: * * correlation for different vectors' lengths *-------------------------------------------------------------------*/ + static void correlate_tc_fx( - const Word16 *x, /* i: target signal Qx*/ - Word16 *y, /* o: correlation between x[] and h[] -Q3*/ - const Word16 *h, /* i: impulse response (of weighted synthesis filter) Q15*/ - const Word16 start, /* i: index of iterest Q0*/ - const Word16 L_1, /* i: vector size Q0*/ - const Word16 L_2 /* i: index of interest Q0*/ + const Word16 *x, /* i : target signal Qx*/ + Word16 *y, /* o : correlation between x[] and h[] -Q3*/ + const Word16 *h, /* i : impulse response (of weighted synthesis filter) Q15*/ + const Word16 start, /* i : index of iterest Q0*/ + const Word16 L_1, /* i : vector size Q0*/ + const Word16 L_2 /* i : index of interest Q0*/ ) { Word16 i, j; @@ -353,4 +370,6 @@ static void correlate_tc_fx( } y[i] = round_fx_sat( s ); /* Qx */ } + + return; } diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index 05802bf45c605f2fc23a5fd455e4b4fae6b6a304..17e2adeebb59dc213f802bef5e7c9e0f7d235840 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -968,9 +968,9 @@ void swb_bwe_enc_fx( /* PURPOSE : Scalar quantizer routine */ /*--------------------------------------------------------------------------*/ /* INPUT ARGUMENTS : */ -/* Word16 *cb i: quantizer codebook Q10 */ -/* Word16 cb_length i: length of codebook */ -/* Word16 cb_dim i: dimension of codebook */ +/* Word16 *cb i : quantizer codebook Q10 */ +/* Word16 cb_length i : length of codebook */ +/* Word16 cb_dim i : dimension of codebook */ /*--------------------------------------------------------------------------*/ /* OUTPUT ARGUMENTS : */ /*--------------------------------------------------------------------------*/ @@ -4190,8 +4190,8 @@ static void energy_control_fx_32( *-------------------------------------------------------------------*/ static Word16 decision_hq_generic_class_fx_32( - const Word32 *coefs_fx, /* i: original MDCT spectrum : Q12 */ - const Word16 hq_generic_offset /* i: frequency offset of high frequency spectrum : Q0 */ + const Word32 *coefs_fx, /* i : original MDCT spectrum : Q12 */ + const Word16 hq_generic_offset /* i : frequency offset of high frequency spectrum : Q0 */ ) { Word16 i, k; diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index 843efcf49bbea3b798e082f1cba583ae184e685d..4a549ffef8e0ddd11f52ffc3ff0ea5576cc2bfd9 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -322,21 +322,23 @@ static void getswbindices_har_fx( return; } + + /*--------------------------------------------------------------------------* * GetSubbandCorrIndex2_pulsestep_fx() * *--------------------------------------------------------------------------*/ static Word16 GetSubbandCorrIndex2_pulsestep_fx( - const Word32 *L_inBuf, /* i: original input vector (highband) */ - const Word16 *predBuf_fx, /* i: spectrum smoothing vector */ - const Word16 *predBufMa_fx, /* i: moving averaged spectrum smoothing vector Q=Qss */ - const Word16 fLen, /* i: subband length of highband */ - const Word16 maxLag, /* i: number of search pulse number */ - const GainItem_fx *gi_fx, /* i: lag gain structure */ - const Word16 nZero, /* i: */ - const Word16 ssearch_buflim, /* i: length of search buffer */ - const Word16 *predBuf_ni_fx /* i: spectrum including noise smoothing vector */ + const Word32 *L_inBuf, /* i : original input vector (highband) */ + const Word16 *predBuf_fx, /* i : spectrum smoothing vector */ + const Word16 *predBufMa_fx, /* i : moving averaged spectrum smoothing vector Q=Qss */ + const Word16 fLen, /* i : subband length of highband */ + const Word16 maxLag, /* i : number of search pulse number */ + const GainItem_fx *gi_fx, /* i : lag gain structure */ + const Word16 nZero, /* i : */ + const Word16 ssearch_buflim, /* i : length of search buffer */ + const Word16 *predBuf_ni_fx /* i : spectrum including noise smoothing vector */ ) { Word16 i, j; @@ -546,10 +548,13 @@ static Word16 GetSubbandCorrIndex2_pulsestep_fx( return bestIdx_fx; } + + /*--------------------------------------------------------------------------* * GetSWBIndices_fx() * *--------------------------------------------------------------------------*/ + static void GetSWBIndices_fx( const Word16 *predBuf_fx, /* i : low-frequency band */ /*const Word16 Qss,*/ /* i : Q value of predBuf_fx */ @@ -634,39 +639,43 @@ static void GetSWBIndices_fx( ssearch_buflim_fx, predBuf_ni_fx + search_offset_fx[sb] ); move16(); } + + return; } + + /*--------------------------------------------------------------------------* * gethar_noisegn_fx() * *--------------------------------------------------------------------------*/ static void gethar_noisegn_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word32 L_spectra[], /* i : Qs input MDCT */ - const Word16 QsL, /* i : Q0 Q value for L_spectra, L_xSynth_har */ - const Word16 noise_flr_fx[], /* i : Qss noise floor */ - const Word16 Qss, /* i : Q0 Q value for noise_flr_fx, sspectra */ - Word32 L_xSynth_har[], /* o : Qs output SWB MDCT */ - const Word16 sbWidth[], /* i : Q0 band width for SWB */ - const Word16 lagIndices[], /* i : Q0 lag Indices */ - const Word16 bands, /* i : Q0 all band number */ - const Word16 har_bands, /* i : Q0 harmonic band number */ - const Word16 fLenLow, /* i : Q0 low frequency band width */ - const Word16 fLenHigh, /* i : Q0 SWB band width */ - const Word16 subband_offsets[], /* i : Q0 offset */ - const Word16 subband_search_offset[], /* i : Q0 offset */ - const Word16 band_start[], /* i : Q0 band start array */ - const Word16 band_end[], /* i : Q0 band end array */ - const Word16 band_width[], /* i : Q0 band width */ - Word32 L_band_energy[], /* i : Qbe band energy (Log scale) */ - const Word16 Qbe, /* i : Q0 Q value for L_band_energy */ - Word32 L_be_tonal[], /* o : QbeL tonal energy */ - Word16 *QbeL, /* o : Q0 Q value for L_be_tonal */ - const Word16 *sspectra_fx, /* i : Qss smoothed spectrum */ - const Word16 har_freq_est2, /* i : Q0 for harmonic structure */ - const Word16 pos_max_hfe2, /* i/o : Q0 for harmonic structure */ - Word16 *pul_res_fx, /* o : Q0 */ - GainItem_fx pk_sf_fx[] /* o : */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + const Word32 L_spectra[], /* i : Qs input MDCT */ + const Word16 QsL, /* i : Q0 Q value for L_spectra, L_xSynth_har */ + const Word16 noise_flr_fx[], /* i : Qss noise floor */ + const Word16 Qss, /* i : Q0 Q value for noise_flr_fx, sspectra */ + Word32 L_xSynth_har[], /* o : Qs output SWB MDCT */ + const Word16 sbWidth[], /* i : Q0 band width for SWB */ + const Word16 lagIndices[], /* i : Q0 lag Indices */ + const Word16 bands, /* i : Q0 all band number */ + const Word16 har_bands, /* i : Q0 harmonic band number */ + const Word16 fLenLow, /* i : Q0 low frequency band width */ + const Word16 fLenHigh, /* i : Q0 SWB band width */ + const Word16 subband_offsets[], /* i : Q0 offset */ + const Word16 subband_search_offset[], /* i : Q0 offset */ + const Word16 band_start[], /* i : Q0 band start array */ + const Word16 band_end[], /* i : Q0 band end array */ + const Word16 band_width[], /* i : Q0 band width */ + Word32 L_band_energy[], /* i : Qbe band energy (Log scale) */ + const Word16 Qbe, /* i : Q0 Q value for L_band_energy */ + Word32 L_be_tonal[], /* o : QbeL tonal energy */ + Word16 *QbeL, /* o : Q0 Q value for L_be_tonal */ + const Word16 *sspectra_fx, /* i : Qss smoothed spectrum */ + const Word16 har_freq_est2, /* i : Q0 for harmonic structure */ + const Word16 pos_max_hfe2, /* i/o: Q0 for harmonic structure */ + Word16 *pul_res_fx, /* o : Q0 */ + GainItem_fx pk_sf_fx[] /* o : */ ) { Word16 i; @@ -819,6 +828,8 @@ static void gethar_noisegn_fx( return; } + + /*--------------------------------------------------------------------------* * EncodeSWBSubbands() * @@ -826,6 +837,7 @@ static void gethar_noisegn_fx( * replicated based on the lowband signal. A search is perform * find lowband indices denoting the selected lowband subband. *--------------------------------------------------------------------------*/ + static void EncodeSWBSubbands_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ Word32 *L_spectra, /* i/o: MDCT domain spectrum */ @@ -891,7 +903,6 @@ static void EncodeSWBSubbands_fx( set32_fx( L_xSynth_har, 0, L_FRAME32k ); set16_fx( pul_res_fx, 0, NB_SWB_SUBBANDS ); - IF( EQ_16( hqswb_clas_fx, HQ_HARMONIC ) ) { pos_max_hfe2 = har_est_fx( L_spectra, fLenLow_fx, &har_freq_est1, &har_freq_est2, &flag_dis, prev_frm_hfe2, subband_search_offset_fx, sbWidth_fx, prev_stab_hfe2 ); @@ -924,7 +935,6 @@ static void EncodeSWBSubbands_fx( L_band_energy, Qbe, L_be_tonal, &QbeL, sspectra_fx, har_freq_est2, pos_max_hfe2, pul_res_fx, pk_sf_fx ); - Gettonl_scalfact_fx( L_xSynth_har, QsL, L_spectra_ni, fLenLow_fx, fLenHigh_fx, har_bands_fx, BANDS_fx, L_band_energy, Qbe, band_start_fx, band_end_fx, p2a_flags_fx, L_be_tonal, QbeL, pk_sf_fx, Qss, pul_res_fx ); @@ -1030,6 +1040,7 @@ static void EncodeSWBSubbands_fx( * * Main encoding routine of SWB BWE for the LR MDCT core *--------------------------------------------------------------------------*/ + void swb_bwe_enc_lr_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 L_m_core[], /* i : lowband synthesis */ diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 6f270929b46df5377b88b48d896bb3a73a298047..7e52cca5397ad2ea765de8082d200a3fbe65e789 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -5287,11 +5287,12 @@ static void singlevectortest_gain_fx( /*------------------------------------------------------------------------------*/ static void return_M_Least_fx_GainFrame( - const Word32 *inp, /* i: input Q18*/ - const Word32 *codebook, /* i: codebook Q18*/ - const Word16 num_grp, /* i: number of centroids */ - const Word16 interNum, /* i: number on short list prior to 2nd stage search*/ - Word16 *least /* o: return value */ ) + const Word32 *inp, /* i : input Q18*/ + const Word32 *codebook, /* i : codebook Q18*/ + const Word16 num_grp, /* i : number of centroids */ + const Word16 interNum, /* i : number on short list prior to 2nd stage search*/ + Word16 *least /* o : return value */ +) { Word16 i, k; Word32 distance[1024], mindist; diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 9765655ba4d880bab90ca7e255273a39d60d3b79..6b2543a7591f0a53b65a907457f7badc4f2c7677 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -9,7 +9,6 @@ #include "stl.h" #include "options.h" #include "cnst.h" -//#include "prot_fx.h" #include "rom_basop_util.h" #include "basop_util.h" #include "rom_com.h" @@ -23,7 +22,11 @@ extern const Word16 int_sqr[17]; #define ONE_POINT_ONE_FIVE_Q7 147 #define ONE_POINT_ONE_FIVE_Q23 9646899 -static Word16 quantize( Word32 x, Word16 invGain, Word16 shift, Word32 offset ) +static Word16 quantize( + Word32 x, + Word16 invGain, + Word16 shift, + Word32 offset ) { Word16 tmp16; Word32 tmp32; @@ -41,12 +44,13 @@ static Word16 quantize( Word32 x, Word16 invGain, Word16 shift, Word32 offset ) } /* compute noise-measure flags for spectrum filling and quantization (0: tonal, 1: noise-like) */ -void ComputeSpectrumNoiseMeasure_fx( const Word32 *powerSpec, - Word16 L_frame, - Word16 startLine, - Word8 resetMemory, - Word8 *noiseFlags, - Word16 lowpassLine ) +void ComputeSpectrumNoiseMeasure_fx( + const Word32 *powerSpec, + Word16 L_frame, + Word16 startLine, + Word8 resetMemory, + Word8 *noiseFlags, + Word16 lowpassLine ) { Word16 i, lastTone, j; Word32 s, c; @@ -170,14 +174,17 @@ void ComputeSpectrumNoiseMeasure_fx( const Word32 *powerSpec, move16(); } } + + return; } -void ComputeSpectrumNoiseMeasure_ivas_fx( Word64 *powerSpec, /* Qx */ - Word16 L_frame, /* Q0 */ - Word16 startLine, /* Q0 */ - Word8 resetMemory, /* Q0 */ - Word8 *noiseFlags, /* Q0 */ - Word16 lowpassLine /* Q0 */ +void ComputeSpectrumNoiseMeasure_ivas_fx( + Word64 *powerSpec, /* Qx */ + Word16 L_frame, /* Q0 */ + Word16 startLine, /* Q0 */ + Word8 resetMemory, /* Q0 */ + Word8 *noiseFlags, /* Q0 */ + Word16 lowpassLine /* Q0 */ ) { Word16 i, lastTone, j, exp; @@ -281,9 +288,17 @@ void ComputeSpectrumNoiseMeasure_ivas_fx( Word64 *powerSpec, /* Qx */ move16(); } } + + return; } -static void detectLowpassFac( const Word32 *powerSpec, Word16 powerSpec_e, Word16 L_frame, Word8 rectWin, Word16 *pLpFac, Word16 lowpassLine ) +static void detectLowpassFac( + const Word32 *powerSpec, + Word16 powerSpec_e, + Word16 L_frame, + Word8 rectWin, + Word16 *pLpFac, + Word16 lowpassLine ) { Word16 i, tmp; Word32 threshold; @@ -314,13 +329,17 @@ static void detectLowpassFac( const Word32 *powerSpec, Word16 powerSpec_e, Word1 tmp = mult_r( 22938 /*0.7f Q15*/, round_fx( L_shl( L_mult0( add( i, 1 ), tmp ), 9 ) ) ); *pLpFac = add( tmp, mult_r( 9830 /*0.3f Q15*/, *pLpFac ) ); move16(); + + return; } + /*-----------------------------------------------------------* * Compute noise-measure flags for spectrum filling * * and quantization (0: tonal, 1: noise-like). * * Detect low pass if present. * *-----------------------------------------------------------*/ + void AnalyzePowerSpectrum_fx( Encoder_State *st, /* i/o: encoder states */ Word16 L_frame, /* input: frame length */ @@ -425,19 +444,22 @@ void AnalyzePowerSpectrum_fx( hTcxEnc->measuredBwRatio = 0x4000; move16(); } + + return; } + void AnalyzePowerSpectrum_ivas_fx( - Encoder_State *st, /* i/o: encoder states */ - Word16 L_frame, /* input: frame length */ - Word16 L_frameTCX, /* input: full band frame length */ - Word16 left_overlap, /* input: left overlap length */ - Word16 right_overlap, /* input: right overlap length */ - Word32 const mdctSpectrum[], /* input: MDCT spectrum */ + Encoder_State *st, /* i/o: encoder states */ + Word16 L_frame, /* i : frame length */ + Word16 L_frameTCX, /* i : full band frame length */ + Word16 left_overlap, /* i : left overlap length */ + Word16 right_overlap, /* i : right overlap length */ + Word32 const mdctSpectrum[], /* i : MDCT spectrum */ Word16 mdctSpectrum_e, - Word16 const signal[], /* input: windowed signal corresponding to mdctSpectrum */ + Word16 const signal[], /* i : windowed signal corresponding to mdctSpectrum */ const Word16 q_signal, - Word32 powerSpec[], /* output: Power spectrum. Can point to signal */ + Word32 powerSpec[], /* o : Power spectrum. Can point to signal */ Word16 powerSpec_e[] ) { Word16 i, iStart, iEnd, lowpassLine; @@ -524,22 +546,25 @@ void AnalyzePowerSpectrum_ivas_fx( hTcxEnc->measuredBwRatio = 0x4000; move16(); } + + return; } -void AdaptLowFreqEmph_fx( Word32 x[], - Word16 x_e, - Word16 xq[], - Word16 invGain, - Word16 invGain_e, - Word16 tcx_lpc_shaped_ari, - Word16 lpcGains[], - Word16 lpcGains_e[], - const Word16 lg ) + +void AdaptLowFreqEmph_fx( + Word32 x[], + Word16 x_e, + Word16 xq[], + Word16 invGain, + Word16 invGain_e, + Word16 tcx_lpc_shaped_ari, + Word16 lpcGains[], + Word16 lpcGains_e[], + const Word16 lg ) { Word16 i, i_max, i_max_old, lg_4, tmp16, s; Word32 tmp32; - IF( tcx_lpc_shaped_ari == 0 ) { lg_4 = shr( lg, 2 ); @@ -729,17 +754,20 @@ void AdaptLowFreqEmph_fx( Word32 x[], { PsychAdaptLowFreqEmph_fx( x, lpcGains, lpcGains_e ); } /*if(!tcx_lpc_shaped_ari)*/ + + return; } -void PsychAdaptLowFreqEmph_fx( Word32 x[], - const Word16 lpcGains[], - const Word16 lpcGains_e[] ) + +void PsychAdaptLowFreqEmph_fx( + Word32 x[], + const Word16 lpcGains[], + const Word16 lpcGains_e[] ) { Word16 i; Word16 max, max_e, fac, min, min_e, tmp, tmp_e; Word32 L_tmp; - assert( lpcGains[0] >= 0x4000 ); max = lpcGains[0]; @@ -795,21 +823,24 @@ void PsychAdaptLowFreqEmph_fx( Word32 x[], fac = shl( mult_r( fac, tmp ), 1 ); } } + + return; } -Word16 SQ_gain_fx( /* output: SQ gain */ - Word32 x[], /* input: vector to quantize */ - Word16 x_e, /* input: exponent */ - Word16 nbitsSQ, /* input: number of bits targeted */ - Word16 lg, /* input: vector size (2048 max) */ - Word16 *gain_e ) /* output: SQ gain exponent */ + +/* o: SQ gain */ +Word16 SQ_gain_fx( + Word32 x[], /* i : vector to quantize */ + Word16 x_e, /* i : exponent */ + Word16 nbitsSQ, /* i : number of bits targeted */ + Word16 lg, /* i : vector size (2048 max) */ + Word16 *gain_e ) /* o : SQ gain exponent */ { Word16 i, iter, lg_4, s, tmp16; Word32 ener, tmp32; Word32 target, fac, offset; Word32 en[N_MAX / 4]; - lg_4 = shr( lg, 2 ); /* energy of quadruples with 9dB offset */ @@ -911,19 +942,20 @@ Word16 SQ_gain_fx( /* output: SQ gain */ return tmp16; } -Word16 SQ_gain_ivas_fx( /* output: SQ gain */ - Word32 x[], /* input: vector to quantize */ - Word16 x_e, /* input: exponent */ - Word16 nbitsSQ, /* input: number of bits targeted */ - Word16 lg, /* input: vector size (2048 max) */ - Word16 *gain_e ) /* output: SQ gain exponent */ + +/* o: SQ gain */ +Word16 SQ_gain_ivas_fx( + Word32 x[], /* i : vector to quantize */ + Word16 x_e, /* i : exponent */ + Word16 nbitsSQ, /* i : number of bits targeted */ + Word16 lg, /* i : vector size (2048 max) */ + Word16 *gain_e ) /* o : SQ gain exponent */ { Word16 i, iter, lg_4, s, tmp16; Word32 ener, tmp32; Word32 target, fac, offset; Word32 en[N_MAX / 4]; - lg_4 = shr( lg, 2 ); /* energy of quadruples with 9dB offset */ @@ -1034,12 +1066,14 @@ Word16 SQ_gain_ivas_fx( /* output: SQ gain */ return tmp16; } -Word16 SQ_gain_estimate_fx( /* output: SQ gain */ - Word32 x[], /* input: vector to quantize */ - Word16 x_e, /* input: exponent */ - Word16 nbitsSQ, /* input: number of bits targeted */ - Word16 lg, /* input: vector size (2048 max) */ - Word16 *gain_e ) /* output: SQ gain exponent */ + +/* o: SQ gain */ +Word16 SQ_gain_estimate_fx( + Word32 x[], /* i : vector to quantize */ + Word16 x_e, /* i : exponent */ + Word16 nbitsSQ, /* i : number of bits targeted */ + Word16 lg, /* i : vector size (2048 max) */ + Word16 *gain_e ) /* o : SQ gain exponent */ { Word16 i, iter, max_iter, lg_4, s, tmp16; Word32 ener, tmp32; @@ -1225,21 +1259,21 @@ Word16 SQ_gain_estimate_fx( /* output: SQ gain return tmp16; } + void tcx_scalar_quantization_fx( - Word32 *x, /* i: input coefficients */ - Word16 x_e, /* i: exponent */ - Word16 *xq, /* o: quantized coefficients */ - Word16 L_frame, /* i: frame length */ - Word16 gain, /* i: quantization gain */ - Word16 gain_e, /* i: quantization gain exponent */ - Word16 offset, /* i: rounding offset (deadzone) */ - Word8 const *memQuantZeros_fx, /* i: coefficients to be set to 0 */ + Word32 *x, /* i : input coefficients */ + Word16 x_e, /* i : exponent */ + Word16 *xq, /* o : quantized coefficients */ + Word16 L_frame, /* i : frame length */ + Word16 gain, /* i : quantization gain */ + Word16 gain_e, /* i : quantization gain exponent */ + Word16 offset, /* i : rounding offset (deadzone) */ + Word8 const *memQuantZeros_fx, /* i : coefficients to be set to 0 */ const Word16 alfe_flag ) { Word16 i, tmp16, s; Word32 tmp32, offs32; - /* common exponent for x and gain for comparison */ tmp16 = sub( gain_e, x_e ); tmp32 = L_shl( L_deposit_h( gain ), s_max( -31, s_min( tmp16, 0 ) ) ); @@ -1294,21 +1328,22 @@ void tcx_scalar_quantization_fx( IF( alfe_flag == 0 ) { - AdaptLowFreqEmph_fx( x, x_e, xq, gain, gain_e, - 0, NULL, NULL, - L_frame ); + AdaptLowFreqEmph_fx( x, x_e, xq, gain, gain_e, 0, NULL, NULL, L_frame ); } + + return; } + void tcx_scalar_quantization_ivas_fx( - Word32 *x, /* i: input coefficients exponent = x_e */ - Word16 x_e, /* i: exponent */ - Word16 *xq, /* o: quantized coefficients */ - Word16 L_frame, /* i: frame length */ - Word16 gain, /* i: quantization gain exponent = gain_e */ - Word16 gain_e, /* i: quantization gain exponent */ - Word16 offset, /* i: rounding offset (deadzone) */ - Word8 const *memQuantZeros_fx, /* i: coefficients to be set to 0 */ + Word32 *x, /* i : input coefficients exponent = x_e */ + Word16 x_e, /* i : exponent */ + Word16 *xq, /* o : quantized coefficients */ + Word16 L_frame, /* i : frame length */ + Word16 gain, /* i : quantization gain exponent = gain_e */ + Word16 gain_e, /* i : quantization gain exponent */ + Word16 offset, /* i : rounding offset (deadzone) */ + Word8 const *memQuantZeros_fx, /* i : coefficients to be set to 0 */ const Word16 alfe_flag ) { Word16 i, tmp16, s; @@ -1316,7 +1351,6 @@ void tcx_scalar_quantization_ivas_fx( Word32 offs32_1; Word32 offset_Q16 = L_shl( offset, 1 ); // Q16 - /* common exponent for x and gain for comparison */ tmp16 = sub( gain_e, x_e ); tmp32 = L_shl_sat( L_deposit_h( gain ), tmp16 ); // exp:x_e @@ -1370,15 +1404,15 @@ void tcx_scalar_quantization_ivas_fx( move16(); } - IF( alfe_flag == 0 ) { - AdaptLowFreqEmph_fx( x, x_e, xq, gain, gain_e, - 0, NULL, NULL, - L_frame ); + AdaptLowFreqEmph_fx( x, x_e, xq, gain, gain_e, 0, NULL, NULL, L_frame ); } + + return; } + Word16 tcx_scalar_quantization_rateloop_fx( Word32 *x, /* i : input coefficients */ Word16 x_e, /* i : exponent */ @@ -1424,7 +1458,6 @@ Word16 tcx_scalar_quantization_rateloop_fx( move16(); move16(); - /* Init */ sqGain = *gain; move16(); @@ -1674,10 +1707,10 @@ Word16 tcx_scalar_quantization_rateloop_fx( move16(); } - return sqBits; } + Word16 tcx_scalar_quantization_rateloop_ivas_fx( Word32 *x, /* i : input coefficients Q = 31 - x_e*/ Word16 x_e, /* i : exponent Q0*/ @@ -1723,7 +1756,6 @@ Word16 tcx_scalar_quantization_rateloop_ivas_fx( Word16 lastnz, saturated, minSqGain = 0; move16(); - /* Init */ saturated = 0; move16(); @@ -2058,11 +2090,15 @@ Word16 tcx_scalar_quantization_rateloop_ivas_fx( move16(); } - return sqBits; } -void QuantizeGain( Word16 n, Word16 *pGain, Word16 *pGain_e, Word16 *pQuantizedGain ) + +void QuantizeGain( + Word16 n, + Word16 *pGain, + Word16 *pGain_e, + Word16 *pQuantizedGain ) { Word16 ener, ener_e, enerInv, enerInv_e, gain, gain_e; Word16 quantizedGain; @@ -2113,21 +2149,24 @@ void QuantizeGain( Word16 n, Word16 *pGain, Word16 *pGain_e, Word16 *pQuantizedG move16(); *pGain_e = add( gain_e, enerInv_e ); move16(); + + return; } + void tcx_noise_factor_fx( - Word32 *x_orig, /* i: unquantized mdct coefficients */ - Word16 x_orig_e, /* i: exponent */ - Word32 *sqQ, /* i: quantized mdct coefficients */ - Word16 iFirstLine, /* i: first coefficient to be considered */ - Word16 lowpassLine, /* i: last nonzero coefficients after low-pass */ - Word16 nTransWidth, /* i: minimum size of hole to be checked */ - Word16 L_frame, /* i: frame length */ - Word16 gain_tcx, /* i: tcx gain */ - Word16 gain_tcx_e, /* i: gain exponent */ - Word16 tiltCompFactor, /* i: LPC tilt compensation factor */ - Word16 *fac_ns, /* o: noise factor */ - Word16 *quantized_fac_ns /* o: quantized noise factor */ + Word32 *x_orig, /* i : unquantized mdct coefficients */ + Word16 x_orig_e, /* i : exponent */ + Word32 *sqQ, /* i : quantized mdct coefficients */ + Word16 iFirstLine, /* i : first coefficient to be considered */ + Word16 lowpassLine, /* i : last nonzero coefficients after low-pass */ + Word16 nTransWidth, /* i : minimum size of hole to be checked */ + Word16 L_frame, /* i : frame length */ + Word16 gain_tcx, /* i : tcx gain */ + Word16 gain_tcx_e, /* i : gain exponent */ + Word16 tiltCompFactor, /* i : LPC tilt compensation factor */ + Word16 *fac_ns, /* o : noise factor */ + Word16 *quantized_fac_ns /* o : quantized noise factor */ ) { Word16 i, k, maxK, segmentOffset; @@ -2139,7 +2178,6 @@ void tcx_noise_factor_fx( Word16 att; /* noise level attenuation factor for transient windows */ Word32 xMax; - assert( nTransWidth <= 16 ); c1 = sub( shl( nTransWidth, 1 ), 4 ); @@ -2458,23 +2496,25 @@ void tcx_noise_factor_fx( move16(); *fac_ns = extract_l( L_mult0( *quantized_fac_ns, shr( 24576 /*0.75f Q15*/, NBITS_NOISE_FILL_LEVEL ) ) ); + + return; } void tcx_noise_factor_ivas_fx( - Word32 *x_orig, /* i: unquantized mdct coefficients */ - Word16 x_orig_e, /* i: exponent */ - Word32 *sqQ, /* i: quantized mdct coefficients, exponent = x_orig_e */ - Word16 iFirstLine, /* i: first coefficient to be considered */ - Word16 lowpassLine, /* i: last nonzero coefficients after low-pass */ - Word16 nTransWidth, /* i: minimum size of hole to be checked */ - Word16 L_frame, /* i: frame length */ - Word16 gain_tcx, /* i: tcx gain */ - Word16 gain_tcx_e, /* i: gain exponent */ - Word16 tiltCompFactor, /* i: LPC tilt compensation factor */ - Word16 *fac_ns, /* o: noise factor, Q15 */ - Word16 *quantized_fac_ns, /* o: quantized noise factor, Q0 */ - Word16 element_mode /* i: element mode */ + Word32 *x_orig, /* i : unquantized mdct coefficients */ + Word16 x_orig_e, /* i : exponent */ + Word32 *sqQ, /* i : quantized mdct coefficients, exponent = x_orig_e */ + Word16 iFirstLine, /* i : first coefficient to be considered */ + Word16 lowpassLine, /* i : last nonzero coefficients after low-pass */ + Word16 nTransWidth, /* i : minimum size of hole to be checked */ + Word16 L_frame, /* i : frame length */ + Word16 gain_tcx, /* i : tcx gain */ + Word16 gain_tcx_e, /* i : gain exponent */ + Word16 tiltCompFactor, /* i : LPC tilt compensation factor */ + Word16 *fac_ns, /* o : noise factor, Q15 */ + Word16 *quantized_fac_ns, /* o : quantized noise factor, Q0 */ + Word16 element_mode /* i : element mode */ ) { Word16 i, k, win, segmentOffset, j; @@ -2763,17 +2803,19 @@ void tcx_noise_factor_ivas_fx( *fac_ns = extract_l( L_mult0( *quantized_fac_ns, shr( 24576 /*0.75f Q15*/, NBITS_NOISE_FILL_LEVEL ) ) ); move16(); + + return; } void tcx_encoder_memory_update_fx( - Word16 *wsig, /* i : target weighted signal */ + Word16 *wsig, /* i : target weighted signal */ Word16 *xn_buf, /* i/o: mdct output buffer/time domain weigthed synthesis */ - Word16 L_frame_glob, /* i: global frame length */ - const Word16 *Ai, /* i: Unquantized (interpolated) LPC coefficients */ - const Word16 *A, /* i: Quantized LPC coefficients */ - Word16 preemph, /* i: preemphasis factor */ - LPD_state *LPDmem, /* i/o: coder memory state */ + Word16 L_frame_glob, /* i : global frame length */ + const Word16 *Ai, /* i : Unquantized (interpolated) LPC coefficients */ + const Word16 *A, /* i : Quantized LPC coefficients */ + Word16 preemph, /* i : preemphasis factor */ + LPD_state *LPDmem, /* i/o: coder memory state */ Encoder_State *st, Word16 *synthout, Word16 Q_new, @@ -2783,11 +2825,9 @@ void tcx_encoder_memory_update_fx( Word16 buf[1 + M + LFAC + L_FRAME_PLUS]; Word16 *synth; - /* Output synth */ Copy( xn_buf, synthout, L_frame_glob ); - /* Update synth */ synth = buf + M + 1; Copy( LPDmem->syn, buf, M + 1 ); @@ -2805,7 +2845,6 @@ void tcx_encoder_memory_update_fx( move16(); } - /* Emphasis of synth -> synth_pe */ tmp = synth[-( M + 1 )]; move16(); @@ -2829,16 +2868,19 @@ void tcx_encoder_memory_update_fx( Residu3_fx( A, synth + sub( L_frame_glob, L_EXC_MEM ), LPDmem->old_exc, L_EXC_MEM, 1 ); } } + + return; } + void tcx_encoder_memory_update_ivas_fx( - Word16 *wsig, /* i : target weighted signal, Q_new */ + Word16 *wsig, /* i : target weighted signal, Q_new */ Word16 *xn_buf, /* i/o: mdct output buffer/time domain weigthed synthesis, Q_new */ - Word16 L_frame_glob, /* i: global frame length */ - const Word16 *Ai, /* i: Unquantized (interpolated) LPC coefficients, Q12 */ - const Word16 *A, /* i: Quantized LPC coefficients, Q = 14 - norm_s(A[0]) */ - Word16 preemph, /* i: preemphasis factor, Q15 */ - LPD_state *LPDmem, /* i/o: coder memory state */ + Word16 L_frame_glob, /* i : global frame length */ + const Word16 *Ai, /* i : Unquantized (interpolated) LPC coefficients, Q12 */ + const Word16 *A, /* i : Quantized LPC coefficients, Q = 14 - norm_s(A[0])*/ + Word16 preemph, /* i : preemphasis factor, Q15 */ + LPD_state *LPDmem, /* i/o: coder memory state */ Encoder_State *st, Word16 *synthout, /* Q_new */ Word16 Q_new ) @@ -2847,11 +2889,9 @@ void tcx_encoder_memory_update_ivas_fx( Word16 buf[1 + M + LFAC + L_FRAME_PLUS]; Word16 *synth; - /* Output synth */ Copy( xn_buf, synthout, L_frame_glob ); - /* Update synth */ synth = buf + M + 1; Copy( LPDmem->syn, buf, M + 1 ); @@ -2869,7 +2909,6 @@ void tcx_encoder_memory_update_ivas_fx( move16(); } - /* Emphasis of synth -> synth_pe */ tmp = synth[-( M + 1 )]; move16(); @@ -2915,6 +2954,8 @@ void tcx_encoder_memory_update_ivas_fx( move16(); } } + + return; } @@ -2924,19 +2965,19 @@ void tcx_encoder_memory_update_ivas_fx( /* Returns: number of bits used (including "bits") Q0 */ Word16 tcx_ari_res_Q_spec_fx( - const Word32 x_orig[], /* i: original spectrum Q31-e */ - Word16 x_orig_e, /* i: original spectrum exponent Q0 */ - const Word16 signs[], /* i: signs (x_orig[.]<0) Q0 */ - Word32 x_Q[], /* i/o: quantized spectrum Q31-e */ - Word16 x_Q_e, /* i: quantized spectrum exponent Q0 */ - Word16 L_frame, /* i: number of lines Q0 */ - Word16 gain, /* i: TCX gain Q15-e */ - Word16 gain_e, /* i: TCX gain exponent Q0 */ - Word16 prm[], /* o: bit-stream Q0 */ - Word16 target_bits, /* i: number of bits available Q0 */ - Word16 bits, /* i: number of bits used so far Q0 */ - Word16 deadzone, /* i: quantizer deadzone Q15 */ - const Word16 x_fac[] /* i: spectrum post-quantization factors Q14 */ + const Word32 x_orig[], /* i : original spectrum Q31-e */ + Word16 x_orig_e, /* i : original spectrum exponent Q0 */ + const Word16 signs[], /* i : signs (x_orig[.]<0) Q0 */ + Word32 x_Q[], /* i/o: quantized spectrum Q31-e */ + Word16 x_Q_e, /* i : quantized spectrum exponent Q0 */ + Word16 L_frame, /* i : number of lines Q0 */ + Word16 gain, /* i : TCX gain Q15-e */ + Word16 gain_e, /* i : TCX gain exponent Q0 */ + Word16 prm[], /* o : bit-stream Q0 */ + Word16 target_bits, /* i : number of bits available Q0 */ + Word16 bits, /* i : number of bits used so far Q0 */ + Word16 deadzone, /* i : quantizer deadzone Q15 */ + const Word16 x_fac[] /* i : spectrum post-quantization factors Q14 */ ) { Word16 i, j, num_zeros; @@ -2946,11 +2987,9 @@ Word16 tcx_ari_res_Q_spec_fx( Word32 L_tmp, L_tmp2; Word16 s, s2; - /* Limit the number of residual bits */ target_bits = s_min( target_bits, NPRM_RESQ ); - /* Requantize the spectrum line-by-line */ /* fac_m = deadzone * 0.5f; fac_p = 0.5f - fac_m; */ @@ -3055,24 +3094,24 @@ Word16 tcx_ari_res_Q_spec_fx( } } - return bits; } + Word16 tcx_ari_res_Q_spec_ivas_fx( - const Word32 x_orig[], /* i: original spectrum Q31-e */ - Word16 x_orig_e, /* i: original spectrum exponent Q0 */ - const Word16 signs[], /* i: signs (x_orig[.]<0) Q0 */ - Word32 x_Q[], /* i/o: quantized spectrum Q31-e */ - Word16 x_Q_e, /* i: quantized spectrum exponent Q0 */ - Word16 L_frame, /* i: number of lines Q0 */ - Word16 gain, /* i: TCX gain Q15-e */ - Word16 gain_e, /* i: TCX gain exponent Q0 */ - Word16 prm[], /* o: bit-stream Q0 */ - Word16 target_bits, /* i: number of bits available Q0 */ - Word16 bits, /* i: number of bits used so far Q0 */ - Word16 deadzone, /* i: quantizer deadzone Q15 */ - const Word16 x_fac[] /* i: spectrum post-quantization factors Q14 */ + const Word32 x_orig[], /* i : original spectrum Q31-e */ + Word16 x_orig_e, /* i : original spectrum exponent Q0 */ + const Word16 signs[], /* i : signs (x_orig[.]<0) Q0 */ + Word32 x_Q[], /* i/o: quantized spectrum Q31-e */ + Word16 x_Q_e, /* i : quantized spectrum exponent Q0 */ + Word16 L_frame, /* i : number of lines Q0 */ + Word16 gain, /* i : TCX gain Q15-e */ + Word16 gain_e, /* i : TCX gain exponent Q0 */ + Word16 prm[], /* o : bit-stream Q0 */ + Word16 target_bits, /* i : number of bits available Q0 */ + Word16 bits, /* i : number of bits used so far Q0 */ + Word16 deadzone, /* i : quantizer deadzone Q15 */ + const Word16 x_fac[] /* i : spectrum post-quantization factors Q14 */ ) { Word16 i, j, num_zeros; @@ -3082,11 +3121,9 @@ Word16 tcx_ari_res_Q_spec_ivas_fx( Word32 L_tmp, L_tmp2; Word16 s, s2; - /* Limit the number of residual bits */ target_bits = s_min( target_bits, NPRM_RESQ ); - /* Requantize the spectrum line-by-line */ /* fac_m = deadzone * 0.5f; fac_p = 0.5f - fac_m; */ @@ -3289,10 +3326,10 @@ Word16 tcx_ari_res_Q_spec_ivas_fx( } } - return bits; } + #define kMaxEstimatorOvershoot 5 #define kMaxEstimatorUndershoot 0 @@ -3373,7 +3410,6 @@ Word16 tcx_res_Q_spec_fx( Word16 c; Word32 thres; - /* Limit the number of residual bits */ sqTargetBits = s_min( sqTargetBits, NPRM_RESQ ); @@ -3530,6 +3566,7 @@ Word16 tcx_res_Q_spec_fx( return bits; } + Word16 tcx_res_Q_spec_ivas_fx( Word32 *x_orig, Word16 x_orig_e, @@ -3648,7 +3685,6 @@ Word16 tcx_res_Q_spec_ivas_fx( FOR( i = 0; ( i < L_frame ) && ( bits < ( sqTargetBits - 2 ) ); i++ ) { - test(); test(); IF( ( x_Q[i] == 0 ) && ( ( lf_deemph_factors == NULL ) || ( GT_16( lf_deemph_factors[i], 0x2000 ) ) ) ) @@ -3711,17 +3747,18 @@ Word16 tcx_res_Q_spec_ivas_fx( return bits; } + void ProcessIGF_fx( - IGF_ENC_INSTANCE_HANDLE const hInstance, /**< in: instance handle of IGF Encoder */ - Encoder_State *st, /**< in: Encoder state */ - Word32 pMDCTSpectrum[], /**< in: MDCT spectrum */ + IGF_ENC_INSTANCE_HANDLE const hInstance, /* i : instance handle of IGF Encoder */ + Encoder_State *st, /* i : Encoder state */ + Word32 pMDCTSpectrum[], /* i : MDCT spectrum */ Word16 *pMDCTSpectrum_e, - Word32 pPowerSpectrum[], /**< in: MDCT^2 + MDST^2 spectrum, or estimate */ + Word32 pPowerSpectrum[], /* i : MDCT^2 + MDST^2 spectrum, or estimate */ Word16 *pPowerSpectrum_e, - Word16 isTCX20, /**< in: flag indicating if the input is TCX20 or TCX10/2xTCX5 */ - Word16 isTNSActive, /**< in: flag indicating if the TNS is active */ - Word16 isTransition, /**< in: flag indicating if the input is the transition from from ACELP to TCX20/TCX10 */ - Word16 frameno /**< in: flag indicating index of current subframe */ + Word16 isTCX20, /* i : flag indicating if the input is TCX20 or TCX10/2xTCX5 */ + Word16 isTNSActive, /* i : flag indicating if the TNS is active */ + Word16 isTransition, /* i : flag indicating if the input is the transition from from ACELP to TCX20/TCX10 */ + Word16 frameno /* i : flag indicating index of current subframe */ ) { Word16 igfGridIdx; @@ -3731,7 +3768,6 @@ void ProcessIGF_fx( BSTR_ENC_HANDLE hBstr = st->hBstr; IGF_ENC_INSTANCE_HANDLE hIGFEnc = st->hIGFEnc; - isIndepFlag = 1; move16(); test(); @@ -3783,7 +3819,6 @@ void ProcessIGF_fx( Word16 predictionGain = 0; Word16 *flatteningTrigger = &( st->hIGFEnc->flatteningTrigger ); - move32(); move16(); move16(); @@ -3821,9 +3856,14 @@ void ProcessIGF_fx( bsBits = sub( hBstr->nb_ind_tot, pBsStart ); IGFEncConcatenateBitstream_ivas_fx( hIGFEnc, bsBits, hBstr ); } + + return; } -void attenuateNbSpectrum_fx( Word16 L_frame, Word32 *spectrum ) + +void attenuateNbSpectrum_fx( + Word16 L_frame, + Word32 *spectrum ) { Word16 i, length, att; @@ -3844,6 +3884,8 @@ void attenuateNbSpectrum_fx( Word16 L_frame, Word32 *spectrum ) move32(); att = mult_r( att, att ); } + + return; } /*---------------------------------------------------------------------* @@ -3851,6 +3893,7 @@ void attenuateNbSpectrum_fx( Word16 L_frame, Word32 *spectrum ) * * *---------------------------------------------------------------------*/ + void ProcessIGF_ivas_fx( Encoder_State *st, /* i : Encoder state */ Word16 powerSpec_len, /* i : length of pPowerSpectrum buffer */ @@ -4006,7 +4049,6 @@ void ProcessStereoIGF_fx( IGFSaveSpectrumForITF_ivas_fx( hIGFEnc[1], igfGridIdx, pITFMDCTSpectrum_fx[1][frameno], sub( Q31, q_pITFMDCTSpectrum_2 ) ); - IGFEncApplyStereo_fx( hStereoMdct, ms_mask, hIGFEnc, igfGridIdx, sts, pPowerSpectrum_fx, exp_pPowerSpectrum_fx, pPowerSpectrumMsInv_fx, q_pPowerSpectrumMsInv_fx, inv_spectrum_fx, exp_inv_spectrum_fx, frameno, sp_aud_decision0, element_brate, mct_on ); @@ -4050,5 +4092,6 @@ void ProcessStereoIGF_fx( IGFEncConcatenateBitstream_ivas_fx( hIGFEnc[ch], bsBits, hBstr ); } } + return; } diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 7c541478058975c0b623e303c7d9a8833b7e8a7f..b6ffbc7381b035a539d709a2d4de1b89db5018e6 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -77,8 +77,8 @@ /* snr_sum = "scale" * (float)log10( L_snr_sum ) ;*/ /* o: Q8 */ static Word16 vad_snr_log_fx( - Word32 L_snr, /* i: Q4 */ - Word16 scale /* i: scale Q13 , 10.0*log10(2) or 1.0*log10(2) */ + Word32 L_snr, /* i : Q4 */ + Word16 scale /* i : scale Q13 , 10.0*log10(2) or 1.0*log10(2) */ ) { Word16 e_snr, f_snr; @@ -178,12 +178,12 @@ void wb_vad_init_fx( * accumulate snr_sum with significance thresholds *-----------------------------------------------------------------*/ static void sign_thr_snr_acc_ivas_fx( - Word32 *L_snr_sum, /* o: q_snr_sum */ + Word32 *L_snr_sum, /* o : q_snr_sum */ Word16 *q_snr_sum, - Word32 L_snr, /* i: q_snr */ + Word32 L_snr, /* i : q_snr */ Word16 q_snr, - Word32 sign_thr, /* i: q_snr */ - Word32 min_snr /* i: q_snr */ + Word32 sign_thr, /* i : q_snr */ + Word32 min_snr /* i : q_snr */ ) { /*if( snr >= sign_thr ) */ @@ -202,10 +202,10 @@ static void sign_thr_snr_acc_ivas_fx( } static void sign_thr_snr_acc_fx( - Word32 *L_snr_sum, /* o: Q4 */ - Word32 L_snr, /* i: Q4 */ - Word16 sign_thr, /* i: Q4 */ - Word16 min_snr /* i: Q4 */ + Word32 *L_snr_sum, /* o : Q4 */ + Word32 L_snr, /* i : Q4 */ + Word16 sign_thr, /* i : Q4 */ + Word16 min_snr /* i : Q4 */ ) { /*if( snr >= sign_thr ) */ diff --git a/lib_enc/voiced_enc_fx.c b/lib_enc/voiced_enc_fx.c index fc3b81724aedeea77fa7fbfa06f01bf235fac865..40c7f8c13839228bb1044d8dc7264250c595abf1 100644 --- a/lib_enc/voiced_enc_fx.c +++ b/lib_enc/voiced_enc_fx.c @@ -64,13 +64,13 @@ ivas_error ppp_voiced_encoder_fx( const Word16 bwidth_fx, /* i : audio bandwidth */ const Word16 last_coder_type_raw, /* i : raw last_coder_type */ const Word16 old_pitch_buf[], /* i : buffer of old subframe pitch values */ - Word16 *in_fx, /* i : residual signal */ - Word16 *out_fx, /* o : Quantized residual signal */ - Word16 delay_fx, /* i : open loop pitch */ - Word16 *lpc1_fx, /* i : prev frame de-emphasized LPC */ - Word16 *lpc2_fx, /* i : current frame de-emphasized LPC */ - Word16 *exc_fx, /* i: previous frame quantized excitation */ - Word16 *pitch_fx, /* o: floating pitch values for each subframe */ + Word16 *in_fx, /* i : residual signal */ + Word16 *out_fx, /* o : Quantized residual signal */ + Word16 delay_fx, /* i : open loop pitch */ + Word16 *lpc1_fx, /* i : prev frame de-emphasized LPC */ + Word16 *lpc2_fx, /* i : current frame de-emphasized LPC */ + Word16 *exc_fx, /* i : previous frame quantized excitation */ + Word16 *pitch_fx, /* o : floating pitch values for each subframe */ Word16 Qres ) { Word16 i; diff --git a/lib_isar/isar_lc3plus_common.c b/lib_isar/isar_lc3plus_common.c index 68e160538c27e69f4db5a640a746eb8a6a273a2b..d8fc0cdb5dbbb0b133d57f7ad9b8b68433f6fb79 100644 --- a/lib_isar/isar_lc3plus_common.c +++ b/lib_isar/isar_lc3plus_common.c @@ -30,10 +30,9 @@ *******************************************************************************************************/ +#include #include "options.h" #include "isar_lc3plus_common.h" -#include "ivas_error.h" -#include "lc3plus.h" /*-----------------------------------------------------------------------------------------* * Function ISAR_LC3PLUS_LC3plusErrToIvasErr() diff --git a/lib_rend/ivas_binRenderer_internal_fx.c b/lib_rend/ivas_binRenderer_internal_fx.c index 14818c7c399773573d38acb450f12b6f3c8a354b..3d7241a97fbc2282bc6330357d4049b46deb5612 100644 --- a/lib_rend/ivas_binRenderer_internal_fx.c +++ b/lib_rend/ivas_binRenderer_internal_fx.c @@ -73,7 +73,7 @@ static const Word32 dmxmtx_table_fx[BINAURAL_CHANNELS][REVERB_INPUT_DOWNMIX_CHAN /*------------------------------------------------------------------------- * ivas_binRenderer_filterModule_fx() * - * + * Filtering module for FastConv binaural renderer *-------------------------------------------------------------------------*/ static void ivas_binRenderer_filterModule_fx( @@ -171,7 +171,6 @@ static void ivas_binRenderer_filterModule_fx( } } - return; } @@ -584,7 +583,7 @@ ivas_error ivas_allocate_binaural_hrtf_fx( /*-------------------------------------------------------------------------* * ivas_binaural_hrtf_open() * - * + * Allocate and initialize HRTF FastConv binaural renderer handle *-------------------------------------------------------------------------*/ static ivas_error ivas_binaural_hrtf_open_fx( @@ -1536,8 +1535,8 @@ void ivas_binaural_add_LFE_fx( *-------------------------------------------------------------------------*/ void ivas_binRenderer_fx( - BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ - const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i : pose correction data handle */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle*/ const Word16 numTimeSlots, /* i : number of time slots to render */ Word32 Cldfb_RealBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index b90b9deb8543083354c25a952de3a6fdb6d8db41..e9015aeb3e38f9404fc87be5726fdd1c68c2d45a 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -1386,8 +1386,9 @@ static ivas_error ivas_er_init_handle( *------------------------------------------------------------------------*/ ivas_error ivas_rend_initCrendWrapper_fx( - CREND_WRAPPER_HANDLE *pCrend, - const Word16 num_poses ) + CREND_WRAPPER_HANDLE *pCrend, /* i/o: Crend wrapper handle */ + const Word16 num_poses /* i : number of poses */ +) { Word16 i; CREND_HANDLE hCrend; @@ -1485,15 +1486,16 @@ ivas_error ivas_rend_openMultiBinCrend( *------------------------------------------------------------------------*/ ivas_error ivas_rend_openCrend_fx( - CREND_WRAPPER_HANDLE *pCrend, - const AUDIO_CONFIG inConfig, - const AUDIO_CONFIG outConfig, - RENDER_CONFIG_DATA *hRendCfg, - HRTFS_CREND_HANDLE hHrtfCrend, - HRTFS_STATISTICS_HANDLE hHrtfStatistics, - const Word32 output_Fs, - const Word16 ext_rend_flag, - const Word16 num_poses ) + CREND_WRAPPER_HANDLE *pCrend, /* i/o: Crend wrapper handle */ + const AUDIO_CONFIG inConfig, /* i : input audio configuration */ + const AUDIO_CONFIG outConfig, /* i : output audio configuration */ + const RENDER_CONFIG_HANDLE hRendCfg, /* i : Renderer configuration handle */ + const HRTFS_CREND_HANDLE hHrtfCrend, /* i : Crend HRTF handle */ + HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ + const Word32 output_Fs, /* i : output sampling rate */ + const Word16 ext_rend_flag, /* i : flag indicating external renderer */ + const Word16 num_poses /* i : number of poses */ +) { Word16 i, subframe_length; Word32 max_total_ir_len; @@ -1687,7 +1689,8 @@ ivas_error ivas_rend_openCrend_fx( *------------------------------------------------------------------------*/ void ivas_rend_closeCrend_fx( - CREND_WRAPPER_HANDLE *pCrend ) + CREND_WRAPPER_HANDLE *pCrend /* i/o: Crend wrapper handle */ +) { Word16 i; Word16 pos_idx; diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index f20e58c42e1ed2395e7d333ced2cdb4805831736..fca856c60de4dcd83777234a80ea6fba9991e0a6 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -496,7 +496,7 @@ ivas_error ivas_dirac_dec_binaural_copy_hrtfs_fx( /*------------------------------------------------------------------------- * void ivas_dirac_dec_binaural_render() * - * + * Parametric binaural renderer process *------------------------------------------------------------------------*/ void ivas_dirac_dec_binaural_render_fx( @@ -6323,6 +6323,13 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( return; } + +/*-------------------------------------------------------------------* + * ivas_masa_ext_rend_parambin_internal() + * + * + *-------------------------------------------------------------------*/ + static void ivas_masa_ext_rend_parambin_internal_fx( MASA_EXT_REND_HANDLE hMasaExtRend, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, @@ -6541,23 +6548,23 @@ static void ivas_masa_ext_rend_parambin_internal_fx( move16(); pMultiBinPoseData = NULL; - if ( hSplitRendWrapper != NULL ) + IF( hSplitRendWrapper != NULL ) { pMultiBinPoseData = &( hSplitRendWrapper->multiBinPoseData ); ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, hMasaExtRend->cldfbSynRend, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat, tmp_Cldfb_out_re, tmp_Cldfb_out_im, reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, &Q_inp_mix, 1 ); - for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - for ( i = 0; i < CLDFB_SLOTS_PER_SUBFRAME; i++ ) + FOR( i = 0; i < CLDFB_SLOTS_PER_SUBFRAME; i++ ) { Copy32( tmp_Cldfb_out_re[ch][i], Cldfb_Out_Real[ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX ); Copy32( tmp_Cldfb_out_im[ch][i], Cldfb_Out_Imag[ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX ); } } } - else + ELSE { ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, hMasaExtRend->cldfbSynRend, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat, NULL, NULL, reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, &Q_inp_mix, 1 ); @@ -6565,14 +6572,14 @@ static void ivas_masa_ext_rend_parambin_internal_fx( hDiracDecBin->hDiffuseDist = NULL; - if ( pMultiBinPoseData != NULL && pMultiBinPoseData->num_poses > 1 ) + test(); + IF( pMultiBinPoseData != NULL && pMultiBinPoseData->num_poses > 1 ) { /* quaternion-based rotation from ivas_binRenderer_internal.c:ivas_binRenderer(), but using absolute rotation instead of delta rotations */ IVAS_QUATERNION Quaternions_rot, Quaternions_abs, *Quaternions_ref; Word32 Rmat_local[3][3]; - - if ( hCombinedOrientationData ) + IF( hCombinedOrientationData ) { Quaternions_ref = &hCombinedOrientationData->Quaternions[0]; Copy_Quat_fx( Quaternions_ref, &Quaternions_abs ); @@ -6656,9 +6663,9 @@ static void ivas_masa_ext_rend_parambin_internal_fx( reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, &Q_inp_mix, 0 ); /* copy from temporary buffer to the main split rendering buffer */ - for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - for ( i = 0; i < CLDFB_SLOTS_PER_SUBFRAME; i++ ) + FOR( i = 0; i < CLDFB_SLOTS_PER_SUBFRAME; i++ ) { Copy32( tmp_Cldfb_out_re[ch][i], Cldfb_Out_Real[pos_idx * BINAURAL_CHANNELS + ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX ); Copy32( tmp_Cldfb_out_im[ch][i], Cldfb_Out_Imag[pos_idx * BINAURAL_CHANNELS + ch][subframe * CLDFB_SLOTS_PER_SUBFRAME + i], CLDFB_NO_CHANNELS_MAX ); @@ -6687,6 +6694,13 @@ static void ivas_masa_ext_rend_parambin_internal_fx( return; } + +/*-------------------------------------------------------------------* + * ivas_masa_ext_rend_parambin_render() + * + * + *-------------------------------------------------------------------*/ + void ivas_masa_ext_rend_parambin_render_fx( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA ext rend structure */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index cbd31bd13eafa95e840437aa19210bff55ce6392..17f904dfca3cff4c1c5cf871b3babac0f87c6608 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -187,8 +187,8 @@ ivas_error ivas_dirac_allocate_parameters_fx( *-------------------------------------------------------------------------*/ ivas_error ivas_spat_hSpatParamRendCom_config_fx( - SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out, /* i/o: IVAS decoder structure */ - const DIRAC_CONFIG_FLAG flag_config_inp, /* i/ : Flag determining if we open or reconfigure the DirAC decoder */ + SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out, /* i/o: common spatial renderer data handle */ + const DIRAC_CONFIG_FLAG flag_config_inp, /* i : Flag determining if we open or reconfigure the DirAC decoder */ const Word16 dec_param_estim_flag, const IVAS_FORMAT ivas_format, const MC_MODE mc_mode, @@ -398,18 +398,19 @@ ivas_error ivas_spat_hSpatParamRendCom_config_fx( *-------------------------------------------------------------------------*/ void ivas_spat_hSpatParamRendCom_close_fx( - SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out ) + SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom /* i/o: common spatial renderer data handle */ +) { test(); - IF( hSpatParamRendCom_out == NULL || *hSpatParamRendCom_out == NULL ) + IF( hSpatParamRendCom == NULL || *hSpatParamRendCom == NULL ) { return; } - ivas_dirac_deallocate_parameters_fx( *hSpatParamRendCom_out, 1 ); - ivas_dirac_deallocate_parameters_fx( *hSpatParamRendCom_out, 2 ); + ivas_dirac_deallocate_parameters_fx( *hSpatParamRendCom, 1 ); + ivas_dirac_deallocate_parameters_fx( *hSpatParamRendCom, 2 ); - free( *hSpatParamRendCom_out ); - *hSpatParamRendCom_out = NULL; + free( *hSpatParamRendCom ); + *hSpatParamRendCom = NULL; return; } @@ -422,7 +423,8 @@ void ivas_spat_hSpatParamRendCom_close_fx( *-------------------------------------------------------------------------*/ void ivas_dirac_rend_close_fx( - DIRAC_REND_HANDLE *hDirACRend_out ) + DIRAC_REND_HANDLE *hDirACRend_out /* i/o: DirAC renderer handle */ +) { Word16 i, j; DIRAC_REND_HANDLE hDirACRend; @@ -3583,7 +3585,12 @@ void rotateAziEle_DirAC_fx( } -/* A reduced rewrite of the corresponding decoder side function */ +/*------------------------------------------------------------------------- + * ivas_masa_ext_dirac_render_sf() + * + * A reduced rewrite of the corresponding decoder side function + *------------------------------------------------------------------------*/ + static void ivas_masa_ext_dirac_render_sf_fx( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: IVAS decoder structure */ Word32 *output_fx[] /* i/o: synthesized core-coder transport channels/DirAC output q11*/ @@ -4468,6 +4475,12 @@ static void ivas_masa_ext_dirac_render_sf_fx( } +/*------------------------------------------------------------------------- + * ivas_masa_ext_dirac_render() + * + * MASA external renderer + *------------------------------------------------------------------------*/ + void ivas_masa_ext_dirac_render_fx( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA renderer structure */ Word32 *output_fx[], /* i/o: input/output signals in time domain q11*/ diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index 03b0afe82aae3f400074c3f108d0b6c938a91e11..6d6c9ba5f9ae29a039130a2dd4e06e3431a19398 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -89,8 +89,6 @@ ivas_error ivas_td_binaural_open_unwrap_fx( Word16 nchan_rend; ivas_error error; - error = IVAS_ERR_OK; - IF( ( pBinRendTd = malloc( sizeof( BINAURAL_TD_OBJECT_RENDERER ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD renderer\n" ) ); @@ -302,7 +300,7 @@ ivas_error ivas_td_binaural_open_unwrap_fx( move32(); } - return error; + return IVAS_ERR_OK; } @@ -796,6 +794,7 @@ ivas_error TDREND_Update_listener_orientation_fx( /* Set the listener position and orientation:*/ TDREND_MIX_LIST_SetPos_fx( hBinRendererTd, Pos_p_fx ); + error = TDREND_MIX_LIST_SetOrient_fx( hBinRendererTd, FrontVec_fx, UpVec_fx, orient_q ); return error; @@ -809,12 +808,12 @@ ivas_error TDREND_Update_listener_orientation_fx( *---------------------------------------------------------------------*/ ivas_error ivas_td_binaural_open_ext_fx( - TDREND_WRAPPER *pTDRend, - AUDIO_CONFIG inConfig, - RENDER_CONFIG_DATA *hRendCfg, /* i : Renderer configuration */ - LSSETUP_CUSTOM_STRUCT *customLsInput, - const Word32 outFs, - const Word16 object_id, /* i: Object ID */ + TDREND_WRAPPER *pTDRend, /* o : TD Renderer wrapper structure */ + const AUDIO_CONFIG inConfig, /* i : Input audio configuration */ + const RENDER_CONFIG_HANDLE hRendCfg, /* i : Renderer configuration */ + const LSSETUP_CUSTOM_HANDLE customLsInput, /* i : Input custom loudspeaker layout */ + const Word32 output_Fs, /* i : output sampling rate */ + const Word16 object_id, /* i : Object ID */ Word16 *SrcInd, Word16 *num_src ) { @@ -868,7 +867,7 @@ ivas_error ivas_td_binaural_open_ext_fx( distAtt_fx = hRendCfg->distAtt_fx; } - return ivas_td_binaural_open_unwrap_fx( pTDRend->hHrtfTD, outFs, nchan_transport, ivas_format, transport_config, directivity_fx, distAtt_fx, hTransSetup, &pTDRend->hBinRendererTd, &pTDRend->binaural_latency_ns, SrcInd ); + return ivas_td_binaural_open_unwrap_fx( pTDRend->hHrtfTD, output_Fs, nchan_transport, ivas_format, transport_config, directivity_fx, distAtt_fx, hTransSetup, &pTDRend->hBinRendererTd, &pTDRend->binaural_latency_ns, SrcInd ); } @@ -882,7 +881,7 @@ ivas_error ivas_td_binaural_open_ext_fx( ivas_error ivas_td_binaural_renderer_ext_fx( const TDREND_WRAPPER *pTDRend, /* i : TD Renderer wrapper structure */ const AUDIO_CONFIG inConfig, /* i : Input audio configuration */ - const LSSETUP_CUSTOM_STRUCT *customLsInput, /* i : Input custom loudspeaker layout */ + const LSSETUP_CUSTOM_HANDLE customLsInput, /* i : Input custom loudspeaker layout */ const COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData, /* i : Combined head and external orientations */ const IVAS_ISM_METADATA *currentPos, /* i : Object position */ const REVERB_HANDLE hReverb, /* i : Reverberator handle */ diff --git a/lib_rend/ivas_objectRenderer_sources_fx.c b/lib_rend/ivas_objectRenderer_sources_fx.c index f91ed65fa86bdb5b5a5cabf58e37001f47af83e3..222a5b0f88bdd907ba61038d88e190c87200bffa 100644 --- a/lib_rend/ivas_objectRenderer_sources_fx.c +++ b/lib_rend/ivas_objectRenderer_sources_fx.c @@ -913,7 +913,8 @@ ivas_error TDREND_SRC_Alloc( --------------------------------------------------------------------*/ void TDREND_SRC_Dealloc( - TDREND_SRC_t *Src_p ) + TDREND_SRC_t *Src_p /* i/o: Source to deallocate */ +) { IF( Src_p == NULL ) { diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index c59520d621ce38205384fd267e1fe1b2a03abb1e..e0a46667c243c0f640071ed528f2c733d97fa051 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -46,13 +46,14 @@ * General renderer declarations *----------------------------------------------------------------------------------*/ +/*! r: audio configuration type */ IVAS_REND_AudioConfigType getAudioConfigType( - const AUDIO_CONFIG config + const AUDIO_CONFIG config /* i : audio configuration */ ); ivas_error getAudioConfigNumChannels( - const AUDIO_CONFIG config, - Word16 *numChannels + const AUDIO_CONFIG config, /* i : audio configuration */ + Word16 *numChannels /* o : number of audio channels */ ); @@ -540,16 +541,16 @@ void ivas_dirac_dec_compute_directional_responses_fx( ); void ivas_dirac_rend_close_fx( - DIRAC_REND_HANDLE *hDirACRend_out + DIRAC_REND_HANDLE *hDirACRend_out /* i/o: DirAC renderer handle */ ); void ivas_spat_hSpatParamRendCom_close_fx( - SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out + SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom /* i/o: common spatial renderer data handle */ ); ivas_error ivas_spat_hSpatParamRendCom_config_fx( - SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out, - const DIRAC_CONFIG_FLAG flag_config_inp, /* i/ : Flag determining if we open or reconfigure the DirAC decoder */ + SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out, /* i/o: common spatial renderer data handle */ + const DIRAC_CONFIG_FLAG flag_config_inp, /* i : Flag determining if we open or reconfigure the DirAC decoder */ const Word16 dec_param_estim_flag, const IVAS_FORMAT ivas_format, const MC_MODE mc_mode, @@ -679,7 +680,7 @@ ivas_error ivas_td_binaural_renderer_unwrap_fx( ivas_error ivas_td_binaural_renderer_ext_fx( const TDREND_WRAPPER *pTDRend, /* i : TD Renderer wrapper structure */ const AUDIO_CONFIG inConfig, /* i : Input audio configuration */ - const LSSETUP_CUSTOM_STRUCT *customLsInput, /* i : Input custom loudspeaker layout */ + const LSSETUP_CUSTOM_HANDLE customLsInput, /* i : Input custom loudspeaker layout */ const COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData,/* i : Combined head and external orientations */ const IVAS_ISM_METADATA *currentPos, /* i : Object position */ const REVERB_HANDLE hReverb, /* i : Reverberator handle */ @@ -705,11 +706,11 @@ ivas_error ivas_td_binaural_open_unwrap_fx( ); ivas_error ivas_td_binaural_open_ext_fx( - TDREND_WRAPPER *pTDRend, - const AUDIO_CONFIG inConfig, - RENDER_CONFIG_DATA *hRendCfg, /* i : Renderer configuration */ - LSSETUP_CUSTOM_STRUCT *customLsInput, - const Word32 output_Fs, + TDREND_WRAPPER *pTDRend, /* o : TD Renderer wrapper structure */ + const AUDIO_CONFIG inConfig, /* i : Input audio configuration */ + const RENDER_CONFIG_HANDLE hRendCfg, /* i : Renderer configuration */ + const LSSETUP_CUSTOM_HANDLE customLsInput, /* i : Input custom loudspeaker layout */ + const Word32 output_Fs, /* i : output sampling rate */ const Word16 object_id, /* i : Object ID */ Word16 *SrcInd, Word16 *num_src @@ -909,19 +910,19 @@ void TDREND_firfilt_fx( *----------------------------------------------------------------------------------*/ ivas_error ivas_rend_openCrend_fx( - CREND_WRAPPER_HANDLE *pCrend, - const AUDIO_CONFIG inConfig, - const AUDIO_CONFIG outConfig, - RENDER_CONFIG_DATA *hRendCfg, - HRTFS_CREND_HANDLE hHrtfCrend, - HRTFS_STATISTICS_HANDLE hHrtfStatistics, - const Word32 output_Fs, - const Word16 ext_rend_flag, - const Word16 num_poses + CREND_WRAPPER_HANDLE *pCrend, /* i/o: Crend wrapper handle */ + const AUDIO_CONFIG inConfig, /* i : input audio configuration */ + const AUDIO_CONFIG outConfig, /* i : output audio configuration */ + const RENDER_CONFIG_HANDLE hRendCfg, /* i : Renderer configuration handle */ + const HRTFS_CREND_HANDLE hHrtfCrend, /* i : Crend HRTF handle */ + HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ + const Word32 output_Fs, /* i : output sampling rate */ + const Word16 ext_rend_flag, /* i : flag indicating external renderer */ + const Word16 num_poses /* i : number of poses */ ); void ivas_rend_closeCrend_fx( - CREND_WRAPPER_HANDLE *pCrend + CREND_WRAPPER_HANDLE *pCrend /* i/o: Crend wrapper handle */ ); ivas_error ivas_Crend_hrtf_init_fx( @@ -929,8 +930,8 @@ ivas_error ivas_Crend_hrtf_init_fx( ); ivas_error ivas_rend_initCrendWrapper_fx( - CREND_WRAPPER_HANDLE *pCrend, - const Word16 num_poses + CREND_WRAPPER_HANDLE *pCrend, /* i/o: Crend wrapper handle */ + const Word16 num_poses /* i : number of poses */ ); ivas_error ivas_rend_crendProcessSubframe_fx( @@ -1147,7 +1148,7 @@ void ivas_reverb_calc_color_levels_fx( Word32 *pTarget_color_R //output in Q30 ); -ivas_error ivas_reverb_prepare_cldfb_params( +void ivas_reverb_prepare_cldfb_params( const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pInput_params, const HRTFS_STATISTICS_HANDLE hHrtfStatistics, const Word32 output_Fs, @@ -1170,13 +1171,13 @@ void ivas_reverb_interp_on_freq_grid_fx( *-----------------------------------------------------------------------------------*/ void ivas_shoebox_config_init( - shoebox_config_t *cal, - RENDER_CONFIG_HANDLE pConfig + shoebox_config_t *cal, /* i/o: shoebox_config_t handle */ + const RENDER_CONFIG_HANDLE pConfig /* i : Renderer configuration handle */ ); void ivas_shoebox_init( - shoebox_obj_t *obj, - shoebox_config_t *cal + shoebox_obj_t *obj, /* i/o: shoebox_obj_t handle */ + const shoebox_config_t *cal /* i : shoebox_config_t handle */ ); void ivas_shoebox_set_scene ( @@ -1193,29 +1194,29 @@ void ivas_shoebox_set_scene ( *-----------------------------------------------------------------------------------*/ ivas_error ivas_er_init( - er_struct_t *reflections, - const AUDIO_CONFIG inConfig + er_struct_t *reflections, /* i/o: early reflections handle */ + const AUDIO_CONFIG inConfig /* i : Input config */ ); ivas_error ivas_er_set_reflections_mode( - er_struct_t *reflections, - const AUDIO_CONFIG inConfig + er_struct_t *reflections, /* i/o: early reflections handle */ + const AUDIO_CONFIG inConfig /* i : Input config */ ); ivas_error ivas_er_compute_reflections( - er_struct_t *reflections + er_struct_t *reflections /* i/o: early reflections handle */ ); ivas_error ivas_er_encoder_init( - er_struct_t *reflections + er_struct_t *reflections /* i/o: early reflections handle */ ); ivas_error ivas_er_process( - er_struct_t *reflections, - const Word16 frame_size, - const Word16 subframe_idx, - Word32 **io, - const AUDIO_CONFIG inConfig + er_struct_t *reflections, /* i/o: early reflections handle */ + const Word16 subframe_size, /* i : subframe length */ + const Word16 subframe_idx, /* i : subframe index */ + Word32 *io[], /* i/o: input/output buffer */ + const AUDIO_CONFIG inConfig /* i : Input config */ ); @@ -1224,19 +1225,18 @@ ivas_error ivas_er_process( *-----------------------------------------------------------------------------------*/ ivas_error ivas_headTrack_open_fx( - HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* o : head track handle */ + HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* o : head track handle */ ); void ivas_headTrack_close_fx( - HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* i/o: head track handle */ + HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* i/o: head track handle */ ); - void Euler2Quat_fx( - const Word32 yaw, /* i : yaw (x) Q22 */ - const Word32 pitch, /* i : pitch (y) Q22 */ - const Word32 roll, /* i : roll (z) Q22 */ - IVAS_QUATERNION *quat /* o : quaternion describing the rotation */ + const Word32 yaw, /* i : yaw (x) Q22 */ + const Word32 pitch, /* i : pitch (y) Q22 */ + const Word32 roll, /* i : roll (z) Q22 */ + IVAS_QUATERNION *quat /* o : quaternion describing the rotation */ ); Word32 deg2rad_fx( diff --git a/lib_rend/ivas_reflections_fx.c b/lib_rend/ivas_reflections_fx.c index 22a332ab1f5a91e4ccf2eff5695a9755726cf04a..d2230f728f08e555d0423eb60b3f10a2fad6d09a 100644 --- a/lib_rend/ivas_reflections_fx.c +++ b/lib_rend/ivas_reflections_fx.c @@ -68,8 +68,9 @@ static UWord16 LC_mixing_7_1_4[11] = { 0, 1, 2, 3, 4, 3, 4, 0, 1, 3, 4 }; *-----------------------------------------------------------------------------------------*/ ivas_error ivas_er_init( - er_struct_t *reflections, - const AUDIO_CONFIG inConfig ) + er_struct_t *reflections, /* i/o: early reflections handle */ + const AUDIO_CONFIG inConfig /* i : Input config */ +) { ivas_error error; UWord8 i; @@ -135,14 +136,15 @@ ivas_error ivas_er_init( /*-----------------------------------------------------------------------------------------* - Function ivas_er_set_reflections_mode() - - Function sets the ER source positions based on the audio config + * Function ivas_er_set_reflections_mode() + * + * Function sets the ER source positions based on the audio config *-----------------------------------------------------------------------------------------*/ ivas_error ivas_er_set_reflections_mode( - er_struct_t *reflections, - const AUDIO_CONFIG inConfig ) + er_struct_t *reflections, /* i/o: early reflections handle */ + const AUDIO_CONFIG inConfig /* i : Input config */ +) { ivas_error error; UWord16 ch; @@ -301,13 +303,14 @@ ivas_error ivas_er_set_reflections_mode( /*-----------------------------------------------------------------------------------------* - Function ivas_er_encoder_init() - - Function that initializes the er encoder + * Function ivas_er_encoder_init() + * + * Function that initializes the er encoder *-----------------------------------------------------------------------------------------*/ ivas_error ivas_er_encoder_init( - er_struct_t *reflections ) + er_struct_t *reflections /* i/o: early reflections handle */ +) { ivas_error error = IVAS_ERR_OK; Word16 i, j, src_idx; @@ -322,7 +325,6 @@ ivas_error ivas_er_encoder_init( Word16 q_format, tmp16, min_qformat = 0; move16(); - IF( reflections == NULL ) { return IVAS_ERR_FAILED_ALLOC; @@ -352,17 +354,14 @@ ivas_error ivas_er_encoder_init( el_angle_cos = getCosWord16( extract_l( rad_el_angle ) ); // Q14 az_angle_cos = getCosWord16( extract_l( rad_az_angle ) ); // Q14 - el_angle_sin = getSinWord16( extract_l( rad_el_angle ) ); // In:Q13, O/p: Q:15 az_angle_sin = getSinWord16( extract_l( rad_az_angle ) ); // In:Q13, O/p: Q:15 - p_x_fx = L_shl( mult( el_angle_cos, az_angle_cos ), 1 ); // Q.14 *Q.14= Q13 p_y_fx = mult( el_angle_cos, az_angle_sin ); // Q.14 *Q.15= Q.14 // Multiplicatio with ER_RADIUS is ignored , as ER_RADIUS=1; p_z_fx = L_shr( el_angle_sin, 1 ); //// Q.15 - /* Calculate the euclidean distance to each point in the config ls setup */ FOR( j = 0; j < reflections->nchan_out; j++ ) { @@ -394,7 +393,6 @@ ivas_error ivas_er_encoder_init( tmp16 = shr( tmp16, 1 ); // Q.13 tmp_fx = L_mac( tmp_fx, tmp16, tmp16 ); // Q.27 - tmp_data = L_sub( p_z_src_fx, p_z_fx ); tmp16 = extract_l( tmp_data ); // Q.14 tmp16 = shr( tmp16, 1 ); // Q.13 @@ -461,13 +459,15 @@ ivas_error ivas_er_encoder_init( /*-----------------------------------------------------------------------------------------* - Function ivas_er_compute_reflections() - - Function computes reflections using the shoebox library and sets up the circular buffers - structure for the early reflections process + * Function ivas_er_compute_reflections() + * + * Function computes reflections using the shoebox library and sets up the circular buffers + * structure for the early reflections process *-----------------------------------------------------------------------------------------*/ + ivas_error ivas_er_compute_reflections( - er_struct_t *reflections ) + er_struct_t *reflections /* i/o: early reflections handle */ +) { ivas_error error = IVAS_ERR_OK; UWord16 circ_len, i, j; @@ -509,7 +509,6 @@ ivas_error ivas_er_compute_reflections( } } - /* If max delay is less than max frame size, use max frame size to compute circ buffer length */ IF( LE_32( circ_len, u_extract_l( reflections->max_frame_size ) ) ) { @@ -576,19 +575,19 @@ ivas_error ivas_er_compute_reflections( /*-----------------------------------------------------------------------------------------* -Function ivas_er_process() - -Takes a buffer of N channels, returns a buffer of N*6 channels containing the early -reflections (one per wall). The process is a delay line architecture -*-----------------------------------------------------------------------------------------*/ - + * Function ivas_er_process() + * + * Takes a buffer of N channels, returns a buffer of N*6 channels containing the early + * reflections (one per wall). The process is a delay line architecture + *-----------------------------------------------------------------------------------------*/ ivas_error ivas_er_process( - er_struct_t *reflections, - const Word16 subframe_size, - const Word16 subframe_idx, - Word32 **io, /*Q11*/ - const AUDIO_CONFIG inConfig ) + er_struct_t *reflections, /* i/o: early reflections handle */ + const Word16 subframe_size, /* i : subframe length */ + const Word16 subframe_idx, /* i : subframe index */ + Word32 *io[], /* i/o: input/output buffer */ + const AUDIO_CONFIG inConfig /* i : Input config */ +) { ivas_error error = IVAS_ERR_OK; UWord16 i, j, k, subframe_offset; @@ -736,5 +735,6 @@ ivas_error ivas_er_process( /* Increment circular buffer start index */ reflections->circ_insert = (UWord16) ( add( reflections->circ_insert, subframe_size ) ) % reflections->circ_len; move16(); + return error; } diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 9ffd743227f9e0621bf4b8692f93b95634fa0e66..50bd990adfb51eae43a55bc8965c37cc8d6d9de0 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -2573,10 +2573,7 @@ ivas_error ivas_binaural_reverb_init_fx( IF( roomAcoustics != NULL ) { - IF( ( error = ivas_reverb_prepare_cldfb_params( roomAcoustics, hHrtfStatistics, sampling_rate, revTimes, revEne ) ) != IVAS_ERR_OK ) - { - return error; - } + ivas_reverb_prepare_cldfb_params( roomAcoustics, hHrtfStatistics, sampling_rate, revTimes, revEne ); /* Convert preDelay from seconds to CLDFB slots as needed by binaural reverb */ temp32 = Mult_32_16( roomAcoustics->acousticPreDelay_fx, ( CLDFB_SLOTS_PER_SECOND >> 1 ) ); // Q11 diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index 05b3f8af64bb6b5f0d96c1925dfb071c53f7b971..1b8c9835db00cc95c82f45dfb016bfca1e5e1518 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -56,7 +56,7 @@ static void ivas_reverb_set_energies( const Word32 *avg_pwr_l, const Word32 *avg * Prepares reverb parameters for CLDFB-based reverberator *-----------------------------------------------------------------------------------------*/ -ivas_error ivas_reverb_prepare_cldfb_params( +void ivas_reverb_prepare_cldfb_params( const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pInput_params, const HRTFS_STATISTICS_HANDLE hHrtfStatistics, const Word32 output_Fs, @@ -132,7 +132,7 @@ ivas_error ivas_reverb_prepare_cldfb_params( pOutput_ene[idx] = L_shl_sat( pOutput_ene[idx], 18 ); // Q31 } - return IVAS_ERR_OK; + return; } @@ -158,8 +158,16 @@ static void ivas_reverb_set_energies( const Word32 cldfb_band_width = 26214400; // 400 in Q16 Word16 s; Word16 temp; + Word16 avg_pwr_len; + + avg_pwr_len = LR_IAC_LENGTH_NR_FC; + move16(); + if ( EQ_32( sampling_rate, 16000 ) ) + { + avg_pwr_len = LR_IAC_LENGTH_NR_FC_16KHZ; + move16(); + } - const Word16 avg_pwr_len = sampling_rate == 16000 ? LR_IAC_LENGTH_NR_FC_16KHZ : LR_IAC_LENGTH_NR_FC; temp = BASOP_Util_Divide3216_Scale( sampling_rate, sub( avg_pwr_len, 1 ), &s ); FOR( freq_idx = 0; freq_idx < avg_pwr_len; freq_idx++ ) @@ -182,4 +190,6 @@ static void ivas_reverb_set_energies( avg_pwr_left[freq_idx] = avg_pwr_left_fx[freq_idx]; avg_pwr_right[freq_idx] = avg_pwr_right_fx[freq_idx]; } + + return; } diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c index 50b0b0f84eb630ddcbf210679455ddda3b1a3eb3..47807658fa612dcf1bda31695ba636792e4b5080 100644 --- a/lib_rend/ivas_rotation_fx.c +++ b/lib_rend/ivas_rotation_fx.c @@ -1613,7 +1613,7 @@ ivas_error combine_external_and_head_orientations_rend( * NOTE that the external orientations are inversed. *------------------------------------------------------------------------*/ -ivas_error combine_external_and_head_orientations( +static ivas_error combine_external_and_head_orientations( IVAS_QUATERNION *headRotQuaternions, /* i : quaternions for head rotation */ IVAS_VECTOR3 *listenerPos, /* i : listener position */ ISAR_SPLIT_REND_ROT_AXIS sr_pose_pred_axis, /* i : split rend pose prediction axis */ diff --git a/lib_rend/ivas_shoebox_fx.c b/lib_rend/ivas_shoebox_fx.c index e6def409e649a8272bf31a719eaa4e159dbed0a3..44b4c28af7b6a66fc065bf9548a0f6e70e0c2059 100644 --- a/lib_rend/ivas_shoebox_fx.c +++ b/lib_rend/ivas_shoebox_fx.c @@ -62,8 +62,8 @@ *-----------------------------------------------------------------------------------------*/ void ivas_shoebox_config_init( - shoebox_config_t *cal, - RENDER_CONFIG_HANDLE hRenderConfig /* i : Renderer configuration handle */ + shoebox_config_t *cal, /* i/o: shoebox_config_t handle */ + const RENDER_CONFIG_HANDLE hRenderConfig /* i : Renderer configuration handle */ ) { UWord16 wall_idx; @@ -102,9 +102,11 @@ void ivas_shoebox_config_init( * Function initializes the shoebox operating parameters by setting limits and defaults, * also contains the calibration structure. *-----------------------------------------------------------------------------------------*/ + void ivas_shoebox_init( - shoebox_obj_t *obj, - shoebox_config_t *cal ) + shoebox_obj_t *obj, /* i/o: shoebox_obj_t handle */ + const shoebox_config_t *cal /* i : shoebox_config_t handle */ +) { UWord16 i; @@ -166,6 +168,7 @@ void ivas_shoebox_init( * by the surface parameters. If object is out of bounds, then new cartesian * coordinates are established to collapse the object position. *-----------------------------------------------------------------------------------------*/ + static void shoebox_bound_fx( shoebox_obj_t *obj, Word32 *out_pos // Q22 @@ -265,7 +268,6 @@ static void shoebox_bound_fx( * Transform relative spherical coordinate to 3D cartesian point *-----------------------------------------------------------------------------------------*/ - static void shoebox_get_coord_fx( shoebox_obj_t *obj, Word32 *fcnOutput_data, // 0th and 1st idx in Q0 and 2nd idx in Q30 @@ -326,7 +328,6 @@ static void shoebox_get_coord_fx( } /* CENTER TO LISTENER */ - k = L_add( out_tmp, 1 ); tmp_pos[0] = obj->src_pos_fx[k - 1]; // Q22 @@ -356,6 +357,7 @@ static void shoebox_get_coord_fx( * * Get 3D source distance from receiver *-----------------------------------------------------------------------------------------*/ + static Word32 shoebox_get_euclidian_distance_internal_fx( shoebox_obj_t *obj, Word32 *tmp_pos, // Q22 @@ -483,7 +485,6 @@ void ivas_shoebox_set_scene( shoebox_bound_fx( obj, obj->list_pos_fx ); - /* ---------- SOURCE LOOP ------------- */ i = obj->nSrc; move32(); @@ -522,9 +523,7 @@ void ivas_shoebox_set_scene( obj->src_dist_fx[j] = L_shl( out_tmp_fx, q_format ); // Q22 move32(); - /* COMPUTE PATTERNS */ - /* SHOEBOX_COMPUTE: fills an input structure (4 array fields of length NxR ) with the */ /* Early reflection metadata (time of arrival, gain, az, el). */ /* */ @@ -538,7 +537,6 @@ void ivas_shoebox_set_scene( FOR( loop_ub = 0; loop_ub < 6; loop_ub++ ) { - Word32 im_pos_fx[3]; Word32 path_dist_fx; Word32 asin_val; @@ -576,10 +574,7 @@ void ivas_shoebox_set_scene( move32(); } - - im_pos_fx[coord] = - L_add( tmp_pos_fx[coord], - L_shl( L_sub( L_shr( W_extract_l( W_mult0_32_32( ( L_negate( L_sub( 1, L_shl( L_and( L_add( loop_ub, 1 ), 1 ), 1 ) ) ) ), scale_fx ) ), 1 ), tmp_pos_fx[coord] ), 1 ) ); // Q:22 + im_pos_fx[coord] = L_add( tmp_pos_fx[coord], L_shl( L_sub( L_shr( W_extract_l( W_mult0_32_32( ( L_negate( L_sub( 1, L_shl( L_and( L_add( loop_ub, 1 ), 1 ), 1 ) ) ) ), scale_fx ) ), 1 ), tmp_pos_fx[coord] ), 1 ) ); // Q:22 move32(); /* 0. Get euclidean distance from IMAGE SOURCE [N,W] to LIST */ @@ -609,7 +604,6 @@ void ivas_shoebox_set_scene( ER_PARAMS->az_angle.data_fx[rcoselev - 1] = az_angle_d; move32(); - q_format = Q22; move16(); sub_im_nd_list_div_path = BASOP_Util_Divide3232_Scale( ( L_sub( im_pos_fx[2], obj->list_pos_fx[2] ) ), path_dist_fx, &q_format ); @@ -624,7 +618,6 @@ void ivas_shoebox_set_scene( one_minus_sub_im_nd_list_div_path_sq_rt = Sqrt32( one_minus_sub_im_nd_list_div_path_sq, &q_format1 ); one_minus_sub_im_nd_list_div_path_sq_rt = L_shl( one_minus_sub_im_nd_list_div_path_sq_rt, q_format1 ); - q_format_n = Q31 - Q31; asin_val = BASOP_util_atan2( sub_im_nd_list_div_path, one_minus_sub_im_nd_list_div_path_sq_rt, q_format_n ); // Q13 @@ -632,7 +625,6 @@ void ivas_shoebox_set_scene( ER_PARAMS->el_angle.data_fx[rcoselev - 1] = asin_val_deg; move32(); - /* 4. Compute gain taking into account air and surface absorption */ /* and propagation loss */ if ( LT_32( path_dist_fx, out_tmp_fx ) ) @@ -655,5 +647,6 @@ void ivas_shoebox_set_scene( move32(); } } + return; } diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 1cb3077905f4367f6f36a5846511371779615585..d16cff5060a7fa1717aea776a212ba0ba96a26f0 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -344,14 +344,13 @@ ivas_error IVAS_REND_SetReferenceVector( const IVAS_VECTOR3 refPos /* i : Reference position */ ); - ivas_error IVAS_REND_SetExternalOrientation( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - IVAS_QUATERNION *orientation, /* i : external orientation data */ - Word8 enableHeadRotation, /* i : flag to enable head rotation for this frame */ - Word8 enableExternalOrientation, /* i : flag to enable external orientation for this frame */ - Word8 enableRotationInterpolation, /* i : flag to interpolate rotations from current and previous frames */ - Word16 numFramesToTargetOrientation, /* i : number of frames until target orientation is reached */ + const IVAS_QUATERNION *orientation, /* i : external orientation data */ + const Word8 enableHeadRotation, /* i : flag to enable head rotation for this frame */ + const Word8 enableExternalOrientation, /* i : flag to enable external orientation for this frame */ + const Word8 enableRotationInterpolation, /* i : flag to interpolate rotations from current and previous frames */ + const Word16 numFramesToTargetOrientation, /* i : number of frames until target orientation is reached */ const Word16 sf_idx /* i : subframe index */ ); diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 3a17884d4f92acb79dbcfb03507321560dc523e2..64a3dc70dd2e4753b23e9e169dd0ba830cfc7b95 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -584,8 +584,10 @@ static ivas_error validateOutputAudioConfig( * *-------------------------------------------------------------------*/ +/*! r: audio configuration type */ IVAS_REND_AudioConfigType getAudioConfigType( - const AUDIO_CONFIG config ) + const AUDIO_CONFIG config /* i : audio configuration */ +) { IVAS_REND_AudioConfigType type; @@ -677,8 +679,9 @@ static ivas_error validateOutputSampleRate( *-------------------------------------------------------------------*/ ivas_error getAudioConfigNumChannels( - const AUDIO_CONFIG config, - Word16 *numChannels ) + const AUDIO_CONFIG config, /* i : audio configuration */ + Word16 *numChannels /* o : number of audio channels */ +) { SWITCH( config ) { @@ -767,6 +770,8 @@ static ivas_error initLimiter( return IVAS_ERR_OK; } + + static LSSETUP_CUSTOM_STRUCT defaultCustomLs( void ) { @@ -792,7 +797,7 @@ static LSSETUP_CUSTOM_STRUCT defaultCustomLs( static ivas_error getSpeakerAzimuths_fx( - AUDIO_CONFIG config, + const AUDIO_CONFIG config, const Word32 **azimuths /* Q22 */ ) { SWITCH( config ) @@ -826,7 +831,7 @@ static ivas_error getSpeakerAzimuths_fx( } static ivas_error getSpeakerElevations_fx( - AUDIO_CONFIG config, + const AUDIO_CONFIG config, const Word32 **elevations /* Q22 */ ) { SWITCH( config ) @@ -860,7 +865,7 @@ static ivas_error getSpeakerElevations_fx( } static ivas_error getAmbisonicsOrder_fx( - AUDIO_CONFIG config, + const AUDIO_CONFIG config, Word16 *order ) { SWITCH( config ) @@ -1026,7 +1031,7 @@ static ivas_error getMcConfigValues_fx( static ivas_error initEfap( EFAP_WRAPPER *pEfapWrapper, - AUDIO_CONFIG outConfig, + const AUDIO_CONFIG outConfig, const LSSETUP_CUSTOM_STRUCT *pCustomLsOut ) { ivas_error error; @@ -3452,7 +3457,7 @@ static ivas_error updateSbaPanGains( static ivas_error initSbaMasaRendering( input_sba *inputSba, - Word32 inSampleRate ) + const Word32 inSampleRate ) { ivas_error error; @@ -4097,7 +4102,7 @@ ivas_error IVAS_REND_GetNumOutChannels( static IVAS_REND_InputId makeInputId( - AUDIO_CONFIG config, + const AUDIO_CONFIG config, const Word32 inputIndex ) { /* Put config type in second byte (from LSB), put index + 1 in first byte @@ -4109,7 +4114,7 @@ static IVAS_REND_InputId makeInputId( static ivas_error getInputById( IVAS_REND_HANDLE hIvasRend, - IVAS_REND_InputId inputId, + const IVAS_REND_InputId inputId, void **ppInput ) { Word32 inputIndex; @@ -4314,8 +4319,9 @@ static ivas_error findFreeInputSlot_fx( *------------------------------------------------------------------------*/ static Word16 getCldfbRendFlag( - IVAS_REND_HANDLE hIvasRend, /* i : Renderer handle */ - const IVAS_REND_AudioConfigType new_configType ) + IVAS_REND_HANDLE hIvasRend, /* i : Renderer handle */ + const IVAS_REND_AudioConfigType new_configType /* i : new Input audio config. type */ +) { Word16 i; Word16 numMasaInputs = 0, numSbaInputs = 0; @@ -5815,13 +5821,13 @@ ivas_error IVAS_REND_SetReferenceVector( *---------------------------------------------------------------------*/ ivas_error IVAS_REND_SetExternalOrientation( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - IVAS_QUATERNION *orientation, /* i : external orientation data */ - Word8 enableHeadRotation, /* i : flag to enable head rotation for this frame */ - Word8 enableExternalOrientation, /* i : flag to enable external orientation for this frame */ - Word8 enableRotationInterpolation, /* i : flag to interpolate rotations from current and previous frames */ - Word16 numFramesToTargetOrientation, /* i : number of frames until target orientation is reached */ - const Word16 sf_idx /* i : subframe index */ + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_QUATERNION *orientation, /* i : external orientation data */ + const Word8 enableHeadRotation, /* i : flag to enable head rotation for this frame */ + const Word8 enableExternalOrientation, /* i : flag to enable external orientation for this frame */ + const Word8 enableRotationInterpolation, /* i : flag to interpolate rotations from current and previous frames */ + const Word16 numFramesToTargetOrientation, /* i : number of frames until target orientation is reached */ + const Word16 sf_idx /* i : subframe index */ ) { /* Validate function arguments */ @@ -6667,8 +6673,7 @@ static ivas_error renderIsmToBinauralRoom( /* compute gains only if position changed */ IF( position_changed ) { - IF( NE_32( ( error = getEfapGains_fx( *ismInput->base.ctx.pEfapOutWrapper, rotatedPos.azimuth_fx, rotatedPos.elevation_fx, currentPanGains ) ), - IVAS_ERR_OK ) ) + IF( NE_32( ( error = getEfapGains_fx( *ismInput->base.ctx.pEfapOutWrapper, rotatedPos.azimuth_fx, rotatedPos.elevation_fx, currentPanGains ) ), IVAS_ERR_OK ) ) { return error; } @@ -6684,7 +6689,11 @@ static ivas_error renderIsmToBinauralRoom( tmpMcBuffer.config.numChannels = tmp; move16(); - tmpMcBuffer.data_fx = malloc( imult1616( tmpMcBuffer.config.numSamplesPerChannel, tmpMcBuffer.config.numChannels ) * sizeof( Word32 ) ); + if ( ( tmpMcBuffer.data_fx = malloc( imult1616( tmpMcBuffer.config.numSamplesPerChannel, tmpMcBuffer.config.numChannels ) * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for renderIsmToBinauralRoom()\n" ) ); + } + set_zero_fx( tmpMcBuffer.data_fx, imult1616( tmpMcBuffer.config.numSamplesPerChannel, tmpMcBuffer.config.numChannels ) ); IF( position_changed ) @@ -7001,7 +7010,7 @@ static ivas_error renderIsmToSba( } pop_wmops(); - return error; + return IVAS_ERR_OK; } @@ -7202,6 +7211,7 @@ static void renderIsmToMasa( return; } + static ivas_error renderInputIsm( input_ism *ismInput, const AUDIO_CONFIG outConfig, @@ -7295,8 +7305,9 @@ static ivas_error renderInputIsm( return error; } + static ivas_error renderActiveInputsIsm( - IVAS_REND_HANDLE hIvasRend, + const IVAS_REND_HANDLE hIvasRend, IVAS_REND_AudioBuffer outAudio ) { Word16 i; @@ -7326,9 +7337,11 @@ static ivas_error renderActiveInputsIsm( *outAudio.pq_fact = sub( input_q, 1 ); move16(); } + return IVAS_ERR_OK; } + static void renderMonoStereoToBinaural( const input_mc *mcInput, IVAS_REND_AudioBuffer outAudio ) @@ -7516,7 +7529,10 @@ static ivas_error renderMcToBinaural( IF( combinedOrientationEnabled ) { tmpRotBuffer = mcInput->base.inputBuffer; - tmpRotBuffer.data_fx = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( Word32 ) ); + if ( ( tmpRotBuffer.data_fx = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for renderMcToBinaural()\n" ) ); + } set32_fx( tmpRotBuffer.data_fx, 0, imult1616( tmpRotBuffer.config.numSamplesPerChannel, tmpRotBuffer.config.numChannels ) ); IF( NE_32( ( error = rotateFrameMc_fx( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, mcInput->rot_gains_prev_fx[0], mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ), IVAS_ERR_OK ) ) @@ -7640,11 +7656,13 @@ static ivas_error renderMcToBinauralRoom( IF( combinedOrientationEnabled ) { tmpRotBuffer = mcInput->base.inputBuffer; - tmpRotBuffer.data_fx = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( Word32 ) ); + if ( ( tmpRotBuffer.data_fx = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for renderMcToBinauralRoom()\n" ) ); + } set32_fx( tmpRotBuffer.data_fx, 0, tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels ); - IF( NE_32( ( error = rotateFrameMc_fx( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, mcInput->rot_gains_prev_fx[0], mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ), - IVAS_ERR_OK ) ) + IF( NE_32( ( error = rotateFrameMc_fx( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, mcInput->rot_gains_prev_fx[0], mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ), IVAS_ERR_OK ) ) { return error; } @@ -7736,7 +7754,10 @@ static ivas_error renderMcCustomLsToBinauralRoom( IF( combinedOrientationEnabled ) { tmpRotBuffer = mcInput->base.inputBuffer; - tmpRotBuffer.data_fx = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( Word32 ) ); + if ( ( tmpRotBuffer.data_fx = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for renderMcCustomLsToBinauralRoom()\n" ) ); + } set32_fx( tmpRotBuffer.data_fx, 0, tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels ); IF( NE_32( ( error = rotateFrameMc_fx( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, mcInput->rot_gains_prev_fx[0], mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ), @@ -7757,7 +7778,10 @@ static ivas_error renderMcCustomLsToBinauralRoom( tmpMcBuffer.config.numChannels = tmp; move16(); - tmpMcBuffer.data_fx = malloc( imult1616( tmpMcBuffer.config.numSamplesPerChannel, tmpMcBuffer.config.numChannels ) * sizeof( Word32 ) ); + if ( ( tmpMcBuffer.data_fx = malloc( imult1616( tmpMcBuffer.config.numSamplesPerChannel, tmpMcBuffer.config.numChannels ) * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for renderMcCustomLsToBinauralRoom()\n" ) ); + } set32_fx( tmpMcBuffer.data_fx, 0, imult1616( tmpMcBuffer.config.numSamplesPerChannel, tmpMcBuffer.config.numChannels ) ); IF( combinedOrientationEnabled ) @@ -7928,7 +7952,10 @@ static ivas_error renderMcToSplitBinaural( move32(); IF( NE_32( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && NE_32( inConfig, IVAS_AUDIO_CONFIG_5_1 ) && NE_32( inConfig, IVAS_AUDIO_CONFIG_7_1 ) ) { - tmpRotBuffer.data_fx = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( Word32 ) ); + if ( ( tmpRotBuffer.data_fx = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for renderMcToSplitBinaural()\n" ) ); + } } FOR( i = 0; i < combinedOrientationDataLocal.num_subframes; i++ ) @@ -8259,7 +8286,10 @@ static ivas_error renderSbaToMultiBinaural( } tmpRotBuffer = sbaInput->base.inputBuffer; - tmpRotBuffer.data_fx = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( Word32 ) ); + if ( ( tmpRotBuffer.data_fx = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for renderSbaToMultiBinaural()\n" ) ); + } FOR( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) { @@ -8453,13 +8483,15 @@ static ivas_error renderSbaToBinaural( { tmpRotBuffer = sbaInput->base.inputBuffer; - tmpRotBuffer.data_fx = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( Word32 ) ); + if ( ( tmpRotBuffer.data_fx = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for renderSbaToBinauralRoom()\n" ) ); + } /* copy input for in-place rotation */ Copy32( sbaInput->base.inputBuffer.data_fx, tmpRotBuffer.data_fx, i_mult( tmpRotBuffer.config.numChannels, tmpRotBuffer.config.numSamplesPerChannel ) ); - IF( NE_16( ( error = rotateFrameSba_fx( sbaInput->base.inputBuffer, sbaInput->base.inConfig, sbaInput->base.ctx.pHeadRotData, sbaInput->base.ctx.pCombinedOrientationData, sbaInput->rot_gains_prev_fx[0], tmpRotBuffer ) ), - IVAS_ERR_OK ) ) + IF( NE_16( ( error = rotateFrameSba_fx( sbaInput->base.inputBuffer, sbaInput->base.inConfig, sbaInput->base.ctx.pHeadRotData, sbaInput->base.ctx.pCombinedOrientationData, sbaInput->rot_gains_prev_fx[0], tmpRotBuffer ) ), IVAS_ERR_OK ) ) { return error; } @@ -8551,13 +8583,15 @@ static ivas_error renderSbaToBinauralRoom( IF( combinedOrientationEnabled ) { tmpRotBuffer = sbaInput->base.inputBuffer; - tmpRotBuffer.data_fx = malloc( imult1616( tmpRotBuffer.config.numSamplesPerChannel, tmpRotBuffer.config.numChannels ) * sizeof( Word32 ) ); + if ( ( tmpRotBuffer.data_fx = malloc( imult1616( tmpRotBuffer.config.numSamplesPerChannel, tmpRotBuffer.config.numChannels ) * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for renderSbaToBinauralRoom()\n" ) ); + } /* copy input for in-place rotation */ Copy32( sbaInput->base.inputBuffer.data_fx, tmpRotBuffer.data_fx, i_mult( tmpRotBuffer.config.numChannels, tmpRotBuffer.config.numSamplesPerChannel ) ); - IF( NE_32( ( error = rotateFrameSba_fx( sbaInput->base.inputBuffer, sbaInput->base.inConfig, sbaInput->base.ctx.pHeadRotData, sbaInput->base.ctx.pCombinedOrientationData, sbaInput->rot_gains_prev_fx[0], tmpRotBuffer ) ), - IVAS_ERR_OK ) ) + IF( NE_32( ( error = rotateFrameSba_fx( sbaInput->base.inputBuffer, sbaInput->base.inConfig, sbaInput->base.ctx.pHeadRotData, sbaInput->base.ctx.pCombinedOrientationData, sbaInput->rot_gains_prev_fx[0], tmpRotBuffer ) ), IVAS_ERR_OK ) ) { return error; } @@ -8573,7 +8607,10 @@ static ivas_error renderSbaToBinauralRoom( tmpMcBuffer.config.numChannels = tmp; move16(); - tmpMcBuffer.data_fx = malloc( tmpMcBuffer.config.numSamplesPerChannel * tmpMcBuffer.config.numChannels * sizeof( Word32 ) ); + if ( ( tmpMcBuffer.data_fx = malloc( tmpMcBuffer.config.numSamplesPerChannel * tmpMcBuffer.config.numChannels * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for renderSbaToBinauralRoom()\n" ) ); + } set32_fx( tmpMcBuffer.data_fx, 0, i_mult( tmpMcBuffer.config.numChannels, tmpMcBuffer.config.numSamplesPerChannel ) ); IF( combinedOrientationEnabled ) @@ -9675,9 +9712,8 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( num_poses_orig = hIvasRend->splitRendWrapper->multiBinPoseData.num_poses; move16(); - ISAR_PRE_REND_GetMultiBinPoseData( pSplitRendConfig, - &hIvasRend->splitRendWrapper->multiBinPoseData, - hIvasRend->headRotData.sr_pose_pred_axis ); + ISAR_PRE_REND_GetMultiBinPoseData( pSplitRendConfig, &hIvasRend->splitRendWrapper->multiBinPoseData, hIvasRend->headRotData.sr_pose_pred_axis ); + assert( num_poses_orig == hIvasRend->splitRendWrapper->multiBinPoseData.num_poses && "number of poses should not change dynamically" ); /* hIvasRend->splitRendEncBuffer contains multi-pose data for BINAURAL_SPLIT_CODED output @@ -9940,6 +9976,12 @@ ivas_error IVAS_REND_openCldfb( Word16 n; ivas_error error; + test(); + IF( cldfbAna == NULL || cldfbSyn == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + FOR( n = 0; n < num_in_chs; n++ ) { IF( ( error = openCldfb_ivas_fx( &( cldfbAna[n] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS, DEC ) ) != IVAS_ERR_OK ) @@ -10538,7 +10580,7 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( } /* output synthesis */ - IF( NE_32( ( ivas_dirac_dec_output_synthesis_open_fx( hSpatParamRendCom, hDirACRend, RENDERER_DIRAC, nchan_transport, output_Fs, 0 ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_dirac_dec_output_synthesis_open_fx( hSpatParamRendCom, hDirACRend, RENDERER_DIRAC, nchan_transport, output_Fs, 0 ) ), IVAS_ERR_OK ) ) { return error; } @@ -10570,7 +10612,6 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( move16(); } - hDirACRend->buffer_energy_fx = NULL; FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) { @@ -10591,7 +10632,7 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( inputMasa->hMasaExtRend->hDirACRend = hDirACRend; - return error; + return IVAS_ERR_OK; } @@ -10618,9 +10659,6 @@ static ivas_error ivas_masa_ext_rend_parambin_init( Word16 tmp_e; Word16 tmp2; - error = IVAS_ERR_OK; - move32(); - phHrtfParambin = inputMasa->hMasaExtRend->hHrtfParambin; /* Set common variables and defaults */ output_Fs = *( inputMasa->base.ctx.pOutSampleRate ); @@ -10794,7 +10832,7 @@ static ivas_error ivas_masa_ext_rend_parambin_init( inputMasa->hMasaExtRend->hDiracDecBin[pos_idx] = hDiracDecBin; } - return error; + return IVAS_ERR_OK; } @@ -10808,9 +10846,6 @@ static ivas_error initMasaExtRenderer( ivas_error error; MASA_EXT_REND_HANDLE hMasaExtRend; - error = IVAS_ERR_OK; - move32(); - IF( ( hMasaExtRend = (MASA_EXT_REND_HANDLE) malloc( sizeof( MASA_EXT_REND_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MASA external renderer structure\n" ) ); diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index d404395e0b9dbdf105590f5c3ee2069e5eb24b77..21d65f059b92ebf09c8d7478eb1de2a2369309e9 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -65,7 +65,7 @@ typedef enum typedef struct ivas_hrtfs_header_t { - Word32 rend_type; + HRTF_READER_RENDERER_TYPE rend_type; Word32 input_cfg; Word32 frequency; UWord32 data_size; diff --git a/lib_util/ls_custom_file_reader.c b/lib_util/ls_custom_file_reader.c index 38e76642bc54b5aa15329c4d25d1aa35288a4f02..e79eab7d357056983751af3200473dcb64050b9f 100644 --- a/lib_util/ls_custom_file_reader.c +++ b/lib_util/ls_custom_file_reader.c @@ -51,7 +51,7 @@ struct LsCustomFileReader ivas_error CustomLsReader_open( const char *LsFilePath, /* i : LS custom layout file name */ - LsCustomFileReader **hLsCustomReader /* o : LsCustomFileReader handle */ + LsCustomFileReader **hLsCustomReader /* o : LsCustomFileReader handle */ ) { LsCustomFileReader *self; diff --git a/lib_util/masa_file_reader.c b/lib_util/masa_file_reader.c index a7253ecd2d1db5a1b29bc4cd745849378415cca4..6cc7e8a7a853d132a4dc6824262886790ec7d681 100644 --- a/lib_util/masa_file_reader.c +++ b/lib_util/masa_file_reader.c @@ -31,7 +31,6 @@ *******************************************************************************************************/ #include "masa_file_reader.h" -#include "ivas_stat_com.h" #include #include #include "ivas_prot_fx.h" diff --git a/lib_util/masa_file_writer.c b/lib_util/masa_file_writer.c index 371fb201e66660273fc9296b7a8138b6120ef995..9ba0e5e534ac9bbd7008204ccecdbc643bae4a2f 100644 --- a/lib_util/masa_file_writer.c +++ b/lib_util/masa_file_writer.c @@ -31,9 +31,7 @@ *******************************************************************************************************/ #include "masa_file_writer.h" -#include "ivas_stat_com.h" #include "ivas_stat_dec.h" -#include "ivas_cnst.h" #include #include #include diff --git a/lib_util/mime_io.c b/lib_util/mime_io.c index 9b20aaeb5c0c9fcbbcc1a83ab577f1727d894080..b6afcd1db88cdbf236bf43abc8c5397453171195 100644 --- a/lib_util/mime_io.c +++ b/lib_util/mime_io.c @@ -33,7 +33,7 @@ #include "mime_io.h" #include "mime.h" #include "prot_fx.h" -#include "string.h" +#include #include #include #include