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_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..9928cda03491ddf3d8a0f85bdb47c2a426a8e424 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2820,12 +2820,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 ) { @@ -3443,7 +3443,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 +3480,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 +3549,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 +3687,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(); 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_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/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 19613babc165207c5621e1766bba17deeb04e5bf..290e3ef367a909f9031916cbf7bba714a4606e46 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 ) ) { @@ -1157,12 +1157,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; 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 ) ) {