Commit f520a0fc authored by vaclav's avatar vaclav
Browse files

simplifications

parent cab8264e
Loading
Loading
Loading
Loading
Loading
+4 −25
Original line number Diff line number Diff line
@@ -2855,30 +2855,7 @@ void ivas_destroy_dec(
    /* Limiter struct */
    ivas_limiter_close( &( st_ivas->hLimiter ) );

#ifdef FIX_1330_JBM_MEMORY
    /* floating-point output audio buffers */
    if ( st_ivas->hDecoderConfig->Opt_tsm )
    {
        /* 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
    if ( st_ivas->hDecoderConfig != NULL )
    {
        free( st_ivas->hDecoderConfig );
@@ -2894,18 +2871,20 @@ 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++ )
    {
#ifdef FIX_1330_JBM_MEMORY
        st_ivas->p_output_f[i] = NULL;
#else
        if ( st_ivas->p_output_f[i] != NULL )
        {
            free( st_ivas->p_output_f[i] );
            st_ivas->p_output_f[i] = NULL;
        }
#endif
    }

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

+0 −5
Original line number Diff line number Diff line
@@ -2211,11 +2211,6 @@ static void ivas_jbm_dec_tc_audio_deallocate(

        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;
        }
+25 −8
Original line number Diff line number Diff line
@@ -258,54 +258,71 @@ ivas_error ivas_osba_render_sf(
    float *p_output[]                /* o  : rendered time signal                      */
)
{
#ifdef FIX_1330_JBM_MEMORY
    int16_t n, tc_offset;
#else
    int16_t n;
#endif
#ifdef FIX_1330_JBM_MEMORY
    float output_ism[MAX_OUTPUT_CHANNELS][2 * L_FRAME48k]; // VE: TBV!!!
    float output_sba[MAX_OUTPUT_CHANNELS][L_FRAME48k];
    float *p_output_sba[MAX_OUTPUT_CHANNELS];
#else
    float output_ism[MAX_OUTPUT_CHANNELS][L_FRAME48k];
#endif
    float *p_output_ism[MAX_OUTPUT_CHANNELS];
#endif
    ivas_error error;

    for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ )
    {
#ifdef FIX_1330_JBM_MEMORY
        p_output_sba[n] = output_sba[n];
#else
        p_output_ism[n] = &output_ism[n][0];
#endif
    }

#ifndef FIX_1330_JBM_MEMORY
    if ( !st_ivas->hDecoderConfig->Opt_tsm )
    {
        int16_t tc_offset;
#endif
        tc_offset = st_ivas->hTcBuffer->n_samples_rendered;
        for ( n = 0; n < st_ivas->nchan_ism; n++ )
        {
            mvr2r( &p_output[n][tc_offset], &output_ism[n][tc_offset], nSamplesAsked );
        }
#ifndef FIX_1330_JBM_MEMORY
    }
#endif

#ifdef FIX_1330_JBM_MEMORY
    if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailableNext, p_output_sba ) ) != IVAS_ERR_OK )
#else
    if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK )
#endif
    {
        return error;
    }

    if ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM )
    {
#ifdef FIX_1330_JBM_MEMORY
        ivas_ism_render_sf( st_ivas, st_ivas->renderer_type, p_output, *nSamplesRendered );
#else
        ivas_ism_render_sf( st_ivas, st_ivas->renderer_type, p_output_ism, *nSamplesRendered );
#endif
    }

    for ( n = 0; n < st_ivas->hDecoderConfig->nchan_out; n++ )
    {
        if ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM )
        {
#ifdef FIX_1330_JBM_MEMORY
            v_add( p_output[n], p_output_sba[n], p_output[n], *nSamplesRendered );
#else
            v_add( p_output[n], p_output_ism[n], p_output[n], *nSamplesRendered );
#endif
        }
#ifdef FIX_1330_JBM_MEMORY
        else
        {
            mvr2r( p_output_sba[n], p_output[n], *nSamplesRendered );
        }
#endif

        v_multc( p_output[n], 0.5f, p_output[n], *nSamplesRendered );
    }
+1 −1
Original line number Diff line number Diff line
@@ -964,7 +964,7 @@ typedef struct decoder_tc_buffer_structure
    int16_t n_samples_discard; /* number of samples to discard from the beginning of the output */

#ifdef FIX_1330_JBM_MEMORY
    float *tc_buffer2;
    float *tc_buffer2; /* non-scaled buffer of output audio - needed only when '*tc_buffer* is not long enough */

#endif
} DECODER_TC_BUFFER, *DECODER_TC_BUFFER_HANDLE;
+57 −72
Original line number Diff line number Diff line
@@ -379,47 +379,10 @@ ivas_error ivas_output_buff_dec(
#endif
)
{
    int16_t ch;

#ifdef FIX_1330_JBM_MEMORY
    if ( !Opt_tsm )
    {
        /* non-JBM decoding: allocate output audio buffers here; audio buffers from 'hTcBuffer' are set to NULL */

#endif
        if ( nchan_out_buff > nchan_out_buff_old )
        {
            for ( ch = nchan_out_buff_old; ch < nchan_out_buff; ch++ )
            {
#ifdef DEBUGGING
                if ( p_output_f[ch] != NULL )
                {
                    return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Memory for floating-point output audio buffer is already allocated!\n" ) );
                }
#endif
                /* note: these are intra-frame heap memories */
                if ( ( p_output_f[ch] = (float *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL )
                {
                    return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) );
                }
            }
        }
        else
        {
            for ( ch = nchan_out_buff; ch < nchan_out_buff_old; ch++ )
            {
                free( p_output_f[ch] );
                p_output_f[ch] = NULL;
            }
        }
#ifdef FIX_1330_JBM_MEMORY
    }
    else
    {
        /* JBM decoding: output audio buffers are shared with audio buffers from 'hTcBuffer' */
        int16_t nchan_tc_jbm, nsamp_to_allocate, n_samp_full, offset;
    int16_t ch, nchan_tc_jbm, nsamp_to_allocate, n_samp_full, offset;

        for ( ch = 0; ch < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; ch++ )
    for ( ch = 0; ch < nchan_out_buff_old; ch++ )
    {
        p_output_f[ch] = NULL;
    }
@@ -430,19 +393,19 @@ ivas_error ivas_output_buff_dec(
        hTcBuffer->tc_buffer2 = NULL;
    }

    nchan_tc_jbm = 0;
    if ( Opt_tsm )
    {
        /* JBM decoding: output audio buffers are shared with audio buffers from 'hTcBuffer->tc[]' */
        nchan_tc_jbm = max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full );
    }

        if ( nchan_out_buff <= nchan_tc_jbm )
    if ( nchan_out_buff <= nchan_tc_jbm && !Opt_tsm )
    {
        for ( ch = 0; ch < nchan_out_buff; ch++ )
        {
            p_output_f[ch] = hTcBuffer->tc[ch];
        }

            for ( ; ch < nchan_out_buff_old; ch++ )
            {
                p_output_f[ch] = NULL;
            }
    }
    else
    {
@@ -451,8 +414,8 @@ ivas_error ivas_output_buff_dec(
            p_output_f[ch] = hTcBuffer->tc[ch];
        }

            /* when not enough audio buffers in 'hTcBuffer', allocate remaining output audio buffers here */

        /* non-JBM decoding: allocate output audio buffers 
           JBM decoding: when not enough audio buffers 'hTcBuffer->tc[]', allocate additional buffers */
        n_samp_full = ( 48000 / FRAMES_PER_SEC );
        nsamp_to_allocate = ( nchan_out_buff - nchan_tc_jbm ) * n_samp_full;

@@ -470,13 +433,35 @@ ivas_error ivas_output_buff_dec(
            p_output_f[ch] = &hTcBuffer->tc_buffer2[offset];
            offset += n_samp_full;
        }
    }
#else
    int16_t ch;

            for ( ; ch < nchan_out_buff_old; ch++ )
    if ( nchan_out_buff > nchan_out_buff_old )
    {
                p_output_f[ch] = NULL;
        for ( ch = nchan_out_buff_old; ch < nchan_out_buff; ch++ )
        {
#ifdef DEBUGGING
            if ( p_output_f[ch] != NULL )
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Memory for floating-point output audio buffer is already allocated!\n" ) );
            }
#endif
            /* note: these are intra-frame heap memories */
            if ( ( p_output_f[ch] = (float *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL )
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) );
            }
        }
    }
    else
    {
        for ( ch = nchan_out_buff; ch < nchan_out_buff_old; ch++ )
        {
            free( p_output_f[ch] );
            p_output_f[ch] = NULL;
        }
    }
#endif

    return IVAS_ERR_OK;