Commit a929ee31 authored by vaclav's avatar vaclav
Browse files

issue 876: fixes within NONBE_UNIFIED_DECODING_PATHS; under NONBE_UNIFIED_DECODING_PATHS_FIX

parent f7009545
Loading
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -164,6 +164,9 @@

#define NONBE_FIX_856_TCX_LTP_SYNTH_FILTER                    /* FhG: issue 856: correct filtering length for tcx-ltp synth filtering*/
#define NONBE_UNIFIED_DECODING_PATHS                          /* FhG: unify decoding paths   */
#ifdef NONBE_UNIFIED_DECODING_PATHS
#define NONBE_UNIFIED_DECODING_PATHS_FIX                      /* VA: issue 876: fixes within NONBE_UNIFIED_DECODING_PATHS */
#endif
#define NONBE_FIX_861_MASA_CRASH_STEREO_SWITCHING             /* VA: issue 861: fix MASA 2TC crash when switching from MDCT stereo to TD/DFT stereo */
#define BE_FIX_867_PARAMC_RECONFIG                            /* FhG: issue #867: fix ParamMC CLDFB buffer dealloc when reconfiguring */
#define NONBE_FIX_850_MASA_HBR_META_RATIO_DECODING            /* Nokia: issue #850: Fixes rare non-valid diffuseness and energy ratio values in 2dir MASA. */
+6 −1
Original line number Diff line number Diff line
@@ -51,6 +51,10 @@
 * Principal IVAS decoder routine
 *--------------------------------------------------------------------------*/

#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX
// TODO: move here function ivas_jbm_dec_tc() and rename it to ivas_dec()

#else
ivas_error ivas_dec(
    Decoder_Struct *st_ivas,             /* i/o: IVAS decoder structure      */
#ifdef SPLIT_REND_WITH_HEAD_ROT
@@ -1160,3 +1164,4 @@ ivas_error ivas_dec(
    pop_wmops();
    return IVAS_ERR_OK;
}
#endif
+49 −6
Original line number Diff line number Diff line
@@ -73,7 +73,9 @@ ivas_error ivas_jbm_dec_tc(
    int16_t n, output_frame, nchan_out;
    Decoder_State *st;                       /* used for bitstream handling */
    float *p_output[MAX_TRANSPORT_CHANNELS]; /* 'float' buffer for output synthesis */
#ifndef NONBE_UNIFIED_DECODING_PATHS_FIX
    float output_f[MAX_TRANSPORT_CHANNELS][L_FRAME48k]; /* TODO: can be allocated dynamically using st_ivas->p_output_f */
#endif
    int16_t nchan_remapped;
    int16_t nb_bits_metadata[MAX_SCE + 1];
    int32_t output_Fs, ivas_total_brate;
@@ -97,7 +99,11 @@ ivas_error ivas_jbm_dec_tc(

    for ( n = 0; n < MAX_TRANSPORT_CHANNELS; n++ )
    {
#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX
        p_output[n] = st_ivas->p_output_f[n];
#else
        p_output[n] = output_f[n];
#endif
    }

    /*----------------------------------------------------------------*
@@ -935,7 +941,9 @@ ivas_error ivas_jbm_dec_render(
{
    int16_t n, nchan_out;
    int16_t nchan_transport;
#ifndef NONBE_UNIFIED_DECODING_PATHS_FIX
    float output[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k]; /* 'float' buffer for output synthesis */
#endif
    int16_t nchan_remapped;
    int32_t output_Fs;
    AUDIO_CONFIG output_config;
@@ -960,10 +968,13 @@ ivas_error ivas_jbm_dec_render(
    output_config = st_ivas->hDecoderConfig->output_config;
    nSamplesAskedLocal = nSamplesAsked + st_ivas->hTcBuffer->n_samples_discard;


    for ( n = 0; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ )
    {
#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX
        p_output[n] = st_ivas->p_output_f[n];
#else
        p_output[n] = &output[n][0];
#endif
    }

    for ( n = 0; n < st_ivas->hTcBuffer->nchan_buffer_full; n++ )
@@ -1257,11 +1268,19 @@ ivas_error ivas_jbm_dec_render(
#endif
                for ( n = st_ivas->hIntSetup.nchan_out_woLFE - 1; n >= 0; n-- )
                {
#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX
                    mvr2r( p_output[n], p_output[n + st_ivas->nchan_ism], *nSamplesRendered );
#else
                    mvr2r( output[n], output[n + st_ivas->nchan_ism], *nSamplesRendered );
#endif
                }
                for ( n = 0; n < st_ivas->nchan_ism; n++ )
                {
#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX
                    set_zero( p_output[n], *nSamplesRendered );
#else
                    set_zero( output[n], *nSamplesRendered );
#endif
                }
            }
        }
@@ -1296,16 +1315,13 @@ ivas_error ivas_jbm_dec_render(
                else
                {
#endif

#if ( defined NONBE_UNIFIED_DECODING_PATHS && defined SPLIT_REND_WITH_HEAD_ROT )
                    if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData,
                                                                   &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs, 0 ) ) != IVAS_ERR_OK )
#else
                if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData,
                                                               &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK )

#endif

                    {
                        return error;
                    }
@@ -1423,15 +1439,24 @@ ivas_error ivas_jbm_dec_render(
                    /* we still need to copy the separate channel if available  */
                    if ( st_ivas->hOutSetup.separateChannelEnabled )
                    {
#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX
                        mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, p_output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered );
#else
                        mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered );
#endif
                    }

                    ivas_mc2sba( st_ivas->hIntSetup, p_output, p_output, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0.f );
                }
                else if ( st_ivas->intern_config == IVAS_AUDIO_CONFIG_5_1 && ( output_config == IVAS_AUDIO_CONFIG_5_1_2 || output_config == IVAS_AUDIO_CONFIG_5_1_4 || output_config == IVAS_AUDIO_CONFIG_7_1 ) )
                {
                    for ( n = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; n < st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; n++ )
                    {
#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX
                        set_zero( p_output[n], *nSamplesRendered );
#else
                        set_zero( output[n], *nSamplesRendered );
#endif
                    }
                }
            }
@@ -1443,13 +1468,22 @@ ivas_error ivas_jbm_dec_render(
                     output_config == IVAS_AUDIO_CONFIG_5_1_4 || output_config == IVAS_AUDIO_CONFIG_7_1_4 ||
                     output_config == IVAS_AUDIO_CONFIG_5_1_2 || ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.num_lfe > 0 ) )
                {
#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX
                    mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL] + offset, p_output[LFE_CHANNEL], *nSamplesRendered );
                    mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, p_output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered );
#else
                    mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL] + offset, output[LFE_CHANNEL], *nSamplesRendered );
                    mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered );
#endif
                }
                else if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.num_lfe == 0 )
                {
                    /* Delay the separated channel to sync with the DirAC rendering */
#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX
                    mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, p_output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered );
#else
                    mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered );
#endif
                }
            }
        }
@@ -2069,7 +2103,16 @@ int16_t ivas_jbm_dec_get_num_tc_channels(
    output_config = st_ivas->hDecoderConfig->output_config;

    ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;

#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX
    if ( st_ivas->ivas_format == MONO_FORMAT )
    {
        num_tc = st_ivas->hDecoderConfig->nchan_out;
    }
    else if ( st_ivas->ivas_format == STEREO_FORMAT && st_ivas->hDecoderConfig->nchan_out == 1 )
#else
    if ( st_ivas->ivas_format == STEREO_FORMAT && st_ivas->hDecoderConfig->nchan_out == 1 )
#endif
    {
        num_tc = 1;
    }
+1 −1
Original line number Diff line number Diff line
@@ -1010,7 +1010,7 @@ typedef struct decoder_config_structure
    /* temp. development parameters */
    int16_t force_rend; /* forced TD/CLDFB binaural renderer (for ISM and MC) */
#endif
    int16_t Opt_tsm;
    int16_t Opt_tsm; /* indicates whether time scaling modification is activated */
#ifdef SPLIT_REND_WITH_HEAD_ROT
    int16_t Opt_Limiter;
#endif
+26 −9
Original line number Diff line number Diff line
@@ -973,7 +973,7 @@ ivas_error IVAS_DEC_GetSamples(
)
{
    ivas_error error;
    int16_t nOutSamplesElse, result, nSamplesToRender;
    int16_t nOutSamplesElse, nSamplesToRender;
    uint16_t nSamplesRendered, nSamplesRendered_loop, l_ts, nTimeScalerOutSamples;
    uint8_t nTransportChannels, nOutChannels;

@@ -1088,7 +1088,11 @@ ivas_error IVAS_DEC_GetSamples(
                int16_t nResidualSamples, nSamplesTcsScaled;
                nSamplesRendered += nSamplesRendered_loop;

#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX
                if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && nTransportChannels != hIvasDec->nTransportChannelsOld )
#else
                if ( nTransportChannels != hIvasDec->nTransportChannelsOld )
#endif
                {
                    if ( ( error = IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ) ) != IVAS_ERR_OK )
                    {
@@ -1096,32 +1100,34 @@ ivas_error IVAS_DEC_GetSamples(
                    }
                }

                /* decode TCs only */
                /* IVAS decoder */
                if ( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer, &nOutSamplesElse ) ) != IVAS_ERR_OK )
                {
                    return error;
                }

                /* JBM */
                if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm )
                {
                    if ( apa_set_scale( hIvasDec->hTimeScaler, hIvasDec->tsm_scale ) != 0 )
                    {
                        return IVAS_ERR_UNKNOWN;
                    }
                    result = apa_exec( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer, hIvasDec->nSamplesFrame * nTransportChannels, (uint16_t) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer, &nTimeScalerOutSamples );
                    if ( result != 0 )

                    if ( apa_exec( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer, hIvasDec->nSamplesFrame * nTransportChannels, (uint16_t) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer, &nTimeScalerOutSamples ) != 0 )
                    {
                        return IVAS_ERR_UNKNOWN;
                    }

                    assert( nTimeScalerOutSamples <= APA_BUF );
                    nSamplesTcsScaled = nTimeScalerOutSamples / nTransportChannels;
                }
                else
                {
                    nTimeScalerOutSamples = hIvasDec->nSamplesFrame * nTransportChannels;
                    nSamplesTcsScaled = hIvasDec->nSamplesFrame;
                }
                nSamplesTcsScaled = nTimeScalerOutSamples / nTransportChannels;

                /* render IVAS frames  */
                /* IVAS renderer  */
                if ( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer ) ) != IVAS_ERR_OK )
                {
                    return error;
@@ -3133,8 +3139,19 @@ static ivas_error printConfigInfo_dec(

        get_channel_config( st_ivas->hDecoderConfig->output_config, &config_str[0] );
        fprintf( stdout, "Output configuration:   %s\n", config_str );

#ifdef NONBE_UNIFIED_DECODING_PATHS
#ifdef NONBE_UNIFIED_DECODING_PATHS_FIX
        AUDIO_CONFIG output_config = st_ivas->hDecoderConfig->output_config;
#ifdef SPLIT_REND_WITH_HEAD_ROT
        if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
#else
        if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
#endif
#endif
        {
            fprintf( stdout, "Render framesize:       %dms\n", get_render_frame_size_ms( st_ivas->hDecoderConfig->render_framesize ) );
        }
#endif
        if ( st_ivas->hDecoderConfig->Opt_HRTF_binary )
        {
Loading