From b1148b031af972d74bd92f5f40ddfab950f1940f Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Thu, 13 Nov 2025 17:02:34 +0200 Subject: [PATCH 1/2] Add own random generator for rtp --- apps/decoder.c | 13 +++++++++++++ apps/encoder.c | 13 +++++++++++++ apps/encoder_fmtsw.c | 13 +++++++++++++ lib_com/options.h | 2 ++ lib_util/ivas_rtp_file.c | 7 +++++++ lib_util/ivas_rtp_file.h | 1 + 6 files changed, 49 insertions(+) diff --git a/apps/decoder.c b/apps/decoder.c index 0b1c48ddb1..0069252302 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -80,9 +80,13 @@ static #define NUM_BITS_SID_IVAS_5K2 104 #endif +#ifdef NONBE_FIX_BASOP_2233_RTPDUMP_DIFFERING_BITSTREAMS +#define RANDOM_INITSEED_DEC ( 0xFADE ) +#else #ifdef FIXED_RTP_SEQUENCE_NUM #define RANDOM_INITSEED_DEC ( 0xFEEDFADE ) #endif +#endif /*------------------------------------------------------------------------------------------* * Local structure for storing cmdln arguments @@ -2050,6 +2054,14 @@ static ivas_error initOnFirstGoodFrame( int16_t splitRendIsarFrameSizeMs; int16_t lc3plusHighRes; +#ifdef NONBE_FIX_BASOP_2233_RTPDUMP_DIFFERING_BITSTREAMS + /* 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 */ + uint16_t rtpDecSeed = RANDOM_INITSEED_DEC; + uint32_t ssrc = (uint16_t) IVAS_RTP_OwnRandom( &rtpDecSeed ) | (uint16_t) IVAS_RTP_OwnRandom( &rtpDecSeed ) << 16; + uint16_t seqNumInitVal = (uint16_t) IVAS_RTP_OwnRandom( &rtpDecSeed ); +#else #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 @@ -2057,6 +2069,7 @@ static ivas_error initOnFirstGoodFrame( srand( RANDOM_INITSEED_DEC ); uint32_t ssrc = ( (uint32_t) rand() & 0x0000FFFF ) | ( (uint32_t) rand() << 16 ); uint16_t seqNumInitVal = (uint16_t) ( rand() & 0xFFFF ); +#endif #endif if ( ( error = IVAS_DEC_GetDelay( hIvasDec, delayNumSamples_temp, &delayTimeScale_temp ) ) != IVAS_ERR_OK ) diff --git a/apps/encoder.c b/apps/encoder.c index 505e66a282..35a556b190 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -61,9 +61,13 @@ static #endif int32_t frame = 0; /* Counter of frames */ +#ifdef NONBE_FIX_BASOP_2233_RTPDUMP_DIFFERING_BITSTREAMS +#define RANDOM_INITSEED_ENC ( 0xDEAF ) +#else #ifdef FIXED_RTP_SEQUENCE_NUM #define RANDOM_INITSEED_ENC ( 0xFEEDDEAF ) #endif +#endif #define DEFAULT_FIXED_SID_RATE 8 /* DTX SID rate */ @@ -234,6 +238,14 @@ int main( IVAS_RTP ivasRtp = { 0 }; #endif +#ifdef NONBE_FIX_BASOP_2233_RTPDUMP_DIFFERING_BITSTREAMS + /* 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 */ + uint16_t rtpEncSeed = RANDOM_INITSEED_ENC; + uint32_t ssrc = (uint16_t) IVAS_RTP_OwnRandom( &rtpEncSeed ) | (uint16_t) IVAS_RTP_OwnRandom( &rtpEncSeed ) << 16; + uint16_t seqNumInitVal = (uint16_t) IVAS_RTP_OwnRandom( &rtpEncSeed ); +#else #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 @@ -241,6 +253,7 @@ int main( srand( RANDOM_INITSEED_ENC ); uint32_t ssrc = ( (uint32_t) rand() & 0x0000FFFF ) | ( (uint32_t) rand() << 16 ); uint16_t seqNumInitVal = (uint16_t) ( rand() & 0xFFFF ); +#endif #endif /*------------------------------------------------------------------------------------------* diff --git a/apps/encoder_fmtsw.c b/apps/encoder_fmtsw.c index 2a990abae1..a2b60f204b 100644 --- a/apps/encoder_fmtsw.c +++ b/apps/encoder_fmtsw.c @@ -64,9 +64,13 @@ static #endif int32_t frame = 0; /* Counter of frames */ +#ifdef NONBE_FIX_BASOP_2233_RTPDUMP_DIFFERING_BITSTREAMS +#define RANDOM_INITSEED_ENC ( 0xDEAF ) +#else #ifdef FIXED_RTP_SEQUENCE_NUM #define RANDOM_INITSEED_ENC ( 0xFEEDDEAF ) #endif +#endif #define DEFAULT_FIXED_SID_RATE 8 /* DTX SID rate */ @@ -359,6 +363,14 @@ int encoder_main( /* IVAS_RTP ivasRtp = { 0 }; */ #endif +#ifdef NONBE_FIX_BASOP_2233_RTPDUMP_DIFFERING_BITSTREAMS + /* 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 */ + uint16_t rtpEncSeed = RANDOM_INITSEED_ENC; + uint32_t ssrc = (uint16_t) IVAS_RTP_OwnRandom( &rtpEncSeed ) | (uint16_t) IVAS_RTP_OwnRandom( &rtpEncSeed ) << 16; + uint16_t seqNumInitVal = (uint16_t) IVAS_RTP_OwnRandom( &rtpEncSeed ); +#else #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 @@ -366,6 +378,7 @@ int encoder_main( srand( RANDOM_INITSEED_ENC ); uint32_t ssrc = ( (uint32_t) rand() & 0x0000FFFF ) | ( (uint32_t) rand() << 16 ); uint16_t seqNumInitVal = (uint16_t) ( rand() & 0xFFFF ); +#endif #endif /*------------------------------------------------------------------------------------------* diff --git a/lib_com/options.h b/lib_com/options.h index 560d3e0a0a..1f09b73080 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -211,6 +211,8 @@ #define FIX_1430_EVS_STEREO_DMX_CHANNEL_DISAPPEARING /* Orange: Fix for basop issue 2184 - to prevent one channel from becoming inaudible in the mono downmix output */ #define FIX_1440_AMR_WB_RESET /* VA: issue 1440: Fix missing AMR-WB IO memory reset (applicable to float only) */ +#define NONBE_FIX_BASOP_2233_RTPDUMP_DIFFERING_BITSTREAMS /* Nokia: fix basop issue 2233: Fix differing rtpdump streams */ + /* ##################### End NON-BE switches ########################### */ /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_util/ivas_rtp_file.c b/lib_util/ivas_rtp_file.c index 65f9fec15d..b8e79fad53 100644 --- a/lib_util/ivas_rtp_file.c +++ b/lib_util/ivas_rtp_file.c @@ -1103,3 +1103,10 @@ ivas_error IVAS_RTP_ReadNextFrame( return IVAS_ERR_OK; } + +uint16_t IVAS_RTP_OwnRandom( uint16_t *seed ) +{ + *seed = (uint16_t) ( *seed * 31821L + 13849L ); + + return ( *seed ); +} diff --git a/lib_util/ivas_rtp_file.h b/lib_util/ivas_rtp_file.h index 684903e175..b57d387cf4 100644 --- a/lib_util/ivas_rtp_file.h +++ b/lib_util/ivas_rtp_file.h @@ -93,5 +93,6 @@ ivas_error IVAS_RTP_ReadNextFrame( IVAS_RTP *rtp, uint8_t *au, int16_t *auSizeBi void IVAS_RTP_LogPiData( FILE *f_piDataOut, const PIDATA_TS *piData, uint32_t nPiDataPresent ); void IVAS_RTP_WriteExtPiData( FILE *f_piDataOut, const PIDATA_TS *piData, uint32_t nPiDataPresent, uint16_t numObj ); const char *IVAS_RTP_GetExtPiFilePath( IVAS_RTP *rtp ); +uint16_t IVAS_RTP_OwnRandom( uint16_t *seed ); #endif /* IVAS_RTP_FILE_H */ -- GitLab From 4865663a3770acd70b52c14906043ef748e235ce Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Thu, 13 Nov 2025 18:22:49 +0200 Subject: [PATCH 2/2] Fix sanitizer issues --- apps/decoder.c | 4 ++-- apps/encoder.c | 4 ++-- apps/encoder_fmtsw.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 0069252302..9b20043786 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2059,8 +2059,8 @@ static ivas_error initOnFirstGoodFrame( use fixed seed for random num generator for regression based tests. Any realtime application should implement this initialization seperately */ uint16_t rtpDecSeed = RANDOM_INITSEED_DEC; - uint32_t ssrc = (uint16_t) IVAS_RTP_OwnRandom( &rtpDecSeed ) | (uint16_t) IVAS_RTP_OwnRandom( &rtpDecSeed ) << 16; - uint16_t seqNumInitVal = (uint16_t) IVAS_RTP_OwnRandom( &rtpDecSeed ); + uint32_t ssrc = ( (uint32_t) IVAS_RTP_OwnRandom( &rtpDecSeed ) & 0x0000FFFF ) | ( (uint32_t) IVAS_RTP_OwnRandom( &rtpDecSeed ) << 16 ); + uint16_t seqNumInitVal = IVAS_RTP_OwnRandom( &rtpDecSeed ); #else #ifdef FIXED_RTP_SEQUENCE_NUM /* Ideally ssrc is negotiated via SDP and sequence number is radomized but we diff --git a/apps/encoder.c b/apps/encoder.c index 35a556b190..2c9c42b462 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -243,8 +243,8 @@ int main( use fixed seed for random num generator for regression based tests. Any realtime application should implement this initialization seperately */ uint16_t rtpEncSeed = RANDOM_INITSEED_ENC; - uint32_t ssrc = (uint16_t) IVAS_RTP_OwnRandom( &rtpEncSeed ) | (uint16_t) IVAS_RTP_OwnRandom( &rtpEncSeed ) << 16; - uint16_t seqNumInitVal = (uint16_t) IVAS_RTP_OwnRandom( &rtpEncSeed ); + uint32_t ssrc = ( (uint32_t) IVAS_RTP_OwnRandom( &rtpEncSeed ) & 0x0000FFFF ) | ( (uint32_t) IVAS_RTP_OwnRandom( &rtpEncSeed ) << 16 ); + uint16_t seqNumInitVal = IVAS_RTP_OwnRandom( &rtpEncSeed ); #else #ifdef FIXED_RTP_SEQUENCE_NUM /* Ideally ssrc is negotiated via SDP and sequence number is radomized but we diff --git a/apps/encoder_fmtsw.c b/apps/encoder_fmtsw.c index a2b60f204b..1730018f8e 100644 --- a/apps/encoder_fmtsw.c +++ b/apps/encoder_fmtsw.c @@ -368,8 +368,8 @@ int encoder_main( use fixed seed for random num generator for regression based tests. Any realtime application should implement this initialization seperately */ uint16_t rtpEncSeed = RANDOM_INITSEED_ENC; - uint32_t ssrc = (uint16_t) IVAS_RTP_OwnRandom( &rtpEncSeed ) | (uint16_t) IVAS_RTP_OwnRandom( &rtpEncSeed ) << 16; - uint16_t seqNumInitVal = (uint16_t) IVAS_RTP_OwnRandom( &rtpEncSeed ); + uint32_t ssrc = ( (uint32_t) IVAS_RTP_OwnRandom( &rtpEncSeed ) & 0x0000FFFF ) | ( (uint32_t) IVAS_RTP_OwnRandom( &rtpEncSeed ) << 16 ); + uint16_t seqNumInitVal = IVAS_RTP_OwnRandom( &rtpEncSeed ); #else #ifdef FIXED_RTP_SEQUENCE_NUM /* Ideally ssrc is negotiated via SDP and sequence number is radomized but we -- GitLab