Loading apps/renderer.c +4 −12 Original line number Diff line number Diff line Loading @@ -1376,16 +1376,14 @@ int main( if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { char *outFile = args.outMetadataFilePath; if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) { outFile = args.outputFilePath; audioWriter = NULL; } if ( ( error = IVAS_REND_GetSplitRendBitstreamHeader( hIvasRend, &bitsBuffer.config.codec, &bitsBuffer.config.poseCorrection, &bitsBuffer.config.codec_frame_size_ms, &bitsBuffer.config.isar_frame_size_ms ) ) != IVAS_ERR_OK ) if ( ( error = IVAS_REND_GetSplitRendBitstreamHeader( hIvasRend, &bitsBuffer.config.codec, &bitsBuffer.config.poseCorrection, &bitsBuffer.config.codec_frame_size_ms, &bitsBuffer.config.isar_frame_size_ms ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_REND_GetSplitRendBitstreamHeader()!\n" ); goto cleanup; Loading Loading @@ -1537,13 +1535,7 @@ int main( /* Convert from int to float and from interleaved to packed */ if ( !flushRendererLastFrame ) { convertInputBuffer( inpInt16Buffer, numSamplesRead, inBuffer.config.numSamplesPerChannel, num_in_channels, inFloatBuffer, inBuffer.config.is_cldfb, cldfbAna ); convertInputBuffer( inpInt16Buffer, numSamplesRead, inBuffer.config.numSamplesPerChannel, num_in_channels, inFloatBuffer, inBuffer.config.is_cldfb, cldfbAna ); } int16_t num_subframes, sf_idx; Loading lib_rend/ivas_prot_rend.h +13 −15 Original line number Diff line number Diff line Loading @@ -1586,44 +1586,42 @@ void ivas_rend_closeCldfbRend( * Time domain ring buffer prototypes *----------------------------------------------------------------------------------*/ typedef struct TdRingBuf *TD_RINGBUF_HANDLE; ivas_error IVAS_TD_RINGBUF_Open( ivas_error ivas_TD_RINGBUF_Open( TD_RINGBUF_HANDLE *ph, uint32_t capacity_per_channel, uint16_t num_channels const uint32_t capacity_per_channel, const uint16_t num_channels ); void IVAS_TD_RINGBUF_Close( void ivas_TD_RINGBUF_Close( TD_RINGBUF_HANDLE *ph ); void IVAS_TD_RINGBUF_Push( void ivas_TD_RINGBUF_Push( TD_RINGBUF_HANDLE h, const float *data, uint32_t num_samples_per_channel const uint32_t num_samples_per_channel ); void IVAS_TD_RINGBUF_PushZeros( void ivas_TD_RINGBUF_PushZeros( TD_RINGBUF_HANDLE h, uint32_t num_samples_per_channel const uint32_t num_samples_per_channel ); void IVAS_TD_RINGBUF_Pop( void ivas_TD_RINGBUF_Pop( TD_RINGBUF_HANDLE h, float *data, uint32_t num_samples_per_channel const uint32_t num_samples_per_channel ); int16_t IVAS_TD_RINGBUF_IsEmpty( int16_t ivas_TD_RINGBUF_IsEmpty( const TD_RINGBUF_HANDLE h ); uint32_t IVAS_TD_RINGBUF_Size( uint32_t ivas_TD_RINGBUF_Size( const TD_RINGBUF_HANDLE h ); void IVAS_TD_RINGBUF_Clear( void ivas_TD_RINGBUF_Clear( TD_RINGBUF_HANDLE h ); Loading lib_rend/ivas_stat_rend.h +16 −0 Original line number Diff line number Diff line Loading @@ -1371,6 +1371,22 @@ typedef struct } CLDFB_REND_WRAPPER; /*----------------------------------------------------------------------------------* * Time domain ring buffer structure *----------------------------------------------------------------------------------*/ typedef struct { float *data; /* samples in interleaved layout */ uint32_t capacity; uint16_t num_channels; uint32_t write_pos; uint32_t read_pos; int16_t is_full; } TD_RINGBUF_DATA, *TD_RINGBUF_HANDLE; /*----------------------------------------------------------------------------------* * MASA external renderer structure *----------------------------------------------------------------------------------*/ Loading lib_rend/ivas_td_ring_buffer.c +42 −28 Original line number Diff line number Diff line Loading @@ -37,21 +37,13 @@ #include "options.h" #include "wmc_auto.h" struct TdRingBuf { float *data; /* samples in interleaved layout */ uint32_t capacity; uint16_t num_channels; uint32_t write_pos; uint32_t read_pos; int16_t is_full; }; /*-----------------------------------------------------------------------* * Local function prototypes *-----------------------------------------------------------------------*/ static uint32_t ivas_td_ringbuf_total_size( TD_RINGBUF_HANDLE h ) static uint32_t ivas_td_ringbuf_total_size( TD_RINGBUF_HANDLE h ) { if ( h->is_full ) { Loading @@ -66,23 +58,28 @@ static uint32_t ivas_td_ringbuf_total_size( TD_RINGBUF_HANDLE h ) return h->write_pos + h->capacity - h->read_pos; } static int16_t ivas_td_ringbuf_has_space_for_num_samples( TD_RINGBUF_HANDLE h, const uint32_t num_samples ) static int16_t ivas_td_ringbuf_has_space_for_num_samples( TD_RINGBUF_HANDLE h, const uint32_t num_samples ) { return (int16_t) ( ivas_td_ringbuf_total_size( h ) + num_samples <= h->capacity ); } /*-----------------------------------------------------------------------* * Global function definitions *-----------------------------------------------------------------------*/ /*---------------------------------------------------------------------* * TD_RINGBUF_Open() * ivas_TD_RINGBUF_Open() * * Allocate a ring buffer for TD data with the given capacity of TD samples per channel. * * May return IVAS_ERR_FAILED_ALLOC on failed allocation, or IVAS_ERR_OK otherwise. *---------------------------------------------------------------------*/ ivas_error IVAS_TD_RINGBUF_Open( ivas_error ivas_TD_RINGBUF_Open( TD_RINGBUF_HANDLE *ph, /* i/o: Ring buffer handle */ const uint32_t capacity_per_channel, /* i : Number of samples stored per channel */ const uint16_t num_channels /* i : Number of channels */ Loading @@ -90,9 +87,10 @@ ivas_error IVAS_TD_RINGBUF_Open( { TD_RINGBUF_HANDLE h; uint32_t capacity; capacity = capacity_per_channel * num_channels; h = malloc( sizeof( struct TdRingBuf ) ); h = malloc( sizeof( TD_RINGBUF_DATA ) ); if ( h == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for TD ring buffer\n" ); Loading @@ -115,12 +113,15 @@ ivas_error IVAS_TD_RINGBUF_Open( return IVAS_ERR_OK; } /*---------------------------------------------------------------------* * TD_RINGBUF_Close() * ivas_TD_RINGBUF_Close() * * Dellocate TD ring buffer. The given handle will be set to NULL. *---------------------------------------------------------------------*/ void IVAS_TD_RINGBUF_Close( void ivas_TD_RINGBUF_Close( TD_RINGBUF_HANDLE *ph /* i/o: Ring buffer handle */ ) { Loading Loading @@ -148,13 +149,15 @@ void IVAS_TD_RINGBUF_Close( return; } /*---------------------------------------------------------------------* * TD_RINGBUF_Push() * ivas_TD_RINGBUF_Push() * * Push samples onto the back of the TD ring buffer. * Returns total number of buffered samples (includes number of channels) *---------------------------------------------------------------------*/ void IVAS_TD_RINGBUF_Push( void ivas_TD_RINGBUF_Push( TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ const float *data, /* i : Input data */ const uint32_t num_samples_per_channel /* i : Number of samples per channel to store */ Loading Loading @@ -187,12 +190,14 @@ void IVAS_TD_RINGBUF_Push( return; } /*---------------------------------------------------------------------* * TD_RINGBUF_PushZeros() * ivas_TD_RINGBUF_PushZeros() * * Push zero samples onto the back of the TD ring buffer. *---------------------------------------------------------------------*/ void IVAS_TD_RINGBUF_PushZeros( void ivas_TD_RINGBUF_PushZeros( TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ const uint32_t num_samples_per_channel /* i : Number of zeros per channel to store */ ) Loading Loading @@ -228,12 +233,14 @@ void IVAS_TD_RINGBUF_PushZeros( return; } /*---------------------------------------------------------------------* * TD_RINGBUF_Pop() * ivas_TD_RINGBUF_Pop() * * Pop samples from the front of the TD ring buffer. *---------------------------------------------------------------------*/ void IVAS_TD_RINGBUF_Pop( void ivas_TD_RINGBUF_Pop( TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ float *data, /* i : Output data */ const uint32_t num_samples_per_channel /* i : Number of samples per channel to retrieve */ Loading Loading @@ -266,40 +273,47 @@ void IVAS_TD_RINGBUF_Pop( return; } /*---------------------------------------------------------------------* * TD_RINGBUF_IsEmpty() * ivas_TD_RINGBUF_IsEmpty() * * Returns 1 if the ring buffer is empty, or 0 otherwise. *---------------------------------------------------------------------*/ int16_t IVAS_TD_RINGBUF_IsEmpty( int16_t ivas_TD_RINGBUF_IsEmpty( const TD_RINGBUF_HANDLE h /* i : Ring buffer handle */ ) { return (int16_t) ( h->read_pos == h->write_pos && !h->is_full ); } /*---------------------------------------------------------------------* * TD_RINGBUF_Size() * ivas_TD_RINGBUF_Size() * * Returns number of buffered samples per channel. *---------------------------------------------------------------------*/ uint32_t IVAS_TD_RINGBUF_Size( uint32_t ivas_TD_RINGBUF_Size( const TD_RINGBUF_HANDLE h /* i : Ring buffer handle */ ) { return ivas_td_ringbuf_total_size( h ) / (uint32_t) h->num_channels; } /*---------------------------------------------------------------------* * TD_RINGBUF_Clear() * ivas_TD_RINGBUF_Clear() * * Remove all samples from the buffer. *---------------------------------------------------------------------*/ void IVAS_TD_RINGBUF_Clear( void ivas_TD_RINGBUF_Clear( TD_RINGBUF_HANDLE h /* i : Ring buffer handle */ ) { h->read_pos = h->write_pos; h->is_full = 0; return; } lib_rend/lib_rend.c +13 −18 Original line number Diff line number Diff line Loading @@ -1348,9 +1348,7 @@ static ivas_error alignInputDelay( /* buffer has to accomodate maxGlobalDelaySamples + 2 * frameSize */ tmpSize = maxGlobalDelaySamples; tmpSize += 2 * inputAudio.config.numSamplesPerChannel; if ( ( error = IVAS_TD_RINGBUF_Open( &inputBase->delayBuffer, tmpSize, inputAudio.config.numChannels ) ) != IVAS_ERR_OK ) if ( ( error = ivas_TD_RINGBUF_Open( &inputBase->delayBuffer, tmpSize, inputAudio.config.numChannels ) ) != IVAS_ERR_OK ) { return error; } Loading @@ -1358,8 +1356,7 @@ static ivas_error alignInputDelay( /* for the first frame we need to push zeros to align the input delay to the global delay * and then push a frame of actual data */ tmpSize = maxGlobalDelaySamples - inputBase->delayNumSamples * cldfb2tdSampleFact; IVAS_TD_RINGBUF_PushZeros( inputBase->delayBuffer, tmpSize ); ivas_TD_RINGBUF_PushZeros( inputBase->delayBuffer, tmpSize ); /* for ISM inputs, ensure the metadata sync delay is updated */ if ( getAudioConfigType( inputBase->inConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED ) Loading @@ -1370,12 +1367,8 @@ static ivas_error alignInputDelay( } /* push in the new input data and pop to retrieve a complete input frame */ IVAS_TD_RINGBUF_Push( inputBase->delayBuffer, inputAudio.data, inputAudio.config.numSamplesPerChannel ); IVAS_TD_RINGBUF_Pop( inputBase->delayBuffer, inputBase->inputBuffer.data, flushInputs ? IVAS_TD_RINGBUF_Size( inputBase->delayBuffer ) : (uint32_t) inputAudio.config.numSamplesPerChannel ); ivas_TD_RINGBUF_Push( inputBase->delayBuffer, inputAudio.data, inputAudio.config.numSamplesPerChannel ); ivas_TD_RINGBUF_Pop( inputBase->delayBuffer, inputBase->inputBuffer.data, flushInputs ? ivas_TD_RINGBUF_Size( inputBase->delayBuffer ) : (uint32_t) inputAudio.config.numSamplesPerChannel ); return IVAS_ERR_OK; } Loading Loading @@ -1543,7 +1536,7 @@ static void clearInputIsm( rendCtx = inputIsm->base.ctx; freeInputBaseBufferData( &inputIsm->base.inputBuffer.data ); IVAS_TD_RINGBUF_Close( &inputIsm->base.delayBuffer ); ivas_TD_RINGBUF_Close( &inputIsm->base.delayBuffer ); initRendInputBase( &inputIsm->base, IVAS_AUDIO_CONFIG_INVALID, 0, rendCtx, NULL, 0 ); Loading Loading @@ -2542,7 +2535,7 @@ static void clearInputMc( freeMcLfeDelayBuffer( &inputMc->lfeDelayBuffer ); freeInputBaseBufferData( &inputMc->bufferData ); IVAS_TD_RINGBUF_Close( &inputMc->base.delayBuffer ); ivas_TD_RINGBUF_Close( &inputMc->base.delayBuffer ); initRendInputBase( &inputMc->base, IVAS_AUDIO_CONFIG_INVALID, 0, rendCtx, NULL, 0 ); Loading Loading @@ -2874,7 +2867,7 @@ static void clearInputSba( rendCtx = inputSba->base.ctx; freeInputBaseBufferData( &inputSba->bufferData ); IVAS_TD_RINGBUF_Close( &inputSba->base.delayBuffer ); ivas_TD_RINGBUF_Close( &inputSba->base.delayBuffer ); initRendInputBase( &inputSba->base, IVAS_AUDIO_CONFIG_INVALID, 0, rendCtx, NULL, 0 ); Loading Loading @@ -2973,7 +2966,7 @@ static void clearInputMasa( rendCtx = inputMasa->base.ctx; freeInputBaseBufferData( &inputMasa->bufferData ); IVAS_TD_RINGBUF_Close( &inputMasa->base.delayBuffer ); ivas_TD_RINGBUF_Close( &inputMasa->base.delayBuffer ); masaPrerendClose( &inputMasa->hMasaPrerend ); freeMasaExtRenderer( &inputMasa->hMasaExtRend ); Loading Loading @@ -3661,7 +3654,6 @@ static ivas_error isar_pre_rend_init( } } /* We may need to change the allocated buffer size if a new input is added. * If the cldfb_in_flag is different from what was previously allocated for the buffer, change the size */ if ( pSplitRendEncBuffer->data != NULL && ( cldfb_in_flag != pSplitRendEncBuffer->config.is_cldfb ) ) Loading Loading @@ -3789,7 +3781,6 @@ ivas_error IVAS_REND_AddInput( /* update global maximum delay after adding an input */ updateMaxGlobalDelayNs( hIvasRend ); return IVAS_ERR_OK; } Loading Loading @@ -4522,6 +4513,7 @@ ivas_error IVAS_REND_FeedRenderConfig( if ( pMasaInput->hMasaExtRend->hDiracDecBin[0] != NULL && pMasaInput->hMasaExtRend->hDiracDecBin[0]->hReverb != NULL ) { ivas_binaural_reverb_close( &pMasaInput->hMasaExtRend->hDiracDecBin[0]->hReverb ); if ( ( error = ivas_binaural_reverb_init( &pMasaInput->hMasaExtRend->hDiracDecBin[0]->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, pMasaInput->hMasaExtRend->hSpatParamRendCom->num_freq_bands, Loading @@ -4539,6 +4531,7 @@ ivas_error IVAS_REND_FeedRenderConfig( if ( pMasaInput->hMasaExtRend->hReverb != NULL ) { ivas_binaural_reverb_close( &pMasaInput->hMasaExtRend->hReverb ); if ( ( error = ivas_binaural_reverb_init( &pMasaInput->hMasaExtRend->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, pMasaInput->hMasaExtRend->hSpatParamRendCom->num_freq_bands, Loading Loading @@ -4571,6 +4564,7 @@ ivas_error IVAS_REND_FeedRenderConfig( return error; } } if ( pMcInput->crendWrapper != NULL && pMcInput->crendWrapper->hCrend[0] && pMcInput->crendWrapper->hCrend[0]->hReverb != NULL ) { if ( ( error = ivas_reverb_open( &pMcInput->crendWrapper->hCrend[0]->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, hRenderConfig, *pMcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) Loading Loading @@ -4621,6 +4615,7 @@ ivas_error IVAS_REND_FeedRenderConfig( { int16_t cldfb_in_flag; cldfb_in_flag = getCldfbRendFlag( hIvasRend, IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN ); if ( hIvasRend->splitRendWrapper != NULL ) { ISAR_PRE_REND_close( hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer ); Loading Loading
apps/renderer.c +4 −12 Original line number Diff line number Diff line Loading @@ -1376,16 +1376,14 @@ int main( if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { char *outFile = args.outMetadataFilePath; if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) { outFile = args.outputFilePath; audioWriter = NULL; } if ( ( error = IVAS_REND_GetSplitRendBitstreamHeader( hIvasRend, &bitsBuffer.config.codec, &bitsBuffer.config.poseCorrection, &bitsBuffer.config.codec_frame_size_ms, &bitsBuffer.config.isar_frame_size_ms ) ) != IVAS_ERR_OK ) if ( ( error = IVAS_REND_GetSplitRendBitstreamHeader( hIvasRend, &bitsBuffer.config.codec, &bitsBuffer.config.poseCorrection, &bitsBuffer.config.codec_frame_size_ms, &bitsBuffer.config.isar_frame_size_ms ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_REND_GetSplitRendBitstreamHeader()!\n" ); goto cleanup; Loading Loading @@ -1537,13 +1535,7 @@ int main( /* Convert from int to float and from interleaved to packed */ if ( !flushRendererLastFrame ) { convertInputBuffer( inpInt16Buffer, numSamplesRead, inBuffer.config.numSamplesPerChannel, num_in_channels, inFloatBuffer, inBuffer.config.is_cldfb, cldfbAna ); convertInputBuffer( inpInt16Buffer, numSamplesRead, inBuffer.config.numSamplesPerChannel, num_in_channels, inFloatBuffer, inBuffer.config.is_cldfb, cldfbAna ); } int16_t num_subframes, sf_idx; Loading
lib_rend/ivas_prot_rend.h +13 −15 Original line number Diff line number Diff line Loading @@ -1586,44 +1586,42 @@ void ivas_rend_closeCldfbRend( * Time domain ring buffer prototypes *----------------------------------------------------------------------------------*/ typedef struct TdRingBuf *TD_RINGBUF_HANDLE; ivas_error IVAS_TD_RINGBUF_Open( ivas_error ivas_TD_RINGBUF_Open( TD_RINGBUF_HANDLE *ph, uint32_t capacity_per_channel, uint16_t num_channels const uint32_t capacity_per_channel, const uint16_t num_channels ); void IVAS_TD_RINGBUF_Close( void ivas_TD_RINGBUF_Close( TD_RINGBUF_HANDLE *ph ); void IVAS_TD_RINGBUF_Push( void ivas_TD_RINGBUF_Push( TD_RINGBUF_HANDLE h, const float *data, uint32_t num_samples_per_channel const uint32_t num_samples_per_channel ); void IVAS_TD_RINGBUF_PushZeros( void ivas_TD_RINGBUF_PushZeros( TD_RINGBUF_HANDLE h, uint32_t num_samples_per_channel const uint32_t num_samples_per_channel ); void IVAS_TD_RINGBUF_Pop( void ivas_TD_RINGBUF_Pop( TD_RINGBUF_HANDLE h, float *data, uint32_t num_samples_per_channel const uint32_t num_samples_per_channel ); int16_t IVAS_TD_RINGBUF_IsEmpty( int16_t ivas_TD_RINGBUF_IsEmpty( const TD_RINGBUF_HANDLE h ); uint32_t IVAS_TD_RINGBUF_Size( uint32_t ivas_TD_RINGBUF_Size( const TD_RINGBUF_HANDLE h ); void IVAS_TD_RINGBUF_Clear( void ivas_TD_RINGBUF_Clear( TD_RINGBUF_HANDLE h ); Loading
lib_rend/ivas_stat_rend.h +16 −0 Original line number Diff line number Diff line Loading @@ -1371,6 +1371,22 @@ typedef struct } CLDFB_REND_WRAPPER; /*----------------------------------------------------------------------------------* * Time domain ring buffer structure *----------------------------------------------------------------------------------*/ typedef struct { float *data; /* samples in interleaved layout */ uint32_t capacity; uint16_t num_channels; uint32_t write_pos; uint32_t read_pos; int16_t is_full; } TD_RINGBUF_DATA, *TD_RINGBUF_HANDLE; /*----------------------------------------------------------------------------------* * MASA external renderer structure *----------------------------------------------------------------------------------*/ Loading
lib_rend/ivas_td_ring_buffer.c +42 −28 Original line number Diff line number Diff line Loading @@ -37,21 +37,13 @@ #include "options.h" #include "wmc_auto.h" struct TdRingBuf { float *data; /* samples in interleaved layout */ uint32_t capacity; uint16_t num_channels; uint32_t write_pos; uint32_t read_pos; int16_t is_full; }; /*-----------------------------------------------------------------------* * Local function prototypes *-----------------------------------------------------------------------*/ static uint32_t ivas_td_ringbuf_total_size( TD_RINGBUF_HANDLE h ) static uint32_t ivas_td_ringbuf_total_size( TD_RINGBUF_HANDLE h ) { if ( h->is_full ) { Loading @@ -66,23 +58,28 @@ static uint32_t ivas_td_ringbuf_total_size( TD_RINGBUF_HANDLE h ) return h->write_pos + h->capacity - h->read_pos; } static int16_t ivas_td_ringbuf_has_space_for_num_samples( TD_RINGBUF_HANDLE h, const uint32_t num_samples ) static int16_t ivas_td_ringbuf_has_space_for_num_samples( TD_RINGBUF_HANDLE h, const uint32_t num_samples ) { return (int16_t) ( ivas_td_ringbuf_total_size( h ) + num_samples <= h->capacity ); } /*-----------------------------------------------------------------------* * Global function definitions *-----------------------------------------------------------------------*/ /*---------------------------------------------------------------------* * TD_RINGBUF_Open() * ivas_TD_RINGBUF_Open() * * Allocate a ring buffer for TD data with the given capacity of TD samples per channel. * * May return IVAS_ERR_FAILED_ALLOC on failed allocation, or IVAS_ERR_OK otherwise. *---------------------------------------------------------------------*/ ivas_error IVAS_TD_RINGBUF_Open( ivas_error ivas_TD_RINGBUF_Open( TD_RINGBUF_HANDLE *ph, /* i/o: Ring buffer handle */ const uint32_t capacity_per_channel, /* i : Number of samples stored per channel */ const uint16_t num_channels /* i : Number of channels */ Loading @@ -90,9 +87,10 @@ ivas_error IVAS_TD_RINGBUF_Open( { TD_RINGBUF_HANDLE h; uint32_t capacity; capacity = capacity_per_channel * num_channels; h = malloc( sizeof( struct TdRingBuf ) ); h = malloc( sizeof( TD_RINGBUF_DATA ) ); if ( h == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for TD ring buffer\n" ); Loading @@ -115,12 +113,15 @@ ivas_error IVAS_TD_RINGBUF_Open( return IVAS_ERR_OK; } /*---------------------------------------------------------------------* * TD_RINGBUF_Close() * ivas_TD_RINGBUF_Close() * * Dellocate TD ring buffer. The given handle will be set to NULL. *---------------------------------------------------------------------*/ void IVAS_TD_RINGBUF_Close( void ivas_TD_RINGBUF_Close( TD_RINGBUF_HANDLE *ph /* i/o: Ring buffer handle */ ) { Loading Loading @@ -148,13 +149,15 @@ void IVAS_TD_RINGBUF_Close( return; } /*---------------------------------------------------------------------* * TD_RINGBUF_Push() * ivas_TD_RINGBUF_Push() * * Push samples onto the back of the TD ring buffer. * Returns total number of buffered samples (includes number of channels) *---------------------------------------------------------------------*/ void IVAS_TD_RINGBUF_Push( void ivas_TD_RINGBUF_Push( TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ const float *data, /* i : Input data */ const uint32_t num_samples_per_channel /* i : Number of samples per channel to store */ Loading Loading @@ -187,12 +190,14 @@ void IVAS_TD_RINGBUF_Push( return; } /*---------------------------------------------------------------------* * TD_RINGBUF_PushZeros() * ivas_TD_RINGBUF_PushZeros() * * Push zero samples onto the back of the TD ring buffer. *---------------------------------------------------------------------*/ void IVAS_TD_RINGBUF_PushZeros( void ivas_TD_RINGBUF_PushZeros( TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ const uint32_t num_samples_per_channel /* i : Number of zeros per channel to store */ ) Loading Loading @@ -228,12 +233,14 @@ void IVAS_TD_RINGBUF_PushZeros( return; } /*---------------------------------------------------------------------* * TD_RINGBUF_Pop() * ivas_TD_RINGBUF_Pop() * * Pop samples from the front of the TD ring buffer. *---------------------------------------------------------------------*/ void IVAS_TD_RINGBUF_Pop( void ivas_TD_RINGBUF_Pop( TD_RINGBUF_HANDLE h, /* i/o: Ring buffer handle */ float *data, /* i : Output data */ const uint32_t num_samples_per_channel /* i : Number of samples per channel to retrieve */ Loading Loading @@ -266,40 +273,47 @@ void IVAS_TD_RINGBUF_Pop( return; } /*---------------------------------------------------------------------* * TD_RINGBUF_IsEmpty() * ivas_TD_RINGBUF_IsEmpty() * * Returns 1 if the ring buffer is empty, or 0 otherwise. *---------------------------------------------------------------------*/ int16_t IVAS_TD_RINGBUF_IsEmpty( int16_t ivas_TD_RINGBUF_IsEmpty( const TD_RINGBUF_HANDLE h /* i : Ring buffer handle */ ) { return (int16_t) ( h->read_pos == h->write_pos && !h->is_full ); } /*---------------------------------------------------------------------* * TD_RINGBUF_Size() * ivas_TD_RINGBUF_Size() * * Returns number of buffered samples per channel. *---------------------------------------------------------------------*/ uint32_t IVAS_TD_RINGBUF_Size( uint32_t ivas_TD_RINGBUF_Size( const TD_RINGBUF_HANDLE h /* i : Ring buffer handle */ ) { return ivas_td_ringbuf_total_size( h ) / (uint32_t) h->num_channels; } /*---------------------------------------------------------------------* * TD_RINGBUF_Clear() * ivas_TD_RINGBUF_Clear() * * Remove all samples from the buffer. *---------------------------------------------------------------------*/ void IVAS_TD_RINGBUF_Clear( void ivas_TD_RINGBUF_Clear( TD_RINGBUF_HANDLE h /* i : Ring buffer handle */ ) { h->read_pos = h->write_pos; h->is_full = 0; return; }
lib_rend/lib_rend.c +13 −18 Original line number Diff line number Diff line Loading @@ -1348,9 +1348,7 @@ static ivas_error alignInputDelay( /* buffer has to accomodate maxGlobalDelaySamples + 2 * frameSize */ tmpSize = maxGlobalDelaySamples; tmpSize += 2 * inputAudio.config.numSamplesPerChannel; if ( ( error = IVAS_TD_RINGBUF_Open( &inputBase->delayBuffer, tmpSize, inputAudio.config.numChannels ) ) != IVAS_ERR_OK ) if ( ( error = ivas_TD_RINGBUF_Open( &inputBase->delayBuffer, tmpSize, inputAudio.config.numChannels ) ) != IVAS_ERR_OK ) { return error; } Loading @@ -1358,8 +1356,7 @@ static ivas_error alignInputDelay( /* for the first frame we need to push zeros to align the input delay to the global delay * and then push a frame of actual data */ tmpSize = maxGlobalDelaySamples - inputBase->delayNumSamples * cldfb2tdSampleFact; IVAS_TD_RINGBUF_PushZeros( inputBase->delayBuffer, tmpSize ); ivas_TD_RINGBUF_PushZeros( inputBase->delayBuffer, tmpSize ); /* for ISM inputs, ensure the metadata sync delay is updated */ if ( getAudioConfigType( inputBase->inConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED ) Loading @@ -1370,12 +1367,8 @@ static ivas_error alignInputDelay( } /* push in the new input data and pop to retrieve a complete input frame */ IVAS_TD_RINGBUF_Push( inputBase->delayBuffer, inputAudio.data, inputAudio.config.numSamplesPerChannel ); IVAS_TD_RINGBUF_Pop( inputBase->delayBuffer, inputBase->inputBuffer.data, flushInputs ? IVAS_TD_RINGBUF_Size( inputBase->delayBuffer ) : (uint32_t) inputAudio.config.numSamplesPerChannel ); ivas_TD_RINGBUF_Push( inputBase->delayBuffer, inputAudio.data, inputAudio.config.numSamplesPerChannel ); ivas_TD_RINGBUF_Pop( inputBase->delayBuffer, inputBase->inputBuffer.data, flushInputs ? ivas_TD_RINGBUF_Size( inputBase->delayBuffer ) : (uint32_t) inputAudio.config.numSamplesPerChannel ); return IVAS_ERR_OK; } Loading Loading @@ -1543,7 +1536,7 @@ static void clearInputIsm( rendCtx = inputIsm->base.ctx; freeInputBaseBufferData( &inputIsm->base.inputBuffer.data ); IVAS_TD_RINGBUF_Close( &inputIsm->base.delayBuffer ); ivas_TD_RINGBUF_Close( &inputIsm->base.delayBuffer ); initRendInputBase( &inputIsm->base, IVAS_AUDIO_CONFIG_INVALID, 0, rendCtx, NULL, 0 ); Loading Loading @@ -2542,7 +2535,7 @@ static void clearInputMc( freeMcLfeDelayBuffer( &inputMc->lfeDelayBuffer ); freeInputBaseBufferData( &inputMc->bufferData ); IVAS_TD_RINGBUF_Close( &inputMc->base.delayBuffer ); ivas_TD_RINGBUF_Close( &inputMc->base.delayBuffer ); initRendInputBase( &inputMc->base, IVAS_AUDIO_CONFIG_INVALID, 0, rendCtx, NULL, 0 ); Loading Loading @@ -2874,7 +2867,7 @@ static void clearInputSba( rendCtx = inputSba->base.ctx; freeInputBaseBufferData( &inputSba->bufferData ); IVAS_TD_RINGBUF_Close( &inputSba->base.delayBuffer ); ivas_TD_RINGBUF_Close( &inputSba->base.delayBuffer ); initRendInputBase( &inputSba->base, IVAS_AUDIO_CONFIG_INVALID, 0, rendCtx, NULL, 0 ); Loading Loading @@ -2973,7 +2966,7 @@ static void clearInputMasa( rendCtx = inputMasa->base.ctx; freeInputBaseBufferData( &inputMasa->bufferData ); IVAS_TD_RINGBUF_Close( &inputMasa->base.delayBuffer ); ivas_TD_RINGBUF_Close( &inputMasa->base.delayBuffer ); masaPrerendClose( &inputMasa->hMasaPrerend ); freeMasaExtRenderer( &inputMasa->hMasaExtRend ); Loading Loading @@ -3661,7 +3654,6 @@ static ivas_error isar_pre_rend_init( } } /* We may need to change the allocated buffer size if a new input is added. * If the cldfb_in_flag is different from what was previously allocated for the buffer, change the size */ if ( pSplitRendEncBuffer->data != NULL && ( cldfb_in_flag != pSplitRendEncBuffer->config.is_cldfb ) ) Loading Loading @@ -3789,7 +3781,6 @@ ivas_error IVAS_REND_AddInput( /* update global maximum delay after adding an input */ updateMaxGlobalDelayNs( hIvasRend ); return IVAS_ERR_OK; } Loading Loading @@ -4522,6 +4513,7 @@ ivas_error IVAS_REND_FeedRenderConfig( if ( pMasaInput->hMasaExtRend->hDiracDecBin[0] != NULL && pMasaInput->hMasaExtRend->hDiracDecBin[0]->hReverb != NULL ) { ivas_binaural_reverb_close( &pMasaInput->hMasaExtRend->hDiracDecBin[0]->hReverb ); if ( ( error = ivas_binaural_reverb_init( &pMasaInput->hMasaExtRend->hDiracDecBin[0]->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, pMasaInput->hMasaExtRend->hSpatParamRendCom->num_freq_bands, Loading @@ -4539,6 +4531,7 @@ ivas_error IVAS_REND_FeedRenderConfig( if ( pMasaInput->hMasaExtRend->hReverb != NULL ) { ivas_binaural_reverb_close( &pMasaInput->hMasaExtRend->hReverb ); if ( ( error = ivas_binaural_reverb_init( &pMasaInput->hMasaExtRend->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, pMasaInput->hMasaExtRend->hSpatParamRendCom->num_freq_bands, Loading Loading @@ -4571,6 +4564,7 @@ ivas_error IVAS_REND_FeedRenderConfig( return error; } } if ( pMcInput->crendWrapper != NULL && pMcInput->crendWrapper->hCrend[0] && pMcInput->crendWrapper->hCrend[0]->hReverb != NULL ) { if ( ( error = ivas_reverb_open( &pMcInput->crendWrapper->hCrend[0]->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, hRenderConfig, *pMcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) Loading Loading @@ -4621,6 +4615,7 @@ ivas_error IVAS_REND_FeedRenderConfig( { int16_t cldfb_in_flag; cldfb_in_flag = getCldfbRendFlag( hIvasRend, IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN ); if ( hIvasRend->splitRendWrapper != NULL ) { ISAR_PRE_REND_close( hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer ); Loading