diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index c388377c1c9c15d7f08f1dd25f5e6ae02ef19f20..ca0bcf69e94ed028890bc49bd5bc0020a4a3663b 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5264,7 +5264,8 @@ void ivas_sba_mix_matrix_determiner_fx( const Word16 bfi, /* i : BFI flag */ const Word16 nchan_remapped, /* i : num channels after remapping of TCs */ const Word16 output_frame, /* i : output frame length */ - const Word16 num_md_sub_frames /* i : number of subframes in mixing matrix */ + const Word16 num_md_sub_frames, /* i : number of subframes in mixing matrix */ + const Word16 Q_p_Output /* i : number of subframes in mixing matrix */ ); #endif // IVAS_FLOAT_FIXED diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index c38410672b723305932354881f767f68ff956e15..56ad79dbb8bb3c17afff8223ed058979e159d658 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -576,7 +576,7 @@ ivas_error ivas_jbm_dec_tc_fx( num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate ); SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; - Word16 Q_p_output = 14; + Word16 Q_p_output = MAX_16, temp_min; move16(); Word16 nchan_transport; @@ -586,13 +586,24 @@ ivas_error ivas_jbm_dec_tc_fx( move16(); FOR( ch = 0; ch < nchan_transport; ch++ ) { - Scale_sig32( p_output_fx[ch], output_frame, sub( Q_p_output, Q11 ) ); + temp_min = getScaleFactor32( p_output_fx[ch], output_frame ); + Q_p_output = s_min( Q_p_output, temp_min ); + } + Q_p_output = sub( Q_p_output, 2 ); + IF( GT_16( Q_p_output, 20 ) ) + { + Q_p_output = 20; + move16(); + } + FOR( ch = 0; ch < nchan_transport; ch++ ) + { + Scale_sig32( p_output_fx[ch], output_frame, Q_p_output ); } hSpar->hMdDec->Q_mixer_mat = 31; move16(); - ivas_sba_mix_matrix_determiner_fx( st_ivas->hSpar, p_output_fx, st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames ); + ivas_sba_mix_matrix_determiner_fx( st_ivas->hSpar, p_output_fx, st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames, Q_p_output ); FOR( Word16 c = 0; c < nchan_transport; c++ ) { Scale_sig32( p_output_fx[c], output_frame, 11 ); @@ -978,7 +989,7 @@ ivas_error ivas_jbm_dec_tc_fx( } hSpar->hMdDec->Q_mixer_mat = 31; - ivas_sba_mix_matrix_determiner_fx( st_ivas->hSpar, &p_output_fx[sba_ch_idx], st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames ); + ivas_sba_mix_matrix_determiner_fx( st_ivas->hSpar, &p_output_fx[sba_ch_idx], st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames, sub( Q_p_output, Q11 ) ); FOR( Word16 c = 0; c < nchan_transport; c++ ) { Scale_sig32( p_output_fx[sba_ch_idx + c], output_frame, Q11 ); diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index a8be633735d1210914eab33d2925b0df4c297f2c..6d87d5f8157945a079212ffe192ce0c7d6ed0d4d 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -836,17 +836,18 @@ ivas_error ivas_sba_linear_renderer( *-------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED void ivas_sba_mix_matrix_determiner_fx( - SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ - Word32 *output_fx[], /* i/o: transport/output audio channels */ - const Word16 bfi, /* i : BFI flag */ - const Word16 nchan_remapped, /* i : num channels after remapping of TCs */ - const Word16 output_frame, /* i : output frame length */ - const Word16 num_md_sub_frames /* i : number of subframes in mixing matrix*/ + SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ + Word32 *output_fx[], /* i/o: transport/output audio channels */ + const Word16 bfi, /* i : BFI flag */ + const Word16 nchan_remapped, /* i : num channels after remapping of TCs */ + const Word16 output_frame, /* i : output frame length */ + const Word16 num_md_sub_frames, /* i : number of subframes in mixing matrix*/ + const Word16 Q_output /* i : number of subframes in mixing matrix*/ ) { Word16 i, ch; Word16 num_bands_out, nchan_transport, nchan_out; - Word16 Q_p_output = 14; + Word16 Q_p_output = add( 11, Q_output ); move16(); Word32 temp_fx; /* Convert numeric range */ @@ -888,7 +889,7 @@ void ivas_sba_mix_matrix_determiner_fx( { FOR( i = 0; i < output_frame; i++ ) { - output_fx[ch][i] = Mult_32_32( L_shl_sat( output_fx[ch][i], 4 ), L_shl_sat( PCM16_TO_FLT_FAC_FX, 16 ) ); /*Q-0*/ + output_fx[ch][i] = Mult_32_32( L_shl_sat( output_fx[ch][i], sub( 18, Q_p_output ) ), L_shl_sat( PCM16_TO_FLT_FAC_FX, 16 ) ); /*Q-0*/ } }