Commit 3dd980c3 authored by vaclav's avatar vaclav
Browse files

Merge branch '1454-buggy-stereo-to-foa-in-jbm' into 'main'

[non-BE] [allow regression] Port MR2290 from float - Resolve "Buggy stereo to FOA in JBM"

Closes #2246

See merge request !2606
parents 938bcae7 960a4000
Loading
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -133,7 +133,6 @@ typedef struct
    bool applyPiData;
    char *piOutputFilename;
    bool rtpOutSR;
    bool evsMode;
    IVAS_ROOM_SIZE_T roomSize;

} DecArguments;
@@ -884,7 +883,6 @@ static bool parseCmdlIVAS_dec(
    arg->output_Fs = IVAS_MAX_SAMPLING_RATE;
    arg->outputConfig = IVAS_AUDIO_CONFIG_MONO;
    arg->decMode = IVAS_DEC_MODE_IVAS;
    arg->evsMode = false;
    arg->quietModeEnabled = false;
    arg->delayCompensationEnabled = true;
    arg->voipMode = false;
@@ -1378,7 +1376,6 @@ static bool parseCmdlIVAS_dec(
        }
        else if ( strcmp( argv_to_upper, "-EVS" ) == 0 )
        {
            arg->evsMode = true;
            arg->decMode = IVAS_DEC_MODE_EVS;
            i++;
        }
@@ -1469,7 +1466,7 @@ static bool parseCmdlIVAS_dec(
            usage_dec();
            return false;
        }
        else if ( arg->non_diegetic_pan_enabled && arg->outputConfig == IVAS_AUDIO_CONFIG_STEREO && arg->evsMode )
        else if ( arg->non_diegetic_pan_enabled && arg->outputConfig == IVAS_AUDIO_CONFIG_STEREO && arg->decMode == IVAS_DEC_MODE_EVS )
        {
            fprintf( stderr, "Error: Both non-diegetic panning and stereo output specified!\n\n" );
            usage_dec();
+9 −3
Original line number Diff line number Diff line
@@ -1126,8 +1126,8 @@ void ivas_mono_stereo_downmix_mcmasa_fx(
);

void ivas_apply_non_diegetic_panning_fx(
    Word32 *input_f_fx,                                         /* i  : non-diegetic object                              */
    Word32 *output_fx[],                                        /* i/o: core-coder transport mono channel/stereo output  */
    Word32 *input_f_fx,                                         /* i  : non-diegetic object (mono channel)               */
    Word32 *output_fx[],                                        /* o  : stereo output channels                           */
    const Word16 non_diegetic_pan_gain_fx,                      /* i  : non-diegetic panning gain                        */
    const Word16 output_frame                                   /* i  : output frame length per channel                  */
);
@@ -3733,6 +3733,12 @@ void ivas_mc2sba_fx(
    const Word16 gain_lfe                                       /* i  : gain for LFE, 0 = ignore LFE                     */
);

void ivas_stereo2sba_fx(
    Word32 *input_fx[],                                         /* i  : core-coder transport stereo channels            */
    Word32 *output_fx[],                                        /* o  : SBA output channels                             */
    const Word16 output_frame                                   /* i  : output frame length per channel                 */
);

void ivas_param_mc_mc2sba_cldfb_fx(
    IVAS_OUTPUT_SETUP hTransSetup,                                                 /* i  : transported MC Format                                       */
    Word32 *hoa_encoder,                                                           /* i  : HOA3 encoder for the transported MC format                  */
@@ -3885,6 +3891,7 @@ void ivas_set_ism_importance_interformat_fx(
    const Word16 lp_noise_CPE_fx,                               /* i  : LP filtered total noise estimation          */
    Word16 ism_imp[]                                            /* o  : ISM importance flags                        */
);

void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx(
    Decoder_Struct *st_ivas,
    Word32 inRe_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*cldfb_buf_q*/
@@ -3894,7 +3901,6 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx(
    const Word16 subframe
);


void ivas_omasa_decode_masa_to_total_fx(
    UWord16 *bit_stream,
    Word16 *index,
+3 −1
Original line number Diff line number Diff line
@@ -84,13 +84,15 @@
#define FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK       /* Eri: Issue 1999: Range check on float values of distance attenuation, while the float values are not propagated to this function. The test is not correct, but configurable distance attenuation is not used in Characterization.*/
#define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR      /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */
#define NONBE_1122_KEEP_EVS_MODE_UNCHANGED              /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR.  */

#define FIX_1435_MOVE_STEREO_PANNING                    /* VA: issue 1435: do the EVS stereo panning in the renderer */

/* #################### End BE switches ################################## */

/* #################### Start NON-BE switches ############################ */
/* any switch which is non-be wrt. TS 26.251 V3.0 */

#define FIX_1454_FIX_STEREO_TO_FOA_JBM                  /* VA: issue 1454: fix buggy stereo to FOA in JBM */



/* ##################### End NON-BE switches ########################### */
+4 −8
Original line number Diff line number Diff line
@@ -1139,6 +1139,7 @@ ivas_error ivas_dec_setup(
     * Initialize decoder in the first good frame based on IVAS format
     * and number of transport channels
     *-------------------------------------------------------------------*/

    test();
    IF( st_ivas->ini_frame == 0 && NE_32( st_ivas->ivas_format, UNDEFINED_FORMAT ) )
    {
@@ -1582,7 +1583,6 @@ ivas_error ivas_init_decoder_front(
     * Allocate and initialize Binaural Renderer configuration handle
     *--------------------------------------------------------------------*/


    test();
    test();
    test();
@@ -1729,12 +1729,6 @@ ivas_error ivas_init_decoder_fx(
        move16();
    }

    test();
    IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) || EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) )
    {
        st_ivas->transport_config = EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ? IVAS_AUDIO_CONFIG_MONO : IVAS_AUDIO_CONFIG_STEREO;
    }

    /* Only initialize transport setup if it is used */
    IF( NE_32( st_ivas->transport_config, IVAS_AUDIO_CONFIG_INVALID ) )
    {
@@ -1900,6 +1894,9 @@ ivas_error ivas_init_decoder_fx(
    {
        st_ivas->nchan_transport = CPE_CHANNELS;
        move16();
        st_ivas->intern_config = IVAS_AUDIO_CONFIG_STEREO;
        move32();

        st_ivas->nSCE = 0;
        move16();
        st_ivas->nCPE = 1; /* in stereo, there is always only one CPE */
@@ -3966,7 +3963,6 @@ static ivas_error doSanityChecks_IVAS(
        return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified!" );
    }


    test();
    test();
    IF( ( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) && NE_32( output_Fs, 48000 ) )
+35 −31
Original line number Diff line number Diff line
@@ -1719,6 +1719,11 @@ ivas_error ivas_jbm_dec_render_fx(
    /*----------------------------------------------------------------*
     * Rendering
     *----------------------------------------------------------------*/

    *nSamplesRendered = s_min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal );
    move16();

    test();
    test();
    IF( EQ_32( st_ivas->ivas_format, UNDEFINED_FORMAT ) )
    {
@@ -1726,6 +1731,7 @@ ivas_error ivas_jbm_dec_render_fx(
    }
    ELSE IF( EQ_32( st_ivas->hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_BUFFER ) )
    {
#ifndef FIX_1435_MOVE_STEREO_PANNING
        Word16 slot_size, tmp, e;

        slot_size = st_ivas->hTcBuffer->n_samples_granularity;
@@ -1734,36 +1740,29 @@ ivas_error ivas_jbm_dec_render_fx(
        /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */
        tmp = BASOP_Util_Divide1616_Scale( nSamplesAsked, slot_size, &e );
        tmp = shr( tmp, sub( 15, e ) );

#endif
        ivas_jbm_dec_tc_buffer_playout_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output_fx );
    }
    ELSE IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) || EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) )
    {
        *nSamplesRendered = s_min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal );
        move16();

        /* Rendering */
        IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) )
        {
            ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, *nSamplesRendered, p_tc_fx, p_output_fx );
        }
        ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) )
        {
            IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) )
#ifdef FIX_1435_MOVE_STEREO_PANNING
        ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) )
        {
                /* routed to W */
                ivas_jbm_dec_tc_buffer_playout_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output_fx );
            ivas_apply_non_diegetic_panning_fx( p_tc_fx[0], p_output_fx, st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx, *nSamplesRendered );
        }
            ELSE IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) )
            {
                FOR( n = 0; n < *nSamplesRendered; n++ )
#endif
        ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) )
        {
                    Word32 tmp;
                    tmp = p_output_fx[0][n];
                    p_output_fx[0][n] = L_shr( L_add( tmp, p_output_fx[1][n] ), 1 ); /* W = 0.5 * ( L + R ) */
                    p_output_fx[1][n] = L_shr( L_sub( tmp, p_output_fx[1][n] ), 1 ); /* Y = 0.5 * ( L - R ) */
                }
            }
#ifdef FIX_1454_FIX_STEREO_TO_FOA_JBM
            ivas_stereo2sba_fx( p_tc_fx, p_output_fx, *nSamplesRendered );
#else
            ivas_stereo2sba_fx( p_output_fx, p_output_fx, *nSamplesRendered );
#endif
        }
    }
    ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) )
@@ -1791,9 +1790,6 @@ ivas_error ivas_jbm_dec_render_fx(
        }
        ELSE /* ISM_MODE_DISC */
        {
            *nSamplesRendered = s_min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal );
            move16();

            test();
            test();
            /* Loudspeaker or Ambisonics rendering */
@@ -1974,9 +1970,6 @@ ivas_error ivas_jbm_dec_render_fx(
            }
            ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_OSBA_STEREO ) )
            {
                *nSamplesRendered = s_min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal );
                move16();

                test();
                /* shift SBA channels to avoid overwrite by ISM upmix in 1 object case and non-TSM unified channel memory*/
                IF( EQ_16( st_ivas->nchan_ism, 1 ) && EQ_16( st_ivas->hDecoderConfig->Opt_tsm, 0 ) )
@@ -2059,8 +2052,6 @@ ivas_error ivas_jbm_dec_render_fx(
        {
            Word16 crendInPlaceRotation = FALSE;
            move16();
            *nSamplesRendered = s_min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal );
            move16();

            test();
            test();
@@ -2155,9 +2146,6 @@ ivas_error ivas_jbm_dec_render_fx(
            }
            ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) )
            {
                *nSamplesRendered = s_min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal );
                move16();

                ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, *nSamplesRendered, p_tc_fx, p_output_fx );
            }
            ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) )
@@ -3084,7 +3072,6 @@ Word16 ivas_jbm_dec_get_num_tc_channels_fx(
    Word32 ivas_total_brate;
    AUDIO_CONFIG output_config;


    IF( EQ_16( st_ivas->renderer_type, RENDERER_DISABLE ) )
    {
        num_tc = st_ivas->hDecoderConfig->nchan_out;
@@ -3104,7 +3091,17 @@ Word16 ivas_jbm_dec_get_num_tc_channels_fx(
    test();
    test();
    test();
#ifdef FIX_1435_MOVE_STEREO_PANNING
    test();
    IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) )
    {
        num_tc = 1;
        move16();
    }
    ELSE IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) && EQ_16( st_ivas->hDecoderConfig->nchan_out, 1 ) )
#else
    IF( EQ_16( st_ivas->ivas_format, STEREO_FORMAT ) && EQ_16( st_ivas->hDecoderConfig->nchan_out, 1 ) )
#endif
    {
        num_tc = 1;
        move16();
@@ -3246,11 +3243,13 @@ Word16 ivas_jbm_dec_get_num_tc_channels_fx(
            }
        }
    }
#ifndef FIX_1435_MOVE_STEREO_PANNING
    ELSE IF( EQ_16( st_ivas->ivas_format, MONO_FORMAT ) && EQ_16( st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) )
    {
        num_tc = MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN;
        move16();
    }
#endif

    return num_tc;
}
@@ -3776,6 +3775,9 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode_fx(
            buffer_mode = TC_BUFFER_MODE_BUFFER;
            move16();
            BREAK;
#ifdef FIX_1435_MOVE_STEREO_PANNING
        case RENDERER_NON_DIEGETIC_DOWNMIX:
#endif
        case RENDERER_TD_PANNING:
        case RENDERER_BINAURAL_OBJECTS_TD:
        case RENDERER_BINAURAL_FASTCONV:
@@ -3794,6 +3796,7 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode_fx(
            buffer_mode = TC_BUFFER_MODE_RENDERER;
            move16();
            BREAK;
#ifndef FIX_1435_MOVE_STEREO_PANNING
        case RENDERER_NON_DIEGETIC_DOWNMIX:
            IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) )
            {
@@ -3806,6 +3809,7 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode_fx(
                move16();
            }
            break;
#endif
        case RENDERER_MC_PARAMMC:
            IF( EQ_32( st_ivas->hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) )
            {
Loading