Commit b8e0d5b9 authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

Merge branch '2188_basop_port_mr-2346' into 'main'

[main] Port MR 2346 from float: [non-spatial] Resolve "Enable rendering to all output formats for EVS mono and IVAS Stereo bitstreams"

See merge request !2512
parents f4e8657d ce2dc1c3
Loading
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -129,6 +129,9 @@ typedef struct
    uint16_t directivityPatternId[IVAS_MAX_NUM_OBJECTS];
    bool objEditEnabled;
    char *objEditFileName;
#ifdef FIX_1419_MONO_STEREO_UMX
    bool evsMode;
#endif

} DecArguments;

@@ -834,6 +837,9 @@ static bool parseCmdlIVAS_dec(
    arg->output_Fs = IVAS_MAX_SAMPLING_RATE;
    arg->outputConfig = IVAS_AUDIO_CONFIG_MONO;
    arg->decMode = IVAS_DEC_MODE_IVAS;
#ifdef FIX_1419_MONO_STEREO_UMX
    arg->evsMode = false;
#endif
    arg->quietModeEnabled = false;
    arg->delayCompensationEnabled = true;
    arg->voipMode = false;
@@ -1360,6 +1366,14 @@ static bool parseCmdlIVAS_dec(
            }
            i++;
        }
#ifdef FIX_1419_MONO_STEREO_UMX
        else if ( strcmp( argv_to_upper, "-EVS" ) == 0 )
        {
            arg->evsMode = true;
            arg->decMode = IVAS_DEC_MODE_EVS;
            i++;
        }
#endif

        /*-----------------------------------------------------------------*
         * Option not recognized
@@ -1410,6 +1424,15 @@ static bool parseCmdlIVAS_dec(
            usage_dec();
            return false;
        }
#ifdef FIX_1419_MONO_STEREO_UMX
        else if ( arg->non_diegetic_pan_enabled && arg->outputConfig == IVAS_AUDIO_CONFIG_STEREO && arg->evsMode )
        {
            fprintf( stderr, "Error: Both non-diegetic panning and stereo output specified!\n\n" );
            usage_dec();
            return false;
        }

#endif
        if ( arg->outputMdFilename != NULL && arg->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
        {
            fprintf( stderr, "Error: Output split rendering metadata file is supported for BINAURAL_SPLIT_PCM output config. only\n\n" );
@@ -1501,6 +1524,9 @@ static bool parseCmdlIVAS_dec(
static void usage_dec( void )
{
    fprintf( stdout, "Usage for EVS:   IVAS_dec.exe [Options] Fs bitstream_file output_file\n" );
#ifdef FIX_1419_MONO_STEREO_UMX
    fprintf( stdout, "                 OR usage for IVAS (below) with -evs option and OutputConf\n" );
#endif
    fprintf( stdout, "Usage for IVAS:  IVAS_dec.exe [Options] OutputConf Fs bitstream_file output_file\n\n" );

    fprintf( stdout, "Mandatory parameters:\n" );
@@ -1517,6 +1543,9 @@ static void usage_dec( void )

    fprintf( stdout, "Options:\n" );
    fprintf( stdout, "--------\n" );
#ifdef FIX_1419_MONO_STEREO_UMX
    fprintf( stdout, "-evs                : Specify that the supplied bitstream is an EVS bitstream\n" );
#endif
    fprintf( stdout, "-VOIP               : VoIP mode: RTP in G192\n" );
    fprintf( stdout, "-VOIP_hf_only=0     : VoIP mode: EVS RTP Payload Format hf_only=0 in rtpdump\n" );
    fprintf( stdout, "-VOIP_hf_only=1     : VoIP mode: EVS RTP Payload Format hf_only=1 in rtpdump\n" );
+4 −0
Original line number Diff line number Diff line
@@ -1295,7 +1295,11 @@ typedef enum
 *----------------------------------------------------------------------------------*/

#define MC_LS_SETUP_BITS                        3                           /* number of bits for writing the MC LS configuration */
#ifdef FIX_1419_MONO_STEREO_UMX
#define LS_SETUP_CONVERSION_NUM_MAPPINGS        41                          /* number of mappings for LS setup conversion         */
#else
#define LS_SETUP_CONVERSION_NUM_MAPPINGS        35                          /* number of mappings for LS setup conversion         */
#endif

typedef enum
{
+1 −0
Original line number Diff line number Diff line
@@ -139,6 +139,7 @@
#define FIX_1330_JBM_MEMORY                             /* VA: issue 1330: memory savings in the JBM decoder */
#define FIX_1330_JBM_MEMORY_FIX                         /* VA: basop issue: 2179 fix non-BE difference in FIX_1330_JBM_MEMORY */
#define FIX_1411_IGF_CRASH_BW_SWITCHING                 /* FhG: Fix for issue 1411: fixes crash that can happen for IGF with BW switching and DTX*/
#define FIX_1419_MONO_STEREO_UMX                        /* FhG: fix for issue 1419 : support upmix to all output formats for mono and stereo */
#define NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG       /* FhG: Fix MDCT-Stereo comfort noise for certain noise types */
#define NONBE_1344_REND_MASA_LOW_FS                     /* Nokia: Issue 1344: Fix sanitizer errors when using IVAS_rend to render MASA with lower sampling rates */
#define NONBE_1412_AVOID_ROUNDING_AZ_ELEV               /* FhG:  Avoid rounding when passing azimuth and elevation to efap_determine_gains() */
+49 −1
Original line number Diff line number Diff line
@@ -1531,7 +1531,16 @@ ivas_error ivas_init_decoder_fx(
    IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
    {
        test();
#ifdef FIX_1419_MONO_STEREO_UMX
        IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) )
        {
            hDecoderConfig->nchan_out = 1;
            move16();
        }
        ELSE IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) )
#else
        IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) )
#endif
        {
            hDecoderConfig->nchan_out = CPE_CHANNELS;
        }
@@ -1598,6 +1607,14 @@ ivas_error ivas_init_decoder_fx(
        st_ivas->hOutSetup.nchan_out_woLFE = audioCfg2channels( st_ivas->intern_config );
        move16();
    }
#ifdef FIX_1419_MONO_STEREO_UMX

    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;
    }
#endif

    /* Only initialize transport setup if it is used */
    IF( NE_32( st_ivas->transport_config, IVAS_AUDIO_CONFIG_INVALID ) )
@@ -1705,8 +1722,10 @@ ivas_error ivas_init_decoder_fx(
    {
        st_ivas->nchan_transport = CPE_CHANNELS;
        move16();
#ifndef FIX_1419_MONO_STEREO_UMX /* already set now by renderer_select() */
        st_ivas->intern_config = IVAS_AUDIO_CONFIG_STEREO;
        move32();
#endif

        st_ivas->nSCE = 0;
        move16();
@@ -2832,7 +2851,8 @@ ivas_error ivas_init_decoder_fx(
    }

    /*-----------------------------------------------------------------*
     * LFE handles for rendering after rendering to adjust LFE delay to filter delay
     * LFE handles for rendering after rendering to adjust LFE delay to
     * filter delay
     *-----------------------------------------------------------------*/

    test();
@@ -3766,6 +3786,7 @@ static ivas_error doSanityChecks_IVAS(
        return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Error: Non-diegetic panning not supported in this IVAS format" );
    }

#ifndef FIX_1419_MONO_STEREO_UMX /* we now support basically everything for stereo */
    /* Verify stereo output configuration */
    IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) )
    {
@@ -3786,10 +3807,37 @@ static ivas_error doSanityChecks_IVAS(
    ELSE
    {
        IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_INVALID ) )
#else /* exclude invalid configs instead of matching valid ones */
    test();
    test();
    test();
    test();
    test();
    test();
    IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_INVALID ) ||
        EQ_32( output_config, IVAS_AUDIO_CONFIG_ISM1 ) ||
        EQ_32( output_config, IVAS_AUDIO_CONFIG_ISM2 ) ||
        EQ_32( output_config, IVAS_AUDIO_CONFIG_ISM3 ) ||
        EQ_32( output_config, IVAS_AUDIO_CONFIG_ISM4 ) ||
        EQ_32( output_config, IVAS_AUDIO_CONFIG_MASA1 ) ||
        EQ_32( output_config, IVAS_AUDIO_CONFIG_MASA2 ) )
#endif
        {
            return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified!" );
        }
#ifdef FIX_1419_MONO_STEREO_UMX
        test();
        test();
        IF( ( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) || EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) &&
            ( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) )
        {
            return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified!" );
        }
#endif
#ifndef FIX_1419_MONO_STEREO_UMX
    }
#endif


    test();
    test();
+39 −0
Original line number Diff line number Diff line
@@ -1815,16 +1815,47 @@ ivas_error ivas_jbm_dec_render_fx(

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

        /* Rendering */
        IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) )
        {
#ifndef FIX_1419_MONO_STEREO_UMX
            *nSamplesRendered = s_min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal );
            move16();
#endif

            ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, *nSamplesRendered, p_tc_fx, p_output_fx );
        }
#ifdef FIX_1419_MONO_STEREO_UMX
        ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) )
        {
            IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) )
            {
                /* routed to W */
                ivas_jbm_dec_tc_buffer_playout_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output_fx );
            }
            ELSE IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) )
            {
                FOR( n = 0; n < *nSamplesRendered; n++ )
                {
                    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 ) */
                }
            }
        }
#endif /* FIX_1419_MONO_STEREO_UMX */
    }
    ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) )
    {
@@ -3227,12 +3258,16 @@ Word16 ivas_jbm_dec_get_num_tc_channels_fx(
    test();
    test();
    test();
#ifndef FIX_1419_MONO_STEREO_UMX /* since we support more output formats for mono, this is no longer sensible; leave it at the default from above */
    IF( EQ_16( st_ivas->ivas_format, MONO_FORMAT ) )
    {
        num_tc = st_ivas->hDecoderConfig->nchan_out;
        move16();
    }
    ELSE IF( EQ_16( 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();
@@ -4437,7 +4472,11 @@ void ivas_dec_prepare_renderer_fx(
            ivas_omasa_gain_masa_tc_fx( st_ivas->hTcBuffer->tc_fx, st_ivas->hMasaIsmData->gain_masa_edited_fx, st_ivas->nchan_ism, st_ivas->hTcBuffer->n_samples_available );
        }
    }
#ifdef FIX_1419_MONO_STEREO_UMX
    ELSE IF( EQ_16( st_ivas->ivas_format, MONO_FORMAT ) || EQ_16( st_ivas->ivas_format, STEREO_FORMAT ) )
#else
    ELSE IF( EQ_16( st_ivas->ivas_format, STEREO_FORMAT ) )
#endif
    {
        ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas );
    }
Loading