diff --git a/apps/decoder.c b/apps/decoder.c index b0b65f519e8282b69fb9afcb298ac90c332340c6..dca59ef8f9d2732d9ae8f35e59e6b387bd0f91fd 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -64,19 +64,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 ) - -#define JBM_FRONTEND_FETCH_FRAMESIZE_MS 20 -#define HEADROTATION_FETCH_FRAMESIZE_MS 5 -#define DEFAULT_FETCH_FRAMESIZE_MS 20 +#ifdef DEBUGGING +#define MIN_NUM_BITS_ACTIVE_FRAME 56 +#define NUM_BITS_SID_IVAS_5K2 104 +#endif /*------------------------------------------------------------------------------------------* @@ -122,7 +113,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; Word16 non_diegetic_pan_gain_fx; /* Q15 */ @@ -164,7 +155,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 ); @@ -324,7 +315,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; @@ -351,7 +342,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; @@ -627,7 +618,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 { @@ -813,7 +804,11 @@ static bool parseCmdlIVAS_dec( int16_t i; char argv_to_upper[FILENAME_MAX]; - arg->output_Fs = 48000; + /*-----------------------------------------------------------------* + * Set default values + *-----------------------------------------------------------------*/ + + arg->output_Fs = IVAS_MAX_SAMPLING_RATE; arg->outputConfig = IVAS_AUDIO_CONFIG_MONO; arg->decMode = IVAS_DEC_MODE_IVAS; arg->quietModeEnabled = false; @@ -823,7 +818,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; @@ -1034,23 +1029,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 { @@ -2586,14 +2581,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]; @@ -2607,7 +2603,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 d0ad408f2f8a77c83875e217e1f7ca71d439c9d4..2a8ef469f6161aea9111c1ff0f7d3d02eec51214 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -163,7 +163,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 ); @@ -208,8 +207,6 @@ int main( reset_mem( USE_BYTES ); #endif - initArgStruct( &arg ); - /*------------------------------------------------------------------------------------------* * Parse command-line arguments *------------------------------------------------------------------------------------------*/ @@ -853,11 +850,26 @@ cleanup: * Local functions *-------------------------------------------------------------------*/ -#define IVAS_DEFAULT_AGC ( 0 ) +/*---------------------------------------------------------------------* + * parseCmdlIVAS_enc() + * + * Encoder command-line parsing + *---------------------------------------------------------------------*/ -static void initArgStruct( EncArguments *arg ) +static bool parseCmdlIVAS_enc( + int16_t argc, + char *argv[], + EncArguments *arg ) { - /* Set default values here */ + int16_t i, j; + char argv_to_upper[FILENAME_MAX]; + char stmp[FILENAME_MAX]; + int32_t tmp; + + /*-----------------------------------------------------------------* + * Set default values + *-----------------------------------------------------------------*/ + arg->inputWavFilename = NULL; arg->outputBitstreamFilename = NULL; arg->inputFs = 0; @@ -887,25 +899,9 @@ static void initArgStruct( EncArguments *arg ) #endif arg->pca = false; - return; -} - - -/*---------------------------------------------------------------------* - * parseCmdlIVAS_enc() - * - * Encoder command-line parsing - *---------------------------------------------------------------------*/ - -static bool parseCmdlIVAS_enc( - int16_t argc, - char *argv[], - EncArguments *arg ) -{ - int16_t i, j; - char argv_to_upper[FILENAME_MAX]; - char stmp[FILENAME_MAX]; - int32_t tmp; + /*-----------------------------------------------------------------* + * Initialization + *-----------------------------------------------------------------*/ if ( argc < 5 ) { diff --git a/apps/isar_post_rend.c b/apps/isar_post_rend.c index 8182bfdd3d16d9baab4c8cfce8ff32fc9a71c3af..53417cf1504d72631ac8ca3ef4848084ac538411 100644 --- a/apps/isar_post_rend.c +++ b/apps/isar_post_rend.c @@ -952,7 +952,7 @@ int main( memset( outBuffer.data_fx, 0, outBuffer.config.numSamplesPerChannel * outBuffer.config.numChannels * sizeof( Word32 ) ); - 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 adf664f97d7fe88cbfcf087f98d6106becc71ff2..920700fd06ccb5bae0e3827610b756e74d61ceb8 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -174,7 +174,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; @@ -1601,7 +1601,7 @@ int main( if ( is_split_pre_rend_mode( &args ) ) { - bitsBufferSize = SPLIT_REND_BITS_BUFF_SIZE; + bitsBufferSize = ISAR_SPLIT_REND_BITS_BUFF_SIZE; } else { @@ -2431,7 +2431,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 8ef02aeed50d3694dd2967ace1af31f503084dcd..6638e6124f955ad26cb19dd9cbdfd745da802b3d 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -46,24 +46,28 @@ * 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 +#define IVAS_ER_LIST_HEIGHT_FX 6710886 /* 1.6f in Q.22 */ -/* 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 @@ -195,7 +199,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; @@ -246,7 +250,7 @@ typedef enum _ivas_binaural_renderer_type #define ISAR_MAX_SPLIT_REND_BITRATE 768000 #define ISAR_MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES ( ( ( (Word32) 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 { @@ -311,6 +315,7 @@ typedef struct _ISAR_SPLIT_REND_CONFIG } ISAR_SPLIT_REND_CONFIG_DATA, *ISAR_SPLIT_REND_CONFIG_HANDLE; + /*----------------------------------------------------------------------------------* * Renderer API structures and enums *----------------------------------------------------------------------------------*/ @@ -355,6 +360,7 @@ typedef struct _IVAS_RENDER_CONFIG Word16 directivity_fx[IVAS_MAX_NUM_OBJECTS * 3]; // has the following q-factor pattern: {6, 6, 15, 6, 6, 15, 6, 6, 15, 6, 6, 15} float distAtt[3]; Word32 distAtt_fx[3]; /* {Q27, Q30, Q30} */ + } IVAS_RENDER_CONFIG_DATA, *IVAS_RENDER_CONFIG_HANDLE; typedef struct @@ -371,7 +377,6 @@ typedef struct Word16 q_factor; Word16 *pq_fact; Word32 *data_fx; - // Word16 Q_data; } IVAS_REND_AudioBuffer; diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 4e5f8871cfed61375177e1647afc3c7444647d92..61ed7ecf61d816bc9933771bba53cbe81789a821 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -151,7 +151,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 */ @@ -1540,7 +1540,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_WORD32 2022552831 /* Gain applied to LFE during renderering, 1.88364911f in Q30 */ #define GAIN_LFE_FX 30862 /* Gain applied to LFE during renderering, 1.88364911f in Q14 */ #define LOW_BIT_RATE_BINAURAL_EQ_BINS 17 /* Number of bins in an EQ applied at low bit rates in binauralization */ @@ -1778,13 +1777,8 @@ typedef enum * Early Reflection constants *----------------------------------------------------------------------------------*/ -#define ER_LIST_ORIGIN_X 0.0f -#define ER_LIST_ORIGIN_Y 0.0f -#define ER_LIST_HEIGHT 1.6f #define ER_RADIUS_FX (1* ONE_IN_Q30) /*Q2.30 */ -#define ER_LIST_ORIGIN_X_FX 0 -#define ER_LIST_ORIGIN_Y_FX 0 -#define ER_LIST_HEIGHT_FX 6710886 /* 1.6f in Q.22 */ +#define ER_LIST_HEIGHT_FX IVAS_ER_LIST_HEIGHT_FX /*----------------------------------------------------------------------------------* diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index c50e99711624758634d8b9079aa60536f85a3db6..7b5c9fd104ab5458a2676b909691b5a492bff1ac 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -577,7 +577,6 @@ typedef struct UWord8 nBits; } Coding; - /* Scale TCX setup */ typedef struct { @@ -590,7 +589,6 @@ typedef struct } SCALE_TCX_SETUP; - typedef struct { UWord16 frame_bits; /*Bits per frame*/ @@ -604,7 +602,7 @@ typedef struct } FrameSizeParams; -typedef struct cldfb_filter_bank_struct +typedef struct ivas_cldfb_filter_bank_struct { Word16 no_channels; Word16 no_col; @@ -648,7 +646,6 @@ typedef struct cldfb_filter_bank_struct Word16 outScalefactor; /*!< Scale factor of output data (syn only) Q0*/ Word16 synFilterHeadroom; /*!< Headroom for states in synthesis cldfb filterbank Q0*/ - /* memory helper states */ Word16 *memory; // Qx Word32 *memory32; // Q_cldfb_state /*because cldfb_state_fx is word32 which is used to assign values*/ @@ -669,7 +666,6 @@ typedef struct cldfb_filter_bank_struct } CLDFB_FILTER_BANK, *HANDLE_CLDFB_FILTER_BANK; - typedef enum { FRAME_0 = 0, @@ -691,6 +687,7 @@ typedef enum } FRAME_SIZE; + /*---------------------------------------------------------------* * IGF * *---------------------------------------------------------------*/ @@ -742,7 +739,6 @@ typedef struct IGF_INFO_struct Word16 bitRateIndex; } IGF_INFO, *H_IGF_INFO; - typedef struct { Word16 *indexBuffer; diff --git a/lib_dec/jbm_pcmdsp_apa.h b/lib_dec/jbm_pcmdsp_apa.h index 8daf3fc11c2f27e8c638ff4c68c721458c0338b5..70e31eb75e64612743ea50e72108d69c5cf92309 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_fx.c b/lib_dec/lib_dec_fx.c index 4083e07499f9bfbab5af6f26d38040377602b6c9..b60d640e0692998587b301645c666f73eb18d1c1 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -2262,7 +2262,7 @@ ivas_error IVAS_DEC_GetFormat( /*---------------------------------------------------------------------* - * getInputBufferSize() + * getOutputBufferSize() * * Get size of output buffer in samples *---------------------------------------------------------------------*/ diff --git a/lib_isar/isar_cnst.h b/lib_isar/isar_cnst.h index 9e8793130d395b65f0a5e54829995d79f426a9e3..40d6c393857ee28145728999a52dfded680ec8db 100644 --- a/lib_isar/isar_cnst.h +++ b/lib_isar/isar_cnst.h @@ -139,7 +139,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 38371d1343b81d0c4c484f9d29f3f78f00cdff85..279daee41d351702c6c9aee5a65d8858deea9651 100644 --- a/lib_isar/isar_lc3plus_dec.c +++ b/lib_isar/isar_lc3plus_dec.c @@ -67,9 +67,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 9cfc24e5ace2249bd5dc97757eedd7f3bd58b460..351cb4525e3d9f46914c5456e29a444e21c2480c 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 baec692cef9cb2dd109748f47b61e9680b6f5e57..8178663ce2c087d88d568880e5f4c7bf01f8355e 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -1039,8 +1039,12 @@ ivas_error ISAR_POST_REND_FeedInputAudio( cldfb2tdSampleFact = ( inputAudio.config.is_cldfb ) ? 2 : 1; - IF( LE_16( inputAudio.config.numSamplesPerChannel, 0 ) || ( LT_16( MAX_BUFFER_LENGTH_PER_CHANNEL, inputAudio.config.numSamplesPerChannel ) && EQ_16( inputAudio.config.is_cldfb, 0 ) ) || - ( LT_16( DEPR_i_mult( MAX_BUFFER_LENGTH_PER_CHANNEL, cldfb2tdSampleFact ), inputAudio.config.numSamplesPerChannel ) && EQ_16( inputAudio.config.is_cldfb, 1 ) ) ) + test(); + test(); + test(); + test(); + IF( LE_16( inputAudio.config.numSamplesPerChannel, 0 ) || ( LT_16( L_FRAME_MAX, inputAudio.config.numSamplesPerChannel ) && EQ_16( inputAudio.config.is_cldfb, 0 ) ) || + ( LT_16( DEPR_i_mult( L_FRAME_MAX, cldfb2tdSampleFact ), inputAudio.config.numSamplesPerChannel ) && EQ_16( inputAudio.config.is_cldfb, 1 ) ) ) { return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Buffer size outside of supported range" ); } @@ -1699,8 +1703,12 @@ 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 ) ) + test(); + test(); + test(); + test(); + 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_fx.c b/lib_rend/ivas_reverb_fx.c index 7fe1883ed444d661a59a83b28f324c6789a10f7a..6ab0c7a6355243b49f77be91ab4511707aec6c93 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -190,9 +190,9 @@ static void ivas_binaural_reverb_setPreDelay_fx( return; } - IF( GT_16( delaySamples, REVERB_PREDELAY_MAX ) ) + IF( GT_16( delaySamples, IVAS_REVERB_PREDELAY_MAX ) ) { - hReverb->preDelayBufferLength = REVERB_PREDELAY_MAX; + hReverb->preDelayBufferLength = IVAS_REVERB_PREDELAY_MAX; move16(); return; @@ -2348,7 +2348,7 @@ static ivas_error ivas_binaural_reverb_open_fx( hReverb->blockSize = numCldfbSlotsPerFrame; move16(); - FOR( k = 0; k < REVERB_PREDELAY_MAX + 1; k++ ) + FOR( k = 0; k < IVAS_REVERB_PREDELAY_MAX + 1; k++ ) { set32_fx( hReverb->preDelayBufferReal_fx[k], 0, hReverb->numBins ); set32_fx( hReverb->preDelayBufferImag_fx[k], 0, hReverb->numBins ); diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index d527bb66385ba5a41e7d0aa03a4fd40c519a827b..6433da8195e7deba7874d9b3b325bf6cc9b350f2 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -153,10 +153,10 @@ static void ivas_reverb_set_energies( { Word16 freq_idx; Word32 input_fc_fx[FFT_SPECTRUM_SIZE]; - Word32 output_fc_fx[CLDFB_NO_CHANNELS_MAX]; - Word32 avg_pwr_left_fx[CLDFB_NO_CHANNELS_MAX]; // Q28 - Word32 avg_pwr_right_fx[CLDFB_NO_CHANNELS_MAX]; // Q28 - const Word32 cldfb_band_width = 26214400; // 400 in Q16 + Word32 output_fc_fx[IVAS_CLDFB_NO_CHANNELS_MAX]; + Word32 avg_pwr_left_fx[IVAS_CLDFB_NO_CHANNELS_MAX]; // Q28 + Word32 avg_pwr_right_fx[IVAS_CLDFB_NO_CHANNELS_MAX]; // Q28 + const Word32 cldfb_band_width = 26214400; // 400 in Q16 Word16 s; Word16 temp; @@ -168,17 +168,17 @@ static void ivas_reverb_set_energies( input_fc_fx[freq_idx] = L_shl( L_mult( temp, freq_idx ), add( 15, s ) ); } - 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_fx[freq_idx] = L_add( L_shr( cldfb_band_width, 1 ), L_shl( Mult_32_16( cldfb_band_width, freq_idx ), 15 ) ); } // Avg Energy Left - ivas_reverb_interp_on_freq_grid_fx( avg_pwr_len, input_fc_fx, avg_pwr_l, CLDFB_NO_CHANNELS_MAX, output_fc_fx, avg_pwr_left_fx ); + ivas_reverb_interp_on_freq_grid_fx( avg_pwr_len, input_fc_fx, avg_pwr_l, IVAS_CLDFB_NO_CHANNELS_MAX, output_fc_fx, avg_pwr_left_fx ); // Avg Energy Right - ivas_reverb_interp_on_freq_grid_fx( avg_pwr_len, input_fc_fx, avg_pwr_r, CLDFB_NO_CHANNELS_MAX, output_fc_fx, avg_pwr_right_fx ); + ivas_reverb_interp_on_freq_grid_fx( avg_pwr_len, input_fc_fx, avg_pwr_r, IVAS_CLDFB_NO_CHANNELS_MAX, output_fc_fx, avg_pwr_right_fx ); - 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++ ) { avg_pwr_left[freq_idx] = avg_pwr_left_fx[freq_idx]; avg_pwr_right[freq_idx] = avg_pwr_right_fx[freq_idx]; diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 221c56950dd4c59553b1ab8a1ef2a030459605f1..aec8eb3b9b4cffaf491605d5c2680a71970515dc 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -536,8 +536,8 @@ typedef struct ivas_binaural_reverb_struct { Word32 *loopBufReal_fx[CLDFB_NO_CHANNELS_MAX]; Word32 *loopBufImag_fx[CLDFB_NO_CHANNELS_MAX]; - Word32 preDelayBufferReal_fx[REVERB_PREDELAY_MAX + 1][CLDFB_NO_CHANNELS_MAX]; - Word32 preDelayBufferImag_fx[REVERB_PREDELAY_MAX + 1][CLDFB_NO_CHANNELS_MAX]; + Word32 preDelayBufferReal_fx[IVAS_REVERB_PREDELAY_MAX + 1][CLDFB_NO_CHANNELS_MAX]; + Word32 preDelayBufferImag_fx[IVAS_REVERB_PREDELAY_MAX + 1][CLDFB_NO_CHANNELS_MAX]; Word32 **tapPointersReal_fx[CLDFB_NO_CHANNELS_MAX][BINAURAL_CHANNELS]; Word32 **tapPointersImag_fx[CLDFB_NO_CHANNELS_MAX][BINAURAL_CHANNELS]; diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index c47d35a332042c45e0cfe901d72cf689d7a60ac6..188919568bdccf440ad2a778e164416d447a0f2a 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -42,12 +42,15 @@ * 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_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 6bb64cb3c37597556af84a86e2cafbdc03210750..42ac97bd59d20df1f7ff95fae143928fd795852f 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -55,7 +55,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 */ /*-------------------------------------------------------------------* @@ -4575,8 +4575,12 @@ ivas_error IVAS_REND_FeedInputAudio_fx( test(); cldfb2tdShift = ( inputAudio.config.is_cldfb ) ? 1 : 0; - IF( inputAudio.config.numSamplesPerChannel <= 0 || ( MAX_BUFFER_LENGTH_PER_CHANNEL < inputAudio.config.numSamplesPerChannel && inputAudio.config.is_cldfb == 0 ) || - ( ( shl( MAX_BUFFER_LENGTH_PER_CHANNEL, cldfb2tdShift ) ) < inputAudio.config.numSamplesPerChannel && inputAudio.config.is_cldfb == 1 ) ) + test(); + test(); + test(); + test(); + IF( inputAudio.config.numSamplesPerChannel <= 0 || ( L_FRAME_MAX < inputAudio.config.numSamplesPerChannel && inputAudio.config.is_cldfb == 0 ) || + ( ( shl( L_FRAME_MAX, cldfb2tdShift ) ) < inputAudio.config.numSamplesPerChannel && inputAudio.config.is_cldfb == 1 ) ) { return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Buffer size outside of supported range" ); } @@ -6694,7 +6698,7 @@ static ivas_error renderLfeToBinaural_fx( Word16 pose_idx, num_poses; Word32 gain_fx; Word16 ear_idx, i, r_shift; - Word32 tmpLfeBuffer[MAX_BUFFER_LENGTH_PER_CHANNEL]; + Word32 tmpLfeBuffer[L_FRAME_MAX]; Word16 frame_size, num_cpy_smpl_cur_frame, num_cpy_smpl_prev_frame; const Word32 *lfeInput; Word32 *writePtr; @@ -8726,8 +8730,12 @@ static ivas_error getSamplesInternal( test(); cldfb2tdSampleShift = ( outAudio.config.is_cldfb ) ? 1 : 0; - IF( outAudio.config.numSamplesPerChannel <= 0 || ( MAX_BUFFER_LENGTH_PER_CHANNEL < outAudio.config.numSamplesPerChannel && outAudio.config.is_cldfb == 0 ) || - ( ( shl( MAX_BUFFER_LENGTH_PER_CHANNEL, cldfb2tdSampleShift ) ) < outAudio.config.numSamplesPerChannel && outAudio.config.is_cldfb == 1 ) ) + test(); + test(); + test(); + test(); + IF( outAudio.config.numSamplesPerChannel <= 0 || ( L_FRAME_MAX < outAudio.config.numSamplesPerChannel && outAudio.config.is_cldfb == 0 ) || + ( ( shl( L_FRAME_MAX, cldfb2tdSampleShift ) ) < outAudio.config.numSamplesPerChannel && outAudio.config.is_cldfb == 1 ) ) { return IVAS_ERR_INVALID_BUFFER_SIZE; } diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index 430d7ade2226e88142a50c59e5a14a47d9c97ce3..6b506e7edaeaaa4b559701d065c904e2e48d42a4 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -34,7 +34,7 @@ #include #include "stl.h" #include "ambi_convert.h" -#include "wmc_auto.h" + #define ONE_1_Q29 536870912l /* 1.0f */ #define ONE_OVER_2_Q29 268435456l /* 1.0f/2.0f */ diff --git a/lib_util/audio_file_reader.c b/lib_util/audio_file_reader.c index ca5e6e4963b676da58526fbb30a3cf07d9f34f77..fe5669fa562052c86617471a0254e7df9a8ad65b 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 fb7a64c425b6f648667a969290b6086c11158887..321063101959dc6ecab0a60103f1f2de3246a52e 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/bitstream_reader.c b/lib_util/bitstream_reader.c index 2bd6f46aa6014e8e37f1c77bd051d49eabb47da4..509335d1feccc0177bf8b2ad54dbf6106939ff42 100644 --- a/lib_util/bitstream_reader.c +++ b/lib_util/bitstream_reader.c @@ -33,7 +33,6 @@ #include "bitstream_reader.h" #include "g192.h" #include "mime_io.h" -#include "ivas_error.h" #include "ivas_error_utils.h" #include #include diff --git a/lib_util/ls_custom_file_reader.c b/lib_util/ls_custom_file_reader.c index f4f43e496e358d9dae0ca00a8478fe342a3fc121..5f056250bf966884a81e777c3b6ce8d4a536acda 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_fx.h" -#include "prot_fx.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,12 @@ 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 +242,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 a658b043268b59f993abad31fb4f27818cc9f4b6..55816d621948b2767da03f2d4100e4f7f34da910 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -59,9 +59,9 @@ #define ACOUSTIC_DSR_EPSILON ( 1.0e-15f ) #define ACOUSTIC_DSR_EPSILON_FX ( 1 ) #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 ) @@ -74,6 +74,27 @@ #define ER_MAX_ABS_COEFF ( 1.0f ) #define ER_MAX_ABS_COEFF_FX ( 1073741824 ) +#define IVAS_ER_LIST_ORIGIN_X 0.0f +#define IVAS_ER_LIST_ORIGIN_Y 0.0f +#define IVAS_ER_LIST_ORIGIN_X_FX 0 +#define IVAS_ER_LIST_ORIGIN_Y_FX 0 + +#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 *------------------------------------------------------------------------------------------*/ @@ -414,10 +435,12 @@ const float defaultFrequencyGrid_8[] = { 5800.0f, 7000.0f, 8500.0f, 10500.0f, 13500.0f }; + /*-----------------------------------------------------------------------------------------* * Function read_bin_bits() * Reads a given number of bits from the bitstream *-----------------------------------------------------------------------------------------*/ + static ivas_error read_bin_bits( RenderConfigReader *this, /* i/o : Renderer config reader handle */ uint32_t *pTarget, /* o : Target read data pointer */ @@ -451,10 +474,12 @@ static ivas_error read_bin_bits( return IVAS_ERR_OK; } + /*-----------------------------------------------------------------------------------------* * Function read_bin_bool() * Reads a boolean value from a bitstream *-----------------------------------------------------------------------------------------*/ + static ivas_error read_bin_bool( RenderConfigReader *this, /* i/o : Renderer config reader handle */ uint32_t *pResult /* o : Target read data pointer */ @@ -463,10 +488,12 @@ static ivas_error read_bin_bool( return read_bin_bits( this, pResult, 1 ); } + /*-----------------------------------------------------------------------------------------* * Function get_bin_id() * Reads an ID from a bitstream *-----------------------------------------------------------------------------------------*/ + static ivas_error get_bin_id( RenderConfigReader *this, /* i/o : Renderer config reader handle */ uint32_t *pResult /* o : Target read data pointer */ @@ -502,10 +529,12 @@ static ivas_error get_bin_id( return IVAS_ERR_OK; } + /*-----------------------------------------------------------------------------------------* * Function read_bin_code_word() * Reads a code word from a LUT *-----------------------------------------------------------------------------------------*/ + static ivas_error read_bin_code_word( RenderConfigReader *this, /* i/o : Renderer config reader handle */ const RC_LUT table, /* i : Table enum */ @@ -658,6 +687,7 @@ static ivas_error read_bin_code_word( * 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 */ @@ -695,10 +725,12 @@ static ivas_error get_bin_count_or_index( return IVAS_ERR_OK; } + /*-----------------------------------------------------------------------------------------* * Function get_bin_duration() * Gets a duration value *-----------------------------------------------------------------------------------------*/ + static ivas_error get_bin_duration( RenderConfigReader *this, /* i/o : Renderer config reader handle */ float *pResult /* o : Duration value */ @@ -766,10 +798,12 @@ static ivas_error get_bin_duration( return IVAS_ERR_OK; } + /*-----------------------------------------------------------------------------------------* * Function get_bin_frequency() * Gets a frequency value *-----------------------------------------------------------------------------------------*/ + static ivas_error get_bin_frequency( RenderConfigReader *this, /* i/o : Renderer config reader handle */ float *pResult /* o : Frequency value */ @@ -804,10 +838,12 @@ static ivas_error get_bin_frequency( return IVAS_ERR_OK; } + /*-----------------------------------------------------------------------------------------* * Function get_bin_dsr() * Gets a DSR value *-----------------------------------------------------------------------------------------*/ + static ivas_error get_bin_dsr( RenderConfigReader *this, /* i/o : Renderer config reader handle */ float *pResult /* o : DSR value */ @@ -904,6 +940,7 @@ static ivas_error get_bin_distance( return IVAS_ERR_OK; } + /*-----------------------------------------------------------------------------------------* * Function get_bin_absorption() * Gets an absorption value @@ -924,10 +961,12 @@ static ivas_error get_bin_absorption( return IVAS_ERR_OK; } + /*-----------------------------------------------------------------------------------------* * Function read_txt_bool() * Reads a boolean value from a line *-----------------------------------------------------------------------------------------*/ + static ivas_error read_txt_bool( const char *pLine, /* i : String to read from */ uint32_t *pTarget /* o : Output pointer */ @@ -950,8 +989,31 @@ static ivas_error read_txt_bool( *pTarget = FALSE; return IVAS_ERR_OK; } + 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_angle() * Gets an angle value in degrees [0,360] @@ -970,11 +1032,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] @@ -994,7 +1057,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; @@ -1002,6 +1065,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] @@ -1020,11 +1084,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] @@ -1043,11 +1108,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] @@ -1066,7 +1132,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; } @@ -1125,6 +1191,7 @@ static int16_t read_txt_vector( return false; } + /*-----------------------------------------------------------------------------------------* * Function strip_spaces() * @@ -1776,9 +1843,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 */ @@ -2829,13 +2896,13 @@ 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; - pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->x_fx = ER_LIST_ORIGIN_X_FX; - pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->y_fx = ER_LIST_ORIGIN_Y_FX; - pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->z_fx = ER_LIST_HEIGHT_FX; + pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->x_fx = IVAS_ER_LIST_ORIGIN_X_FX; + pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->y_fx = IVAS_ER_LIST_ORIGIN_Y_FX; + pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->z_fx = IVAS_ER_LIST_HEIGHT_FX; pRenderConfigReader->pAE[n].pEarlyReflections->pListenerOrigin->q_fact = Q22; } else @@ -2873,7 +2940,7 @@ ivas_error RenderConfigReader_getDirectivity( Word16 *directivity_fx /* o : Target directivity */ ) { - uint16_t n, m; + uint16_t n, m, i; uint16_t last_specified_id; bool idExists; float directivity[12]; @@ -2911,13 +2978,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++ ) @@ -2925,7 +2991,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; } } @@ -2947,6 +3017,7 @@ ivas_error RenderConfigReader_getDirectivity( return IVAS_ERR_OK; } + /*------------------------------------------------------------------------------------------* * RenderConfigReader_getDistanceAttenuation() * diff --git a/lib_util/split_rend_bfi_file_reader.c b/lib_util/split_rend_bfi_file_reader.c index 1ac4f4979522886824c9a104debbfd736e5520fa..f82308edfd8cd72f541091a1f91b3c1235f81773 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_fx.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 9083d42177a7c43c8ac8bf242bc54cae95c3488c..871411616fc909f748b2a446971c2a6e28c97414 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_fx.h" +#include /*------------------------------------------------------------------------------------------* diff --git a/lib_util/vector3_pair_file_reader.c b/lib_util/vector3_pair_file_reader.c index 5745e95955616a19c7e95adf68d2dda74a908ff9..11b87a13f7b709392e7f1759f75e63e6f8edbd7d 100644 --- a/lib_util/vector3_pair_file_reader.c +++ b/lib_util/vector3_pair_file_reader.c @@ -31,13 +31,10 @@ *******************************************************************************************************/ #include "vector3_pair_file_reader.h" -#include #include #include -#include -#include "options.h" /* only included to get access to the feature-defines */ -#include "prot_fx.h" -#include "ivas_prot_fx.h" +#include "prot_fx.h" // needed for floatToFixed_32 +//#include "ivas_prot_fx.h" // needed for floatToFixed_32 struct Vector3PairFileReader diff --git a/readme.txt b/readme.txt index b195e99c74ef25dec17a92d0853b8e35d866ad29..175f541dc605db8e1b2b87cce3e588ed6971b2e9 100644 --- a/readme.txt +++ b/readme.txt @@ -398,7 +398,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