Commit c7a2a6aa authored by sagnowski's avatar sagnowski
Browse files

Remove use of unsigned integers from the CLDFB ring buffer

parent e3683ca5
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -350,9 +350,9 @@ typedef struct
{
    float *real;
    float *imag;
    uint32_t capacity;
    uint32_t write_pos;
    uint32_t read_pos;
    int32_t capacity;
    int32_t write_pos;
    int32_t read_pos;
    int16_t is_full;

} ISAR_CLDFB_RINGBUF, *ISAR_CLDFB_RINGBUF_HANDLE;
+10 −11
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ static int16_t ivas_cldfb_ringbuf_IsFull(
/*---------------------------------------------------------------------*
 * ivas_CLDFB_RINGBUF_Open()
 *
 * Allocate a ring buffer for CLDFB data with the given capacity of CLDFB columns.
 * Allocates a ring buffer for CLDFB data with the given capacity of CLDFB columns.
 * Each column is expected to contain at most CLDFB_NO_CHANNELS_MAX frequency bands.
 *
 * May return IVAS_ERR_FAILED_ALLOC on failed allocation, or IVAS_ERR_OK otherwise.
@@ -88,7 +88,7 @@ ivas_error ivas_CLDFB_RINGBUF_Open(
    ISAR_CLDFB_RINGBUF_HANDLE h;
    int32_t capacity;

    capacity = capacity_columns * CLDFB_NO_CHANNELS_MAX;
    capacity = (int32_t) capacity_columns * CLDFB_NO_CHANNELS_MAX;

    if ( ( h = malloc( sizeof( ISAR_CLDFB_RINGBUF ) ) ) == NULL )
    {
@@ -119,7 +119,7 @@ ivas_error ivas_CLDFB_RINGBUF_Open(
/*---------------------------------------------------------------------*
 * ivas_CLDFB_RINGBUF_Close()
 *
 * Dellocate CLDFB ring buffer. The given handle will be set to NULL.
 * Dellocates CLDFB ring buffer. The given handle will be set to NULL.
 *---------------------------------------------------------------------*/

void ivas_CLDFB_RINGBUF_Close(
@@ -190,7 +190,7 @@ void ivas_CLDFB_RINGBUF_Push(
/*---------------------------------------------------------------------*
 * ivas_CLDFB_RINGBUF_Pop()
 *
 * Pop a single column from the front of the CLDFB ring buffer into real and imag arrays.
 * Pops a single column from the front of the CLDFB ring buffer into real and imag arrays.
 *---------------------------------------------------------------------*/

void ivas_CLDFB_RINGBUF_Pop(
@@ -229,7 +229,7 @@ void ivas_CLDFB_RINGBUF_Pop(
 * Returns total number of buffered samples (including number of channels)
 *---------------------------------------------------------------------*/

static uint32_t ivas_cldfb_ringbuf_total_size(
static int32_t ivas_cldfb_ringbuf_total_size(
    ISAR_CLDFB_RINGBUF_HANDLE h )
{
    if ( ivas_cldfb_ringbuf_IsFull( h ) )
@@ -265,8 +265,8 @@ void ivas_CLDFB_RINGBUF_GetByIdx(
    const int16_t col_idx )
{
    int32_t idx = col_idx * CLDFB_NO_CHANNELS_MAX;
    int32_t num_floats = (int32_t) ivas_cldfb_ringbuf_total_size( h );
    uint32_t offset, uidx;
    int32_t num_floats = ivas_cldfb_ringbuf_total_size( h );
    int32_t offset;

    assert( -num_floats <= idx && idx <= num_floats );

@@ -280,14 +280,13 @@ void ivas_CLDFB_RINGBUF_GetByIdx(
    }
    else
    {
        uidx = (uint32_t) -idx;
        if ( uidx <= h->write_pos )
        if ( -idx <= h->write_pos )
        {
            offset = h->write_pos - uidx;
            offset = h->write_pos + idx;
        }
        else
        {
            offset = h->write_pos + h->capacity - uidx;
            offset = h->write_pos + h->capacity + idx;
        }
    }