From a867a8baab2fb64ef74b8e5efdcf9791cd1c09cc Mon Sep 17 00:00:00 2001 From: rtyag Date: Mon, 17 Feb 2025 14:48:33 +1100 Subject: [PATCH] lc3 plus unit tests changes from ISAR BASOP code --- .../lc3plus/ivas_lc3plus_unit_test.c | 233 +++++++++++++++--- .../ivas_lc3plus_unit_test_payload_format.c | 2 + .../lc3plus/split_rend_lc3plus_cmdlines.py | 191 ++++++++++++++ 3 files changed, 386 insertions(+), 40 deletions(-) create mode 100644 scripts/split_rendering/lc3plus/split_rend_lc3plus_cmdlines.py diff --git a/scripts/split_rendering/lc3plus/ivas_lc3plus_unit_test.c b/scripts/split_rendering/lc3plus/ivas_lc3plus_unit_test.c index 725cf525c3..d4617c13c2 100644 --- a/scripts/split_rendering/lc3plus/ivas_lc3plus_unit_test.c +++ b/scripts/split_rendering/lc3plus/ivas_lc3plus_unit_test.c @@ -38,11 +38,23 @@ the United Nations Convention on Contracts on the International Sales of Goods. #include "isar_lc3plus_common.h" #include "isar_lc3plus_dec.h" #include "ivas_error_utils.h" +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS #include "lc3.h" +#endif +#ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS #define MAX_SAMPLES_PER_CHANNEL 960 / 4 +#else +#define MAX_SAMPLES_PER_CHANNEL 960 +#endif #define DEFAULT_BPS 256000 +#ifndef PCM_SAMPLE_TYPEDEF_DEFINED +#define PCM_SAMPLE_TYPEDEF_DEFINED +typedef int32_t PcmSample; +#endif + static int encodeAndDecodeOneStereoFrame( LC3PLUS_CONFIG config, uint32_t bps ) { ivas_error err; @@ -70,11 +82,11 @@ static int encodeAndDecodeOneStereoFrame( LC3PLUS_CONFIG config, uint32_t bps ) /* encode one frame */ int16_t numSamplesPerChannels = config.samplerate / ( 1000000 / config.isar_frame_duration_us ); - float *pcm_in[2]; - float pcm_in_ch1[MAX_SAMPLES_PER_CHANNEL * sizeof( float )]; - memset( pcm_in_ch1, 0, numSamplesPerChannels * sizeof( float ) ); - float pcm_in_ch2[MAX_SAMPLES_PER_CHANNEL * sizeof( float )]; - memset( pcm_in_ch2, 0, numSamplesPerChannels * sizeof( float ) ); + PcmSample *pcm_in[2]; + PcmSample pcm_in_ch1[MAX_SAMPLES_PER_CHANNEL * sizeof( PcmSample )]; + memset( pcm_in_ch1, 0, numSamplesPerChannels * sizeof( PcmSample ) ); + PcmSample pcm_in_ch2[MAX_SAMPLES_PER_CHANNEL * sizeof( PcmSample )]; + memset( pcm_in_ch2, 0, numSamplesPerChannels * sizeof( PcmSample ) ); pcm_in[0] = pcm_in_ch1; pcm_in[1] = pcm_in_ch2; @@ -88,6 +100,7 @@ static int encodeAndDecodeOneStereoFrame( LC3PLUS_CONFIG config, uint32_t bps ) uint8_t *bitstream_out = malloc( bitstreamSizePerIvasFrame ); memset( bitstream_out, 0, bitstreamSizePerIvasFrame ); +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS int perChannelBitrate = lc3plus_enc_get_real_bitrate(encHandle->handles[0]); int perLc3plusFrameDataBlockOctets = encHandle->num_ftds * perChannelBitrate / 8 / (1000*1000/config.lc3plus_frame_duration_us); int targetOctets = bps / 8 / (1000*1000/config.isar_frame_duration_us); @@ -102,7 +115,12 @@ static int encodeAndDecodeOneStereoFrame( LC3PLUS_CONFIG config, uint32_t bps ) return err; } - err = ISAR_LC3PLUS_ENC_Encode( encHandle, pcm_in, bitstream_out, bitstreamSizePerIvasFrame ); + Word16 Q_in[16]; + memset(Q_in, 0, sizeof(Q_in) ); + err = ISAR_LC3PLUS_ENC_Encode( encHandle, pcm_in, bitstream_out, bitstreamSizePerIvasFrame, Q_in ); +#else + err = ISAR_LC3PLUS_ENC_Encode( encHandle, pcm_in, bitstream_out ); +#endif if ( IVAS_ERR_OK != err ) { ISAR_LC3PLUS_ENC_Close( &encHandle ); @@ -140,11 +158,11 @@ static int encodeAndDecodeOneStereoFrame( LC3PLUS_CONFIG config, uint32_t bps ) uint8_t *bitstream_in = bitstream_out; - float *pcm_out[2]; - float pcm_out_ch1[MAX_SAMPLES_PER_CHANNEL * sizeof( float )]; - memset( pcm_out_ch1, 0, numSamplesPerChannels * sizeof( float ) ); - float pcm_out_ch2[MAX_SAMPLES_PER_CHANNEL * sizeof( float )]; - memset( pcm_out_ch2, 0, numSamplesPerChannels * sizeof( float ) ); + PcmSample *pcm_out[2]; + PcmSample pcm_out_ch1[MAX_SAMPLES_PER_CHANNEL * sizeof( PcmSample )]; + memset( pcm_out_ch1, 0, numSamplesPerChannels * sizeof( PcmSample ) ); + PcmSample pcm_out_ch2[MAX_SAMPLES_PER_CHANNEL * sizeof( PcmSample )]; + memset( pcm_out_ch2, 0, numSamplesPerChannels * sizeof( PcmSample ) ); pcm_out[0] = pcm_out_ch1; pcm_out[1] = pcm_out_ch2; @@ -182,7 +200,11 @@ static int encodeAndDecodeOneStereoFrame( LC3PLUS_CONFIG config, uint32_t bps ) static int openCloseEncoder( void ) { ivas_error err; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 }; +#else + LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20000, .channels = 1, .samplerate = 48000 }; +#endif uint32_t bps = 128000; ISAR_LC3PLUS_ENC_HANDLE encHandle; @@ -199,23 +221,36 @@ static int openCloseEncoder( void ) static int tryOpenEncoderWithInvalidBitrate( void ) { ivas_error err; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 }; +#else + LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20000, .channels = 1, .samplerate = 48000 }; +#endif /* lc3plus max bitrate is 320000 per channel */ uint32_t invalid_high_bps = 700000; uint32_t invalid_low_bps = 8; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS uint32_t limitedBitrate; +#endif ISAR_LC3PLUS_ENC_HANDLE encHandle; err = ISAR_LC3PLUS_ENC_Open( config, invalid_high_bps, &encHandle ); +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS /* setting an invalid bitrate should result in a limited bitrate*/ if ( IVAS_ERR_OK != err ) +#else + /* setting an invalid bitrate should trigger an error - which is what we expect */ + if ( IVAS_ERR_LC3PLUS_INVALID_BITRATE != err ) +#endif { return 1; } +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS limitedBitrate = lc3plus_enc_get_real_bitrate(encHandle->handles[0]); if(limitedBitrate != 320000) { return 1; } +#endif ISAR_LC3PLUS_ENC_Close(&encHandle); err = ISAR_LC3PLUS_ENC_Open( config, invalid_low_bps, &encHandle ); /* setting an invalid bitrate should trigger an error - which is what we expect */ @@ -230,7 +265,11 @@ static int tryOpenEncoderWithInvalidBitrate( void ) static int tryOpenEncoderWithInvalidFrameDuration( void ) { ivas_error err; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 }; +#else + LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20000, .channels = 1, .samplerate = 48000 }; +#endif config.lc3plus_frame_duration_us = 1234; /*unsupported frame duration*/ uint32_t bps = 320000; @@ -247,7 +286,11 @@ static int tryOpenEncoderWithInvalidFrameDuration( void ) static int tryOpenEncoderWithInvalidSampleRate( void ) { ivas_error err; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 }; +#else + LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20000, .channels = 1, .samplerate = 48000 }; +#endif config.samplerate = 1234; /*unsupported sample rate */ uint32_t bps = 320000; @@ -268,13 +311,13 @@ static int tryCallEncoderApiWithInvalidParams( void ) int32_t bsSize; int32_t *invalidDelayInSamples = NULL; int32_t delayInSamples; - float **invalidPcm_in = NULL; + PcmSample **invalidPcm_in = NULL; void *invalidBitstream_out = NULL; const int16_t numSamplesPerChannels = MAX_SAMPLES_PER_CHANNEL; - float *pcm_in[1]; - float pcm_in_ch1[MAX_SAMPLES_PER_CHANNEL * sizeof( float )]; - memset( pcm_in_ch1, 0, numSamplesPerChannels * sizeof( float ) ); + PcmSample *pcm_in[1]; + PcmSample pcm_in_ch1[MAX_SAMPLES_PER_CHANNEL * sizeof( PcmSample )]; + memset( pcm_in_ch1, 0, numSamplesPerChannels * sizeof( PcmSample ) ); pcm_in[0] = pcm_in_ch1; uint8_t bitstream_out[1200]; @@ -287,11 +330,22 @@ static int tryCallEncoderApiWithInvalidParams( void ) return 1; } ISAR_LC3PLUS_ENC_Close( &invalidEncHandle ); - if ( IVAS_ERR_UNEXPECTED_NULL_POINTER != ISAR_LC3PLUS_ENC_Encode( invalidEncHandle, invalidPcm_in, invalidBitstream_out, bsSize ) ) +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + Word16 Q_in[16]; + memset(Q_in, 0, sizeof(Q_in) ); + if ( IVAS_ERR_UNEXPECTED_NULL_POINTER != ISAR_LC3PLUS_ENC_Encode( invalidEncHandle, invalidPcm_in, invalidBitstream_out, bsSize, Q_in ) ) +#else + if ( IVAS_ERR_UNEXPECTED_NULL_POINTER != ISAR_LC3PLUS_ENC_Encode( invalidEncHandle, invalidPcm_in, invalidBitstream_out ) ) +#endif { return 1; } - if ( IVAS_ERR_UNEXPECTED_NULL_POINTER != ISAR_LC3PLUS_ENC_Encode( invalidEncHandle, pcm_in, invalidBitstream_out, bsSize ) || IVAS_ERR_UNEXPECTED_NULL_POINTER != ISAR_LC3PLUS_ENC_Encode( invalidEncHandle, invalidPcm_in, bitstream_out, bsSize ) || IVAS_ERR_UNEXPECTED_NULL_POINTER != ISAR_LC3PLUS_ENC_Encode( invalidEncHandle, pcm_in, bitstream_out, bsSize ) ) +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + memset(Q_in, 0, sizeof(Q_in) ); + if ( IVAS_ERR_UNEXPECTED_NULL_POINTER != ISAR_LC3PLUS_ENC_Encode( invalidEncHandle, pcm_in, invalidBitstream_out, bsSize, Q_in) || IVAS_ERR_UNEXPECTED_NULL_POINTER != ISAR_LC3PLUS_ENC_Encode( invalidEncHandle, invalidPcm_in, bitstream_out, bsSize, Q_in ) || IVAS_ERR_UNEXPECTED_NULL_POINTER != ISAR_LC3PLUS_ENC_Encode( invalidEncHandle, pcm_in, bitstream_out, bsSize, Q_in ) ) +#else + if ( IVAS_ERR_UNEXPECTED_NULL_POINTER != ISAR_LC3PLUS_ENC_Encode( invalidEncHandle, pcm_in, invalidBitstream_out ) || IVAS_ERR_UNEXPECTED_NULL_POINTER != ISAR_LC3PLUS_ENC_Encode( invalidEncHandle, invalidPcm_in, bitstream_out ) || IVAS_ERR_UNEXPECTED_NULL_POINTER != ISAR_LC3PLUS_ENC_Encode( invalidEncHandle, pcm_in, bitstream_out ) ) +#endif { return 1; } @@ -305,15 +359,15 @@ static int tryCallDecoderApiWithInvalidParams( void ) int32_t *invalidDelayInSamples = NULL; int32_t delayInSamples; - float **invalidPcm_out = NULL; + PcmSample **invalidPcm_out = NULL; void *invalidBitstream_in = NULL; int32_t invalidBitstream_in_size = 0; int32_t bitstream_in_size = 100; const int16_t numSamplesPerChannels = MAX_SAMPLES_PER_CHANNEL; - float *pcm_out[1]; - float pcm_out_ch1[MAX_SAMPLES_PER_CHANNEL * sizeof( float )]; - memset( pcm_out_ch1, 0, numSamplesPerChannels * sizeof( float ) ); + PcmSample *pcm_out[1]; + PcmSample pcm_out_ch1[MAX_SAMPLES_PER_CHANNEL * sizeof( PcmSample )]; + memset( pcm_out_ch1, 0, numSamplesPerChannels * sizeof( PcmSample ) ); pcm_out[0] = pcm_out_ch1; uint8_t bitstream_in[1200]; @@ -337,7 +391,11 @@ static int tryCallDecoderApiWithInvalidParams( void ) static int openCloseDecoderWithCaching( void ) { ivas_error err; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 }; +#else + LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20000, .channels = 1, .samplerate = 48000 }; +#endif ISAR_LC3PLUS_DEC_HANDLE decHandle; err = ISAR_LC3PLUS_DEC_Open( config, #ifdef LC3PLUS_DEC_ALLOW_DISABLE_CACHING @@ -356,7 +414,11 @@ static int openCloseDecoderWithCaching( void ) static int openCloseDecoderWithoutCaching( void ) { ivas_error err; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 }; +#else + LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20000, .channels = 1, .samplerate = 48000 }; +#endif ISAR_LC3PLUS_DEC_HANDLE decHandle; err = ISAR_LC3PLUS_DEC_Open( config, #ifdef LC3PLUS_DEC_ALLOW_DISABLE_CACHING @@ -376,7 +438,11 @@ static int openCloseDecoderWithoutCaching( void ) static int tryOpenDecoderWithInvalidFrameDuration( void ) { ivas_error err; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 }; +#else + LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20000, .channels = 1, .samplerate = 48000 }; +#endif config.lc3plus_frame_duration_us = 1234; /*unsupported frame duration*/ ISAR_LC3PLUS_DEC_HANDLE decHandle; @@ -396,7 +462,11 @@ static int tryOpenDecoderWithInvalidFrameDuration( void ) static int tryOpenDecoderWithInvalidSampleRate( void ) { ivas_error err; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 }; +#else + LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20000, .channels = 1, .samplerate = 48000 }; +#endif config.samplerate = 1234; /*unsupported sample rate*/ ISAR_LC3PLUS_DEC_HANDLE decHandle; @@ -416,7 +486,11 @@ static int tryOpenDecoderWithInvalidSampleRate( void ) static int encodeOneFrame( void ) { ivas_error err; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 }; +#else + LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20000, .channels = 1, .samplerate = 48000 }; +#endif uint32_t bps = 128000; ISAR_LC3PLUS_ENC_HANDLE encHandle; @@ -426,9 +500,9 @@ static int encodeOneFrame( void ) int16_t numSamplesPerChannels = config.samplerate / ( 1000000 / config.isar_frame_duration_us ); - float *pcm[1]; - float pcm_ch1[MAX_SAMPLES_PER_CHANNEL * sizeof( float )]; - memset( pcm_ch1, 0, numSamplesPerChannels * sizeof( float ) ); + PcmSample *pcm[1]; + PcmSample pcm_ch1[MAX_SAMPLES_PER_CHANNEL * sizeof( PcmSample )]; + memset( pcm_ch1, 0, numSamplesPerChannels * sizeof( PcmSample ) ); pcm[0] = pcm_ch1; int32_t bitstreamSizePerIvasFrame = 0; @@ -437,7 +511,14 @@ static int encodeOneFrame( void ) return err; uint8_t *bitstream_out = malloc( bitstreamSizePerIvasFrame ); memset( bitstream_out, 0, bitstreamSizePerIvasFrame ); - err = ISAR_LC3PLUS_ENC_Encode( encHandle, pcm, bitstream_out, bitstreamSizePerIvasFrame ); +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + Word16 Q_in[16]; + memset(Q_in, 0, sizeof(Q_in) ); + err = ISAR_LC3PLUS_ENC_Encode( encHandle, pcm, bitstream_out, bitstreamSizePerIvasFrame, Q_in ); + +#else + err = ISAR_LC3PLUS_ENC_Encode( encHandle, pcm, bitstream_out ); +#endif if ( IVAS_ERR_OK != err ) return err; @@ -450,7 +531,11 @@ static int encodeOneFrame( void ) static int encodeAndDecodeOneMonoFrame( void ) { ivas_error err; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 }; +#else + LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20000, .channels = 1, .samplerate = 48000 }; +#endif uint32_t bps = 128000; ISAR_LC3PLUS_ENC_HANDLE encHandle; @@ -462,9 +547,9 @@ static int encodeAndDecodeOneMonoFrame( void ) /* encode one frame */ int16_t numSamplesPerChannels = config.samplerate / ( 1000000 / config.isar_frame_duration_us ); - float *pcm_in[1]; - float pcm_in_ch1[MAX_SAMPLES_PER_CHANNEL * sizeof( float )]; - memset( pcm_in_ch1, 0, numSamplesPerChannels * sizeof( float ) ); + PcmSample *pcm_in[1]; + PcmSample pcm_in_ch1[MAX_SAMPLES_PER_CHANNEL * sizeof( PcmSample )]; + memset( pcm_in_ch1, 0, numSamplesPerChannels * sizeof( PcmSample ) ); pcm_in[0] = pcm_in_ch1; int32_t bitstreamSizePerIvasFrame = 0; @@ -474,7 +559,13 @@ static int encodeAndDecodeOneMonoFrame( void ) uint8_t *bitstream_out = malloc( bitstreamSizePerIvasFrame ); memset( bitstream_out, 0, bitstreamSizePerIvasFrame ); - err = ISAR_LC3PLUS_ENC_Encode( encHandle, pcm_in, bitstream_out, bitstreamSizePerIvasFrame ); +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + Word16 Q_in[16]; + memset(Q_in, 0, sizeof(Q_in) ); + err = ISAR_LC3PLUS_ENC_Encode( encHandle, pcm_in, bitstream_out, bitstreamSizePerIvasFrame, Q_in ); +#else + err = ISAR_LC3PLUS_ENC_Encode( encHandle, pcm_in, bitstream_out ); +#endif if ( IVAS_ERR_OK != err ) return err; ISAR_LC3PLUS_ENC_Close( &encHandle ); @@ -493,9 +584,9 @@ static int encodeAndDecodeOneMonoFrame( void ) uint8_t *bitstream_in = bitstream_out; - float *pcm_out[1]; - float pcm_out_ch1[MAX_SAMPLES_PER_CHANNEL * sizeof( float )]; - memset( pcm_out_ch1, 0, numSamplesPerChannels * sizeof( float ) ); + PcmSample *pcm_out[1]; + PcmSample pcm_out_ch1[MAX_SAMPLES_PER_CHANNEL * sizeof( PcmSample )]; + memset( pcm_out_ch1, 0, numSamplesPerChannels * sizeof( PcmSample ) ); pcm_out[0] = pcm_out_ch1; err = ISAR_LC3PLUS_DEC_Decode( decHandle, bitstream_in, bitstreamSizePerIvasFrame, pcm_out ); if ( IVAS_ERR_OK != err ) @@ -517,7 +608,11 @@ static int encodeAndDecodeOneMonoFrame( void ) static int encodeAndDecodeOneStereoFrameIvas20msLc3plus10ms_48kHz( void ) { +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20 * 1000, .channels = 2, .samplerate = 48000, .high_res_mode_enabled = 0 }; +#else + LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20 * 1000, .channels = 2, .samplerate = 48000 }; +#endif return encodeAndDecodeOneStereoFrame( config, DEFAULT_BPS ); } @@ -535,88 +630,140 @@ static int encodeAndDecodeOneStereoFrameIvas20msLc3plus10ms_16kHz( void ) static int encodeAndDecodeOneStereoFrameIvas5msLc3plus5ms_48kHz( void ) { +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5 * 1000, .channels = 2, .samplerate = 48000, .high_res_mode_enabled = 0 }; +#else + LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5 * 1000, .channels = 2, .samplerate = 48000 }; +#endif return encodeAndDecodeOneStereoFrame( config, DEFAULT_BPS ); } static int encodeAndDecodeOneStereoFrameIvas10msLc3plus10ms_48kHz( void ) { +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000, .high_res_mode_enabled = 0 }; +#else + LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5 * 1000, .channels = 2, .samplerate = 48000 }; +#endif return encodeAndDecodeOneStereoFrame( config, DEFAULT_BPS ); } static int encodeAndDecodeOneMonoFrameIvas20msLc3plus10ms_48kHz( void ) { +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20 * 1000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 }; +#else + LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20 * 1000, .channels = 1, .samplerate = 48000 }; +#endif return encodeAndDecodeOneStereoFrame( config, DEFAULT_BPS ); } static int encodeAndDecodeOneMonoFrameIvas5msLc3plus5ms_48kHz( void ) { +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5 * 1000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 }; +#else + LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5 * 1000, .channels = 1, .samplerate = 48000 }; +#endif return encodeAndDecodeOneStereoFrame( config, DEFAULT_BPS ); } static int encodeAndDecodeOneStereoFrameIvas20msLc3plus2_5ms_48kHz( void ) { +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 2.5 * 1000, .isar_frame_duration_us = 20 * 1000, .channels = 2, .samplerate = 48000, .high_res_mode_enabled = 0 }; +#else + LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 2.5 * 1000, .isar_frame_duration_us = 20 * 1000, .channels = 2, .samplerate = 48000 }; +#endif return encodeAndDecodeOneStereoFrame( config, DEFAULT_BPS ); } static int encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_80kbpsPerChannel( void ) { +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000, .high_res_mode_enabled = 0 }; +#else + LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000 }; +#endif return encodeAndDecodeOneStereoFrame( config, config.channels * 82*1000 ); } static int encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_96kbpsPerChannel( void ) { +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000, .high_res_mode_enabled = 0 }; +#else + LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000 }; +#endif return encodeAndDecodeOneStereoFrame( config, config.channels * 98*1000 ); } -#ifdef LC3PLUS_LEA_COMPAT_BITRATES_48_6 -static int encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_126kbpsPerChannel( void ) -#else static int encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_124kbpsPerChannel( void ) -#endif { +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000, .high_res_mode_enabled = 0 }; +#else + LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000 }; +#endif return encodeAndDecodeOneStereoFrame( config, config.channels * 126*1000 ); } +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS static int encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_800kbpsPerChannel( void ) { +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000, .high_res_mode_enabled = 0 }; +#else + LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000 }; +#endif return encodeAndDecodeOneStereoFrame( config, config.channels * 800*1000 ); } +#endif static int encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_204800bpsPerChannel( void ) { +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 }; +#else + LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000 }; +#endif return encodeAndDecodeOneStereoFrame( config, config.channels * 204800 ); } static int encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_205600bpsPerChannel( void ) { +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 }; +#else + LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000 }; +#endif return encodeAndDecodeOneStereoFrame( config, config.channels * 205600 ); } static int encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_206400bpsPerChannel( void ) { +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 }; +#else + LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000 }; +#endif return encodeAndDecodeOneStereoFrame( config, config.channels * 206400 ); } static int encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_207200bpsPerChannel( void ) { +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 }; +#else + LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000 }; +#endif return encodeAndDecodeOneStereoFrame( config, config.channels * 207200 ); } +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS #include "ivas_lc3plus_unit_test_payload_format.c" +#endif int main( int argc, @@ -691,16 +838,14 @@ int main( ret = encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_96kbpsPerChannel(); if ( ret != 0 ) return 1; -#ifdef LC3PLUS_LEA_COMPAT_BITRATES_48_6 - ret = encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_126kbpsPerChannel(); -#else ret = encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_124kbpsPerChannel(); -#endif if ( ret != 0 ) return 1; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS ret = encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_800kbpsPerChannel(); if ( ret != 0 ) return 1; +#endif /* start configs around the FDL threshold */ ret = encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_204800bpsPerChannel(); if ( ret != 0 ) @@ -715,8 +860,16 @@ int main( if ( ret != 0 ) return 1; /* end configs around the FDL threshold */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS ret = run_all_payload_tests(); if ( ret != 0 ) return 1; +#endif return 0; } +#else +int main( void ) +{ + return EXIT_SUCCESS; +} +#endif /* SPLIT_REND_WITH_HEAD_ROT */ diff --git a/scripts/split_rendering/lc3plus/ivas_lc3plus_unit_test_payload_format.c b/scripts/split_rendering/lc3plus/ivas_lc3plus_unit_test_payload_format.c index 88ee6783df..a303d01f53 100644 --- a/scripts/split_rendering/lc3plus/ivas_lc3plus_unit_test_payload_format.c +++ b/scripts/split_rendering/lc3plus/ivas_lc3plus_unit_test_payload_format.c @@ -38,6 +38,7 @@ the United Nations Convention on Contracts on the International Sales of Goods. #include "isar_lc3plus_common.h" #include "options.h" +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS /* included by ivas_lc3plus_unit_test.c */ @@ -447,3 +448,4 @@ static int run_all_payload_tests( void ) } return 0; } +#endif diff --git a/scripts/split_rendering/lc3plus/split_rend_lc3plus_cmdlines.py b/scripts/split_rendering/lc3plus/split_rend_lc3plus_cmdlines.py new file mode 100644 index 0000000000..033c25bb60 --- /dev/null +++ b/scripts/split_rendering/lc3plus/split_rend_lc3plus_cmdlines.py @@ -0,0 +1,191 @@ +""" +Generate command lines for split rendering with LC3plus +""" + +import itertools +import os + +# Paths +ENC_PATH = "./IVAS_cod" +DEC_PATH = "./IVAS_dec" +REND_PATH = "./IVAS_rend" +TEMP_DIR = "tmp" + +# Config values to iterate over +ISM_CONFIGS_NUM_OBJECTS = [1, 2, 3, 4] +IVAS_BITRATES = [128000] +PRE_HEAD_ROT_FILES = [ + "Workspace_msvc/trajectories/pre-renderer_pose_files/pre_yaw-20static.csv" +] +POST_HEAD_ROT_FILES = [ + "Workspace_msvc/trajectories/post-renderer_pose_files/post_0static.csv" +] +RENDER_CONFIG_FILES = [ + ####################################################### + # Alternative 2 - LC3plus with CLDFB pose correction + "Workspace_msvc/renderer_configs/split_renderer_config_768_1dof.txt", + "Workspace_msvc/renderer_configs/split_renderer_config_512_2dof.txt", + None, # Alternative 2 is the default when no rendering config file is given on command line + ####################################################### + # Alternative 3 - LC3plus with multi-stream (TD) pose correction + "Workspace_msvc/renderer_configs/split_renderer_config_768_1dof_tdposecorr.txt", + "Workspace_msvc/renderer_configs/split_renderer_config_1536_2dof_tdposecorr.txt", +] + + +def audio_for_ism(num_objects): + return f"scripts/testv/stv{num_objects}ISM48s.wav" + + +def metadata_for_ism(num_objects): + return f"scripts/testv/stvISM{num_objects}.csv" + + +def basename(file_path): + basename_w_ext = os.path.basename(file_path) + return os.path.splitext(basename_w_ext)[0] + + +# Full chain: IVAS_cod -> IVAS_dec -> IVAS_rend(post) +def full_chain( + num_objects, ivas_bitrate, pre_head_rot_file, render_config_file, post_head_rot_file +): + bs_name = f"{TEMP_DIR}/ism{num_objects}_b{ivas_bitrate}_full_chain.g192" + cod = [ + ENC_PATH, + "-ism", + str(num_objects), + *[metadata_for_ism(i + 1) for i in range(num_objects)], + str(ivas_bitrate), + "48", + audio_for_ism(num_objects), + bs_name, + ] + + render_config_infix = ( + f"##{basename(render_config_file)}" if render_config_file else "" + ) + split_bs_name = bs_name.replace( + ".g192", f"##{basename(pre_head_rot_file)}{render_config_infix}##split.bs" + ) + render_config_args = ( + ["-render_config", render_config_file] if render_config_file else [] + ) + dec = [ + DEC_PATH, + "-T", + pre_head_rot_file, + *render_config_args, + "SPLIT_BINAURAL", + "48", + bs_name, + split_bs_name, + ] + + binaural_output_name = split_bs_name.replace( + ".bs", f"##{basename(post_head_rot_file)}##binaural.wav" + ) + rend = [ + REND_PATH, + "-i", + split_bs_name, + "-if", + "BINAURAL_SPLIT_CODED", + "-of", + "BINAURAL", + "-fs", + "48", + "-tf", + post_head_rot_file, + "-o", + binaural_output_name, + ] + + return [cod, dec, rend] + + +# Renderer chain: IVAS_rend(pre) -> IVAS_rend(post) +def rend_chain(num_objects, pre_head_rot_file, render_config_file, post_head_rot_file): + render_config_infix = ( + f"##{basename(render_config_file)}" if render_config_file else "" + ) + split_bs_name = f"{TEMP_DIR}/ism{num_objects}_rend_chain##{basename(pre_head_rot_file)}{render_config_infix}##split.bs" + render_config_args = ( + ["-render_config", render_config_file] if render_config_file else [] + ) + pre = [ + REND_PATH, + "-i", + audio_for_ism(num_objects), + "-if", + f"ISM{num_objects}", + "-im", + *[metadata_for_ism(i + 1) for i in range(num_objects)], + "-of", + "BINAURAL_SPLIT_CODED", + "-fs", + "48", + *render_config_args, + "-tf", + pre_head_rot_file, + "-o", + split_bs_name, + ] + + binaural_output_name = split_bs_name.replace( + ".bs", f"##{basename(post_head_rot_file)}##binaural.wav" + ) + post = [ + REND_PATH, + "-i", + split_bs_name, + "-if", + "BINAURAL_SPLIT_CODED", + "-of", + "BINAURAL", + "-fs", + "48", + "-tf", + post_head_rot_file, + "-o", + binaural_output_name, + ] + + return [pre, post] + + +def print_command_list(list_of_lists): + for lst in list_of_lists: + print(" ".join(lst)) + print("") # newline + + +def main(): + print("\n##########################################") + print("# Full chain: enc -> dec -> rend(post)") + print("##########################################\n") + for args_full_chain in itertools.product( + # Ordering here must match argument order in function call below! + ISM_CONFIGS_NUM_OBJECTS, + IVAS_BITRATES, + PRE_HEAD_ROT_FILES, + RENDER_CONFIG_FILES, + POST_HEAD_ROT_FILES, + ): + print_command_list(full_chain(*args_full_chain)) + + print("\n##########################################") + print("# Renderer chain: rend(pre) -> rend(post)") + print("##########################################\n") + for args_rend_chain in itertools.product( + # Ordering here must match argument order in function call below! + ISM_CONFIGS_NUM_OBJECTS, + PRE_HEAD_ROT_FILES, + RENDER_CONFIG_FILES, + POST_HEAD_ROT_FILES, + ): + print_command_list(rend_chain(*args_rend_chain)) + + +if __name__ == "__main__": + main() -- GitLab