Commit fd640229 authored by Jan Kiene's avatar Jan Kiene
Browse files

align ring buffer code with later MR

parent 2774cfd2
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1624,10 +1624,11 @@ void ivas_TD_RINGBUF_Pop(
    Word32 *data,                                                /* i  : Output data                             */
    const Word16 num_samples_per_channel                      /* i  : Number of samples per channel to retrieve*/
);
#endif

Word16 ivas_TD_RINGBUF_Size(
    const TD_RINGBUF_HANDLE h                                   /* i  : Ring buffer handle                      */
);

/* clang-format on */

#endif /* IVAS_PROT_REND_H */
+5 −5
Original line number Diff line number Diff line
@@ -1441,10 +1441,10 @@ typedef struct
typedef struct
{
    Word32 *data;    /* samples in interleaved layout, e.g. for channels A, B, C, samples are stored: A1, B1, C1, A2, B2, C2, ... */
    UWord32 capacity; /* max number of Word32 values that can be stored */
    UWord16 num_channels;
    UWord32 write_pos;
    UWord32 read_pos;
    Word32 capacity; /* max number of Word32 values that can be stored */
    Word16 num_channels;
    Word32 write_pos;
    Word32 read_pos;
    Word16 is_full;

} TD_RINGBUF_DATA, *TD_RINGBUF_HANDLE;
+7 −11
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ static Word16 ivas_td_ringbuf_has_space_for_num_samples(
    TD_RINGBUF_HANDLE h,
    const Word32 num_samples )
{
    if ( LE_32( L_add( ivas_td_ringbuf_total_size( h ), num_samples ), h->capacity ) )
    IF( LE_32( L_add( ivas_td_ringbuf_total_size( h ), num_samples ), h->capacity ) )
    {
        return 1;
    }
@@ -108,7 +108,6 @@ ivas_error ivas_TD_RINGBUF_Open(
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for TD ring buffer\n" );
    }
    h->data = NULL;
    move32();
    h->capacity = 0;
    move32();
    h->num_channels = num_channels;
@@ -120,10 +119,9 @@ ivas_error ivas_TD_RINGBUF_Open(
    h->is_full = 0;
    move16();
    *ph = h;
    move32();

    h->data = malloc( capacity * sizeof( Word32 ) );
    if ( h->data == NULL )
    IF( h->data == NULL )
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for TD ring buffer\n" );
    }
@@ -152,7 +150,6 @@ void ivas_TD_RINGBUF_Close(
        return;
    }
    h = *ph;
    move32();

    IF( h == NULL )
    {
@@ -166,7 +163,6 @@ void ivas_TD_RINGBUF_Close(

    free( h );
    *ph = NULL;
    move32();

    return;
}
@@ -196,7 +192,7 @@ void ivas_TD_RINGBUF_Push(
        {
            h->data[h->write_pos] = data[L_add( L_mult0( c, num_samples_per_channel ), s )];
            move32();
            ++h->write_pos;
            h->write_pos = L_add( h->write_pos, 1 );

            if ( EQ_32( h->write_pos, h->capacity ) )
            {
@@ -231,7 +227,7 @@ void ivas_TD_RINGBUF_PushZeros(
    Word16 c;

    assert( ivas_td_ringbuf_has_space_for_num_samples( h, num_samples_per_channel * h->num_channels ) );
    if ( !num_samples_per_channel )
    IF( !num_samples_per_channel )
    {
        return;
    }
@@ -242,9 +238,9 @@ void ivas_TD_RINGBUF_PushZeros(
        {
            h->data[h->write_pos] = 0;
            move32();
            ++h->write_pos;
            h->write_pos = L_add( h->write_pos, 1 );

            if ( EQ_32( h->write_pos, h->capacity ) )
            IF( EQ_32( h->write_pos, h->capacity ) )
            {
                h->write_pos = 0;
                move32();
@@ -295,7 +291,7 @@ void ivas_TD_RINGBUF_Pop(
        }
    }

    if ( h->is_full )
    IF( h->is_full )
    {
        h->is_full = 0;
        move16();