diff --git a/apps/decoder.c b/apps/decoder.c index d6b189ccf85f0ca9e7668af84572b6a53744ee5b..401a26761ce7244356038ff81f2ba9abd4994989 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -133,7 +133,6 @@ typedef struct bool applyPiData; char *piOutputFilename; bool rtpOutSR; - bool evsMode; IVAS_ROOM_SIZE_T roomSize; } DecArguments; @@ -884,7 +883,6 @@ static bool parseCmdlIVAS_dec( arg->output_Fs = IVAS_MAX_SAMPLING_RATE; arg->outputConfig = IVAS_AUDIO_CONFIG_MONO; arg->decMode = IVAS_DEC_MODE_IVAS; - arg->evsMode = false; arg->quietModeEnabled = false; arg->delayCompensationEnabled = true; arg->voipMode = false; @@ -1378,7 +1376,6 @@ static bool parseCmdlIVAS_dec( } else if ( strcmp( argv_to_upper, "-EVS" ) == 0 ) { - arg->evsMode = true; arg->decMode = IVAS_DEC_MODE_EVS; i++; } @@ -1469,7 +1466,7 @@ static bool parseCmdlIVAS_dec( usage_dec(); return false; } - else if ( arg->non_diegetic_pan_enabled && arg->outputConfig == IVAS_AUDIO_CONFIG_STEREO && arg->evsMode ) + else if ( arg->non_diegetic_pan_enabled && arg->outputConfig == IVAS_AUDIO_CONFIG_STEREO && arg->decMode == IVAS_DEC_MODE_EVS ) { fprintf( stderr, "Error: Both non-diegetic panning and stereo output specified!\n\n" ); usage_dec(); diff --git a/apps/renderer.c b/apps/renderer.c index 4f05f6f4c8382ca135f0ca8580501898412c32c5..69e1935eb0c5727f32f24651dbcac15e44fa19c7 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1640,7 +1640,7 @@ int main( ObjectPositionBuffer mtdBuffer; outBuffer.pq_fact = &outBuffer.q_factor; - Word16 subframe_len = (Word16) ( args.sampleRate / ( 200 ) ); // sample rate /FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES + Word16 subframe_len = (Word16) ( args.sampleRate / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ); Word16 gd_bits = find_guard_bits( subframe_len ); Word16 prev_q_fact = Q11; while ( 1 ) diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 320cac0810ca27cf11c07f3ba07a1195f3cb0600..746f8d2ddd97fb88b4ee28ef8e8f272ff2ba14bc 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -593,12 +593,9 @@ enum *----------------------------------------------------------------------------------*/ #define FRAMES_PER_SEC 50 -#define MAX_PARAM_SPATIAL_SUB_FRAMES_PER_SEC 200 //(FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES) -#define ONE_BY_SUBFRAME_LEN_MS_Q31 (429496730) #define ONE_BY_FRAMES_PER_SEC_Q31 ( 42949673 ) #define FRAMES_PER_SEC_BY_2 (FRAMES_PER_SEC >> 1) #define INV_FRAME_PER_SEC_Q15 656 -#define INV_FR_P_S_MX_PRM_SPL_SBFR_Q15 164 #define FRAME_SIZE_NS 20000000L #define ACELP_LOOK_NS 8750000L diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 9274be5b4f879d45936b1005eb0cf89b8cd1bd0e..7f16a8b365187a2d07687249b7ff9d08d5142493 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -208,6 +208,9 @@ typedef enum TC_BUFFER_MODE_BUFFER } TC_BUFFER_MODE; +#define ONE_BY_SUBFRAME_LEN_MS_Q31 429496730 +#define ONE_BY_SUBFR_PER_SEC_Q15 164 + /*----------------------------------------------------------------------------------* * IVAS Bitrates diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 5e5d3c5bdca0188ca82a747cfa18ef8b0931f97d..def4c806b0c503d9d922a5721a416b32e19b959d 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1126,8 +1126,8 @@ void ivas_mono_stereo_downmix_mcmasa_fx( ); void ivas_apply_non_diegetic_panning_fx( - Word32 *input_f_fx, /* i : non-diegetic object */ - Word32 *output_fx[], /* i/o: core-coder transport mono channel/stereo output */ + Word32 *input_f_fx, /* i : non-diegetic object (mono channel) */ + Word32 *output_fx[], /* o : stereo output channels */ const Word16 non_diegetic_pan_gain_fx, /* i : non-diegetic panning gain */ const Word16 output_frame /* i : output frame length per channel */ ); @@ -3733,6 +3733,12 @@ void ivas_mc2sba_fx( const Word16 gain_lfe /* i : gain for LFE, 0 = ignore LFE */ ); +void ivas_stereo2sba_fx( + Word32 *input_fx[], /* i : core-coder transport stereo channels */ + Word32 *output_fx[], /* o : SBA output channels */ + const Word16 output_frame /* i : output frame length per channel */ +); + void ivas_param_mc_mc2sba_cldfb_fx( IVAS_OUTPUT_SETUP hTransSetup, /* i : transported MC Format */ Word32 *hoa_encoder, /* i : HOA3 encoder for the transported MC format */ @@ -3885,6 +3891,7 @@ void ivas_set_ism_importance_interformat_fx( const Word16 lp_noise_CPE_fx, /* i : LP filtered total noise estimation */ Word16 ism_imp[] /* o : ISM importance flags */ ); + void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( Decoder_Struct *st_ivas, Word32 inRe_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*cldfb_buf_q*/ @@ -3894,7 +3901,6 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( const Word16 subframe ); - void ivas_omasa_decode_masa_to_total_fx( UWord16 *bit_stream, Word16 *index, diff --git a/lib_com/options.h b/lib_com/options.h index 52e39ec1576f979ce2d9c9bfbcb6787e92d920b3..2f468a0103cf461a087a99ff839532ec719af75b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -84,13 +84,15 @@ #define FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK /* Eri: Issue 1999: Range check on float values of distance attenuation, while the float values are not propagated to this function. The test is not correct, but configurable distance attenuation is not used in Characterization.*/ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ - +#define FIX_1435_MOVE_STEREO_PANNING /* VA: issue 1435: do the EVS stereo panning in the renderer */ /* #################### End BE switches ################################## */ /* #################### Start NON-BE switches ############################ */ /* any switch which is non-be wrt. TS 26.251 V3.0 */ +#define FIX_1454_FIX_STEREO_TO_FOA_JBM /* VA: issue 1454: fix buggy stereo to FOA in JBM */ + /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 64e1f817742e2b5edc035a969a8be4a3d67e9e64..4e3c652865b0d1b9e3b6737fae230c4aeba4e1bb 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -1139,6 +1139,7 @@ ivas_error ivas_dec_setup( * Initialize decoder in the first good frame based on IVAS format * and number of transport channels *-------------------------------------------------------------------*/ + test(); IF( st_ivas->ini_frame == 0 && NE_32( st_ivas->ivas_format, UNDEFINED_FORMAT ) ) { @@ -1582,7 +1583,6 @@ ivas_error ivas_init_decoder_front( * Allocate and initialize Binaural Renderer configuration handle *--------------------------------------------------------------------*/ - test(); test(); test(); @@ -1729,12 +1729,6 @@ ivas_error ivas_init_decoder_fx( move16(); } - test(); - IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) || EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) - { - st_ivas->transport_config = EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ? IVAS_AUDIO_CONFIG_MONO : IVAS_AUDIO_CONFIG_STEREO; - } - /* Only initialize transport setup if it is used */ IF( NE_32( st_ivas->transport_config, IVAS_AUDIO_CONFIG_INVALID ) ) { @@ -1900,6 +1894,9 @@ ivas_error ivas_init_decoder_fx( { st_ivas->nchan_transport = CPE_CHANNELS; move16(); + st_ivas->intern_config = IVAS_AUDIO_CONFIG_STEREO; + move32(); + st_ivas->nSCE = 0; move16(); st_ivas->nCPE = 1; /* in stereo, there is always only one CPE */ @@ -3966,7 +3963,6 @@ static ivas_error doSanityChecks_IVAS( return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified!" ); } - test(); test(); IF( ( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) && NE_32( output_Fs, 48000 ) ) diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index 2e2a257a11a96837fc296c79ea672c18ac0cc540..32f54c45ab7755bcf229c219e3d619eebff8ad6a 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -233,7 +233,7 @@ void ivas_ism_render_sf_fx( { Word16 n_samples_in_subframe; - n_samples_in_subframe = st_ivas->hTcBuffer->n_samples_granularity * st_ivas->hTcBuffer->subframe_nbslots[subframe_idx]; + n_samples_in_subframe = imult1616( st_ivas->hTcBuffer->n_samples_granularity, st_ivas->hTcBuffer->subframe_nbslots[subframe_idx] ); test(); IF( st_ivas->hCombinedOrientationData && EQ_16( st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx], 1 ) ) { diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 5c60e89f3ca3cb93a8d4d41b6340c8673e1cea07..cca59f2b6b21719471fc3e0dc4a5ab170993da6e 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1719,6 +1719,11 @@ ivas_error ivas_jbm_dec_render_fx( /*----------------------------------------------------------------* * Rendering *----------------------------------------------------------------*/ + + *nSamplesRendered = s_min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); + move16(); + + test(); test(); IF( EQ_32( st_ivas->ivas_format, UNDEFINED_FORMAT ) ) { @@ -1726,6 +1731,7 @@ ivas_error ivas_jbm_dec_render_fx( } ELSE IF( EQ_32( st_ivas->hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_BUFFER ) ) { +#ifndef FIX_1435_MOVE_STEREO_PANNING Word16 slot_size, tmp, e; slot_size = st_ivas->hTcBuffer->n_samples_granularity; @@ -1734,36 +1740,29 @@ ivas_error ivas_jbm_dec_render_fx( /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ tmp = BASOP_Util_Divide1616_Scale( nSamplesAsked, slot_size, &e ); tmp = shr( tmp, sub( 15, e ) ); - +#endif ivas_jbm_dec_tc_buffer_playout_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output_fx ); } ELSE IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) || EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) { - *nSamplesRendered = s_min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); - move16(); - /* Rendering */ IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) ) { ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, *nSamplesRendered, p_tc_fx, p_output_fx ); } +#ifdef FIX_1435_MOVE_STEREO_PANNING + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) ) + { + ivas_apply_non_diegetic_panning_fx( p_tc_fx[0], p_output_fx, st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx, *nSamplesRendered ); + } +#endif ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) { - IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ) - { - /* routed to W */ - ivas_jbm_dec_tc_buffer_playout_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output_fx ); - } - ELSE IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) - { - FOR( n = 0; n < *nSamplesRendered; n++ ) - { - Word32 tmp; - tmp = p_output_fx[0][n]; - p_output_fx[0][n] = L_shr( L_add( tmp, p_output_fx[1][n] ), 1 ); /* W = 0.5 * ( L + R ) */ - p_output_fx[1][n] = L_shr( L_sub( tmp, p_output_fx[1][n] ), 1 ); /* Y = 0.5 * ( L - R ) */ - } - } +#ifdef FIX_1454_FIX_STEREO_TO_FOA_JBM + ivas_stereo2sba_fx( p_tc_fx, p_output_fx, *nSamplesRendered ); +#else + ivas_stereo2sba_fx( p_output_fx, p_output_fx, *nSamplesRendered ); +#endif } } ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) @@ -1791,9 +1790,6 @@ ivas_error ivas_jbm_dec_render_fx( } ELSE /* ISM_MODE_DISC */ { - *nSamplesRendered = s_min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); - move16(); - test(); test(); /* Loudspeaker or Ambisonics rendering */ @@ -1974,9 +1970,6 @@ ivas_error ivas_jbm_dec_render_fx( } ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_OSBA_STEREO ) ) { - *nSamplesRendered = s_min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); - move16(); - test(); /* shift SBA channels to avoid overwrite by ISM upmix in 1 object case and non-TSM unified channel memory*/ IF( EQ_16( st_ivas->nchan_ism, 1 ) && EQ_16( st_ivas->hDecoderConfig->Opt_tsm, 0 ) ) @@ -2059,8 +2052,6 @@ ivas_error ivas_jbm_dec_render_fx( { Word16 crendInPlaceRotation = FALSE; move16(); - *nSamplesRendered = s_min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); - move16(); test(); test(); @@ -2155,9 +2146,6 @@ ivas_error ivas_jbm_dec_render_fx( } ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) ) { - *nSamplesRendered = s_min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); - move16(); - ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, *nSamplesRendered, p_tc_fx, p_output_fx ); } ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) @@ -2820,12 +2808,12 @@ ivas_error ivas_jbm_dec_set_discard_samples_fx( { Word16 nMaxSlotsPerSubframe, nSlotsInFirstSubframe; Word16 temp, temp_e; + /* render first frame with front zero padding and discarding those samples */ - // nMaxSlotsPerSubframe = (Word16)(st_ivas->hDecoderConfig->output_Fs / (FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES)) / st_ivas->hTcBuffer->n_samples_granularity; - temp = BASOP_Util_Divide3232_Scale( st_ivas->hDecoderConfig->output_Fs, ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ), &temp_e ); - temp = shr( temp, sub( 15, temp_e ) ); - nMaxSlotsPerSubframe = BASOP_Util_Divide1616_Scale( temp, st_ivas->hTcBuffer->n_samples_granularity, &temp_e ); - nMaxSlotsPerSubframe = shr( nMaxSlotsPerSubframe, sub( 15, temp_e ) ); // Q0 + /* nMaxSlotsPerSubframe = (Word16)(st_ivas->hDecoderConfig->output_Fs / (FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES)) / st_ivas->hTcBuffer->n_samples_granularity; */ + temp = extract_l( Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ) ); + temp = BASOP_Util_Divide1616_Scale( temp, st_ivas->hTcBuffer->n_samples_granularity, &temp_e ); + nMaxSlotsPerSubframe = shr( temp, sub( 15, temp_e ) ); /* Q0 */ nSlotsInFirstSubframe = sub( nMaxSlotsPerSubframe, st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] ); IF( nSlotsInFirstSubframe > 0 ) { @@ -3084,7 +3072,6 @@ Word16 ivas_jbm_dec_get_num_tc_channels_fx( Word32 ivas_total_brate; AUDIO_CONFIG output_config; - IF( EQ_16( st_ivas->renderer_type, RENDERER_DISABLE ) ) { num_tc = st_ivas->hDecoderConfig->nchan_out; @@ -3104,7 +3091,17 @@ Word16 ivas_jbm_dec_get_num_tc_channels_fx( test(); test(); test(); +#ifdef FIX_1435_MOVE_STEREO_PANNING + test(); + IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ) + { + num_tc = 1; + move16(); + } + ELSE IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) && EQ_16( st_ivas->hDecoderConfig->nchan_out, 1 ) ) +#else IF( EQ_16( st_ivas->ivas_format, STEREO_FORMAT ) && EQ_16( st_ivas->hDecoderConfig->nchan_out, 1 ) ) +#endif { num_tc = 1; move16(); @@ -3246,11 +3243,13 @@ Word16 ivas_jbm_dec_get_num_tc_channels_fx( } } } +#ifndef FIX_1435_MOVE_STEREO_PANNING ELSE IF( EQ_16( st_ivas->ivas_format, MONO_FORMAT ) && EQ_16( st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) ) { num_tc = MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN; move16(); } +#endif return num_tc; } @@ -3443,7 +3442,6 @@ ivas_error ivas_jbm_dec_tc_buffer_open_fx( Word16 nMaxSlotsPerSubframe; ivas_error error; Word16 tmp, tmp_e; - Word32 tmp32; /*-----------------------------------------------------------------* * prepare library opening @@ -3481,9 +3479,10 @@ ivas_error ivas_jbm_dec_tc_buffer_open_fx( hTcBuffer->nb_subframes = MAX_PARAM_SPATIAL_SUBFRAMES; move16(); - tmp32 = L_mult0( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES, hTcBuffer->n_samples_granularity ); // Q0 - tmp = BASOP_Util_Divide3232_Scale( st_ivas->hDecoderConfig->output_Fs, tmp32, &tmp_e ); - nMaxSlotsPerSubframe = shr( tmp, sub( 15, tmp_e ) ); // Q0 + /* nMaxSlotsPerSubframe = (Word16)(st_ivas->hDecoderConfig->output_Fs / (FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES)) / st_ivas->hTcBuffer->n_samples_granularity; */ + tmp = extract_l( Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ) ); + tmp = BASOP_Util_Divide1616_Scale( tmp, hTcBuffer->n_samples_granularity, &tmp_e ); + nMaxSlotsPerSubframe = shr( tmp, sub( 15, tmp_e ) ); /* Q0 */ hTcBuffer->num_slots = mult0( nMaxSlotsPerSubframe, MAX_PARAM_SPATIAL_SUBFRAMES ); move16(); @@ -3549,8 +3548,13 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx( IF( NE_16( n_samples_granularity, hTcBuffer->n_samples_granularity ) ) { Word16 nMaxSlotsPerSubframeNew; + Word16 tmp, tmp_e; + + /* nMaxSlotsPerSubframeNew = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / n_samples_granularity; */ + tmp = extract_l( Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ) ); + tmp = BASOP_Util_Divide1616_Scale( tmp, n_samples_granularity, &tmp_e ); + nMaxSlotsPerSubframeNew = shr( tmp, sub( 15, tmp_e ) ); /* Q0 */ - nMaxSlotsPerSubframeNew = idiv1616( divide3216( st_ivas->hDecoderConfig->output_Fs, ( ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) >> 1 ) ), n_samples_granularity ); // Q0 /* if samples were flushed, take that into account here */ test(); IF( LT_16( n_samples_granularity, hTcBuffer->n_samples_granularity ) && hTcBuffer->n_samples_flushed > 0 ) @@ -3682,17 +3686,17 @@ void ivas_jbm_dec_td_renderers_adapt_subframes( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { - Word16 nMaxSlotsPerSubframe, nSlotsAvailable, tmp, exp, tmp1, tmp2, s1, s2; + Word16 nMaxSlotsPerSubframe, nSlotsAvailable, tmp, tmp_e, tmp1, tmp2, s1, s2; UWord16 nSlotsInLastSubframe, nSlotsInFirstSubframe; /* nMaxSlotsPerSubframe = (Word16) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; */ - tmp = extract_l( Mpy_32_32_r( st_ivas->hDecoderConfig->output_Fs, 10737418 /* 1 / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) in Q31 */ ) ); - tmp = BASOP_Util_Divide1616_Scale( tmp, st_ivas->hTcBuffer->n_samples_granularity, &exp ); - nMaxSlotsPerSubframe = shr( tmp, sub( 15, exp ) ); // Q0 + tmp = extract_l( Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ) ); + tmp = BASOP_Util_Divide1616_Scale( tmp, st_ivas->hTcBuffer->n_samples_granularity, &tmp_e ); + nMaxSlotsPerSubframe = shr( tmp, sub( 15, tmp_e ) ); /* Q0 */ /* nSlotsAvailable = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; */ - tmp = BASOP_Util_Divide1616_Scale( st_ivas->hTcBuffer->n_samples_available, st_ivas->hTcBuffer->n_samples_granularity, &exp ); - nSlotsAvailable = shr( tmp, sub( 15, exp ) ); // Q0 + tmp = BASOP_Util_Divide1616_Scale( st_ivas->hTcBuffer->n_samples_available, st_ivas->hTcBuffer->n_samples_granularity, &tmp_e ); + nSlotsAvailable = shr( tmp, sub( 15, tmp_e ) ); /* Q0 */ st_ivas->hTcBuffer->num_slots = nSlotsAvailable; move16(); @@ -3771,6 +3775,9 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode_fx( buffer_mode = TC_BUFFER_MODE_BUFFER; move16(); BREAK; +#ifdef FIX_1435_MOVE_STEREO_PANNING + case RENDERER_NON_DIEGETIC_DOWNMIX: +#endif case RENDERER_TD_PANNING: case RENDERER_BINAURAL_OBJECTS_TD: case RENDERER_BINAURAL_FASTCONV: @@ -3789,6 +3796,7 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode_fx( buffer_mode = TC_BUFFER_MODE_RENDERER; move16(); BREAK; +#ifndef FIX_1435_MOVE_STEREO_PANNING case RENDERER_NON_DIEGETIC_DOWNMIX: IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ) { @@ -3801,6 +3809,7 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode_fx( move16(); } break; +#endif case RENDERER_MC_PARAMMC: IF( EQ_32( st_ivas->hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) { diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index b41036a5d6cfa4016b10116de0e2983b1ef7a529..b91e5233c1bb34037043e31c5fe0bc9b4e7f4f82 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -1422,7 +1422,7 @@ static ivas_error init_lfe_synth_data_fx( /* Ring buffer for the filterbank of the LFE synthesis. * The filterbank is using moving average lowpass filter with the crossover of 120 Hz. */ /* bufferSize = (int16_t) ( ( output_Fs / FRAMES_PER_SEC ) / MAX_PARAM_SPATIAL_SUBFRAMES ); */ - bufferSize = extract_l( Mpy_32_32_r( output_Fs, 10737418 /* 1 / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) in Q31 */ ) ); + bufferSize = extract_l( Mpy_32_16_1( output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ) ); IF( ( hMasa->hMasaLfeSynth->lfeSynthRingBuffer_fx = (Word32 *) malloc( bufferSize * sizeof( Word32 ) ) ) == NULL ) { diff --git a/lib_dec/ivas_mono_dmx_renderer_fx.c b/lib_dec/ivas_mono_dmx_renderer_fx.c index 6c64eee816fc5cfbb4db6c676a09e080e004d4bc..fffcfff2ec363dd5a5f5c9de844170207d7d87db 100644 --- a/lib_dec/ivas_mono_dmx_renderer_fx.c +++ b/lib_dec/ivas_mono_dmx_renderer_fx.c @@ -317,10 +317,10 @@ void ivas_mono_stereo_downmix_mcmasa_fx( *------------------------------------------------------------------------*/ void ivas_apply_non_diegetic_panning_fx( - Word32 *input_f_fx, /* i : non-diegetic object */ - Word32 *output_fx[], /* o: core-coder transport mono channel/stereo output */ - const Word16 non_diegetic_pan_gain_fx, /* i : non-diegetic panning gain Q15*/ - const Word16 output_frame /* i : output frame length per channel Q11*/ + Word32 *input_f_fx, /* i : non-diegetic object (mono channel) */ + Word32 *output_fx[], /* o : stereo output channels */ + const Word16 non_diegetic_pan_gain_fx, /* i : non-diegetic panning gain Q15*/ + const Word16 output_frame /* i : output frame length per channel */ ) { Word16 pan_left_fx, pan_right_fx; diff --git a/lib_dec/ivas_output_config_fx.c b/lib_dec/ivas_output_config_fx.c index 48305b524007f5a031ec98af79f2ed468cc1da06..abf80add0da1b9f2af4f621c1d3680a42b573064 100644 --- a/lib_dec/ivas_output_config_fx.c +++ b/lib_dec/ivas_output_config_fx.c @@ -37,34 +37,13 @@ #include "wmc_auto.h" #include "ivas_prot_fx.h" -static void ms_bin_upmix_renderer_select( - const IVAS_FORMAT ivas_format, /* i : Decoder format */ - IVAS_AUDIO_CONFIG *internal_config, /* o : Internal configuration for rendering */ - RENDERER_TYPE *renderer_type /* o : Selected renderer type */ -) -{ - - *internal_config = EQ_32( ivas_format, MONO_FORMAT ) ? IVAS_AUDIO_CONFIG_MONO : IVAS_AUDIO_CONFIG_STEREO; - - IF( EQ_32( ivas_format, MONO_FORMAT ) ) - { - *renderer_type = RENDERER_NON_DIEGETIC_DOWNMIX; - move16(); - } - ELSE - { - *renderer_type = RENDERER_DISABLE; - move16(); - } - return; -} - /*-------------------------------------------------------------------------* * ivas_renderer_select() * * Select and configure IVAS renderer parameters *-------------------------------------------------------------------------*/ + void ivas_renderer_select( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) @@ -110,9 +89,15 @@ void ivas_renderer_select( test(); test(); test(); - IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) || EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) + IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ) + { + *renderer_type = RENDERER_NON_DIEGETIC_DOWNMIX; + move16(); + } + ELSE IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) { - ms_bin_upmix_renderer_select( st_ivas->ivas_format, internal_config, renderer_type ); + *renderer_type = RENDERER_DISABLE; + move16(); } ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) { @@ -298,47 +283,43 @@ void ivas_renderer_select( * Non-binaural rendering configurations *-----------------------------------------------------------------*/ - ELSE IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) || EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) + ELSE IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ) { - *internal_config = EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ? IVAS_AUDIO_CONFIG_MONO : IVAS_AUDIO_CONFIG_STEREO; - move16(); - - SWITCH( output_config ) + test(); + test(); + test(); + test(); + test(); + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) { - case IVAS_AUDIO_CONFIG_FOA: - case IVAS_AUDIO_CONFIG_HOA2: - case IVAS_AUDIO_CONFIG_HOA3: - *renderer_type = RENDERER_SBA_LINEAR_ENC; - move16(); - BREAK; - case IVAS_AUDIO_CONFIG_5_1: - case IVAS_AUDIO_CONFIG_7_1: - case IVAS_AUDIO_CONFIG_5_1_2: - case IVAS_AUDIO_CONFIG_5_1_4: - case IVAS_AUDIO_CONFIG_7_1_4: - case IVAS_AUDIO_CONFIG_LS_CUSTOM: - *renderer_type = RENDERER_MC; - move16(); - BREAK; - case IVAS_AUDIO_CONFIG_MONO: - IF( EQ_32( *internal_config, IVAS_AUDIO_CONFIG_STEREO ) ) - { - /* stereo to mono downmix */ - *renderer_type = RENDERER_MC; - move16(); - } - BREAK; - case IVAS_AUDIO_CONFIG_STEREO: - IF( EQ_32( *internal_config, IVAS_AUDIO_CONFIG_MONO ) ) - { - /* mono to stereo upmix */ - *renderer_type = RENDERER_NON_DIEGETIC_DOWNMIX; - move16(); - } - BREAK; - default: - /* RENDERER_DISABLE already set by default */ - BREAK; + *renderer_type = RENDERER_NON_DIEGETIC_DOWNMIX; + move16(); + } + ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) + { + *renderer_type = RENDERER_MC; + move16(); + } + } + ELSE IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) + { + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) + { + *renderer_type = RENDERER_SBA_LINEAR_ENC; + move16(); + } + ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) + { + *renderer_type = RENDERER_MC; + move16(); } } ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) diff --git a/lib_dec/ivas_sba_rendering_internal_fx.c b/lib_dec/ivas_sba_rendering_internal_fx.c index d9f7b26be0676b936f9d11c681b3001ed0332488..5d8724a19fb86c6aa84c2f1e09fa89d886408d50 100644 --- a/lib_dec/ivas_sba_rendering_internal_fx.c +++ b/lib_dec/ivas_sba_rendering_internal_fx.c @@ -212,6 +212,32 @@ void ivas_mc2sba_fx( } +/*-------------------------------------------------------------------------* + * ivas_stereo2sba() + * + * stereo signal is transformed into SBA in TD domain + *-------------------------------------------------------------------------*/ + +void ivas_stereo2sba_fx( + Word32 *input_fx[], /* i : core-coder transport stereo channels */ + Word32 *output_fx[], /* o : SBA output channels */ + const Word16 output_frame /* i : output frame length per channel */ +) +{ + Word16 n; + Word32 tmp; + + FOR( n = 0; n < output_frame; n++ ) + { + tmp = input_fx[0][n]; + output_fx[0][n] = L_shr( L_add( tmp, input_fx[1][n] ), 1 ); /* W = 0.5 * ( L + R ) */ + output_fx[1][n] = L_shr( L_sub( tmp, input_fx[1][n] ), 1 ); /* Y = 0.5 * ( L - R ) */ + } + + return; +} + + /*-------------------------------------------------------------------------* * ivas_param_mc_mc2sba_cldfb() * diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index 625606678420527cd9d8340dce81de8872368578..5e1c8270f8e1e355e27d76a303e006f8dced3db7 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -4392,7 +4392,7 @@ void stereo_dft_dec_read_BS_fx( test(); IF( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) && NE_16( ivas_format, MASA_FORMAT ) ) { - *nb_bits = (Word16) Mult_32_16( L_sub( element_brate, SID_2k40 ), INV_FRAME_PER_SEC_Q15 ); /* => hCPE->hCoreCoder[0]->total_brate = SID_2k40; Q0*/ + *nb_bits = extract_l( Mult_32_16( L_sub( element_brate, SID_2k40 ), INV_FRAME_PER_SEC_Q15 ) ); /* => hCPE->hCoreCoder[0]->total_brate = SID_2k40; Q0*/ move16(); } { diff --git a/lib_dec/jbm_pcmdsp_apa_fx.c b/lib_dec/jbm_pcmdsp_apa_fx.c index bdf896c115861d812953d38581eca9cd95ba85eb..82cebd2fbad9a8ad02d5516f0ef49b15e530c319 100644 --- a/lib_dec/jbm_pcmdsp_apa_fx.c +++ b/lib_dec/jbm_pcmdsp_apa_fx.c @@ -691,7 +691,11 @@ UWord8 apa_exec_fx( ) { UWord16 i; +#ifdef FIX_1435_MOVE_STEREO_PANNING + Word16 frm_in[APA_BUF_PER_CHANNEL]; /* NOTE: this buffer could be smaller if alocated dynamically based on the actual sampling rate */ +#else Word16 frm_in[CPE_CHANNELS * APA_BUF / APA_MAX_NUM_CHANNELS]; /* in EVS, 2 output channels */ /* NOTE: this buffer could be smaller if alocated dynamically based on the actual sampling rate and number of channels */ +#endif UWord16 l_frm_out; Word16 l_rem; Word32 dl_scaled, dl_copied, l_frm_out_target; diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 19613babc165207c5621e1766bba17deeb04e5bf..bd86f5c6fee75e956203faeff560501a3bf2dfdf 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -791,7 +791,7 @@ static Word16 get_render_frame_size_samples( { Word16 tmp; - tmp = (Word16) Mpy_32_16_1( hDecoderConfig->output_Fs, INV_FR_P_S_MX_PRM_SPL_SBFR_Q15 ); + tmp = extract_l( Mpy_32_16_1( hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ) ); IF( EQ_16( hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) ) { @@ -1048,6 +1048,8 @@ ivas_error IVAS_DEC_FeedFrame_Serial( { hIvasDec->st_ivas->hDecoderConfig->ivas_total_brate = ACELP_8k00; move32(); + hIvasDec->st_ivas->transport_config = IVAS_AUDIO_CONFIG_MONO; + move32(); IF( NE_32( ( error = ivas_init_decoder_fx( hIvasDec->st_ivas ) ), IVAS_ERR_OK ) ) { @@ -1157,12 +1159,12 @@ static Word16 isar_get_frame_size( ( EQ_32( st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) || EQ_32( st_ivas->hRenderConfig->split_rend_config.dof, 0 ) ) ) { - nSamplesPerChannel = extract_l( ar_div( output_Fs, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ); + nSamplesPerChannel = extract_l( Mpy_32_16_1( output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ) ); nSamplesPerChannel = imult1616( nSamplesPerChannel, st_ivas->hDecoderConfig->render_framesize ); } ELSE { - nSamplesPerChannel = extract_l( ar_div( output_Fs, FRAMES_PER_SEC ) ); + nSamplesPerChannel = extract_l( Mpy_32_16_1( output_Fs, INV_FRAME_PER_SEC_Q15 ) ); } return nSamplesPerChannel; @@ -1651,6 +1653,9 @@ static ivas_error ivas_dec_setup_all( IF( EQ_16( (Word16) hIvasDec->mode, IVAS_DEC_MODE_EVS ) ) { +#ifdef FIX_1435_MOVE_STEREO_PANNING + *nTransportChannels = 1; +#else IF( EQ_16( (Word16) hIvasDec->st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) ) { *nTransportChannels = MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN; @@ -1659,6 +1664,7 @@ static ivas_error ivas_dec_setup_all( { *nTransportChannels = 1; } +#endif move16(); } ELSE @@ -3853,7 +3859,11 @@ static ivas_error apa_exec_evs_wrapper( { Word16 ch; UWord16 apa_buff_len; +#ifdef FIX_1435_MOVE_STEREO_PANNING + Word16 tmp_apaExecBuffer[APA_BUF_PER_CHANNEL]; +#else Word16 tmp_apaExecBuffer[CPE_CHANNELS * APA_BUF / APA_MAX_NUM_CHANNELS]; /* in EVS, 2 output channels */ +#endif DECODER_TC_BUFFER_HANDLE hTcBuffer; test(); @@ -5636,9 +5646,14 @@ static ivas_error evs_dec_main_fx( Decoder_Struct *st_ivas ) { DEC_CORE_HANDLE *hCoreCoder; +#ifndef FIX_1435_MOVE_STEREO_PANNING Word16 mixer_left_fx, mixer_right_fx; Word32 *p_output_fx[MAX_TRANSPORT_CHANNELS]; Word16 ch, i, nOutSamples; +#else + Word32 *p_output_fx[1]; + Word16 i, nOutSamples; +#endif Word16 output_16[L_FRAME48k]; ivas_error error; @@ -5652,6 +5667,9 @@ static ivas_error evs_dec_main_fx( mdct_switching_dec_fx( hCoreCoder[0] ); +#ifdef FIX_1435_MOVE_STEREO_PANNING + p_output_fx[0] = st_ivas->p_output_fx[0]; +#else FOR( ch = 0; ch < MAX_TRANSPORT_CHANNELS; ch++ ) { p_output_fx[ch] = st_ivas->p_output_fx[ch]; // Q0 @@ -5660,6 +5678,7 @@ static ivas_error evs_dec_main_fx( set_zero_fx( p_output_fx[ch], L_FRAME48k ); } } +#endif /* run the main EVS decoding routine */ IF( EQ_16( hCoreCoder[0]->codec_mode, MODE1 ) ) @@ -5711,6 +5730,7 @@ static ivas_error evs_dec_main_fx( st_ivas->BER_detect = hCoreCoder[0]->BER_detect; move16(); +#ifndef FIX_1435_MOVE_STEREO_PANNING IF( EQ_16( st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) ) { mixer_left_fx = add( shr( st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx, Q1 ), ONE_IN_Q14 ); // Q14 @@ -5719,9 +5739,9 @@ static ivas_error evs_dec_main_fx( v_multc_fx_16( p_output_fx[0], mixer_right_fx, p_output_fx[1], nOutSamples ); /* Q11 */ v_multc_fx_16( p_output_fx[0], mixer_left_fx, p_output_fx[0], nOutSamples ); /* Q11 */ } +#endif - test(); - IF( st_ivas->hDecoderConfig->Opt_tsm && EQ_16( st_ivas->hDecoderConfig->nchan_out, 1 ) ) + /*if ( st_ivas->hDecoderConfig->Opt_tsm && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO )*/ { /* BE workaround: in order to keep EVS bit-exact wrt. TS 26.443, convert 'float' output data to 'short' before the TSM */ /* not applicable in BASOP */ diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index 9c3379527d84ee278052b0ce8099af94674a623c..bb1c5519aaea764c817870d44136d01b92f756a9 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -1862,7 +1862,7 @@ static ivas_error ivas_rend_crendConvolver_fx( } /* subframe_length = (int16_t) ( output_Fs / FRAMES_PER_SEC ) / MAX_PARAM_SPATIAL_SUBFRAMES; */ - subframe_length = extract_l( Mpy_32_32_r( output_Fs, 10737418 /* 1 / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) in Q31 */ ) ); + subframe_length = extract_l( Mpy_32_16_1( output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ) ); lfe_idx_in = -1; move16(); diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index dd99c0070055fe74b7b4d7a45cb0d31a37d98cd7..5c72bf87e5f387a05f1b90168ce33fe2cb7e9ed4 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -893,7 +893,7 @@ ivas_error ivas_td_binaural_renderer_ext_fx( { ISM_METADATA_FRAME hIsmMetaDataFrame; ISM_METADATA_HANDLE hIsmMetaData[1]; - Word16 lfe_idx, exp_tmp; + Word16 lfe_idx, tmp, exp_tmp; Word16 num_src; IVAS_FORMAT ivas_format; IVAS_REND_AudioConfigType inConfigType; @@ -968,11 +968,10 @@ ivas_error ivas_td_binaural_renderer_ext_fx( move16(); } - Word16 num_subframes = BASOP_Util_Divide3232_Scale( L_mult0( output_frame, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ), output_Fs, &exp_tmp ); - IF( sub( 15, exp_tmp ) ) - { - num_subframes = shr( num_subframes, sub( 15, exp_tmp ) ); - } + tmp = extract_l( Mpy_32_16_1( output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ) ); + tmp = BASOP_Util_Divide1616_Scale( output_frame, tmp, &exp_tmp ); + Word16 num_subframes = shr( tmp, sub( 15, exp_tmp ) ); /* Q0 */ + FOR( Word16 subframe_idx = 0; subframe_idx < num_subframes; subframe_idx++ ) { Word16 idx = subframe_idx; diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c index 3d810e5d419f010a8cb3616468fa804bed99a07f..d363c3629870ba8d91b323f656918bbe32350ec9 100644 --- a/lib_rend/ivas_rotation_fx.c +++ b/lib_rend/ivas_rotation_fx.c @@ -1490,7 +1490,7 @@ ivas_error ivas_combined_orientation_open_fx( ( *hCombinedOrientationData )->subframe_idx = 0; move16(); /* ( *hCombinedOrientationData )->subframe_size = (int16_t) ( fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ); */ - ( *hCombinedOrientationData )->subframe_size = extract_l( Mpy_32_32_r( fs, 10737418 /* 1 / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) in Q31 */ ) ); + ( *hCombinedOrientationData )->subframe_size = extract_l( Mpy_32_16_1( fs, ONE_BY_SUBFR_PER_SEC_Q15 ) ); move16(); ( *hCombinedOrientationData )->cur_subframe_samples_rendered = 0; move16(); diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 8376e40097fbd2515e4b2f0039bc11cf6f8cdb25..1149440a9dfaf05b6e82a8ed1cbd1f2b420643d9 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -4996,14 +4996,19 @@ ivas_error IVAS_REND_FeedInputAudio_fx( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - test(); - cldfb2tdShift = ( inputAudio.config.is_cldfb ) ? 1 : 0; + cldfb2tdShift = 0; + move16(); + if ( inputAudio.config.is_cldfb ) + { + cldfb2tdShift = 1; + move16(); + } test(); test(); test(); test(); - IF( inputAudio.config.numSamplesPerChannel <= 0 || ( L_FRAME_MAX < inputAudio.config.numSamplesPerChannel && inputAudio.config.is_cldfb == 0 ) || + IF( inputAudio.config.numSamplesPerChannel <= 0 || ( LT_16( L_FRAME_MAX, inputAudio.config.numSamplesPerChannel ) && inputAudio.config.is_cldfb == 0 ) || ( ( shl( L_FRAME_MAX, cldfb2tdShift ) ) < inputAudio.config.numSamplesPerChannel && inputAudio.config.is_cldfb == 1 ) ) { return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Buffer size outside of supported range" ); @@ -5015,6 +5020,8 @@ ivas_error IVAS_REND_FeedInputAudio_fx( return IVAS_ERR_WRONG_NUM_CHANNELS; } + test(); + test(); test(); move32(); // move added for typecasting IF( EQ_32( getAudioConfigType( hIvasRend->outputConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) && @@ -6445,13 +6452,20 @@ static Word16 getNumSubframesInBuffer( const IVAS_REND_AudioBuffer *buffer, const Word32 sampleRate ) { - Word16 cldfb2tdShift; + Word16 cldfb2tdShift, temp, temp_e; - cldfb2tdShift = buffer->config.is_cldfb ? 1 : 0; + cldfb2tdShift = 0; + move16(); + if ( buffer->config.is_cldfb ) + { + cldfb2tdShift = 1; + move16(); + } - Word16 scale, temp = extract_l( Mpy_32_32( sampleRate, 10737418 /* 1 / FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES in Q31 */ ) ); - temp = BASOP_Util_Divide1616_Scale( buffer->config.numSamplesPerChannel, temp, &scale ); - temp = shr( temp, sub( 15, scale ) ); /* Q0 */ + // temp = ( buffer->config.numSamplesPerChannel / ( sampleRate / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES * cldfb2tdSampleFact ) ); + temp = extract_l( Mpy_32_16_1( sampleRate, ONE_BY_SUBFR_PER_SEC_Q15 ) ); + temp = BASOP_Util_Divide1616_Scale( buffer->config.numSamplesPerChannel, temp, &temp_e ); + temp = shr( temp, sub( 15, temp_e ) ); // Q0 temp = shr( temp, cldfb2tdShift ); return temp; @@ -8527,7 +8541,14 @@ static ivas_error renderInputSba( move32(); inAudio = sbaInput->base.inputBuffer; - cldfb2tdShift = outAudio.config.is_cldfb ? 1 : 0; + cldfb2tdShift = 0; + move16(); + if ( outAudio.config.is_cldfb ) + { + cldfb2tdShift = 1; + move16(); + } + test(); IF( NE_32( L_shl( sbaInput->base.numNewSamplesPerChannel, cldfb2tdShift ), outAudio.config.numSamplesPerChannel ) && NE_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { @@ -8888,7 +8909,15 @@ static ivas_error renderInputMasa( inAudio = masaInput->base.inputBuffer; - cldfb2tdShift = outAudio.config.is_cldfb ? 1 : 0; + cldfb2tdShift = 0; + move16(); + if ( outAudio.config.is_cldfb ) + { + cldfb2tdShift = 1; + move16(); + } + test(); + test(); IF( ( NE_32( L_shl( masaInput->base.numNewSamplesPerChannel, cldfb2tdShift ), outAudio.config.numSamplesPerChannel ) ) && NE_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { @@ -8917,15 +8946,18 @@ static ivas_error renderInputMasa( ELSE { /* MASA external renderer -> other formats */ - Word16 num_subframes, exp; + Word16 num_subframes, temp, temp_e; + FOR( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) { tmpBuffer_fx[ch] = tmpBuffer_buff_fx[ch]; } copyBufferTo2dArray_fx( masaInput->base.inputBuffer, tmpBuffer_buff_fx ); - num_subframes = BASOP_Util_Divide3232_Scale( L_mult0( masaInput->base.inputBuffer.config.numSamplesPerChannel, IVAS_NUM_FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ), *masaInput->base.ctx.pOutSampleRate, &exp ); - num_subframes = shr( num_subframes, sub( 15, exp ) ); /* Q0 */ + /* num_subframes = (int16_t) ( masaInput->base.inputBuffer.config.numSamplesPerChannel / ( *masaInput->base.ctx.pOutSampleRate / ( IVAS_NUM_FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); */ + temp = extract_l( Mpy_32_16_1( *masaInput->base.ctx.pOutSampleRate, ONE_BY_SUBFR_PER_SEC_Q15 ) ); + temp = BASOP_Util_Divide1616_Scale( masaInput->base.inputBuffer.config.numSamplesPerChannel, temp, &temp_e ); + num_subframes = shr( temp, sub( 15, temp_e ) ); /* Q0 */ IF( EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) {