Skip to content

Crash in low level signal at 24.4 kbps with dtx enabled

with 315a2539, there is a crash with the following bit-stream:

ltv_STEREO_32k_d4_-stereo_-dtx_24400_32.zip

decoder command line : stereo 32 bit syn

the crash happens at frame 2214 in the function stereo_dft_generate_comfort_noise_fx() around line 1044. The shr() in the IF condition overflow. Using shr_sat solved the issue, but I would like someone that knows more about this part of the code to confirm that saturation can be expected there

            tmp_16 = BASOP_Util_Divide3232_Scale( E0, E1, &q_div );
            tmp_16 = Sqrt16( tmp_16, &q_div );
  ->>>>>    IF( LT_16( tmp_16, shr( MAX_16, q_div ) ) )
            {
                tmp_16 = shl( tmp_16, q_div );
                hStereoCng->xfade_length = sub( MAX_XFADE_FX, extract_l( L_shr( imult3216( MAX_XFADE_FX, tmp_16 ), Q15 ) ) );
                move16();
            }
            ELSE
            {
                Word16 q_inv;
                tmp_16 = Invert16( tmp_16, &q_inv );
                tmp_16 = shl( tmp_16, add( q_inv, q_div ) );
                hStereoCng->xfade_length = sub( MAX_XFADE_FX, extract_l( L_shr( imult3216( MAX_XFADE_FX, tmp_16 ), Q15 ) ) );
                move16();
            }

@kinuthia, @norvell