Commit 6f654ffe authored by vaclav's avatar vaclav
Browse files

introduce buffer *tc_buffer2

parent dc145ebf
Loading
Loading
Loading
Loading
Loading
+16 −4
Original line number Diff line number Diff line
@@ -2861,16 +2861,26 @@ void ivas_destroy_dec(
    ivas_limiter_close( &( st_ivas->hLimiter ) );

#ifdef FIX_1330_JBM_MEMORY
    /* JBM decoding: floating-point output audio buffers are shared with bufeers from 'hTcBuffer' */
    /* floating-point output audio buffers */
    if ( st_ivas->hDecoderConfig->Opt_tsm )
    {
        int16_t nchan_tc_jbm = max( st_ivas->hTcBuffer->nchan_transport_jbm, st_ivas->hTcBuffer->nchan_buffer_full );

        for ( i = 0; i < nchan_tc_jbm; i++ )
        /* JBM decoding: floating-point output audio buffers are shared with buffers from 'hTcBuffer' */
        for ( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ )
        {
            st_ivas->p_output_f[i] = NULL;
        }
    }
    else
    {
        for ( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ )
        {
            if ( st_ivas->p_output_f[i] != NULL )
            {
                free( st_ivas->p_output_f[i] );
                st_ivas->p_output_f[i] = NULL;
            }
        }
    }

    /* Decoder configuration structure */
#endif
@@ -2889,6 +2899,7 @@ void ivas_destroy_dec(
        st_ivas->hJbmMetadata = NULL;
    }

#ifndef FIX_1330_JBM_MEMORY
    /* floating-point output audio buffers */
    for ( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ )
    {
@@ -2899,6 +2910,7 @@ void ivas_destroy_dec(
        }
    }

#endif
    /* main IVAS handle */
    free( st_ivas );

+17 −0
Original line number Diff line number Diff line
@@ -2166,6 +2166,10 @@ static ivas_error ivas_jbm_dec_tc_audio_allocate(
        }
    }

#ifdef FIX_1330_JBM_MEMORY
    hTcBuffer->tc_buffer2 = NULL;

#endif
    return IVAS_ERR_OK;
}

@@ -2203,6 +2207,19 @@ static void ivas_jbm_dec_tc_audio_deallocate(
                hTcBuffer->tc_buffer_old[ch_idx] = NULL;
            }
        }
#ifdef FIX_1330_JBM_MEMORY

        if ( hTcBuffer->tc_buffer2 != NULL )
        {
            for ( ch_idx = 0; ch_idx < MAX_INTERN_CHANNELS; ch_idx++ )
            {
                //hTcBuffer->tc[ch_idx] = NULL;
            }

            free( hTcBuffer->tc_buffer2 );
            hTcBuffer->tc_buffer2 = NULL;
        }
#endif
    }

    return;
+4 −0
Original line number Diff line number Diff line
@@ -963,6 +963,10 @@ typedef struct decoder_tc_buffer_structure
    int16_t num_slots;
    int16_t n_samples_discard; /* number of samples to discard from the beginning of the output */

#ifdef FIX_1330_JBM_MEMORY
    float *tc_buffer2;

#endif
} DECODER_TC_BUFFER, *DECODER_TC_BUFFER_HANDLE;

typedef struct jbm_metadata_structure
+23 −11
Original line number Diff line number Diff line
@@ -417,7 +417,14 @@ ivas_error ivas_output_buff_dec(
    else
    {
        /* JBM decoding: output audio buffers are shared with audio buffers from 'hTcBuffer' */
        int16_t nchan_tc_jbm;
        int16_t nchan_tc_jbm, nsamp_to_allocate, n_samp_full, offset;

        if ( hTcBuffer->tc_buffer2 != NULL )
        {
            free( hTcBuffer->tc_buffer2 );
            hTcBuffer->tc_buffer2 = NULL;
        }

        nchan_tc_jbm = max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full );

        if ( nchan_out_buff <= nchan_tc_jbm )
@@ -440,18 +447,23 @@ ivas_error ivas_output_buff_dec(
            }

            /* when not enough audio buffers in 'hTcBuffer', allocate remaining output audio buffers here */
            for ( ; ch < nchan_out_buff; ch++ )
            {

            n_samp_full = ( 48000 / FRAMES_PER_SEC );
            nsamp_to_allocate = ( nchan_out_buff - nchan_tc_jbm ) * n_samp_full;

            /* note: these are intra-frame heap memories */
                if ( ( p_output_f[ch] = (float *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL )
            if ( ( hTcBuffer->tc_buffer2 = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL )
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) );
            }

                if ( ch < MAX_INTERN_CHANNELS )
            set_zero( hTcBuffer->tc_buffer2, nsamp_to_allocate );

            offset = 0;
            for ( ; ch < nchan_out_buff; ch++ )
            {
                    hTcBuffer->tc[ch] = p_output_f[ch];
                }
                p_output_f[ch] = &hTcBuffer->tc_buffer2[offset];
                offset += n_samp_full;
            }

            for ( ; ch < nchan_out_buff_old; ch++ )