Commit 39102f53 authored by Vladimir Malenovsky's avatar Vladimir Malenovsky
Browse files

fix crash in LC3+ high-res mode

parent acb442b0
Loading
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -4352,8 +4352,11 @@ ivas_error IVAS_DEC_Flush(
            float head_pose_buf[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES][L_FRAME48k];
            float *p_head_pose_buf[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES];

            /* Zero-initialise so that ivas_limiter_dec never reads uninitialised memory
               (e.g. when the ring buffer provides fewer samples than the nominal frame size) */
            for ( i = 0; i < BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES; ++i )
            {
                set_zero( head_pose_buf[i], L_FRAME48k );
                p_head_pose_buf[i] = head_pose_buf[i];
            }

+27 −0
Original line number Diff line number Diff line
@@ -1396,6 +1396,12 @@ static void isar_SplitRenderer_GetRotMd(
    for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ )
    {
        start_slot_idx = sf_idx * num_slots;
#ifdef FIX_1342_PROPER_FLUSH_IN_SR
        if ( start_slot_idx >= num_cldfb_slots )
        {
            break;
        }
#endif
        for ( b = 0; b < num_md_bands; b++ )
        {
            if ( ( b < SPLIT_REND_RO_MD_BAND_THRESH ) || ( !ro_md_flag && b < COMPLEX_MD_BAND_THRESH ) )
@@ -1945,7 +1951,21 @@ ivas_error isar_renderMultiTDBinToSplitBinaural(
            /* Artificially delay input to head pose correction analysis by LC3plus coding delay, so that audio and metadata are in sync after decoding */
            mvr2r( hSplitBin->lc3plusDelayBuffers[i] + frame_size, hSplitBin->lc3plusDelayBuffers[i], (int16_t) hSplitBin->lc3plusDelaySamples );
            in_delayed[i] = hSplitBin->lc3plusDelayBuffers[i];
#ifdef FIX_1342_PROPER_FLUSH_IN_SR
            {
                /* During flush the actual number of new samples may be less than the nominal frame size.
                 * Only copy the available samples and zero-fill the rest to avoid reading uninitialised memory. */
                int16_t actual_samples_lc3 = (int16_t) ( (int32_t) hSplitBin->hLc3plusEnc->config.samplerate * isar_frame_size_ms / 1000 );
                mvr2r( in[i], hSplitBin->lc3plusDelayBuffers[i] + hSplitBin->lc3plusDelaySamples, actual_samples_lc3 );
                if ( actual_samples_lc3 < frame_size )
                {
                    set_zero( hSplitBin->lc3plusDelayBuffers[i] + hSplitBin->lc3plusDelaySamples + actual_samples_lc3,
                              frame_size - actual_samples_lc3 );
                }
            }
#else
            mvr2r( in[i], hSplitBin->lc3plusDelayBuffers[i] + hSplitBin->lc3plusDelaySamples, frame_size );
#endif
        }
    }
    else
@@ -1958,7 +1978,14 @@ ivas_error isar_renderMultiTDBinToSplitBinaural(

    if ( ( hSplitBin->multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) || ( !useLc3plus && !pcm_out_flag ) )
    {
#ifdef FIX_1342_PROPER_FLUSH_IN_SR
        /* During flush, use only the actual number of valid CLDFB slots derived from isar_frame_size_ms */
        num_slots = ( hSplitBin->multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB )
                        ? (int32_t) ( (int32_t) isar_frame_size_ms * 1000000L / CLDFB_SLOT_NS )
                        : ( hSplitBin->hSplitBinLCLDEnc->iNumBlocks * hSplitBin->hSplitBinLCLDEnc->iNumIterations );
#else
        num_slots = ( hSplitBin->multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ? CLDFB_NO_COL_MAX : ( hSplitBin->hSplitBinLCLDEnc->iNumBlocks * hSplitBin->hSplitBinLCLDEnc->iNumIterations );
#endif
        num_cldfb_bands = hSplitBin->hCldfbHandles->cldfbAna[0]->no_channels;

        /* CLDFB Analysis*/