From 26b7b5dfe01a8e9fc1e4b95c56aa7214837f6cfe Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 17 Oct 2025 11:27:46 +0200 Subject: [PATCH 1/3] port MR --- apps/decoder.c | 58 +++++++-------- apps/encoder.c | 47 +++++++++++- apps/isar_post_rend.c | 2 +- apps/renderer.c | 6 +- lib_com/common_api_types.h | 27 ++++--- lib_com/ivas_cnst.h | 7 +- lib_com/stat_com.h | 2 +- lib_dec/jbm_pcmdsp_apa.h | 12 +-- lib_dec/lib_dec.c | 2 +- lib_isar/isar_cnst.h | 2 +- lib_isar/isar_lc3plus_dec.c | 4 +- lib_isar/isar_stat.h | 4 +- lib_isar/lib_isar_post_rend.c | 10 +-- lib_rend/ivas_reverb.c | 6 +- lib_rend/ivas_reverb_utils.c | 9 +-- lib_rend/ivas_stat_rend.h | 4 +- lib_rend/lib_rend.c | 15 ++-- lib_rend/lib_rend.h | 6 +- lib_util/audio_file_reader.c | 4 +- lib_util/audio_file_writer.c | 3 +- lib_util/ls_custom_file_reader.c | 31 +++++--- lib_util/render_config_reader.c | 98 +++++++++++++++++++------ lib_util/rotation_file_reader.c | 3 +- lib_util/split_rend_bfi_file_reader.c | 5 +- lib_util/split_render_file_read_write.c | 4 +- lib_util/tsm_scale_file_reader.c | 2 +- lib_util/vector3_pair_file_reader.c | 4 - readme.txt | 2 +- 28 files changed, 234 insertions(+), 145 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 62be6f1fc..4b1164859 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -69,22 +69,10 @@ static #endif int32_t frame = 0; /* Counter of frames */ -#define MIN_NUM_BITS_ACTIVE_FRAME 56 -#define NUM_BITS_SID_IVAS_5K2 104 -#define MAX_OUTPUT_PCM_BUFFER_SIZE ( ( IVAS_MAX_OUTPUT_CHANNELS + IVAS_MAX_NUM_OBJECTS ) * IVAS_MAX_FRAME_SIZE ) - -#define ORIENT_TRK_NONE ( 0 ) -#define ORIENT_TRK_REF ( 1 ) -#define ORIENT_TRK_AVG ( 2 ) -#define ORIENT_TRK_REF_VEC ( 3 ) -#define ORIENT_TRK_REF_VEC_LEV ( 4 ) - -#ifdef VARIABLE_SPEED_DECODING -#define VARIABLE_SPEED_FETCH_FRAMESIZE_MS 20 +#ifdef DEBUGGING +#define MIN_NUM_BITS_ACTIVE_FRAME 56 +#define NUM_BITS_SID_IVAS_5K2 104 #endif -#define JBM_FRONTEND_FETCH_FRAMESIZE_MS 20 -#define HEADROTATION_FETCH_FRAMESIZE_MS 5 -#define DEFAULT_FETCH_FRAMESIZE_MS 20 /*------------------------------------------------------------------------------------------* @@ -130,7 +118,7 @@ typedef struct IVAS_DEC_INPUT_FORMAT inputFormat; bool customLsOutputEnabled; char *customLsSetupFilename; - int16_t orientation_tracking; + IVAS_HEAD_ORIENT_TRK_T orientation_tracking; bool non_diegetic_pan_enabled; float non_diegetic_pan_gain; bool renderConfigEnabled; @@ -182,7 +170,7 @@ typedef struct static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg ); static void usage_dec( void ); static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); -static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec ); +static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); static ivas_error load_hrtf_from_file( IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, IVAS_DEC_HANDLE hIvasDec, const IVAS_AUDIO_CONFIG OutputConfig, const int32_t output_Fs ); #ifdef DEBUGGING static ivas_error printBitstreamInfoVoip( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HANDLE hIvasDec ); @@ -356,7 +344,7 @@ int main( } /* sanity check */ - if ( arg.orientation_tracking != ORIENT_TRK_REF ) + if ( arg.orientation_tracking != IVAS_HEAD_ORIENT_TRK_REF ) { fprintf( stderr, "\nError: Reference rotation file can be used in '-otr ref' mode only.\n\n" ); goto cleanup; @@ -383,7 +371,7 @@ int main( } /* sanity check */ - if ( arg.orientation_tracking != ORIENT_TRK_REF_VEC && arg.orientation_tracking != ORIENT_TRK_REF_VEC_LEV ) + if ( arg.orientation_tracking != IVAS_HEAD_ORIENT_TRK_REF_VEC && arg.orientation_tracking != IVAS_HEAD_ORIENT_TRK_REF_VEC_LEV ) { fprintf( stderr, "\nError: Reference trajectory file can be used in '-otr ref_vec' or '-otr ref_vec_lev' mode only.\n\n" ); goto cleanup; @@ -753,7 +741,7 @@ int main( if ( arg.voipMode ) { - error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, hIvasDec ); + error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, hIvasDec, pcmBuf ); } else { @@ -951,6 +939,10 @@ static bool parseCmdlIVAS_dec( int16_t i; char argv_to_upper[FILENAME_MAX]; + /*-----------------------------------------------------------------* + * Set default values + *-----------------------------------------------------------------*/ + #ifdef DEBUGGING float ftmp; @@ -959,7 +951,7 @@ static bool parseCmdlIVAS_dec( arg->agcBitstream = NULL; #endif #endif - arg->output_Fs = 48000; + arg->output_Fs = IVAS_MAX_SAMPLING_RATE; arg->outputConfig = IVAS_AUDIO_CONFIG_MONO; arg->decMode = IVAS_DEC_MODE_IVAS; arg->quietModeEnabled = false; @@ -969,7 +961,7 @@ static bool parseCmdlIVAS_dec( arg->enableHeadRotation = false; arg->headrotTrajFileName = NULL; - arg->orientation_tracking = ORIENT_TRK_NONE; + arg->orientation_tracking = IVAS_HEAD_ORIENT_TRK_NONE; arg->enableReferenceRotation = false; arg->headrotTrajFileName = NULL; arg->enableReferenceVectorTracking = false; @@ -1178,9 +1170,9 @@ static bool parseCmdlIVAS_dec( } arg->tsmScale = (uint16_t) tmp; - if ( arg->tsmScale < 50 || arg->tsmScale > 150 ) + if ( arg->tsmScale < IVAS_TIME_SCALE_MIN || arg->tsmScale > IVAS_TIME_SCALE_MAX ) { - fprintf( stderr, "Error: Scaling factor value must be 50 <= fac <= 150!\n\n" ); + fprintf( stderr, "Error: Scaling factor value must be IVAS_TIME_SCALE_MIN <= fac <= IVAS_TIME_SCALE_MAX !\n\n" ); usage_dec(); return false; } @@ -1255,23 +1247,23 @@ static bool parseCmdlIVAS_dec( if ( strcmp( argv_to_upper, "NONE" ) == 0 ) { - arg->orientation_tracking = ORIENT_TRK_NONE; + arg->orientation_tracking = IVAS_HEAD_ORIENT_TRK_NONE; } else if ( strcmp( argv_to_upper, "REF" ) == 0 ) { - arg->orientation_tracking = ORIENT_TRK_REF; + arg->orientation_tracking = IVAS_HEAD_ORIENT_TRK_REF; } else if ( strcmp( argv_to_upper, "AVG" ) == 0 ) { - arg->orientation_tracking = ORIENT_TRK_AVG; + arg->orientation_tracking = IVAS_HEAD_ORIENT_TRK_AVG; } else if ( strcmp( argv_to_upper, "REF_VEC" ) == 0 ) { - arg->orientation_tracking = ORIENT_TRK_REF_VEC; + arg->orientation_tracking = IVAS_HEAD_ORIENT_TRK_REF_VEC; } else if ( strcmp( argv_to_upper, "REF_VEC_LEV" ) == 0 ) { - arg->orientation_tracking = ORIENT_TRK_REF_VEC_LEV; + arg->orientation_tracking = IVAS_HEAD_ORIENT_TRK_REF_VEC_LEV; } else { @@ -1704,7 +1696,7 @@ static void usage_dec( void ) #ifdef DEBUGGING #ifdef VARIABLE_SPEED_DECODING fprintf( stdout, "-VS fac : Variable Speed mode: change speed of playout fac as integer in percent.\n" ); - fprintf( stdout, " 50 <= fac <= 150; fac<100 faster, fac>100 slower\n" ); + fprintf( stdout, " IVAS_TIME_SCALE_MIN <= fac <= IVAS_TIME_SCALE_MAX; fac<100 faster, fac>100 slower\n" ); #endif #endif fprintf( stdout, "-fr L : render frame size in ms L=(5,10,20), default is 20)\n" ); @@ -3025,14 +3017,15 @@ static ivas_error decodeVoIP( RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, - IVAS_DEC_HANDLE hIvasDec ) + IVAS_DEC_HANDLE hIvasDec, + int16_t *pcmBuf ) { bool decodingFailed = true; /* Assume failure until cleanup is reached without errors */ ivas_error error = IVAS_ERR_OK; uint32_t nextPacketRcvTime_ms = 0; uint32_t systemTime_ms = 0; - uint32_t systemTimeInc_ms = (uint32_t) JBM_FRONTEND_FETCH_FRAMESIZE_MS; + uint32_t systemTimeInc_ms = (uint32_t) ( 1000 / IVAS_NUM_FRAMES_PER_SEC ); int32_t nFramesFed = 0; uint8_t au[( IVAS_MAX_BITS_PER_FRAME + 7 ) >> 3]; @@ -3046,7 +3039,6 @@ static ivas_error decodeVoIP( MasaFileWriter *masaWriter = NULL; uint16_t numObj = 0; - int16_t pcmBuf[MAX_OUTPUT_PCM_BUFFER_SIZE]; AudioFileWriter *afWriter = NULL; #ifdef SUPPORT_JBM_TRACEFILE JbmTraceFileWriter *jbmTraceWriter = NULL; diff --git a/apps/encoder.c b/apps/encoder.c index 4ff6171dd..bd7f4f804 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -170,7 +170,6 @@ typedef struct * Local functions prototypes *------------------------------------------------------------------------------------------*/ -static void initArgStruct( EncArguments *arg ); static bool parseCmdlIVAS_enc( int16_t argc, char *argv[], EncArguments *arg ); static void usage_enc( void ); static bool readBandwidth( FILE *file, IVAS_ENC_BANDWIDTH *bandwidth, int32_t *bandwidthFrameCounter ); @@ -223,8 +222,6 @@ int main( reset_mem( USE_BYTES ); #endif - initArgStruct( &arg ); - /*------------------------------------------------------------------------------------------* * Parse command-line arguments *------------------------------------------------------------------------------------------*/ @@ -970,6 +967,50 @@ static bool parseCmdlIVAS_enc( char stmp[FILENAME_MAX]; int32_t tmp; + /*-----------------------------------------------------------------* + * Set default values + *-----------------------------------------------------------------*/ + + arg->inputWavFilename = NULL; + arg->outputBitstreamFilename = NULL; + arg->inputFs = IVAS_MAX_SAMPLING_RATE; + arg->inputFormat = IVAS_ENC_INPUT_MONO; + arg->is_binaural = false; + arg->inputFormatConfig.stereoToMonoDownmix = false; + arg->max_bwidth_user = false; + arg->maxBandwidth = IVAS_ENC_BANDWIDTH_UNDEFINED; + arg->bandwithProfileFile = NULL; + arg->dtxConfig = IVAS_ENC_GetDefaultDtxConfig(); + arg->initBitrate = 0; + arg->bitrateProfileFile = NULL; + arg->quietModeEnabled = false; + arg->delayCompensationEnabled = true; + arg->masaMetadataFile = NULL; + arg->caConfig = IVAS_ENC_GetDefaultChannelAwareConfig(); + arg->ca_config_file = NULL; + arg->mimeOutput = false; + arg->ism_extended_metadata = false; + arg->complexityLevel = IVAS_ENC_COMPLEXITY_LEVEL_THREE; + +#ifdef DEBUGGING + arg->forcedMode = IVAS_ENC_FORCE_UNFORCED; + arg->forcedModeFile = NULL; +#ifdef DEBUG_AGC_ENCODER_CMD_OPTION + arg->agc = IVAS_ENC_AGC_UNDEFINED; +#endif +#ifdef DEBUG_FOA_AGC + arg->agcBitstream = NULL; +#endif +#ifdef DEBUG_SBA + arg->dbg_file_tag = NULL; +#endif +#endif + arg->pca = false; + + /*-----------------------------------------------------------------* + * Initialization + *-----------------------------------------------------------------*/ + if ( argc < 5 ) { fprintf( stderr, "Error: Not enough input parameters. Exiting!\n\n" ); diff --git a/apps/isar_post_rend.c b/apps/isar_post_rend.c index fc93d9375..f7b3e479f 100644 --- a/apps/isar_post_rend.c +++ b/apps/isar_post_rend.c @@ -920,7 +920,7 @@ int main( memset( outBuffer.data, 0, outBuffer.config.numSamplesPerChannel * outBuffer.config.numChannels * sizeof( float ) ); - bitsBufferSize = SPLIT_REND_BITS_BUFF_SIZE; + bitsBufferSize = ISAR_SPLIT_REND_BITS_BUFF_SIZE; if ( bitsBufferSize > 0 ) { diff --git a/apps/renderer.c b/apps/renderer.c index 0c5183cd9..1a70731cd 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -170,7 +170,7 @@ typedef struct char externalOrientationFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; char customHrtfFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; char renderConfigFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; - int8_t orientation_tracking; + IVAS_HEAD_ORIENT_TRK_T orientation_tracking; int16_t Opt_Headrotation; int16_t Opt_ExternalOrientation; int16_t nonDiegeticPan; @@ -1477,7 +1477,7 @@ int main( if ( is_split_pre_rend_mode( &args ) ) { - bitsBufferSize = SPLIT_REND_BITS_BUFF_SIZE; + bitsBufferSize = ISAR_SPLIT_REND_BITS_BUFF_SIZE; } else { @@ -2312,7 +2312,7 @@ static bool parseRenderFramesize( static bool parseOrientationTracking( char *value, - int8_t *orientation_tracking ) + IVAS_HEAD_ORIENT_TRK_T *orientation_tracking ) { to_upper( value ); diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index ac26b97e4..35a816897 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -44,24 +44,27 @@ * Common API constants *----------------------------------------------------------------------------------*/ -#define IVAS_NUM_FRAMES_PER_SEC 50 -#define IVAS_MAX_FRAME_SIZE ( 48000 / IVAS_NUM_FRAMES_PER_SEC ) -#define IVAS_MAX_BITS_PER_FRAME ( 512000 / IVAS_NUM_FRAMES_PER_SEC ) +#define IVAS_NUM_FRAMES_PER_SEC 50 /* number of frames per second */ +#define IVAS_MAX_SAMPLING_RATE 48000 /* maximum supported sampling rate in Hz */ +#define IVAS_MAX_FRAME_SIZE ( IVAS_MAX_SAMPLING_RATE / IVAS_NUM_FRAMES_PER_SEC ) /* maximum frame buffer length (per channel) in samples */ +#define IVAS_MAX_BITS_PER_FRAME ( 512000 / IVAS_NUM_FRAMES_PER_SEC ) /* maximum bits per frame; corresponds to maximum bitrate of 512 kbps */ #define IVAS_MAX_NUM_OBJECTS 4 #define IVAS_MAX_INPUT_CHANNELS 16 -#define IVAS_MAX_OUTPUT_CHANNELS 16 +#define IVAS_MAX_OUTPUT_CHANNELS 16 /* Note: there is an exception for OSBA and EXT otuput where it can be 20 (HOA3 + 4 ISM channels) */ #define IVAS_CLDFB_NO_COL_MAX 16 #define IVAS_CLDFB_NO_CHANNELS_MAX 60 +/* Renderer constants */ #define IVAS_MAX_PARAM_SPATIAL_SUBFRAMES 4 #define IVAS_ROOM_ABS_COEFF 6 +#define IVAS_REVERB_PREDELAY_MAX 20 /* Max input delay for reverb module */ +#define IVAS_ER_LIST_HEIGHT 1.6f -/* Maximum buffer length (per channel) in samples */ -#define MAX_BUFFER_LENGTH_PER_CHANNEL ( L_FRAME48k ) +/* JBM constants for adaptive-playout */ +#define IVAS_TIME_SCALE_MIN 50 /* min. time-scaling [%] */ +#define IVAS_TIME_SCALE_MAX 150 /* max. time-scaling [%] */ -/* Frame size required when rendering to binaural */ -#define BINAURAL_RENDERING_FRAME_SIZE_MS 5 /*----------------------------------------------------------------------------------* * Common API enum for output audio configurations @@ -182,7 +185,7 @@ typedef struct ivas_hrtf_crend_structure *IVAS_DEC_HRTF_CREND_HANDLE; typedef struct ivas_hrtf_fastconv_struct *IVAS_DEC_HRTF_FASTCONV_HANDLE; typedef struct ivas_hrtf_parambin_struct *IVAS_DEC_HRTF_PARAMBIN_HANDLE; typedef struct ivas_hrtf_statistics_struct *IVAS_DEC_HRTF_STATISTICS_HANDLE; -typedef struct cldfb_filter_bank_struct *IVAS_CLDFB_FILTER_BANK_HANDLE; +typedef struct ivas_cldfb_filter_bank_struct *IVAS_CLDFB_FILTER_BANK_HANDLE; typedef struct ivas_LS_setup_custom *IVAS_LSSETUP_CUSTOM_HANDLE; typedef struct ivas_LS_setup_custom IVAS_LSSETUP_CUSTOM_STRUCT; @@ -231,7 +234,7 @@ typedef enum _ivas_binaural_renderer_type #define ISAR_MAX_SPLIT_REND_BITRATE 768000 #define ISAR_MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES ( ( ( (int32_t) ISAR_MAX_SPLIT_REND_BITRATE / IVAS_NUM_FRAMES_PER_SEC ) + 7 ) >> 3 ) #define ISAR_SPLIT_REND_ADDITIONAL_BYTES_TO_READ 1 -#define SPLIT_REND_BITS_BUFF_SIZE ( ISAR_MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES + ISAR_SPLIT_REND_ADDITIONAL_BYTES_TO_READ ) +#define ISAR_SPLIT_REND_BITS_BUFF_SIZE ( ISAR_MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES + ISAR_SPLIT_REND_ADDITIONAL_BYTES_TO_READ ) typedef enum { @@ -309,7 +312,6 @@ typedef enum } IVAS_RENDER_TYPE_OVERRIDE; #endif - typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG { int16_t nBands; /* Number of frequency bands for which reverb properties are provided, integer, range [2..256] */ @@ -337,6 +339,7 @@ typedef struct _IVAS_RENDER_CONFIG ISAR_SPLIT_REND_CONFIG_DATA split_rend_config; float directivity[IVAS_MAX_NUM_OBJECTS * 3]; float distAtt[3]; + } IVAS_RENDER_CONFIG_DATA, *IVAS_RENDER_CONFIG_HANDLE; typedef struct @@ -344,12 +347,14 @@ typedef struct int16_t numSamplesPerChannel; int16_t numChannels; int16_t is_cldfb; + } IVAS_REND_AudioBufferConfig; typedef struct { IVAS_REND_AudioBufferConfig config; float *data; + } IVAS_REND_AudioBuffer; #endif /* COMMON_API_TYPES_H */ diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 09e414867..fac0fa021 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -133,7 +133,7 @@ typedef enum #define MAX_INTERN_CHANNELS 16 /* Maximum number of intern channels (HOA 3rd order) */ #define HEAD_ROTATION_HOA_ORDER 3 /* HOA 3rd order */ #define MAX_CICP_CHANNELS 16 /* max channels for loudspeaker layouts (16 for custom layouts)*/ -#define MAX_OUTPUT_CHANNELS 16 /* Maximum number of output channels (HOA 3rd order), == IVAS_MAX_OUTPUT_CHANNELS */ +#define MAX_OUTPUT_CHANNELS 16 /* Maximum number of output channels (HOA 3rd order) without separate objects in combined formats */ #define MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN 2 /* Maximum number of output channels with non diegetic panning */ #define BINAURAL_CHANNELS 2 /* number of channels for binaural output configuration */ @@ -1489,7 +1489,6 @@ typedef enum #define HRTF_SH_CHANNELS HOA3_CHANNELS #define HRTF_LS_CHANNELS 15 #define HRTF_NUM_BINS 60 -#define REVERB_PREDELAY_MAX 20 /* Max input delay for reverb module */ #define GAIN_LFE 1.88364911f /* Gain applied to LFE during renderering */ #define LOW_BIT_RATE_BINAURAL_EQ_BINS 17 /* Number of bins in an EQ applied at low bit rates in binauralization */ #define LOW_BIT_RATE_BINAURAL_EQ_OFFSET 14 /* Offset of bins where the low-bit-rate EQ starts*/ @@ -1732,9 +1731,7 @@ typedef enum *----------------------------------------------------------------------------------*/ #define ER_RADIUS (1.0f) -#define ER_LIST_ORIGIN_X (0.0f) -#define ER_LIST_ORIGIN_Y (0.0f) -#define ER_LIST_HEIGHT (1.6f) +#define ER_LIST_HEIGHT IVAS_ER_LIST_HEIGHT /*----------------------------------------------------------------------------------* diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index 622a07eb1..4f459ef53 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -573,7 +573,7 @@ typedef struct } FrameSizeParams; -typedef struct cldfb_filter_bank_struct +typedef struct ivas_cldfb_filter_bank_struct { int16_t no_channels; int16_t no_col; diff --git a/lib_dec/jbm_pcmdsp_apa.h b/lib_dec/jbm_pcmdsp_apa.h index 26c380e38..a728cb53d 100644 --- a/lib_dec/jbm_pcmdsp_apa.h +++ b/lib_dec/jbm_pcmdsp_apa.h @@ -39,9 +39,9 @@ #ifndef JBM_PCMDSP_APA_H #define JBM_PCMDSP_APA_H JBM_PCMDSP_APA_H +#include "common_api_types.h" #include -#include -#include "options.h" + /* ******************************************************************************** @@ -50,17 +50,17 @@ */ /* size of IO buffers (a_in[], a_out[]) for apa_exec() */ -#define APA_BUF_PER_CHANNEL ( 960 * 3 ) +#define APA_BUF_PER_CHANNEL ( IVAS_MAX_FRAME_SIZE * 3 ) #define APA_MAX_NUM_CHANNELS 16 #define APA_BUF ( APA_BUF_PER_CHANNEL * APA_MAX_NUM_CHANNELS ) /* min/max sampling rate [Hz] */ #define APA_MIN_RATE 1000 -#define APA_MAX_RATE 48000 +#define APA_MAX_RATE IVAS_MAX_SAMPLING_RATE /* min/max scaling [%] */ -#define APA_MIN_SCALE 50 -#define APA_MAX_SCALE 150 +#define APA_MIN_SCALE IVAS_TIME_SCALE_MIN +#define APA_MAX_SCALE IVAS_TIME_SCALE_MAX #define APA_SM_SURROUND 1 #define APA_SM_LOGARITHMIC 2 diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 7859e4fb0..6726c87d6 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -2521,7 +2521,7 @@ ivas_error IVAS_DEC_GetFormat( /*---------------------------------------------------------------------* - * getInputBufferSize() + * getOutputBufferSize() * * *---------------------------------------------------------------------*/ diff --git a/lib_isar/isar_cnst.h b/lib_isar/isar_cnst.h index 8f2636bda..88a26196a 100644 --- a/lib_isar/isar_cnst.h +++ b/lib_isar/isar_cnst.h @@ -110,7 +110,7 @@ typedef enum #define ISAR_SPLIT_REND_ROT_AXIS_BITS 3 #define ISAR_SPLIT_REND_RO_FLAG_BITS 1 -#define IVAS_LC3PLUS_MAX_NUM_DECODERS 2 +#define ISAR_LC3PLUS_MAX_NUM_DECODERS 2 /*----------------------------------------------------------------------------------* * Split rendering bitrate constants diff --git a/lib_isar/isar_lc3plus_dec.c b/lib_isar/isar_lc3plus_dec.c index 7d43ed83b..f097aec14 100644 --- a/lib_isar/isar_lc3plus_dec.c +++ b/lib_isar/isar_lc3plus_dec.c @@ -66,9 +66,9 @@ ivas_error ISAR_LC3PLUS_DEC_Open( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus wrapper handle\n" ); } - if ( config.channels > IVAS_LC3PLUS_MAX_NUM_DECODERS ) + if ( config.channels > ISAR_LC3PLUS_MAX_NUM_DECODERS ) { - return IVAS_ERROR( IVAS_ERR_INIT_ERROR, "Maximum number of channels exceeds IVAS_LC3PLUS_MAX_NUM_DECODERS\n" ); + return IVAS_ERROR( IVAS_ERR_INIT_ERROR, "Maximum number of channels exceeds ISAR_LC3PLUS_MAX_NUM_DECODERS\n" ); } diff --git a/lib_isar/isar_stat.h b/lib_isar/isar_stat.h index acdddd839..587c3c8ea 100644 --- a/lib_isar/isar_stat.h +++ b/lib_isar/isar_stat.h @@ -48,9 +48,9 @@ * ISAR post rend constants *-------------------------------------------------------------------*/ -#define MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL ( MAX_BUFFER_LENGTH_PER_CHANNEL * 2 ) +#define MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL ( L_FRAME_MAX * 2 ) #define MAX_CLDFB_BUFFER_LENGTH ( MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL * MAX_INPUT_CHANNELS ) -#define MAX_BIN_BUFFER_LENGTH ( MAX_BUFFER_LENGTH_PER_CHANNEL * BINAURAL_CHANNELS ) +#define MAX_BIN_BUFFER_LENGTH ( L_FRAME_MAX * BINAURAL_CHANNELS ) #define MAX_CLDFB_BIN_BUFFER_LENGTH ( MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL * BINAURAL_CHANNELS ) /*-------------------------------------------------------------------* diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index 9bbee5d1b..b31d698ab 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -1039,8 +1039,8 @@ ivas_error ISAR_POST_REND_FeedInputAudio( cldfb2tdSampleFact = ( inputAudio.config.is_cldfb ) ? 2 : 1; - if ( inputAudio.config.numSamplesPerChannel <= 0 || ( MAX_BUFFER_LENGTH_PER_CHANNEL < inputAudio.config.numSamplesPerChannel && inputAudio.config.is_cldfb == 0 ) || - ( ( MAX_BUFFER_LENGTH_PER_CHANNEL * cldfb2tdSampleFact ) < inputAudio.config.numSamplesPerChannel && inputAudio.config.is_cldfb == 1 ) ) + if ( inputAudio.config.numSamplesPerChannel <= 0 || ( L_FRAME_MAX < inputAudio.config.numSamplesPerChannel && inputAudio.config.is_cldfb == 0 ) || + ( ( L_FRAME_MAX * cldfb2tdSampleFact ) < inputAudio.config.numSamplesPerChannel && inputAudio.config.is_cldfb == 1 ) ) { return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Buffer size outside of supported range" ); } @@ -1053,7 +1053,7 @@ ivas_error ISAR_POST_REND_FeedInputAudio( if ( isar_getAudioConfigType( hIvasRend->outputConfig ) == ISAR_POST_REND_AUDIO_CONFIG_TYPE_BINAURAL && hIvasRend->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && hIvasRend->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && - ( inputAudio.config.numSamplesPerChannel * 1000 / cldfb2tdSampleFact ) != ( BINAURAL_RENDERING_FRAME_SIZE_MS * hIvasRend->num_subframes ) * hIvasRend->sampleRateOut ) + ( inputAudio.config.numSamplesPerChannel * 1000 / cldfb2tdSampleFact ) != ( L_FRAME_MAX * hIvasRend->num_subframes ) * hIvasRend->sampleRateOut ) { return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Binaural rendering requires specific frame size" ); } @@ -1653,8 +1653,8 @@ ivas_error ISAR_POST_REND_getSamples( cldfb2tdSampleFact = ( outAudio.config.is_cldfb ) ? 2 : 1; - if ( outAudio.config.numSamplesPerChannel <= 0 || ( MAX_BUFFER_LENGTH_PER_CHANNEL < outAudio.config.numSamplesPerChannel && outAudio.config.is_cldfb == 0 ) || - ( ( MAX_BUFFER_LENGTH_PER_CHANNEL * cldfb2tdSampleFact ) < outAudio.config.numSamplesPerChannel && outAudio.config.is_cldfb == 1 ) ) + if ( outAudio.config.numSamplesPerChannel <= 0 || ( L_FRAME_MAX < outAudio.config.numSamplesPerChannel && outAudio.config.is_cldfb == 0 ) || + ( ( L_FRAME_MAX * cldfb2tdSampleFact ) < outAudio.config.numSamplesPerChannel && outAudio.config.is_cldfb == 1 ) ) { return IVAS_ERR_INVALID_BUFFER_SIZE; } diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index a5ade8027..ffb017794 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -158,9 +158,9 @@ static void ivas_binaural_reverb_setPreDelay( return; } - if ( delaySamples > REVERB_PREDELAY_MAX ) + if ( delaySamples > IVAS_REVERB_PREDELAY_MAX ) { - hReverb->preDelayBufferLength = REVERB_PREDELAY_MAX; + hReverb->preDelayBufferLength = IVAS_REVERB_PREDELAY_MAX; return; } @@ -1787,7 +1787,7 @@ static ivas_error ivas_binaural_reverb_open( hReverb->numBins = numBins; hReverb->blockSize = numCldfbSlotsPerFrame; - for ( k = 0; k < REVERB_PREDELAY_MAX + 1; k++ ) + for ( k = 0; k < IVAS_REVERB_PREDELAY_MAX + 1; k++ ) { set_f( hReverb->preDelayBufferReal[k], 0.0f, hReverb->numBins ); set_f( hReverb->preDelayBufferImag[k], 0.0f, hReverb->numBins ); diff --git a/lib_rend/ivas_reverb_utils.c b/lib_rend/ivas_reverb_utils.c index 36a84bd1a..9c4f590a0 100644 --- a/lib_rend/ivas_reverb_utils.c +++ b/lib_rend/ivas_reverb_utils.c @@ -47,7 +47,6 @@ *-----------------------------------------------------------------------------------------*/ #define DEFAULT_SRC_DIST ( 1.5f ) /* default source distance [m] for reverb dmx factor computing */ -#define MAX_SAMPLING_RATE ( 48000 ) #define CLDFB_CONVOLVER_NTAPS_MAX ( 16 ) #define FFT_SPECTRUM_SIZE ( 1 + ( RV_FILTER_MAX_FFT_SIZE / 2 ) ) @@ -93,7 +92,7 @@ ivas_error ivas_reverb_prepare_cldfb_params( for ( idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) { - fc[idx] = ( (float) idx + 0.5f ) * ( (float) MAX_SAMPLING_RATE / (float) ( 2 * CLDFB_NO_CHANNELS_MAX ) ); + fc[idx] = ( (float) idx + 0.5f ) * ( (float) IVAS_MAX_SAMPLING_RATE / (float) ( 2 * IVAS_CLDFB_NO_CHANNELS_MAX ) ); } ivas_reverb_interpolate_acoustic_data( pInput_params->nBands, pInput_params->pFc_input, pInput_params->pAcoustic_rt60, pInput_params->pAcoustic_dsr, CLDFB_NO_CHANNELS_MAX, fc, pOutput_t60, pOutput_ene ); @@ -136,7 +135,7 @@ static void ivas_reverb_set_energies( float *avg_pwr_right ) { int16_t freq_idx; - const int16_t cldfb_freq_halfstep = MAX_SAMPLING_RATE / ( 4 * CLDFB_NO_CHANNELS_MAX ); + const int16_t cldfb_freq_halfstep = IVAS_MAX_SAMPLING_RATE / ( 4 * IVAS_CLDFB_NO_CHANNELS_MAX ); float input_fc[FFT_SPECTRUM_SIZE]; float output_fc[CLDFB_NO_CHANNELS_MAX]; @@ -147,9 +146,9 @@ static void ivas_reverb_set_energies( input_fc[freq_idx] = freq_idx * ( 0.5f * sampling_rate / (float) ( avg_pwr_len - 1 ) ); } - for ( freq_idx = 0; freq_idx < CLDFB_NO_CHANNELS_MAX; freq_idx++ ) + for ( freq_idx = 0; freq_idx < IVAS_CLDFB_NO_CHANNELS_MAX; freq_idx++ ) { output_fc[freq_idx] = (float) ( ( 2 * freq_idx + 1 ) * cldfb_freq_halfstep ); } - ivas_reverb_interpolate_acoustic_data( avg_pwr_len, input_fc, avg_pwr_l, avg_pwr_r, CLDFB_NO_CHANNELS_MAX, output_fc, avg_pwr_left, avg_pwr_right ); + ivas_reverb_interpolate_acoustic_data( avg_pwr_len, input_fc, avg_pwr_l, avg_pwr_r, IVAS_CLDFB_NO_CHANNELS_MAX, output_fc, avg_pwr_left, avg_pwr_right ); } diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 396e4e6c6..bba88de8e 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -452,8 +452,8 @@ typedef struct ivas_binaural_reverb_struct { float *loopBufReal[CLDFB_NO_CHANNELS_MAX]; float *loopBufImag[CLDFB_NO_CHANNELS_MAX]; - float preDelayBufferReal[REVERB_PREDELAY_MAX + 1][CLDFB_NO_CHANNELS_MAX]; - float preDelayBufferImag[REVERB_PREDELAY_MAX + 1][CLDFB_NO_CHANNELS_MAX]; + float preDelayBufferReal[IVAS_REVERB_PREDELAY_MAX + 1][CLDFB_NO_CHANNELS_MAX]; + float preDelayBufferImag[IVAS_REVERB_PREDELAY_MAX + 1][CLDFB_NO_CHANNELS_MAX]; float **tapPointersReal[CLDFB_NO_CHANNELS_MAX][BINAURAL_CHANNELS]; float **tapPointersImag[CLDFB_NO_CHANNELS_MAX][BINAURAL_CHANNELS]; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 953672fce..d740eed34 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -51,7 +51,7 @@ *-------------------------------------------------------------------*/ /* Maximum buffer length (total) in samples. */ -#define MAX_BUFFER_LENGTH ( MAX_BUFFER_LENGTH_PER_CHANNEL * MAX_INPUT_CHANNELS ) +#define MAX_BUFFER_LENGTH ( L_FRAME_MAX * MAX_INPUT_CHANNELS ) #define MAX_BIN_DELAY_SAMPLES 150 /* Maximum supported rendering latency for binaural IRs */ /*-------------------------------------------------------------------* @@ -4013,8 +4013,8 @@ ivas_error IVAS_REND_FeedInputAudio( cldfb2tdSampleFact = ( inputAudio.config.is_cldfb ) ? 2 : 1; - if ( inputAudio.config.numSamplesPerChannel <= 0 || ( MAX_BUFFER_LENGTH_PER_CHANNEL < inputAudio.config.numSamplesPerChannel && inputAudio.config.is_cldfb == 0 ) || - ( ( MAX_BUFFER_LENGTH_PER_CHANNEL * cldfb2tdSampleFact ) < inputAudio.config.numSamplesPerChannel && inputAudio.config.is_cldfb == 1 ) ) + if ( inputAudio.config.numSamplesPerChannel <= 0 || ( L_FRAME_MAX < inputAudio.config.numSamplesPerChannel && inputAudio.config.is_cldfb == 0 ) || + ( ( L_FRAME_MAX * cldfb2tdSampleFact ) < inputAudio.config.numSamplesPerChannel && inputAudio.config.is_cldfb == 1 ) ) { return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Buffer size outside of supported range" ); } @@ -5796,7 +5796,7 @@ static ivas_error renderLfeToBinaural( int16_t pose_idx, num_poses; float gain; int16_t ear_idx; - float tmpLfeBuffer[MAX_BUFFER_LENGTH_PER_CHANNEL]; + float tmpLfeBuffer[L_FRAME_MAX]; int16_t frame_size, num_cpy_smpl_cur_frame, num_cpy_smpl_prev_frame; const float *lfeInput; float *writePtr; @@ -7440,8 +7440,8 @@ static ivas_error getSamplesInternal( cldfb2tdSampleFact = ( outAudio.config.is_cldfb ) ? 2 : 1; - if ( outAudio.config.numSamplesPerChannel <= 0 || ( MAX_BUFFER_LENGTH_PER_CHANNEL < outAudio.config.numSamplesPerChannel && outAudio.config.is_cldfb == 0 ) || - ( ( MAX_BUFFER_LENGTH_PER_CHANNEL * cldfb2tdSampleFact ) < outAudio.config.numSamplesPerChannel && outAudio.config.is_cldfb == 1 ) ) + if ( outAudio.config.numSamplesPerChannel <= 0 || ( L_FRAME_MAX < outAudio.config.numSamplesPerChannel && outAudio.config.is_cldfb == 0 ) || + ( ( L_FRAME_MAX * cldfb2tdSampleFact ) < outAudio.config.numSamplesPerChannel && outAudio.config.is_cldfb == 1 ) ) { return IVAS_ERR_INVALID_BUFFER_SIZE; } @@ -7777,8 +7777,7 @@ void IVAS_REND_Close( * *-------------------------------------------------------------------*/ -ivas_error -IVAS_REND_openCldfb( +ivas_error IVAS_REND_openCldfb( IVAS_CLDFB_FILTER_BANK_HANDLE cldfbAna[IVAS_MAX_INPUT_CHANNELS], IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_OUTPUT_CHANNELS], const int16_t num_in_chs, diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 4ed038df9..83d4ab426 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -41,12 +41,16 @@ * Renderer constants *---------------------------------------------------------------------*/ -#define RENDERER_MAX_ISM_INPUTS 4 +#define RENDERER_MAX_ISM_INPUTS IVAS_MAX_NUM_OBJECTS #define RENDERER_MAX_MC_INPUTS 1 #define RENDERER_MAX_SBA_INPUTS 1 #define RENDERER_MAX_MASA_INPUTS 1 #define RENDERER_MAX_INPUT_LFE_CHANNELS 4 +/* Frame size required when rendering to binaural */ +#define BINAURAL_RENDERING_FRAME_SIZE_MS 5 + + /*---------------------------------------------------------------------* * Renderer structures *---------------------------------------------------------------------*/ diff --git a/lib_util/audio_file_reader.c b/lib_util/audio_file_reader.c index ca5e6e496..fe5669fa5 100644 --- a/lib_util/audio_file_reader.c +++ b/lib_util/audio_file_reader.c @@ -32,9 +32,7 @@ #include "audio_file_reader.h" #include "tinywavein_c.h" -#include -#include -#include "wmc_auto.h" + struct AudioFileReader { diff --git a/lib_util/audio_file_writer.c b/lib_util/audio_file_writer.c index fb7a64c42..321063101 100644 --- a/lib_util/audio_file_writer.c +++ b/lib_util/audio_file_writer.c @@ -32,9 +32,8 @@ #include "audio_file_writer.h" #include "tinywaveout_c.h" -#include #include -#include "wmc_auto.h" + struct AudioFileWriter { diff --git a/lib_util/ls_custom_file_reader.c b/lib_util/ls_custom_file_reader.c index 01d1f0307..9e5882aee 100644 --- a/lib_util/ls_custom_file_reader.c +++ b/lib_util/ls_custom_file_reader.c @@ -34,7 +34,6 @@ #include #include #include "ivas_prot.h" -#include "prot.h" struct LsCustomFileReader @@ -126,6 +125,13 @@ static LS_CUSTOM_FILEREADER_ERROR CustomLoudspeakerLayout_validate( float azi_tmp[IVAS_MAX_OUTPUT_CHANNELS]; float ele_tmp[IVAS_MAX_OUTPUT_CHANNELS]; + for ( i = 0; i < IVAS_MAX_OUTPUT_CHANNELS; i++ ) + { + dup[i] = 0; + azi_tmp[i] = 0.0f; + ele_tmp[i] = 0.0f; + } + if ( *num_azi != *num_ele ) { return LS_CUSTOM_FILEREADER_NUM_SPK_MISMATCH_ERROR; @@ -150,7 +156,6 @@ static LS_CUSTOM_FILEREADER_ERROR CustomLoudspeakerLayout_validate( /* Check for and flag duplicate loudspeakers */ dup_count = 0; - set_s( dup, 0, IVAS_MAX_OUTPUT_CHANNELS ); for ( i = 0; i < *num_azi; i++ ) { for ( j = i + 1; j < *num_azi; j++ ) @@ -163,9 +168,6 @@ static LS_CUSTOM_FILEREADER_ERROR CustomLoudspeakerLayout_validate( } /* Remove duplicates from array */ - set_zero( azi_tmp, IVAS_MAX_OUTPUT_CHANNELS ); - set_zero( ele_tmp, IVAS_MAX_OUTPUT_CHANNELS ); - for ( i = 0, j = 0; i < *num_azi; i++ ) { if ( dup[i] ) @@ -179,8 +181,11 @@ static LS_CUSTOM_FILEREADER_ERROR CustomLoudspeakerLayout_validate( } ( *num_azi ) -= dup_count; - mvr2r( azi_tmp, azi, IVAS_MAX_OUTPUT_CHANNELS ); - mvr2r( ele_tmp, ele, IVAS_MAX_OUTPUT_CHANNELS ); + for ( i = 0; i < IVAS_MAX_OUTPUT_CHANNELS; i++ ) + { + azi[i] = azi_tmp[i]; + ele[i] = ele_tmp[i]; + } return LS_CUSTOM_FILEREADER_NO_ERROR; } @@ -236,17 +241,19 @@ LS_CUSTOM_FILEREADER_ERROR CustomLsFileReading( char line[200]; /* > (10 chars * IVAS_MAX_OUTPUT_CHANNELS) i.e. "-999, " */ const char *tok; - - int16_t num_azi, num_ele, num_lfe; + int16_t i, num_azi, num_ele, num_lfe; /* initialize variables */ num_azi = 0; num_ele = 0; num_lfe = 0; - set_zero( hLsCustomData->azimuth, IVAS_MAX_OUTPUT_CHANNELS ); - set_zero( hLsCustomData->elevation, IVAS_MAX_OUTPUT_CHANNELS ); - set_s( hLsCustomData->lfe_idx, -1, IVAS_MAX_OUTPUT_CHANNELS ); + for ( i = 0; i < IVAS_MAX_OUTPUT_CHANNELS; i++ ) + { + hLsCustomData->lfe_idx[i] = -1; + hLsCustomData->azimuth[i] = 0.0f; + hLsCustomData->elevation[i] = 0.0f; + } if ( hLsCustomReader->file == NULL ) { diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 9bd5e019d..c03392efd 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -35,9 +35,7 @@ #include #include #include -#include #include "cmdl_tools.h" -#include "prot.h" /*------------------------------------------------------------------------------------------* @@ -58,9 +56,9 @@ #define ACOUSTIC_DSR_MAX ( 1.0e+2f ) #define ACOUSTIC_DSR_EPSILON ( 1.0e-15f ) #define ACOUSTICPREDELAY_JOTREV_MIN ( SHORTEST_REV_DEL_LINE ) -#define ACOUSTICPREDELAY_JOTREV_MAX ( SHORTEST_REV_DEL_LINE + 1.0f / (float) FRAMES_PER_SEC ) -#define ACOUSTICPREDELAY_FDREV_MIN ( 1.0f / (float) ( 16 * FRAMES_PER_SEC ) ) -#define ACOUSTICPREDELAY_FDREV_MAX ( (float) ( REVERB_PREDELAY_MAX ) / (float) ( 16 * FRAMES_PER_SEC ) ) +#define ACOUSTICPREDELAY_JOTREV_MAX ( SHORTEST_REV_DEL_LINE + 1.0f / (float) IVAS_NUM_FRAMES_PER_SEC ) +#define ACOUSTICPREDELAY_FDREV_MIN ( 1.0f / (float) ( 16 * IVAS_NUM_FRAMES_PER_SEC ) ) +#define ACOUSTICPREDELAY_FDREV_MAX ( (float) ( IVAS_REVERB_PREDELAY_MAX ) / (float) ( 16 * IVAS_NUM_FRAMES_PER_SEC ) ) #define INPUTPREDELAY_MIN ( 0.0f ) #define INPUTPREDELAY_MAX ( 1.0e+2f ) @@ -69,6 +67,25 @@ #define ER_MIN_ABS_COEFF ( 0.0f ) #define ER_MAX_ABS_COEFF ( 1.0f ) +#define IVAS_ER_LIST_ORIGIN_X 0.0f +#define IVAS_ER_LIST_ORIGIN_Y 0.0f + +#ifndef TRUE +#define TRUE 1 +#endif +#ifndef FALSE +#define FALSE 0 +#endif + +#ifndef min +#define min( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) ) +#endif + +#ifndef max +#define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) ) +#endif + + /*------------------------------------------------------------------------------------------* * Local Type definitions *------------------------------------------------------------------------------------------*/ @@ -646,13 +663,36 @@ static ivas_error read_bin_code_word( } } } + return IVAS_ERR_INVALID_RENDER_CONFIG; } + +/*-------------------------------------------------------------------* + * usdequant_rend_cfg() + * + * Uniform scalar de-quantizer routine + *-------------------------------------------------------------------*/ + +static float usdequant_rend_cfg( + const uint32_t idx, /* i : quantizer index */ + const float qlow, /* i : lowest codebook entry (index 0) */ + const float delta /* i : quantization step */ +) +{ + float g; + + g = idx * delta + qlow; + + return ( g ); +} + + /*-----------------------------------------------------------------------------------------* * Function get_bin_count_or_index() * Gets a count or index *-----------------------------------------------------------------------------------------*/ + static ivas_error get_bin_count_or_index( RenderConfigReader *this, /* i/o : Renderer config reader handle */ uint32_t *pResult /* o : Count or index value */ @@ -945,8 +985,11 @@ static ivas_error read_txt_bool( *pTarget = FALSE; return IVAS_ERR_OK; } + return IVAS_ERR_INVALID_RENDER_CONFIG; } + + /*-----------------------------------------------------------------------------------------* * Function get_bin_angle() * Gets an angle value in degrees [0,360] @@ -965,11 +1008,12 @@ static ivas_error get_bin_angle( return error; } - *pResult = usdequant( (int16_t) value, 0.0f, 20.0f ); + *pResult = usdequant_rend_cfg( value, 0.0f, 20.0f ); return IVAS_ERR_OK; } + /*-----------------------------------------------------------------------------------------* * Function get_bin_outer_attenuation () * Gets an outer attenuation value [3.1623e-05,1.0], or in dB: [-90,0] @@ -989,7 +1033,7 @@ static ivas_error get_bin_outer_attenuation( return error; } - logval = usdequant( (int16_t) value, -90.0f, 3.0f ); + logval = usdequant_rend_cfg( value, -90.0f, 3.0f ); att = powf( 10, logval / 20.0f ); *pResult = att; @@ -997,6 +1041,7 @@ static ivas_error get_bin_outer_attenuation( return IVAS_ERR_OK; } + /*-----------------------------------------------------------------------------------------* * Function get_bin_max_dist () * Gets a Maximum Distance value [1.0, 64.0] @@ -1015,11 +1060,12 @@ static ivas_error get_bin_max_dist( return error; } - *pResult = usdequant( (int16_t) value, 1.0f, 1.0f ); + *pResult = usdequant_rend_cfg( value, 1.0f, 1.0f ); return IVAS_ERR_OK; } + /*-----------------------------------------------------------------------------------------* * Function get_bin_ref_dist () * Gets a Reference Distance value [0.1, 6.4] @@ -1038,11 +1084,12 @@ static ivas_error get_bin_ref_dist( return error; } - *pResult = usdequant( (int16_t) value, 0.1f, 0.1f ); + *pResult = usdequant_rend_cfg( value, 0.1f, 0.1f ); return IVAS_ERR_OK; } + /*-----------------------------------------------------------------------------------------* * Function get_bin_rolloff () * Gets a Rollof Factor [0.0, 4.0] @@ -1061,7 +1108,7 @@ static ivas_error get_bin_rolloff( return error; } - *pResult = usdequant( (int16_t) value, 0.0f, 0.1f ); + *pResult = usdequant_rend_cfg( value, 0.0f, 0.1f ); return IVAS_ERR_OK; } @@ -1806,9 +1853,9 @@ static ivas_error RenderConfigReader_readBinary( { return IVAS_ERR_FAILED_ALLOC; } - pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->x = ER_LIST_ORIGIN_X; - pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->y = ER_LIST_ORIGIN_Y; - pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->z = ER_LIST_HEIGHT; + pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->x = IVAS_ER_LIST_ORIGIN_X; + pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->y = IVAS_ER_LIST_ORIGIN_Y; + pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->z = IVAS_ER_LIST_HEIGHT; } /* Low complexity mode */ @@ -2968,9 +3015,9 @@ ivas_error RenderConfigReader_getAcousticEnvironment( { return IVAS_ERR_FAILED_ALLOC; } - pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->x = ER_LIST_ORIGIN_X; - pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->y = ER_LIST_ORIGIN_Y; - pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->z = ER_LIST_HEIGHT; + pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->x = IVAS_ER_LIST_ORIGIN_X; + pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->y = IVAS_ER_LIST_ORIGIN_Y; + pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->z = IVAS_ER_LIST_HEIGHT; } pAcEnv->ListenerOrigin = *pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin; for ( j = 0; j < IVAS_ROOM_ABS_COEFF; j++ ) @@ -3001,7 +3048,7 @@ ivas_error RenderConfigReader_getDirectivity( float *directivity /* o : Target directivity */ ) { - uint16_t n, m; + uint16_t i, n, m; uint16_t last_specified_id; bool idExists; @@ -3011,7 +3058,7 @@ ivas_error RenderConfigReader_getDirectivity( } if ( pRenderConfigReader->pDP == NULL ) { - for ( n = 0; n < MAX_NUM_OBJECTS; n++ ) + for ( n = 0; n < IVAS_MAX_NUM_OBJECTS; n++ ) { directivity[n * 3] = 360.0f; directivity[n * 3 + 1] = 360.0f; @@ -3023,7 +3070,7 @@ ivas_error RenderConfigReader_getDirectivity( last_specified_id = id[0]; /* set unpspecified Directivity Patterns ID to last specified ID */ - for ( n = MAX_NUM_OBJECTS - 1; n > 0; n-- ) + for ( n = IVAS_MAX_NUM_OBJECTS - 1; n > 0; n-- ) { if ( id[n] != 65535 ) { @@ -3037,13 +3084,12 @@ ivas_error RenderConfigReader_getDirectivity( last_specified_id = (uint16_t) pRenderConfigReader->pDP[0].id; } - for ( ; n < MAX_NUM_OBJECTS; n++ ) + for ( ; n < IVAS_MAX_NUM_OBJECTS; n++ ) { id[n] = last_specified_id; } - - for ( n = 0; n < MAX_NUM_OBJECTS; n++ ) + for ( n = 0; n < IVAS_MAX_NUM_OBJECTS; n++ ) { idExists = false; for ( m = 0; m < pRenderConfigReader->nDP; m++ ) @@ -3051,7 +3097,11 @@ ivas_error RenderConfigReader_getDirectivity( if ( id[n] == pRenderConfigReader->pDP[m].id ) { idExists = true; - mvr2r( pRenderConfigReader->pDP[m].pDirectivity, directivity + ( n * 3 ), 3 ); + for ( i = 0; i < 3; i++ ) + { + directivity[n * 3 + i] = pRenderConfigReader->pDP[m].pDirectivity[i]; + } + break; } } @@ -3061,9 +3111,11 @@ ivas_error RenderConfigReader_getDirectivity( } } } + return IVAS_ERR_OK; } + /*------------------------------------------------------------------------------------------* * RenderConfigReader_getDistanceAttenuation() * diff --git a/lib_util/rotation_file_reader.c b/lib_util/rotation_file_reader.c index b948a5152..f659fbb9f 100644 --- a/lib_util/rotation_file_reader.c +++ b/lib_util/rotation_file_reader.c @@ -33,8 +33,7 @@ #include "rotation_file_reader.h" #include #include -#include -#include "prot.h" +#include struct RotFileReader diff --git a/lib_util/split_rend_bfi_file_reader.c b/lib_util/split_rend_bfi_file_reader.c index 1573db5a9..f82308edf 100644 --- a/lib_util/split_rend_bfi_file_reader.c +++ b/lib_util/split_rend_bfi_file_reader.c @@ -30,10 +30,11 @@ *******************************************************************************************************/ -#include #include "split_rend_bfi_file_reader.h" #include -#include "prot.h" +#include +#include + struct SplitRendBFIFileReader { diff --git a/lib_util/split_render_file_read_write.c b/lib_util/split_render_file_read_write.c index 4a72bc4d3..17070a630 100644 --- a/lib_util/split_render_file_read_write.c +++ b/lib_util/split_render_file_read_write.c @@ -30,10 +30,10 @@ *******************************************************************************************************/ -#include #include "split_render_file_read_write.h" +#include "ivas_error_utils.h" #include -#include "prot.h" +#include /*------------------------------------------------------------------------------------------* diff --git a/lib_util/tsm_scale_file_reader.c b/lib_util/tsm_scale_file_reader.c index e61f80763..653fc0f2f 100644 --- a/lib_util/tsm_scale_file_reader.c +++ b/lib_util/tsm_scale_file_reader.c @@ -32,10 +32,10 @@ #include "tsm_scale_file_reader.h" #include "cmdl_tools.h" -#include #include #include + #ifdef DEBUGGING #ifdef VARIABLE_SPEED_DECODING diff --git a/lib_util/vector3_pair_file_reader.c b/lib_util/vector3_pair_file_reader.c index a6aee3eef..8a46a97d1 100644 --- a/lib_util/vector3_pair_file_reader.c +++ b/lib_util/vector3_pair_file_reader.c @@ -31,12 +31,8 @@ *******************************************************************************************************/ #include "vector3_pair_file_reader.h" -#include #include #include -#include -#include "prot.h" -#include "options.h" /* only included to get access to the feature-defines */ struct Vector3PairFileReader diff --git a/readme.txt b/readme.txt index 6623e52da..91a118c21 100644 --- a/readme.txt +++ b/readme.txt @@ -397,7 +397,7 @@ Where the first two rows are comma separated azimuth and elevation positions of The output channel ordering is 0, 1, ... N-1. The third row contains an index "LFE0" (zero based) specifying the output channel to which the LFE input will be routed if present. If the third row is omitted, the LFE input is downmixed to all channels with a factor of 1/N. Position is not considered for -the LFE channel. +the LFE channel. Maximum number of supported loudskpeakers N is 16. An example custom loudspeaker layout file is available: ls_setup_16ch_8+4+4.txt -- GitLab From 94d96d4541023dbeaac7cda66753d04f2520c7cb Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 17 Oct 2025 11:37:44 +0200 Subject: [PATCH 2/3] fix --- apps/encoder.c | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) diff --git a/apps/encoder.c b/apps/encoder.c index bd7f4f804..7e5154226 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -903,54 +903,6 @@ cleanup: * Local functions *-------------------------------------------------------------------*/ -#define IVAS_DEFAULT_AGC ( 0 ) - -static void initArgStruct( EncArguments *arg ) -{ - /* Set default values here */ - arg->inputWavFilename = NULL; - arg->outputBitstreamFilename = NULL; - arg->inputFs = 0; - arg->inputFormat = IVAS_ENC_INPUT_MONO; - arg->is_binaural = false; - arg->inputFormatConfig.stereoToMonoDownmix = false; - arg->max_bwidth_user = false; - arg->maxBandwidth = IVAS_ENC_BANDWIDTH_UNDEFINED; - arg->bandwithProfileFile = NULL; - arg->dtxConfig = IVAS_ENC_GetDefaultDtxConfig(); - arg->initBitrate = 0; - arg->bitrateProfileFile = NULL; - arg->quietModeEnabled = false; - arg->delayCompensationEnabled = true; - arg->masaMetadataFile = NULL; - arg->caConfig = IVAS_ENC_GetDefaultChannelAwareConfig(); - arg->ca_config_file = NULL; - arg->mimeOutput = false; - arg->ism_extended_metadata = false; - arg->complexityLevel = IVAS_ENC_COMPLEXITY_LEVEL_THREE; - -#ifdef DEBUGGING - arg->forcedMode = IVAS_ENC_FORCE_UNFORCED; - arg->forcedModeFile = NULL; -#ifdef DEBUG_FORCE_DIR - arg->forcedModeDir = NULL; -#endif -#ifdef DEBUG_AGC_ENCODER_CMD_OPTION - arg->agc = IVAS_ENC_AGC_UNDEFINED; -#endif -#ifdef DEBUG_FOA_AGC - arg->agcBitstream = NULL; -#endif -#ifdef DEBUG_SBA - arg->dbg_file_tag = NULL; -#endif -#endif - arg->pca = false; - - return; -} - - /*---------------------------------------------------------------------* * parseCmdlIVAS_enc() * -- GitLab From cd8a89e91b5560166a0aedc4884c0c8cea9c6d13 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 17 Oct 2025 13:49:53 +0200 Subject: [PATCH 3/3] fix --- lib_isar/lib_isar_post_rend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index b31d698ab..711be967d 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -1053,7 +1053,7 @@ ivas_error ISAR_POST_REND_FeedInputAudio( if ( isar_getAudioConfigType( hIvasRend->outputConfig ) == ISAR_POST_REND_AUDIO_CONFIG_TYPE_BINAURAL && hIvasRend->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && hIvasRend->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && - ( inputAudio.config.numSamplesPerChannel * 1000 / cldfb2tdSampleFact ) != ( L_FRAME_MAX * hIvasRend->num_subframes ) * hIvasRend->sampleRateOut ) + ( inputAudio.config.numSamplesPerChannel * 1000 / cldfb2tdSampleFact ) != ( BINAURAL_RENDERING_FRAME_SIZE_MS * hIvasRend->num_subframes ) * hIvasRend->sampleRateOut ) { return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Binaural rendering requires specific frame size" ); } -- GitLab