Commit 9614da83 authored by bayers's avatar bayers
Browse files

fix for #1105, fix snapping to renderer time resolution borders in the time...

fix for #1105, fix snapping to renderer time resolution borders in the time scale modification in silence portions
parent 1b499ada
Loading
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -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 ) );
@@ -2589,6 +2593,19 @@ static ivas_error decodeG192(
                        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 ) );
                        goto cleanup;
                    }
                }
#endif
#endif
#endif
                if ( ( error = BS_Reader_ReadFrame_short( hBsReader, bit_stream, &num_bits, &bfi ) ) != IVAS_ERR_OK )
+1 −0
Original line number Diff line number Diff line
@@ -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 ######################### */
+24 −1
Original line number Diff line number Diff line
@@ -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