Commit bb901e8f authored by Vladimir Malenovsky's avatar Vladimir Malenovsky
Browse files

Merge branch 'main' into 1154_Crash_in_decoder_free

parents 6880621b d2023947
Loading
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -110,6 +110,12 @@
    <ClCompile Include="..\lib_util\cmdl_tools.c" />
    <ClCompile Include="..\lib_util\evs_rtp_payload.c" />
    <ClCompile Include="..\lib_util\g192.c" />
    <ClCompile Include="..\lib_util\ivas_bpool.c" />
    <ClCompile Include="..\lib_util\ivas_queue.c" />
    <ClCompile Include="..\lib_util\ivas_rtp_file.c" />
    <ClCompile Include="..\lib_util\ivas_rtp_payload.c" />
    <ClCompile Include="..\lib_util\ivas_rtp_pi_data.c" />
    <ClCompile Include="..\lib_util\rtpdump.c" />
    <ClCompile Include="..\lib_util\vector3_pair_file_reader.c" />
    <ClCompile Include="..\lib_util\hrtf_file_reader.c" />
    <ClCompile Include="..\lib_util\ism_file_reader.c" />
@@ -123,7 +129,6 @@
    <ClCompile Include="..\lib_util\obj_edit_file_reader.c" />
    <ClCompile Include="..\lib_util\render_config_reader.c" />
    <ClCompile Include="..\lib_util\rotation_file_reader.c" />
    <ClCompile Include="..\lib_util\rtpdump.c" />
    <ClCompile Include="..\lib_util\split_render_file_read_write.c" />
    <ClCompile Include="..\lib_util\split_rend_bfi_file_reader.c" />
    <ClCompile Include="..\lib_util\tsm_scale_file_reader.c" />
@@ -139,6 +144,14 @@
    <ClInclude Include="..\lib_util\cmdl_tools.h" />
    <ClInclude Include="..\lib_util\evs_rtp_payload.h" />
    <ClInclude Include="..\lib_util\g192.h" />
    <ClInclude Include="..\lib_util\ivas_bpool.h" />
    <ClInclude Include="..\lib_util\ivas_queue.h" />
    <ClInclude Include="..\lib_util\ivas_rtp_api.h" />
    <ClInclude Include="..\lib_util\ivas_rtp_file.h" />
    <ClInclude Include="..\lib_util\ivas_rtp_internal.h" />
    <ClInclude Include="..\lib_util\ivas_rtp_pi_data.h" />
    <ClInclude Include="..\lib_util\mutex.h" />
    <ClInclude Include="..\lib_util\rtpdump.h" />
    <ClInclude Include="..\lib_util\vector3_pair_file_reader.h" />
    <ClInclude Include="..\lib_util\hrtf_file_reader.h" />
    <ClInclude Include="..\lib_util\ism_file_reader.h" />
@@ -152,7 +165,6 @@
    <ClInclude Include="..\lib_util\masa_file_writer.h" />
    <ClInclude Include="..\lib_util\render_config_reader.h" />
    <ClInclude Include="..\lib_util\rotation_file_reader.h" />
    <ClInclude Include="..\lib_util\rtpdump.h" />
    <ClInclude Include="..\lib_util\split_render_file_read_write.h" />
    <ClInclude Include="..\lib_util\tinywavein_c.h" />
    <ClInclude Include="..\lib_util\tinywaveout_c.h" />
+42 −6
Original line number Diff line number Diff line
@@ -67,9 +67,6 @@
    <ClCompile Include="..\lib_util\rotation_file_reader.c">
      <Filter>util_c</Filter>
    </ClCompile>
    <ClCompile Include="..\lib_util\rtpdump.c">
      <Filter>util_c</Filter>
    </ClCompile>
    <ClCompile Include="..\lib_util\split_rend_bfi_file_reader.c">
      <Filter>util_c</Filter>
    </ClCompile>
@@ -82,6 +79,24 @@
    <ClCompile Include="..\lib_util\vector3_pair_file_reader.c">
      <Filter>util_c</Filter>
    </ClCompile>
    <ClCompile Include="..\lib_util\ivas_bpool.c">
      <Filter>util_c</Filter>
    </ClCompile>
    <ClCompile Include="..\lib_util\ivas_queue.c">
      <Filter>util_c</Filter>
    </ClCompile>
    <ClCompile Include="..\lib_util\ivas_rtp_file.c">
      <Filter>util_c</Filter>
    </ClCompile>
    <ClCompile Include="..\lib_util\ivas_rtp_payload.c">
      <Filter>util_c</Filter>
    </ClCompile>
    <ClCompile Include="..\lib_util\ivas_rtp_pi_data.c">
      <Filter>util_c</Filter>
    </ClCompile>
    <ClCompile Include="..\lib_util\rtpdump.c">
      <Filter>util_c</Filter>
    </ClCompile>
  </ItemGroup>
  <ItemGroup>
    <ClInclude Include="..\lib_util\aeid_file_reader.h">
@@ -150,9 +165,6 @@
    <ClInclude Include="..\lib_util\rotation_file_reader.h">
      <Filter>util_h</Filter>
    </ClInclude>
    <ClInclude Include="..\lib_util\rtpdump.h">
      <Filter>util_h</Filter>
    </ClInclude>
    <ClInclude Include="..\lib_util\split_rend_bfi_file_reader.h">
      <Filter>util_h</Filter>
    </ClInclude>
@@ -171,6 +183,30 @@
    <ClInclude Include="..\lib_util\vector3_pair_file_reader.h">
      <Filter>util_h</Filter>
    </ClInclude>
    <ClInclude Include="..\lib_util\ivas_bpool.h">
      <Filter>util_h</Filter>
    </ClInclude>
    <ClInclude Include="..\lib_util\ivas_queue.h">
      <Filter>util_h</Filter>
    </ClInclude>
    <ClInclude Include="..\lib_util\ivas_rtp_api.h">
      <Filter>util_h</Filter>
    </ClInclude>
    <ClInclude Include="..\lib_util\ivas_rtp_file.h">
      <Filter>util_h</Filter>
    </ClInclude>
    <ClInclude Include="..\lib_util\ivas_rtp_internal.h">
      <Filter>util_h</Filter>
    </ClInclude>
    <ClInclude Include="..\lib_util\ivas_rtp_pi_data.h">
      <Filter>util_h</Filter>
    </ClInclude>
    <ClInclude Include="..\lib_util\mutex.h">
      <Filter>util_h</Filter>
    </ClInclude>
    <ClInclude Include="..\lib_util\rtpdump.h">
      <Filter>util_h</Filter>
    </ClInclude>
  </ItemGroup>
  <ItemGroup>
    <Filter Include="util_c">
+107 −2
Original line number Diff line number Diff line
@@ -38,6 +38,9 @@
#include "bitstream_reader.h"
#include "evs_rtp_payload.h"
#include "ism_file_writer.h"
#ifdef IVAS_RTPDUMP
#include "ivas_rtp_file.h"
#endif
#include "jbm_file_writer.h"
#include "hrtf_file_reader.h"
#include "ls_custom_file_reader.h"
@@ -129,6 +132,9 @@ typedef struct
    IVAS_DEC_COMPLEXITY_LEVEL complexityLevel;
    bool tsmEnabled;
    IVAS_RENDER_FRAMESIZE renderFramesize;
#ifdef IVAS_RTPDUMP
    char *piOutputFilename;
#endif
#ifdef DEBUGGING
#ifdef DEBUG_FOA_AGC
    FILE *agcBitstream; /* temporary */
@@ -738,6 +744,7 @@ int main(

    if ( arg.voipMode )
    {

#ifdef FIX_1119_SPLIT_RENDERING_VOIP
        error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, &splitRendBits, hIvasDec, pcmBuf );
#else
@@ -968,6 +975,9 @@ static bool parseCmdlIVAS_dec(
    arg->referenceVectorTrajFileName = NULL;
    arg->enableExternalOrientation = false;
    arg->externalOrientationTrajFileName = NULL;
#ifdef IVAS_RTPDUMP
    arg->piOutputFilename = NULL;
#endif

#ifdef SUPPORT_JBM_TRACEFILE
    arg->jbmTraceFilename = NULL;
@@ -1054,6 +1064,20 @@ static bool parseCmdlIVAS_dec(
            arg->inputFormat = IVAS_DEC_INPUT_FORMAT_RTPDUMP_HF;
            i++;
        }
#ifdef IVAS_RTPDUMP
        else if ( strcmp( argv_to_upper, "-PIDATAFILE" ) == 0 )
        {
            i++;
            if ( argc - i <= 3 || argv[i][0] == '-' )
            {
                fprintf( stderr, "Error: PI Data Output file name not specified!\n\n" );
                usage_dec();
                return false;
            }

            arg->piOutputFilename = argv[i++];
        }
#endif
#ifdef SUPPORT_JBM_TRACEFILE
        else if ( strcmp( argv_to_upper, "-TRACEFILE" ) == 0 )
        {
@@ -1638,10 +1662,19 @@ static void usage_dec( void )
    fprintf( stdout, "--------\n" );
    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
    fprintf( stdout, "-VOIP_hf_only=1     : VoIP mode: EVS or IVAS RTP Payload Format hf_only=1 in rtpdump\n" );
    fprintf( stdout, "                      The decoder may read rtpdump files containing TS26.445 Annex A.2.2\n" );
    fprintf( stdout, "                      EVS RTP Payload Format or rtpdump files containing TS26.253 Annex A\n" );
    fprintf( stdout, "                      IVAS RTP Payload Format. The SDP parameter hf_only is required.\n" );
    fprintf( stdout, "                      Reading RFC4867 AMR/AMR-WB RTP payload format is not supported.\n" );
    fprintf( stdout, "-PiDataFile PF        Log the timestampped PI data.\n" );
#else
    fprintf( stdout, "-VOIP_hf_only=1     : VoIP mode: EVS RTP Payload Format hf_only=1 in rtpdump\n" );
    fprintf( stdout, "                      The decoder may read rtpdump files containing TS26.445 Annex A.2.2\n" );
    fprintf( stdout, "                      EVS RTP Payload Format. The SDP parameter hf_only is required.\n" );
    fprintf( stdout, "                      Reading RFC4867 AMR/AMR-WB RTP payload format is not supported.\n" );
#endif
#ifdef SUPPORT_JBM_TRACEFILE
    fprintf( stdout, "-Tracefile TF       : VoIP mode: Generate trace file named TF. Requires -no_delay_cmp to\n" );
    fprintf( stdout, "                      be enabled so that trace contents remain in sync with audio output.\n" );
@@ -2881,24 +2914,40 @@ static ivas_error printBitstreamInfoVoip(
{
    bool previewFailed = true;
    ivas_error error = IVAS_ERR_OK;
#ifdef IVAS_RTPDUMP
    IVAS_RTP ivasRtp;
    uint8_t au[( IVAS_MAX_BITS_PER_FRAME + 7 ) >> 3];
    int16_t auSizeBits;
    uint8_t *auPtr = NULL;
#else
    FILE *f_rtpstream = NULL;
    EVS_RTPDUMP_DEPACKER rtpdumpDepacker;
    EVS_RTPDUMP_DEPACKER_ERROR rtpdumpDepackerError = EVS_RTPDUMP_DEPACKER_NO_ERROR;
    bool isAMRWB_IOmode;
    uint16_t frameTypeIndex;
    uint8_t au[( IVAS_MAX_BITS_PER_FRAME + 7 ) >> 3];
    int16_t auSizeBits;
    uint8_t *auPtr = NULL;
    bool isAMRWB_IOmode;
    uint16_t frameTypeIndex;
#endif
    bool qBit;
    uint32_t nextPacketRcvTime_ms = 0;
    uint16_t rtpSequenceNumber;
    uint32_t rtpTimeStamp;

#ifndef IVAS_RTPDUMP
    rtpdumpDepacker.rtpdump = NULL;
#endif
    switch ( arg.inputFormat )
    {
        case IVAS_DEC_INPUT_FORMAT_RTPDUMP:
        case IVAS_DEC_INPUT_FORMAT_RTPDUMP_HF:
#ifdef IVAS_RTPDUMP
            if ( ( error = IVAS_RTP_READER_Init( &ivasRtp, arg.inputBitstreamFilename, arg.piOutputFilename ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "error in IVAS_RTP_READER_Init(): %d\n", error );
                goto cleanup;
            }
#else
            f_rtpstream = fopen( arg.inputBitstreamFilename, "r" );

            if ( f_rtpstream == NULL )
@@ -2913,6 +2962,7 @@ static ivas_error printBitstreamInfoVoip(
                fprintf( stderr, "error in EVS_RTPDUMP_DEPACKER_open(): %d\n", rtpdumpDepackerError );
                goto cleanup;
            }
#endif
            break;
        case IVAS_DEC_INPUT_FORMAT_G192:
            auPtr = au;
@@ -2933,12 +2983,20 @@ static ivas_error printBitstreamInfoVoip(
        else
        {
            auPtr = au; /* might have been set to RTP packet in prev call */
#ifdef IVAS_RTPDUMP
            error = IVAS_RTP_ReadNextFrame( &ivasRtp, auPtr, &auSizeBits, &rtpTimeStamp, &rtpSequenceNumber, &nextPacketRcvTime_ms, &qBit );
#else
            rtpdumpDepackerError = EVS_RTPDUMP_DEPACKER_readNextFrame( &rtpdumpDepacker, &rtpSequenceNumber, &rtpTimeStamp, &nextPacketRcvTime_ms, &isAMRWB_IOmode, &frameTypeIndex, &qBit, &auPtr, (uint16_t *) &auSizeBits );
#endif

            /* EVS RTP payload format has timescale 16000, JBM uses 1000 internally */
            rtpTimeStamp = rtpTimeStamp / 16;
        }
#ifdef IVAS_RTPDUMP
        if ( error != IVAS_ERR_OK )
#else
        if ( error != IVAS_ERR_OK || rtpdumpDepackerError != EVS_RTPDUMP_DEPACKER_NO_ERROR )
#endif
        {
            fprintf( stderr, "failed to read first RTP packet\n" );
            goto cleanup;
@@ -2957,7 +3015,11 @@ static ivas_error printBitstreamInfoVoip(

cleanup:

#ifdef IVAS_RTPDUMP
    IVAS_RTP_Term( &ivasRtp );
#else
    EVS_RTPDUMP_DEPACKER_close( &rtpdumpDepacker );
#endif

    if ( previewFailed && error == IVAS_ERR_OK )
    {
@@ -3026,12 +3088,18 @@ static ivas_error decodeVoIP(
    int16_t delayNumSamples = -1;
    int32_t delayTimeScale = -1;
    int16_t i;
#ifdef IVAS_RTPDUMP
    IVAS_RTP ivasRtp = { 0 };
#else
    FILE *f_rtpstream = NULL;
    EVS_RTPDUMP_DEPACKER rtpdumpDepacker;
    EVS_RTPDUMP_DEPACKER_ERROR rtpdumpDepackerError = EVS_RTPDUMP_DEPACKER_NO_ERROR;
#endif
    uint8_t *auPtr = NULL;
#ifndef IVAS_RTPDUMP
    bool isAMRWB_IOmode;
    uint16_t frameTypeIndex;
#endif
    bool qBit;

    IVAS_DEC_BS_FORMAT bsFormat = IVAS_DEC_BS_UNKOWN;
@@ -3092,11 +3160,20 @@ static ivas_error decodeVoIP(

    delayNumSamples_orig[0] = -1;

#ifndef IVAS_RTPDUMP
    rtpdumpDepacker.rtpdump = NULL;
#endif
    switch ( arg.inputFormat )
    {
        case IVAS_DEC_INPUT_FORMAT_RTPDUMP:
        case IVAS_DEC_INPUT_FORMAT_RTPDUMP_HF:
#ifdef IVAS_RTPDUMP
            if ( ( error = IVAS_RTP_READER_Init( &ivasRtp, arg.inputBitstreamFilename, arg.piOutputFilename ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "error in IVAS_RTP_READER_Init(): %d\n", error );
                goto cleanup;
            }
#else
            f_rtpstream = fopen( arg.inputBitstreamFilename, "r" );

            if ( f_rtpstream == NULL )
@@ -3111,6 +3188,7 @@ static ivas_error decodeVoIP(
                fprintf( stderr, "error in EVS_RTPDUMP_DEPACKER_open(): %d\n", rtpdumpDepackerError );
                goto cleanup;
            }
#endif
            break;
        case IVAS_DEC_INPUT_FORMAT_G192:
            auPtr = au;
@@ -3152,12 +3230,20 @@ static ivas_error decodeVoIP(
    else
    {
        auPtr = au; /* might have been set to RTP packet in prev call */
#ifdef IVAS_RTPDUMP
        error = IVAS_RTP_ReadNextFrame( &ivasRtp, auPtr, &auSize, &rtpTimeStamp, &rtpSequenceNumber, &nextPacketRcvTime_ms, &qBit );
#else
        rtpdumpDepackerError = EVS_RTPDUMP_DEPACKER_readNextFrame( &rtpdumpDepacker, &rtpSequenceNumber, &rtpTimeStamp, &nextPacketRcvTime_ms, &isAMRWB_IOmode, &frameTypeIndex, &qBit, &auPtr, (uint16_t *) &auSize );
#endif

        /* EVS RTP payload format has timescale 16000, JBM uses 1000 internally */
        rtpTimeStamp = rtpTimeStamp / 16;
    }
#ifdef IVAS_RTPDUMP
    if ( error != IVAS_ERR_OK )
#else
    if ( error != IVAS_ERR_OK || rtpdumpDepackerError != EVS_RTPDUMP_DEPACKER_NO_ERROR )
#endif
    {
        fprintf( stderr, "failed to read first RTP packet\n" );
        goto cleanup;
@@ -3327,19 +3413,34 @@ static ivas_error decodeVoIP(
            else
            {
                auPtr = au; /* might have been set to RTP packet in prev call */
#ifdef IVAS_RTPDUMP
                error = IVAS_RTP_ReadNextFrame( &ivasRtp, au, &auSize, &rtpTimeStamp, &rtpSequenceNumber, &nextPacketRcvTime_ms, &qBit );

                /* IVAS RTP payload format has timescale 16000, JBM uses 1000 internally */
                rtpTimeStamp = rtpTimeStamp / 16;
#else
                rtpdumpDepackerError = EVS_RTPDUMP_DEPACKER_readNextFrame( &rtpdumpDepacker, &rtpSequenceNumber, &rtpTimeStamp,
                                                                           &nextPacketRcvTime_ms,
                                                                           &isAMRWB_IOmode, &frameTypeIndex, &qBit,
                                                                           &auPtr, (uint16_t *) &auSize );
                /* EVS RTP payload format has timescale 16000, JBM uses 1000 internally */
                rtpTimeStamp = rtpTimeStamp / 16;
#endif
            }
#ifdef IVAS_RTPDUMP
            if ( error == IVAS_ERR_END_OF_FILE )
#else
            if ( error == IVAS_ERR_END_OF_FILE || rtpdumpDepackerError == EVS_RTPDUMP_DEPACKER_EOF )
#endif
            {
                /* finished reading */
                nextPacketRcvTime_ms = (uint32_t) -1;
            }
#ifdef IVAS_RTPDUMP
            else if ( error != IVAS_ERR_OK )
#else
            else if ( error != IVAS_ERR_OK || rtpdumpDepackerError != EVS_RTPDUMP_DEPACKER_NO_ERROR )
#endif
            {
                fprintf( stderr, "\nError in BS_Reader_ReadVoipFrame_compact, error code: %d\n", error );
                goto cleanup;
@@ -3735,7 +3836,11 @@ static ivas_error decodeVoIP(

cleanup:

#ifdef IVAS_RTPDUMP
    IVAS_RTP_Term( &ivasRtp );
#else
    EVS_RTPDUMP_DEPACKER_close( &rtpdumpDepacker );
#endif
    AudioFileWriter_close( &afWriter );
#ifdef FIX_1119_SPLIT_RENDERING_VOIP
    split_rend_reader_writer_close( &splitRendWriter );
+239 −8

File changed.

Preview size limit exceeded, changes collapsed.

+24 −0
Original line number Diff line number Diff line
@@ -151,6 +151,14 @@ typedef enum
    IVAS_ERR_LC3PLUS_INVALID_BITRATE,
    IVAS_ERR_INVALID_SPLIT_REND_CONFIG,

    /*----------------------------------------*
     *               rtp errors               *
     *----------------------------------------*/
    IVAS_ERR_RTP_UNDERFLOW = 0x7000,
    IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE,
    IVAS_ERR_RTP_UNPACK_PI_DATA,
    IVAS_ERR_RTP_UNSUPPORTED_FRAME,

    /*----------------------------------------*
     *              unknown error             *
     *----------------------------------------*/
@@ -288,6 +296,22 @@ static inline const char *ivas_error_to_string( ivas_error error_code )
    {
        return "data error";
    }
    if ( ( error_code & 0x7000 ) == 0x7000 )
    {
        switch ( error_code )
        {
            case IVAS_ERR_RTP_UNDERFLOW:
                return "RTP Undeflow in reading frame/packet";
            case IVAS_ERR_RTP_INSUFFICIENT_OUTPUT_SIZE:
                return "Output buffer size is insufficient";
            case IVAS_ERR_RTP_UNPACK_PI_DATA:
                return "Unpacking PI data failure";
            case IVAS_ERR_RTP_UNSUPPORTED_FRAME:
                return "Unsupported RTP frame";
            default:
                return "rtp error";
        }
    }

    return "Unknown error";
}
Loading