diff --git a/Workspace_msvc/lib_util.vcxproj b/Workspace_msvc/lib_util.vcxproj
index 85859e257cb0d7e5ebb4efb670a53c44e7cd6361..ac1fda37471067bd220d940241ae010a92c8f9a4 100644
--- a/Workspace_msvc/lib_util.vcxproj
+++ b/Workspace_msvc/lib_util.vcxproj
@@ -129,6 +129,7 @@
+
@@ -165,6 +166,7 @@
+
diff --git a/Workspace_msvc/lib_util.vcxproj.filters b/Workspace_msvc/lib_util.vcxproj.filters
index 07c8fdfe435e4f5835dd69ec4c25598d4e67e0f4..f79a53552b211e14186b17678bed9f4a8aaa5f64 100644
--- a/Workspace_msvc/lib_util.vcxproj.filters
+++ b/Workspace_msvc/lib_util.vcxproj.filters
@@ -67,6 +67,9 @@
util_c
+
+ util_c
+
util_c
@@ -165,6 +168,9 @@
util_h
+
+ util_h
+
util_h
diff --git a/apps/encoder.c b/apps/encoder.c
index ebb81866e0996a8b17758643f4b37b68b5a99f4e..0bd9b60b3789bb36f13e583535c796a24319bb6f 100644
--- a/apps/encoder.c
+++ b/apps/encoder.c
@@ -40,6 +40,9 @@
#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
@@ -157,6 +160,9 @@ typedef struct
char *sceneOrientationTrajFileName;
char *deviceOrientationTrajFileName;
+#ifdef FIX_1527_CMR_BITRATE_IDX
+ char *requestsFileName;
+#endif
} EncArguments;
@@ -224,6 +230,9 @@ 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 */
@@ -656,6 +665,20 @@ int main(
}
}
+#ifdef FIX_1527_CMR_BITRATE_IDX
+ /*------------------------------------------------------------------------------------------*
+ * Open remote requests file for rtp packing (E-bytes)
+ *------------------------------------------------------------------------------------------*/
+ if ( arg.requestsFileName != NULL )
+ {
+ 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
+
/*------------------------------------------------------------------------------------------*
* Run the encoder
*------------------------------------------------------------------------------------------*/
@@ -865,6 +888,17 @@ int main(
}
}
+#ifdef FIX_1527_CMR_BITRATE_IDX
+ if ( requestsFileReader )
+ {
+ if ( ( error = ReadNextRequests( requestsFileReader, ivasRtp.remoteRequests, &ivasRtp.remoteRequestBitmap ) ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nError %s while reading requests from %s\n", IVAS_ENC_GetErrorMessage( error ), RequestsFileReader_getFilePath( requestsFileReader ) );
+ goto cleanup;
+ }
+ }
+#endif
+
if ( ( error = IVAS_ENC_EncodeFrameToCompact( hIvasEnc, pcmBuf, pcmBufSize, au, &numBits ) ) != IVAS_ERR_OK )
{
fprintf( stderr, "\nencodeFrame failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) );
@@ -969,6 +1003,13 @@ cleanup:
fclose( f_bitrateProfile );
}
+#ifdef FIX_1527_CMR_BITRATE_IDX
+ if ( requestsFileReader )
+ {
+ RequestsFileReader_close( &requestsFileReader );
+ }
+#endif
+
if ( sceneOrientationFileReader )
{
RotationFileReader_close( &sceneOrientationFileReader );
@@ -1030,6 +1071,10 @@ 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;
@@ -1910,6 +1955,20 @@ static bool parseCmdlIVAS_enc(
arg->deviceOrientationTrajFileName = argv[i];
i++;
}
+#ifdef FIX_1527_CMR_BITRATE_IDX
+ else if ( strcmp( argv_to_upper, "-REQUESTS" ) == 0 )
+ {
+ i++;
+ if ( argc - i <= 4 || argv[i][0] == '-' )
+ {
+ fprintf( stderr, "Error: Remote requests file name not specified!\n\n" );
+ usage_enc();
+ return false;
+ }
+ arg->requestsFileName = argv[i];
+ i++;
+ }
+#endif
/*-----------------------------------------------------------------*
* Option not recognized
@@ -2148,6 +2207,10 @@ static void usage_enc( void )
fprintf( stdout, " EVS RTP Payload Format is used. Optional N represents number of frames per RTP packet\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" );
return;
diff --git a/lib_com/options.h b/lib_com/options.h
index bbea3aa1534059d14c1f9b80304d8ebe81ea7d42..69b0e3d9d98cda5cf06bb4ff0a6ef8c5327b71f2 100644
--- a/lib_com/options.h
+++ b/lib_com/options.h
@@ -162,6 +162,7 @@
#define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */
#define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */
+#define FIX_1527_CMR_BITRATE_IDX /* Fix for incorrect bitrate idx packed in rtp CMR E-byte */
/* #################### End BE switches ################################## */
diff --git a/lib_util/ivas_rtp_file.c b/lib_util/ivas_rtp_file.c
index 35733681c0249f1e198c3db1d2b994eb125659d0..26149f634577abab5976cb03826d8578ddce6bf3 100644
--- a/lib_util/ivas_rtp_file.c
+++ b/lib_util/ivas_rtp_file.c
@@ -952,6 +952,20 @@ ivas_error IVAS_RTP_WriteNextFrame(
rtp->nWrittenPiData--;
}
+#ifdef FIX_1527_CMR_BITRATE_IDX
+ for ( IVAS_RTP_REQUEST_TYPE req = 0; req < IVAS_REQUEST_MAX; req++ )
+ {
+ if ( rtp->remoteRequestBitmap & ( 1u << req ) )
+ {
+ if ( ( error = IVAS_RTP_PACK_PushRemoteRequest( rtp->hPack, req, rtp->remoteRequests[req] ) ) != IVAS_ERR_OK )
+ {
+ fprintf( stderr, "\nError %s while pushing requests\n", ivas_error_to_string( error ) );
+ return error;
+ }
+ }
+ }
+#endif
+
if ( forcePacket || IVAS_RTP_PACK_GetNumFrames( rtp->hPack ) == rtp->packCfg.maxFramesPerPacket )
{
uint32_t numFramesInPayload = 0;
diff --git a/lib_util/ivas_rtp_file.h b/lib_util/ivas_rtp_file.h
index a3742c6c81ad277a5d96f851a7bf6e660279f017..9e0c2906abebf420da6983fb5e40eabb8a3f3ba5 100644
--- a/lib_util/ivas_rtp_file.h
+++ b/lib_util/ivas_rtp_file.h
@@ -44,6 +44,9 @@ typedef struct
uint8_t packet[NOMINAL_BUFFER_SIZE( IVAS_MAX_FRAMES_PER_RTP_PACKET )];
IVAS_PIDATA_TS piData[IVAS_PI_MAX_ID * IVAS_MAX_FRAMES_PER_RTP_PACKET];
+#ifdef FIX_1527_CMR_BITRATE_IDX
+ IVAS_RTP_REQUEST_VALUE remoteRequests[IVAS_REQUEST_MAX];
+#endif
IVAS_RTP_FILE_HANDLE hRtpFile;
FILE *f_piDataOut;
FILE *f_piExtOut;
diff --git a/lib_util/ivas_rtp_payload.c b/lib_util/ivas_rtp_payload.c
index 71b70fcc21f28485f0eb019c970a73069a1bd940..c8fd3bc91cf5741df4a285d37769201bcef98e13 100644
--- a/lib_util/ivas_rtp_payload.c
+++ b/lib_util/ivas_rtp_payload.c
@@ -641,7 +641,11 @@ static uint32_t getBitrateIdx( const uint32_t *table, uint32_t tableLen, uint32_
for ( n = 0; n < tableLen; n++ )
{
+#ifdef FIX_1527_CMR_BITRATE_IDX
+ if ( bitrate >= ( table[n] * IVAS_NUM_FRAMES_PER_SEC ) )
+#else
if ( bitrate > ( table[n] * IVAS_NUM_FRAMES_PER_SEC ) )
+#endif
{
idx = n;
}
@@ -707,7 +711,11 @@ static void packEBytes(
/* EVS Modes */
bitrate = ( bitrate > 128000 ) ? 128000 : bitrate;
bitrate = ( bitrate < 5900 ) ? 5900 : bitrate;
+#ifdef FIX_1527_CMR_BITRATE_IDX
+ bitrateIdx = getBitrateIdx( evsFrameSizeInBits, ( sizeof( evsFrameSizeInBits ) / sizeof( evsFrameSizeInBits[0] ) ) - 1, bitrate );
+#else
bitrateIdx = getBitrateIdx( evsFrameSizeInBits, sizeof( evsFrameSizeInBits ) / sizeof( evsFrameSizeInBits[0] ), bitrate );
+#endif
BR = (uint8_t) bitrateIdx & MASK_4BIT;
/* If a bandwidth choice cannot be signalled for a given bitrate
@@ -771,7 +779,11 @@ static void packEBytes(
/* Initial E-Byte */
bitrate = ( bitrate > 512000 ) ? 512000 : bitrate;
bitrate = ( bitrate < 13200 ) ? 13200 : bitrate;
+#ifdef FIX_1527_CMR_BITRATE_IDX
+ bitrateIdx = getBitrateIdx( ivasFrameSizeInBits, ( sizeof( ivasFrameSizeInBits ) / sizeof( ivasFrameSizeInBits[0] ) ) - 2, bitrate );
+#else
bitrateIdx = getBitrateIdx( ivasFrameSizeInBits, sizeof( ivasFrameSizeInBits ) / sizeof( ivasFrameSizeInBits[0] ), bitrate );
+#endif
BR = (uint8_t) bitrateIdx & MASK_4BIT;
if ( nByte < maxNumEBytes )
{
diff --git a/lib_util/requests_file_reader.c b/lib_util/requests_file_reader.c
new file mode 100644
index 0000000000000000000000000000000000000000..894b07568f9f345333085e802c9a92850ef3ee04
--- /dev/null
+++ b/lib_util/requests_file_reader.c
@@ -0,0 +1,167 @@
+/******************************************************************************************************
+
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+ Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+ Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+ contributors to this repository. All Rights Reserved.
+
+ This software is protected by copyright law and by international treaties.
+ The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
+ Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+ Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+ Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+ contributors to this repository retain full ownership rights in their respective contributions in
+ the software. This notice grants no license of any kind, including but not limited to patent
+ license, nor is any license granted by implication, estoppel or otherwise.
+
+ Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
+ contributions.
+
+ This software is provided "AS IS", without any express or implied warranties. The software is in the
+ development stage. It is intended exclusively for experts who have experience with such software and
+ solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
+ and fitness for a particular purpose are hereby disclaimed and excluded.
+
+ Any dispute, controversy or claim arising under or in relation to providing this software shall be
+ submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
+ accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
+ the United Nations Convention on Contracts on the International Sales of Goods.
+
+*******************************************************************************************************/
+
+#include "requests_file_reader.h"
+#include
+#include
+#include
+
+
+struct ReqFileReader
+{
+ FILE *requestsFile;
+ int32_t frameCounter;
+ char *file_path;
+ bool fileRewind;
+};
+
+
+/*-----------------------------------------------------------------------*
+ * RequestsFileReader_open()
+ *
+ * Allocate and initialize requests reader
+ *-----------------------------------------------------------------------*/
+
+ivas_error RequestsFileReader_open(
+ char *requestsFilePath, /* i : requests file name */
+ ReqFileReader **reqReader /* o : ReqFileReader handle */
+)
+{
+ ReqFileReader *self;
+ FILE *requestsFile;
+
+ /* Open trajectory file */
+ if ( strlen( requestsFilePath ) < 1 )
+ {
+ return IVAS_ERR_FAILED_FILE_OPEN;
+ }
+
+ requestsFile = fopen( requestsFilePath, "r" );
+
+ if ( !requestsFile )
+ {
+ return IVAS_ERR_FAILED_FILE_OPEN;
+ }
+
+ self = calloc( 1, sizeof( ReqFileReader ) );
+ self->requestsFile = requestsFile;
+ self->frameCounter = 0;
+ self->file_path = calloc( strlen( requestsFilePath ) + 1, sizeof( char ) );
+ strcpy( self->file_path, requestsFilePath );
+ self->fileRewind = false;
+
+ *reqReader = self;
+
+ return IVAS_ERR_OK;
+}
+
+/*-----------------------------------------------------------------------*
+ * RequestsFileReader_close()
+ *
+ * Deallocates memory for the requests reader
+ *-----------------------------------------------------------------------*/
+
+void RequestsFileReader_close(
+ ReqFileReader **reqReader /* i/o: ReqFileReader handle */
+)
+{
+ if ( reqReader == NULL || *reqReader == NULL )
+ {
+ return;
+ }
+
+ fclose( ( *reqReader )->requestsFile );
+ free( ( *reqReader )->file_path );
+ free( *reqReader );
+ *reqReader = NULL;
+
+ return;
+}
+
+/*-----------------------------------------------------------------------*
+ * ReadNextRequests()
+ *
+ * Read request for next frame from the requests file
+ *-----------------------------------------------------------------------*/
+
+ivas_error ReadNextRequests(
+ ReqFileReader *reqReader, /* i/o: ReqFileReader handle */
+ IVAS_RTP_REQUEST_VALUE reqs[IVAS_REQUEST_MAX], /* o : Requests buffer buffer */
+ uint32_t *remoteRequestBitmap /* o : Bitmap of available request */
+)
+{
+ *remoteRequestBitmap = 0u;
+ if ( !feof( reqReader->requestsFile ) )
+ {
+ if ( IVAS_REQUEST_MAX != fscanf( reqReader->requestsFile, "%d,%d,%d,%d,%d,%d,%d\n",
+ (int32_t *) &reqs[IVAS_REQUEST_CODEC].codec,
+ (int32_t *) &reqs[IVAS_REQUEST_BITRATE].bitrate,
+ (int32_t *) &reqs[IVAS_REQUEST_BANDWIDTH].bandwidth,
+ (int32_t *) &reqs[IVAS_REQUEST_FORMAT].formatType,
+ (int32_t *) &reqs[IVAS_REQUEST_CA_MODE].caMode,
+ (int32_t *) &reqs[IVAS_REQUEST_SUBFORMAT].subFormatType,
+ (int32_t *) &reqs[IVAS_REQUEST_SR_CONFIG].srConfig ) )
+ {
+ return IVAS_ERR_FAILED_FILE_PARSE;
+ }
+
+ /* Indicate Request present if not equal to -1 */
+ for ( IVAS_RTP_REQUEST_TYPE req = 0; req < IVAS_REQUEST_MAX; req++ )
+ {
+ if ( reqs[req].bitrate != ( ~0u ) )
+ {
+ *remoteRequestBitmap |= ( 1u << req );
+ }
+ }
+ }
+
+ return IVAS_ERR_OK;
+}
+
+
+/*-----------------------------------------------------------------------*
+ * HeadRequestsFileReader_getFilePath()
+ *
+ *
+ *-----------------------------------------------------------------------*/
+
+const char *RequestsFileReader_getFilePath(
+ ReqFileReader *reqReader /* i/o: ReqFileReader handle */
+)
+{
+ if ( reqReader == NULL )
+ {
+ return NULL;
+ }
+
+ return reqReader->file_path;
+}
diff --git a/lib_util/requests_file_reader.h b/lib_util/requests_file_reader.h
new file mode 100644
index 0000000000000000000000000000000000000000..0918dd3447ec28f676e8713a0bc8486b5d176e83
--- /dev/null
+++ b/lib_util/requests_file_reader.h
@@ -0,0 +1,85 @@
+/******************************************************************************************************
+
+ (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+ Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+ Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+ contributors to this repository. All Rights Reserved.
+
+ This software is protected by copyright law and by international treaties.
+ The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
+ Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+ Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+ Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+ contributors to this repository retain full ownership rights in their respective contributions in
+ the software. This notice grants no license of any kind, including but not limited to patent
+ license, nor is any license granted by implication, estoppel or otherwise.
+
+ Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
+ contributions.
+
+ This software is provided "AS IS", without any express or implied warranties. The software is in the
+ development stage. It is intended exclusively for experts who have experience with such software and
+ solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
+ and fitness for a particular purpose are hereby disclaimed and excluded.
+
+ Any dispute, controversy or claim arising under or in relation to providing this software shall be
+ submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
+ accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
+ the United Nations Convention on Contracts on the International Sales of Goods.
+
+*******************************************************************************************************/
+
+#ifndef IVAS_REQUESTS_FILE_READER_H
+#define IVAS_REQUESTS_FILE_READER_H
+
+#include "common_api_types.h"
+#include "ivas_rtp_api.h"
+
+typedef struct ReqFileReader ReqFileReader;
+
+/*-----------------------------------------------------------------------*
+ * RequestsFileReader_open()
+ *
+ * Allocate and initialize requests handle
+ *-----------------------------------------------------------------------*/
+
+ivas_error RequestsFileReader_open(
+ char *requestsFilePath, /* i : requests file name */
+ ReqFileReader **reqReader /* o : ReqFileReader handle */
+);
+
+/*-----------------------------------------------------------------------*
+ * RequestsFileReading()
+ *
+ * Read values from the trajectory file
+ *-----------------------------------------------------------------------*/
+
+ivas_error ReadNextRequests(
+ ReqFileReader *reqReader, /* i/o: ReqFileReader handle */
+ IVAS_RTP_REQUEST_VALUE reqs[IVAS_REQUEST_MAX], /* o : Requests buffer buffer */
+ uint32_t *remoteRequestBitmap /* o : Bitmap of available request */
+);
+
+/*-----------------------------------------------------------------------*
+ * RequestsFileReader_close()
+ *
+ * Deallocates memory for the requests handle
+ *-----------------------------------------------------------------------*/
+
+void RequestsFileReader_close(
+ ReqFileReader **reqReader /* i/o: ReqFileReader handle */
+);
+
+/*-----------------------------------------------------------------------*
+ * RequestsFileReader_getFilePath()
+ *
+ *
+ *-----------------------------------------------------------------------*/
+
+const char *RequestsFileReader_getFilePath(
+ ReqFileReader *reqReader /* i/o: ReqFileReader handle */
+);
+
+
+#endif /* IVAS_REQUESTS_FILE_READER_H */
diff --git a/tests/rtp/ivasrtp.py b/tests/rtp/ivasrtp.py
index d593f625e8d785f6b85d0847beffb699278ae2ef..e935f0000507d46b783ca364dcfac20617a87240 100644
--- a/tests/rtp/ivasrtp.py
+++ b/tests/rtp/ivasrtp.py
@@ -525,6 +525,26 @@ requestBitratesForCodec = {
CODECS.EVS: evsBitrates[0:12],
CODECS.IVAS: ivasBitrates[0:14],
}
+
+
+def requestBandwidthsForCodec(codec: CODECS, bitrate: int) -> list[BANDWIDTH]:
+ if codec == CODECS.AMRWB:
+ return [BANDWIDTH.WB]
+ elif codec == CODECS.IVAS:
+ return [BANDWIDTH.WB, BANDWIDTH.SWB, BANDWIDTH.FB]
+ else:
+ supportedBitrate = list()
+ if bitrate <= 24400:
+ supportedBitrate.append(BANDWIDTH.NB)
+ if bitrate <= 128000:
+ supportedBitrate.append(BANDWIDTH.WB)
+ if bitrate >= 9600 and bitrate <= 128000:
+ supportedBitrate.append(BANDWIDTH.SWB)
+ if bitrate >= 16400 and bitrate <= 128000:
+ supportedBitrate.append(BANDWIDTH.FB)
+ return supportedBitrate
+
+
rt60Value = [
0.01,
0.0126,
@@ -1344,7 +1364,7 @@ def unpackEBytes(bitstrm: ConstBitStream) -> tuple[bool, dict]:
BANDWIDTH.WB,
BANDWIDTH.SWB,
BANDWIDTH.FB,
- BANDWIDTH.NREQ,
+ NO_REQ,
]
reserved = bitstrm.read(2)
BW = bitstrm.read(2).uint
diff --git a/tests/rtp/test_rtp.py b/tests/rtp/test_rtp.py
index 76a97b03be6b3c127deed70135d658ac314ebdd2..62212149ccf21d76a0fe0ab0c04b59bf6d7c25cf 100644
--- a/tests/rtp/test_rtp.py
+++ b/tests/rtp/test_rtp.py
@@ -70,6 +70,77 @@ sys.path.append(ROOT_DIR)
from tests.conftest import EncoderFrontend, DecoderFrontend
+def test_rtp_requests_pack(test_info, dut_encoder_frontend: EncoderFrontend):
+ tmp_dir = "."
+ if True:
+ # with TemporaryDirectory() as tmp_dir:
+ reqsOutJson = Path(tmp_dir).joinpath(f"requests.json").absolute()
+ reqsOut = Path(tmp_dir).joinpath(f"requests.txt").absolute()
+ rtpdumpOut = Path(tmp_dir).joinpath(f"outrtp.rtpdump").absolute()
+
+ expectedRequests = list()
+ with open(reqsOut, "w") as fr:
+ for codec in CODECS:
+ for bitrate in requestBitratesForCodec[codec]:
+ for bandwidth in requestBandwidthsForCodec(codec, bitrate):
+ bandwidthIdx = list(BANDWIDTH).index(bandwidth)
+ if codec == CODECS.IVAS:
+ for fmtIdx, fmt in enumerate(FORMATS):
+ # Map to C API Enumuration values
+ request = dict()
+ request[REQUESTS.CODEC] = codec
+ request[REQUESTS.BR] = bitrate
+ request[REQUESTS.BW] = bandwidth
+ request[REQUESTS.FMT] = fmt
+ expectedRequests.append(request)
+ fr.write(
+ f"1,{bitrate},{bandwidthIdx},{fmtIdx},-1,-1,-1\n"
+ )
+ else:
+ request = dict()
+ request[REQUESTS.CODEC] = codec
+ request[REQUESTS.BR] = bitrate
+ request[REQUESTS.BW] = bandwidth
+ expectedRequests.append(request)
+ fr.write(f"0,{bitrate},{bandwidthIdx},-1,-1,-1,-1\n")
+
+ with open(reqsOutJson, "w") as fw:
+ json.dump(expectedRequests, fw, indent=4)
+
+ # assert False, f"Path is {reqsOutJson}"
+ dut_encoder_frontend.run(
+ bitrate=64000,
+ input_sampling_rate=48,
+ input_path=Path(ROOT_DIR).joinpath("scripts/testv/stvFOA48c.wav"),
+ output_bitstream_path=rtpdumpOut,
+ add_option_list=[
+ "-requests",
+ reqsOut.as_posix(),
+ "-sba",
+ "+1",
+ "-rtpdump",
+ "1",
+ ],
+ )
+
+ unpacker = IvasRtp()
+ unpacker.unpackFile(rtpdumpOut)
+ frmIdx = 0
+ # Validate the Expected requests to what was read in bitstream
+ for packet in unpacker.getPackets():
+ thisRequest = packet.payload.requests
+ if frmIdx < len(expectedRequests):
+ for keys in expectedRequests[frmIdx].keys():
+ assert (
+ keys in thisRequest.keys()
+ ), f"Missing Request {keys} was expected at frame {frmIdx} : {expectedRequests[frmIdx]}"
+ assert (
+ expectedRequests[frmIdx][keys] == thisRequest[keys]
+ ), f"Failed to match Request {keys} in bitstream at frame {frmIdx} : {expectedRequests[frmIdx]} vs {thisRequest[keys]}"
+ print(f"Done {frmIdx}")
+ frmIdx += 1
+
+
@pytest.mark.parametrize("dtx", [False, True])
@pytest.mark.parametrize("bitrate", [6600, 12650, 23850])
@pytest.mark.parametrize("framesPerPacket", [1, 3, 8])