Commit 32c876e9 authored by Lauros Pajunen's avatar Lauros Pajunen
Browse files

Merge origin/main

parents 021397d2 c42975a1
Loading
Loading
Loading
Loading
Loading
+138 −0
Original line number Diff line number Diff line
@@ -41,6 +41,10 @@
#ifdef IVAS_RTPDUMP
#include "ivas_rtp_file.h"
#endif
#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT
#include "ivas_cnst.h"
#endif

#include "jbm_file_writer.h"
#include "hrtf_file_reader.h"
#include "ls_custom_file_reader.h"
@@ -155,6 +159,9 @@ typedef struct
    uint16_t directivityPatternId[IVAS_MAX_NUM_OBJECTS];
    bool objEditEnabled;
    char *objEditFileName;
#ifdef FIX_1419_MONO_STEREO_UMX
    bool evsMode;
#endif

} DecArguments;

@@ -253,6 +260,10 @@ int main(
    IVAS_RENDER_FRAMESIZE asked_frame_size;
    IVAS_DEC_HRTF_BINARY_WRAPPER hHrtfBinary;
    ObjectEditFileReader *objectEditFileReader = NULL;
#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT
    IVAS_ROOM_ACOUSTICS_CONFIG_DATA **pAE = NULL;
    uint32_t aeCount = 0;
#endif
#ifdef DEBUGGING
    int32_t noClipping;
    int32_t cnt_frames_limited;
@@ -477,7 +488,11 @@ int main(
     *------------------------------------------------------------------------------------------*/

    asked_frame_size = arg.renderFramesize;
#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT
    uint16_t aeID = arg.aeSequence.count > 0 ? arg.aeSequence.pID[0] : IVAS_DEFAULT_AEID;
#else
    uint16_t aeID = arg.aeSequence.count > 0 ? arg.aeSequence.pID[0] : 65535;
#endif

#ifdef IVAS_RTPDUMP
    arg.enableHeadRotation = arg.enableHeadRotation || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM;
@@ -658,6 +673,47 @@ int main(
            fprintf( stderr, "Failed to read renderer configuration from file %s\n\n", arg.renderConfigFilename );
            goto cleanup;
        }
#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT
        aeCount = RenderConfigReader_getAcousticEnvironmentCount( renderConfigReader );
        if ( aeCount > 0 )
        {
            uint32_t n;

            pAE = malloc( aeCount * sizeof( IVAS_ROOM_ACOUSTICS_CONFIG_DATA * ) );

            if ( pAE == NULL )
            {
                fprintf( stderr, "\nError: cannot allocate memory for acoustic environment array\n\n" );
                goto cleanup;
            }

            for ( n = 0; n < aeCount; n++ )
            {
                pAE[n] = NULL;

                if ( NULL == ( pAE[n] = malloc( sizeof( IVAS_ROOM_ACOUSTICS_CONFIG_DATA ) ) ) )
                {
                    fprintf( stderr, "\nError: cannot allocate memory for acoustic environment\n\n" );
                    goto cleanup;
                }
            }

            if ( ( error = RenderConfigReader_getAcousticEnvironments( renderConfigReader, pAE ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "Error while getting acoustic environments\n\n" );
                goto cleanup;
            }

            for ( n = 0; n < aeCount; n++ )
            {
                if ( ( error = IVAS_DEC_AddAcousticEnvironment( hIvasDec, *pAE[n] ) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "Failed to add acoustic environments\n\n" );
                    goto cleanup;
                }
            }
        }
#endif

        if ( ( error = RenderConfigReader_getDirectivity( renderConfigReader, arg.directivityPatternId, renderConfig.directivity ) ) != IVAS_ERR_OK )
        {
@@ -696,7 +752,11 @@ int main(

        if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
        {
#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT
            if ( ( error = IVAS_DEC_GetAcousticEnvironment( hIvasDec, aeID, &renderConfig.roomAcoustics ) ) == IVAS_ERR_OK )
#else
            if ( ( error = RenderConfigReader_getAcousticEnvironment( renderConfigReader, aeID, &renderConfig.roomAcoustics ) ) == IVAS_ERR_OK )
#endif
            {
                if ( RenderConfigReader_checkValues( &renderConfig ) != IVAS_ERR_OK )
                {
@@ -835,6 +895,19 @@ cleanup:

    free( pcmBuf );

#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT
    if ( pAE != NULL )
    {
        uint16_t n;

        for ( n = 0; n < aeCount; n++ )
        {
            free( pAE[n] );
        }

        free( pAE );
    }
#endif
    if ( arg.aeSequence.count > 0 )
    {
        free( arg.aeSequence.pID );
@@ -1002,6 +1075,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;
@@ -1555,6 +1631,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
@@ -1605,6 +1689,14 @@ 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 )
        {
@@ -1697,6 +1789,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" );
@@ -1713,6 +1808,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" );
#ifdef IVAS_RTPDUMP
@@ -4238,6 +4336,46 @@ static void do_object_editing(
                        editableParameters->ism_metadata[obj_idx].elevation = readInfo->obj_ele[obj_idx];
                    }
                }
#ifdef FIX_1427_OBJ_EDITING_EXT_METADATA
                /* object direction editing only for diegetic objects */
                if ( readInfo->obj_yaw_edited[obj_idx] )
                {
                    if ( readInfo->obj_yaw_relative[obj_idx] )
                    {
                        /* yaw: apply relative edit + wrap */
                        editableParameters->ism_metadata[obj_idx].yaw = fmodf( editableParameters->ism_metadata[obj_idx].yaw + readInfo->obj_yaw[obj_idx] + 540.f, 360.f ) - 180.f;
                    }
                    else
                    {
                        editableParameters->ism_metadata[obj_idx].yaw = readInfo->obj_yaw[obj_idx];
                    }
                }
                if ( readInfo->obj_pitch_edited[obj_idx] )
                {
                    if ( readInfo->obj_pitch_relative[obj_idx] )
                    {
                        /* pitch: apply relative edit + saturation */
                        editableParameters->ism_metadata[obj_idx].pitch = fmaxf( fminf( editableParameters->ism_metadata[obj_idx].pitch + readInfo->obj_pitch[obj_idx], 90.f ), -90.f );
                    }
                    else
                    {
                        editableParameters->ism_metadata[obj_idx].pitch = readInfo->obj_pitch[obj_idx];
                    }
                }
                /* radius editing only for diegetic objects */
                if ( readInfo->obj_radius_edited[obj_idx] )
                {
                    if ( readInfo->obj_radius_relative[obj_idx] )
                    {
                        /* radius: apply relative edit + saturation */
                        editableParameters->ism_metadata[obj_idx].radius = fmaxf( fminf( editableParameters->ism_metadata[obj_idx].radius * readInfo->obj_radius[obj_idx], OBJ_EDIT_RADIUS_MAX ), 0.0f );
                    }
                    else
                    {
                        editableParameters->ism_metadata[obj_idx].radius = readInfo->obj_radius[obj_idx];
                    }
                }
#endif
            }

            /* gain editing for all objects */
+3 −0
Original line number Diff line number Diff line
@@ -312,6 +312,9 @@ typedef enum
#endif
typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG
{
#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT
    uint16_t aeID; /* Acoustic environment ID*/
#endif
    int16_t nBands;                                   /* Number of frequency bands for which reverb properties are provided, integer, range [2..256]        */
    float pFc_input[IVAS_CLDFB_NO_CHANNELS_MAX];      /* Center frequencies for which following values are provided:                                        */
    float pAcoustic_rt60[IVAS_CLDFB_NO_CHANNELS_MAX]; /*  - The room's T60 per center frequency                                                             */
+13 −0
Original line number Diff line number Diff line
@@ -177,6 +177,12 @@ typedef enum
#define MAX_SPAR_INTERNAL_CHANNELS              IVAS_SPAR_MAX_CH
#define MAX_CLDFB_DIGEST_CHANNELS               3                           /* == maximum of ParamISM TCs and ParamMC TCs */

#ifdef FIX_GAIN_EDIT_LIMITS
#define EDIT_GAIN_MIN                           0.0630957f                     /* Minimum allowed gain edit with parametric modes: -24 dB */
#define EDIT_GAIN_MAX                           3.9810719f                     /* Maximum allowed gain edit: +12 dB */
#endif


typedef enum
{
    TC_BUFFER_MODE_RENDERER,
@@ -1251,7 +1257,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
{
@@ -1592,6 +1602,9 @@ typedef enum
#define RV_LENGTH_NR_FC                         ( RV_FILTER_MAX_FFT_SIZE / 2 ) + 1
#define RV_LENGTH_NR_FC_16KHZ                   ( RV_FILTER_MAX_FFT_SIZE / 4 ) + 1
#define IVAS_REVERB_DEFAULT_N_BANDS             31
#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT
#define IVAS_DEFAULT_AEID                       ( 65535 )
#endif

#define LR_IAC_LENGTH_NR_FC                     ( RV_LENGTH_NR_FC )
#define LR_IAC_LENGTH_NR_FC_16KHZ               ( RV_LENGTH_NR_FC_16KHZ )

lib_com/options.h

100755 → 100644
+5 −0
Original line number Diff line number Diff line
@@ -161,7 +161,9 @@

#define RTP_S4_251135_CR26253_0016_REV1                /* RTP Pack/Unpack API corresponding to CR 26253 */
#define IVAS_RTPDUMP                                   /* RTPDUMP writing and reading for IVAS payloads */
#define IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT              /* RTPDUMP acoustic environment */
#define FIXED_RTP_SEQUENCE_NUM                         /* Remove random sequence number initialization */
#define ISM_PI_DATA                                    /* Add reading and packing/unpacking of ISM PI data */
#define DECODER_FORMAT_SWITCHING                       /* Re-initialize the decoder when the format/subformat of the incoming stream is changed */

/* ################### Start BE switches ################################# */
@@ -172,6 +174,8 @@
#define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR      /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */
#define FIX_1413_IGF_INIT_PRINTOUT                      /* FhG: use correct variable for IGF initiliazation */
#define RENDERER_MD_SYNC_DELAY_TO_INTEGER               /* FhG: change data type of metadata sync delay in ext renderer to int16_t for better BASOP portability (and nicer code) */
#define FIX_1427_OBJ_EDITING_EXT_METADATA               /* Eri: Add support for extended metadata in object editing */
#define FIX_1419_MONO_STEREO_UMX                        /* FhG: fix for issue 1419 : support upmix to all output formats for mono and stereo */


/* #################### End BE switches ################################## */
@@ -194,6 +198,7 @@
#define FIX_1330_JBM_MEMORY_FIX                         /* VA: basop issue: 2179 fix non-BE difference in FIX_1330_JBM_MEMORY */
#define NONBE_1380_OMASA_BUILD_DIFF                     /* Nokia: Fix for issue #1380: Large differences in OMASA output between Debug and Release builds */
#define NONBE_FIX_1426_STEREO_PANNING_BETWEEN_OPT_LEVEL /* Nokia: Adjustments in remaining stereo panning functions to make them BE between Debug and Release */
#define FIX_GAIN_EDIT_LIMITS                                 /* Harmonize gain edit limits for all opertation points. For all modes, limit to max +12dB. For parametric modes, limit to min -24dB. */


#define FIX_1430_EVS_STEREO_DMX_CHANNEL_DISAPPEARING    /* Orange: Fix for basop issue 2184 - to prevent one channel from becoming inaudible in the mono downmix output */
+49 −1
Original line number Diff line number Diff line
@@ -1425,7 +1425,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;
        }
@@ -1478,6 +1486,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 )
@@ -1560,7 +1575,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 */
@@ -2454,7 +2471,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 )
@@ -2777,6 +2795,10 @@ void ivas_initialize_handles_dec(
    st_ivas->hRenderConfig = NULL;
    st_ivas->hExtOrientationData = NULL;
    st_ivas->hCombinedOrientationData = NULL;
#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT
    st_ivas->acousticEnvironmentsCount = 0;
    st_ivas->pAcousticEnvironments = NULL;
#endif

    st_ivas->hSplitBinRend = NULL;
    for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i )
@@ -3023,6 +3045,15 @@ void ivas_destroy_dec(
        st_ivas->p_output_f[i] = NULL;
    }

#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT
    /* Acoustic environments */
    if ( st_ivas->pAcousticEnvironments != NULL )
    {
        free( st_ivas->pAcousticEnvironments );
        st_ivas->pAcousticEnvironments = NULL;
    }
#endif

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

@@ -3286,6 +3317,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 )
    {
@@ -3298,10 +3330,26 @@ static ivas_error doSanityChecks_IVAS(
    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 )
    {
Loading