Commit 11c2a236 authored by Vladimir Malenovsky's avatar Vladimir Malenovsky
Browse files

zero-initialize unused CLDFB ring buffer pointers

parent 74cbfffd
Loading
Loading
Loading
Loading
Loading
+16 −14
Original line number Diff line number Diff line
@@ -2143,6 +2143,22 @@ static ivas_error isar_generate_metadata_and_bitstream(
                 * This requirement is fulfilled in this case. */
                ivas_CLDFB_RINGBUF_Pop( hSplitBinRend->hMultiBinCldfbData[i], NULL, NULL, CLDFB_NO_CHANNELS_MAX );
            }

#ifdef FIX_1342_PROPER_FLUSH_IN_SR
            /* For partial flush the ring buffer has fewer slots than the nominal CLDFB_NO_COL_MAX.
             * Point the remaining slot pointers to a static zero column so that the LCLD encoder
             * (which always iterates over its iNumBlocks blocks) reads deterministic
             * zeros instead of garbage stack pointers, preventing a SIGSEGV. */
            if ( num_cldfb_slots < CLDFB_NO_COL_MAX )
            {
                static float zero_cldfb_col[CLDFB_NO_CHANNELS_MAX]; /* zero-initialised (static storage) */
                for ( j = num_cldfb_slots; j < CLDFB_NO_COL_MAX; ++j )
                {
                    p_Cldfb_RealBuffer_Binaural[i][j] = zero_cldfb_col;
                    p_Cldfb_ImagBuffer_Binaural[i][j] = zero_cldfb_col;
                }
            }
#endif
        }
    }
    else
@@ -2286,7 +2302,6 @@ ivas_error IVAS_DEC_FlushSplitBinaural(
    ivas_error error;
    float head_pose_buf[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES][L_FRAME48k];
    float *p_head_pose_buf[BINAURAL_CHANNELS * MAX_HEAD_ROT_POSES];
    uint8_t localSplitRendBitsBuf[ISAR_MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES];
    bool needNewFrame;
    int16_t i;

@@ -2329,19 +2344,6 @@ ivas_error IVAS_DEC_FlushSplitBinaural(
        return IVAS_ERR_OK;
    }

    /* Split-coded flush path currently assumes a full frame of ISAR metadata generation.
       In case of a shorter trailing frame (ee.g. in VoIP flush), this can break the
       LCLD encoder assumptions and lead to a crash. Therefore, we skip
       such cases. */
    if ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM &&
         *nSamplesFlushed < isar_get_frame_size( st_ivas ) )
    {
        *nSamplesFlushed = 0;
        splitRendBits->bits_read = 0;
        splitRendBits->bits_written = 0;
        return IVAS_ERR_OK;
    }

    if ( ( error = isar_generate_metadata_and_bitstream( st_ivas, p_head_pose_buf, *nSamplesFlushed, splitRendBits ) ) != IVAS_ERR_OK )
    {
        return error;