diff --git a/apps/decoder.c b/apps/decoder.c index 9d38acb1da54002fbe27e144bd60d4eba4b0f140..2cf649471be482fdccddff180d93a39888031103 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2389,7 +2389,11 @@ static ivas_error decodeG192( { int16_t maxScaling; /* max scaling as abs diff to the normal frame size in samples */ +#ifdef NONBE_FIX_1105_TSM_IN_SILENCE + maxScaling = arg.tsmScale >= 100 ? nOutSamples * vec_pos_len : 0; /* always allow the maximum possible scaling */ +#else maxScaling = (int16_t) ceilf( (float) abs( arg.tsmScale - 100 ) / 100.0f * (float) ( nOutSamples * vec_pos_len ) ); +#endif if ( ( error = IVAS_DEC_VoIP_SetScale( hIvasDec, maxScaling, arg.tsmScale ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_VoIP_SetScale failed: %s \n", IVAS_DEC_GetErrorMessage( error ) ); @@ -2582,7 +2586,23 @@ static ivas_error decodeG192( } int16_t maxScaling; /* max scaling as abs diff to the normal frame size in samples */ - maxScaling = (int16_t) ceilf( (float) abs( arg.tsmScale - 100 ) / 100.0f * (float) ( nOutSamples * vec_pos_len ) ); +#ifdef NONBE_FIX_1105_TSM_IN_SILENCE + maxScaling = scale >= 100 ? nOutSamples * vec_pos_len : 0; /* always allow the maximum possible scaling */ +#else + maxScaling = (int16_t) ceilf( (float) abs( scale - 100 ) / 100.0f * (float) ( nOutSamples * vec_pos_len ) ); +#endif + if ( ( error = IVAS_DEC_VoIP_SetScale( hIvasDec, maxScaling, scale ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_VoIP_SetScale failed: %s \n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + } +#ifdef NONBE_FIX_1105_TSM_IN_SILENCE + else if ( arg.tsmEnabled ) + { + int16_t maxScaling; + /* max scaling as abs diff to the normal frame size in samples */ + maxScaling = arg.tsmScale >= 100 ? nOutSamples * vec_pos_len : 0; /* always allow the maximum possible scaling */ if ( ( error = IVAS_DEC_VoIP_SetScale( hIvasDec, maxScaling, arg.tsmScale ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_VoIP_SetScale failed: %s \n", IVAS_DEC_GetErrorMessage( error ) ); @@ -2590,6 +2610,7 @@ static ivas_error decodeG192( } } #endif +#endif #endif if ( ( error = BS_Reader_ReadFrame_short( hBsReader, bit_stream, &num_bits, &bfi ) ) != IVAS_ERR_OK ) { diff --git a/lib_com/options.h b/lib_com/options.h index 6c4363df1775edf2e1fcac6b2c6b395dd8ed9ad1..eae2486b8d7c76e85638d4712099d46ec4155321 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -190,6 +190,7 @@ #define NONBE_FIX_1087_OOB_SBA_DTX_RS /* VA: issue 1087: Extend the length of the buffer for MCT decoding to avoid out-of-bound writing in SBA SID bitrate switching decoding */ #define NONBE_FIX_1091_PMC_LOW_SIGNAL_BURSTS /* FhG: fix for #1091, fix limit calculation for the regularized inverse of Kx to avoid bursts in very low signals */ #define NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR /* Nok: issue 1074 fixing number of objects signaling in OMASA low rate */ +#define NONBE_FIX_1105_TSM_IN_SILENCE /* FhG: fix for issue #1105: align code to the specification text */ /* ##################### End NON-BE switches ########################### */ /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_dec/jbm_pcmdsp_apa.c b/lib_dec/jbm_pcmdsp_apa.c index bf58f0fa1eb5c8537a08cb3289366d6630934fbe..032fa0dae79c1cfb6f0c758683fd3d61542c43e1 100644 --- a/lib_dec/jbm_pcmdsp_apa.c +++ b/lib_dec/jbm_pcmdsp_apa.c @@ -1163,17 +1163,34 @@ static bool shrink_frm( quality = 5; if ( ps->evs_compat_mode == false ) { - +#ifdef NONBE_FIX_1105_TSM_IN_SILENCE + if ( maxScaling != 0U && s_end > maxScaling + 1 ) + { + xtract = maxScaling; + } + else + { + /* set to last valid element (i.e. element[len - 1] but note for stereo last element is last pair of samples) */ + xtract = s_end; + } + /* snap to renderer time slot borders */ + xtract += ( ps->l_ts - xtract % ps->l_ts ) % ps->l_ts - ( ps->l_ts - ps->l_r_buf ) % ps->l_ts; +#else xtract = maxScaling; /* take samples already in the renderer buf into account */ xtract += ps->l_r_buf; /* snap to renderer time slot borders */ xtract -= ( ps->l_ts - ( l_frm - xtract + ps->l_r_buf ) % ps->l_ts ); +#endif while ( xtract < 0 ) { xtract += ps->l_ts; } +#ifdef NONBE_FIX_1105_TSM_IN_SILENCE + while ( xtract > ( s_end ) ) +#else while ( xtract > ( s_end - ps->num_channels ) ) +#endif { /* exceeded the possible shrinking, go back one renderer ts*/ xtract -= ps->l_ts; @@ -1398,10 +1415,16 @@ static bool extend_frm( xtract[n] = s_start + ps->num_channels; if ( ps->evs_compat_mode == false ) { +#ifdef NONBE_FIX_1105_TSM_IN_SILENCE + xtract[n] -= ps->num_channels; + /* take renderer buffer samples into accout */ + xtract[n] += ( ps->l_r_buf % ps->l_ts ); +#else /* take renderer buffer samples into accout */ xtract[n] += ps->l_r_buf; /* snap to next renderer time slot border to resynchronize */ xtract[n] -= ( ( N - 1 ) * l_seg - xtract[n] + ps->l_r_buf ) % ps->l_ts; +#endif } } else