Commit d905daf9 authored by Gregory Pallone's avatar Gregory Pallone
Browse files

Merge branch 'main' into float-1548-Harmonize-non-diegetic-panning-law-in-ISM-and-renderer

parents b0bf9ca6 7e397bd1
Loading
Loading
Loading
Loading
+48 −1
Original line number Diff line number Diff line
@@ -180,14 +180,20 @@ static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS
#else
static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf );
#endif
#ifdef FIX_FMSW_DEC
static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtf, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE *phIvasDec, int16_t *pcmBuf );
#else
static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtf, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_RENDER_CONFIG_DATA *renderConfig, IVAS_DEC_HANDLE *phIvasDec, int16_t *pcmBuf );
#endif
static ivas_error load_hrtf_from_file( IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, IVAS_DEC_HANDLE hIvasDec, const IVAS_AUDIO_CONFIG OutputConfig, const int32_t output_Fs );
#ifdef DEBUGGING
static ivas_error printBitstreamInfoVoip( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HANDLE hIvasDec );
static int16_t app_own_random( int16_t *seed );
#endif
static void do_object_editing( IVAS_EDITABLE_PARAMETERS *editableParameters, ObjectEditFileReader *objectEditFileReader );
#ifndef FIX_FMSW_DEC
static ivas_error restartDecoder( IVAS_DEC_HANDLE *phIvasDec, const IVAS_DEC_MODE decMode, DecArguments *arg, IVAS_RENDER_CONFIG_DATA *renderConfig, IVAS_CUSTOM_LS_DATA *hLsCustomData );
#endif


/*------------------------------------------------------------------------------------------*
@@ -779,7 +785,11 @@ int main(

    if ( arg.voipMode )
    {
#ifdef FIX_FMSW_DEC
        error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, &splitRendBits, &hIvasDec, pcmBuf );
#else
        error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, &splitRendBits, &renderConfig, &hIvasDec, pcmBuf );
#endif
    }
    else
    {
@@ -2627,6 +2637,13 @@ static ivas_error decodeG192(

                if ( restartNeeded )
                {
#ifdef FIX_FMSW_DEC
                    if ( ( error = IVAS_DEC_Restart( hIvasDec, IVAS_DEC_MODE_IVAS ) ) != IVAS_ERR_OK ) /* note: only switching within IVAS formats is supported in G.192 */
                    {
                        fprintf( stderr, "\nIVAS_DEC_Restart restart failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                        goto cleanup;
                    }
#else
                    IVAS_DEC_BS_FORMAT tempFormat;
                    if ( ( error = IVAS_DEC_GetFormat( hIvasDec, &tempFormat ) ) != IVAS_ERR_OK )
                    {
@@ -2647,6 +2664,7 @@ static ivas_error decodeG192(
                        goto cleanup;
                    }
                    *phIvasDec = hIvasDec; /* Update for main()' s free */
#endif
                }
#endif

@@ -3221,7 +3239,9 @@ static ivas_error decodeVoIP(
    Vector3PairFileReader *referenceVectorReader,
    ObjectEditFileReader *objectEditFileReader,
    ISAR_SPLIT_REND_BITS_DATA *splitRendBits,
#ifndef FIX_FMSW_DEC
    IVAS_RENDER_CONFIG_DATA *renderConfig,
#endif
    IVAS_DEC_HANDLE *phIvasDec,
    int16_t *pcmBuf )
{
@@ -3379,6 +3399,15 @@ static ivas_error decodeVoIP(

        /* EVS RTP payload format has timescale 16000, JBM uses 1000 internally */
        rtpTimeStamp = rtpTimeStamp / 16;

#ifdef FIX_FMSW_DEC_2
        arg.decMode = ( ivasRtp.codecId == IVAS_RTP_EVS ) ? IVAS_DEC_MODE_EVS : IVAS_DEC_MODE_IVAS;
        if ( ( error = IVAS_DEC_Restart( hIvasDec, arg.decMode ) ) != IVAS_ERR_OK ) /* note: when the RTP bitstream starts with EVS, do the restart */
        {
            fprintf( stderr, "\nIVAS_DEC_Restart restart failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
            goto cleanup;
        }
#endif
    }
    if ( error != IVAS_ERR_OK )
    {
@@ -3412,6 +3441,14 @@ static ivas_error decodeVoIP(
        /* restart decoder in case of format switching */
        if ( ivasRtp.restartNeeded )
        {
#ifdef FIX_FMSW_DEC
            arg.decMode = ( ivasRtp.codecId == IVAS_RTP_EVS ) ? IVAS_DEC_MODE_EVS : IVAS_DEC_MODE_IVAS;
            if ( ( error = IVAS_DEC_Restart( hIvasDec, arg.decMode ) ) != IVAS_ERR_OK ) /* note: switching between EVS and IVAS is supported in RTP */
            {
                fprintf( stderr, "\nIVAS_DEC_Restart restart failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                goto cleanup;
            }
#else
            IVAS_DEC_MODE newDecModeInPacket = ( ivasRtp.codecId == IVAS_RTP_EVS ) ? IVAS_DEC_MODE_EVS : IVAS_DEC_MODE_IVAS;
            if ( ( error = restartDecoder(
                       &hIvasDec,
@@ -3426,6 +3463,7 @@ static ivas_error decodeVoIP(
            }

            *phIvasDec = hIvasDec; /* Update for main()' s free */
#endif
            ivasRtp.restartNeeded = false;
            bitstreamReadDone = false;
            parametersAvailableForEditing = false;
@@ -3657,6 +3695,13 @@ static ivas_error decodeVoIP(

                if ( restartNeeded )
                {
#ifdef FIX_FMSW_DEC
                    if ( ( error = IVAS_DEC_Restart( hIvasDec, IVAS_DEC_MODE_IVAS ) ) != IVAS_ERR_OK ) /* note: only switching within IVAS formats is supported in non-RTP VoIP */
                    {
                        fprintf( stderr, "\nIVAS_DEC_Restart restart failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                        goto cleanup;
                    }
#else
                    IVAS_DEC_BS_FORMAT tempBsFormat;
                    if ( ( error = IVAS_DEC_GetFormat( hIvasDec, &tempBsFormat ) ) != IVAS_ERR_OK )
                    {
@@ -3677,6 +3722,7 @@ static ivas_error decodeVoIP(
                        goto cleanup;
                    }
                    *phIvasDec = hIvasDec; /* Update for main()' s free */
#endif
                    bitstreamReadDone = false;
                    parametersAvailableForEditing = false;
                }
@@ -4364,7 +4410,7 @@ static ivas_error load_hrtf_from_file(
    return IVAS_ERR_OK;
}


#ifndef FIX_FMSW_DEC
/*---------------------------------------------------------------------*
 * restartDecoder()
 *
@@ -4469,4 +4515,5 @@ cleanup:
    return error;
}

#endif
#undef WMC_TOOL_SKIP
+25 −18
Original line number Diff line number Diff line
@@ -40,9 +40,7 @@
#include "masa_file_reader.h"
#include "rotation_file_reader.h"
#include "ivas_rtp_file.h"
#ifdef FIX_1527_CMR_BITRATE_IDX
#include "requests_file_reader.h"
#endif
#ifdef DEBUGGING
#include "debug.h"
#endif
@@ -160,9 +158,7 @@ typedef struct
    char *sceneOrientationTrajFileName;
    char *deviceOrientationTrajFileName;

#ifdef FIX_1527_CMR_BITRATE_IDX
    char *requestsFileName;
#endif
} EncArguments;


@@ -230,9 +226,7 @@ int main(
    uint8_t au[IVAS_MAX_BITS_PER_FRAME / 8];
    IVAS_RTP ivasRtp = { 0 };

#ifdef FIX_1527_CMR_BITRATE_IDX
    ReqFileReader *requestsFileReader = NULL;
#endif
    /* Ideally ssrc is negotiated via SDP and sequence number is radomized but we
       use fixed seed for random num generator for regression based tests. Any realtime
       application should implement this initialization seperately */
@@ -375,6 +369,28 @@ int main(
        }
    }

#ifdef FIX_FMSW_DEC
    /*------------------------------------------------------------------------------------------*
     * Open remote requests file for rtp packing (E-bytes)
     *------------------------------------------------------------------------------------------*/

    if ( arg.requestsFileName != NULL )
    {
        if ( !arg.rtpdumpOutput )
        {
            fprintf( stderr, "\nError: RTP requests file can be used with rtpdump output only.\n\n" );
            usage_enc();
            goto cleanup;
        }

        if ( ( error = RequestsFileReader_open( arg.requestsFileName, &requestsFileReader ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nError: Can't open requests file %s \n\n", arg.requestsFileName );
            goto cleanup;
        }
    }
#endif

    /*------------------------------------------------------------------------------------------*
     * Handle Channel-aware mode
     *------------------------------------------------------------------------------------------*/
@@ -672,6 +688,7 @@ int main(
        }
    }

#ifndef FIX_FMSW_DEC
#ifdef FIX_1527_CMR_BITRATE_IDX
    /*------------------------------------------------------------------------------------------*
     * Open remote requests file for rtp packing (E-bytes)
@@ -685,7 +702,7 @@ int main(
        }
    }
#endif

#endif
    /*------------------------------------------------------------------------------------------*
     * Run the encoder
     *------------------------------------------------------------------------------------------*/
@@ -895,7 +912,6 @@ int main(
                }
            }

#ifdef FIX_1527_CMR_BITRATE_IDX
            if ( requestsFileReader )
            {
                if ( ( error = ReadNextRequests( requestsFileReader, ivasRtp.remoteRequests, &ivasRtp.remoteRequestBitmap ) ) != IVAS_ERR_OK )
@@ -904,7 +920,6 @@ int main(
                    goto cleanup;
                }
            }
#endif

            if ( ( error = IVAS_ENC_EncodeFrameToCompact( hIvasEnc, pcmBuf, pcmBufSize, au, &numBits ) ) != IVAS_ERR_OK )
            {
@@ -1010,12 +1025,10 @@ cleanup:
        fclose( f_bitrateProfile );
    }

#ifdef FIX_1527_CMR_BITRATE_IDX
    if ( requestsFileReader )
    {
        RequestsFileReader_close( &requestsFileReader );
    }
#endif

    if ( sceneOrientationFileReader )
    {
@@ -1078,10 +1091,8 @@ static bool parseCmdlIVAS_enc(
    /*-----------------------------------------------------------------*
     * Set default values
     *-----------------------------------------------------------------*/
#ifdef FIX_1527_CMR_BITRATE_IDX
    // Need less usan/msan or new arg addition
    memset( arg, 0, sizeof( *arg ) );
#endif

    arg->inputWavFilename = NULL;
    arg->outputBitstreamFilename = NULL;
@@ -1962,7 +1973,6 @@ static bool parseCmdlIVAS_enc(
            arg->deviceOrientationTrajFileName = argv[i];
            i++;
        }
#ifdef FIX_1527_CMR_BITRATE_IDX
        else if ( strcmp( argv_to_upper, "-REQUESTS" ) == 0 )
        {
            i++;
@@ -1975,7 +1985,6 @@ static bool parseCmdlIVAS_enc(
            arg->requestsFileName = argv[i];
            i++;
        }
#endif

        /*-----------------------------------------------------------------*
         * Option not recognized
@@ -2212,11 +2221,9 @@ static void usage_enc( void )
    fprintf( stdout, "                      bitstream frames into TS26.253 Annex A IVAS RTP Payload Format packets and \n" );
    fprintf( stdout, "                      writes those to the output file. In EVS mono operating mode, TS26.445 Annex A.2.2 \n" );
    fprintf( stdout, "                      EVS RTP Payload Format is used. Optional N represents number of frames per RTP packet\n" );
    fprintf( stdout, "-requests           : Remote requests file, Only used with rtpdump output.\n" );
    fprintf( stdout, "-scene_orientation  : Scene orientation trajectory file. Only used with rtpdump output.\n" );
    fprintf( stdout, "-device_orientation : Device orientation trajectory file. Only used with rtpdump output.\n" );
#ifdef FIX_1527_CMR_BITRATE_IDX
    fprintf( stdout, "-requests           : Remote requests file, Only used with rtpdump output.\n" );
#endif

    fprintf( stdout, "\n" );

+47 −0
Original line number Diff line number Diff line
@@ -1100,6 +1100,53 @@ int main(
        fprintf( stderr, "\nError in Renderer Config Init: %s\n", ivas_error_to_string( error ) );
        goto cleanup;
    }
#ifdef FIX_1452_DEFAULT_REVERB

    if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
    {
        /* Set reverb room size if specified or select based automatically based on default per input formats */
        IVAS_ROOM_SIZE_T selectedReverbRoomSize = args.reverbRoomSize;
        if ( selectedReverbRoomSize == IVAS_ROOM_SIZE_AUTO )
        {
            bool combinedFormat = false;
            selectedReverbRoomSize = IVAS_ROOM_SIZE_MEDIUM;

            /* ISM present with MASA/SBA inputs; treat as combined format */
            if ( args.inConfig.numAudioObjects > 0 && ( args.inConfig.numMasaBuses > 0 || args.inConfig.numAmbisonicsBuses > 0 ) )
            {
                combinedFormat = true;
            }

            if ( combinedFormat )
            {
                selectedReverbRoomSize = IVAS_ROOM_SIZE_MEDIUM;
            }
            else
            {
                /* Only set large if ISM is present alone, MASA and Ambisonic have been checked above */
                if ( args.inConfig.numAudioObjects > 0 && args.inConfig.numMultiChannelBuses == 0 )
                {
                    selectedReverbRoomSize = IVAS_ROOM_SIZE_LARGE;
                }
                /* if only MC is present, set medium; Will not be overridden by the subsequent block */
                else if ( args.inConfig.numMultiChannelBuses > 0 )
                {
                    selectedReverbRoomSize = IVAS_ROOM_SIZE_MEDIUM;
                }
                else if ( args.inConfig.numMasaBuses > 0 || args.inConfig.numAmbisonicsBuses > 0 )
                {
                    selectedReverbRoomSize = IVAS_ROOM_SIZE_SMALL;
                }
            }
        }

        if ( ( error = IVAS_REND_SetReverbRoomSize( hIvasRend, selectedReverbRoomSize ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nError setting reverb room size\n" );
            goto cleanup;
        }
    }
#endif

    if ( args.renderConfigFilePath[0] != '\0' )
    {
+4 −0
Original line number Diff line number Diff line
@@ -61,6 +61,10 @@
#define IVAS_REVERB_PREDELAY_MAX         20 /* Max input delay for reverb module */
#define IVAS_ER_LIST_HEIGHT              1.6f
#define IVAS_DEFAULT_AEID                65535
#ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION
#define IVAS_LISTENER_POSITION_MAX 327.67f
#endif


/* JBM constants for adaptive-playout */
#define IVAS_TIME_SCALE_MIN 50  /* min. time-scaling [%] */
+11 −0
Original line number Diff line number Diff line
@@ -1576,6 +1576,17 @@ typedef enum
#define IVAS_REVERB_DEFAULT_M_N_BANDS           31
#define IVAS_REVERB_DEFAULT_S_N_BANDS           60

#ifdef FIX_1452_DEFAULT_REVERB
#define IVAS_REVERB_DEFAULT_S_ACOUSTIC_PRE_DELAY    0.015f
#define IVAS_REVERB_DEFAULT_S_INPUT_PRE_DELAY       0.02f

#define IVAS_REVERB_DEFAULT_M_ACOUSTIC_PRE_DELAY    0.015f
#define IVAS_REVERB_DEFAULT_M_INPUT_PRE_DELAY       0.02f

#define IVAS_REVERB_DEFAULT_L_ACOUSTIC_PRE_DELAY    0.01625f
#define IVAS_REVERB_DEFAULT_L_INPUT_PRE_DELAY       0.1f
#endif

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

Loading