Commit 9d01b941 authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

port MR 2346 from float: FIX_1419_MONO_STEREO_UMX

parent 636b5563
Loading
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -144,6 +144,9 @@ typedef struct
    uint16_t directivityPatternId[IVAS_MAX_NUM_OBJECTS];
    bool objEditEnabled;
    char *objEditFileName;
#ifdef FIX_1419_MONO_STEREO_UMX
    bool evsMode;
#endif

} DecArguments;

@@ -953,6 +956,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;
@@ -1537,6 +1543,15 @@ 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
@@ -1678,6 +1693,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" );
@@ -1694,6 +1712,10 @@ 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
@@ -1256,7 +1256,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
@@ -196,6 +196,7 @@
#define NONBE_1362_FIX_OMASA_TO_MASA1_RENDERING         /* Nokia: Fix OMASA to MASA1 rendering in IVAS_rend */
#define FIX_1383_HEAD_TRACK_SANITIZER                   /* Nok: issue 1383: Fix head tracking struc values reading in renderer */
#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() */
+47 −5
Original line number Diff line number Diff line
@@ -1286,7 +1286,15 @@ ivas_error ivas_init_decoder(

    if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL )
    {
#ifdef FIX_1419_MONO_STEREO_UMX
        if ( st_ivas->ivas_format == MONO_FORMAT )
        {
            hDecoderConfig->nchan_out = 1;
        }
        else if ( st_ivas->ivas_format == STEREO_FORMAT )
#else
        if ( st_ivas->ivas_format == STEREO_FORMAT )
#endif
        {
            hDecoderConfig->nchan_out = CPE_CHANNELS;
        }
@@ -1339,6 +1347,13 @@ ivas_error ivas_init_decoder(
        st_ivas->hOutSetup.output_config = st_ivas->intern_config;
        st_ivas->hOutSetup.nchan_out_woLFE = audioCfg2channels( st_ivas->intern_config );
    }
#ifdef FIX_1419_MONO_STEREO_UMX

    if ( st_ivas->ivas_format == MONO_FORMAT || st_ivas->ivas_format == STEREO_FORMAT )
    {
        st_ivas->transport_config = ( st_ivas->ivas_format == MONO_FORMAT ) ? IVAS_AUDIO_CONFIG_MONO : IVAS_AUDIO_CONFIG_STEREO;
    }
#endif

    /* Only initialize transport setup if it is used */
    if ( st_ivas->transport_config != IVAS_AUDIO_CONFIG_INVALID )
@@ -1421,7 +1436,9 @@ ivas_error ivas_init_decoder(
    else if ( st_ivas->ivas_format == STEREO_FORMAT )
    {
        st_ivas->nchan_transport = CPE_CHANNELS;
#ifndef FIX_1419_MONO_STEREO_UMX /* already set now by renderer_select() */
        st_ivas->intern_config = IVAS_AUDIO_CONFIG_STEREO;
#endif

        st_ivas->nSCE = 0;
        st_ivas->nCPE = 1; /* in stereo, there is always only one CPE */
@@ -2309,7 +2326,8 @@ ivas_error ivas_init_decoder(
    }

    /*-----------------------------------------------------------------*
     * 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
     *-----------------------------------------------------------------*/

    if ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX )
@@ -3165,6 +3183,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 ( st_ivas->ivas_format == STEREO_FORMAT )
    {
@@ -3173,7 +3192,30 @@ static ivas_error doSanityChecks_IVAS(
            return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Wrong output configuration specified for Stereo!" );
        }
    }
    if ( output_config != IVAS_AUDIO_CONFIG_MONO && output_config != IVAS_AUDIO_CONFIG_STEREO && output_config != IVAS_AUDIO_CONFIG_5_1 && output_config != IVAS_AUDIO_CONFIG_7_1 && output_config != IVAS_AUDIO_CONFIG_5_1_2 && output_config != IVAS_AUDIO_CONFIG_5_1_4 && output_config != IVAS_AUDIO_CONFIG_7_1_4 && output_config != IVAS_AUDIO_CONFIG_LS_CUSTOM && output_config != IVAS_AUDIO_CONFIG_EXTERNAL )
    /* Verify output configuration for other formats */
    else
    {
        if ( output_config == IVAS_AUDIO_CONFIG_INVALID )
#else /* exclude invalid configs instead of matching valid ones */
    if ( output_config == IVAS_AUDIO_CONFIG_INVALID ||
         output_config == IVAS_AUDIO_CONFIG_ISM1 ||
         output_config == IVAS_AUDIO_CONFIG_ISM2 ||
         output_config == IVAS_AUDIO_CONFIG_ISM3 ||
         output_config == IVAS_AUDIO_CONFIG_ISM4 ||
         output_config == IVAS_AUDIO_CONFIG_MASA1 ||
         output_config == IVAS_AUDIO_CONFIG_MASA2 )
#endif
        {
            return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified!" );
        }
        if ( ( st_ivas->ivas_format == MONO_FORMAT || st_ivas->ivas_format == STEREO_FORMAT ) &&
             ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
        {
            return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified!" );
        }
#ifndef FIX_1419_MONO_STEREO_UMX
    }
#endif

    if ( ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) && output_Fs != 48000 )
    {
+38 −0
Original line number Diff line number Diff line
@@ -1003,14 +1003,44 @@ ivas_error ivas_jbm_dec_render(
    {
        ivas_jbm_dec_tc_buffer_playout( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output );
    }
#ifdef FIX_1419_MONO_STEREO_UMX
    else if ( st_ivas->ivas_format == MONO_FORMAT || st_ivas->ivas_format == STEREO_FORMAT )
#else
    else if ( st_ivas->ivas_format == STEREO_FORMAT )
#endif
    {
#ifdef FIX_1419_MONO_STEREO_UMX
        *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal );
#endif

        /* Rendering */
        if ( st_ivas->renderer_type == RENDERER_MC )
        {
#ifndef FIX_1419_MONO_STEREO_UMX
            *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal );
#endif
            ivas_ls_setup_conversion( st_ivas, st_ivas->nchan_transport, *nSamplesRendered, p_tc, p_output );
        }
#ifdef FIX_1419_MONO_STEREO_UMX
        else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC )
        {
            if ( st_ivas->ivas_format == MONO_FORMAT )
            {
                /* routed to W */
                ivas_jbm_dec_tc_buffer_playout( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output );
            }
            else if ( st_ivas->ivas_format == STEREO_FORMAT )
            {
                for ( n = 0; n < *nSamplesRendered; n++ )
                {
                    float tmp;
                    tmp = p_output[0][n];
                    p_output[0][n] = 0.5f * ( tmp + p_output[1][n] ); /* W = 0.5 * ( L + R ) */
                    p_output[1][n] = 0.5f * ( tmp - p_output[1][n] ); /* Y = 0.5 * ( L - R ) */
                }
            }
        }
#endif /* FIX_1419_MONO_STEREO_UMX */
    }
    else if ( st_ivas->ivas_format == ISM_FORMAT )
    {
@@ -2027,11 +2057,15 @@ int16_t ivas_jbm_dec_get_num_tc_channels(

    ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;

#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 ( 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;
    }
@@ -3070,7 +3104,11 @@ void ivas_dec_prepare_renderer(
            ivas_omasa_gain_masa_tc( st_ivas->hTcBuffer->tc, st_ivas->hMasaIsmData->gain_masa_edited, st_ivas->nchan_ism, st_ivas->hTcBuffer->n_samples_available );
        }
    }
#ifdef FIX_1419_MONO_STEREO_UMX
    else if ( st_ivas->ivas_format == MONO_FORMAT || st_ivas->ivas_format == STEREO_FORMAT )
#else
    else if ( st_ivas->ivas_format == STEREO_FORMAT )
#endif
    {
        ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas );
    }
Loading