Commit 97dad48e authored by Marek Szczerba's avatar Marek Szczerba
Browse files

Merge branch 'main' into 1019-socket-interface-for-pose-and-audio

parents b8794ae3 964def59
Loading
Loading
Loading
Loading
Loading
+22 −45
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ static
#endif
#define RANDOM_INITSEED_DEC ( 0xFADE )


/*------------------------------------------------------------------------------------------*
 * Local structure for storing cmdln arguments
 *------------------------------------------------------------------------------------------*/
@@ -157,7 +158,6 @@ typedef struct
    uint16_t directivityPatternId[IVAS_MAX_NUM_OBJECTS];
    bool objEditEnabled;
    char *objEditFileName;
    bool evsMode;
    IVAS_ROOM_SIZE_T roomSize;

} DecArguments;
@@ -190,37 +190,13 @@ static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg );
static ivas_error parseQuaternionData( char *rxBuffer, IVAS_QUATERNION *pQuaternion );
#endif
static void usage_dec( void );
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,
#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO
    unsigned int hSocket,
#endif
    ISAR_SPLIT_REND_BITS_DATA *splitRendBits,
    IVAS_DEC_HANDLE hIvasDec,
    int16_t *pcmBuf );
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,
#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO
    unsigned int hSocket,
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, unsigned int hSocket, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf );
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, unsigned int hSocket, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_RENDER_CONFIG_DATA *renderConfig, IVAS_DEC_HANDLE *phIvasDec, int16_t *pcmBuf );
#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 );
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
    ISAR_SPLIT_REND_BITS_DATA *splitRendBits,
    IVAS_RENDER_CONFIG_DATA *renderConfig,
    IVAS_DEC_HANDLE *phIvasDec,
    int16_t *pcmBuf );
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 );
@@ -514,8 +490,8 @@ int main(

    asked_frame_size = arg.renderFramesize;
    uint16_t aeID = arg.aeSequence.count > 0 ? arg.aeSequence.pID[0] : IVAS_DEFAULT_AEID;

    arg.enableHeadRotation = arg.enableHeadRotation || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM;

    if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.renderFramesize, arg.customLsOutputEnabled, arg.hrtfReaderEnabled,
                                       arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.roomSize, arg.non_diegetic_pan_enabled,
                                       arg.non_diegetic_pan_gain, arg.dpidEnabled, aeID, arg.objEditEnabled, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK )
@@ -661,7 +637,6 @@ int main(

    if ( arg.renderConfigEnabled )
    {

        /* sanity check */
        if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB &&
             arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && arg.non_diegetic_pan_enabled == false )
@@ -850,14 +825,11 @@ int main(

    if ( arg.voipMode )
    {
        error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader,
#ifdef SOCKET_INTERFACE_FOR_POSE_AND_AUDIO
                            hSocket,
        error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, hSocket, &splitRendBits, &renderConfig, &hIvasDec, pcmBuf );
#else
        error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, &splitRendBits, &renderConfig, &hIvasDec, pcmBuf );
#endif
                            &splitRendBits,
                            &renderConfig,
                            &hIvasDec,
                            pcmBuf );
    }
    else
    {
@@ -1092,7 +1064,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;
@@ -1692,7 +1663,6 @@ static bool parseCmdlIVAS_dec(
        }
        else if ( strcmp( argv_to_upper, "-EVS" ) == 0 )
        {
            arg->evsMode = true;
            arg->decMode = IVAS_DEC_MODE_EVS;
            i++;
        }
@@ -1783,7 +1753,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();
@@ -3319,6 +3289,7 @@ static ivas_error printBitstreamInfoVoip(
        else
        {
            auPtr = au; /* might have been set to RTP packet in prev call */

            error = IVAS_RTP_ReadNextFrame( &ivasRtp, auPtr, &auSizeBits, &rtpTimeStamp, &rtpSequenceNumber, &nextPacketRcvTime_ms, NULL, &qBit );

            /* EVS RTP payload format has timescale 16000, JBM uses 1000 internally */
@@ -3415,6 +3386,7 @@ static ivas_error decodeVoIP(
    int32_t delayTimeScale = -1;
    int16_t i;
    IVAS_DEC_HANDLE hIvasDec = *phIvasDec;

    bool restartNeeded;
    IVAS_RTP ivasRtp = { 0 };
    IVAS_RTP srRtp = { 0 };
@@ -3500,7 +3472,6 @@ static ivas_error decodeVoIP(
            goto cleanup;
    }


#ifdef SUPPORT_JBM_TRACEFILE
    if ( arg.jbmTraceFilename != NULL )
    {
@@ -3532,7 +3503,9 @@ static ivas_error decodeVoIP(
    else
    {
        auPtr = au; /* might have been set to RTP packet in prev call */

        error = IVAS_RTP_ReadNextFrame( &ivasRtp, auPtr, &auSize, &rtpTimeStamp, &rtpSequenceNumber, &nextPacketRcvTime_ms, NULL, &qBit );

        initialTsOffsetSystemAndRTP = rtpTimeStamp - systemTime_ms * 16; /* For time mapping */

        /* EVS RTP payload format has timescale 16000, JBM uses 1000 internally */
@@ -3764,6 +3737,7 @@ static ivas_error decodeVoIP(
            else
            {
                auPtr = au; /* might have been set to RTP packet in prev call */

                error = IVAS_RTP_ReadNextFrame( &ivasRtp, au, &auSize, &rtpTimeStamp, &rtpSequenceNumber, &nextPacketRcvTime_ms, NULL, &qBit );

                /* IVAS RTP payload format has timescale 16000, JBM uses 1000 internally */
@@ -3818,6 +3792,7 @@ static ivas_error decodeVoIP(

                ivasRtp.nProcPiData += numPiData;
            }

            if ( isSplitRend )
            {
#ifdef SUPPORT_JBM_TRACEFILE
@@ -4065,6 +4040,7 @@ static ivas_error decodeVoIP(
            srInfo.bitrateKbps = splitRendBits->bits_written * 1000 / splitRendBits->codec_frame_size_ms;
            srInfo.codec = ( splitRendBits->codec == ISAR_SPLIT_REND_CODEC_LC3PLUS ) ? IVAS_SR_TRANSPORT_LC3PLUS : IVAS_SR_TRANSPORT_LCLD;
            srInfo.codecFrameSizeMs = (uint32_t) splitRendBits->codec_frame_size_ms;

            if ( ( error = IVAS_RTP_WriteNextFrame( &srRtp, splitRendBits->bits_buf, &srInfo, (int16_t) splitRendBits->bits_written, false, false ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nError %s while pushing SR audio bitstream to RTP pack\n", ivas_error_to_string( error ) );
@@ -4316,7 +4292,8 @@ static void do_object_editing(
                        editableParameters->ism_metadata[obj_idx].elevation = readInfo->obj_ele[obj_idx];
                    }
                }
                /* object direction editing only for diegetic objects */

                /* object orientation editing only for diegetic objects */
                if ( readInfo->obj_yaw_edited[obj_idx] )
                {
                    if ( readInfo->obj_yaw_relative[obj_idx] )
@@ -4612,9 +4589,10 @@ static ivas_error restartDecoder(

    hIvasDec = *phIvasDec;

    uint16_t aeID = arg->aeSequence.count > 0 ? arg->aeSequence.pID[0] : 65535;
    uint16_t aeID = arg->aeSequence.count > 0 ? arg->aeSequence.pID[0] : IVAS_DEFAULT_AEID;

    IVAS_AUDIO_CONFIG outputConfig = ( decMode == IVAS_DEC_MODE_IVAS ) ? arg->outputConfig : IVAS_AUDIO_CONFIG_MONO;

    if ( ( error = IVAS_DEC_Configure( hIvasDec, arg->output_Fs, outputConfig, arg->renderFramesize, arg->customLsOutputEnabled, arg->hrtfReaderEnabled,
                                       arg->enableHeadRotation, arg->enableExternalOrientation, arg->orientation_tracking, arg->renderConfigEnabled, arg->roomSize, arg->non_diegetic_pan_enabled,
                                       arg->non_diegetic_pan_gain, arg->dpidEnabled, aeID, arg->objEditEnabled, arg->delayCompensationEnabled ) ) != IVAS_ERR_OK )
@@ -4629,7 +4607,6 @@ static ivas_error restartDecoder(
        goto cleanup;
    }


    if ( arg->voipMode )
    {
        if ( ( error = IVAS_DEC_EnableVoIP( hIvasDec, 60, arg->inputFormat ) ) != IVAS_ERR_OK )
+1 −1
Original line number Diff line number Diff line
@@ -256,6 +256,7 @@ int main(
cleanup:

    IVAS_RTP_Term( &ivasRtp );

    if ( FmtSWFile )
    {
        fclose( FmtSWFile );
@@ -1156,7 +1157,6 @@ static bool parseCmdlIVAS_enc(
    arg->rtpdumpOutput = false;
    arg->sceneOrientationTrajFileName = NULL;
    arg->deviceOrientationTrajFileName = NULL;

#ifdef DEBUGGING
    arg->forcedMode = IVAS_ENC_FORCE_UNFORCED;
    arg->forcedModeFile = NULL;
+5 −1
Original line number Diff line number Diff line
@@ -398,6 +398,7 @@ static IVAS_AUDIO_CONFIG parseAudioConfig(
        *srRtp = true;
        return IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED;
    }

    return IVAS_AUDIO_CONFIG_INVALID;
}

@@ -455,6 +456,7 @@ static CmdlnArgs defaultArgs(
    clearString( args.inputFilePath );
    clearString( args.outputFilePath );
    clearString( args.srParamsFilePath );

    args.sampleRate = 0;

    args.outConfig.audioConfig = IVAS_AUDIO_CONFIG_INVALID;
@@ -560,7 +562,6 @@ static void parseOption(
                fprintf( stderr, "Unknown or invalid option for frame size: %s\n", optionValues[0] );
                exit( -1 );
            }

            break;
        case CmdLnOptionId_srParamsFile:
            assert( numOptionValues == 1 );
@@ -695,6 +696,7 @@ static void convertOutputBuffer(
    return;
}


static void trim( char *str )
{
    char c;
@@ -712,6 +714,7 @@ static void trim( char *str )
    str[w] = 0;
}


static ivas_error parseSRParamsFile(
    const char *srParamsFilePath,
    const char *rtpFilePath,
@@ -803,6 +806,7 @@ static ivas_error parseSRParamsFile(
    return IVAS_ERR_OK;
}


/*------------------------------------------------------------------------------------------*
 * main()
 *
+3 −8
Original line number Diff line number Diff line
@@ -226,7 +226,7 @@ typedef enum
    CmdLnOptionId_syncMdDelay,
    CmdLnOptionId_directivityPatternId,
    CmdLnOptionId_acousticEnvironmentId,
    CmdLnOptionId_roomSize,
    CmdLnOptionId_roomSize
} CmdLnOptionId;

static const CmdLnParser_Option cliOptions[] = {
@@ -1127,7 +1127,7 @@ int main(

        if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
        {
            aeID = args.aeSequence.count > 0 ? args.aeSequence.pID[0] : 65535;
            aeID = args.aeSequence.count > 0 ? args.aeSequence.pID[0] : IVAS_DEFAULT_AEID;
            if ( ( error = RenderConfigReader_getAcousticEnvironment( renderConfigReader, aeID, &renderConfig.roomAcoustics ) ) == IVAS_ERR_OK )
            {
                if ( RenderConfigReader_checkValues( &renderConfig ) != IVAS_ERR_OK )
@@ -1433,12 +1433,7 @@ int main(
            audioWriter = NULL;
        }

        if ( ( error = IVAS_REND_GetSplitRendBitstreamHeader( hIvasRend,
                                                              &bitsBuffer.config.codec,
                                                              &bitsBuffer.config.poseCorrection,
                                                              &bitsBuffer.config.codec_frame_size_ms,
                                                              &bitsBuffer.config.isar_frame_size_ms,
                                                              &bitsBuffer.config.lc3plus_highres ) ) != IVAS_ERR_OK )
        if ( ( error = IVAS_REND_GetSplitRendBitstreamHeader( hIvasRend, &bitsBuffer.config.codec, &bitsBuffer.config.poseCorrection, &bitsBuffer.config.codec_frame_size_ms, &bitsBuffer.config.isar_frame_size_ms, &bitsBuffer.config.lc3plus_highres ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nError in IVAS_REND_GetSplitRendBitstreamHeader()!\n" );
            goto cleanup;
+2 −1
Original line number Diff line number Diff line
@@ -180,7 +180,6 @@ typedef enum
#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 */


typedef enum
{
    TC_BUFFER_MODE_RENDERER,
@@ -1486,6 +1485,7 @@ typedef enum
#define LS_ANGLE_RAD_30_DEG                     0.52359879f                /* 30.0f * PI_OVER_180 */
#define INV_TAN_LS_ANGLE_RAD_30_DEG             1.7320507f                 /* 1.0f/tanf(30.0f * PI_OVER_180) */


/*----------------------------------------------------------------------------------*
 * Binaural Rendering Constants
 *----------------------------------------------------------------------------------*/
@@ -1604,6 +1604,7 @@ typedef enum
    DEFAULT_REVERB_LARGE,
} IVAS_DefaultReverbSize;


/*----------------------------------------------------------------------------------*
 * FB mixer constants
 *----------------------------------------------------------------------------------*/
Loading