Commit 49bfaa83 authored by sagnowski's avatar sagnowski
Browse files

Save memory by using values directly from the CLDFB ring buffer

parent 52aeec04
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -137,8 +137,14 @@ void CLDFB_RB_Pop( CLDFB_RING_BUFFER_HANDLE h, float* real, float* imag, uint16_
    assert( num_bands <= CLDFB_NO_CHANNELS_MAX );
    assert( !CLDFB_RB_IsEmpty( h ) );

    if ( real != NULL )
    {
        mvr2r( &h->real[h->read_pos], real, (int16_t) num_bands );
    }
    if ( imag != NULL )
    {
        mvr2r( &h->imag[h->read_pos], imag, (int16_t) num_bands );
    }

    h->read_pos += CLDFB_NO_CHANNELS_MAX;
    if ( h->read_pos == h->capacity )
+16 −10
Original line number Diff line number Diff line
@@ -1945,9 +1945,6 @@ static ivas_error isar_generate_metadata_and_bitstream(
    int16_t ro_md_flag;
    IVAS_QUATERNION Quaternion;
    int16_t i, j, num_poses;
    // TODO 1119: If data could be read directly from the ring buffer, these large buffers could be removed
    float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
    float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
    float *p_Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX];
    float *p_Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX];

@@ -1969,15 +1966,24 @@ static ivas_error isar_generate_metadata_and_bitstream(
        {
            for ( j = 0; j < CLDFB_NO_COL_MAX; ++j )
            {
                /* Save pointers to first CLDFB column in the ring buffer. Allows us to save
                 * significant amounts of memory by not copying CLDFB values into a separate buffer. */
                CLDFB_RB_GetByIdx(
                    hSplitBinRend->hMultiBinCldfbData[i],
                    &p_Cldfb_RealBuffer_Binaural[i][j],
                    &p_Cldfb_ImagBuffer_Binaural[i][j],
                    0
                );
                /* Pop the CLDFB column we just saved pointers to. This is fine as long as we use 
                 * the saved columns only before any new columns are pushed to the buffer - the new
                 * columns could potentially overwrite the old columns we wanted to use.
                 * This requirement is fulfilled in this case. */
                CLDFB_RB_Pop(
                    hSplitBinRend->hMultiBinCldfbData[i], 
                        Cldfb_RealBuffer_Binaural[i][j],
                        Cldfb_ImagBuffer_Binaural[i][j],
                    NULL,
                    NULL,
                    CLDFB_NO_CHANNELS_MAX
                );

                p_Cldfb_RealBuffer_Binaural[i][j] = Cldfb_RealBuffer_Binaural[i][j];
                p_Cldfb_ImagBuffer_Binaural[i][j] = Cldfb_ImagBuffer_Binaural[i][j];
            }
        }
    }