Commit e0d2ebe1 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Fix for 3GPP issue 1458: Crash with new testcase in pytest suite - ISM with...

Fix for 3GPP issue 1458: Crash with new testcase in pytest suite - ISM with DTX, bitrate switching + JBM to BINAURAL_ROOM_IR

Link #1458
parent 8d9f712d
Loading
Loading
Loading
Loading
Loading
+29 −2
Original line number Diff line number Diff line
@@ -2550,7 +2550,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx(
    DECODER_TC_BUFFER_HANDLE hTcBuffer;
    Word32 output_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES];
    Word32 *p_output_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS];
    Word16 nchan_in, nchan_out;
    Word16 nchan_in, nchan_out, gd_bits, n_chan_inp, i, shift;
    IF( !st_ivas->hDecoderConfig->Opt_tsm )
    {
        return IVAS_ERR_OK;
@@ -2637,17 +2637,44 @@ ivas_error ivas_jbm_dec_flush_renderer_fx(
                    /* Convert to CICPxx; used also for ISM->CICP19->binaural_room rendering */
                    set16_fx( st_ivas->hIsmRendererData->interpolator_fx, 32767, hTcBuffer->n_samples_granularity ); // 32767=1.0f in Q15

                    ivas_ism_render_sf_fx( st_ivas, p_output_fx, *nSamplesRendered );
                    ivas_ism_render_sf_fx( st_ivas, p_output_fx, hTcBuffer->n_samples_granularity );

                    st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor;
                    *st_ivas->hCrendWrapper->p_io_qfactor = 11;
                    move16();

                    shift = MAX_16;
                    move16();
                    n_chan_inp = add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe );

                    FOR( i = 0; i < n_chan_inp; i++ )
                    {
                        shift = s_min( shift, L_norm_arr( p_output_fx[i], hTcBuffer->n_samples_granularity ) );
                    }

                    gd_bits = sub( find_guarded_bits_fx( imult1616( hTcBuffer->subframe_nbslots[0], hTcBuffer->n_samples_granularity ) ), shift );

                    *st_ivas->hCrendWrapper->p_io_qfactor = sub( *st_ivas->hCrendWrapper->p_io_qfactor, gd_bits );
                    move16();

                    FOR( i = 0; i < n_chan_inp; i++ )
                    {
                        scale_sig32( p_output_fx[i], hTcBuffer->n_samples_granularity, sub( *st_ivas->hCrendWrapper->p_io_qfactor, Q11 ) ); // Q(*st_ivas->hCrendWrapper->p_io_qfactor)
                    }

                    IF( NE_32( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL,
                                                                         NULL, NULL, st_ivas->hTcBuffer, p_output_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ),
                               IVAS_ERR_OK ) )
                    {
                        return error;
                    }

                    FOR( i = 0; i < n_chan_inp; i++ )
                    {
                        scale_sig32( p_output_fx[i], hTcBuffer->n_samples_granularity, sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ); // Q(11)
                    }
                    *st_ivas->hCrendWrapper->p_io_qfactor = Q11;
                    move16();
                }
            }
            ELSE