Loading lib_dec/cldfb_ring_buffer.c +9 −22 Original line number Diff line number Diff line Loading @@ -161,10 +161,9 @@ void CLDFB_RINGBUF_Pop( CLDFB_RINGBUF_HANDLE h, float *real, float *imag, uint16 return; } static uint32_t rb_num_floats( CLDFB_RINGBUF_HANDLE h ) /* Returns total number of buffered samples (including number of channels) */ static uint32_t total_size( CLDFB_RINGBUF_HANDLE h ) { uint32_t ret; if ( CLDFB_RINGBUF_IsFull( h ) ) { return h->capacity; Loading @@ -172,29 +171,19 @@ static uint32_t rb_num_floats( CLDFB_RINGBUF_HANDLE h ) if ( h->read_pos <= h->write_pos ) { ret = h->write_pos - h->read_pos; } else { /* wrap around */ ret = h->write_pos + h->capacity - h->read_pos; return h->write_pos - h->read_pos; } return ret; /* else wrap around */ return h->write_pos + h->capacity - h->read_pos; } int16_t CLDFB_RINGBUF_GetByIdx( CLDFB_RINGBUF_HANDLE h, float **p_real, float **p_imag, int16_t col_idx ) void CLDFB_RINGBUF_GetByIdx( CLDFB_RINGBUF_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 ); int32_t num_floats = (int32_t) total_size( h ); uint32_t offset; if ( idx < -num_floats || num_floats <= idx ) { *p_real = NULL; *p_imag = NULL; return -1; } assert( -num_floats <= idx && idx <= num_floats ); if ( idx >= 0 ) { Loading @@ -207,8 +196,6 @@ int16_t CLDFB_RINGBUF_GetByIdx( CLDFB_RINGBUF_HANDLE h, float **p_real, float ** *p_real = &h->real[offset]; *p_imag = &h->imag[offset]; return 0; } int16_t CLDFB_RINGBUF_IsEmpty( CLDFB_RINGBUF_HANDLE h ) Loading @@ -223,7 +210,7 @@ int16_t CLDFB_RINGBUF_IsFull( CLDFB_RINGBUF_HANDLE h ) uint16_t CLDFB_RINGBUF_Size( CLDFB_RINGBUF_HANDLE h ) { return (uint16_t) ( rb_num_floats( h ) / CLDFB_NO_CHANNELS_MAX ); return (uint16_t) ( total_size( h ) / CLDFB_NO_CHANNELS_MAX ); } #endif lib_dec/cldfb_ring_buffer.h +9 −11 Original line number Diff line number Diff line Loading @@ -80,10 +80,8 @@ void CLDFB_RINGBUF_Pop( CLDFB_RINGBUF_HANDLE h, float *real, float *imag, uint16 * * - index 0 accesses the front of the buffer, i.e. the oldest CLDFB column in the queue. * - index -1 accesses the back of the buffer, i.e. the newest (last pushed) CLDFB column in the queue. * * Returns -1 if given an invalid index (p_real and p_imag will be set to NULL in that case), or 0 otherwise. *---------------------------------------------------------------------*/ int16_t CLDFB_RINGBUF_GetByIdx( CLDFB_RINGBUF_HANDLE h, float **p_real, float **p_imag, int16_t idx ); void CLDFB_RINGBUF_GetByIdx( CLDFB_RINGBUF_HANDLE h, float **p_real, float **p_imag, int16_t idx ); /*---------------------------------------------------------------------* * CLDFB_RINGBUF_IsEmpty() Loading Loading
lib_dec/cldfb_ring_buffer.c +9 −22 Original line number Diff line number Diff line Loading @@ -161,10 +161,9 @@ void CLDFB_RINGBUF_Pop( CLDFB_RINGBUF_HANDLE h, float *real, float *imag, uint16 return; } static uint32_t rb_num_floats( CLDFB_RINGBUF_HANDLE h ) /* Returns total number of buffered samples (including number of channels) */ static uint32_t total_size( CLDFB_RINGBUF_HANDLE h ) { uint32_t ret; if ( CLDFB_RINGBUF_IsFull( h ) ) { return h->capacity; Loading @@ -172,29 +171,19 @@ static uint32_t rb_num_floats( CLDFB_RINGBUF_HANDLE h ) if ( h->read_pos <= h->write_pos ) { ret = h->write_pos - h->read_pos; } else { /* wrap around */ ret = h->write_pos + h->capacity - h->read_pos; return h->write_pos - h->read_pos; } return ret; /* else wrap around */ return h->write_pos + h->capacity - h->read_pos; } int16_t CLDFB_RINGBUF_GetByIdx( CLDFB_RINGBUF_HANDLE h, float **p_real, float **p_imag, int16_t col_idx ) void CLDFB_RINGBUF_GetByIdx( CLDFB_RINGBUF_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 ); int32_t num_floats = (int32_t) total_size( h ); uint32_t offset; if ( idx < -num_floats || num_floats <= idx ) { *p_real = NULL; *p_imag = NULL; return -1; } assert( -num_floats <= idx && idx <= num_floats ); if ( idx >= 0 ) { Loading @@ -207,8 +196,6 @@ int16_t CLDFB_RINGBUF_GetByIdx( CLDFB_RINGBUF_HANDLE h, float **p_real, float ** *p_real = &h->real[offset]; *p_imag = &h->imag[offset]; return 0; } int16_t CLDFB_RINGBUF_IsEmpty( CLDFB_RINGBUF_HANDLE h ) Loading @@ -223,7 +210,7 @@ int16_t CLDFB_RINGBUF_IsFull( CLDFB_RINGBUF_HANDLE h ) uint16_t CLDFB_RINGBUF_Size( CLDFB_RINGBUF_HANDLE h ) { return (uint16_t) ( rb_num_floats( h ) / CLDFB_NO_CHANNELS_MAX ); return (uint16_t) ( total_size( h ) / CLDFB_NO_CHANNELS_MAX ); } #endif
lib_dec/cldfb_ring_buffer.h +9 −11 Original line number Diff line number Diff line Loading @@ -80,10 +80,8 @@ void CLDFB_RINGBUF_Pop( CLDFB_RINGBUF_HANDLE h, float *real, float *imag, uint16 * * - index 0 accesses the front of the buffer, i.e. the oldest CLDFB column in the queue. * - index -1 accesses the back of the buffer, i.e. the newest (last pushed) CLDFB column in the queue. * * Returns -1 if given an invalid index (p_real and p_imag will be set to NULL in that case), or 0 otherwise. *---------------------------------------------------------------------*/ int16_t CLDFB_RINGBUF_GetByIdx( CLDFB_RINGBUF_HANDLE h, float **p_real, float **p_imag, int16_t idx ); void CLDFB_RINGBUF_GetByIdx( CLDFB_RINGBUF_HANDLE h, float **p_real, float **p_imag, int16_t idx ); /*---------------------------------------------------------------------* * CLDFB_RINGBUF_IsEmpty() Loading