Commit 52aeec04 authored by sagnowski's avatar sagnowski
Browse files

CLDFB ring buffer: replace CLDFB_RB_GetNthLastPushed with CLDFB_RB_GetByIdx

parent aba18db5
Loading
Loading
Loading
Loading
+15 −20
Original line number Diff line number Diff line
@@ -134,7 +134,11 @@ void CLDFB_RB_Push( CLDFB_RING_BUFFER_HANDLE h, const float* real, const float*

void CLDFB_RB_Pop( CLDFB_RING_BUFFER_HANDLE h, float* real, float* imag, uint16_t num_bands )
{
    CLDFB_RB_Front( h, real, imag, num_bands );
    assert( num_bands <= CLDFB_NO_CHANNELS_MAX );
    assert( !CLDFB_RB_IsEmpty( h ) );

    mvr2r( &h->real[h->read_pos], real, (int16_t) num_bands );
    mvr2r( &h->imag[h->read_pos], imag, (int16_t) num_bands );

    h->read_pos += CLDFB_NO_CHANNELS_MAX;
    if ( h->read_pos == h->capacity )
@@ -146,15 +150,6 @@ void CLDFB_RB_Pop( CLDFB_RING_BUFFER_HANDLE h, float* real, float* imag, uint16_
    {
        h->is_full = 0;
    }
}

void CLDFB_RB_Front( CLDFB_RING_BUFFER_HANDLE h, float* real, float* imag, uint16_t num_bands )
{
    assert( num_bands <= CLDFB_NO_CHANNELS_MAX );
    assert( !CLDFB_RB_IsEmpty( h ) );

    mvr2r( &h->real[h->read_pos], real, (int16_t) num_bands );
    mvr2r( &h->imag[h->read_pos], imag, (int16_t) num_bands );

    return;
}
@@ -181,31 +176,31 @@ static uint32_t rb_num_floats( CLDFB_RING_BUFFER_HANDLE h )
    return ret;
}

int16_t CLDFB_RB_GetNthLastPushed( CLDFB_RING_BUFFER_HANDLE h, float** p_real, float** p_imag, uint16_t n )
int16_t CLDFB_RB_GetByIdx( CLDFB_RING_BUFFER_HANDLE h, float** p_real, float** p_imag, int16_t col_idx )
{
    int32_t idx = col_idx * CLDFB_NO_CHANNELS_MAX;
    int32_t num_floats = (int32_t) rb_num_floats(h);
    uint32_t offset;
    offset = ( n + 1 ) * CLDFB_NO_CHANNELS_MAX;

    /* Trying to access column that was already popped, error */
    if ( rb_num_floats( h ) < offset )
    if ( idx < -num_floats || num_floats <= idx )
    {
        *p_real = NULL;
        *p_imag = NULL;
        return -1;
    }

    if ( offset <= h->write_pos )
    if ( idx >= 0 )
    {
        *p_real = &h->real[h->write_pos - offset];
        *p_imag = &h->imag[h->write_pos - offset];
        offset = ( h->read_pos + idx ) % h->capacity;
    }
    else
    {
        /* wrap around */
        *p_real = &h->real[h->write_pos + h->capacity - offset];
        *p_imag = &h->imag[h->write_pos + h->capacity - offset];
        offset = ( h->write_pos + h->capacity + idx ) % h->capacity;
    }

    *p_real = &h->real[offset];
    *p_imag = &h->imag[offset];

    return 0;
}

+1 −7
Original line number Diff line number Diff line
@@ -48,13 +48,7 @@ void CLDFB_RB_Push( CLDFB_RING_BUFFER_HANDLE h, const float* real, const float*

void CLDFB_RB_Pop( CLDFB_RING_BUFFER_HANDLE h, float* real, float* imag, uint16_t num_bands );

void CLDFB_RB_Front( CLDFB_RING_BUFFER_HANDLE h, float* real, float* imag, uint16_t num_bands );

/**
 * Get pointers into the last nth pushed CLDFB column.
 * TODO: describe n more precisely
 */
int16_t CLDFB_RB_GetNthLastPushed( CLDFB_RING_BUFFER_HANDLE h, float** p_real, float** p_imag, uint16_t n );
int16_t CLDFB_RB_GetByIdx( CLDFB_RING_BUFFER_HANDLE h, float** p_real, float** p_imag, int16_t idx );

int16_t CLDFB_RB_IsEmpty( CLDFB_RING_BUFFER_HANDLE h );

+1 −2
Original line number Diff line number Diff line
@@ -800,8 +800,7 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm(

                /* note: this intentionally differs from OSBA by: no scaling by 0.5 */
#ifdef FIX_1119_SPLIT_RENDERING_VOIP
                // TODO 1119: Double-check indexing here
                CLDFB_RB_GetNthLastPushed( st_ivas->hSplitBinRend->hMultiBinCldfbData[n], &re, &im, cldfb_slots - slot_idx - 1 );
                CLDFB_RB_GetByIdx( st_ivas->hSplitBinRend->hMultiBinCldfbData[n], &re, &im, slot_idx - cldfb_slots  );
                v_add( re, Cldfb_RealBuffer, re, num_cldfb_bands );
                v_add( im, Cldfb_ImagBuffer, im, num_cldfb_bands );
#else
+1 −2
Original line number Diff line number Diff line
@@ -185,8 +185,7 @@ ivas_error ivas_osba_dirac_td_binaural_jbm(
                cldfbAnalysis_ts( &( output_f[n][num_cldfb_bands * slot_idx] ), Cldfb_RealBuffer, Cldfb_ImagBuffer, num_cldfb_bands, st_ivas->hSplitBinRend->splitrend.hCldfbHandles->cldfbAna[n] );

#ifdef FIX_1119_SPLIT_RENDERING_VOIP
                // TODO 1119: Double-check indexing here
                CLDFB_RB_GetNthLastPushed( st_ivas->hSplitBinRend->hMultiBinCldfbData[n], &re, &im, cldfb_slots - slot_idx - 1 );
                CLDFB_RB_GetByIdx( st_ivas->hSplitBinRend->hMultiBinCldfbData[n], &re, &im, slot_idx - cldfb_slots );

                for ( b = 0; b < num_cldfb_bands; b++ )
                {