diff --git a/Workspace_msvc/lib_util.vcxproj b/Workspace_msvc/lib_util.vcxproj
index bfbfa8d4cfcb5cde0cfbb9ee005bd22b7c228761..b0c380c38602e3c8d6725f967b60210984351870 100644
--- a/Workspace_msvc/lib_util.vcxproj
+++ b/Workspace_msvc/lib_util.vcxproj
@@ -129,6 +129,7 @@
+
@@ -164,6 +165,7 @@
+
diff --git a/apps/encoder.c b/apps/encoder.c
index e157cc8c60e7a9a60f10f393d13f7d5043ffbd57..420c80c57c72977888e6b4dadf36a47b8b26f881 100644
--- a/apps/encoder.c
+++ b/apps/encoder.c
@@ -45,6 +45,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
#include "wmc_auto.h"
@@ -165,6 +168,9 @@ typedef struct
char *sceneOrientationTrajFileName;
char *deviceOrientationTrajFileName;
+#ifdef FIX_1527_CMR_BITRATE_IDX
+ char *requestsFileName;
+#endif
} EncArguments;
@@ -221,6 +227,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 */
@@ -658,6 +667,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
*------------------------------------------------------------------------------------------*/
@@ -867,6 +890,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 ) );
@@ -962,6 +996,13 @@ cleanup:
fclose( f_bitrateProfile );
}
+#ifdef FIX_1527_CMR_BITRATE_IDX
+ if ( requestsFileReader )
+ {
+ RequestsFileReader_close( &requestsFileReader );
+ }
+#endif
+
if ( sceneOrientationFileReader )
{
RotationFileReader_close( &sceneOrientationFileReader );
@@ -1008,6 +1049,9 @@ static bool parseCmdlIVAS_enc(
/*-----------------------------------------------------------------*
* Set default values
*-----------------------------------------------------------------*/
+#ifdef FIX_1527_CMR_BITRATE_IDX
+ memset( arg, 0, sizeof( *arg ) );
+#endif
arg->inputWavFilename = NULL;
arg->outputBitstreamFilename = NULL;
@@ -1874,6 +1918,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
@@ -2093,6 +2151,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_util/ivas_rtp_file.c b/lib_util/ivas_rtp_file.c
index 3a6ccaddc376eb0b530f4cbd385ab05d2066223f..4d5065890cce126b9d74a4eb2e62022aa3e5cca7 100644
--- a/lib_util/ivas_rtp_file.c
+++ b/lib_util/ivas_rtp_file.c
@@ -1016,6 +1016,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 4483dea95b58926423fc9c8629a929f14ff5bdce..57af1826cce9db54d8e4a7f9ba3195c1d78a84ca 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/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 */