Commit 5224af90 authored by vaclav's avatar vaclav
Browse files

RTP revision

parent 29b93e0e
Loading
Loading
Loading
Loading
Loading
+57 −36
Original line number Diff line number Diff line
@@ -55,13 +55,7 @@
#ifdef IVAS_RTPDUMP
#include "ivas_rtp_file.h"
#endif
#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT
#include "ivas_cnst.h"
#endif

#ifdef FIXED_RTP_SEQUENCE_NUM
#define RANDOM_INITSEED_DEC ( 0xFEEDFADE )
#endif

#define WMC_TOOL_SKIP

@@ -74,6 +68,10 @@ static
#endif
    int32_t frame = 0; /* Counter of frames */

#ifdef FIXED_RTP_SEQUENCE_NUM
#define RANDOM_INITSEED_DEC ( 0xFEEDFADE )
#endif

#ifdef DEBUGGING
#define MIN_NUM_BITS_ACTIVE_FRAME 56
#define NUM_BITS_SID_IVAS_5K2     104
@@ -193,11 +191,11 @@ static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS
#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 );
static void do_object_editing_fx( IVAS_EDITABLE_PARAMETERS *editableParameters, ObjectEditFileReader *objectEditFileReader );

#ifdef DECODER_FORMAT_SWITCHING
static ivas_error restartDecoder( IVAS_DEC_HANDLE *phIvasDec, IVAS_DEC_MODE codec, DecArguments *arg, IVAS_RENDER_CONFIG_DATA *renderConfig, IVAS_CUSTOM_LS_DATA *hLsCustomData );
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


/*------------------------------------------------------------------------------------------*
 * main()
 *
@@ -495,7 +493,6 @@ int main(
            fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
            goto cleanup;
        }

#ifndef IVAS_RTPDUMP
        arg.enableHeadRotation = true;
#endif
@@ -558,6 +555,7 @@ 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 )
@@ -1877,6 +1875,7 @@ static ivas_error initOnFirstGoodFrame(
        ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection;
        int16_t splitRendIsarFrameSizeMs;
        int16_t lc3plusHighRes;

#ifdef FIXED_RTP_SEQUENCE_NUM
        /* 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
@@ -2411,7 +2410,7 @@ static ivas_error decodeG192(
            fprintf( stderr, "\nIVAS_DEC_GetNumOrientationSubframes failed: \n" );
            goto cleanup;
        }
        /* Head-tracking input simulation */

        /* Head-tracking input simulation */
        if ( arg.enableHeadRotation )
        {
@@ -3047,6 +3046,7 @@ static ivas_error decodeVoIP(
    int16_t i;
#ifdef DECODER_FORMAT_SWITCHING
    IVAS_DEC_HANDLE hIvasDec = *phIvasDec;
    bool restartNeeded;
#endif
#ifdef IVAS_RTPDUMP
    IVAS_RTP ivasRtp = { 0 };
@@ -3243,21 +3243,22 @@ static ivas_error decodeVoIP(
        nSamplesRendered = 0;

#ifdef DECODER_FORMAT_SWITCHING
        /* restart decoder in case of format switching */
        if ( ivasRtp.restartNeeded )
        {
            IVAS_DEC_MODE newCodecInPacket = ( ivasRtp.codecId == IVAS_RTP_EVS ) ? IVAS_DEC_MODE_EVS : IVAS_DEC_MODE_IVAS;
            error = restartDecoder(
            IVAS_DEC_MODE newDecModeInPacket = ( ivasRtp.codecId == IVAS_RTP_EVS ) ? IVAS_DEC_MODE_EVS : IVAS_DEC_MODE_IVAS;
            if(( error = restartDecoder(
                &hIvasDec,
                newCodecInPacket,
                newDecModeInPacket,
                &arg,
                NULL, /* ToDo : Provide rendererConfig */
                NULL  /* ToDo : Provide LS Custom Data */
            );
            if ( error != IVAS_ERR_OK )
            )  )!= IVAS_ERR_OK )
            {
                fprintf( stderr, "\nFailed to restart decoder from %d to %d\n", arg.decMode, newCodecInPacket );
                fprintf( stderr, "\nFailed to restart decoder from %d to %d\n", arg.decMode, newDecModeInPacket );
                goto cleanup;
            }

            *phIvasDec = hIvasDec; /* Update for main()' s free */
            ivasRtp.restartNeeded = false;
        }
@@ -3296,6 +3297,7 @@ static ivas_error decodeVoIP(
                goto cleanup;
            }
        }

        int16_t num_subframes;
        if ( ( error = IVAS_DEC_GetNumOrientationSubframes( hIvasDec, &num_subframes ) ) != IVAS_ERR_OK )
        {
@@ -3303,7 +3305,6 @@ static ivas_error decodeVoIP(
            goto cleanup;
        }

        /* Head-tracking input simulation */
        /* Head-tracking input simulation */
        if ( arg.enableHeadRotation )
        {
@@ -3446,12 +3447,17 @@ static ivas_error decodeVoIP(
        /* we are finished when all packets have been received and jitter buffer is empty */
        /* also stop when the input file contains less than two frames, because JBM cannot calculate a delay value and won't start decoding */
        /* last clause should make sure that for BE tests we end up with the same number of samples...*/
        if ( nextPacketRcvTime_ms == (uint32_t) ( -1 ) && ( IVAS_DEC_VoIP_IsEmpty( hIvasDec, nOutSamples ) || nFramesFed < 2 ) )
        bool isEmpty;
        if ( ( error = IVAS_DEC_VoIP_IsEmpty( hIvasDec, nOutSamples, &isEmpty ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) );
            goto cleanup;
        }
        if ( nextPacketRcvTime_ms == (uint32_t) ( -1 ) && ( isEmpty || nFramesFed < 2 ) )
        {
            break;
        }


        /* decode and get samples */
        while ( nSamplesRendered < nOutSamples )
        {
@@ -3468,7 +3474,7 @@ static ivas_error decodeVoIP(
                    numPiData++;
                }

                if ( ( error = IVAS_RTP_FeedPiDataToDecoder( hIvasDec, &ivasRtp.piData[ivasRtp.nProcPiData], numPiData ) ) != IVAS_ERR_OK )
                if ( ( error = IVAS_DEC_FeedPiDataToDecoder( hIvasDec, &ivasRtp.piData[ivasRtp.nProcPiData], numPiData ) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                    goto cleanup;
@@ -3477,6 +3483,7 @@ static ivas_error decodeVoIP(
                ivasRtp.nProcPiData += numPiData;
            }
#endif

#ifdef FIX_1119_SPLIT_RENDERING_VOIP
            if ( isSplitRend )
            {
@@ -3516,34 +3523,42 @@ static ivas_error decodeVoIP(
                    return error;
                }

                /* Placeholder for memory reallocation */
                /* ... */
#ifdef DECODER_FORMAT_SWITCHING
                if ( IVAS_DEC_isRestartNeeded( hIvasDec ) )
                /* restart decoder in case of format switching */
                if ( ( error = IVAS_DEC_isRestartNeeded( hIvasDec, &restartNeeded ) ) != IVAS_ERR_OK )
                {
                    IVAS_DEC_BS_FORMAT tempFormat;
                    if ( ( error = IVAS_DEC_GetFormat( hIvasDec, &tempFormat ) ) != IVAS_ERR_OK )
                    return error;
                }

                if ( restartNeeded )
                {
                    IVAS_DEC_BS_FORMAT tempBsFormat;
                    if ( ( error = IVAS_DEC_GetFormat( hIvasDec, &tempBsFormat ) ) != IVAS_ERR_OK )
                    {
                        fprintf( stderr, "\nError in IVAS_DEC_GetFormat, code: %d\n", error );
                        goto cleanup;
                    }
                    IVAS_DEC_MODE codecMode = ( tempFormat == IVAS_DEC_BS_MONO ) ? IVAS_DEC_MODE_EVS : IVAS_DEC_MODE_IVAS;
                    error = restartDecoder(

                    IVAS_DEC_MODE newDecModeInPacket = ( tempBsFormat == IVAS_DEC_BS_MONO ) ? IVAS_DEC_MODE_EVS : IVAS_DEC_MODE_IVAS;
                    if((error = restartDecoder(
                        &hIvasDec,
                        codecMode,
                        newDecModeInPacket ,
                        &arg,
                        NULL, /* ToDo : Provide rendererConfig */
                        NULL  /* ToDo : Provide LS Custom Data */
                    );
                    if ( error != IVAS_ERR_OK )
                    ) )!= IVAS_ERR_OK )
                    {
                        fprintf( stderr, "\nFailed to restart decoder\n" );
                        goto cleanup;
                    }

                    *phIvasDec = hIvasDec; /* Update for main()' s free */
                }
#endif

                /* Placeholder for memory reallocation */
                /* ... */

                /* Load HRTF binary file data */
                if ( arg.hrtfReaderEnabled )
                {
@@ -3859,7 +3874,6 @@ static ivas_error decodeVoIP(
        }
    }


    /*------------------------------------------------------------------------------------------*
     * Add zeros at the end to have equal length of synthesized signals
     *------------------------------------------------------------------------------------------*/
@@ -4322,9 +4336,15 @@ static ivas_error load_hrtf_from_file(

#ifdef DECODER_FORMAT_SWITCHING

ivas_error restartDecoder(
/*---------------------------------------------------------------------*
 * restartDecoder()
 *
 * Restart decoder in case of IVAS format switching
 *---------------------------------------------------------------------*/

static ivas_error restartDecoder(
    IVAS_DEC_HANDLE *phIvasDec,
    IVAS_DEC_MODE codec,
    const IVAS_DEC_MODE decMode,
    DecArguments *arg,
    IVAS_RENDER_CONFIG_DATA *renderConfig,
    IVAS_CUSTOM_LS_DATA *hLsCustomData )
@@ -4342,19 +4362,19 @@ ivas_error restartDecoder(
        IVAS_DEC_Close( phIvasDec );
    }

    if ( ( error = IVAS_DEC_Open( phIvasDec, codec ) ) != IVAS_ERR_OK )
    if ( ( error = IVAS_DEC_Open( phIvasDec, decMode ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "Open failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
        goto cleanup;
    }

    arg->decMode = codec;
    arg->decMode = decMode;

    hIvasDec = *phIvasDec;

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

    IVAS_AUDIO_CONFIG outputConfig = ( codec == IVAS_DEC_MODE_IVAS ) ? arg->outputConfig : IVAS_AUDIO_CONFIG_MONO;
    IVAS_AUDIO_CONFIG outputConfig = ( decMode == IVAS_DEC_MODE_IVAS ) ? arg->outputConfig : IVAS_AUDIO_CONFIG_MONO;
#ifdef FIX_1318_ROOM_SIZE_CMD_LINE
    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,
@@ -4429,6 +4449,7 @@ ivas_error restartDecoder(

cleanup:
    IVAS_DEC_Close( phIvasDec );

    return error;
}

+12 −6
Original line number Diff line number Diff line
@@ -63,10 +63,6 @@
#endif
#endif

#ifdef FIXED_RTP_SEQUENCE_NUM
#define RANDOM_INITSEED_ENC ( 0xFEEDDEAF )
#endif

#define WMC_TOOL_SKIP

/*------------------------------------------------------------------------------------------*
@@ -78,6 +74,10 @@ static
#endif
    int32_t frame = 0; /* Counter of frames */

#ifdef FIXED_RTP_SEQUENCE_NUM
#define RANDOM_INITSEED_ENC ( 0xFEEDDEAF )
#endif

#define DEFAULT_FIXED_SID_RATE 8 /* DTX SID rate */

/* Additional config info for each input format */
@@ -468,14 +468,14 @@ int main(
            if ( ( error = IVAS_ENC_ConfigureForSBAObjects( hIvasEnc, arg.inputFs, totalBitrate, bandwidth, arg.dtxConfig, arg.inputFormatConfig.sba_ism.numObjects, arg.inputFormatConfig.sba_ism.order, arg.inputFormatConfig.sba_ism.isPlanar, arg.pca ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nIVAS_ENC_ConfigureForSBAObjects failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) );
                exit( -1 );
                goto cleanup;
            }
            break;
        case IVAS_ENC_INPUT_MASA_ISM:
            if ( ( error = IVAS_ENC_ConfigureForMASAObjects( hIvasEnc, arg.inputFs, totalBitrate, bandwidth, arg.dtxConfig, arg.inputFormatConfig.masa_ism.numObjects, arg.inputFormatConfig.masa_ism.masaVariant ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nIVAS_ENC_ConfigureForMASAObjects failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) );
                exit( -1 );
                goto cleanup;
            }
            break;
        default:
@@ -672,6 +672,10 @@ int main(
    }
#endif

    /*------------------------------------------------------------------------------------------*
     * Run the encoder
     *------------------------------------------------------------------------------------------*/

    int16_t numSamplesRead = 0;
    uint16_t bitStream[IVAS_MAX_BITS_PER_FRAME];
    uint16_t numBits = 0;
@@ -1841,6 +1845,7 @@ static bool parseCmdlIVAS_enc(
        {
            i++;
            arg->rtpdumpOutput = true;

            if ( i < argc - 4 )
            {
                if ( !is_digits_only( argv[i] ) )
@@ -1857,6 +1862,7 @@ static bool parseCmdlIVAS_enc(
                    }
                }
            }

            fprintf( stdout, "Output format: RTPDump using %d frames/packet \n", arg->numFramesPerPacket );
        }

+41 −14
Original line number Diff line number Diff line
@@ -63,10 +63,6 @@
#endif
#endif

#ifdef FIXED_RTP_SEQUENCE_NUM
#define RANDOM_INITSEED_ENC ( 0xFEEDDEAF )
#endif

#define WMC_TOOL_SKIP

/*------------------------------------------------------------------------------------------*
@@ -81,6 +77,10 @@ static
#endif
    int32_t frame = 0; /* Counter of frames */

#ifdef FIXED_RTP_SEQUENCE_NUM
#define RANDOM_INITSEED_ENC ( 0xFEEDDEAF )
#endif

#define DEFAULT_FIXED_SID_RATE 8 /* DTX SID rate */

/* Additional config info for each input format */
@@ -199,13 +199,14 @@ static int encoder_main( int argc, char *argv[] );
 * main()
 *
 * Main IVAS encoder function for command-line interface
 * supporting format switching
 * supporting IVAS format switching
 *------------------------------------------------------------------------------------------*/

int main(
    int argc,
    char *argv[] )
{
    bool mainFailed = true; /* Assume main failed until cleanup is reached without errors */
    FILE *FmtSWFile = NULL;
    char line[2048];
    int argc_local = 0;
@@ -218,18 +219,18 @@ int main(

    IVAS_ENC_PrintDisclaimer();

    if ( argc != 2 )
    if ( argc != 3 )
    {
        fprintf( stdout, "Usage: IVAS_cod_fmtsw.exe format_switching_file\n\n" );
        fprintf( stdout, "where format_switching_file is a text file containg a valid encoder command line in each line\n\n" );
        exit( 0 );
        goto cleanup;
    }
    fprintf( stdout, "Input format switching file: %s\n", argv[1] );

    if ( ( FmtSWFile = fopen( argv[1], "r" ) ) == NULL )
    {
        fprintf( stdout, "error: cannot open format switching file %s\n", argv[1] );
        exit( 0 );
        goto cleanup;
    }

    while ( fgets( line, sizeof( line ), FmtSWFile ) )
@@ -238,11 +239,15 @@ int main(
        line[strcspn( line, "\r\n" )] = 0;
        printf( "Processing format switching commandline: %s\n", line );
        str2arg( line, &argc_local, argv_local );

#ifdef IVAS_RTPDUMP
        if ( strcmp( argv_local[argc_local - 1], (char *) prev_outputBitstreamFilename ) == 0 )
        {
            /* append to last Rtp file */
            encoder_main( argc_local, argv_local, &ivasRtp, 0 );
            if ( encoder_main( argc_local, argv_local, &ivasRtp, 0 ) != 0 )
            {
                goto cleanup;
            }
        }
        else
        {
@@ -250,8 +255,13 @@ int main(
            {
                IVAS_RTP_Term( &ivasRtp );
            }

            /* write in separate Rtp file */
            encoder_main( argc_local, argv_local, &ivasRtp, 1 );
            if ( encoder_main( argc_local, argv_local, &ivasRtp, 1 ) != 0 )
            {
                goto cleanup;
            }

            rtp_term = 1;
        }
        strcpy( (char *) prev_outputBitstreamFilename, argv_local[argc_local - 1] );
@@ -259,11 +269,24 @@ int main(
        encoder_main( argc_local, argv_local );
#endif
    }

    /*------------------------------------------------------------------------------------------*
     * Close files and deallocate resources
     *------------------------------------------------------------------------------------------*/

    mainFailed = false; /* This will stay set to true if cleanup is reached via a goto due to an error */

cleanup:

#ifdef IVAS_RTPDUMP
    IVAS_RTP_Term( &ivasRtp );
#endif
    if( FmtSWFile)
    {
        fclose( FmtSWFile );
    exit( 0 );
    }

    return mainFailed ? -1 : 0;
}


@@ -568,14 +591,14 @@ int encoder_main(
            if ( ( error = IVAS_ENC_ConfigureForSBAObjects( hIvasEnc, arg.inputFs, totalBitrate, bandwidth, arg.dtxConfig, arg.inputFormatConfig.sba_ism.numObjects, arg.inputFormatConfig.sba_ism.order, arg.inputFormatConfig.sba_ism.isPlanar, arg.pca ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nIVAS_ENC_ConfigureForSBAObjects failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) );
                exit( -1 );
                goto cleanup;
            }
            break;
        case IVAS_ENC_INPUT_MASA_ISM:
            if ( ( error = IVAS_ENC_ConfigureForMASAObjects( hIvasEnc, arg.inputFs, totalBitrate, bandwidth, arg.dtxConfig, arg.inputFormatConfig.masa_ism.numObjects, arg.inputFormatConfig.masa_ism.masaVariant ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nIVAS_ENC_ConfigureForMASAObjects failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) );
                exit( -1 );
                goto cleanup;
            }
            break;
        default:
@@ -772,6 +795,10 @@ int encoder_main(
    }
#endif

    /*------------------------------------------------------------------------------------------*
     * Run the encoder
     *------------------------------------------------------------------------------------------*/

    int16_t numSamplesRead = 0;
    uint16_t bitStream[IVAS_MAX_BITS_PER_FRAME];
    uint16_t numBits = 0;
+1 −0
Original line number Diff line number Diff line
@@ -3860,6 +3860,7 @@ void convertSerialToBytestream_fx(
    UWord8 bitinbyte2, bytestream_tmp;
    assert( num_bits <= MAX_16 ); /* 512 kbps = 10240 bits, num_bits should always fits Word16 */
#endif

    FOR( i = 0; i < num_bits; ++i )
    {
        IF( EQ_32( serial[i], 0x0001 ) )
+3 −0
Original line number Diff line number Diff line
@@ -62,6 +62,9 @@
#define IVAS_REVERB_PREDELAY_MAX         20 /* Max input delay for reverb module */
#define IVAS_ER_LIST_HEIGHT              1.6f
#define IVAS_ER_LIST_HEIGHT_FX           6710886 /* 1.6f in Q.22 */
#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT
#define IVAS_DEFAULT_AEID                65535
#endif

/* JBM constants for adaptive-playout */
#define IVAS_TIME_SCALE_MIN 50  /* min. time-scaling [%] */
Loading