Loading lib_dec/ivas_jbm_dec.c +61 −75 Original line number Diff line number Diff line Loading @@ -2236,12 +2236,12 @@ int16_t ivas_jbm_dec_get_render_granularity( #ifdef REMOVE_APA_BUFFER /*--------------------------------------------------------------------------* * ivas_jbm_dec_tc_buffer_allocate() * ivas_jbm_dec_tc_audio_allocate() * * open and initialize JBM transport channel buffer * allocate and initialize TC audio buffer *--------------------------------------------------------------------------*/ static ivas_error ivas_jbm_dec_tc_buffer_allocate( static ivas_error ivas_jbm_dec_tc_audio_allocate( DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: JBM TSM buffer handle */ const int32_t output_Fs, /* i : output sampling rate */ const int16_t Opt_tsm /* i : TSM option flag */ Loading Loading @@ -2278,7 +2278,7 @@ static ivas_error ivas_jbm_dec_tc_buffer_allocate( hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; offset += n_samp_full; } for ( ; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) for ( ; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ ) { hTcBuffer->tc[ch_idx] = NULL; } Loading @@ -2301,7 +2301,7 @@ static ivas_error ivas_jbm_dec_tc_buffer_allocate( { hTcBuffer->tc_buffer = NULL; for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) // VE: number of channels could be lowered?? for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ ) { hTcBuffer->tc[ch_idx] = NULL; } Loading @@ -2310,6 +2310,44 @@ static ivas_error ivas_jbm_dec_tc_buffer_allocate( return IVAS_ERR_OK; } /*--------------------------------------------------------------------------* * ivas_jbm_dec_tc_audio_deallocate() * * deallocate TC audio buffer *--------------------------------------------------------------------------*/ static void ivas_jbm_dec_tc_audio_deallocate( DECODER_TC_BUFFER_HANDLE hTcBuffer /* i/o: JBM TSM buffer handle */ ) { int16_t ch_idx; if ( hTcBuffer != NULL ) { if ( hTcBuffer->tc_buffer != NULL ) { for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ ) { hTcBuffer->tc[ch_idx] = NULL; } free( hTcBuffer->tc_buffer ); hTcBuffer->tc_buffer = NULL; } for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ ) { if ( hTcBuffer->tc_buffer_old[ch_idx] != NULL ) { free( hTcBuffer->tc_buffer_old[ch_idx] ); hTcBuffer->tc_buffer_old[ch_idx] = NULL; } } } return; } #endif /*--------------------------------------------------------------------------* Loading Loading @@ -2369,7 +2407,7 @@ ivas_error ivas_jbm_dec_tc_buffer_open( set_s( hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, MAX_PARAM_SPATIAL_SUBFRAMES ); #ifdef REMOVE_APA_BUFFER if ( ( error = ivas_jbm_dec_tc_buffer_allocate( hTcBuffer, st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->Opt_tsm ) ) != IVAS_ERR_OK ) if ( ( error = ivas_jbm_dec_tc_audio_allocate( hTcBuffer, st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->Opt_tsm ) ) != IVAS_ERR_OK ) { return error; } Loading @@ -2379,11 +2417,7 @@ ivas_error ivas_jbm_dec_tc_buffer_open( int32_t offset; if ( st_ivas->hDecoderConfig->Opt_tsm ) { #ifdef REMOVE_APA_BUFFER n_samp_full = ( NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ) ); #else n_samp_full = ( NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ) + hTcBuffer->n_samples_granularity - 1 ); #endif n_samp_residual = hTcBuffer->n_samples_granularity - 1; } else Loading @@ -2392,12 +2426,8 @@ ivas_error ivas_jbm_dec_tc_buffer_open( n_samp_residual = 0; } #ifdef OPT_TC nsamp_to_allocate = max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ) * n_samp_full; #else nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full; nsamp_to_allocate += nchan_residual * n_samp_residual; #endif if ( nsamp_to_allocate == 0 ) { Loading Loading @@ -2434,22 +2464,6 @@ ivas_error ivas_jbm_dec_tc_buffer_open( { hTcBuffer->tc[ch_idx] = NULL; } #ifdef OPT_TC /* memory buffer for TC audio samples not rendered in the previous frame */ for ( ch_idx = 0; ch_idx < max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); ch_idx++ ) { if ( ( hTcBuffer->tc_buffer_old[ch_idx] = (float *) malloc( n_samp_residual * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); } set_zero( hTcBuffer->tc_buffer_old[ch_idx], n_samp_residual ); } for ( ; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ ) { hTcBuffer->tc_buffer_old[ch_idx] = NULL; } #endif } else { Loading Loading @@ -2481,7 +2495,6 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( ) { #ifdef REMOVE_APA_BUFFER int16_t ch_idx; ivas_error error; #else int16_t nsamp_to_allocate, n_samp_full, n_samp_residual, offset, nchan_residual; Loading Loading @@ -2537,44 +2550,27 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( /* what is remaining from last frames needs always be smaller than n_samples_granularity */ assert( ( hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_rendered ) < n_samples_granularity ); #endif /* realloc buffers */ if ( hTcBuffer->tc_buffer != NULL ) { #ifdef OPT_TC for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) { hTcBuffer->tc[ch_idx] = NULL; } #endif free( hTcBuffer->tc_buffer ); hTcBuffer->tc_buffer = NULL; #ifdef OPT_TC #ifdef REMOVE_APA_BUFFER /* reallocate TC audio buffers */ for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ ) { if ( hTcBuffer->tc_buffer_old[ch_idx] != NULL ) { free( hTcBuffer->tc_buffer_old[ch_idx] ); hTcBuffer->tc_buffer_old[ch_idx] = NULL; } } #endif } ivas_jbm_dec_tc_audio_deallocate( hTcBuffer ); #ifdef REMOVE_APA_BUFFER if ( ( error = ivas_jbm_dec_tc_buffer_allocate( hTcBuffer, st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->Opt_tsm ) ) != IVAS_ERR_OK ) if ( ( error = ivas_jbm_dec_tc_audio_allocate( hTcBuffer, st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->Opt_tsm ) ) != IVAS_ERR_OK ) { return error; } #else /* realloc buffers */ if ( hTcBuffer->tc_buffer != NULL ) { free( hTcBuffer->tc_buffer ); hTcBuffer->tc_buffer = NULL; } if ( st_ivas->hDecoderConfig->Opt_tsm ) { #ifdef REMOVE_APA_BUFFER n_samp_full = ( NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ) ); #else n_samp_full = ( NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ) + hTcBuffer->n_samples_granularity - 1 ); #endif n_samp_residual = hTcBuffer->n_samples_granularity - 1; } else Loading @@ -2583,12 +2579,7 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( n_samp_residual = 0; } #ifdef OPT_TC nsamp_to_allocate = max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ) * n_samp_full; #else nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full; nsamp_to_allocate += nchan_residual * n_samp_residual; #endif if ( nsamp_to_allocate == 0 ) { Loading Loading @@ -2704,10 +2695,15 @@ void ivas_jbm_dec_tc_buffer_close( DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ ) { #ifndef REMOVE_APA_BUFFER int16_t i; #endif if ( *phTcBuffer != NULL ) { #ifdef REMOVE_APA_BUFFER ivas_jbm_dec_tc_audio_deallocate( *phTcBuffer ); #else for ( i = 0; i < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; i++ ) { ( *phTcBuffer )->tc[i] = NULL; Loading @@ -2718,18 +2714,8 @@ void ivas_jbm_dec_tc_buffer_close( free( ( *phTcBuffer )->tc_buffer ); ( *phTcBuffer )->tc_buffer = NULL; } #ifdef OPT_TC for ( i = 0; i < MAX_TRANSPORT_CHANNELS; i++ ) { if ( ( *phTcBuffer )->tc_buffer_old[i] != NULL ) { free( ( *phTcBuffer )->tc_buffer_old[i] ); ( *phTcBuffer )->tc_buffer_old[i] = NULL; } } #endif free( *phTcBuffer ); *phTcBuffer = NULL; } Loading lib_dec/ivas_stat_dec.h +13 −10 Original line number Diff line number Diff line Loading @@ -946,10 +946,13 @@ typedef struct decoder_tc_buffer_structure { #ifdef OPT_TC float *tc_buffer_old[MAX_TRANSPORT_CHANNELS]; /* TC audio samples not rendered in the previous frame */ float *tc_residual_old[MAX_INTERN_CHANNELS]; /* residual channels audio samples not rendered in the previous frame */ #endif float *tc_buffer; /* the buffer itself */ #ifdef OPT_TC float *tc[MAX_TRANSPORT_CHANNELS]; /* pointers into the buffer to the beginning of each tc */ #else float *tc[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; /* pointers into the buffer to the beginning of each tc */ // VE2SB: TBV #endif TC_BUFFER_MODE tc_buffer_mode; /* mode of the buffer (no buffering, render buffering, out buffering) */ int16_t nchan_transport_jbm; /* number of TCs after TC decoding */ int16_t nchan_transport_internal; /* total number of TC buffer channels, can include e.g. TD decorr data */ Loading Loading
lib_dec/ivas_jbm_dec.c +61 −75 Original line number Diff line number Diff line Loading @@ -2236,12 +2236,12 @@ int16_t ivas_jbm_dec_get_render_granularity( #ifdef REMOVE_APA_BUFFER /*--------------------------------------------------------------------------* * ivas_jbm_dec_tc_buffer_allocate() * ivas_jbm_dec_tc_audio_allocate() * * open and initialize JBM transport channel buffer * allocate and initialize TC audio buffer *--------------------------------------------------------------------------*/ static ivas_error ivas_jbm_dec_tc_buffer_allocate( static ivas_error ivas_jbm_dec_tc_audio_allocate( DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: JBM TSM buffer handle */ const int32_t output_Fs, /* i : output sampling rate */ const int16_t Opt_tsm /* i : TSM option flag */ Loading Loading @@ -2278,7 +2278,7 @@ static ivas_error ivas_jbm_dec_tc_buffer_allocate( hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; offset += n_samp_full; } for ( ; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) for ( ; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ ) { hTcBuffer->tc[ch_idx] = NULL; } Loading @@ -2301,7 +2301,7 @@ static ivas_error ivas_jbm_dec_tc_buffer_allocate( { hTcBuffer->tc_buffer = NULL; for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) // VE: number of channels could be lowered?? for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ ) { hTcBuffer->tc[ch_idx] = NULL; } Loading @@ -2310,6 +2310,44 @@ static ivas_error ivas_jbm_dec_tc_buffer_allocate( return IVAS_ERR_OK; } /*--------------------------------------------------------------------------* * ivas_jbm_dec_tc_audio_deallocate() * * deallocate TC audio buffer *--------------------------------------------------------------------------*/ static void ivas_jbm_dec_tc_audio_deallocate( DECODER_TC_BUFFER_HANDLE hTcBuffer /* i/o: JBM TSM buffer handle */ ) { int16_t ch_idx; if ( hTcBuffer != NULL ) { if ( hTcBuffer->tc_buffer != NULL ) { for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ ) { hTcBuffer->tc[ch_idx] = NULL; } free( hTcBuffer->tc_buffer ); hTcBuffer->tc_buffer = NULL; } for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ ) { if ( hTcBuffer->tc_buffer_old[ch_idx] != NULL ) { free( hTcBuffer->tc_buffer_old[ch_idx] ); hTcBuffer->tc_buffer_old[ch_idx] = NULL; } } } return; } #endif /*--------------------------------------------------------------------------* Loading Loading @@ -2369,7 +2407,7 @@ ivas_error ivas_jbm_dec_tc_buffer_open( set_s( hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, MAX_PARAM_SPATIAL_SUBFRAMES ); #ifdef REMOVE_APA_BUFFER if ( ( error = ivas_jbm_dec_tc_buffer_allocate( hTcBuffer, st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->Opt_tsm ) ) != IVAS_ERR_OK ) if ( ( error = ivas_jbm_dec_tc_audio_allocate( hTcBuffer, st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->Opt_tsm ) ) != IVAS_ERR_OK ) { return error; } Loading @@ -2379,11 +2417,7 @@ ivas_error ivas_jbm_dec_tc_buffer_open( int32_t offset; if ( st_ivas->hDecoderConfig->Opt_tsm ) { #ifdef REMOVE_APA_BUFFER n_samp_full = ( NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ) ); #else n_samp_full = ( NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ) + hTcBuffer->n_samples_granularity - 1 ); #endif n_samp_residual = hTcBuffer->n_samples_granularity - 1; } else Loading @@ -2392,12 +2426,8 @@ ivas_error ivas_jbm_dec_tc_buffer_open( n_samp_residual = 0; } #ifdef OPT_TC nsamp_to_allocate = max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ) * n_samp_full; #else nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full; nsamp_to_allocate += nchan_residual * n_samp_residual; #endif if ( nsamp_to_allocate == 0 ) { Loading Loading @@ -2434,22 +2464,6 @@ ivas_error ivas_jbm_dec_tc_buffer_open( { hTcBuffer->tc[ch_idx] = NULL; } #ifdef OPT_TC /* memory buffer for TC audio samples not rendered in the previous frame */ for ( ch_idx = 0; ch_idx < max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); ch_idx++ ) { if ( ( hTcBuffer->tc_buffer_old[ch_idx] = (float *) malloc( n_samp_residual * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); } set_zero( hTcBuffer->tc_buffer_old[ch_idx], n_samp_residual ); } for ( ; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ ) { hTcBuffer->tc_buffer_old[ch_idx] = NULL; } #endif } else { Loading Loading @@ -2481,7 +2495,6 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( ) { #ifdef REMOVE_APA_BUFFER int16_t ch_idx; ivas_error error; #else int16_t nsamp_to_allocate, n_samp_full, n_samp_residual, offset, nchan_residual; Loading Loading @@ -2537,44 +2550,27 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( /* what is remaining from last frames needs always be smaller than n_samples_granularity */ assert( ( hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_rendered ) < n_samples_granularity ); #endif /* realloc buffers */ if ( hTcBuffer->tc_buffer != NULL ) { #ifdef OPT_TC for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) { hTcBuffer->tc[ch_idx] = NULL; } #endif free( hTcBuffer->tc_buffer ); hTcBuffer->tc_buffer = NULL; #ifdef OPT_TC #ifdef REMOVE_APA_BUFFER /* reallocate TC audio buffers */ for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ ) { if ( hTcBuffer->tc_buffer_old[ch_idx] != NULL ) { free( hTcBuffer->tc_buffer_old[ch_idx] ); hTcBuffer->tc_buffer_old[ch_idx] = NULL; } } #endif } ivas_jbm_dec_tc_audio_deallocate( hTcBuffer ); #ifdef REMOVE_APA_BUFFER if ( ( error = ivas_jbm_dec_tc_buffer_allocate( hTcBuffer, st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->Opt_tsm ) ) != IVAS_ERR_OK ) if ( ( error = ivas_jbm_dec_tc_audio_allocate( hTcBuffer, st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->Opt_tsm ) ) != IVAS_ERR_OK ) { return error; } #else /* realloc buffers */ if ( hTcBuffer->tc_buffer != NULL ) { free( hTcBuffer->tc_buffer ); hTcBuffer->tc_buffer = NULL; } if ( st_ivas->hDecoderConfig->Opt_tsm ) { #ifdef REMOVE_APA_BUFFER n_samp_full = ( NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ) ); #else n_samp_full = ( NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ) + hTcBuffer->n_samples_granularity - 1 ); #endif n_samp_residual = hTcBuffer->n_samples_granularity - 1; } else Loading @@ -2583,12 +2579,7 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( n_samp_residual = 0; } #ifdef OPT_TC nsamp_to_allocate = max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ) * n_samp_full; #else nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full; nsamp_to_allocate += nchan_residual * n_samp_residual; #endif if ( nsamp_to_allocate == 0 ) { Loading Loading @@ -2704,10 +2695,15 @@ void ivas_jbm_dec_tc_buffer_close( DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ ) { #ifndef REMOVE_APA_BUFFER int16_t i; #endif if ( *phTcBuffer != NULL ) { #ifdef REMOVE_APA_BUFFER ivas_jbm_dec_tc_audio_deallocate( *phTcBuffer ); #else for ( i = 0; i < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; i++ ) { ( *phTcBuffer )->tc[i] = NULL; Loading @@ -2718,18 +2714,8 @@ void ivas_jbm_dec_tc_buffer_close( free( ( *phTcBuffer )->tc_buffer ); ( *phTcBuffer )->tc_buffer = NULL; } #ifdef OPT_TC for ( i = 0; i < MAX_TRANSPORT_CHANNELS; i++ ) { if ( ( *phTcBuffer )->tc_buffer_old[i] != NULL ) { free( ( *phTcBuffer )->tc_buffer_old[i] ); ( *phTcBuffer )->tc_buffer_old[i] = NULL; } } #endif free( *phTcBuffer ); *phTcBuffer = NULL; } Loading
lib_dec/ivas_stat_dec.h +13 −10 Original line number Diff line number Diff line Loading @@ -946,10 +946,13 @@ typedef struct decoder_tc_buffer_structure { #ifdef OPT_TC float *tc_buffer_old[MAX_TRANSPORT_CHANNELS]; /* TC audio samples not rendered in the previous frame */ float *tc_residual_old[MAX_INTERN_CHANNELS]; /* residual channels audio samples not rendered in the previous frame */ #endif float *tc_buffer; /* the buffer itself */ #ifdef OPT_TC float *tc[MAX_TRANSPORT_CHANNELS]; /* pointers into the buffer to the beginning of each tc */ #else float *tc[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; /* pointers into the buffer to the beginning of each tc */ // VE2SB: TBV #endif TC_BUFFER_MODE tc_buffer_mode; /* mode of the buffer (no buffering, render buffering, out buffering) */ int16_t nchan_transport_jbm; /* number of TCs after TC decoding */ int16_t nchan_transport_internal; /* total number of TC buffer channels, can include e.g. TD decorr data */ Loading