diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj
index 2bcf77f098e0ad1b668c58fc212c6274b41af6fe..d55896b03c15d1abb812a1272349ca3bc434a20a 100644
--- a/Workspace_msvc/lib_com.vcxproj
+++ b/Workspace_msvc/lib_com.vcxproj
@@ -268,6 +268,7 @@
+
diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters
index f9d7920ca2d85337fc08ed083b6d6eb2242def73..baa170036182d9c8edf122cf87895890bff4348a 100644
--- a/Workspace_msvc/lib_com.vcxproj.filters
+++ b/Workspace_msvc/lib_com.vcxproj.filters
@@ -463,6 +463,9 @@
common_ivas_c
+
+ common_ivas_c
+
diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj
index cb8c0cfa76f1ac0905ff530f211f108d4c1f6502..e1c0f9ead1e80039fb23607500d3580bece6215c 100644
--- a/Workspace_msvc/lib_dec.vcxproj
+++ b/Workspace_msvc/lib_dec.vcxproj
@@ -264,6 +264,7 @@
+
@@ -271,7 +272,6 @@
-
@@ -284,6 +284,7 @@
+
@@ -292,6 +293,8 @@
+
+
@@ -301,6 +304,7 @@
+
@@ -319,7 +323,6 @@
-
diff --git a/Workspace_msvc/lib_dec.vcxproj.filters b/Workspace_msvc/lib_dec.vcxproj.filters
index e6661b742de5618067ea2dbf12518ccb06a1bd0e..d1dedc413cef958bb637b92972c2b95ef1656319 100644
--- a/Workspace_msvc/lib_dec.vcxproj.filters
+++ b/Workspace_msvc/lib_dec.vcxproj.filters
@@ -13,9 +13,6 @@
dec_ivas_c
-
- dec_ivas_c
-
dec_ivas_c
@@ -473,9 +470,6 @@
dec_ivas_c
-
- dec_ivas_c
-
dec_ivas_c
@@ -503,6 +497,21 @@
dec_ivas_c
+
+ dec_ivas_c
+
+
+ dec_ivas_c
+
+
+ dec_ivas_c
+
+
+ dec_ivas_c
+
+
+ dec_ivas_c
+
dec_ivas_c
diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj
index c3a12686948da841c8373af7cbda5f337af9c5e5..865652649a8a320ff0769bd83170528445da8ab3 100644
--- a/Workspace_msvc/lib_rend.vcxproj
+++ b/Workspace_msvc/lib_rend.vcxproj
@@ -197,15 +197,13 @@
+
+
-
-
-
-
@@ -229,7 +227,7 @@
-
+
diff --git a/apps/decoder.c b/apps/decoder.c
index 6193913e17ba56289cfb088c0e77465e164770f6..1d991b8ad34e243ba81967698f6a9f5df83245e2 100644
--- a/apps/decoder.c
+++ b/apps/decoder.c
@@ -50,6 +50,7 @@
#endif
#include "wmc_auto.h"
#include "render_config_reader.h"
+#include "hrtf_file_reader.h"
#define WMC_TOOL_SKIP
diff --git a/apps/renderer.c b/apps/renderer.c
index 47285b81a4370ecfd35b0b363220ed8a8dfdcbca..64f1659b9d937096d93b4597983bdee128786088 100644
--- a/apps/renderer.c
+++ b/apps/renderer.c
@@ -54,6 +54,10 @@
#include "wmc_auto.h"
+/*------------------------------------------------------------------------------------------*
+ * Local constants
+ *------------------------------------------------------------------------------------------*/
+
#define RENDERER_MAX_CLI_ARG_LENGTH ( FILENAME_MAX )
#define RENDERER_MAX_METADATA_LENGTH 8192
#define RENDERER_MAX_METADATA_LINE_LENGTH 1024
@@ -69,6 +73,11 @@ static
#define SEP_FOLDER '/'
#endif
+
+/*------------------------------------------------------------------------------------------*
+ * Local structures
+ *------------------------------------------------------------------------------------------*/
+
typedef struct
{
uint32_t frameCounter;
@@ -264,96 +273,48 @@ static const CmdLnParser_Option cliOptions[] = {
},
};
-static const int32_t numCliOptions = sizeof( cliOptions ) / sizeof( CmdLnParser_Option );
-
-static IVAS_REND_AudioConfig ambisonicsOrderToEnum(
- const int16_t order );
-static void parseSceneDescriptionFile(
- char *path,
- char *audioFilePath,
- InputConfig *inConfig,
- IsmPositionProvider *positionProvider,
- MasaFileReader **masaReaders );
+/*------------------------------------------------------------------------------------------*
+ * Local function prototypes
+ *------------------------------------------------------------------------------------------*/
-static ivas_error parseCustomLayoutFile(
- const char *filePath,
- IVAS_CUSTOM_LS_DATA *pLsSetupCustom );
+static const int32_t numCliOptions = sizeof( cliOptions ) / sizeof( CmdLnParser_Option );
-static CmdlnArgs parseCmdlnArgs(
- const int argc,
- char **argv );
+static IVAS_REND_AudioConfig ambisonicsOrderToEnum( const int16_t order );
-static IsmPositionProvider *IsmPositionProvider_open(
- void );
+static void parseSceneDescriptionFile( char *path, char *audioFilePath, InputConfig *inConfig, IsmPositionProvider *positionProvider, MasaFileReader **masaReaders );
-static void IsmPositionProvider_getNextFrame(
- IsmPositionProvider *positionProvider,
- ObjectPositionBuffer *objectMetadataBuffer );
+static ivas_error parseCustomLayoutFile( const char *filePath, IVAS_CUSTOM_LS_DATA *pLsSetupCustom );
-static void IsmPositionProvider_close(
- IsmPositionProvider *positionProvider );
+static CmdlnArgs parseCmdlnArgs( const int argc, char **argv );
-static void readFromShorthandMetadata(
- IsmPositionProvider *positionProvider,
- ObjectPositionBuffer *objectMetadataBuffer,
- const uint32_t objIdx );
-
-void getMetadataFromFileReader(
- IsmFileReader *ismReader,
- ObjectPositionBuffer *objectMetadataBuffer,
- const uint32_t objIdx );
+static IsmPositionProvider *IsmPositionProvider_open( void );
-static void splitConfigFile(
- const char *mdfFilePath,
- char *metadataString,
- uint32_t *metadataStringLength,
- char *wavFileName,
- uint32_t *wavFileNameLength );
+static void IsmPositionProvider_getNextFrame( IsmPositionProvider *positionProvider, ObjectPositionBuffer *objectMetadataBuffer );
-static char *readNextMetadataChunk(
- char *line,
- const char *delimiter );
+static void IsmPositionProvider_close( IsmPositionProvider *positionProvider );
-static void parseUint8(
- const char *line,
- uint8_t *ret );
+static void readFromShorthandMetadata( IsmPositionProvider *positionProvider, ObjectPositionBuffer *objectMetadataBuffer, const uint32_t objIdx );
-static void parseUint16(
- const char *line,
- uint16_t *ret );
+void getMetadataFromFileReader( IsmFileReader *ismReader, ObjectPositionBuffer *objectMetadataBuffer, const uint32_t objIdx );
-static int8_t parseUint32(
- const char *line,
- uint32_t *ret );
+static void splitConfigFile( const char *mdfFilePath, char *metadataString, uint32_t *metadataStringLength, char *wavFileName, uint32_t *wavFileNameLength );
-static int8_t parseInt32(
- const char *line,
- int32_t *ret );
+static char *readNextMetadataChunk( char *line, const char *delimiter );
-static void parseObjectPosition(
- char *line,
- IVAS_REND_AudioObjectPosition *position,
- uint16_t *positionDuration );
+static void parseUint8( const char *line, uint8_t *ret );
-static void parseMetadata(
- char *metadataString,
- char *inDir,
- InputConfig *inConfig,
- IsmPositionProvider *positionProvider,
- MasaFileReader **masaReaders );
+static void parseUint16( const char *line, uint16_t *ret );
-static ivas_error parseLfePanMtxFile(
- const char *lfeRoutingMatrixFilePath,
- IVAS_REND_LfePanMtx *lfePanMtx );
+static int8_t parseUint32( const char *line, uint32_t *ret );
-static void convert_backslash( char *str );
+static int8_t parseInt32( const char *line, int32_t *ret );
-static void remove_cr( char *str );
+static void parseObjectPosition( char *line, IVAS_REND_AudioObjectPosition *position, uint16_t *positionDuration );
-static void clearString( char *str );
+static void parseMetadata( char *metadataString, char *inDir, InputConfig *inConfig, IsmPositionProvider *positionProvider, MasaFileReader **masaReaders );
-static bool isEmptyString( const char *str );
+static ivas_error parseLfePanMtxFile( const char *lfeRoutingMatrixFilePath, IVAS_REND_LfePanMtx *lfePanMtx );
static void printSupportedAudioConfigs( void );
@@ -364,7 +325,14 @@ static void convertInputBuffer( const int16_t *intBuffer, const int16_t numIntSa
static void convertOutputBuffer( const float *floatBuffer, const int16_t numSamplesPerChannel, const int16_t numChannels, int16_t *intBuffer );
-static IVAS_REND_ReadOnlyAudioBuffer getReadOnlySubBuffer( IVAS_REND_AudioBuffer buffer, const int16_t chBeginIdx, const int16_t numChannels )
+/*------------------------------------------------------------------------------------------*
+ * Local functions
+ *------------------------------------------------------------------------------------------*/
+
+static IVAS_REND_ReadOnlyAudioBuffer getReadOnlySubBuffer(
+ IVAS_REND_AudioBuffer buffer,
+ const int16_t chBeginIdx,
+ const int16_t numChannels )
{
IVAS_REND_ReadOnlyAudioBuffer subBuffer;
@@ -375,6 +343,7 @@ static IVAS_REND_ReadOnlyAudioBuffer getReadOnlySubBuffer( IVAS_REND_AudioBuffer
return subBuffer;
}
+
static int16_t getTotalNumInChannels(
IVAS_REND_HANDLE hIvasRend,
IVAS_REND_InputId mcIds[RENDERER_MAX_MC_INPUTS],
@@ -454,6 +423,7 @@ static int16_t getTotalNumInChannels(
return totalNumInChannels;
}
+
static void setupWithSingleFormatInput(
CmdlnArgs args,
char *audioFilePath,
@@ -509,6 +479,7 @@ static void setupWithSingleFormatInput(
}
}
+
static float dBToLin(
const float gain_dB )
{
@@ -516,7 +487,11 @@ static float dBToLin(
}
-/* ============================================================================ */
+/*------------------------------------------------------------------------------------------*
+ * main()
+ *
+ * Main External renderer function for command-line interface
+ *------------------------------------------------------------------------------------------*/
int main(
int argc,
@@ -1058,6 +1033,11 @@ int main(
return 0;
}
+
+/*------------------------------------------------------------------------------------------*
+ * Local functions
+ *------------------------------------------------------------------------------------------*/
+
static IVAS_REND_AudioConfig ambisonicsOrderToEnum(
const int16_t order )
{
@@ -1723,7 +1703,7 @@ void readFromShorthandMetadata(
return;
}
-void IsmPositionProvider_getNextFrame(
+static void IsmPositionProvider_getNextFrame(
IsmPositionProvider *positionProvider,
ObjectPositionBuffer *objectMetadataBuffer )
{
@@ -1769,7 +1749,8 @@ void IsmPositionProvider_getNextFrame(
return;
}
-void IsmPositionProvider_close( IsmPositionProvider *positionProvider )
+static void IsmPositionProvider_close(
+ IsmPositionProvider *positionProvider )
{
uint32_t i;
@@ -2346,6 +2327,8 @@ static void parseSceneDescriptionFile(
strncat( audioFilePath, inAudioFilePath, inAudioFilePathLen );
parseMetadata( mtdStr, inDir, inConfig, positionProvider, masaReaders );
+
+ return;
}
static void printSupportedAudioConfigs()
@@ -2439,64 +2422,10 @@ static ivas_error parseLfePanMtxFile(
}
fclose( mtxFile );
- return IVAS_ERR_OK;
-}
-
-// VE2AT: possibly move these functions to cmdln_parser.c ?
-static void convert_backslash(
- char *str )
-{
- int16_t i, len;
-
- /* check that all backslashes are correct on the given platform */
- len = (int16_t) strlen( str );
-
- for ( i = 0; i < len; i++ )
- {
-#ifdef _WIN32
- if ( str[i] == '/' )
- {
- str[i] = '\\';
- }
-#else
- if ( str[i] == '\\' )
- {
- str[i] = '/';
- }
-#endif
- }
- return;
-}
-
-static void remove_cr( char *str )
-{
- char *pos;
-
- /* remove all \r characters from the string */
- pos = strchr( str, '\r' );
- while ( pos != NULL )
- {
- strcpy( pos, pos + 1 );
- pos = strchr( pos, '\r' );
- }
-
- return;
-}
-
-static void clearString(
- char *str )
-{
- str[0] = '\0';
-
- return;
+ return IVAS_ERR_OK;
}
-static bool isEmptyString(
- const char *str )
-{
- return str[0] == '\0';
-}
/*--------------------------------------------------------------------------*
* convertInputBuffer()
diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h
index 2a15165be0d244dcbeb7d8c4dfbab3ff57fb1252..d03a0b7f814457cc636aee2d71c96c990b6c0a88 100644
--- a/lib_com/common_api_types.h
+++ b/lib_com/common_api_types.h
@@ -49,6 +49,9 @@
#define IVAS_CLDFB_NO_CHANNELS_MAX ( 60 )
#define IVAS_MAX_INPUT_LFE_CHANNELS 4
+#define RENDERER_HEAD_POSITIONS_PER_FRAME 4
+
+
/*----------------------------------------------------------------------------------*
* Common API structures
*----------------------------------------------------------------------------------*/
@@ -67,7 +70,6 @@ typedef struct _IVAS_ENC_CHANNEL_AWARE_CONFIG
int16_t fec_offset;
} IVAS_ENC_CHANNEL_AWARE_CONFIG;
-
typedef struct _IVAS_ISM_METADATA
{
float azimuth;
@@ -89,7 +91,6 @@ typedef struct ivas_masa_qmetadata_frame_struct *IVAS_MASA_QMETADATA_HANDLE;
typedef struct TDREND_HRFILT_FiltSet_struct *IVAS_DEC_HRTF_HANDLE;
typedef struct ivas_hrtfs_crend_structure *IVAS_DEC_HRTF_CREND_HANDLE;
typedef struct ivas_hrtfs_fastconv_struct *IVAS_DEC_HRTF_FASTCONV_HANDLE;
-
typedef struct ivas_hrtfs_parambin_struct *IVAS_DEC_HRTF_PARAMBIN_HANDLE;
#ifdef DEBUGGING
@@ -101,6 +102,12 @@ typedef enum
} IVAS_RENDER_TYPE_OVERRIDE;
#endif
+typedef struct
+{
+ float azimuth;
+ float elevation;
+} IVAS_REND_AudioObjectPosition;
+
typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG
{
int16_t override;
@@ -152,5 +159,4 @@ typedef struct _IVAS_JBM_TRACE_DATA
} IVAS_JBM_TRACE_DATA;
-
#endif /* COMMON_API_TYPES_H */
diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h
index d29a7d33facce6db6da7da91c073a8e2db580950..09134774c0420f7cde9fe6fceebaaa89e2c679ff 100644
--- a/lib_com/ivas_cnst.h
+++ b/lib_com/ivas_cnst.h
@@ -36,7 +36,6 @@
#include
#include "options.h"
#include "cnst.h"
-#include "ivas_error.h"
/* clang-format off */
@@ -1396,9 +1395,9 @@ typedef enum
typedef enum
{
BINAURAL_INPUT_AUDIO_CONFIG_INVALID,
- BINAURAL_INPUT_AUDIO_CONFIG_COMBINED, // 5_1, 5_1_2, 5_1_4, 7_1, 7_1_4
- BINAURAL_INPUT_AUDIO_CONFIG_HOA, // FOA, HOA2, HOA3
- BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED // Not used
+ BINAURAL_INPUT_AUDIO_CONFIG_COMBINED, /* 5_1, 5_1_2, 5_1_4, 7_1, 7_1_4 */
+ BINAURAL_INPUT_AUDIO_CONFIG_HOA, /* FOA, HOA2, HOA3 */
+ BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED /* Not used */
} BINAURAL_INPUT_AUDIO_CONFIG;
diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h
index 8c46ce6f2e8db89773df137de2732414172e9dd7..9a69f81882c12273f5ce50a724a0a5085f40980d 100644
--- a/lib_com/ivas_prot.h
+++ b/lib_com/ivas_prot.h
@@ -40,9 +40,6 @@
#include "stat_enc.h"
#include "stat_dec.h"
#include "stat_com.h"
-#ifdef FIX_197_CREND_INTERFACE
-#include "ivas_stat_rend.h"
-#endif
#include "ivas_stat_enc.h"
#include "ivas_stat_dec.h"
#include "ivas_stat_com.h"
@@ -690,33 +687,6 @@ MC_LS_SETUP ivas_mc_map_output_config_to_mc_ls_setup(
const AUDIO_CONFIG output_config /* i : output audio configuration */
);
-/*! r: limiter struct handle */
-IVAS_LIMITER_HANDLE ivas_limiter_open(
- const int16_t num_channels, /* i : number of I/O channels */
- const int32_t sampling_rate /* i : sampling rate for processing */
-);
-
-void ivas_limiter_close(
- IVAS_LIMITER_HANDLE* phLimiter /* i/o: pointer to limiter handle, can be NULL */
-);
-
-void ivas_limiter_dec
-(
- IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */
- float output[MAX_OUTPUT_CHANNELS][L_FRAME48k], /* i/o: input/output buffer */
- const int16_t num_channels, /* i : number of channels to be processed */
- const int16_t output_frame, /* i : number of samples per channel in the buffer */
- const int16_t BER_detect /* i : BER detect flag */
-);
-
-void limiter_process(
- IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */
- const int16_t output_frame, /* i : number of samples to be processed per channel in the I/O buffer */
- const float threshold, /* i : signal amplitude above which limiting starts to be applied */
- const int16_t BER_detect, /* i : BER detect flag */
- int16_t *strong_saturation_cnt /* i/o: counter of strong saturations (can be NULL) */
-);
-
void smooth_dft2td_transition(
CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
float output[CPE_CHANNELS][L_FRAME48k], /* i/o: synthesis @external Fs */
@@ -1162,7 +1132,7 @@ void stereo_dft_dec_synthesize(
void stereo_dft_dec(
STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */
Decoder_State *st0, /* i/o: decoder state structure */
- float DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* i/o: DFT buffers */
+ float DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* i/o: DFT buffers */
float *input_mem, /* i/o: mem of buffer DFT analysis */
STEREO_CNG_DEC_HANDLE hStereoCng, /* i/o: Stereo CNG data structure */
const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */
@@ -3253,15 +3223,6 @@ void ivas_sba_getTCs(
const int16_t input_frame /* i : frame length */
);
-ivas_error ivas_sba_linear_renderer(
- float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */
- const int16_t output_frame, /* i : output frame length per channel */
- const int16_t nchan_in, /* i : number of input ambisonics channels */
- const AUDIO_CONFIG output_config, /* i : output audio configuration */
- const IVAS_OUTPUT_SETUP output_setup, /* i : output format setup */
- const float hoa_dec_mtx[] /* i : HOA decoding mtx */
-);
-
int16_t ivas_sba_remapTCs(
float sba_data[][L_FRAME48k], /* i/o: SBA signals */
Decoder_Struct *st_ivas, /* i/o: decoder struct */
@@ -3292,19 +3253,15 @@ void ivas_sba_dirac_stereo_smooth_parameters(
#endif
);
-ivas_error ivas_sba_get_hoa_dec_matrix(
- const IVAS_OUTPUT_SETUP hOutSetup, /* i : target output setup */
- float **hoa_dec_mtx, /* o : ALLRAD decoder matrix */
- const int16_t ambisonics_order /* i : Ambisonics order */
+void ivas_sba2mc_cldfb(
+ IVAS_OUTPUT_SETUP hInSetup, /* i : Format of input layout */
+ float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: cldfb real part */
+ float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: cldfb imag part */
+ const int16_t nb_channels_out, /* i : nb of output channels */
+ const int16_t nb_bands, /* i : nb of CLDFB bands to process */
+ const float *hoa_dec_mtx /* i : HOA decoding mtx */
);
-void ivas_sba_mtx_mult(
- float output_f[][L_FRAME48k], /* i/o: synthesized core-corder transport channels/DirAC output */
- const int16_t output_frame, /* i : frame length per channel */
- const int16_t nchan_in, /* i : Number of ambisonic channels */
- const IVAS_OUTPUT_SETUP output_setup, /* i : Output configuration */
- const float *mtx_hoa_decoder /* o : HOA decoding matrix */
-);
/*----------------------------------------------------------------------------------*
* DirAC prototypes
@@ -3398,59 +3355,6 @@ ivas_error ivas_dirac_dec_init_binaural_data(
HRTFS_PARAMBIN_HANDLE hHrtfParambin /* i : HRTF structure for rendering */
);
-void ivas_dirac_dec_close_binaural_data(
- DIRAC_DEC_BIN_HANDLE *hBinaural /* i/o: decoder DirAC binaural data handle */
-);
-
-ivas_error ivas_dirac_dec_binaural_copy_hrtfs(
- HRTFS_PARAMBIN_HANDLE *hHrtfParambin /* i/o: HRTF structure for rendering */
-);
-
-void ivas_dirac_dec_binaural(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */
- const int16_t nchan_transport /* i : number of transport channels */
-);
-
-ivas_error ivas_binaural_reverb_open(
- REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */
- const int16_t numBins, /* i : number of CLDFB bins */
- const int16_t numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame */
- ivas_roomAcoustics_t *roomAcoustics, /* i/o: room acoustics parameters */
- const AUDIO_CONFIG output_config, /* i : output audio configuration */
- const int32_t sampling_rate, /* i : sampling rate */
- const RENDERER_TYPE renderer_type /* i : renderer type */
- ,
- const HRTFS_FASTCONV_HANDLE hHrtfFastConv, /* i : FastConv HRTF handle */
- const HRTFS_PARAMBIN_HANDLE hHrtfParambin /* i : Parametric binauralizer HRTF handle */
-);
-
-void ivas_binaural_reverb_close(
- REVERB_STRUCT_HANDLE *hReverb /* i/o: binaural reverb handle */
-);
-
-void ivas_binaural_reverb_setReverbTimes(
- REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */
- const int32_t output_Fs, /* i : sampling_rate */
- const float *revTimes, /* i : reverberation times T60 for each CLDFB bin in seconds */
- const float *revEnes /* i : spectrum for reverberated sound at each CLDFB bin */
-);
-
-void ivas_binaural_reverb_setPreDelay(
- REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */
- const int16_t delaySamples /* i : reverb pre-delay in CLDFB slots */
-);
-
-void ivas_binaural_reverb_processFrame(
- REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */
- const int16_t numInChannels, /* i : num input channels to be processed */
- float inReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : input CLDFB data real */
- float inImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : input CLDFB data imag */
- float outReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : output CLDFB data real */
- float outImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : output CLDFB data imag */
- const uint8_t offsetSamplesIO /* i : number of offset samples */
-);
-
void computeDiffuseness_mdft(
float **buffer_intensity[DIRAC_NUM_DIMS],
const float *buffer_energy,
@@ -3928,6 +3832,15 @@ void ivas_sba_upmixer_renderer(
const int16_t output_frame /* i : output frame length */
);
+ivas_error ivas_sba_linear_renderer(
+ float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */
+ const int16_t output_frame, /* i : output frame length per channel */
+ const int16_t nchan_in, /* i : number of input ambisonics channels */
+ const AUDIO_CONFIG output_config, /* i : output audio configuration */
+ const IVAS_OUTPUT_SETUP output_setup, /* i : output format setup */
+ const float hoa_dec_mtx[] /* i : HOA decoding mtx */
+);
+
void ivas_sba_mix_matrix_determiner(
SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */
float output[][L_FRAME48k], /* i/o: transport/output audio channels */
@@ -3936,14 +3849,6 @@ void ivas_sba_mix_matrix_determiner(
const int16_t output_frame /* i : output frame length */
);
-void ivas_sba_prototype_renderer(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */
- float inRe[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */
- float inIm[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, imag */
- const int16_t firstSubframe, /* i : First subframe to map */
- const int16_t nSubframes /* i : Number of subframes to map */
-);
-
/* AGC */
/*! r: AGC enable flag */
int16_t ivas_agc_enc_get_flag(
@@ -4279,13 +4184,13 @@ void ivas_cov_smooth_process(
);
/* Transient detector module */
-ivas_error ivas_spar_transient_det_open(
- ivas_trans_det_state_t **hTranDet, /* i/o: SPAR TD handle */
+ivas_error ivas_transient_det_open(
+ ivas_trans_det_state_t **hTranDet, /* i/o: Transient detector handle */
const int32_t sampling_rate /* i : sampling rate */
);
-void ivas_spar_transient_det_close(
- ivas_trans_det_state_t **hTranDet /* i/o: SPAR TD handle */
+void ivas_transient_det_close(
+ ivas_trans_det_state_t **hTranDet /* i/o: Transient detector handle */
);
#ifdef SMOOTH_WITH_TRANS_DET
@@ -4297,14 +4202,14 @@ void ivas_transient_det_process(
);
#else
int16_t ivas_transient_det_process(
- ivas_trans_det_state_t *hTranDet, /* i/o: SPAR TD handle */
+ ivas_trans_det_state_t *hTranDet, /* i/o: Transient detector handle */
float *pIn_pcm, /* i : input audio channels */
const int16_t frame_len /* i : frame length in samples */
);
#endif
void ivas_td_decorr_get_ducking_gains(
- ivas_trans_det_state_t *hTranDet, /* i/o: SPAR TD handle */
+ ivas_trans_det_state_t *hTranDet, /* i/o: Transient detector handle */
float *pIn_pcm,
float *pIn_duck_gains,
float *pOut_duck_gains,
@@ -4312,15 +4217,15 @@ void ivas_td_decorr_get_ducking_gains(
const int16_t tdet_flag
);
-ivas_error ivas_spar_td_decorr_dec_open(
- ivas_td_decorr_state_t **hTdDecorr, /* i/o: SPAR Covar. decoder handle */
+ivas_error ivas_td_decorr_dec_open(
+ ivas_td_decorr_state_t **hTdDecorr, /* i/o: TD decorrelator handle */
const int32_t output_Fs, /* i : output sampling rate */
const int16_t nchan_internal, /* i : number of internal channels */
const int16_t ducking_flag /* i : ducking flag */
);
-void ivas_spar_td_decorr_dec_close(
- ivas_td_decorr_state_t **hTdDecorr /* i/o: SPAR Covar. decoder handle */
+void ivas_td_decorr_dec_close(
+ ivas_td_decorr_state_t **hTdDecorr /* i/o: TD decorrelator handle */
);
void ivas_td_decorr_process(
@@ -4671,23 +4576,8 @@ void ivas_spar_param_to_masa_param_mapping(
);
-/*----------------------------------------------------------------------------------*
- * output setup prototypes
- *----------------------------------------------------------------------------------*/
-
-/*! r: number of output channels */
-int16_t audioCfg2channels(
- const AUDIO_CONFIG output_config /* i : output audio configuration */
-);
-
-void ivas_output_init(
- IVAS_OUTPUT_SETUP *hOutSetup, /* o : output setup structure */
- const AUDIO_CONFIG output_config /* i : output audio configuration */
-);
-
-
/*---------------------------------------------------------------------------------*
- * Binaural Renderer Prototypes
+ * Binaural FastConv Renderer Prototypes
*-----------------------------------------------------------------------------------*/
ivas_error ivas_binRenderer_open(
@@ -4719,95 +4609,6 @@ void ivas_binaural_add_LFE(
float output_f[][L_FRAME48k] /* i/o: synthesized core-coder transport channels/DirAC output */
);
-ivas_error ivas_HRTF_fastconv_binary_open(
- HRTFS_FASTCONV **hHrtfFastConv /* i/o: FASTCONV HRTF structure */
-);
-
-void ivas_HRTF_fastconv_binary_close(
- HRTFS_FASTCONV **hHrtfFastConv /* i/o: FASTCONV HRTF structure */
-);
-
-ivas_error ivas_HRTF_parambin_binary_open(
- HRTFS_PARAMBIN **hHrtfParambin /* i/o: Parametric binauralizer HRTF structure */
-);
-
-void ivas_HRTF_parambin_binary_close(
- HRTFS_PARAMBIN **hHrtfParambin /* i/o: Parametric binauralizer HRTF structure */
-);
-
-void QuatToRotMat(
- const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */
- float Rmat[3][3] /* o : real-space rotation matrix for this rotation */
-);
-
-void Quat2Euler(
- const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */
- float *yaw, /* o : yaw */
- float *pitch, /* o : pitch */
- float *roll /* o : roll */
-);
-
-void SHrotmatgen(
- float SHrotmat[SBA_NHARM_HOA3][SBA_NHARM_HOA3], /* o : SHD rotation matrix */
- float Rmat[3][3], /* i : real-space rotation matrix */
- const int16_t order /* i : ambisonics order */
-);
-
-void rotateAziEle(
- float azi_in, /* i : output elevation */
- float ele_in, /* i : input elevation */
- int16_t *azi, /* o : rotated azimuth */
- int16_t *ele, /* o : rotated elevation */
- float Rmat[3][3], /* i : real-space rotation matrix */
- const int16_t isPlanar /* i : is roation planar and elevation meaningless? */
-);
-
-void rotateAziEle_DirAC(
- int16_t *azi, /* i/o: array of azimuth values */
- int16_t *ele, /* i/o: array of elevation values */
- const int16_t band1, /* i : bands to work on (lower limit) */
- const int16_t band2, /* i : bands to work on (upper bound) */
- const float *p_Rmat /* i : pointer to real-space rotation matrix */
-);
-
-ivas_error ivas_headTrack_open(
- HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* o : head track handle */
-);
-
-void rotateFrame_shd(
- HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : head track handle */
- float output[][L_FRAME48k], /* i/o: unrotated HOA3 signal buffer in TD */
- const int16_t subframe_len, /* i : subframe length per channel */
- const IVAS_OUTPUT_SETUP hTransSetup, /* i : format for rotation */
- const int16_t subframe_idx /* i : subframe index */
-);
-
-void rotateFrame_sd(
- HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : head track handle */
- float output[][L_FRAME48k], /* i/o: unrotated SD signal buffer in TD */
- const int16_t subframe_len, /* i : subframe length per channel */
- const IVAS_OUTPUT_SETUP hTransSetup, /* i : format for rotation */
- const EFAP_HANDLE hEFAPdata, /* i : EFAP structure */
- const int16_t subframe_idx /* i : subframe index */
-);
-
-void rotateFrame_shd_cldfb(
- float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain real part */
- float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain imag part */
- float Rmat[3][3], /* i : real-space rotation matrix */
- const int16_t nInChannels, /* i : number of channels */
- const int16_t shd_rot_max_order /* i : split-order rotation method */
-);
-
-void rotateFrame_sd_cldfb(
- HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : head track handle */
- float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain real part */
- float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain imag part */
- const IVAS_OUTPUT_SETUP_HANDLE hOutputSetup, /* i : output format setup number of channels */
- const EFAP_HANDLE hEFAPdata, /* i : EFAP structure */
- const int16_t nb_band /* i : number of CLDFB bands to process */
-);
-
/*----------------------------------------------------------------------------------*
* renderer prototypes
@@ -4838,15 +4639,6 @@ void ivas_mc2sba(
const float gain_lfe /* i : gain for LFE, 0=ignore LFE */
);
-void ivas_sba2mc_cldfb(
- IVAS_OUTPUT_SETUP hInSetup, /* i : Format of input layout */
- float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: cldfb real part */
- float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: cldfb imag part */
- const int16_t nb_channels_out, /* i : nb of output channels */
- const int16_t nb_bands, /* i : nb of CLDFB bands to process */
- const float *hoa_dec_mtx /* i : HOA decoding mtx */
-);
-
void ivas_ism2sba(
float buffer_td[][L_FRAME48k], /* i/o: TD signal buffers */
ISM_RENDERER_HANDLE hIsmRendererData, /* i/o: renderer data */
@@ -4858,7 +4650,7 @@ void ivas_ism2sba(
/*----------------------------------------------------------------------------------*
- * Amplitude Panning (EFAP, VBAP) prototypes
+ * Amplitude Panning VBAP prototypes
*----------------------------------------------------------------------------------*/
void panning_wrap_angles(
@@ -4868,26 +4660,6 @@ void panning_wrap_angles(
float *ele_wrapped /* o : wrapped elevation component */
);
-ivas_error efap_init_data(
- EFAP_HANDLE *hEFAPdata, /* i/o: handle for EFAP data structure that will be initialized */
- const float *speaker_node_azi_deg, /* i : vector of speaker node azimuths (positive left) */
- const float *speaker_node_ele_deg, /* i : vector of speaker node elevations (positive up) */
- const int16_t num_speaker_nodes, /* i : number of speaker nodes in the set */
- const int16_t efap_mode /* i : indicates whether EFAP or EFIP is used */
-);
-
-void efap_free_data(
- EFAP_HANDLE *hEFAPdata /* i/o: EFAP handle to be freed */
-);
-
-void efap_determine_gains(
- EFAP_HANDLE hEFAPdata, /* i : EFAP structure */
- float *gains, /* o : gain vector for speaker nodes for given direction */
- const float azi_deg, /* i : azimuth in degrees for panning direction (positive left) */
- const float ele_deg, /* i : elevation in degrees for panning direction (positive up) */
- const int16_t efap_mode /* i : indicates whether EFAP or EFIP is used */
-);
-
ivas_error vbap_init_data(
VBAP_HANDLE *hVBAPdata, /* i/o: handle for VBAP data structure that will be initialized */
const float *speaker_node_azi_deg, /* i : vector of speaker node azimuths (positive left) */
@@ -5063,7 +4835,6 @@ void computeReferencePower_enc(
const SBA_MODE sba_mode /* i : SBA mode */
);
-
ivas_error ivas_mono_dmx_renderer_open(
Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
);
@@ -5088,6 +4859,7 @@ void ivas_lfe_synth_with_filters(
const int16_t lfeChannelIndex /* i : LFE channel index */
);
+
/*----------------------------------------------------------------------------------*
* LFE Coding prototypes
*----------------------------------------------------------------------------------*/
@@ -5162,217 +4934,17 @@ void ivas_filter_process(
* TD Binaural Object renderer
*----------------------------------------------------------------------------------*/
-ivas_error ivas_HRTF_binary_open(
- TDREND_HRFILT_FiltSet_t **hHrtfTD /* i/o: TD renderer HRTF handle */
-);
-
-void ivas_HRTF_binary_close(
- TDREND_HRFILT_FiltSet_t **hHrtfTD /* i/o: TD renderer HRTF handle */
-);
-
-void DefaultBSplineModel(
- TDREND_HRFILT_FiltSet_t *HrFiltSet_p, /* o : Loaded HR filter set */
- const int32_t output_Fs /* i : Output sampling rate */
-);
-
ivas_error ivas_td_binaural_open(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-);
-
-void ivas_td_binaural_close(
- BINAURAL_TD_OBJECT_RENDERER_HANDLE *hBinRendererTd /* i/o: TD binaural object renderer handle */
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
);
-void ObjRenderIVASFrame(
+void ivas_td_binaural_renderer(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
float output[][L_FRAME48k], /* i/o: SCE channels / Binaural synthesis */
const int16_t output_frame /* i : output frame length */
);
-void BSplineModelEvalAlloc(
- ModelParams_t *model, /* i : Model parameters */
- ModelEval_t *modelEval /* i/o: Model evaluation structure */
-);
-
-/* ----- Object renderer - hrfilt ----- */
-void GetFilterFromAngle(
- TDREND_HRFILT_FiltSet_t *HrFiltSet_p, /* i/o: HR filter set structure */
- const float Elev, /* i : Elevation, degrees */
- float Azim, /* i : Azimuth, degrees */
- float *LeftFilter, /* o : Left HR filter */
- float *RightFilter, /* o : Right HR filter */
- int16_t *itd /* o : ITD value */
-);
-
-void HRTF_model_precalc(
- ModelParams_t *model /* i/o: HRTF Model parameters */
-);
-
-void BSplineModelEvalDealloc(
- ModelParams_t *model, /* i : Model parameters */
- ModelEval_t *modelEval /* i : Model evaluation structure */
-);
-
-
-
-ivas_error TDREND_REND_RenderSourceHRFilt(
- TDREND_SRC_t *Src_p, /* i/o: The source to be rendered */
- const float *hrf_left_delta, /* i: Left filter interpolation delta */
- const float *hrf_right_delta, /* i: Right filter interpolation delta */
- const int16_t intp_count, /* i: Interpolation count */
- float output_buf[][L_SPATIAL_SUBFR_48k], /* o : Output buffer */
- const int16_t subframe_length /* i : Subframe length in use */
-);
-
-/* ----- Object renderer - sources ----- */
-
-ivas_error TDREND_MIX_SRC_SetPos(
- BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */
- const int16_t SrcInd, /* i : Source index */
- const float *Vec_p /* i : Position vector */
-);
-
-ivas_error TDREND_MIX_SRC_SetDir(
- BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */
- const int16_t SrcInd, /* i : Source index */
- const float *Vec_p /* i : Direction vector */
-);
-
-ivas_error TDREND_MIX_SRC_SetDirAtten(
- BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */
- const int16_t SrcInd, /* i : Source index */
- const TDREND_DirAtten_t *DirAtten_p /* i : Directional attenuation specifier */
-);
-
-ivas_error TDREND_MIX_SRC_SetPlayState(
- BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */
- const int16_t SrcInd, /* i : Source index */
- const TDREND_PlayStatus_t PlayStatus /* i : Play state */
-);
-
-void TDREND_SRC_REND_UpdateFiltersFromSpatialParams(
- BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */
- TDREND_SRC_REND_t *SrcRend_p, /* i/o: Source object */
- TDREND_SRC_SPATIAL_t *SrcSpatial_p, /* i : Spatial aspects of source */
- float *hrf_left_prev, /* o: Left filter */
- float *hrf_right_prev, /* o: Right filter */
- float *hrf_left_delta, /* o: Left filter interpolation delta */
- float *hrf_right_delta, /* o: Right filter interpolation delta */
- int16_t *intp_count, /* o: Interpolation count */
- int16_t *filterlength, /* o: Length of filters */
- int16_t *itd, /* o: ITD value */
- float *Gain, /* o: Gain value */
- TDREND_SRC_t *Src_p,
- const int16_t subframe_idx /* i : Subframe index to 5 ms subframe */
-);
-
-ivas_error TDREND_SRC_Alloc(
- TDREND_SRC_t **Src_pp /* i/o: Source */
-);
-
-void TDREND_SRC_Dealloc(
- TDREND_SRC_t *Src_p /* i/o: Source to deallocate */
-);
-
-void TDREND_SRC_Init(
- TDREND_SRC_t *Src_p, /* i/o: Source to initialize */
- const TDREND_PosType_t PosType /* i : Position type specifier */
-);
-
-/* ----- Object renderer - vec ----- */
-
-void TDREND_SPATIAL_VecInit(
- float *Pos_p, /* o : Output vector */
- const float PosX, /* i : X value */
- const float PosY, /* i : Y value */
- const float PosZ /* i : Z value */
-);
-
-/*! r: Euclidian norm value */
-float TDREND_SPATIAL_VecNorm(
- const float *Vec_p /* i : Vector for norm calculation */
-);
-
-void TDREND_SPATIAL_VecNormalize(
- const float *Vec_p, /* i : Input vector */
- float *VecNorm_p /* o : Output vector */
-);
-
-void TDREND_SPATIAL_VecMapToNewCoordSystem(
- const float *Vec_p, /* i : Input vector */
- const float *TranslVec_p, /* i : Translation vector */
- const float *DirVec_p, /* i : Direction vector */
- const float *UpVec_p, /* i : Up vector */
- const float *RightVec_p, /* i : Right vector */
- float *MappedVec_p /* o : Transformed vector */
-);
-
-/*! r: Flag if the orientation has been updated */
-int16_t TDREND_SPATIAL_EvalOrthonormOrient(
- float *FrontVecON_p, /* o : Normalized front vector */
- float *UpVecON_p, /* o : Normalized up vector */
- float *RightVecON_p, /* o : Normalized right vector */
- const float *FrontVec_p, /* i : Input front vector */
- const float *UpVec_p /* i : Input up vector */
-);
-
-/* ----- Object renderer - mix ----- */
-
-ivas_error TDREND_MIX_AddSrc(
- BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */
- int16_t *SrcInd, /* o : Source index */
- const TDREND_PosType_t PosType /* i : Position type (absolute/relative) */
-);
-
-ivas_error TDREND_MIX_SetDistAttenModel(
- BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */
- const TDREND_DistAttenModel_t DistAttenModel /* i : Distance attenuation model */
-);
-
-void TDREND_MIX_LIST_SetPos(
- BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */
- const float *Pos_p /* i : Listener's position */
-);
-
-ivas_error TDREND_MIX_LIST_SetOrient(
- BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */
- const float *FrontVec_p, /* i : Listener's orientation front vector */
- const float *UpVec_p /* i : Listener's orientation up vector */
-);
-
-void TDREND_MIX_Dealloc(
- BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd /* i/o: TD renderer handle */
-);
-
-ivas_error TDREND_MIX_Init(
- BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */
- TDREND_HRFILT_FiltSet_t **hHrtfTD, /* i/o: HRTF data (initialized in case of NULL) */
- const TDREND_MixSpatSpec_t *MixSpatSpec_p, /* i : Mixer spatial specification */
- const int32_t output_Fs /* i : Output sampling rate */
-);
-
- /* ----- Object renderer - sfx ----- */
-
-void TDREND_Apply_ITD(
- float *input, /* i: Input SCE subframe to be time adjusted */
- float *out_left, /* o: Output left channels with ITD applied */
- float *out_right, /* o: Output right channels with ITD applied */
- int16_t *previtd, /*i/o: Previous ITD value */
- const int16_t itd, /* i: Current subframe ITD value */
- float *mem_itd, /*i/o: ITD buffer memory */
- const int16_t length /* i: Subframe length */
-);
-
-void TDREND_firfilt(
- float *signal, /* i/o: Input signal / Filtered signal */
- float *filter, /* i/o: FIR filter */
- const float *filter_delta, /* i : FIR filter delta */
- const int16_t intp_count, /* i : interpolation count */
- float *mem, /* i/o: filter memory */
- const int16_t subframe_length, /* i : Length of signal */
- const int16_t filterlength /* i : Filter length */
-);
/*----------------------------------------------------------------------------------*
* Filter-bank (FB) Mixer
*----------------------------------------------------------------------------------*/
@@ -5448,353 +5020,6 @@ int16_t ivas_get_num_bands_from_bw_idx(
);
-/*----------------------------------------------------------------------------------*
- * Crend renderer
- *----------------------------------------------------------------------------------*/
-
-
-ivas_error ivas_HRTF_CRend_binary_open(
- HRTFS_CREND **hSetOfHRTF /* i/o: Set of HRTF handle */
-);
-
-void ivas_HRTF_CRend_binary_close(
- HRTFS_CREND **hSetOfHRTF /* i/o: Set of HRTF handle */
-);
-
-#ifndef FIX_197_CREND_INTERFACE
-
-ivas_error ivas_crend_init_from_setofhrtf(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-);
-
-ivas_error ivas_crend_init_from_hrtf_handle(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- HRTFS_HANDLE hrtf);
-#endif
-
-#ifndef FIX_MEMORY_COUNTING_HRTF_BINARY_FILE
-ivas_error destroy_SetOfHRTF(
- HRTFS_CREND_HANDLE hSetOfHRTF /* i/o: Set of HRTF CRend handle */
-);
-#endif
-
-
-#ifndef FIX_197_CREND_INTERFACE
-
-ivas_error ivas_crend_init_from_rom(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-);
-
-ivas_error ivas_crend_open(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-);
-
-ivas_error ivas_crend_close(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-);
-
-ivas_error ivas_crend_process(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- float output[][L_FRAME48k] /* i/o: input/output audio channels */
-);
-
-#else
-
-IVAS_REND_AudioConfigType getAudioConfigType(
- const IVAS_REND_AudioConfig config );
-
-ivas_error getAudioConfigNumChannels(
- const IVAS_REND_AudioConfig config,
- int16_t *numChannels );
-
-IVAS_REND_AudioConfig getRendAudioConfigFromIvasAudioConfig(
- AUDIO_CONFIG config );
-
-ivas_error ivas_rend_initCrend(
- CREND_WRAPPER *pCrend,
- const IVAS_REND_AudioConfig inConfig,
- const IVAS_REND_AudioConfig outConfig,
- RENDER_CONFIG_DATA *hRendCfg,
- HRTFS_CREND_HANDLE hSetOfHRTF,
- const int32_t output_Fs );
-
-ivas_error ivas_rend_openCrend(
- CREND_WRAPPER_HANDLE *pCrend,
- const IVAS_REND_AudioConfig inConfig,
- const IVAS_REND_AudioConfig outConfig,
- RENDER_CONFIG_DATA *hRendCfg,
- int16_t Opt_Headrotation,
- HRTFS_CREND_HANDLE hSetOfHRTF,
- const int32_t output_Fs );
-
-#ifdef FIX_197_CREND_INTERFACE
-void ivas_rend_closeCrend(
-#else
-ivas_error ivas_rend_closeCrend(
-#endif
- CREND_WRAPPER_HANDLE *pCrend );
-
-ivas_error ivas_rend_crendProcess(
- const CREND_WRAPPER *pCrend,
- const IVAS_REND_AudioConfig inConfig,
- const IVAS_REND_AudioConfig outConfig,
- DECODER_CONFIG_HANDLE hDecoderConfig,
- HEAD_TRACK_DATA_HANDLE hHeadTrackData,
- IVAS_OUTPUT_SETUP_HANDLE hIntSetup,
- EFAP_HANDLE hEFAPdata,
- float output[][L_FRAME48k], /* i/o: input/output audio channels */
- const int32_t output_Fs );
-#endif
-
-/*----------------------------------------------------------------------------------*
- * Renderer configuration
- *----------------------------------------------------------------------------------*/
-
-ivas_error ivas_render_config_open(
- RENDER_CONFIG_HANDLE *hRenderConfig /* i/o: Renderer config handle */
-);
-
-void ivas_render_config_close(
- RENDER_CONFIG_HANDLE *hRenderConfig /* i/o: Renderer config handle */
-);
-
-ivas_error ivas_render_config_init_from_rom(
- RENDER_CONFIG_HANDLE *hRenderConfig, /* i/o: Renderer config handle */
- const int16_t room_flag_on /* i : room effect on/off flag */
-);
-
-
-/*----------------------------------------------------------------------------------*
- * Reverberator
- *----------------------------------------------------------------------------------*/
-
-ivas_error ivas_reverb_open(
- REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */
- const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */
- const HRTFS_HANDLE hHrtf, /* i : HRTF handle */
- RENDER_CONFIG_DATA *pConfig, /* i : Reverb configuration */
- const int32_t output_Fs /* i : output sampling rate */
-);
-
-void ivas_reverb_close(
- REVERB_HANDLE *hReverb /* i/o: Reverberator handle */
-);
-
-ivas_error ivas_reverb_process(
- REVERB_HANDLE hReverb, /* i/o: reverb state */
- const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */
- const int16_t mix_signals, /* i : add reverb to output signal */
- float pcm_in[][L_FRAME48k], /* i : the PCM audio to apply reverb on */
- float pcm_out[][L_FRAME48k], /* o : the PCM audio with reverb applied */
- const int16_t i_ts
-);
-
-void ivas_rev_delay_line_init(
- ivas_rev_delay_line_t *pDelay, /* o : the delay line to initialize */
- float *memory_buffer, /* i : the memory buffer to use for the delay line */
- const uint16_t delay, /* i : the delay */
- const uint16_t maxdelay /* i : maximum delay to be supported */
-);
-
-/* !r: sample gotten out of delay line, and amplified by set gain */
-float ivas_rev_delay_line_get_sample(
- ivas_rev_delay_line_t *pDelay /* i/o: the delay line */
-);
-
-void ivas_rev_delay_line_feed_sample(
- ivas_rev_delay_line_t *pDelay, /* i : the delay line */
- float input /* i : the sample to feed */
-);
-
-void ivas_rev_delay_line_get_sample_blk(
- ivas_rev_delay_line_t *pDelay, /* i : the delay line */
- const uint16_t blk_size, /* i : number of samples in the data block */
- float *output /* i/o: amples gotten out of delay line, and amplified by set gainin */
-);
-
-void ivas_rev_delay_line_feed_sample_blk(
- ivas_rev_delay_line_t *pDelay, /* i/o: the delay line */
- const uint16_t blk_size, /* i : number of samples in the input data block */
- float *input /* i : the samples to feed */
-);
-
-void ivas_reverb_iir_filt_init(
- ivas_rev_iir_filter_t *iirFilter, /* o : IIR filter */
- const uint16_t maxTaps /* i : maximum number of filter taps */
-);
-
-void ivas_reverb_iir_filt_set(
- ivas_rev_iir_filter_t *iirFilter, /* i/o: IIR filter */
- uint16_t nr_taps, /* i : number of IIR filter taps */
- const float *coefA, /* i : A filter coefficients to set */
- const float *coefB /* i : the B filter coefficients to set */
-);
-
-void ivas_reverb_iir_filt_2taps_feed_blk(
- ivas_rev_iir_filter_t *iirFilter, /* i/o: IIR filter */
- const uint16_t blk_size, /* i : size */
- const float *input, /* i : input buffer */
- float *output /* i : output buffer */
-);
-
-uint16_t int_log2(
- uint32_t powerOf2
-);
-
-int16_t ivas_reverb_t2f_f2t_init(
- ivas_reverb_t2f_f2t_t *t2f_f2t,
- const int16_t fft_size,
- const int16_t block_size
-);
-
-void ivas_reverb_t2f_f2t_ClearHistory(
- ivas_reverb_t2f_f2t_t *t2f_f2t
-);
-
-void ivas_reverb_t2f_f2t_in(
- ivas_reverb_t2f_f2t_t *t2f_f2t,
- float *input_L,
- float *input_R, float *buffer_L,
- float *buffer_R
-);
-
-void ivas_reverb_t2f_f2t_out(
- ivas_reverb_t2f_f2t_t *t2f_f2t,
- float *buffer_L,
- float *buffer_R,
- float *output_L,
- float *output_R
-);
-
-int16_t ivas_reverb_fft_filter_init(
- ivas_reverb_fft_filter_t *fft_filter,
- const int16_t fft_size
-);
-
-void ivas_reverb_fft_filter_ComplexMul(
- ivas_reverb_fft_filter_t *fft_filter,
- float *buffer
-);
-
-void ivas_reverb_fft_filter_CrossMix(
- float *buffer0,
- float *buffer1,
- const int16_t fft_size
-);
-
-void ivas_reverb_fft_filter_ConvertFFTWF_2_FFTR(
- rv_fftwf_type_complex *spectrum,
- float *fft_real,
- const int16_t fft_size
-);
-
-void ivas_reverb_define_window_fft(
- float *pWindow,
- const int16_t transitionStart,
- const int16_t transitionLength,
- const int16_t spectrumLength
-);
-
-int16_t ivas_reverb_calc_color_filters(
- const float *pTargetL,
- const float *pTargetR,
- const float *pWindow,
- const int16_t fft_size,
- const float delay,
- rv_fftwf_type_complex *pBeqL,
- rv_fftwf_type_complex *pBeqR
-);
-
-int16_t ivas_reverb_calc_correl_filters(
- const float *pTargetICC,
- const float *pWindow,
- const int16_t fft_size,
- const float delay,
- rv_fftwf_type_complex *pU,
- rv_fftwf_type_complex *pV
-);
-
-void ivas_reverb_calc_color_levels(
- const int32_t output_Fs,
- const int16_t freq_count,
- const int16_t loop_count,
- const float *pFc,
- const float *pAcoustic_dsr,
- const float *pHrtf_avg_pwr_L,
- const float *pHrtf_avg_pwr_R,
- const int16_t *pLoop_delays,
- const float *pT60_filter_coeff,
- float *pTarget_color_L,
- float *pTarget_color_R
-);
-
-void ivas_reverb_prepare_cldfb_params(
- ivas_roomAcoustics_t *pInput_params,
- const HRTFS_FASTCONV_HANDLE hHrtfFastConv,
- const AUDIO_CONFIG input_audio_config,
- const int16_t use_brir,
- const int32_t output_Fs,
- float *pOutput_t60,
- float *pOutput_ene );
-
-void ivas_reverb_interpolate_acoustic_data(
- const int16_t input_table_size,
- const float *pInput_fc,
- const float *pInput_t60,
- const float *pInput_dsrR,
- const int16_t output_table_size,
- const float *pOutput_fc,
- float *pOutput_t60,
- float *pOutput_dsr
-);
-
-void ivas_reverb_get_hrtf_set_properties(
- float **ppHrtf_set_L_re,
- float **ppHrtf_set_L_im,
- float **ppHrtf_set_R_re,
- float **ppHrtf_set_R_im,
- const AUDIO_CONFIG input_audio_config,
- const int16_t hrtf_count,
- const int16_t in_freq_count,
- const int16_t out_freq_count,
- float *pOut_avg_pwr_L,
- float *pOut_avg_pwr_R,
- float *pOut_i_a_coherence
-);
-
-
-/*----------------------------------------------------------------------------------*
- * Orientation tracking
- *----------------------------------------------------------------------------------*/
-
-void ivas_orient_trk_Init(
- ivas_orient_trk_state_t *pOTR
-);
-
-ivas_error ivas_orient_trk_SetTrackingType(
- ivas_orient_trk_state_t *pOTR,
- OTR_TRACKING_T trackingType
-);
-
-ivas_error ivas_orient_trk_SetAbsoluteOrientation(
- ivas_orient_trk_state_t *pOTR,
- float yaw,
- float pitch,
- float roll
-);
-
-ivas_error ivas_orient_trk_Process(
- ivas_orient_trk_state_t *pOTR
-);
-
-ivas_error ivas_orient_trk_GetTrackedOrientation(
- ivas_orient_trk_state_t *pOTR,
- float *yaw,
- float *pitch,
- float *roll
-);
-
-
/* clang-format on */
#endif /* IVAS_PROT_H */
diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h
index 5c9b60aceba75d6555209328a8e29556147167f1..8231588551aa246aa6f71ccd6ccd6ec0c457fc1b 100644
--- a/lib_com/ivas_stat_com.h
+++ b/lib_com/ivas_stat_com.h
@@ -655,6 +655,32 @@ typedef struct ivas_trans_det_state_t
} ivas_trans_det_state_t;
+/*----------------------------------------------------------------------------------*
+ * Time domain decorrelator
+ *----------------------------------------------------------------------------------*/
+
+typedef struct ivas_td_decorr_APD_filt_state_t
+{
+ int16_t order[IVAS_MAX_DECORR_APD_SECTIONS];
+ int16_t idx[IVAS_MAX_DECORR_APD_SECTIONS];
+ float coeffs[IVAS_MAX_DECORR_APD_SECTIONS];
+ float *state[IVAS_MAX_DECORR_APD_SECTIONS];
+
+} ivas_td_decorr_APD_filt_state_t;
+
+typedef struct ivas_td_decorr_state_t
+{
+ ivas_trans_det_state_t *pTrans_det;
+ float *look_ahead_buf;
+ ivas_td_decorr_APD_filt_state_t APD_filt_state[IVAS_MAX_DECORR_CHS];
+
+ int16_t num_apd_outputs;
+ int16_t num_apd_sections;
+ int16_t ducking_flag;
+
+} ivas_td_decorr_state_t;
+
+
/*----------------------------------------------------------------------------------*
* Filter Bank (FB) structures
*----------------------------------------------------------------------------------*/
diff --git a/lib_dec/ivas_td_decorr.c b/lib_com/ivas_td_decorr.c
similarity index 89%
rename from lib_dec/ivas_td_decorr.c
rename to lib_com/ivas_td_decorr.c
index 34f88aeb03f6dba603f86456f311ead88788f8f3..81c477fb43d17301065ce98ad98accabe6674c90 100644
--- a/lib_dec/ivas_td_decorr.c
+++ b/lib_com/ivas_td_decorr.c
@@ -96,83 +96,83 @@ static ivas_error ivas_td_decorr_init( ivas_td_decorr_state_t *hTdDecorr, const
/*-------------------------------------------------------------------------
- * ivas_spar_td_decorr_dec_open()
+ * ivas_td_decorr_dec_open()
*
- * Allocate and initialize SPAR time domain decorrelator handle
+ * Allocate and initialize time domain decorrelator handle
*------------------------------------------------------------------------*/
-ivas_error ivas_spar_td_decorr_dec_open(
- ivas_td_decorr_state_t **hTdDecorr, /* i/o: SPAR Covar. decoder handle */
- const int32_t output_Fs, /* i : output sampling rate */
- const int16_t nchan_internal, /* i : number of internal channels */
- const int16_t ducking_flag /* i : ducking flag */
+ivas_error ivas_td_decorr_dec_open(
+ ivas_td_decorr_state_t **hTdDecorr, /* i/o: TD decorrelator handle */
+ const int32_t output_Fs, /* i : output sampling rate */
+ const int16_t nchan_internal, /* i : number of internal channels */
+ const int16_t ducking_flag /* i : ducking flag */
)
{
int16_t i, j, len;
int16_t num_out_chans;
- ivas_td_decorr_state_t *hCovState;
+ ivas_td_decorr_state_t *hTdDecorr_loc;
ivas_error error;
num_out_chans = nchan_internal - 1;
error = IVAS_ERR_OK;
- if ( ( hCovState = (ivas_td_decorr_state_t *) malloc( sizeof( ivas_td_decorr_state_t ) ) ) == NULL )
+ if ( ( hTdDecorr_loc = (ivas_td_decorr_state_t *) malloc( sizeof( ivas_td_decorr_state_t ) ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV decoder" );
}
- if ( ( hCovState->look_ahead_buf = (float *) malloc( sizeof( float ) * (int16_t) ( output_Fs * IVAS_DECORR_PARM_LOOKAHEAD_TAU ) ) ) == NULL )
+ if ( ( hTdDecorr_loc->look_ahead_buf = (float *) malloc( sizeof( float ) * (int16_t) ( output_Fs * IVAS_DECORR_PARM_LOOKAHEAD_TAU ) ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV decoder" );
}
- set_f( hCovState->look_ahead_buf, 0, (int16_t) ( output_Fs * IVAS_DECORR_PARM_LOOKAHEAD_TAU ) );
+ set_f( hTdDecorr_loc->look_ahead_buf, 0, (int16_t) ( output_Fs * IVAS_DECORR_PARM_LOOKAHEAD_TAU ) );
- hCovState->num_apd_sections = ivas_get_APD_filt_orders( num_out_chans, output_Fs, hCovState->APD_filt_state[0].order );
+ hTdDecorr_loc->num_apd_sections = ivas_get_APD_filt_orders( num_out_chans, output_Fs, hTdDecorr_loc->APD_filt_state[0].order );
for ( j = 0; j < num_out_chans; j++ )
{
- for ( i = 0; i < hCovState->num_apd_sections; i++ )
+ for ( i = 0; i < hTdDecorr_loc->num_apd_sections; i++ )
{
- len = hCovState->APD_filt_state[0].order[i];
+ len = hTdDecorr_loc->APD_filt_state[0].order[i];
- if ( ( hCovState->APD_filt_state[j].state[i] = (float *) malloc( sizeof( float ) * len ) ) == NULL )
+ if ( ( hTdDecorr_loc->APD_filt_state[j].state[i] = (float *) malloc( sizeof( float ) * len ) ) == NULL )
{
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV decoder" );
}
- set_f( hCovState->APD_filt_state[j].state[i], 0, len );
+ set_f( hTdDecorr_loc->APD_filt_state[j].state[i], 0, len );
}
}
- ivas_td_decorr_init( hCovState, num_out_chans, ducking_flag );
+ ivas_td_decorr_init( hTdDecorr_loc, num_out_chans, ducking_flag );
if ( ducking_flag )
{
- if ( ( error = ivas_spar_transient_det_open( &hCovState->pTrans_det, output_Fs ) ) != IVAS_ERR_OK )
+ if ( ( error = ivas_transient_det_open( &hTdDecorr_loc->pTrans_det, output_Fs ) ) != IVAS_ERR_OK )
{
return error;
}
}
else
{
- hCovState->pTrans_det = NULL;
+ hTdDecorr_loc->pTrans_det = NULL;
}
- *hTdDecorr = hCovState;
+ *hTdDecorr = hTdDecorr_loc;
return error;
}
/*-------------------------------------------------------------------------
- * ivas_spar_td_decorr_dec_close()
+ * ivas_td_decorr_dec_close()
*
- * Deallocate SPAR time domain decorrelator handle
+ * Deallocate time domain decorrelator handle
*------------------------------------------------------------------------*/
-void ivas_spar_td_decorr_dec_close(
- ivas_td_decorr_state_t **hTdDecorr /* i/o: SPAR Covar. decoder handle */
+void ivas_td_decorr_dec_close(
+ ivas_td_decorr_state_t **hTdDecorr /* i/o: TD decorrelator handle */
)
{
int16_t i, j;
@@ -196,7 +196,7 @@ void ivas_spar_td_decorr_dec_close(
if ( ( *hTdDecorr )->pTrans_det != NULL )
{
- ivas_spar_transient_det_close( &( *hTdDecorr )->pTrans_det );
+ ivas_transient_det_close( &( *hTdDecorr )->pTrans_det );
}
free( ( *hTdDecorr ) );
diff --git a/lib_com/ivas_transient_det.c b/lib_com/ivas_transient_det.c
index 20aaf80d7390dbcb9133f856d90aff0abf262dad..8fc2b92c995a7f867ddef45a26b4ad54250511a8 100644
--- a/lib_com/ivas_transient_det.c
+++ b/lib_com/ivas_transient_det.c
@@ -84,8 +84,8 @@
*-----------------------------------------------------------------------------------------*/
static void ivas_transient_det_init(
- ivas_trans_det_state_t *hTranDet, /* i/o: SPAR TD handle */
- const int32_t sampling_rate /* i : sampling rate */
+ ivas_trans_det_state_t *hTranDet, /* i/o: Transient detector handle */
+ const int32_t sampling_rate /* i : sampling rate */
)
{
float filt_coeff_arr[3][IVAS_BIQUAD_FILT_LEN << 1] = { { 0 } };
@@ -159,14 +159,14 @@ static void ivas_transient_det_init(
/*-------------------------------------------------------------------------
- * ivas_spar_transient_det_open()
+ * ivas_transient_det_open()
*
* Allocate and initialize SPAR TD handle
*------------------------------------------------------------------------*/
-ivas_error ivas_spar_transient_det_open(
- ivas_trans_det_state_t **hTranDet_in, /* i/o: SPAR TD handle */
- const int32_t sampling_rate /* i : sampling rate */
+ivas_error ivas_transient_det_open(
+ ivas_trans_det_state_t **hTranDet_in, /* i/o: Transient detector handle */
+ const int32_t sampling_rate /* i : sampling rate */
)
{
ivas_trans_det_state_t *hTranDet;
@@ -185,13 +185,13 @@ ivas_error ivas_spar_transient_det_open(
/*-------------------------------------------------------------------------
- * ivas_spar_transient_det_close()
+ * ivas_transient_det_close()
*
- * Deallocate and initialize SPAR TD handle
+ * Deallocate and initialize Transient detector handle
*------------------------------------------------------------------------*/
-void ivas_spar_transient_det_close(
- ivas_trans_det_state_t **hTranDet /* i/o: SPAR TD handle */
+void ivas_transient_det_close(
+ ivas_trans_det_state_t **hTranDet /* i/o: Transient detector handle */
)
{
if ( hTranDet == NULL || *hTranDet == NULL )
@@ -308,7 +308,7 @@ static float ivas_calc_duck_gain(
*-----------------------------------------------------------------------------------------*/
void ivas_td_decorr_get_ducking_gains(
- ivas_trans_det_state_t *hTranDet,
+ ivas_trans_det_state_t *hTranDet, /* i/o: Transient detector handle */
float *pIn_pcm,
float *pIn_duck_gains,
float *pOut_duck_gains,
@@ -340,7 +340,7 @@ void ivas_td_decorr_get_ducking_gains(
/* env slow */
ivas_filter_process( &hTranDet->env_slow, e_slow, frame_len );
- if ( tdet_flag == IVAS_TDET_ONLY )
+ if ( tdet_flag )
{
for ( i = 0; i < frame_len; i++ )
{
diff --git a/lib_rend/ivas_binauralRenderer.c b/lib_dec/ivas_binRenderer_internal.c
similarity index 99%
rename from lib_rend/ivas_binauralRenderer.c
rename to lib_dec/ivas_binRenderer_internal.c
index 71db67ce2e8c85c0e0bec52fa3655652d903ae3d..33e79578237782b709e6d760a5344e7ce9640120 100644
--- a/lib_rend/ivas_binauralRenderer.c
+++ b/lib_dec/ivas_binRenderer_internal.c
@@ -33,8 +33,9 @@
#include
#include "options.h"
#include
-#include "ivas_prot.h"
#include "prot.h"
+#include "ivas_prot.h"
+#include "ivas_prot_rend.h"
#include "cnst.h"
#include "ivas_cnst.h"
#include "ivas_rom_rend.h"
@@ -687,7 +688,7 @@ ivas_error ivas_binRenderer_open(
{
for ( k = 0; k < hBinRenderer->nInChannels; k++ )
{
- hBinRenderer->hReverb->dmxmtx[chIdx][k] = dmxmtx[chIdx][k];
+ hBinRenderer->hReverb->dmxmtx[chIdx][k] = dmxmtx_table[chIdx][k];
}
}
}
diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig.c
index 5bc68227355c5b348304ae811fe9312857b61de1..21b8cdf05f5790ec88ab7b0a4321f871298bb212 100644
--- a/lib_dec/ivas_corecoder_dec_reconfig.c
+++ b/lib_dec/ivas_corecoder_dec_reconfig.c
@@ -35,7 +35,6 @@
#include "ivas_prot.h"
#include "ivas_rom_com.h"
#include "ivas_stat_enc.h"
-#include "lib_dec.h"
#include "prot.h"
#include
#include
diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c
index ec618917b7963429e303b8dde1366de1a1b3f938..db54bca1be96daecd7a47e507e317aa38b402a35 100644
--- a/lib_dec/ivas_dec.c
+++ b/lib_dec/ivas_dec.c
@@ -37,6 +37,7 @@
#include "rom_com.h"
#include "prot.h"
#include "ivas_prot.h"
+#include "ivas_prot_rend.h"
#include "ivas_rom_com.h"
#ifdef DEBUGGING
#include "debug.h"
@@ -213,14 +214,14 @@ ivas_error ivas_dec(
/* Binaural rendering */
if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD )
{
- ObjRenderIVASFrame( st_ivas, output, output_frame );
+ ivas_td_binaural_renderer( st_ivas, output, output_frame );
}
else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM )
{
#ifdef FIX_197_CREND_INTERFACE
if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper,
- IVAS_REND_AUDIO_CONFIG_7_1_4,
- IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM,
+ AUDIO_CONFIG_7_1_4,
+ AUDIO_CONFIG_BINAURAL_ROOM,
NULL,
NULL,
NULL,
@@ -445,8 +446,8 @@ ivas_error ivas_dec(
{
#ifdef FIX_197_CREND_INTERFACE
if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper,
- getRendAudioConfigFromIvasAudioConfig( st_ivas->intern_config ),
- getRendAudioConfigFromIvasAudioConfig( st_ivas->hOutSetup.output_config ),
+ st_ivas->intern_config,
+ st_ivas->hOutSetup.output_config,
st_ivas->hDecoderConfig,
st_ivas->hHeadTrackData,
&st_ivas->hIntSetup,
@@ -472,7 +473,7 @@ ivas_error ivas_dec(
}
else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD )
{
- ObjRenderIVASFrame( st_ivas, output, output_frame );
+ ivas_td_binaural_renderer( st_ivas, output, output_frame );
ivas_binaural_add_LFE( st_ivas, output_frame, output );
}
}
diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c
index 557af7a49782c4bdc14cd7a5491c38a110e67fea..f3090415ae70c33aac2ad9e8fdf578b7aa62428c 100644
--- a/lib_dec/ivas_dirac_dec.c
+++ b/lib_dec/ivas_dirac_dec.c
@@ -37,6 +37,7 @@
#include "cnst.h"
#include "prot.h"
#include "ivas_prot.h"
+#include "ivas_prot_rend.h"
#include "ivas_cnst.h"
#include "ivas_rom_com.h"
#include "ivas_rom_dec.h"
@@ -49,33 +50,16 @@
/*-----------------------------------------------------------------------*
* Local function prototypes
*-----------------------------------------------------------------------*/
+
static void ivas_dirac_alloc_mem( DIRAC_DEC_HANDLE hDirAC, const RENDERER_TYPE renderer_type, DIRAC_DEC_STACK_MEM_HANDLE hDirAC_mem );
static void ivas_dirac_free_mem( DIRAC_DEC_STACK_MEM_HANDLE hDirAC_mem );
-static void initDiffuseResponses(
- float *diffuse_response_function,
- const int16_t num_channels,
- AUDIO_CONFIG output_config,
- IVAS_OUTPUT_SETUP hOutSetup,
- const int16_t ambisonics_order,
- const IVAS_FORMAT ivas_format,
- int16_t *num_ele_spk_no_diffuse_rendering,
- AUDIO_CONFIG transport_config );
+static void initDiffuseResponses( float *diffuse_response_function, const int16_t num_channels, AUDIO_CONFIG output_config, IVAS_OUTPUT_SETUP hOutSetup, const int16_t ambisonics_order, const IVAS_FORMAT ivas_format, int16_t *num_ele_spk_no_diffuse_rendering, AUDIO_CONFIG transport_config );
static void computeIntensityVector_dec( float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], const int16_t num_frequency_bands, float *intensity_real_x, float *intensity_real_y, float *intensity_real_z );
-static void protoSignalComputation_shd(
- float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX],
- float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX],
- float *proto_direct_buffer_f,
- float *proto_diffuse_buffer_f,
- float *reference_power,
- const int16_t slot_index,
- const int16_t num_inputs,
- const int16_t num_outputs_diff,
- const int16_t num_freq_bands,
- float *p_Rmat );
+static void protoSignalComputation_shd( float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float *proto_direct_buffer_f, float *proto_diffuse_buffer_f, float *reference_power, const int16_t slot_index, const int16_t num_inputs, const int16_t num_outputs_diff, const int16_t num_freq_bands, float *p_Rmat );
static void protoSignalComputation1( float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float *proto_frame_f, float *proto_direct_buffer_f, float *reference_power, float *proto_power_smooth, const int16_t slot_index, const int16_t num_outputs_diff, const int16_t num_freq_bands );
@@ -85,7 +69,6 @@ static void protoSignalComputation4( float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRA
static void ivas_dirac_dec_compute_diffuse_proto( DIRAC_DEC_HANDLE hDirAC, const int16_t slot_idx );
-
static void computeDirectionAngles( float *intensity_real_x, float *intensity_real_y, float *intensity_real_z, const int16_t num_frequency_bands, int16_t *azimuth, int16_t *elevation );
static void ivas_masa_init_stereotype_detection( MASA_STEREO_TYPE_DETECT *stereo_type_detect );
@@ -94,6 +77,8 @@ static void ivas_masa_stereotype_detection( MASA_STEREO_TYPE_DETECT *stereo_type
static void ivas_lfe_synth_with_cldfb( MCMASA_LFE_SYNTH_DATA_HANDLE hMasaLfeSynth, float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float RealBufferLfe[MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float ImagBufferLfe[MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], const int16_t slot_index, const int16_t subframe_index, const int16_t nchan_transport );
+static void rotateAziEle_DirAC( int16_t *azi, int16_t *ele, const int16_t band1, const int16_t band2, const float *p_Rmat );
+
/*-------------------------------------------------------------------------
* ivas_dirac_dec_open()
@@ -3617,3 +3602,48 @@ static void ivas_lfe_synth_with_cldfb(
return;
}
+
+
+/*-------------------------------------------------------------------------
+ * rotateAziEle_DirAC()
+ *
+ * Apply rotation to DirAC DOAs
+ *------------------------------------------------------------------------*/
+
+static void rotateAziEle_DirAC(
+ int16_t *azi, /* i/o: array of azimuth values */
+ int16_t *ele, /* i/o: array of elevation values */
+ const int16_t band1, /* i : bands to work on (lower limit) */
+ const int16_t band2, /* i : bands to work on (upper bound) */
+ const float *p_Rmat /* i : pointer to real-space rotation matrix */
+)
+{
+ int16_t b;
+ float dv_0, dv_1, dv_2;
+ float dv_r_0, dv_r_1, dv_r_2;
+ float w;
+
+ push_wmops( "rotateAziEle_DirAC" );
+
+ for ( b = band1; b < band2; b++ )
+ {
+
+ /*Conversion spherical to cartesian coordinates*/
+ w = cosf( ele[b] * PI_OVER_180 );
+ dv_0 = w * cosf( azi[b] * PI_OVER_180 );
+ dv_1 = w * sinf( azi[b] * PI_OVER_180 );
+ dv_2 = sinf( ele[b] * PI_OVER_180 );
+
+ dv_r_0 = p_Rmat[0] * dv_0 + p_Rmat[1] * dv_1 + p_Rmat[2] * dv_2;
+ dv_r_1 = p_Rmat[3] * dv_0 + p_Rmat[4] * dv_1 + p_Rmat[5] * dv_2;
+ dv_r_2 = p_Rmat[6] * dv_0 + p_Rmat[7] * dv_1 + p_Rmat[8] * dv_2;
+
+ /*Conversion spherical to cartesian coordinates*/
+ azi[b] = (int16_t) ( atan2f( dv_r_1, dv_r_0 ) * _180_OVER_PI );
+ ele[b] = (int16_t) ( atan2f( dv_r_2, sqrtf( dv_r_0 * dv_r_0 + dv_r_1 * dv_r_1 ) ) * _180_OVER_PI );
+ }
+
+ pop_wmops();
+
+ return;
+}
diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c
index 4e49799315f6300e82211243db2f5336a7146c3e..015832ea74ad65fd9f668b66364b2d5b851dca85 100755
--- a/lib_dec/ivas_init_dec.c
+++ b/lib_dec/ivas_init_dec.c
@@ -33,9 +33,9 @@
#include "options.h"
#include "ivas_cnst.h"
#include "ivas_prot.h"
+#include "ivas_prot_rend.h"
#include "ivas_rom_com.h"
#include "ivas_stat_enc.h"
-#include "lib_dec.h"
#include "prot.h"
#include
#include
@@ -1287,8 +1287,8 @@ ivas_error ivas_init_decoder(
}
if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ),
- getRendAudioConfigFromIvasAudioConfig( st_ivas->intern_config ),
- getRendAudioConfigFromIvasAudioConfig( st_ivas->hDecoderConfig->output_config ),
+ st_ivas->intern_config,
+ st_ivas->hDecoderConfig->output_config,
st_ivas->hRenderConfig, st_ivas->hDecoderConfig->Opt_Headrotation,
st_ivas->hSetOfHRTF,
st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
@@ -2107,8 +2107,7 @@ static ivas_error doSanityChecks_IVAS(
if ( st_ivas->hDecoderConfig->Opt_Headrotation )
{
- if ( !( output_config == AUDIO_CONFIG_BINAURAL ||
- output_config == AUDIO_CONFIG_BINAURAL_ROOM ) )
+ if ( !( output_config == AUDIO_CONFIG_BINAURAL || output_config == AUDIO_CONFIG_BINAURAL_ROOM ) )
{
return IVAS_ERROR( IVAS_ERR_HEAD_ROTATION_NOT_SUPPORTED, "Wrong set-up: Head-rotation not supported in this configuration" );
}
@@ -2127,17 +2126,12 @@ static ivas_error doSanityChecks_IVAS(
return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Wrong set-up: Forced subframe resolution parametric binauralization activated for non-binaural output." );
}
}
-#endif
-#ifdef DEBUGGING
if ( ( st_ivas->hDecoderConfig->force_rend == FORCE_TD_RENDERER ) && ( ( st_ivas->ivas_format != MC_FORMAT && st_ivas->ivas_format != ISM_FORMAT ) || output_config != AUDIO_CONFIG_BINAURAL || ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM ) || ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode != MC_MODE_MCT ) ) )
{
return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration: Time Domain object renderer not supported in this configuration" );
}
-#endif
-
-#ifdef DEBUGGING
if ( ( st_ivas->hHrtfTD != NULL && st_ivas->hDecoderConfig->force_rend == FORCE_CLDFB_RENDERER ) )
{
return IVAS_ERROR( IVAS_ERR_INVALID_FORCE_MODE, "Incorrect debug configuration: Cannot force CLDFB renderer in combination with TD renderer HRTF file" );
diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c
index c354ca257e3f02d6f47dbe799384ab2bcdb29590..6f07130d1d2aa77f5c5b4b626b081ec8c64f63f7 100644
--- a/lib_dec/ivas_ism_dec.c
+++ b/lib_dec/ivas_ism_dec.c
@@ -33,6 +33,7 @@
#include
#include "options.h"
#include "ivas_prot.h"
+#include "ivas_prot_rend.h"
#ifdef DEBUGGING
#include "debug.h"
#endif
@@ -122,8 +123,8 @@ static ivas_error ivas_ism_bitrate_switching(
/* Open Crend Binaural renderer */
#ifdef FIX_197_CREND_INTERFACE
if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ),
- getRendAudioConfigFromIvasAudioConfig( st_ivas->intern_config ),
- getRendAudioConfigFromIvasAudioConfig( st_ivas->hOutSetup.output_config ),
+ st_ivas->intern_config,
+ st_ivas->hOutSetup.output_config,
st_ivas->hRenderConfig,
st_ivas->hDecoderConfig->Opt_Headrotation,
st_ivas->hSetOfHRTF,
diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c
index 165dddb54628a60347e91ab561dafe6b416c47d1..dea3e6d6f86d3020472a03d26a96664f83d94954 100644
--- a/lib_dec/ivas_ism_param_dec.c
+++ b/lib_dec/ivas_ism_param_dec.c
@@ -35,6 +35,7 @@
#include
#include "options.h"
#include "ivas_prot.h"
+#include "ivas_prot_rend.h"
#include "prot.h"
#include "ivas_rom_com.h"
#include "ivas_rom_dec.h"
diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c
index 462fedfdc6d0e9320474c7489de8eca2323c3a7a..a965a0ffed38a43b5e3472da691aae20348293ff 100644
--- a/lib_dec/ivas_ism_renderer.c
+++ b/lib_dec/ivas_ism_renderer.c
@@ -29,12 +29,13 @@
the United Nations Convention on Contracts on the International Sales of Goods.
*******************************************************************************************************/
-// VE2AT: move to lib_rend ?
+
#include
#include "options.h"
#include "ivas_cnst.h"
-#include "ivas_prot.h"
#include "prot.h"
+#include "ivas_prot.h"
+#include "ivas_prot_rend.h"
#include "ivas_stat_com.h"
#include "ivas_rom_com.h"
#include "ivas_rom_dec.h"
@@ -186,6 +187,7 @@ void ivas_ism_render(
st_ivas->hIsmRendererData->prev_gains[i][j] = gains[i][j];
}
}
+
/* Move to output skipping LFE */
for ( j = 0, j2 = 0; j < nchan_out_woLFE; j++, j2++ )
{
@@ -195,9 +197,17 @@ void ivas_ism_render(
}
mvr2r( tmp_output_f[j], output_f[j2], output_frame );
}
+
return;
}
+
+/*-------------------------------------------------------------------------*
+ * ivas_ism_get_stereo_gains()
+ *
+ *
+ *-------------------------------------------------------------------------*/
+
void ivas_ism_get_stereo_gains(
const float azimuth, /* i : object azimuth */
const float elevation, /* i : object elevation */
@@ -235,4 +245,6 @@ void ivas_ism_get_stereo_gains(
*left_gain = sqrtf( A3 );
*right_gain = sqrtf( 1.0f - A3 );
}
+
+ return;
}
diff --git a/lib_rend/ivas_ls_custom_dec.c b/lib_dec/ivas_ls_custom_dec.c
similarity index 99%
rename from lib_rend/ivas_ls_custom_dec.c
rename to lib_dec/ivas_ls_custom_dec.c
index 0e3a4d980120b7629efdf38d71d6fd14642ffb29..ef3698ab8c87c4929ffe12a01e4f29eedaafff23 100644
--- a/lib_rend/ivas_ls_custom_dec.c
+++ b/lib_dec/ivas_ls_custom_dec.c
@@ -29,7 +29,6 @@
the United Nations Convention on Contracts on the International Sales of Goods.
*******************************************************************************************************/
-
#include
#include "options.h"
#include "ivas_prot.h"
diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c
index 41ba3e53c7983fe7f5dae8b5d5d77abcdcd75730..745e9c04ff88227e4affec2be93ceb88283b4a90 100644
--- a/lib_dec/ivas_mc_param_dec.c
+++ b/lib_dec/ivas_mc_param_dec.c
@@ -38,6 +38,7 @@
#include "rom_com.h"
#include "prot.h"
#include "ivas_prot.h"
+#include "ivas_prot_rend.h"
#include "ivas_cnst.h"
#include "ivas_rom_com.h"
#include "ivas_rom_dec.h"
@@ -1547,8 +1548,7 @@ void ivas_param_mc_dec(
if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM )
{
- ivas_binRenderer( st_ivas->hBinRenderer, st_ivas->hHeadTrackData,
- Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer );
+ ivas_binRenderer( st_ivas->hBinRenderer, st_ivas->hHeadTrackData, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer );
}
else if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_CLDFB )
{
diff --git a/lib_dec/ivas_mcmasa_dec.c b/lib_dec/ivas_mcmasa_dec.c
index 748f665dce2437936de078aeb0f238ed23a8e91a..20b1ea49ad9e5995898869a1405827a359fab7bd 100644
--- a/lib_dec/ivas_mcmasa_dec.c
+++ b/lib_dec/ivas_mcmasa_dec.c
@@ -34,6 +34,7 @@ the United Nations Convention on Contracts on the International Sales of Goods.
#include
#include "ivas_cnst.h"
#include "ivas_prot.h"
+#include "ivas_prot_rend.h"
#include "prot.h"
#ifdef DEBUGGING
#include "debug.h"
diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c
index 9c8e6407841d1cf2415f332ab4a5855c76797f82..282ca41e2f1f1caea98c56581b5bf264f040d30f 100644
--- a/lib_dec/ivas_mct_dec.c
+++ b/lib_dec/ivas_mct_dec.c
@@ -39,6 +39,7 @@
#include "rom_com.h"
#include "prot.h"
#include "ivas_prot.h"
+#include "ivas_prot_rend.h"
#include "ivas_rom_com.h"
#ifdef DEBUGGING
#include "debug.h"
@@ -1158,8 +1159,8 @@ static ivas_error ivas_mc_dec_reconfig(
else if ( st_ivas->hCrendWrapper == NULL && ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) )
{
if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ),
- getRendAudioConfigFromIvasAudioConfig( st_ivas->intern_config ),
- getRendAudioConfigFromIvasAudioConfig( st_ivas->hDecoderConfig->output_config ),
+ st_ivas->intern_config,
+ st_ivas->hDecoderConfig->output_config,
st_ivas->hRenderConfig, st_ivas->hDecoderConfig->Opt_Headrotation,
st_ivas->hSetOfHRTF,
st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer.c
index 4932e71d51c32adca641a7d6c79c0f194d330f4f..d4dcb7ac7339e69e50347c4061c68b9547d8a3b9 100644
--- a/lib_dec/ivas_mono_dmx_renderer.c
+++ b/lib_dec/ivas_mono_dmx_renderer.c
@@ -29,7 +29,7 @@
the United Nations Convention on Contracts on the International Sales of Goods.
*******************************************************************************************************/
-// VE2AT: move to lib_rend ?
+
#include
#include "options.h"
#include
@@ -124,10 +124,11 @@ void ivas_mono_downmix_render_passive(
return;
}
+
/*-------------------------------------------------------------------------
* ivas_mono_stereo_downmix_mcmasa()
*
- * Downmix process
+ * Downmix process in McMASA
*------------------------------------------------------------------------*/
void ivas_mono_stereo_downmix_mcmasa(
@@ -165,4 +166,6 @@ void ivas_mono_stereo_downmix_mcmasa(
/* Move to output */
mvr2r( dmx_tmp, output_f[0], output_frame );
}
+
+ return;
}
diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c
new file mode 100644
index 0000000000000000000000000000000000000000..1daf799fe7f189c5b444a65bdadb2ec3ddc85d55
--- /dev/null
+++ b/lib_dec/ivas_objectRenderer_internal.c
@@ -0,0 +1,276 @@
+/******************************************************************************************************
+
+ (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+ Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+ Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+ contributors to this repository. All Rights Reserved.
+
+ This software is protected by copyright law and by international treaties.
+ The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
+ Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+ Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+ Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+ contributors to this repository retain full ownership rights in their respective contributions in
+ the software. This notice grants no license of any kind, including but not limited to patent
+ license, nor is any license granted by implication, estoppel or otherwise.
+
+ Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
+ contributions.
+
+ This software is provided "AS IS", without any express or implied warranties. The software is in the
+ development stage. It is intended exclusively for experts who have experience with such software and
+ solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
+ and fitness for a particular purpose are hereby disclaimed and excluded.
+
+ Any dispute, controversy or claim arising under or in relation to providing this software shall be
+ submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
+ accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
+ the United Nations Convention on Contracts on the International Sales of Goods.
+
+*******************************************************************************************************/
+
+#include
+#include "options.h"
+#include "prot.h"
+#include "ivas_prot.h"
+#include "ivas_prot_rend.h"
+#include
+#include "ivas_rom_com.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
+#include "wmc_auto.h"
+
+
+#ifdef FIX_198_TDREND_INTERFACE
+
+/*---------------------------------------------------------------------*
+ * ivas_td_binaural_open()
+ *
+ * Open and initialize TD Object binaural renderer
+ *---------------------------------------------------------------------*/
+
+ivas_error ivas_td_binaural_open(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+)
+{
+ return ivas_td_binaural_open_unwrap( &st_ivas->hHrtfTD, st_ivas->hDecoderConfig->output_Fs, st_ivas->nchan_transport, st_ivas->ivas_format,
+ st_ivas->transport_config, st_ivas->hTransSetup, &st_ivas->hBinRendererTd, &st_ivas->binaural_latency_ns );
+}
+
+#else
+
+/*---------------------------------------------------------------------*
+ * ivas_td_binaural_open()
+ *
+ * Open and initialize TD Object binaural renderer
+ *---------------------------------------------------------------------*/
+
+ivas_error ivas_td_binaural_open(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+)
+{
+ BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd;
+ TDREND_PosType_t PosType;
+ int16_t nS;
+ int16_t SrcInd[MAX_NUM_TDREND_CHANNELS];
+ const float *ls_azimuth, *ls_elevation;
+ float Pos[3];
+ float Dir[3];
+ TDREND_DirAtten_t *DirAtten_p;
+ int16_t nchan_rend;
+ ivas_error error;
+
+ error = IVAS_ERR_OK;
+
+ if ( ( hBinRendererTd = malloc( sizeof( BINAURAL_TD_OBJECT_RENDERER ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD renderer\n" ) );
+ }
+ if ( ( hBinRendererTd->TdRend_MixSpatSpec_p = malloc( sizeof( TDREND_MixSpatSpec_t ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD renderer\n" ) );
+ }
+ if ( ( hBinRendererTd->DirAtten_p = malloc( sizeof( TDREND_DirAtten_t ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD renderer\n" ) );
+ }
+ if ( ( hBinRendererTd->Listener_p = malloc( sizeof( TDREND_MIX_Listener_t ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD renderer\n" ) );
+ }
+
+ hBinRendererTd->NumOfSrcs = 0;
+ hBinRendererTd->MaxSrcInd = -1;
+
+ /* Mixer spatial setup */
+ hBinRendererTd->TdRend_MixSpatSpec_p->UseCommonDistAttenModel = TRUE;
+ hBinRendererTd->TdRend_MixSpatSpec_p->DistAttenModel = 0; /* 0=Turned off, else use TDREND_DIST_ATTEN_MODEL_INV_DIST_CLAMPED */
+
+ TDREND_MIX_Init( hBinRendererTd, &st_ivas->hHrtfTD, hBinRendererTd->TdRend_MixSpatSpec_p, st_ivas->hDecoderConfig->output_Fs );
+
+ /* Set the attenuation (or can set MixSpatSpec.DistAttenModel above) */
+ TDREND_MIX_SetDistAttenModel( hBinRendererTd, TDREND_DIST_ATTEN_MODEL_INV_DIST_CLAMPED );
+
+ /* Add sources to module and mixer, headphones */
+ PosType = TDREND_POSTYPE_ABSOLUTE; /* or TDREND_POSTYPE_RELATIVE_TO_LISTENER */
+
+ nchan_rend = st_ivas->nchan_transport;
+ if ( st_ivas->ivas_format == MC_FORMAT )
+ {
+ nchan_rend--; /* Skip LFE channel -- added to the others */
+ }
+
+ for ( nS = 0; nS < nchan_rend; nS++ )
+ {
+ if ( ( error = TDREND_MIX_AddSrc( hBinRendererTd, &SrcInd[nS], PosType ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+
+ if ( st_ivas->ivas_format == MC_FORMAT )
+ {
+ switch ( st_ivas->transport_config )
+ {
+ case AUDIO_CONFIG_5_1:
+ ls_azimuth = ls_azimuth_CICP6;
+ ls_elevation = ls_elevation_CICP6;
+ break;
+ case AUDIO_CONFIG_7_1:
+ ls_azimuth = ls_azimuth_CICP12;
+ ls_elevation = ls_elevation_CICP12;
+ break;
+ case AUDIO_CONFIG_5_1_2:
+ ls_azimuth = ls_azimuth_CICP14;
+ ls_elevation = ls_elevation_CICP14;
+ break;
+ case AUDIO_CONFIG_5_1_4:
+ ls_azimuth = ls_azimuth_CICP16;
+ ls_elevation = ls_elevation_CICP16;
+ break;
+ case AUDIO_CONFIG_7_1_4:
+ ls_azimuth = ls_azimuth_CICP19;
+ ls_elevation = ls_elevation_CICP19;
+ break;
+ case AUDIO_CONFIG_LS_CUSTOM:
+ ls_azimuth = st_ivas->hTransSetup.ls_azimuth;
+ ls_elevation = st_ivas->hTransSetup.ls_elevation;
+ break;
+ default:
+ ls_azimuth = NULL;
+ ls_elevation = NULL;
+ }
+
+ DirAtten_p = hBinRendererTd->DirAtten_p;
+
+ for ( nS = 0; nS < nchan_rend; nS++ )
+ {
+ /* Set source positions according to loudspeaker layout */
+ Pos[0] = cosf( ls_elevation[nS] * PI_OVER_180 ) * cosf( ls_azimuth[nS] * PI_OVER_180 );
+ Pos[1] = cosf( ls_elevation[nS] * PI_OVER_180 ) * sinf( ls_azimuth[nS] * PI_OVER_180 );
+ Pos[2] = sinf( ls_elevation[nS] * PI_OVER_180 );
+ Dir[0] = 1.0f;
+ Dir[1] = 0.0f;
+ Dir[2] = 0.0f;
+
+ /* Source directivity info */
+ DirAtten_p->ConeInnerAngle = 360.0f;
+ DirAtten_p->ConeOuterAngle = 360.0f;
+ DirAtten_p->ConeOuterGain = 1.0f;
+
+ TDREND_MIX_SRC_SetPos( hBinRendererTd, nS, Pos );
+ TDREND_MIX_SRC_SetDir( hBinRendererTd, nS, Dir );
+ TDREND_MIX_SRC_SetPlayState( hBinRendererTd, nS, TDREND_PLAYSTATUS_PLAYING );
+ TDREND_MIX_SRC_SetDirAtten( hBinRendererTd, nS, DirAtten_p );
+ }
+ }
+
+ st_ivas->hBinRendererTd = hBinRendererTd;
+
+ st_ivas->binaural_latency_ns = (int32_t) ( hBinRendererTd->HrFiltSet_p->latency_s * 1000000000.f );
+
+ return error;
+}
+#endif
+
+
+/*---------------------------------------------------------------------*
+ * ivas_td_binaural_renderer()
+ *
+ * Receives the current frames for the object streams, updates metadata
+ * and renders the current frame.
+ *---------------------------------------------------------------------*/
+
+void ivas_td_binaural_renderer(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ float output[][L_FRAME48k], /* i/o: SCE channels / Binaural synthesis */
+ const int16_t output_frame /* i : output frame length */
+)
+{
+#ifdef FIX_198_TDREND_INTERFACE
+ ivas_td_binaural_renderer_unwrap( st_ivas->hRenderConfig, st_ivas->ini_frame,
+#ifdef FIX_197_CREND_INTERFACE
+ st_ivas->hCrendWrapper,
+#else
+ st_ivas->hCrend,
+#endif
+ st_ivas->transport_config,
+ st_ivas->hDecoderConfig->output_Fs, st_ivas->hBinRendererTd, st_ivas->nchan_transport, LFE_CHANNEL, st_ivas->ivas_format,
+ st_ivas->hIsmMetaData, st_ivas->hDecoderConfig->Opt_Headrotation, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->Quaternions : NULL, output, output_frame );
+#else
+ int16_t subframe_length;
+ int16_t subframe_idx;
+ float reverb_signal[BINAURAL_CHANNELS][L_FRAME48k];
+
+ subframe_length = output_frame / MAX_PARAM_SPATIAL_SUBFRAMES;
+ if ( st_ivas->hRenderConfig != NULL ) /* Renderer Configuration not enabled in TD standalone renderer */
+ {
+
+ if ( st_ivas->hRenderConfig->roomAcoustics.late_reverb_on && ( st_ivas->ini_frame == 0 ) )
+ {
+#ifdef FIX_197_CREND_INTERFACE
+ ivas_reverb_open( &st_ivas->hCrendWrapper->hCrend->hReverb, st_ivas->transport_config, NULL, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs );
+#else
+ ivas_reverb_open( &st_ivas->hCrend->hReverb, st_ivas->transport_config, NULL, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs );
+#endif
+ }
+ }
+
+ /* Update object position(s) */
+ TDREND_Update_object_positions( st_ivas->hBinRendererTd, st_ivas->nchan_transport, LFE_CHANNEL, st_ivas->ivas_format, st_ivas->hIsmMetaData, output );
+
+ for ( subframe_idx = 0; subframe_idx < MAX_PARAM_SPATIAL_SUBFRAMES; subframe_idx++ )
+ {
+ /* Update the listener's location/orientation */
+ TDREND_Update_listener_orientation( st_ivas->hBinRendererTd,
+ st_ivas->hDecoderConfig->Opt_Headrotation,
+ ( st_ivas->hHeadTrackData != NULL ) ? &st_ivas->hHeadTrackData->Quaternions[subframe_idx] : NULL );
+
+ if ( ( st_ivas->hRenderConfig != NULL ) && ( st_ivas->hRenderConfig->roomAcoustics.late_reverb_on ) )
+ {
+#ifdef FIX_197_CREND_INTERFACE
+ ivas_reverb_process( st_ivas->hCrendWrapper->hCrend->hReverb, st_ivas->transport_config, 0, output, reverb_signal, subframe_idx );
+#else
+ ivas_reverb_process( st_ivas->hCrend->hReverb, st_ivas->transport_config, 0, output, reverb_signal, subframe_idx );
+#endif
+ }
+
+ /* Render subframe */
+ TDREND_GetMix( st_ivas->hBinRendererTd, output, subframe_length, subframe_idx );
+ }
+
+ if ( st_ivas->hRenderConfig != NULL ) /* Renderer Configuration not enabled in TD standalone renderer */
+ {
+ if ( st_ivas->hRenderConfig->roomAcoustics.late_reverb_on )
+ {
+ /* add reverb to rendered signals */
+ v_add( reverb_signal[0], output[0], output[0], output_frame );
+ v_add( reverb_signal[1], output[1], output[1], output_frame );
+ }
+ }
+
+ return;
+#endif
+}
diff --git a/lib_dec/ivas_out_setup_conversion.c b/lib_dec/ivas_out_setup_conversion.c
index 0e553b4759945bb243e8f96029a497d11c286221..787ceaaf44ac7fe6059d334b85d545214aaf240c 100644
--- a/lib_dec/ivas_out_setup_conversion.c
+++ b/lib_dec/ivas_out_setup_conversion.c
@@ -29,19 +29,20 @@
the United Nations Convention on Contracts on the International Sales of Goods.
*******************************************************************************************************/
-// VE2AT: move to lib_rend ?
-#include
+
#include
#include "options.h"
#include
-#include "ivas_prot.h"
+#include
#include "prot.h"
+#include "ivas_prot.h"
+#include "ivas_prot_rend.h"
+#include "ivas_rom_com.h"
+#include "ivas_rom_rend.h"
#ifdef DEBUGGING
#include "debug.h"
#endif
#include "wmc_auto.h"
-#include "ivas_rom_com.h"
-#include "ivas_rom_dec.h"
/*----------------------------------------------------------------------------------*
diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c
new file mode 100644
index 0000000000000000000000000000000000000000..f38e810ce3289158e5f66ac2feb42be54c22d57b
--- /dev/null
+++ b/lib_dec/ivas_output_config.c
@@ -0,0 +1,405 @@
+/******************************************************************************************************
+
+ (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+ Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+ Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+ contributors to this repository. All Rights Reserved.
+
+ This software is protected by copyright law and by international treaties.
+ The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
+ Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+ Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+ Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+ contributors to this repository retain full ownership rights in their respective contributions in
+ the software. This notice grants no license of any kind, including but not limited to patent
+ license, nor is any license granted by implication, estoppel or otherwise.
+
+ Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
+ contributions.
+
+ This software is provided "AS IS", without any express or implied warranties. The software is in the
+ development stage. It is intended exclusively for experts who have experience with such software and
+ solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
+ and fitness for a particular purpose are hereby disclaimed and excluded.
+
+ Any dispute, controversy or claim arising under or in relation to providing this software shall be
+ submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
+ accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
+ the United Nations Convention on Contracts on the International Sales of Goods.
+
+*******************************************************************************************************/
+
+#include
+#include "options.h"
+#include "ivas_cnst.h"
+#include "ivas_prot.h"
+#include "ivas_stat_dec.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#include
+#endif
+#include "wmc_auto.h"
+
+
+/*-------------------------------------------------------------------------*
+ * ivas_renderer_select()
+ *
+ * Select and configure IVAS renderer parameters
+ *-------------------------------------------------------------------------*/
+
+void ivas_renderer_select(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+)
+{
+ RENDERER_TYPE *renderer_type;
+ AUDIO_CONFIG *internal_config;
+ AUDIO_CONFIG output_config;
+ AUDIO_CONFIG transport_config;
+
+ int16_t nchan_internal;
+
+ renderer_type = &( st_ivas->renderer_type );
+ internal_config = &( st_ivas->intern_config );
+ output_config = st_ivas->hDecoderConfig->output_config;
+ transport_config = st_ivas->transport_config;
+
+ /* disabled rendering by default */
+ *renderer_type = RENDERER_DISABLE;
+
+ /*-----------------------------------------------------------------*
+ * Binaural rendering configurations
+ *-----------------------------------------------------------------*/
+
+ if ( st_ivas->hDecoderConfig->Opt_Headrotation )
+ {
+ st_ivas->hHeadTrackData->shd_rot_max_order = -1;
+ }
+
+ if ( output_config == AUDIO_CONFIG_BINAURAL || output_config == AUDIO_CONFIG_BINAURAL_ROOM )
+ {
+ if ( st_ivas->ivas_format == ISM_FORMAT )
+ {
+ if ( st_ivas->ism_mode == ISM_MODE_PARAM )
+ {
+ if ( output_config == AUDIO_CONFIG_BINAURAL )
+ {
+ *renderer_type = RENDERER_BINAURAL_PARAMETRIC;
+ }
+ else
+ {
+ *renderer_type = RENDERER_BINAURAL_PARAMETRIC_ROOM;
+ }
+ }
+ else /* ISM_MODE_DISC */
+ {
+ if ( output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hRenderConfig->roomAcoustics.use_brir == 0 )
+ {
+#ifdef DEBUGGING
+ if ( st_ivas->hDecoderConfig->force_rend == FORCE_CLDFB_RENDERER )
+ {
+ *renderer_type = RENDERER_BINAURAL_FASTCONV;
+ *internal_config = AUDIO_CONFIG_HOA3; /* Render ISM to HOA3 before binauralization*/
+ }
+ else
+ {
+ *renderer_type = RENDERER_BINAURAL_OBJECTS_TD;
+ *internal_config = AUDIO_CONFIG_BINAURAL;
+ }
+#else
+ *renderer_type = RENDERER_BINAURAL_OBJECTS_TD;
+ *internal_config = AUDIO_CONFIG_BINAURAL;
+#endif
+ }
+ else
+ {
+ *renderer_type = RENDERER_BINAURAL_MIXER_CONV_ROOM;
+#if defined( DEBUGGING )
+ if ( st_ivas->hRenderConfig->renderer_type_override == RENDER_TYPE_OVERRIDE_FASTCONV )
+ {
+ *renderer_type = RENDERER_BINAURAL_FASTCONV_ROOM;
+ }
+#endif
+ *internal_config = AUDIO_CONFIG_7_1_4;
+ }
+ }
+ }
+ else if ( st_ivas->ivas_format == MASA_FORMAT || ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->nchan_transport <= 2 ) )
+ {
+ *internal_config = output_config;
+ if ( output_config == AUDIO_CONFIG_BINAURAL )
+ {
+ *renderer_type = RENDERER_BINAURAL_PARAMETRIC;
+ }
+ else
+ {
+ *renderer_type = RENDERER_BINAURAL_PARAMETRIC_ROOM;
+ }
+ }
+ else if ( st_ivas->ivas_format == SBA_FORMAT )
+ {
+ *internal_config = AUDIO_CONFIG_HOA3;
+
+ if ( output_config == AUDIO_CONFIG_BINAURAL )
+ {
+ *renderer_type = RENDERER_BINAURAL_FASTCONV;
+ }
+ else
+ {
+ *renderer_type = RENDERER_BINAURAL_FASTCONV_ROOM;
+ }
+
+ if ( st_ivas->hDecoderConfig->Opt_Headrotation )
+ {
+
+ nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order );
+ if ( nchan_internal == 2 )
+ {
+ st_ivas->hHeadTrackData->shd_rot_max_order = 1;
+ }
+ else if ( nchan_internal == 4 || nchan_internal == 3 )
+ {
+ st_ivas->hHeadTrackData->shd_rot_max_order = 0;
+ }
+ else if ( nchan_internal == 6 || nchan_internal == 5 )
+ {
+ st_ivas->hHeadTrackData->shd_rot_max_order = 2;
+ }
+ else if ( nchan_internal == 8 || nchan_internal == 7 )
+ {
+ st_ivas->hHeadTrackData->shd_rot_max_order = 3;
+ }
+ }
+ }
+ else if ( st_ivas->ivas_format == MC_FORMAT )
+ {
+ if ( st_ivas->mc_mode == MC_MODE_MCMASA )
+ {
+ *internal_config = output_config;
+ if ( output_config == AUDIO_CONFIG_BINAURAL )
+ {
+ *renderer_type = RENDERER_BINAURAL_PARAMETRIC;
+ }
+ else
+ {
+ *renderer_type = RENDERER_BINAURAL_PARAMETRIC_ROOM;
+ }
+ }
+ else
+ {
+ *internal_config = transport_config;
+ if ( output_config == AUDIO_CONFIG_BINAURAL )
+ {
+#ifdef DEBUGGING
+ if ( ( ( ( st_ivas->transport_config == AUDIO_CONFIG_5_1 || st_ivas->transport_config == AUDIO_CONFIG_7_1 ) && st_ivas->hDecoderConfig->Opt_Headrotation ) || ( st_ivas->hDecoderConfig->force_rend == FORCE_TD_RENDERER ) ) && ( st_ivas->mc_mode == MC_MODE_MCT ) && !( st_ivas->hDecoderConfig->force_rend == FORCE_CLDFB_RENDERER ) )
+#else
+ if ( ( st_ivas->transport_config == AUDIO_CONFIG_5_1 || st_ivas->transport_config == AUDIO_CONFIG_7_1 ) && st_ivas->hDecoderConfig->Opt_Headrotation && ( st_ivas->mc_mode == MC_MODE_MCT ) )
+#endif
+ {
+ *renderer_type = RENDERER_BINAURAL_OBJECTS_TD;
+ }
+ else
+ {
+ if ( st_ivas->mc_mode == MC_MODE_MCT )
+ {
+ *renderer_type = RENDERER_BINAURAL_MIXER_CONV;
+ }
+ else
+ {
+ *renderer_type = RENDERER_BINAURAL_FASTCONV;
+ }
+
+#ifdef DEBUGGING
+ if ( st_ivas->hRenderConfig->renderer_type_override == RENDER_TYPE_OVERRIDE_CREND )
+ {
+ *renderer_type = RENDERER_BINAURAL_MIXER_CONV;
+ }
+ else if ( st_ivas->hRenderConfig->renderer_type_override == RENDER_TYPE_OVERRIDE_FASTCONV )
+ {
+ *renderer_type = RENDERER_BINAURAL_FASTCONV;
+ }
+#endif
+ if ( st_ivas->hDecoderConfig->Opt_Headrotation )
+ {
+ /* force HOA3 domain for rotation*/
+ *internal_config = AUDIO_CONFIG_HOA3;
+ }
+ }
+ }
+ else /* AUDIO_CONFIG_BINAURAL_ROOM */
+ {
+ if ( st_ivas->mc_mode == MC_MODE_MCT )
+ {
+ *renderer_type = RENDERER_BINAURAL_MIXER_CONV_ROOM;
+ }
+ else
+ {
+ *renderer_type = RENDERER_BINAURAL_FASTCONV_ROOM;
+ }
+#ifdef DEBUGGING
+ if ( st_ivas->hRenderConfig->renderer_type_override == RENDER_TYPE_OVERRIDE_CREND )
+ {
+ *renderer_type = RENDERER_BINAURAL_MIXER_CONV_ROOM;
+ }
+ else if ( st_ivas->hRenderConfig->renderer_type_override == RENDER_TYPE_OVERRIDE_FASTCONV )
+ {
+ *renderer_type = RENDERER_BINAURAL_FASTCONV_ROOM;
+ }
+#endif
+ }
+ }
+ }
+ }
+
+ /*-----------------------------------------------------------------*
+ * Non-binaural rendering configurations
+ *-----------------------------------------------------------------*/
+
+ else if ( st_ivas->ivas_format == STEREO_FORMAT )
+ {
+ if ( output_config != AUDIO_CONFIG_STEREO && output_config != AUDIO_CONFIG_MONO )
+ {
+ *renderer_type = RENDERER_MC;
+ }
+ }
+ else if ( st_ivas->ivas_format == ISM_FORMAT )
+ {
+ if ( st_ivas->ism_mode == ISM_MODE_PARAM )
+ {
+ *renderer_type = RENDERER_PARAM_ISM;
+ if ( output_config == AUDIO_CONFIG_MONO )
+ {
+ *renderer_type = RENDERER_MONO_DOWNMIX;
+ }
+ else if ( output_config == AUDIO_CONFIG_STEREO )
+ {
+ *renderer_type = RENDERER_DISABLE;
+ }
+ else if ( output_config == AUDIO_CONFIG_FOA || output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_HOA3 )
+ {
+ *renderer_type = RENDERER_SBA_LINEAR_ENC;
+ *internal_config = AUDIO_CONFIG_7_1_4;
+ }
+ }
+ else /* ISM_MODE_DISC */
+ {
+ *renderer_type = RENDERER_TD_PANNING;
+ if ( output_config == AUDIO_CONFIG_MONO )
+ {
+ *renderer_type = RENDERER_MONO_DOWNMIX;
+ }
+ else if ( output_config == AUDIO_CONFIG_FOA || output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_HOA3 )
+ {
+ *renderer_type = RENDERER_SBA_LINEAR_ENC;
+ }
+ else if ( output_config == AUDIO_CONFIG_EXTERNAL )
+ {
+ *renderer_type = RENDERER_DISABLE;
+ }
+ }
+ }
+ else if ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == SBA_FORMAT )
+ {
+ *renderer_type = RENDERER_DIRAC;
+
+ if ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->sba_mode == SBA_MODE_SPAR &&
+ ( output_config != AUDIO_CONFIG_5_1 && output_config != AUDIO_CONFIG_5_1_2 && output_config != AUDIO_CONFIG_5_1_4 && output_config != AUDIO_CONFIG_7_1 && output_config != AUDIO_CONFIG_7_1_4 && output_config != AUDIO_CONFIG_LS_CUSTOM ) )
+ {
+ if ( output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_FOA )
+ {
+ *internal_config = output_config;
+ }
+ else if ( output_config == AUDIO_CONFIG_MONO || output_config == AUDIO_CONFIG_STEREO )
+ {
+ *internal_config = AUDIO_CONFIG_FOA;
+ }
+ else
+ {
+ *internal_config = AUDIO_CONFIG_HOA3;
+ }
+ st_ivas->renderer_type = RENDERER_SBA_LINEAR_DEC;
+ }
+ else if ( ( st_ivas->ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_MONO && st_ivas->nchan_transport == 1 ) ||
+ ( st_ivas->ivas_format == SBA_FORMAT && output_config == AUDIO_CONFIG_STEREO && st_ivas->nchan_transport == 1 ) )
+ {
+ *renderer_type = RENDERER_DISABLE;
+ }
+ else if ( ( st_ivas->ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_MONO && st_ivas->hDecoderConfig->ivas_total_brate < MASA_STEREO_MIN_BITRATE && st_ivas->hDecoderConfig->ivas_total_brate > IVAS_SID_5k2 ) )
+ {
+ *renderer_type = RENDERER_DISABLE;
+ }
+ else if ( st_ivas->ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_STEREO )
+ {
+ *renderer_type = RENDERER_STEREO_PARAMETRIC;
+ }
+ else if ( st_ivas->ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_EXTERNAL )
+ {
+ *renderer_type = RENDERER_DISABLE;
+ }
+ else if ( st_ivas->ivas_format == SBA_FORMAT && output_config == AUDIO_CONFIG_MONO )
+ {
+ *renderer_type = RENDERER_SBA_LINEAR_DEC;
+ }
+ }
+ else if ( st_ivas->ivas_format == MC_FORMAT )
+ {
+ *internal_config = transport_config;
+ if ( st_ivas->mc_mode == MC_MODE_MCT && *internal_config != output_config )
+ {
+ if ( output_config != AUDIO_CONFIG_FOA && output_config != AUDIO_CONFIG_HOA2 && output_config != AUDIO_CONFIG_HOA3 )
+ {
+ *renderer_type = RENDERER_MC;
+ }
+ else
+ {
+ *renderer_type = RENDERER_SBA_LINEAR_ENC;
+ }
+ }
+ else if ( st_ivas->mc_mode == MC_MODE_PARAMMC )
+ {
+ if ( output_config == AUDIO_CONFIG_FOA || output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_HOA3 )
+ {
+ *renderer_type = RENDERER_SBA_LINEAR_ENC;
+ }
+ else
+ {
+ *renderer_type = RENDERER_MC_PARAMMC;
+ }
+ }
+ else if ( st_ivas->mc_mode == MC_MODE_MCMASA )
+ {
+ *internal_config = output_config;
+ /* No rendering for 1TC to Mono or Stereo and 2TC to Stereo */
+ if ( output_config == AUDIO_CONFIG_MONO || output_config == AUDIO_CONFIG_STEREO )
+ {
+ if ( st_ivas->nchan_transport == 1 )
+ {
+ *renderer_type = RENDERER_DISABLE;
+ }
+ else if ( output_config == AUDIO_CONFIG_STEREO && st_ivas->nchan_transport == 2 && !st_ivas->hOutSetup.separateChannelEnabled )
+ {
+ *renderer_type = RENDERER_DISABLE;
+ }
+ else
+ {
+ *renderer_type = RENDERER_MCMASA_MONO_STEREO;
+ }
+ }
+ else
+ {
+ *renderer_type = RENDERER_DIRAC;
+ if ( output_config == AUDIO_CONFIG_FOA || output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_HOA3 )
+ {
+ *renderer_type = RENDERER_SBA_LINEAR_ENC;
+ *internal_config = transport_config;
+ }
+ else if ( transport_config == AUDIO_CONFIG_5_1 && ( output_config == AUDIO_CONFIG_7_1 || output_config == AUDIO_CONFIG_5_1_4 ) )
+ {
+ *internal_config = transport_config;
+ }
+ }
+ }
+ }
+
+ return;
+}
diff --git a/lib_dec/ivas_rom_dec.c b/lib_dec/ivas_rom_dec.c
index e9e107e863b7a4cc1f65ed13dbd852e3a8021208..664c7308167cf9db41b843d450aa9c496ba78d8b 100644
--- a/lib_dec/ivas_rom_dec.c
+++ b/lib_dec/ivas_rom_dec.c
@@ -533,43 +533,4 @@ const int16_t sba_map_tc[8] =
};
-/*----------------------------------------------------------------------------------*
- * FASTCONV and PARAMETRIC binaural renderer ROM tables
- *----------------------------------------------------------------------------------*/
-// VE2AT: move to in ivas_rom_dec ?
-const float surCohEne[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS] =
-{
- 3.0903f, 2.0053f, 1.0860f, 0.8072f, 0.7079f
-};
-
-const float spreadCohEne05[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS] =
-{
- 2.3988f, 1.7783f, 1.1220f, 1.1220f, 1.1220f
-};
-
-const float spreadCohEne1[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS] =
-{
- 1.5975f, 1.1220f, 1.1220f, 1.1220f, 1.1220f
-};
-
-const float lowBitRateBinauralEQ[LOW_BIT_RATE_BINAURAL_EQ_BINS] =
-{
- 0.979f, 0.893f, 0.762f, 0.615f, 0.52f, 0.48f, 0.477f, 0.477f, 0.48f, 0.501f, 0.546f, 0.602f, 0.652f, 0.664f, 0.652f, 0.639f, 0.635f
-};
-
-const float diffuseFieldCoherenceDifferenceX[BINAURAL_COHERENCE_DIFFERENCE_BINS] =
-{
- 0.047421f, 0.19773f, 0.22582f, 0.10637f, 0.0087111f, 0.012028f, 0.031972f, 0.019668f, 0.0079928f
-};
-
-const float diffuseFieldCoherenceDifferenceY[BINAURAL_COHERENCE_DIFFERENCE_BINS] =
-{
- -0.095628f, -0.30569f, -0.34427f, -0.15425f, -0.044628f, -0.057224f, -0.050835f, -0.035214f, -0.02215f
-};
-
-const float diffuseFieldCoherenceDifferenceZ[BINAURAL_COHERENCE_DIFFERENCE_BINS] =
-{
- 0.048207f, 0.10796f, 0.11845f, 0.047886f, 0.035917f, 0.045196f, 0.018863f, 0.015547f, 0.014157f
-};
-
/* clang-format on */
diff --git a/lib_dec/ivas_rom_dec.h b/lib_dec/ivas_rom_dec.h
index 0f40b07c2afe8c503b8dbb4f2d00f1abc8f6057a..3931d527514ea490cf2578d122897706dbb8ae2f 100644
--- a/lib_dec/ivas_rom_dec.h
+++ b/lib_dec/ivas_rom_dec.h
@@ -117,50 +117,5 @@ extern const float ap_split_frequencies[DIRAC_DECORR_NUM_SPLIT_BANDS + 1];
extern const int16_t sba_map_tc[8];
-/*----------------------------------------------------------------------------------*
- * LS Configuration Converter ROM tables
- *----------------------------------------------------------------------------------*/
-
-/* Downmix matrices */
-extern const float ls_conversion_cicpX_mono[12][1];
-extern const float ls_conversion_cicpX_stereo[12][2];
-extern const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp6[];
-extern const LS_CONVERSION_MATRIX ls_conversion_cicp14_cicp6[];
-extern const LS_CONVERSION_MATRIX ls_conversion_cicp14_cicp12[];
-extern const LS_CONVERSION_MATRIX ls_conversion_cicp16_cicp6[];
-extern const LS_CONVERSION_MATRIX ls_conversion_cicp16_cicp14[];
-extern const LS_CONVERSION_MATRIX ls_conversion_cicp19_cicp6[];
-extern const LS_CONVERSION_MATRIX ls_conversion_cicp19_cicp12[];
-extern const LS_CONVERSION_MATRIX ls_conversion_cicp19_cicp14[];
-extern const LS_CONVERSION_MATRIX ls_conversion_cicp19_cicp16[];
-
-/* Upmix matrices */
-extern const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp14[];
-extern const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp16[];
-extern const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp19[];
-extern const LS_CONVERSION_MATRIX ls_conversion_cicp14_cicp19[];
-extern const LS_CONVERSION_MATRIX ls_conversion_cicp16_cicp19[];
-
-/* Mapping table of input config : output config with corresponding matrix */
-extern const LS_CONVERSION_MAPPING ls_conversion_mapping[];
-
-
-/*----------------------------------------------------------------------------------*
- * FASTCONV and PARAMETRIC binaural renderer ROM tables
- *----------------------------------------------------------------------------------*/
-
-/* These are equalization values for spread and surround coherent sounds, approximating the spectrum
- * for such sounds at anechoic multichannel listening. */
-extern const float surCohEne[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS];
-extern const float spreadCohEne05[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS];
-extern const float spreadCohEne1[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS];
-
-/* Values for low-bit-rate equalization */
-extern const float lowBitRateBinauralEQ[LOW_BIT_RATE_BINAURAL_EQ_BINS];
-
-/* Diffuse field binaural coherence directional adjustment values */
-extern const float diffuseFieldCoherenceDifferenceX[BINAURAL_COHERENCE_DIFFERENCE_BINS];
-extern const float diffuseFieldCoherenceDifferenceY[BINAURAL_COHERENCE_DIFFERENCE_BINS];
-extern const float diffuseFieldCoherenceDifferenceZ[BINAURAL_COHERENCE_DIFFERENCE_BINS];
#endif
diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c
index b251bed572136b541d412b0b8c848f2f3cc054e8..848879983d38d7573cc13620a5203d608dde96d1 100644
--- a/lib_dec/ivas_sba_dec.c
+++ b/lib_dec/ivas_sba_dec.c
@@ -37,6 +37,7 @@
#include "ivas_cnst.h"
#include "prot.h"
#include "ivas_prot.h"
+#include "ivas_prot_rend.h"
#ifdef SBA_BR_SWITCHING
#include "ivas_rom_com.h"
#endif
@@ -668,9 +669,9 @@ ivas_error ivas_sba_dec_reconfigure(
hSpar->hMdDec->table_idx = -1;
/* TD decorr. */
- ivas_spar_td_decorr_dec_close( &hSpar->hTdDecorr );
+ ivas_td_decorr_dec_close( &hSpar->hTdDecorr );
- if ( ( error = ivas_spar_td_decorr_dec_open( &hSpar->hTdDecorr, hDecoderConfig->output_Fs, nchan_internal, 1 ) ) != IVAS_ERR_OK )
+ if ( ( error = ivas_td_decorr_dec_open( &hSpar->hTdDecorr, hDecoderConfig->output_Fs, nchan_internal, 1 ) ) != IVAS_ERR_OK )
{
return error;
}
diff --git a/lib_dec/ivas_sba_dirac_stereo_dec.c b/lib_dec/ivas_sba_dirac_stereo_dec.c
index f8f57ae53c5cdbbed24ba5706537028fb4e6b661..bbd612b7ec7d4a6c1b7ebec80d28f91601f56fad 100644
--- a/lib_dec/ivas_sba_dirac_stereo_dec.c
+++ b/lib_dec/ivas_sba_dirac_stereo_dec.c
@@ -964,16 +964,12 @@ void ivas_sba_dirac_stereo_dec(
mvr2r( tmp_buf, hSCE->prev_hb_synth, memOffset );
}
- if ( ( hCPE->hCoreCoder[0]->core == ACELP_CORE || hCPE->hCoreCoder[0]->last_core == ACELP_CORE ) && !fd_cng_flag
-#if defined DFT_STEREO_SPAR_MIXING && defined FIX_345_MSAN_ERROR
- && st_ivas->nchan_transport == 1
-#endif
- )
+ if ( ( hCPE->hCoreCoder[0]->core == ACELP_CORE || hCPE->hCoreCoder[0]->last_core == ACELP_CORE ) && !fd_cng_flag )
{
/* upmix ACELP BWE */
ivas_sba_dirac_stereo_compute_hb_gain( hStereoDft, hb_gain );
-#if defined DFT_STEREO_SPAR_MIXING && !defined FIX_345_MSAN_ERROR
+#ifdef DFT_STEREO_SPAR_MIXING
if ( st_ivas->nchan_transport == 1 )
#endif
{
diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c
new file mode 100644
index 0000000000000000000000000000000000000000..bd799f9d5fbff0499d68a83b4c26734f0a779ab9
--- /dev/null
+++ b/lib_dec/ivas_sba_rendering_internal.c
@@ -0,0 +1,629 @@
+/******************************************************************************************************
+
+ (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+ Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+ Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+ contributors to this repository. All Rights Reserved.
+
+ This software is protected by copyright law and by international treaties.
+ The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
+ Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+ Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+ Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+ contributors to this repository retain full ownership rights in their respective contributions in
+ the software. This notice grants no license of any kind, including but not limited to patent
+ license, nor is any license granted by implication, estoppel or otherwise.
+
+ Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
+ contributions.
+
+ This software is provided "AS IS", without any express or implied warranties. The software is in the
+ development stage. It is intended exclusively for experts who have experience with such software and
+ solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
+ and fitness for a particular purpose are hereby disclaimed and excluded.
+
+ Any dispute, controversy or claim arising under or in relation to providing this software shall be
+ submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
+ accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
+ the United Nations Convention on Contracts on the International Sales of Goods.
+
+*******************************************************************************************************/
+
+#include
+#include "options.h"
+#include "prot.h"
+#include "ivas_prot.h"
+#include "ivas_prot_rend.h"
+#include "ivas_stat_dec.h"
+#include "ivas_cnst.h"
+#include
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
+#include "wmc_auto.h"
+
+
+#ifdef DEBUG_MODE_DIRAC
+/*-----------------------------------------------------------------------*
+ * Local function prototypes
+ *-----------------------------------------------------------------------*/
+
+static void debug_mode_dirac( float output[MAX_OUTPUT_CHANNELS][L_FRAME48k], const int16_t nchan_transport, const int16_t output_frame );
+#endif
+
+
+/*-------------------------------------------------------------------------*
+ * ivas_sba2MC_cldfb()
+ *
+ * SBA signals transformed into MC in CLDFB domain
+ *-------------------------------------------------------------------------*/
+
+void ivas_sba2mc_cldfb(
+ IVAS_OUTPUT_SETUP hInSetup, /* i : Format of input layout */
+ float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: cldfb real part */
+ float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: cldfb imag part */
+ const int16_t nb_channels_out, /* i : nb of output channels */
+ const int16_t nb_bands, /* i : nb of CLDFB bands to process */
+ const float *hoa_dec_mtx /* i : HOA decoding mtx */
+)
+{
+ int16_t iBlock, iBand, n, m;
+ float realOut[16][MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX], imagOut[16][MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX];
+ float g;
+ float *p_real, *p_imag, *p_realOut, *p_imagOut;
+ int16_t nb_channels_in;
+
+ push_wmops( "ivas_sba2mc_cldfb" );
+
+ nb_channels_in = hInSetup.nchan_out_woLFE;
+ assert( ( nb_channels_in == 16 ) && ( nb_channels_out == 11 ) && "ivas_sba2mc_cldfb; only HOA3 to CICP19 is for now supported!" );
+
+ for ( n = 0; n < nb_channels_out; n++ )
+ {
+ set_zero( realOut[n], MAX_PARAM_SPATIAL_SUBFRAMES * nb_bands );
+ set_zero( imagOut[n], MAX_PARAM_SPATIAL_SUBFRAMES * nb_bands );
+
+ for ( m = 0; m < nb_channels_in; m++ )
+ {
+ g = hoa_dec_mtx[SBA_NHARM_HOA3 * n + m];
+ p_realOut = realOut[n];
+ p_imagOut = imagOut[n];
+ for ( iBlock = 0; iBlock < MAX_PARAM_SPATIAL_SUBFRAMES; iBlock++ )
+ {
+ p_real = RealBuffer[m][iBlock];
+ p_imag = ImagBuffer[m][iBlock];
+ for ( iBand = 0; iBand < nb_bands; iBand++ )
+ {
+ *p_realOut = *p_realOut + g * *( p_real++ );
+ *p_imagOut = *p_imagOut + g * *( p_imag++ );
+ p_realOut++;
+ p_imagOut++;
+ }
+ }
+ }
+ }
+
+ for ( n = 0; n < nb_channels_out; n++ )
+ {
+ p_realOut = realOut[n];
+ p_imagOut = imagOut[n];
+ for ( iBlock = 0; iBlock < MAX_PARAM_SPATIAL_SUBFRAMES; iBlock++ )
+ {
+ p_real = RealBuffer[n][iBlock];
+ p_imag = ImagBuffer[n][iBlock];
+ for ( iBand = 0; iBand < nb_bands; iBand++ )
+ {
+ *( p_real++ ) = *p_realOut++;
+ *( p_imag++ ) = *p_imagOut++;
+ }
+ }
+ }
+
+ pop_wmops();
+
+ return;
+}
+
+
+/*-------------------------------------------------------------------------*
+ * ivas_mc2sba()
+ *
+ * MC signals transformed into SBA in TD domain
+ *-------------------------------------------------------------------------*/
+
+void ivas_mc2sba(
+ IVAS_OUTPUT_SETUP hIntSetup, /* i : Format of decoder output */
+ float buffer_td[][L_FRAME48k], /* i/o: MC signals (on input) and the HOA3 (on output) */
+ const int16_t output_frame, /* i : output frame length per channel */
+ const int16_t sba_order, /* i : Ambisonic (SBA) order */
+ const float gain_lfe /* i : gain for LFE, 0 = ignore LFE */
+)
+{
+ int16_t i, j, k;
+ int16_t idx_lfe, idx_in;
+ float buffer_tmp[16][L_FRAME48k];
+ float gains[16];
+ int16_t azimuth, elevation;
+ int16_t sba_num_chans;
+
+ assert( ( sba_order <= 3 ) && "Only order up to 3 is supported!" );
+
+ /* Init*/
+ sba_num_chans = ( sba_order + 1 ) * ( sba_order + 1 );
+ for ( j = 0; j < sba_num_chans; j++ )
+ {
+ set_zero( buffer_tmp[j], output_frame );
+ }
+
+ /* HOA encoding*/
+ idx_lfe = 0;
+ idx_in = 0;
+ for ( i = 0; i < hIntSetup.nchan_out_woLFE + hIntSetup.num_lfe; i++ )
+ {
+ if ( ( hIntSetup.num_lfe > 0 ) && ( i == hIntSetup.index_lfe[idx_lfe] ) )
+ {
+ if ( gain_lfe > 0.f )
+ {
+ /* Add LFE to omni W with gain*/
+ for ( k = 0; k < output_frame; k++ )
+ {
+ buffer_tmp[0][k] += gain_lfe * buffer_td[i][k];
+ }
+ }
+
+ if ( idx_lfe < ( hIntSetup.num_lfe - 1 ) )
+ {
+ idx_lfe++;
+ }
+ }
+ else
+ {
+ azimuth = (int16_t) ( hIntSetup.ls_azimuth[idx_in] );
+ elevation = (int16_t) ( hIntSetup.ls_elevation[idx_in] );
+ idx_in++;
+
+ /* get HOA response for direction (ACN/SN3D)*/
+ ivas_dirac_dec_get_response(
+ azimuth,
+ elevation,
+ gains,
+ sba_order );
+
+ for ( j = 0; j < sba_num_chans; j++ )
+ {
+ for ( k = 0; k < output_frame; k++ )
+ {
+ buffer_tmp[j][k] += gains[j] * buffer_td[i][k];
+ }
+ }
+ }
+ }
+
+ for ( j = 0; j < sba_num_chans; j++ )
+ {
+ mvr2r( buffer_tmp[j], buffer_td[j], output_frame );
+ }
+
+ return;
+}
+
+
+/*-------------------------------------------------------------------*
+ * ivas_sba_remapTCs()
+ *
+ * Get TCs from Ambisonics signal in ACN
+ *-------------------------------------------------------------------*/
+
+int16_t ivas_sba_remapTCs(
+ float sba_data[][L_FRAME48k], /* i/o: SBA signals */
+ Decoder_Struct *st_ivas, /* i/o: decoder struct */
+ const int16_t output_frame /* i : frame length */
+)
+{
+ int16_t nchan_remapped;
+
+#ifdef DEBUG_MODE_DIRAC
+ debug_mode_dirac( sba_data, st_ivas->nchan_transport, output_frame );
+#endif
+
+ nchan_remapped = st_ivas->nchan_transport;
+ if ( ( st_ivas->sba_mode != SBA_MODE_SPAR && st_ivas->sba_planar && nchan_remapped >= 3 ) ||
+ ( ( st_ivas->sba_mode == SBA_MODE_SPAR ) && nchan_remapped == 3 ) )
+ {
+
+ nchan_remapped++;
+ if ( st_ivas->sba_mode != SBA_MODE_SPAR )
+ {
+ assert( ( ( st_ivas->nchan_transport == 3 ) || ( st_ivas->nchan_transport == 5 ) || ( st_ivas->nchan_transport == 7 ) ) && "Number of channels must be odd for SBA planar!" );
+ }
+
+ if ( nchan_remapped == 4 )
+ {
+ /*For planar A-format channel 2 and 3 are identical -> Z=0*/
+ mvr2r( sba_data[2], sba_data[3], output_frame );
+ }
+ }
+
+ if ( st_ivas->nchan_transport >= 3 )
+ {
+ int16_t i = 0;
+ float temp;
+
+ /*convert WYXZ downmix to WYZX*/
+ for ( i = 0; i < output_frame; i++ )
+ {
+ temp = sba_data[2][i];
+ sba_data[2][i] = sba_data[3][i];
+ sba_data[3][i] = temp;
+ if ( st_ivas->nchan_transport == 3 )
+ {
+ sba_data[2][i] = 0;
+ }
+ }
+ }
+
+ if ( st_ivas->sba_mode != SBA_MODE_SPAR )
+ {
+ ivas_sba_zero_vert_comp( sba_data, st_ivas->sba_analysis_order, st_ivas->sba_planar, output_frame );
+ }
+
+ return ( nchan_remapped );
+}
+
+
+/*-------------------------------------------------------------------------*
+ * ivas_ism2sba()
+ *
+ * ISM transformed into SBA in TD domain.
+ *-------------------------------------------------------------------------*/
+
+void ivas_ism2sba(
+ float buffer_td[][L_FRAME48k], /* i/o: TD signal buffers */
+ ISM_RENDERER_HANDLE hIsmRendererData, /* i/o: renderer data */
+ const ISM_METADATA_HANDLE hIsmMetaData[], /* i : object metadata */
+ const int16_t num_objects, /* i : number of objects */
+ const int16_t output_frame, /* i : output frame length per channel */
+ const int16_t sba_order /* i : Ambisonic (SBA) order */
+)
+{
+ int16_t i, j, k;
+ float buffer_tmp[16][L_FRAME48k];
+ float gains[16];
+ float g1, g2;
+ int16_t azimuth, elevation;
+ int16_t sba_num_chans;
+
+ assert( ( sba_order <= 3 ) && "Only order up to 3 is supported!" );
+ assert( hIsmRendererData != NULL && "hIsmRendererData not allocated!" );
+
+ /* Init*/
+ sba_num_chans = ( sba_order + 1 ) * ( sba_order + 1 );
+ for ( j = 0; j < sba_num_chans; j++ )
+ {
+ set_zero( buffer_tmp[j], output_frame );
+ }
+
+ for ( i = 0; i < num_objects; i++ )
+ {
+ // TODO tmu review when #215 is resolved
+ azimuth = (int16_t) floorf( hIsmMetaData[i]->azimuth + 0.5f );
+ elevation = (int16_t) floorf( hIsmMetaData[i]->elevation + 0.5f );
+
+ /*get HOA gets for direction (ACN/SN3D)*/
+ ivas_dirac_dec_get_response( azimuth, elevation, gains, sba_order );
+
+ for ( j = 0; j < sba_num_chans; j++ )
+ {
+ g1 = 1.f;
+ g2 = 0.f;
+ for ( k = 0; k < output_frame; k++ )
+ {
+ buffer_tmp[j][k] += ( g2 * gains[j] + g1 * hIsmRendererData->prev_gains[i][j] ) * buffer_td[i][k];
+ g2 += 1.f / ( output_frame - 1 );
+ g1 = 1.0f - g2;
+ }
+ hIsmRendererData->prev_gains[i][j] = gains[j];
+ }
+ }
+
+ for ( j = 0; j < sba_num_chans; j++ )
+ {
+ mvr2r( buffer_tmp[j], buffer_td[j], output_frame );
+ }
+
+ return;
+}
+
+
+/*-------------------------------------------------------------------*
+ * ivas_sba_upmixer_renderer()
+ *
+ * SBA upmix & rendering
+ *-------------------------------------------------------------------*/
+
+void ivas_sba_upmixer_renderer(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */
+ float output[][L_FRAME48k], /* i/o: transport/output audio channels */
+ const int16_t output_frame /* i : output frame length */
+)
+{
+ int16_t i, nchan_internal;
+ float temp;
+
+ push_wmops( "ivas_sba_upmixer_renderer" );
+
+ nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order );
+
+ if ( st_ivas->nchan_transport >= 3 )
+ {
+ /*convert WYZX downmix to WYXZ*/
+ for ( i = 0; i < output_frame; i++ )
+ {
+ temp = output[2][i];
+ output[2][i] = output[3][i];
+ output[3][i] = temp;
+ }
+ }
+
+ /* Upmixer + Renderer */
+ ivas_spar_dec_upmixer( st_ivas, output, nchan_internal, output_frame );
+
+ if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC )
+ {
+ ivas_sba_linear_renderer( output, output_frame, st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx );
+ }
+
+ pop_wmops();
+
+ return;
+}
+
+
+/*-------------------------------------------------------------------*
+ * ivas_sba_mtx_mult()
+ *
+ * HOA decoding with LFE insertion
+ *-------------------------------------------------------------------*/
+
+static void ivas_sba_mtx_mult(
+ float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */
+ const int16_t output_frame, /* i : output frame length per channel */
+ const int16_t nchan_in, /* i : Number of ambisonic channels */
+ const IVAS_OUTPUT_SETUP output_setup, /* i : Output configuration */
+ const float *mtx_hoa_decoder /* i : HOA decoding mtx */
+)
+{
+ int16_t i, k, ch_idx;
+ int16_t idx_lfe;
+ float input_f[16];
+ const float *hoa_decoder;
+
+ assert( ( nchan_in >= FOA_CHANNELS ) && "Number of input channels must be at least 4 (FOA)!\n" );
+
+ for ( i = 0; i < output_frame; i++ )
+ {
+ /* init*/
+ idx_lfe = 0;
+ hoa_decoder = &mtx_hoa_decoder[0];
+ for ( k = 0; k < nchan_in; k++ )
+ {
+ input_f[k] = output_f[k][i];
+ }
+
+ /* mtx mult with LFE insertion*/
+ for ( ch_idx = 0; ch_idx < ( output_setup.nchan_out_woLFE + output_setup.num_lfe ); ch_idx++ )
+ {
+ if ( ( output_setup.num_lfe > 0 ) && ( output_setup.index_lfe[idx_lfe] == ch_idx ) )
+ {
+ /*LFE insertion*/
+ output_f[ch_idx][i] = 0.f;
+ if ( idx_lfe < ( output_setup.num_lfe - 1 ) )
+ {
+ idx_lfe++;
+ }
+ }
+ else
+ {
+ /*HOA decoding*/
+ output_f[ch_idx][i] = input_f[0] * hoa_decoder[0];
+ for ( k = 1; k < nchan_in; k++ )
+ {
+ output_f[ch_idx][i] += input_f[k] * hoa_decoder[k];
+ }
+ hoa_decoder += 16;
+ }
+ }
+ }
+
+ return;
+}
+
+
+/*-------------------------------------------------------------------*
+ * ivas_sba_linear_renderer()
+ *
+ * Linear rendering for SBA format
+ *-------------------------------------------------------------------*/
+
+ivas_error ivas_sba_linear_renderer(
+ float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */
+ const int16_t output_frame, /* i : output frame length per channel */
+ const int16_t nchan_in, /* i : number of input ambisonics channels */
+ const AUDIO_CONFIG output_config, /* i : output audio configuration */
+ const IVAS_OUTPUT_SETUP output_setup, /* i : output format setup */
+ const float hoa_dec_mtx[] /* i : HOA decoding mtx */
+)
+{
+ int16_t i;
+ float dmx_l;
+ int16_t nchan_hoa;
+ ivas_error error;
+
+ error = IVAS_ERR_OK;
+
+ /* Number of channels of HOA depends of transport format which is mixed order xH1V*/
+ nchan_hoa = nchan_in;
+
+ if ( nchan_in == 6 ) /*2H1V*/
+ {
+ nchan_hoa = 9;
+ }
+ else if ( nchan_in == 8 ) /*3H1V*/
+ {
+ nchan_hoa = 16;
+ }
+
+ switch ( output_config )
+ {
+ case AUDIO_CONFIG_MONO:
+ /* If stereo DMX, MONO = W = Cardioids L + R*/
+ if ( nchan_in == 2 )
+ {
+ for ( i = 0; i < output_frame; i++ )
+ {
+ output_f[0][i] += output_f[1][i];
+ }
+ }
+ /* else: do nothing, MONO = W*/
+ break;
+ case AUDIO_CONFIG_STEREO:
+ assert( ( nchan_in >= 2 ) && "Number of input channels must be at least 2 (for W and Y)!\n" );
+
+ /* Compute L and R cardioids from SB format except if stereo DMX is transmitted already in this format*/
+ if ( nchan_in > 2 )
+ {
+ /*Build L/R cardioids*/
+ for ( i = 0; i < output_frame; i++ )
+ {
+ dmx_l = 0.5f * ( output_f[0][i] + output_f[1][i] ); /* cardioid_left = 0.5(W + Y) */
+ output_f[1][i] = 0.5f * ( output_f[0][i] - output_f[1][i] ); /* cardioid_right = 0.5(W - Y) */
+ output_f[0][i] = dmx_l;
+ }
+ }
+ break;
+ case AUDIO_CONFIG_5_1:
+ case AUDIO_CONFIG_7_1:
+ case AUDIO_CONFIG_5_1_2:
+ case AUDIO_CONFIG_5_1_4:
+ case AUDIO_CONFIG_7_1_4:
+ case AUDIO_CONFIG_LS_CUSTOM:
+ ivas_sba_mtx_mult( output_f, output_frame, nchan_hoa, output_setup, hoa_dec_mtx );
+ break;
+ case AUDIO_CONFIG_FOA: /* Ambisonics output, order: 1 */
+ case AUDIO_CONFIG_HOA2: /* Ambisonics output, order: 2 */
+ case AUDIO_CONFIG_HOA3: /* Ambisonics output, order: 3 */
+ for ( i = nchan_hoa; i < output_setup.nchan_out_woLFE; i++ )
+ {
+ set_zero( output_f[i], output_frame );
+ }
+ break;
+ default:
+ return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: illegal output configuration, Exiting.\n" );
+ }
+
+ return error;
+}
+
+
+/*-------------------------------------------------------------------*
+ * ivas_sba_mix_matrix_determiner()
+ *
+ * Determine SBA mixing matrices
+ *-------------------------------------------------------------------*/
+
+void ivas_sba_mix_matrix_determiner(
+ SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */
+ float output[][L_FRAME48k], /* i/o: transport/output audio channels */
+ const int16_t bfi, /* i : BFI flag */
+ const int16_t nchan_remapped, /* i : num channels after remapping of TCs */
+ const int16_t output_frame /* i : output frame length */
+)
+{
+ int16_t i, ch;
+ float temp;
+ int16_t num_bands_out, nchan_transport, nchan_out;
+
+ /* Convert numeric range */
+ for ( ch = 0; ch < nchan_remapped; ch++ )
+ {
+ for ( i = 0; i < output_frame; i++ )
+ {
+ temp = output[ch][i];
+ temp = floorf( temp + 0.5f );
+
+ if ( temp > MAX16B_FLT )
+ {
+ temp = MAX16B_FLT;
+ }
+ else if ( temp < ( -1.0f * PCM16_TO_FLT_FAC ) )
+ {
+ temp = ( -1.0f * PCM16_TO_FLT_FAC );
+ }
+ temp *= ( 1.0f / PCM16_TO_FLT_FAC );
+ output[ch][i] = temp;
+ }
+ }
+
+ /* AGC */
+ nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport;
+ nchan_out = nchan_transport;
+ ivas_agc_dec_process( hSpar->hAgcDec, output, output, nchan_transport, output_frame );
+
+ /* Convert numeric range back */
+ for ( ch = 0; ch < nchan_out; ch++ )
+ {
+ for ( i = 0; i < output_frame; i++ )
+ {
+ output[ch][i] = output[ch][i] * PCM16_TO_FLT_FAC;
+ }
+ }
+
+ /* Mixing matrix determiner */
+ num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands;
+ ivas_spar_dec_gen_umx_mat( hSpar->hMdDec, nchan_transport, num_bands_out, bfi );
+
+ return;
+}
+
+
+#ifdef DEBUG_MODE_DIRAC
+/*-----------------------------------------------------------------------*
+ * Debugging function
+ *-----------------------------------------------------------------------*/
+
+static void debug_mode_dirac(
+ float output[MAX_OUTPUT_CHANNELS][L_FRAME48k],
+ const int16_t nchan_transport,
+ const int16_t output_frame )
+{
+ int16_t i, n;
+ int16_t tmp[L_FRAME48k];
+ char file_name[50] = { 0 };
+
+#ifdef DEBUG_MODE_DIRAC_NOCORE
+ for ( n = 0; n < nchan_transport; n++ )
+ {
+ sprintf( file_name, "./res/ivas_dirac_enc_%d.%d.pcm", n, (int16_t) ( output_frame * 0.05 ) );
+ dbgread( tmp, sizeof( int16_t ), output_frame, file_name );
+ for ( i = 0; i < output_frame; i++ )
+ {
+ output[n][i] = (float) ( tmp[i] );
+ }
+ }
+#else
+ for ( n = 0; n < nchan_transport; n++ )
+ {
+ for ( i = 0; i < output_frame; i++ )
+ {
+ tmp[i] = (int16_t) ( output[n][i] + 0.5f );
+ }
+
+ sprintf( file_name, "./res/ivas_dirac_dec_%d.%d.pcm", n, (int16_t) ( output_frame * 0.05 ) );
+ dbgwrite( tmp, sizeof( int16_t ), output_frame, 1, file_name );
+ }
+#endif
+
+ return;
+}
+#endif
diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c
index 9f9f8cc1197f0ceee639d53f4be0a82ce50351dd..fb7e74a208c8d317aeb95d1715d3459c610ca490 100644
--- a/lib_dec/ivas_spar_decoder.c
+++ b/lib_dec/ivas_spar_decoder.c
@@ -39,6 +39,7 @@
#include "prot.h"
#include "string.h"
#include "ivas_prot.h"
+#include "ivas_prot_rend.h"
#include "ivas_rom_com.h"
#include "ivas_stat_com.h"
#include
@@ -83,7 +84,7 @@ ivas_error ivas_spar_dec_open(
output_Fs = st_ivas->hDecoderConfig->output_Fs;
/* TD decorr. */
- if ( ( error = ivas_spar_td_decorr_dec_open( &hSpar->hTdDecorr, output_Fs, num_channels_internal, 1 ) ) != IVAS_ERR_OK )
+ if ( ( error = ivas_td_decorr_dec_open( &hSpar->hTdDecorr, output_Fs, num_channels_internal, 1 ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -193,8 +194,8 @@ void ivas_spar_dec_close(
/* MD handle */
ivas_spar_md_dec_close( &hSpar->hMdDec );
- /* Covar. State handle */
- ivas_spar_td_decorr_dec_close( &hSpar->hTdDecorr );
+ /* TD decorrelator handle */
+ ivas_td_decorr_dec_close( &hSpar->hTdDecorr );
/* FB mixer handle */
ivas_FB_mixer_close( &hSpar->hFbMixer, output_Fs );
diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h
old mode 100755
new mode 100644
index 3d9ed18351fc81d3d4fcc34d5d9dd53d1724a148..1ceba1e3fd8025a93e85efb7621bafe55edcc1d9
--- a/lib_dec/ivas_stat_dec.h
+++ b/lib_dec/ivas_stat_dec.h
@@ -36,40 +36,10 @@
#include
#include "options.h"
#include "cnst.h"
-#include "stat_dec.h"
#include "ivas_cnst.h"
+#include "stat_dec.h"
#include "ivas_stat_com.h"
#include "ivas_stat_rend.h"
-#ifndef FIX_197_CREND_INTERFACE
-#include "common_api_types.h" // VE2AT: don't we want to avoid this include in the library? I admit that the rules hefre are not 100% clear to me but introducing it just for IVAS_QUATERNION is not necessry I think
-#endif
-
-#ifndef FIX_197_CREND_INTERFACE
-
-/*----------------------------------------------------------------------------------*
- * Output configuration for renderer (e.g. DirAC, MASA, Binaural Renderer...)
- *----------------------------------------------------------------------------------*/
-
-typedef struct ivas_output_setup_structure
-{
- AUDIO_CONFIG output_config;
- int16_t nchan_out_woLFE; /* number of output audio channels without LFE */
- int16_t ambisonics_order;
- int8_t is_loudspeaker_setup;
- int8_t is_planar_setup;
- int8_t is_binaural_setup;
-
- int16_t num_lfe;
- int16_t index_lfe[1];
- const float *ls_azimuth;
- const float *ls_elevation;
-
- uint8_t separateChannelEnabled;
- int16_t separateChannelIndex;
-
-} IVAS_OUTPUT_SETUP, *IVAS_OUTPUT_SETUP_HANDLE;
-
-#endif
/*----------------------------------------------------------------------------------*
* DFT Stereo decoder structure
*----------------------------------------------------------------------------------*/
@@ -841,7 +811,6 @@ typedef struct ivas_spar_md_dec_state_t
int16_t spar_hoa_md_flag;
} ivas_spar_md_dec_state_t;
-#ifndef FIX_197_CREND_INTERFACE
/* AGC structure */
typedef struct ivas_agc_dec_chan_state_t
@@ -859,30 +828,6 @@ typedef struct ivas_agc_dec_state_t
} ivas_agc_dec_state_t;
-/* TD decorr */
-typedef struct ivas_td_decorr_APD_filt_state_t
-{
- int16_t order[IVAS_MAX_DECORR_APD_SECTIONS];
- int16_t idx[IVAS_MAX_DECORR_APD_SECTIONS];
- float coeffs[IVAS_MAX_DECORR_APD_SECTIONS];
- float *state[IVAS_MAX_DECORR_APD_SECTIONS];
-
-} ivas_td_decorr_APD_filt_state_t;
-
-typedef struct ivas_td_decorr_state_t
-{
- ivas_trans_det_state_t *pTrans_det;
- float *look_ahead_buf;
- ivas_td_decorr_APD_filt_state_t APD_filt_state[IVAS_MAX_DECORR_CHS];
-
- int16_t num_apd_outputs;
- int16_t num_apd_sections;
- int16_t ducking_flag;
-
-} ivas_td_decorr_state_t;
-
-#endif
-
/* PCA structure */
typedef struct
{
@@ -1014,83 +959,33 @@ typedef struct mct_dec_data_structure
} MCT_DEC_DATA, *MCT_DEC_HANDLE;
-#ifndef FIX_197_CREND_INTERFACE
/*----------------------------------------------------------------------------------*
- * EFAP structures
+ * LFE decoder structure
*----------------------------------------------------------------------------------*/
-// VE2AT: move to ivas_rom_rend.h ?
-typedef struct EFAP_VERTEX
-{
- float azi; /* azimuth of the loudspeaker */
- float ele; /* elevation of the loudspeaker */
- float pos[3]; /* [x y z] cartesian coordinate vector */
- int16_t idx; /* integer, that corresponds to the first index for the LS in the 1D output */
- int16_t isNaN; /* used to indicate if the vertex is a virtual speaker */
- EFAP_VTX_DMX_TYPE dmxType; /* virtual speaker downmix type */
-
-} EFAP_VERTEX;
-
-typedef struct EFAP_VERTEX_DATA
-{
- EFAP_VERTEX *vertexArray; /* Array of vertices */
- int16_t numVtx; /* Number of vertices */
- int16_t *vtxOrder; /* Array that indicates the order of the vertex ranked by increasing azimuth */
-
-} EFAP_VERTEX_DATA;
-
-typedef struct EFAP_POLYSET
-{
- int16_t chan[EFAP_MAX_CHAN_NUM]; /* An array indicating the loudspeaker index of the polygon vertices */
- int16_t isNaN[EFAP_MAX_CHAN_NUM]; /* Indicates if one of the vertices isNaN */
- int16_t numChan; /* An integer between 0 and EFAP_MAX_CHAN_NUM corresponding to the number of vertices of the polygon */
- float polyAzi[EFAP_MAX_CHAN_NUM]; /* An array (same length as "chan"), with the azimuth of the channels */
- float polyEle[EFAP_MAX_CHAN_NUM]; /* An array (same length as "chan"), with the elevation of the channels */
-
-} EFAP_POLYSET;
-
-typedef struct EFAP_LS_TRIANGLE
-{
- int16_t LS[3]; /* Array indicating the loudspeaker index of the triangle vertices */
-} EFAP_LS_TRIANGLE;
-
-typedef struct EFAP_POLYSET_DATA
+typedef struct ivas_lfe_dec_data_structure
{
- EFAP_POLYSET polysetArray[EFAP_MAX_POLY_SET]; /* Array of polygons */
- int16_t numPoly; /* Number of polygons */
- EFAP_LS_TRIANGLE triArray[EFAP_MAX_POLY_SET]; /* Array of triangles */
- int16_t numTri; /* Number of triangles */
-
-} EFAP_POLYSET_DATA;
+ ivas_filters_process_state_t filter_state;
+ LFE_WINDOW_HANDLE pWindow_state;
+ const uint16_t *cum_freq_models[IVAS_MAX_NUM_QUANT_STRATS][IVAS_MAX_NUM_DCT_COEF_GROUPS];
+ int16_t lfe_dec_indices_coeffs_tbl[IVAS_MAX_NUM_QUANT_STRATS][IVAS_MAX_NUM_DCT_COEF_GROUPS];
+ float lfe_block_delay_s;
+ int16_t lfe_prior_buf_len;
+ float *prior_out_buffer;
-typedef struct EFAP
-{
- int16_t numSpk; /* Number of loudspeakers */
- float *aziSpk; /* Loudspeaker azimuths */
- float *eleSpk; /* Loudspeaker elevations */
- EFAP_VERTEX_DATA vtxData; /* Vertex Data, contains all the data concerning the vertex */
- EFAP_POLYSET_DATA polyData; /* Polygon data */
- float **dmTranspose; /* Downmix Matrix used for redistributing the energy of ghosts LS and its transpose */
- float *bufferLong; /* tmp buffer that will be given as a parameter for computing the gain; this is a 1D array of length numVtx */
- float *bufferShort; /* tmp buffer that will be given as a parameter for computing the gain; this is the result of downMixMatrix*bufferLong, length is numSpk */
- int16_t numTot; /* Total number of real + ghost loudspeakers, used later for freeing memory */
+ float *prevsynth_buf;
+ float *lfe_delay_buf;
+ int16_t lfe_addl_delay;
+ int16_t bfi_count;
-} EFAP, *EFAP_HANDLE;
+} LFE_DEC_DATA, *LFE_DEC_HANDLE;
+// Note: the following structures are used only in lib_dec but this would likely change in the future
/*----------------------------------------------------------------------------------*
* VBAP structures
*----------------------------------------------------------------------------------*/
-// VE2AT: move to ivas_rom_rend.h ?
-enum SpeakerNodeGroup
-{
- SPEAKER_NODE_BOTTOM_HALF,
- SPEAKER_NODE_HORIZONTAL,
- SPEAKER_NODE_TOP_HALF,
- SPEAKER_NODE_BACK,
- SPEAKER_NODE_ALL
-};
/* Defines a single virtual surface triplet of loudspeakers
* with a precalculated inverse matrix */
@@ -1101,15 +996,6 @@ typedef struct vbap_vs_triplet_structure
} VBAP_VS_TRIPLET;
-/* Defines a single speaker node */
-typedef struct vbap_speaker_node_structure
-{
- float azi_deg;
- float ele_deg;
- float unit_vec[3];
- enum SpeakerNodeGroup group;
-
-} VBAP_SPEAKER_NODE;
/* Storage structure for fast runtime triplet search */
typedef struct triplet_search_structure
@@ -1120,6 +1006,7 @@ typedef struct triplet_search_structure
} VBAP_SEARCH_STRUCT;
+
/* VBAP data structure. Contains the formed virtual surface arrangement * and supporting data. */
typedef struct vbap_data_structure
{
@@ -1140,7 +1027,7 @@ typedef struct vbap_data_structure
/*----------------------------------------------------------------------------------*
* renderer structures
*----------------------------------------------------------------------------------*/
-// VE2AT: move to ivas_rom_rend.h ?
+
typedef struct renderer_struct
{
float prev_gains[MAX_CICP_CHANNELS - 1][MAX_OUTPUT_CHANNELS];
@@ -1148,7 +1035,32 @@ typedef struct renderer_struct
} ISM_RENDERER_DATA, *ISM_RENDERER_HANDLE;
-#endif
+
+/* Fastconv binaural data structure */
+typedef struct ivas_binaural_rendering_struct
+{
+ /* Common variables for all modules */
+ IVAS_OUTPUT_SETUP_HANDLE hInputSetup; /* pointer to input spatial format for binaural renderer*/
+ EFAP_HANDLE hEFAPdata; /* EFAP structure*/
+ float *hoa_dec_mtx; /* pointer to HOA decoder mtx */
+ int8_t rotInCldfb; /* Flag to enable rotation within bin Renderer in CLDFB*/
+ int16_t max_band; /* band upto which rendering is performed */
+ int16_t conv_band; /* band upto which convolution in cldfb domain is performed */
+ int16_t timeSlots; /* number of time slots of binaural renderer */
+ int16_t nInChannels; /* number input channels */
+ int8_t render_lfe; /* Flag to render LFE in binaural rendering*/
+ IVAS_FORMAT ivas_format; /* format; corresponds to st_ivas->ivas_format, unless the signal gets transormed to a different domain for rendering */
+
+ /* Convolution module structure */
+ BINRENDERER_CONV_MODULE_HANDLE hBinRenConvModule;
+
+ /* Variables related to reverb module */
+ float earlyPartEneCorrection[CLDFB_NO_CHANNELS_MAX];
+ REVERB_STRUCT_HANDLE hReverb;
+
+} BINAURAL_RENDERER, *BINAURAL_RENDERER_HANDLE;
+
+
/*----------------------------------------------------------------------------------*
* MASA decoder structures
*----------------------------------------------------------------------------------*/
@@ -1203,681 +1115,6 @@ typedef struct ivas_masa_decoder_struct
} MASA_DECODER, *MASA_DECODER_HANDLE;
-#ifndef FIX_197_CREND_INTERFACE
-
-/*----------------------------------------------------------------------------------*
- * Binaural Rendering structure
- *----------------------------------------------------------------------------------*/
-// VE2AT: move to ivas_rom_rend.h ?
-/* Binaural reverberator structure */
-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 **tapPointersReal[CLDFB_NO_CHANNELS_MAX][BINAURAL_CHANNELS];
- float **tapPointersImag[CLDFB_NO_CHANNELS_MAX][BINAURAL_CHANNELS];
-
- float binauralCoherenceCrossmixGains[CLDFB_NO_CHANNELS_MAX];
- float binauralCoherenceDirectGains[CLDFB_NO_CHANNELS_MAX];
- float reverbEqGains[CLDFB_NO_CHANNELS_MAX];
- float loopAttenuationFactor[CLDFB_NO_CHANNELS_MAX];
-
- float *outputBufferReal[CLDFB_NO_CHANNELS_MAX][BINAURAL_CHANNELS];
- float *outputBufferImag[CLDFB_NO_CHANNELS_MAX][BINAURAL_CHANNELS];
-
- int16_t numBins;
-
- int16_t useBinauralCoherence;
- int16_t loopBufLength[CLDFB_NO_CHANNELS_MAX];
- int16_t loopBufLengthMax[CLDFB_NO_CHANNELS_MAX];
- int16_t preDelayBufferIndex;
- int16_t preDelayBufferLength;
-
- int16_t taps[CLDFB_NO_CHANNELS_MAX][BINAURAL_CHANNELS];
- int16_t *tapPhaseShiftType[CLDFB_NO_CHANNELS_MAX][BINAURAL_CHANNELS];
-
- int16_t blockSize;
- uint32_t binRend_RandNext;
- int16_t highestBinauralCoherenceBin;
-
- float dmxmtx[BINAURAL_CHANNELS][MAX_OUTPUT_CHANNELS];
- float foa_enc[MAX_OUTPUT_CHANNELS][FOA_CHANNELS];
-
-} REVERB_STRUCT, *REVERB_STRUCT_HANDLE;
-
-/* Parametric binaural data structure */
-typedef struct ivas_dirac_dec_binaural_data_structure
-{
- float ChEnePrev[BINAURAL_CHANNELS][CLDFB_NO_CHANNELS_MAX];
- float ChCrossRePrev[CLDFB_NO_CHANNELS_MAX];
- float ChCrossImPrev[CLDFB_NO_CHANNELS_MAX];
- float ChEne[BINAURAL_CHANNELS][CLDFB_NO_CHANNELS_MAX];
- float ChCrossRe[CLDFB_NO_CHANNELS_MAX];
- float ChCrossIm[CLDFB_NO_CHANNELS_MAX];
- float ChEneOutPrev[BINAURAL_CHANNELS][CLDFB_NO_CHANNELS_MAX];
- float ChCrossReOutPrev[CLDFB_NO_CHANNELS_MAX];
- float ChCrossImOutPrev[CLDFB_NO_CHANNELS_MAX];
- float ChEneOut[BINAURAL_CHANNELS][CLDFB_NO_CHANNELS_MAX];
- float ChCrossReOut[CLDFB_NO_CHANNELS_MAX];
- float ChCrossImOut[CLDFB_NO_CHANNELS_MAX];
- float processMtxRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS + 1][CLDFB_NO_CHANNELS_MAX]; /* +1 refers to SeparateChannel */
- float processMtxIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS + 1][CLDFB_NO_CHANNELS_MAX];
- float processMtxDecRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS][CLDFB_NO_CHANNELS_MAX];
- float processMtxDecIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS][CLDFB_NO_CHANNELS_MAX];
- float diffuseFieldCoherence[CLDFB_NO_CHANNELS_MAX];
- float diffuseFieldCoherenceX[BINAURAL_COHERENCE_DIFFERENCE_BINS];
- float diffuseFieldCoherenceY[BINAURAL_COHERENCE_DIFFERENCE_BINS];
- float diffuseFieldCoherenceZ[BINAURAL_COHERENCE_DIFFERENCE_BINS];
- float earlyPartEneCorrection[CLDFB_NO_CHANNELS_MAX];
- REVERB_STRUCT_HANDLE hReverb;
- uint8_t renderStereoOutputInsteadOfBinaural;
- float frameMeanDiffuseness[CLDFB_NO_CHANNELS_MAX];
- float processMtxRePrev[BINAURAL_CHANNELS][BINAURAL_CHANNELS + 1][CLDFB_NO_CHANNELS_MAX];
- float processMtxImPrev[BINAURAL_CHANNELS][BINAURAL_CHANNELS + 1][CLDFB_NO_CHANNELS_MAX];
- float processMtxDecRePrev[BINAURAL_CHANNELS][BINAURAL_CHANNELS][CLDFB_NO_CHANNELS_MAX];
- float processMtxDecImPrev[BINAURAL_CHANNELS][BINAURAL_CHANNELS][CLDFB_NO_CHANNELS_MAX];
- uint16_t useSubframeMode; /* 0 = process in 20 ms frames, 1 = process in 5 ms subframes */
- uint16_t useTdDecorr;
- ivas_td_decorr_state_t *hTdDecorr;
-
-} DIRAC_DEC_BIN_DATA, *DIRAC_DEC_BIN_HANDLE;
-
-typedef struct ivas_binaural_rendering_conv_module_struct
-{
- float ***filterTapsLeftReal;
- float ***filterTapsLeftImag;
- float ***filterTapsRightReal;
- float ***filterTapsRightImag;
-
- float ***filterStatesLeftReal;
- float ***filterStatesLeftImag;
-
- int16_t numTapsArray[BINAURAL_CONVBANDS];
- int16_t numTaps;
-
-} BINRENDERER_CONV_MODULE, *BINRENDERER_CONV_MODULE_HANDLE;
-
-/* Fastconv binaural data structure */
-
-typedef struct ivas_hrtfs_fastconv_struct
-{
- float FASTCONV_HRIR_latency_s;
- float leftHRIRReal[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][7];
- float leftHRIRImag[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][7];
- float rightHRIRReal[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][7];
- float rightHRIRImag[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][7];
-
- float FASTCONV_HOA3_latency_s;
- float leftHRIRReal_HOA3[BINAURAL_CONVBANDS][HRTF_SH_CHANNELS][7];
- float leftHRIRImag_HOA3[BINAURAL_CONVBANDS][HRTF_SH_CHANNELS][7];
- float rightHRIRReal_HOA3[BINAURAL_CONVBANDS][HRTF_SH_CHANNELS][7];
- float rightHRIRImag_HOA3[BINAURAL_CONVBANDS][HRTF_SH_CHANNELS][7];
-
- float FASTCONV_BRIR_latency_s;
- float leftBRIRReal[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS_MAX];
- float leftBRIRImag[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS_MAX];
- float rightBRIRReal[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS_MAX];
- float rightBRIRImag[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS_MAX];
-
- float fastconvReverberationTimes[CLDFB_NO_CHANNELS_MAX];
- float fastconvReverberationEneCorrections[CLDFB_NO_CHANNELS_MAX];
-} HRTFS_FASTCONV, *HRTFS_FASTCONV_HANDLE;
-
-
-typedef struct ivas_hrtfs_parambin_struct
-{
- float hrtfShCoeffsRe[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS];
- float hrtfShCoeffsIm[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS];
-
- float parametricReverberationTimes[CLDFB_NO_CHANNELS_MAX];
- float parametricReverberationEneCorrections[CLDFB_NO_CHANNELS_MAX];
- float parametricEarlyPartEneCorrection[CLDFB_NO_CHANNELS_MAX];
-} HRTFS_PARAMBIN, *HRTFS_PARAMBIN_HANDLE;
-
-
-typedef struct ivas_binaural_rendering_struct
-{
- /* Common variables for all modules */
- IVAS_OUTPUT_SETUP_HANDLE hInputSetup; /* pointer to input spatial format for binaural renderer*/
- EFAP_HANDLE hEFAPdata; /* EFAP structure*/
- float *hoa_dec_mtx; /* pointer to HOA decoder mtx */
- int8_t rotInCldfb; /* Flag to enable rotation within bin Renderer in CLDFB*/
- int16_t max_band; /* band upto which rendering is performed */
- int16_t conv_band; /* band upto which convolution in cldfb domain is performed */
- int16_t timeSlots; /* number of time slots of binaural renderer */
- int16_t nInChannels; /* number input channels */
- int8_t render_lfe; /* Flag to render LFE in binaural rendering*/
- IVAS_FORMAT ivas_format; /* format; corresponds to st_ivas->ivas_format, unless the signal gets transormed to a different domain for rendering */
-
- /* Convolution module structure */
- BINRENDERER_CONV_MODULE_HANDLE hBinRenConvModule;
-
- /* Variables related to reverb module */
- float earlyPartEneCorrection[CLDFB_NO_CHANNELS_MAX];
- REVERB_STRUCT_HANDLE hReverb;
-
-} BINAURAL_RENDERER, *BINAURAL_RENDERER_HANDLE;
-
-
-/*----------------------------------------------------------------------------------*
- * Head tracking data structure
- *----------------------------------------------------------------------------------*/
-// VE2AT: move to ivas_rom_rend.h ?
-
-typedef struct ivas_binaural_head_track_struct
-{
- int16_t num_quaternions;
- IVAS_QUATERNION Quaternions[MAX_PARAM_SPATIAL_SUBFRAMES];
- float Rmat[3][3];
- float Rmat_prev[3][3];
-
- uint8_t lrSwitchedNext;
- uint8_t lrSwitchedCurrent;
- float lrSwitchInterpVal;
-
- int16_t shd_rot_max_order;
-
-} HEAD_TRACK_DATA, *HEAD_TRACK_DATA_HANDLE;
-
-
-/*----------------------------------------------------------------------------------*
- * TD ISm Object Renderer structure
- *----------------------------------------------------------------------------------*/
-
-
-typedef struct
-{
- int16_t modelROM; /* Flag that indicates that the model resides in ROM (controls init/dealloc). */
- int16_t UseItdModel; /* Controls whether ITD model is used. */
- int16_t SplineDegree; /* Degree of the spline functions */
- int16_t K; /* Length of filter */
- int16_t elevDim2;
- int16_t elevDim3;
- int16_t AlphaN; /* Number of rows in Alpha matrices */
- int16_t num_unique_azim_splines;
- int16_t elevSegSamples;
-
- int16_t elevBsLen[HRTF_MODEL_BSPLINE_NUM_COEFFS];
- int16_t elevBsStart[HRTF_MODEL_BSPLINE_NUM_COEFFS];
- const int16_t *azimDim2;
- const int16_t *azimDim3;
- const int16_t *azim_start_idx;
- const int16_t *azimSegSamples;
- const int16_t *azimShapeIdx;
- const int16_t *azimShapeSampFactor;
-
- const float *elevKSeq; /* Array, N x elevDim2 x elevDim3 */
- const float *AlphaL; /* Array, size AlphaN x K */
- const float *AlphaR; /* Array, size AlphaN x K */
- const float *elevBsShape;
- float **azimKSeq; /* Array, length azimDim3+1 */
- const float **azimBsShape;
-
- int16_t azimDim3Max;
- int16_t iSecFirst[HRTF_MODEL_N_SECTIONS]; /* Indices for start of sections */
- int16_t iSecLast[HRTF_MODEL_N_SECTIONS]; /* Indices for end of sections */
- const float *EL; /* Array, size (AlphaN*HRTF_MODEL_N_SECTIONS) */
- const float *ER; /* Array, size (AlphaN*HRTF_MODEL_N_SECTIONS) */
-
- /* Pointers for allocation of dynamic memory */
- float *AlphaL_dyn;
- float *AlphaR_dyn;
- float *EL_dyn;
- float *ER_dyn;
- float *elevBsShape_dyn;
- float *elevKSeq_dyn;
- int16_t *azimDim2_dyn;
- int16_t *azimDim3_dyn;
- int16_t *azim_start_idx_dyn;
- int16_t *azimSegSamples_dyn;
- int16_t *azimShapeIdx_dyn;
- int16_t *azimShapeSampFactor_dyn;
- float **azimBsShape_dyn;
-
-} ModelParams_t;
-
-typedef struct
-{
- int16_t N; /* Polynomial degree */
-
- int16_t elevDim2;
- int16_t elevDim3;
- const float *elevKSeq; /* Array, length elevDim3-2 */
- int16_t azimDim2;
- int16_t azimDim3;
- const float *azimKSeq; /* Array, length azimDim3-2 */
- const float *W; /* Array, size (elevDim3*azimDim3) x K */
-
- int16_t azimBsLen[HRTF_MODEL_BSPLINE_NUM_COEFFS];
- int16_t azimBsStart[HRTF_MODEL_BSPLINE_NUM_COEFFS];
- const float *azimBsShape;
- int16_t azimSegSamples;
-
- int16_t elevBsLen[HRTF_MODEL_BSPLINE_NUM_COEFFS];
- int16_t elevBsStart[HRTF_MODEL_BSPLINE_NUM_COEFFS];
- const float *elevBsShape;
- int16_t elevSegSamples;
- float resamp_factor;
-
- /* Pointers for allocation of dynamic memory */
- float *elevKSeq_dyn;
- float *azimKSeq_dyn;
- float *W_dyn;
- float *azimBsShape_dyn;
- float *elevBsShape_dyn;
-
-} ModelParamsITD_t;
-
-typedef struct
-{
- float val;
- int16_t i;
-
-} ValueIndex_t;
-
-/* Shared memory for use when evaluating BSpline HR filter model*/
-typedef struct
-{
- float BM[HRTF_MODEL_BSPLINE_NUM_COEFFS_SQ];
- ValueIndex_t BMEnergiesL[HRTF_MODEL_BSPLINE_NUM_COEFFS_SQ];
- ValueIndex_t BMEnergiesR[HRTF_MODEL_BSPLINE_NUM_COEFFS_SQ];
- int16_t UseIndsL[HRTF_MODEL_BSPLINE_NUM_COEFFS_SQ];
- int16_t UseIndsR[HRTF_MODEL_BSPLINE_NUM_COEFFS_SQ];
- float *hrfModL;
- float *hrfModR;
- float elevBfVec[HRTF_MODEL_BSPLINE_NUM_COEFFS];
- float azimBfVec[HRTF_MODEL_BSPLINE_NUM_COEFFS][HRTF_MODEL_BSPLINE_NUM_COEFFS];
- float BM_ITD[HRTF_MODEL_BSPLINE_NUM_COEFFS_SQ];
- float elevBfVecITD[HRTF_MODEL_BSPLINE_NUM_COEFFS];
- float azimBfVecITD[HRTF_MODEL_BSPLINE_NUM_COEFFS];
- float itdMod;
-
-} ModelEval_t;
-
-/* Mixer listener */
-typedef struct
-{
- int16_t PoseUpdated;
- float Pos[3];
- float Front[3];
- float Up[3];
- float Right[3];
-
- int16_t VelUpdated;
- float Vel[3];
-
-} TDREND_MIX_Listener_t;
-
-/* HR filter */
-typedef struct TDREND_HRFILT_FiltSet_struct
-{
- int32_t SampleRate; /* Sample rate of the HR filter */
- int16_t NumPos;
- int16_t NumElev;
- float Dist;
- float *ItdSet_p;
- int16_t FiltLength;
- float *Azim_p;
- float *Elev_p;
- float *ItdSetNominal_p;
- float *LeftFiltSet_p;
- float *RightFiltSet_p;
- ModelParams_t ModelParams;
- ModelEval_t ModelEval;
- ModelParamsITD_t ModelParamsITD;
- TDREND_HRFILT_Method_t FilterMethod; /* HR filtering method */
-
-} TDREND_HRFILT_FiltSet_t;
-
-
-/* Distance attenuation */
-typedef struct
-{
- TDREND_DistAttenModel_t DistAttenModel;
- float RefDist;
- float MaxDist;
- float RollOffFactor;
-
-} TDREND_DistAtten_t;
-
-/* Directional attenuation */
-typedef struct
-{
- float ConeInnerAngle;
- float ConeOuterAngle;
- float ConeOuterGain;
-
-} TDREND_DirAtten_t;
-
-/* Mixer spatial specification */
-typedef struct
-{
- int16_t UseCommonDistAttenModel; /* Common distance attenuation model flag */
- TDREND_DistAttenModel_t DistAttenModel; /* Distance attenuation model */
-
-} TDREND_MixSpatSpec_t;
-
-
-typedef struct TDREND_SRC_REND_s
-{
- int16_t InputAvailable;
- TDREND_PlayStatus_t PlayStatus;
-
- /* Gains */
- int16_t SrcGainUpdated;
- float SrcGain_p[SPAT_BIN_MAX_INPUT_CHANNELS];
- float SrcGainMin_p[SPAT_BIN_MAX_INPUT_CHANNELS];
- float SrcGainMax_p[SPAT_BIN_MAX_INPUT_CHANNELS];
- float DirGain_p[SPAT_BIN_MAX_INPUT_CHANNELS];
- float DistGain_p[SPAT_BIN_MAX_INPUT_CHANNELS];
-} TDREND_SRC_REND_t;
-
-
-/* Source spatial parameters */
-typedef struct
-{
- int16_t Updated;
- TDREND_PosType_t PosType;
- float Pos_p[3 * SPAT_BIN_MAX_INPUT_CHANNELS];
- float Front_p[3 * SPAT_BIN_MAX_INPUT_CHANNELS];
- int16_t DirAttenEnabled;
- TDREND_DirAtten_t DirAtten;
- int16_t DistAttenEnabled;
- TDREND_DistAtten_t DistAtten;
-
-} TDREND_SRC_SPATIAL_t;
-
-typedef struct
-{
- float *InputFrame_p; /* Input frame pointer */
- TDREND_SRC_SPATIAL_t *SrcSpatial_p;
- TDREND_SRC_REND_t *SrcRend_p;
- int16_t itd;
- int16_t previtd;
- int16_t filterlength;
- float mem_itd[ITD_MEM_LEN];
- float hrf_left_prev[SFX_SPAT_BIN_MAX_FILTER_LENGTH]; /* Todo: Should we allocate these buffers with malloc() instead of the maximum length? */
- float hrf_right_prev[SFX_SPAT_BIN_MAX_FILTER_LENGTH];
- float azim_prev;
- float elev_prev;
- float mem_hrf_left[SFX_SPAT_BIN_MAX_FILTER_LENGTH - 1];
- float mem_hrf_right[SFX_SPAT_BIN_MAX_FILTER_LENGTH - 1];
- float Gain;
-} TDREND_SRC_t;
-
-/* Top level TD binaural renderer handle */
-typedef struct ivas_binaural_td_rendering_struct
-{
- TDREND_MixSpatSpec_t *TdRend_MixSpatSpec_p;
- TDREND_DirAtten_t *DirAtten_p;
- int16_t NumOfSrcs;
- int16_t MaxSrcInd;
-
- TDREND_SRC_t *Sources[MAX_NUM_TDREND_CHANNELS];
-
- float Gain; /* Mixer gain */
- TDREND_MIX_Listener_t *Listener_p; /* The virtual listener */
- TDREND_HRFILT_FiltSet_t *HrFiltSet_p; /* HR filter set */
-
- int16_t UseCommonDistAttenModel; /* Use common dist atten model (TRUE/FALSE) */
- int16_t DistAttenEnabled; /* (TRUE/FALSE) */
- TDREND_DistAttenModel_t DistAttenModel; /* Common distance attenuation model */
-
-} BINAURAL_TD_OBJECT_RENDERER, *BINAURAL_TD_OBJECT_RENDERER_HANDLE;
-
-
-/*------------------------------------------------------------------------------------------*
- * Crend structures
- *------------------------------------------------------------------------------------------*/
-// VE2AT: move to ivas_rom_rend.h ?
-typedef struct ivas_hrtfs_structure
-{
- float *pOut_to_bin_re[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS];
- float *pOut_to_bin_im[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS];
- float *pOut_to_bin_diffuse_re[BINAURAL_CHANNELS];
- float *pOut_to_bin_diffuse_im[BINAURAL_CHANNELS];
- float latency_s;
- uint16_t num_iterations[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS];
- uint16_t num_iterations_diffuse[BINAURAL_CHANNELS];
- uint16_t *pIndex_frequency_max[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS];
- uint16_t *pIndex_frequency_max_diffuse[BINAURAL_CHANNELS];
- uint16_t index_frequency_max_diffuse;
- int16_t max_num_ir;
- int16_t max_num_iterations;
- float inv_diffuse_weight[MAX_INTERN_CHANNELS]; /* inverse diffuse weights array, access one inverse weight by pInvDiffuseWeight[channel] */
- float gain_lfe;
-
-} HRTFS_DATA, *HRTFS_HANDLE;
-
-/* Reverberator structures */
-
-
-typedef struct ivas_roomAcoustics_t
-{
- int16_t override;
- int16_t use_brir;
- int16_t late_reverb_on;
- int16_t nBands; /* Number of frequency bands for which reverb properties are provided, integer, range [2..256] */
- float pFc_input[CLDFB_NO_CHANNELS_MAX]; /* Center frequencies for which following values are provided: */
- float pAcoustic_rt60[CLDFB_NO_CHANNELS_MAX]; /* - The room's T60 per center frequency */
- float pAcoustic_dsr[CLDFB_NO_CHANNELS_MAX]; /* - The room's Diffuse to Source Ratio per center frequency */
- float acousticPreDelay; /* Time elapsed between input signal and late reverberation start, float, range [0.001..10] */
- float inputPreDelay; /* Offset in seconds from where DSR is computed in the RIR (0 = at source), float, range [0.001..10] */
-
-} ivas_roomAcoustics_t;
-
-typedef struct ivas_render_config_t
-{
-#ifdef DEBUGGING
- ivas_renderTypeOverride renderer_type_override;
-#endif
- ivas_roomAcoustics_t roomAcoustics;
-
-} RENDER_CONFIG_DATA, *RENDER_CONFIG_HANDLE;
-
-
-typedef struct ivas_rev_delay_line_t
-{
- float *pBuffer;
- uint16_t MaxDelay;
- int16_t Delay;
- uint16_t BufferPos;
- float Gain;
-
-} ivas_rev_delay_line_t;
-
-typedef struct ivas_rev_iir_filter_t
-{
- uint16_t MaxTaps;
- uint16_t nr_taps;
- uint16_t isFIR;
- float Output;
- float CoefA[IVAS_REV_MAX_IIR_FILTER_LENGTH];
- float CoefB[IVAS_REV_MAX_IIR_FILTER_LENGTH];
- float pBuffer[IVAS_REV_MAX_IIR_FILTER_LENGTH];
-
-} ivas_rev_iir_filter_t;
-
-
-typedef float rv_fftwf_type_complex[2]; /* complex type of fftwf library */
-
-/* Convertion block for FFT filter: from time domain to frequency domain (with OLS) and back */
-typedef struct ivas_reverb_t2f_f2t_t
-{
- int16_t fft_size;
- int16_t log2_fft_size;
- int16_t block_size;
- int16_t hist_size; /* rv_fft_size - rv_block_size */
- float fft_history_L[RV_FILTER_MAX_HISTORY];
- float fft_history_R[RV_FILTER_MAX_HISTORY];
-
-} ivas_reverb_t2f_f2t_t;
-
-/* FFT filter with its frequency response coefficients */
-typedef struct ivas_reverb_fft_filter_t
-{
- int16_t fft_size;
- float fft_spectrum[RV_FILTER_MAX_FFT_SIZE];
-
-} ivas_reverb_fft_filter_t;
-
-
-typedef struct ivas_reverb_state_t
-{
- RENDER_CONFIG_DATA pConfig;
-
- /* input downmixer: */
- float dmx_gain; /* downmix gain */
-
- /* predelay: */
- ivas_rev_delay_line_t predelay_line;
- float *pPredelay_buffer;
-
- /* jot reverberator: */
- uint16_t nr_of_branches; /* number of feedback loops */
- ivas_rev_delay_line_t delay_line[IVAS_REV_MAX_NR_BRANCHES]; /* feedback loop delays */
- float *loop_delay_buffer[IVAS_REV_MAX_NR_BRANCHES]; /* feedback loop delay sample buffers */
- ivas_rev_iir_filter_t t60[IVAS_REV_MAX_NR_BRANCHES]; /* feedback loop filters */
- float gain_matrix[IVAS_REV_MAX_NR_BRANCHES][IVAS_REV_MAX_NR_BRANCHES]; /* feedback matrix */
- float mixer[BINAURAL_CHANNELS][IVAS_REV_MAX_NR_BRANCHES]; /* output mixer matrix */
-
- /* binauralization filters: */
- int16_t do_corr_filter;
- ivas_reverb_t2f_f2t_t fft_filter_ols;
- ivas_reverb_fft_filter_t fft_filter_correl_0;
- ivas_reverb_fft_filter_t fft_filter_correl_1;
- ivas_reverb_fft_filter_t fft_filter_color_0;
- ivas_reverb_fft_filter_t fft_filter_color_1;
- uint16_t fft_size; /* fft processing size */
- uint16_t fft_subblock_size; /* fft block processing size */
- uint16_t num_fft_subblocks; /* number of fft subblocks */
- uint16_t full_block_size; /* full block processing size */
-
-} REVERB_DATA, *REVERB_HANDLE;
-
-
-typedef struct ivas_orient_trk_state_t
-{
- OTR_TRACKING_T trackingType;
- float centerAdaptationRate;
- float offCenterAdaptationRate;
- float adaptationAngle;
-
- float alpha;
-
- float absYaw; /* absolute orientation */
- float absPitch;
- float absRoll;
-
- float absAvgYaw; /* average absolute orientation */
- float absAvgPitch;
- float absAvgRoll;
-
- float refYaw; /* reference orientation */
- float refPitch;
- float refRoll;
-
- float trkYaw; /* tracked orientation */
- float trkPitch;
- float trkRoll;
-
-} ivas_orient_trk_state_t;
-
-
-/* Main Crend structure */
-typedef struct ivas_crend_state_t
-{
- float *freq_buffer_re[MAX_INTERN_CHANNELS];
- float *freq_buffer_im[MAX_INTERN_CHANNELS];
- float *freq_buffer_re_diffuse;
- float *freq_buffer_im_diffuse;
- float *prev_out_buffer[BINAURAL_CHANNELS];
- float *lfe_delay_line;
- float m_fYaw;
- float m_fPitch;
- float m_fRoll;
- ivas_orient_trk_state_t *hTrack;
- REVERB_HANDLE hReverb;
- int16_t delay_line_rw_index;
- int16_t diffuse_delay_line_rw_index;
-
-} CREND_DATA, *CREND_HANDLE;
-
-
-/* htrfs from binary files. */
-
-typedef struct ivas_hrtfs_crend_structure
-{
- HRTFS_DATA *hHRTF_hrir_combined;
- HRTFS_DATA *hHRTF_hrir_hoa3;
- HRTFS_DATA *hHRTF_brir_combined;
-
-} HRTFS_CREND, *HRTFS_CREND_HANDLE;
-
-typedef struct ivas_hrtfs_header_t
-{
- int32_t rend_type;
- int32_t input_cfg;
- int32_t frequency;
- uint32_t data_size;
-
-} ivas_hrtfs_header_t;
-
-typedef struct ivas_hrtfs_file_header_t
-{
- char identifier[8];
- int32_t file_size;
- int16_t nb_hrtf;
- int32_t max_data_size;
-
-} ivas_hrtfs_file_header_t;
-
-
-/*----------------------------------------------------------------------------------*
- * LFE decoder structure
- *----------------------------------------------------------------------------------*/
-
-typedef struct ivas_lfe_dec_data_structure
-{
- ivas_filters_process_state_t filter_state;
- LFE_WINDOW_HANDLE pWindow_state;
- const uint16_t *cum_freq_models[IVAS_MAX_NUM_QUANT_STRATS][IVAS_MAX_NUM_DCT_COEF_GROUPS];
- int16_t lfe_dec_indices_coeffs_tbl[IVAS_MAX_NUM_QUANT_STRATS][IVAS_MAX_NUM_DCT_COEF_GROUPS];
- float lfe_block_delay_s;
- int16_t lfe_prior_buf_len;
- float *prior_out_buffer;
-
- float *prevsynth_buf;
- float *lfe_delay_buf;
- int16_t lfe_addl_delay;
- int16_t bfi_count;
-
-} LFE_DEC_DATA, *LFE_DEC_HANDLE;
-
-
-/*----------------------------------------------------------------------------------*
- * Limiter structure
- *----------------------------------------------------------------------------------*/
-
-typedef struct
-{
- int16_t max_num_channels;
- int16_t num_channels;
- float **channel_ptrs;
- int32_t sampling_rate;
- float gain;
- float release_heuristic;
- float attack_constant;
- int16_t strong_saturation_count;
-#ifdef DEBUGGING
- int32_t cnt_frames_limited; /* counter of frames in which the limiter is applied */
-#endif
-
-} IVAS_LIMITER, *IVAS_LIMITER_HANDLE;
-
-
/*----------------------------------------------------------------------------------*
* Decoder configuration structure
*----------------------------------------------------------------------------------*/
@@ -1904,7 +1141,6 @@ typedef struct decoder_config_structure
} DECODER_CONFIG, *DECODER_CONFIG_HANDLE;
-#endif
/*----------------------------------------------------------------------------------*
*
* Main IVAS decoder structure
diff --git a/lib_dec/ivas_vbap.c b/lib_dec/ivas_vbap.c
index e0deb652dc6a0625fcb4367423cac58fce789b9b..9c595ea1fee5f33f38a2ab91b42696e1329438c5 100644
--- a/lib_dec/ivas_vbap.c
+++ b/lib_dec/ivas_vbap.c
@@ -29,7 +29,7 @@
the United Nations Convention on Contracts on the International Sales of Goods.
*******************************************************************************************************/
-// VE2AT: move to lib_rend ?
+
#include
#include "options.h"
#include
@@ -95,6 +95,26 @@ typedef struct connection_option
float arc_weighted;
} ConnectionOption;
+enum SpeakerNodeGroup
+{
+ SPEAKER_NODE_BOTTOM_HALF,
+ SPEAKER_NODE_HORIZONTAL,
+ SPEAKER_NODE_TOP_HALF,
+ SPEAKER_NODE_BACK,
+ SPEAKER_NODE_ALL
+};
+
+/* Defines a single speaker node */
+typedef struct vbap_speaker_node_structure
+{
+ float azi_deg;
+ float ele_deg;
+ float unit_vec[3];
+ enum SpeakerNodeGroup group;
+
+} VBAP_SPEAKER_NODE;
+
+
/*-----------------------------------------------------------------------*
* Local function prototypes
*-----------------------------------------------------------------------*/
diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c
index 61114b9a6b3d7739045c20da2c7d85ffaca7dca9..a1fee7f0fd9371c0820a909c35c4f534b145d16d 100644
--- a/lib_dec/lib_dec.c
+++ b/lib_dec/lib_dec.c
@@ -32,6 +32,7 @@
#include "lib_dec.h"
#include "ivas_prot.h"
+#include "ivas_prot_rend.h"
#include "prot.h"
#include "jbm_jb4sb.h"
#include "jbm_pcmdsp_apa.h"
diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c
index 36505b966c90a109defd0a54197ab5949af7c487..ca307b02471edb96a86b5ca6b1555d594009984a 100644
--- a/lib_enc/ivas_spar_encoder.c
+++ b/lib_enc/ivas_spar_encoder.c
@@ -114,7 +114,7 @@ ivas_error ivas_spar_enc_open(
}
/* Transient Detector handle */
- if ( ( error = ivas_spar_transient_det_open( &( hSpar->hTranDet ), input_Fs ) ) != IVAS_ERR_OK )
+ if ( ( error = ivas_transient_det_open( &( hSpar->hTranDet ), input_Fs ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -256,7 +256,7 @@ void ivas_spar_enc_close(
ivas_FB_mixer_close( &hSpar->hFbMixer, input_Fs );
/* Trans Det handle */
- ivas_spar_transient_det_close( &hSpar->hTranDet );
+ ivas_transient_det_close( &hSpar->hTranDet );
/* AGC */
ivas_spar_agc_enc_close( &hSpar->hAgcEnc );
diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h
index 1f88d0c0c1e9c371edbad7bd526f17cf6769c5dc..8a96430129d3362a2317f416f6d27c3a193592e8 100644
--- a/lib_enc/ivas_stat_enc.h
+++ b/lib_enc/ivas_stat_enc.h
@@ -35,10 +35,9 @@
#include
#include "options.h"
-#include "ivas_cnst.h"
#include "cnst.h"
-#include "stat_enc.h"
#include "ivas_cnst.h"
+#include "stat_enc.h"
#include "ivas_stat_com.h"
/*----------------------------------------------------------------------------------*
diff --git a/lib_rend/ivas_allrad_dec.c b/lib_rend/ivas_allrad_dec.c
index ada7c2c6d106d00933248de425db7b2afb02b20b..fc840755aac643e05fd0fc9f514ab29373433b7e 100644
--- a/lib_rend/ivas_allrad_dec.c
+++ b/lib_rend/ivas_allrad_dec.c
@@ -31,14 +31,12 @@
*******************************************************************************************************/
#include
+#include "options.h"
#include
#include
-#include
-#include
-#include "options.h"
#include "prot.h"
#include "ivas_prot.h"
-#include "ivas_stat_dec.h"
+#include "ivas_prot_rend.h"
#include "ivas_rom_rend.h"
#ifdef DEBUGGING
#include "debug.h"
diff --git a/lib_rend/ivas_binaural_reverb.c b/lib_rend/ivas_binaural_reverb.c
deleted file mode 100644
index ccff4323afb27d57b8aab0bd80d991197930b00b..0000000000000000000000000000000000000000
--- a/lib_rend/ivas_binaural_reverb.c
+++ /dev/null
@@ -1,547 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-#include
-#include "options.h"
-#include
-#include "ivas_prot.h"
-#include "prot.h"
-#include "ivas_rom_com.h"
-#include "ivas_rom_binauralRenderer.h"
-#ifdef DEBUGGING
-#include "debug.h"
-#endif
-#include "wmc_auto.h"
-
-
-/* The reverberator structure implemented here is described in detail in:
- * Vilkamo, J., Neugebauer, B., & Plogsties, J. (2012). Sparse frequency-domain reverberator.
- * Journal of the Audio Engineering Society, 59(12), 936-943. */
-
-/*-------------------------------------------------------------------------
- * Local constants
- *------------------------------------------------------------------------*/
-
-#define BIN_REND_RANDOM_SEED 1 /* random seed for generating reverb decorrelators */
-
-#define CLDFB_SLOTS_PER_SECOND 800 /* Used for initializing reverb */
-
-/*-------------------------------------------------------------------------
- * ivas_binaural_reverb_processFrame()
- *
- * Compute the reverberation - room effect
- *------------------------------------------------------------------------*/
-
-void ivas_binaural_reverb_processFrame(
- REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */
- const int16_t numInChannels, /* i : num inputs to be processed */
- float inReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : input CLDFB data real, Comment: This change swaps two first dimensions as first dimension is not constant. */
- float inImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : input CLDFB data imag */
- float outReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : output CLDFB data real */
- float outImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : output CLDFB data imag */
- const uint8_t offsetSamplesIO /* i : number of offset samples */
-)
-{
- /* Declare the required variables */
- int16_t idx, bin, ch, sample, invertSampleIndex, tapIdx, *phaseShiftTypePr;
- float **tapRealPr, **tapImagPr;
-
- /* 1) Rotate the data in the loop buffer of the reverberator.
- * Notice that the audio at the loop buffers is at time-inverted order
- * for convolution purposes later on. */
- for ( bin = 0; bin < hReverb->numBins; bin++ )
- {
- /* Move the data forwards by blockSize (i.e. by the frame size of 16 CLDFB slots) */
- mvr2r( hReverb->loopBufReal[bin], hReverb->loopBufReal[bin] + hReverb->blockSize, hReverb->loopBufLength[bin] );
- mvr2r( hReverb->loopBufImag[bin], hReverb->loopBufImag[bin] + hReverb->blockSize, hReverb->loopBufLength[bin] );
-
- /* Add the data from the end of the loop to the beginning, with an attenuation factor
- * according to RT60. This procedure generates an IIR decaying response. The response
- * is decorrelated later on. */
- v_multc( hReverb->loopBufReal[bin] + hReverb->loopBufLength[bin], hReverb->loopAttenuationFactor[bin], hReverb->loopBufReal[bin], hReverb->blockSize );
- v_multc( hReverb->loopBufImag[bin] + hReverb->loopBufLength[bin], hReverb->loopAttenuationFactor[bin], hReverb->loopBufImag[bin], hReverb->blockSize );
- }
-
- /* 2) Apply the determined pre-delay to the input audio, and add the delayed audio to the loop. */
- idx = hReverb->preDelayBufferIndex;
- for ( sample = 0; sample < hReverb->blockSize; sample++ )
- {
- uint16_t sampleWithOffset;
- sampleWithOffset = sample + offsetSamplesIO;
- invertSampleIndex = hReverb->blockSize - sample - 1;
- for ( bin = 0; bin < hReverb->numBins; bin++ )
- {
- /* Add from pre-delay buffer a sample to the loop buffer, in a time-inverted order.
- * Also apply the spectral gains determined for the reverberation */
- hReverb->loopBufReal[bin][invertSampleIndex] += hReverb->preDelayBufferReal[idx][bin] * hReverb->reverbEqGains[bin];
- hReverb->loopBufImag[bin][invertSampleIndex] += hReverb->preDelayBufferImag[idx][bin] * hReverb->reverbEqGains[bin];
- hReverb->preDelayBufferReal[idx][bin] = 0.0f;
- hReverb->preDelayBufferImag[idx][bin] = 0.0f;
- }
-
- /* Add every second input channel as is to the pre-delay buffer, and every second input channel with
- * 90 degrees phase shift to reduce energy imbalances between coherent and incoherent sounds */
- for ( ch = 0; ch < numInChannels; ch++ )
- {
- if ( ch % 2 )
- {
- v_add( hReverb->preDelayBufferReal[idx], inReal[ch][sampleWithOffset], hReverb->preDelayBufferReal[idx], hReverb->numBins );
- v_add( hReverb->preDelayBufferImag[idx], inImag[ch][sampleWithOffset], hReverb->preDelayBufferImag[idx], hReverb->numBins );
- }
- else
- {
- v_sub( hReverb->preDelayBufferReal[idx], inImag[ch][sampleWithOffset], hReverb->preDelayBufferReal[idx], hReverb->numBins );
- v_add( hReverb->preDelayBufferImag[idx], inReal[ch][sampleWithOffset], hReverb->preDelayBufferImag[idx], hReverb->numBins );
- }
- }
- idx = ( idx + 1 ) % hReverb->preDelayBufferLength;
- }
- hReverb->preDelayBufferIndex = idx;
-
- /* 3) Perform the filtering/decorrelating, using complex and sparse FIR filtering */
- for ( bin = 0; bin < hReverb->numBins; bin++ )
- {
- for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
- {
- /* These tap pointers have been determined to point to the loop buffer at sparse locations */
- tapRealPr = hReverb->tapPointersReal[bin][ch];
- tapImagPr = hReverb->tapPointersImag[bin][ch];
- phaseShiftTypePr = hReverb->tapPhaseShiftType[bin][ch];
-
- /* Flush output */
- set_f( hReverb->outputBufferReal[bin][ch], 0.0f, hReverb->blockSize );
- set_f( hReverb->outputBufferImag[bin][ch], 0.0f, hReverb->blockSize );
-
- /* Add from temporally decaying sparse tap locations the audio to the output. */
- for ( tapIdx = 0; tapIdx < hReverb->taps[bin][ch]; tapIdx++ )
- {
- switch ( phaseShiftTypePr[tapIdx] )
- {
- case 0: /* 0 degrees phase */
- v_add( hReverb->outputBufferReal[bin][ch], tapRealPr[tapIdx], hReverb->outputBufferReal[bin][ch], hReverb->blockSize );
- v_add( hReverb->outputBufferImag[bin][ch], tapImagPr[tapIdx], hReverb->outputBufferImag[bin][ch], hReverb->blockSize );
- break;
- case 1: /* 90 degrees phase */
- v_sub( hReverb->outputBufferReal[bin][ch], tapImagPr[tapIdx], hReverb->outputBufferReal[bin][ch], hReverb->blockSize );
- v_add( hReverb->outputBufferImag[bin][ch], tapRealPr[tapIdx], hReverb->outputBufferImag[bin][ch], hReverb->blockSize );
- break;
- case 2: /* 180 degrees phase */
- v_sub( hReverb->outputBufferReal[bin][ch], tapRealPr[tapIdx], hReverb->outputBufferReal[bin][ch], hReverb->blockSize );
- v_sub( hReverb->outputBufferImag[bin][ch], tapImagPr[tapIdx], hReverb->outputBufferImag[bin][ch], hReverb->blockSize );
- break;
- default: /* 270 degrees phase */
- v_add( hReverb->outputBufferReal[bin][ch], tapImagPr[tapIdx], hReverb->outputBufferReal[bin][ch], hReverb->blockSize );
- v_sub( hReverb->outputBufferImag[bin][ch], tapRealPr[tapIdx], hReverb->outputBufferImag[bin][ch], hReverb->blockSize );
- break;
- }
- }
- }
-
- /* Generate diffuse field binaural coherence by mixing the incoherent reverberated channels with pre-defined gains */
- if ( bin <= hReverb->highestBinauralCoherenceBin )
- {
- if ( hReverb->useBinauralCoherence )
- {
- for ( sample = 0; sample < hReverb->blockSize; sample++ )
- {
- float leftRe, rightRe, leftIm, rightIm;
-
- leftRe = hReverb->binauralCoherenceDirectGains[bin] * hReverb->outputBufferReal[bin][0][sample] + hReverb->binauralCoherenceCrossmixGains[bin] * hReverb->outputBufferReal[bin][1][sample];
- rightRe = hReverb->binauralCoherenceDirectGains[bin] * hReverb->outputBufferReal[bin][1][sample] + hReverb->binauralCoherenceCrossmixGains[bin] * hReverb->outputBufferReal[bin][0][sample];
- leftIm = hReverb->binauralCoherenceDirectGains[bin] * hReverb->outputBufferImag[bin][0][sample] + hReverb->binauralCoherenceCrossmixGains[bin] * hReverb->outputBufferImag[bin][1][sample];
- rightIm = hReverb->binauralCoherenceDirectGains[bin] * hReverb->outputBufferImag[bin][1][sample] + hReverb->binauralCoherenceCrossmixGains[bin] * hReverb->outputBufferImag[bin][0][sample];
-
- hReverb->outputBufferReal[bin][0][sample] = leftRe;
- hReverb->outputBufferReal[bin][1][sample] = rightRe;
- hReverb->outputBufferImag[bin][0][sample] = leftIm;
- hReverb->outputBufferImag[bin][1][sample] = rightIm;
- }
- }
- }
- }
-
- /* 4) Write data to output */
- for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
- {
- for ( sample = 0; sample < hReverb->blockSize; sample++ )
- {
- uint16_t sampleWithOffset;
-
- sampleWithOffset = sample + offsetSamplesIO;
- /* Audio was in the temporally inverted order for convolution, re-invert audio to output */
- invertSampleIndex = hReverb->blockSize - sample - 1;
-
- for ( bin = 0; bin < hReverb->numBins; bin++ )
- {
- outReal[ch][sampleWithOffset][bin] = hReverb->outputBufferReal[bin][ch][invertSampleIndex];
- outImag[ch][sampleWithOffset][bin] = hReverb->outputBufferImag[bin][ch][invertSampleIndex];
- }
- for ( ; bin < CLDFB_NO_CHANNELS_MAX; bin++ )
- {
- outReal[ch][sampleWithOffset][bin] = 0.0f;
- outImag[ch][sampleWithOffset][bin] = 0.0f;
- }
- }
- }
-
- return;
-}
-
-
-/*-------------------------------------------------------------------------
- * binRend_rand()
- *
- *
- *------------------------------------------------------------------------*/
-
-static uint16_t binRend_rand(
- REVERB_STRUCT_HANDLE hReverb /* i/o: binaural reverb handle */
-)
-{
- hReverb->binRend_RandNext = hReverb->binRend_RandNext * 1103515245 + 12345;
-
- return (uint16_t) ( hReverb->binRend_RandNext / 65536 ) % 32768;
-}
-
-
-/*-------------------------------------------------------------------------
- * ivas_binaural_reverb_setPreDelay()
- *
- *
- *------------------------------------------------------------------------*/
-
-void ivas_binaural_reverb_setPreDelay(
- REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */
- const int16_t delaySamples /* i : reverb pre-delay in CLDFB slots */
-)
-{
- if ( delaySamples < 1 )
- {
- hReverb->preDelayBufferLength = 1;
-
- return;
- }
-
- if ( delaySamples > REVERB_PREDELAY_MAX )
- {
- hReverb->preDelayBufferLength = REVERB_PREDELAY_MAX;
-
- return;
- }
-
- hReverb->preDelayBufferLength = delaySamples;
-
- return;
-}
-
-
-/*-------------------------------------------------------------------------
- * ivas_binaural_reverb_setReverbTimes()
- *
- *
- *------------------------------------------------------------------------*/
-
-void ivas_binaural_reverb_setReverbTimes(
- REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */
- const int32_t output_Fs, /* i : sampling_rate */
- const float *revTimes, /* i : reverberation times T60 for each CLDFB bin in seconds */
- const float *revEnes /* i : spectrum for reverberated sound at each CLDFB bin */
-)
-{
- int16_t bin, ch, tap, sample;
- float binCenterFreq, diffuseFieldICC, tmpVal, attenuationFactorPerSample;
- float intendedEnergy, actualizedEnergy, energyBuildup, currentEnergy, attenuationFactorPerSampleSq;
-
- hReverb->binRend_RandNext = (uint16_t) BIN_REND_RANDOM_SEED;
- hReverb->highestBinauralCoherenceBin = 0;
- for ( bin = 0; bin < hReverb->numBins; bin++ )
- {
- /* Determine the diffuse field binaural coherence */
- binCenterFreq = ( (float) bin + 0.5f ) / ( (float) hReverb->numBins ) * ( (float) output_Fs ) / 2.0f;
- if ( bin == 0 )
- {
- diffuseFieldICC = 1.0f;
- }
- else if ( binCenterFreq < 2700.0f )
- {
- diffuseFieldICC = sinf( EVS_PI * binCenterFreq / 550.0f + 1e-20f ) / ( EVS_PI * binCenterFreq / 550.0f + 1e-20f ) * ( 1.0f - binCenterFreq / 2700.0f );
- hReverb->highestBinauralCoherenceBin = bin;
- }
- else
- {
- diffuseFieldICC = 0.0f;
- }
-
- /* Mixing gains to generate a diffuse-binaural sound based on incoherent sound */
- tmpVal = ( 1.0f - sqrtf( 1.0f - powf( diffuseFieldICC, 2.0 ) ) ) / 2.0f;
- if ( diffuseFieldICC > 0 )
- {
- hReverb->binauralCoherenceCrossmixGains[bin] = sqrtf( fabsf( tmpVal ) );
- }
- else
- {
- hReverb->binauralCoherenceCrossmixGains[bin] = -sqrtf( fabsf( tmpVal ) );
- }
- hReverb->binauralCoherenceDirectGains[bin] = sqrtf( 1.0f - fabsf( tmpVal ) );
-
- /* Determine attenuation factor that generates the appropriate energy decay according to reverberation time */
- attenuationFactorPerSample = powf( 10.0f, -3.0f * ( 1.0f / ( (float) CLDFB_SLOTS_PER_SECOND * revTimes[bin] ) ) );
- hReverb->loopAttenuationFactor[bin] = powf( attenuationFactorPerSample, hReverb->loopBufLength[bin] );
- attenuationFactorPerSampleSq = attenuationFactorPerSample * attenuationFactorPerSample;
-
- /* Design sparse decorrelation filters. The decorrelation filters, due to random procedures involved,
- * may affect the spectrum of the output. The spectral effect is therefore monitored and compensated for. */
- intendedEnergy = 0.0f;
- actualizedEnergy = 0.0f;
-
- for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
- {
- energyBuildup = 0.0f;
- currentEnergy = 1.0f;
- tap = 0;
-
- for ( sample = 0; sample < hReverb->loopBufLength[bin]; sample++ )
- {
- intendedEnergy += currentEnergy;
-
- /* The randomization at the energy build up affects where the sparse taps are located */
- energyBuildup += currentEnergy + 0.1f * ( (float) binRend_rand( hReverb ) / PCM16_TO_FLT_FAC - 0.5f );
-
- if ( energyBuildup >= 1.0f ) /* A new filter tap is added at this condition */
- {
- /* Four efficient phase operations: n*pi/2, n=0,1,2,3 */
- hReverb->tapPhaseShiftType[bin][ch][tap] = (int16_t) ( binRend_rand( hReverb ) % 4 );
- /* Set the tapPointer to point to the determined sample at the loop buffer */
- hReverb->tapPointersReal[bin][ch][tap] = &( hReverb->loopBufReal[bin][sample] );
- hReverb->tapPointersImag[bin][ch][tap] = &( hReverb->loopBufImag[bin][sample] );
- energyBuildup -= 1.0f; /* A tap is added, thus remove its energy from the buildup */
- tap++;
- actualizedEnergy += 1.0f;
- }
- currentEnergy *= attenuationFactorPerSampleSq;
- }
- hReverb->taps[bin][ch] = tap; /* Number of taps determined at the above random procedure */
- }
-
- /* The decorrelator design and IIR attenuation rate affects the energy of reverb, which is compensated here */
- hReverb->reverbEqGains[bin] = sqrtf( revEnes[bin] ); /* Determined reverb spectrum */
- hReverb->reverbEqGains[bin] *= sqrtf( intendedEnergy / actualizedEnergy ); /* Correction of random effects at the decorrelator design */
- hReverb->reverbEqGains[bin] *= sqrtf( 0.5f * ( 1.0f - attenuationFactorPerSampleSq ) ); /* Correction of IIR decay rate */
- }
-
- return;
-}
-
-
-/*-------------------------------------------------------------------------
- * ivas_binaural_reverb_open()
- *
- * Allocate and initialize binaural room reverberator handle
- *------------------------------------------------------------------------*/
-
-ivas_error ivas_binaural_reverb_open(
- REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */
- const int16_t numBins, /* i : number of CLDFB bins */
- const int16_t numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame */
- ivas_roomAcoustics_t *roomAcoustics, /* i/o: room acoustics parameters */
- const AUDIO_CONFIG output_config, /* i : output audio configuration */
- const int32_t sampling_rate, /* i : sampling rate */
- const RENDERER_TYPE renderer_type /* i : renderer type */
- ,
- const HRTFS_FASTCONV_HANDLE hHrtfFastConv, /* i : FastConv HRTF handle */
- const HRTFS_PARAMBIN_HANDLE hHrtfParambin /* i : Parametric binauralizer HRTF handle */
-)
-{
- int16_t bin, chIdx, k, len;
- REVERB_STRUCT_HANDLE hReverb;
- const float *revTimes;
- float t60[CLDFB_NO_CHANNELS_MAX];
- float ene[CLDFB_NO_CHANNELS_MAX];
-
- if ( ( *hReverbPr = (REVERB_STRUCT_HANDLE) malloc( sizeof( REVERB_STRUCT ) ) ) == NULL )
- {
- return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) );
- }
-
- hReverb = *hReverbPr;
-
- hReverb->useBinauralCoherence = 1;
- hReverb->preDelayBufferLength = 1;
- hReverb->preDelayBufferIndex = 0;
-
- hReverb->numBins = numBins;
- hReverb->blockSize = numCldfbSlotsPerFrame;
-
- for ( k = 0; k < REVERB_PREDELAY_MAX + 1; k++ )
- {
- set_f( hReverb->preDelayBufferReal[k], 0.0f, hReverb->numBins );
- set_f( hReverb->preDelayBufferImag[k], 0.0f, hReverb->numBins );
- }
-
- if ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM )
- {
- if ( !roomAcoustics->override )
- {
- revTimes = hHrtfFastConv->fastconvReverberationTimes;
- }
- else
- {
- revTimes = t60;
- }
- }
- else
- {
- revTimes = hHrtfParambin->parametricReverberationTimes;
- }
-
- for ( bin = 0; bin < hReverb->numBins; bin++ )
- {
- /* Loop Buffer */
- hReverb->loopBufLengthMax[bin] = (int16_t) ( 500 / ( 1 + bin ) + ( CLDFB_NO_CHANNELS_MAX - bin ) );
-
- len = hReverb->loopBufLengthMax[bin] + hReverb->blockSize;
- if ( ( hReverb->loopBufReal[bin] = (float *) malloc( len * sizeof( float ) ) ) == NULL )
- {
- return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) );
- }
-
- if ( ( hReverb->loopBufImag[bin] = (float *) malloc( len * sizeof( float ) ) ) == NULL )
- {
- return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) );
- }
-
- set_f( hReverb->loopBufReal[bin], 0.0f, len );
- set_f( hReverb->loopBufImag[bin], 0.0f, len );
-
- /* Determine loop buffer length. The following formula is manually tuned to generate sufficiently long
- * but not excessively long loops to generate reverberation. */
- /* Note: the resulted length is very sensitive to the precision of the constants below (e.g. 1.45 vs. 1.45f) */
- hReverb->loopBufLength[bin] = (int16_t) ( 1.45 * (int16_t) ( revTimes[bin] * 150.0 ) + 1 );
- hReverb->loopBufLength[bin] = min( hReverb->loopBufLength[bin], hReverb->loopBufLengthMax[bin] );
-
- /* Sparse Filter Tap Locations */
- for ( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ )
- {
- len = hReverb->loopBufLength[bin];
-
- if ( ( hReverb->tapPhaseShiftType[bin][chIdx] = (int16_t *) malloc( len * sizeof( int16_t ) ) ) == NULL )
- {
- return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) );
- }
- set_s( hReverb->tapPhaseShiftType[bin][chIdx], 0, len );
-
- if ( ( hReverb->tapPointersReal[bin][chIdx] = (float **) malloc( len * sizeof( float * ) ) ) == NULL )
- {
- return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) );
- }
-
- if ( ( hReverb->tapPointersImag[bin][chIdx] = (float **) malloc( len * sizeof( float * ) ) ) == NULL )
- {
- return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) );
- }
-
- len = hReverb->blockSize;
- if ( ( hReverb->outputBufferReal[bin][chIdx] = (float *) malloc( len * sizeof( float ) ) ) == NULL )
- {
- return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) );
- }
-
- if ( ( hReverb->outputBufferImag[bin][chIdx] = (float *) malloc( len * sizeof( float ) ) ) == NULL )
- {
- return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) );
- }
-
- set_f( hReverb->outputBufferReal[bin][chIdx], 0.0f, len );
- set_f( hReverb->outputBufferImag[bin][chIdx], 0.0f, len );
- }
- }
-
- if ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM )
- {
- if ( !roomAcoustics->override )
- {
- ivas_binaural_reverb_setReverbTimes( hReverb, sampling_rate, hHrtfFastConv->fastconvReverberationTimes, hHrtfFastConv->fastconvReverberationEneCorrections );
- ivas_binaural_reverb_setPreDelay( hReverb, 10 );
- }
- else
- {
- ivas_reverb_prepare_cldfb_params( roomAcoustics, hHrtfFastConv, output_config, roomAcoustics->use_brir, sampling_rate, t60, ene );
- ivas_binaural_reverb_setReverbTimes( hReverb, sampling_rate, t60, ene );
- ivas_binaural_reverb_setPreDelay( hReverb, (int16_t) roundf( 48000.0f * roomAcoustics->acousticPreDelay / CLDFB_NO_CHANNELS_MAX ) );
- }
- }
- else
- {
- ivas_binaural_reverb_setReverbTimes( hReverb, sampling_rate, hHrtfParambin->parametricReverberationTimes, hHrtfParambin->parametricReverberationEneCorrections );
- ivas_binaural_reverb_setPreDelay( hReverb, 10 );
- }
-
- return IVAS_ERR_OK;
-}
-
-
-/*-------------------------------------------------------------------------
- * ivas_binaural_reverb_close()
- *
- * Close binaural room reverberator handle
- *------------------------------------------------------------------------*/
-
-void ivas_binaural_reverb_close(
- REVERB_STRUCT_HANDLE *hReverb /* i/o: binaural reverb handle */
-)
-{
- int16_t bin, chIdx;
-
- if ( hReverb == NULL || *hReverb == NULL )
- {
- return;
- }
-
- for ( bin = 0; bin < ( *hReverb )->numBins; bin++ )
- {
- for ( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ )
- {
- free( ( *hReverb )->tapPhaseShiftType[bin][chIdx] );
- free( ( *hReverb )->tapPointersReal[bin][chIdx] );
- free( ( *hReverb )->tapPointersImag[bin][chIdx] );
- free( ( *hReverb )->outputBufferReal[bin][chIdx] );
- free( ( *hReverb )->outputBufferImag[bin][chIdx] );
- }
- free( ( *hReverb )->loopBufReal[bin] );
- free( ( *hReverb )->loopBufImag[bin] );
- }
-
- free( ( *hReverb ) );
- ( *hReverb ) = NULL;
-
- return;
-}
diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c
index f3ea41f08156d92ad28ddefe55f2640feb425742..03df4a559b4bf9f9f469055b9bbe756b7fc109c0 100644
--- a/lib_rend/ivas_crend.c
+++ b/lib_rend/ivas_crend.c
@@ -34,18 +34,13 @@
#include "options.h"
#include "prot.h"
#include "ivas_prot.h"
+#include "ivas_prot_rend.h"
#include "ivas_cnst.h"
#include "ivas_rom_rend.h"
-#include "ivas_stat_dec.h"
#include
#include "ivas_rom_binaural_crend_head.h"
-#ifdef FIX_197_CREND_INTERFACE
#include "ivas_stat_rend.h"
#include "lib_rend.h"
-#else
-#include "lib_rend.h"
-#include "ivas_lib_rend_internal.h"
-#endif
#ifdef DEBUGGING
#include "debug.h"
#endif
@@ -878,74 +873,6 @@ ivas_error ivas_crend_init_from_setofhrtf(
* Destroy the HRTF CRend handle
*---------------------------------------------------------------------*/
-static ivas_error destroy_HRTF(
- HRTFS_HANDLE *hHRTF /* i/o: HRTF CRend handle */
-)
-{
- uint16_t i, j;
-
- if ( *hHRTF != NULL && hHRTF != NULL )
- {
- for ( i = 0; i < MAX_INTERN_CHANNELS; i++ )
- {
- for ( j = 0; j < BINAURAL_CHANNELS; j++ )
- {
- if ( ( *hHRTF )->pIndex_frequency_max[i][j] != NULL )
- {
- free( ( *hHRTF )->pIndex_frequency_max[i][j] );
- }
- if ( ( *hHRTF )->pOut_to_bin_re[i][j] != NULL )
- {
- free( ( *hHRTF )->pOut_to_bin_re[i][j] );
- }
- if ( ( *hHRTF )->pOut_to_bin_im[i][j] != NULL )
- {
- free( ( *hHRTF )->pOut_to_bin_im[i][j] );
- }
- }
- }
- for ( j = 0; j < BINAURAL_CHANNELS; j++ )
- {
- if ( ( *hHRTF )->pIndex_frequency_max_diffuse[j] != NULL )
- {
- free( ( *hHRTF )->pIndex_frequency_max_diffuse[j] );
- }
- if ( ( *hHRTF )->pOut_to_bin_diffuse_re[j] != NULL )
- {
- free( ( *hHRTF )->pOut_to_bin_diffuse_re[j] );
- }
- if ( ( *hHRTF )->pOut_to_bin_diffuse_im[j] != NULL )
- {
- free( ( *hHRTF )->pOut_to_bin_diffuse_im[j] );
- }
- }
-
- free( *hHRTF );
- *hHRTF = NULL;
- }
-
- return IVAS_ERR_OK;
-}
-
-/*---------------------------------------------------------------------*
- * destroy_SetOfHRTF()
- *
- * Destroy the HRTF data set.
- *---------------------------------------------------------------------*/
-
-ivas_error destroy_SetOfHRTF(
- HRTFS_CREND_HANDLE hSetOfHRTF /* i/o: Set of HRTF CRend handle */
-)
-{
- if ( hSetOfHRTF != NULL )
- {
- destroy_HRTF( &( hSetOfHRTF->hHRTF_hrir_combined ) );
- destroy_HRTF( &( hSetOfHRTF->hHRTF_hrir_hoa3 ) );
- destroy_HRTF( &( hSetOfHRTF->hHRTF_brir_combined ) );
- }
-
- return IVAS_ERR_OK;
-}
#endif
#ifndef FIX_197_CREND_INTERFACE
@@ -1454,10 +1381,10 @@ ivas_error ivas_crend_process(
* Allocate and initialize crend renderer handle
*------------------------------------------------------------------------*/
-ivas_error ivas_rend_initCrend(
+static ivas_error ivas_rend_initCrend(
CREND_WRAPPER *pCrend,
- const IVAS_REND_AudioConfig inConfig,
- const IVAS_REND_AudioConfig outConfig,
+ const AUDIO_CONFIG inIvasConfig,
+ const AUDIO_CONFIG outIvasConfig,
RENDER_CONFIG_DATA *hRendCfg,
HRTFS_CREND_HANDLE hSetOfHRTF,
const int32_t output_Fs )
@@ -1468,6 +1395,11 @@ ivas_error ivas_rend_initCrend(
IVAS_REND_AudioConfigType inConfigType;
HRTFS_HANDLE hHrtf;
ivas_error error;
+ IVAS_REND_AudioConfig inConfig;
+ IVAS_REND_AudioConfig outConfig;
+
+ inConfig = getRendAudioConfigFromIvasAudioConfig( inIvasConfig );
+ outConfig = getRendAudioConfigFromIvasAudioConfig( outIvasConfig );
inConfigType = getAudioConfigType( inConfig );
hHrtf = pCrend->hHrtfCrend;
@@ -1980,8 +1912,8 @@ ivas_error ivas_rend_openCrend(
#else
CREND_WRAPPER *pCrend,
#endif
- const IVAS_REND_AudioConfig inConfig,
- const IVAS_REND_AudioConfig outConfig,
+ const AUDIO_CONFIG inConfig,
+ const AUDIO_CONFIG outConfig,
RENDER_CONFIG_DATA *hRendCfg,
#ifdef FIX_197_CREND_INTERFACE
int16_t Opt_Headrotation,
@@ -2029,9 +1961,7 @@ ivas_error ivas_rend_openCrend(
#else
if ( pCrend->hHrtfCrend == NULL )
{
- if ( ( error = ivas_rend_initCrend( pCrend, inConfig, outConfig, hRendCfg,
- hSetOfHRTF,
- output_Fs ) ) != IVAS_ERR_OK )
+ if ( ( error = ivas_rend_initCrend( pCrend, inConfig, outConfig, hRendCfg, hSetOfHRTF, output_Fs ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -2156,7 +2086,7 @@ ivas_error ivas_rend_openCrend(
if ( ( hRendCfg != NULL ) && ( hRendCfg->roomAcoustics.late_reverb_on ) )
{
if ( ( error = ivas_reverb_open( &( hCrend->hReverb ),
- getIvasAudioConfigFromRendAudioConfig( inConfig ),
+ inConfig,
#ifdef FIX_197_CREND_INTERFACE
( *pCrend )->hHrtfCrend,
#else
@@ -2343,8 +2273,6 @@ ivas_error ivas_rend_closeCrend(
#endif
}
-#ifdef FIX_197_CREND_INTERFACE
-
/*-----------------------------------------------------------------------------------------*
* Function ivas_crend_convolver()
*
@@ -2498,7 +2426,6 @@ static ivas_error ivas_rend_crendConvolver(
return IVAS_ERR_OK;
}
-#endif
/*-----------------------------------------------------------------------------------------*
* Function ivas_rend_crend_Process()
@@ -2508,8 +2435,8 @@ static ivas_error ivas_rend_crendConvolver(
ivas_error ivas_rend_crendProcess(
const CREND_WRAPPER *pCrend,
- const IVAS_REND_AudioConfig inConfig,
- const IVAS_REND_AudioConfig outConfig,
+ const AUDIO_CONFIG inConfig,
+ const AUDIO_CONFIG outConfig,
#ifdef FIX_197_CREND_INTERFACE
DECODER_CONFIG_HANDLE hDecoderConfig,
HEAD_TRACK_DATA_HANDLE hHeadTrackData,
@@ -2529,12 +2456,23 @@ ivas_error ivas_rend_crendProcess(
AUDIO_CONFIG in_config;
IVAS_REND_AudioConfigType inConfigType;
ivas_error error;
+ IVAS_REND_AudioConfig inRendConfig;
+ IVAS_REND_AudioConfig outRendConfig;
push_wmops( "ivas_rend_crendProcess" );
- in_config = getIvasAudioConfigFromRendAudioConfig( inConfig );
- inConfigType = getAudioConfigType( inConfig );
- getAudioConfigNumChannels( outConfig, &nchan_out );
+ inRendConfig = getRendAudioConfigFromIvasAudioConfig( inConfig );
+ outRendConfig = getRendAudioConfigFromIvasAudioConfig( outConfig );
+
+#ifdef FIX_197_CREND_INTERFACE
+ in_config = getIvasAudioConfigFromRendAudioConfig( inRendConfig );
+#else
+ in_config = rendAudioConfigToIvasAudioConfig( inRendConfig );
+#endif
+
+ inConfigType = getAudioConfigType( inRendConfig );
+ getAudioConfigNumChannels( outRendConfig, &nchan_out );
+
output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC );
#ifdef FIX_197_CREND_INTERFACE
subframe_len = output_frame / MAX_PARAM_SPATIAL_SUBFRAMES;
@@ -2581,7 +2519,7 @@ ivas_error ivas_rend_crendProcess(
if ( ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) || ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS ) )
{
- if ( ( error = ivas_rend_crendConvolver( pCrend, inConfig, outConfig, output, pcm_tmp, output_Fs, subframe_idx ) ) != IVAS_ERR_OK )
+ if ( ( error = ivas_rend_crendConvolver( pCrend, inRendConfig, outRendConfig, output, pcm_tmp, output_Fs, subframe_idx ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -2610,160 +2548,3 @@ ivas_error ivas_rend_crendProcess(
return IVAS_ERR_OK;
}
-
-#ifndef FIX_197_CREND_INTERFACE
-
-/*-----------------------------------------------------------------------------------------*
- * Function ivas_crend_convolver()
- *
- * Convolver block
- *-----------------------------------------------------------------------------------------*/
-
-ivas_error ivas_rend_crendConvolver(
- const CREND_WRAPPER *pCrend,
- IVAS_REND_AudioConfig inConfig,
- IVAS_REND_AudioConfig outConfig,
- float pcm_in[][L_FRAME48k],
- float pcm_out[][L_FRAME48k],
- const int32_t output_Fs,
- const int16_t i_ts )
-{
- int16_t i, j, k, m;
- int16_t subframe_length, idx_in;
- int16_t lfe_idx_in;
- int16_t offset, offset_in, offset_diffuse;
- int16_t nchan_in, nchan_out;
- float *pIn;
- float *pFreq_buf_re, *pFreq_buf_im;
- float *pFreq_filt_re, *pFreq_filt_im;
- float pOut[L_FRAME48k * 2];
- float tmp_out_re[L_FRAME48k], tmp_out_im[L_FRAME48k];
-
- getAudioConfigNumChannels( inConfig, &nchan_in );
- getAudioConfigNumChannels( outConfig, &nchan_out );
-
- subframe_length = (int16_t) ( output_Fs / FRAMES_PER_SEC ) / MAX_PARAM_SPATIAL_SUBFRAMES;
-
- lfe_idx_in = -1;
- if ( getAudioConfigType( inConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED )
- {
- if ( inConfig != IVAS_REND_AUDIO_CONFIG_LS_CUSTOM )
- {
- lfe_idx_in = LFE_CHANNEL;
- }
- else
- {
- assert( 0 && "Custom LS not supported in CRend" );
- }
- }
-
- offset = pCrend->hCrend->delay_line_rw_index * subframe_length; /* subframe_length * ( pCrend->hHrtfCrend->max_num_iterations - 1 ); */
- offset_diffuse = pCrend->hCrend->diffuse_delay_line_rw_index * subframe_length; /* subframe_length *( pCrend->hHrtfCrend->num_iterations_diffuse[0] - 1 ); */
-
- if ( pCrend->hHrtfCrend->num_iterations_diffuse[0] > 0 )
- {
- set_zero( &pCrend->hCrend->freq_buffer_re_diffuse[offset_diffuse], subframe_length );
- set_zero( &pCrend->hCrend->freq_buffer_im_diffuse[offset_diffuse], subframe_length );
- }
-
- i = 0;
- for ( idx_in = 0; idx_in < nchan_in; idx_in++ )
- {
- pIn = &pcm_in[idx_in][i_ts * subframe_length];
- if ( idx_in != lfe_idx_in )
- {
- if ( pCrend->hHrtfCrend->num_iterations_diffuse[0] > 0 )
- {
- pFreq_buf_re = &pCrend->hCrend->freq_buffer_re_diffuse[offset_diffuse];
- pFreq_buf_im = &pCrend->hCrend->freq_buffer_im_diffuse[offset_diffuse];
- pFreq_filt_re = &pCrend->hCrend->freq_buffer_re[i][offset];
- pFreq_filt_im = &pCrend->hCrend->freq_buffer_im[i][offset];
-
- for ( k = 0; k < pCrend->hHrtfCrend->index_frequency_max_diffuse; k++ )
- {
- pFreq_buf_re[k] += pFreq_filt_re[k] * pCrend->hHrtfCrend->inv_diffuse_weight[i];
- pFreq_buf_im[k] += pFreq_filt_im[k] * pCrend->hHrtfCrend->inv_diffuse_weight[i];
- }
- }
-
- pFreq_buf_re = &pCrend->hCrend->freq_buffer_re[i][offset];
- pFreq_buf_im = &pCrend->hCrend->freq_buffer_im[i][offset];
-
- ivas_mdft( pIn, pFreq_buf_re, pFreq_buf_im, subframe_length, subframe_length );
- i++;
- }
- }
-
- for ( j = 0; j < nchan_out; j++ )
- {
- set_zero( tmp_out_re, subframe_length );
- set_zero( tmp_out_im, subframe_length );
-
- i = 0;
- for ( idx_in = 0; idx_in < nchan_in; idx_in++ )
- {
- if ( idx_in != lfe_idx_in )
- {
- offset = 0;
- for ( m = 0; m < pCrend->hHrtfCrend->num_iterations[i][j]; m++ )
- {
- offset_in = ( pCrend->hCrend->delay_line_rw_index + pCrend->hHrtfCrend->max_num_iterations - pCrend->hHrtfCrend->num_iterations[i][j] + m + 1 );
- offset_in = offset_in % ( pCrend->hHrtfCrend->max_num_iterations );
- offset_in = offset_in * subframe_length;
- pFreq_buf_re = &pCrend->hCrend->freq_buffer_re[i][offset_in];
- pFreq_buf_im = &pCrend->hCrend->freq_buffer_im[i][offset_in];
- pFreq_filt_re = &pCrend->hHrtfCrend->pOut_to_bin_re[i][j][offset];
- pFreq_filt_im = &pCrend->hHrtfCrend->pOut_to_bin_im[i][j][offset];
-
- for ( k = 0; k < pCrend->hHrtfCrend->pIndex_frequency_max[i][j][m]; k++ )
- {
- tmp_out_re[k] += pFreq_buf_re[k] * pFreq_filt_re[k] - pFreq_buf_im[k] * pFreq_filt_im[k];
- tmp_out_im[k] += pFreq_buf_re[k] * pFreq_filt_im[k] + pFreq_buf_im[k] * pFreq_filt_re[k];
- }
- offset = offset + k;
- }
- i++;
- }
- }
-
- offset = 0;
- for ( m = 0; m < pCrend->hHrtfCrend->num_iterations_diffuse[j]; m++ )
- {
- offset_diffuse = ( pCrend->hCrend->diffuse_delay_line_rw_index + m + 1 );
- offset_diffuse = offset_diffuse % pCrend->hHrtfCrend->num_iterations_diffuse[0];
- offset_diffuse = offset_diffuse * subframe_length;
- pFreq_buf_re = &pCrend->hCrend->freq_buffer_re_diffuse[offset_diffuse];
- pFreq_buf_im = &pCrend->hCrend->freq_buffer_im_diffuse[offset_diffuse];
- pFreq_filt_re = &pCrend->hHrtfCrend->pOut_to_bin_diffuse_re[j][offset];
- pFreq_filt_im = &pCrend->hHrtfCrend->pOut_to_bin_diffuse_im[j][offset];
-
- for ( k = 0; k < pCrend->hHrtfCrend->pIndex_frequency_max_diffuse[j][m]; k++ )
- {
- tmp_out_re[k] += pFreq_buf_re[k] * pFreq_filt_re[k] - pFreq_buf_im[k] * pFreq_filt_im[k];
- tmp_out_im[k] += pFreq_buf_re[k] * pFreq_filt_im[k] + pFreq_buf_im[k] * pFreq_filt_re[k];
- }
- offset = offset + k;
- }
-
- ivas_imdft( tmp_out_re, tmp_out_im, pOut, subframe_length );
-
- pFreq_buf_re = &pcm_out[j][i_ts * subframe_length];
- for ( k = 0; k < subframe_length; k++ )
- {
- pFreq_buf_re[k] = pOut[k] + pCrend->hCrend->prev_out_buffer[j][k];
- pCrend->hCrend->prev_out_buffer[j][k] = pOut[k + subframe_length];
- }
- }
-
- pCrend->hCrend->delay_line_rw_index++;
- pCrend->hCrend->delay_line_rw_index = pCrend->hCrend->delay_line_rw_index % ( pCrend->hHrtfCrend->max_num_iterations );
- if ( pCrend->hHrtfCrend->num_iterations_diffuse[0] > 0 )
- {
- pCrend->hCrend->diffuse_delay_line_rw_index++;
- pCrend->hCrend->diffuse_delay_line_rw_index = pCrend->hCrend->diffuse_delay_line_rw_index % ( pCrend->hHrtfCrend->num_iterations_diffuse[0] );
- }
-
- return IVAS_ERR_OK;
-}
-
-#endif
diff --git a/lib_dec/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c
similarity index 99%
rename from lib_dec/ivas_dirac_dec_binaural_functions.c
rename to lib_rend/ivas_dirac_dec_binaural_functions.c
index 8a9b38a9d5cbf7cc958d496690c55f8ea43eba99..020dd27cfa1b47d827fcf82d00f7e45094865297 100644
--- a/lib_dec/ivas_dirac_dec_binaural_functions.c
+++ b/lib_rend/ivas_dirac_dec_binaural_functions.c
@@ -29,16 +29,17 @@
the United Nations Convention on Contracts on the International Sales of Goods.
*******************************************************************************************************/
-// VE2AT: move to lib_rend ?
+
#include
#include "options.h"
#include
#include
#include "prot.h"
#include "ivas_prot.h"
+#include "ivas_prot_rend.h"
#include "ivas_cnst.h"
-#include "ivas_rom_binauralRenderer.h" // VE2AT: what about to put these includes ust into ivas_rom_rend.c ?
-#include "ivas_rom_dec.h"
+#include "ivas_rom_binauralRenderer.h"
+#include "ivas_rom_rend.h"
#ifdef DEBUGGING
#include "debug.h"
#endif
@@ -260,7 +261,7 @@ ivas_error ivas_dirac_dec_init_binaural_data(
{
if ( hBinaural->hTdDecorr == NULL )
{
- ivas_spar_td_decorr_dec_open( &( hBinaural->hTdDecorr ), output_Fs, 3, 1 );
+ ivas_td_decorr_dec_open( &( hBinaural->hTdDecorr ), output_Fs, 3, 1 );
}
if ( st_ivas->hDecoderConfig->ivas_total_brate < IVAS_24k4 )
@@ -274,12 +275,12 @@ ivas_error ivas_dirac_dec_init_binaural_data(
}
else
{
- ivas_spar_td_decorr_dec_open( &( hBinaural->hTdDecorr ), output_Fs, 3, 0 );
+ ivas_td_decorr_dec_open( &( hBinaural->hTdDecorr ), output_Fs, 3, 0 );
}
}
else
{
- ivas_spar_td_decorr_dec_close( &( hBinaural->hTdDecorr ) );
+ ivas_td_decorr_dec_close( &( hBinaural->hTdDecorr ) );
}
st_ivas->hDiracDecBin = hBinaural;
@@ -308,7 +309,7 @@ void ivas_dirac_dec_close_binaural_data(
ivas_binaural_reverb_close( &( ( *hBinaural )->hReverb ) );
}
- ivas_spar_td_decorr_dec_close( &( ( *hBinaural )->hTdDecorr ) );
+ ivas_td_decorr_dec_close( &( ( *hBinaural )->hTdDecorr ) );
free( *hBinaural );
*hBinaural = NULL;
diff --git a/lib_rend/ivas_efap.c b/lib_rend/ivas_efap.c
index 587046082db95dbfaaf3bb3ed5b6e43e847d4c79..4301d75dec749b89b32404dbcad9c59de9dd329e 100644
--- a/lib_rend/ivas_efap.c
+++ b/lib_rend/ivas_efap.c
@@ -37,8 +37,8 @@
#include "options.h"
#include "prot.h"
#include "ivas_prot.h"
+#include "ivas_prot_rend.h"
#include "ivas_stat_dec.h"
-#include "ivas_rom_dec.h"
#ifdef DEBUGGING
#include "debug.h"
#endif
@@ -101,6 +101,7 @@ static float vertex_distance( const EFAP_VERTEX *vtxArray, const EFAP_LS_TRIANGL
static float point_plane_distance( const float P1[3], const float P2[3], const float P3[3], const float X[3] );
static float point_poly_distance( const EFAP_POLYSET poly, const float X[3] );
+
static void efap_crossp( const float *v1, const float *v2, float *v );
static int16_t find_int_in_tri( const EFAP_LS_TRIANGLE *tri, const int16_t n, const int16_t r, int16_t *pos );
diff --git a/lib_rend/ivas_hrtf.c b/lib_rend/ivas_hrtf.c
index 6e2483bba6c743f72fac471d2c4ad337d249760c..063893e13206b3c9749bd6d7764dbc9af7464852 100644
--- a/lib_rend/ivas_hrtf.c
+++ b/lib_rend/ivas_hrtf.c
@@ -33,192 +33,10 @@
#include
#include "options.h"
#include "prot.h"
-#include "ivas_prot.h"
-#include "lib_dec.h"
-#include "string.h"
-#include "assert.h"
-#include "ivas_rom_TdBinauralRenderer.h"
+#include "ivas_prot_rend.h"
#include "ivas_error.h"
#include "wmc_auto.h"
-/*-------------------------------------------------------------------*
- * Local constants
- *-------------------------------------------------------------------*/
-
-#define RESAMPLE_FACTOR_16_48 ( 16.0f / 48.0f )
-#define RESAMPLE_FACTOR_32_48 ( 32.0f / 48.0f )
-
-
-/*-------------------------------------------------------------------*
- * BSplineModelEvalAlloc()
- *
- * Allocate the B Spline HR Filter model.
- --------------------------------------------------------------------*/
-
-void BSplineModelEvalAlloc(
- ModelParams_t *model, /* i : Model parameters */
- ModelEval_t *modelEval /* i/o: Model evaluation structure */
-)
-{
- modelEval->hrfModL = (float *) malloc( model->K * sizeof( float ) );
- modelEval->hrfModR = (float *) malloc( model->K * sizeof( float ) );
-
- return;
-}
-
-
-/*-------------------------------------------------------------------*
- * DefaultBSplineModel()
- *
- * Init default HRTF model
- --------------------------------------------------------------------*/
-
-void DefaultBSplineModel(
- TDREND_HRFILT_FiltSet_t *HrFiltSet_p, /* o : Loaded HR filter set */
- const int32_t output_Fs /* i : Output sampling rate */
-)
-{
- ModelParams_t *model;
- ModelParamsITD_t *modelITD;
- int16_t i, j;
-
- HrFiltSet_p->FilterMethod = TDREND_HRFILT_Method_BSplineModel;
- model = &( HrFiltSet_p->ModelParams );
- modelITD = &( HrFiltSet_p->ModelParamsITD );
-
- /* Set ROM flag for correct deallocation */
- model->modelROM = TRUE;
-
- /* int16_t parameters */
- model->UseItdModel = 1;
- model->SplineDegree = 4;
- model->elevDim2 = 20;
- model->elevDim3 = 18;
- model->AlphaN = 578;
- model->num_unique_azim_splines = 1;
- model->elevSegSamples = 3;
- model->elevBsLen[0] = 4;
- model->elevBsLen[1] = 7;
- model->elevBsLen[2] = 10;
- model->elevBsLen[3] = 7;
- model->elevBsStart[0] = 0;
- model->elevBsStart[1] = 4;
- model->elevBsStart[2] = 11;
- model->elevBsStart[3] = 21;
-
- model->azimDim2 = orange53_rom_azimDim2;
- model->azimDim3 = orange53_rom_azimDim3;
- model->azim_start_idx = orange53_rom_azim_start_idx;
- model->azimSegSamples = orange53_rom_azimSegSamples;
- model->azimShapeIdx = orange53_rom_azimShapeIdx;
- model->azimShapeSampFactor = orange53_rom_azimShapeSampFactor;
-
- /* float parameters */
- model->elevKSeq = (const float *) orange53_rom_elevKSeq;
- model->elevBsShape = (const float *) orange53_rom_elevBsShape;
-
- model->azimBsShape = (const float **) malloc( model->num_unique_azim_splines * sizeof( float * ) );
- model->azimBsShape[0] = (const float *) orange53_rom_azimBsShape;
- model->azimKSeq = (float **) malloc( 18 * sizeof( float * ) );
- model->azimKSeq[0] = (float *) malloc( 2 * sizeof( float * ) );
- model->azimKSeq[17] = (float *) malloc( 2 * sizeof( float * ) );
- model->azimKSeq[0][0] = 0.0f;
- model->azimKSeq[17][0] = 0.0f;
- model->azimKSeq[0][1] = 360.0f;
- model->azimKSeq[17][1] = 360.0f;
-
- for ( i = 1; i < 17; i++ )
- {
- model->azimKSeq[i] = (float *) malloc( model->azimDim2[i] * sizeof( float * ) ); /* azimDim2[i] = 91, i=2..15 */
- for ( j = 0; j < model->azimDim2[i]; j++ )
- {
- model->azimKSeq[i][j] = (float) orange53_rom_azimSegSamples[0] * j;
- }
- }
-
- switch ( output_Fs )
- {
- case 48000:
- model->AlphaL = (const float *) orange53_rom_AlphaL48;
- model->AlphaR = (const float *) orange53_rom_AlphaR48;
- model->EL = (const float *) orange53_rom_EL48;
- model->ER = (const float *) orange53_rom_ER48;
- model->K = 128;
- if ( HrFiltSet_p->ModelParams.UseItdModel )
- {
- modelITD->resamp_factor = 1.0f;
- }
- break;
- case 32000:
- model->AlphaL = (const float *) orange53_rom_AlphaL32;
- model->AlphaR = (const float *) orange53_rom_AlphaR32;
- model->EL = (const float *) orange53_rom_EL32;
- model->ER = (const float *) orange53_rom_ER32;
- model->K = 86;
- if ( HrFiltSet_p->ModelParams.UseItdModel )
- {
- modelITD->resamp_factor = RESAMPLE_FACTOR_32_48;
- }
- break;
- case 16000:
- model->AlphaL = (const float *) orange53_rom_AlphaL16;
- model->AlphaR = (const float *) orange53_rom_AlphaR16;
- model->EL = (const float *) orange53_rom_EL16;
- model->ER = (const float *) orange53_rom_ER16;
- model->K = 43;
- if ( HrFiltSet_p->ModelParams.UseItdModel )
- {
- modelITD->resamp_factor = RESAMPLE_FACTOR_16_48;
- }
- break;
- default:
- break;
- }
-
- modelITD->N = 4;
- modelITD->elevDim2 = 20;
- modelITD->elevDim3 = 18;
- modelITD->azimDim2 = 41;
- modelITD->azimDim3 = 41;
- modelITD->elevSegSamples = 3;
- modelITD->elevBsLen[0] = 4;
- modelITD->elevBsLen[1] = 7;
- modelITD->elevBsLen[2] = 10;
- modelITD->elevBsLen[3] = 7;
- modelITD->elevBsStart[0] = 0;
- modelITD->elevBsStart[1] = 4;
- modelITD->elevBsStart[2] = 11;
- modelITD->elevBsStart[3] = 21;
-
- modelITD->elevKSeq = model->elevKSeq;
-
- modelITD->azimBsLen[0] = 11;
- modelITD->azimBsLen[1] = 21;
- modelITD->azimBsLen[2] = 31;
- modelITD->azimBsLen[3] = 21;
- modelITD->azimBsStart[0] = 0;
- modelITD->azimBsStart[1] = 11;
- modelITD->azimBsStart[2] = 32;
- modelITD->azimBsStart[3] = 63;
-
- modelITD->azimSegSamples = 10;
-
- modelITD->azimKSeq = orange53_rom_ITD_azimKSeq;
- modelITD->W = (const float *) orange53_rom_ITD_W;
- modelITD->azimBsShape = (const float *) orange53_rom_ITD_azimBsShape;
- modelITD->elevBsShape = (const float *) orange53_rom_ITD_elevBsShape;
-
- HRTF_model_precalc( model );
-
- HrFiltSet_p->latency_s = orange53_rom_latency_s;
- HrFiltSet_p->SampleRate = output_Fs;
- HrFiltSet_p->FiltLength = HrFiltSet_p->ModelParams.K;
- BSplineModelEvalAlloc( &HrFiltSet_p->ModelParams, &HrFiltSet_p->ModelEval );
-
- return;
-}
-
-
/*-----------------------------------------------------------------------*
* ivas_HRTF_binary_open()
*
@@ -283,6 +101,7 @@ ivas_error ivas_HRTF_CRend_binary_open(
return IVAS_ERR_OK;
}
+
/*-------------------------------------------------------------------*
* ivas_HRTF_CRend_binary_close()
*
@@ -307,6 +126,7 @@ void ivas_HRTF_CRend_binary_close(
return;
}
+
/*-----------------------------------------------------------------------*
* ivas_HRTF_fastconv_binary_open()
*
@@ -325,6 +145,7 @@ ivas_error ivas_HRTF_fastconv_binary_open(
return IVAS_ERR_OK;
}
+
/*-----------------------------------------------------------------------*
* ivas_HRTF_fastconv_binary_close()
*
@@ -345,6 +166,7 @@ void ivas_HRTF_fastconv_binary_close(
return;
}
+
/*-----------------------------------------------------------------------*
* ivas_HRTF_parambin_binary_open()
*
@@ -363,6 +185,7 @@ ivas_error ivas_HRTF_parambin_binary_open(
return IVAS_ERR_OK;
}
+
/*-----------------------------------------------------------------------*
* ivas_HRTF_parambin_binary_close()
*
@@ -382,3 +205,38 @@ void ivas_HRTF_parambin_binary_close(
return;
}
+
+
+/*-----------------------------------------------------------------------*
+ * ivas_headTrack_open()
+ *
+ * Allocate and initialize Head-Tracking handle
+ *-----------------------------------------------------------------------*/
+
+ivas_error ivas_headTrack_open(
+ HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* o : head track handle */
+)
+{
+ int16_t i;
+
+ /* Allocate Head-Tracking handle */
+ if ( ( *hHeadTrackData = (HEAD_TRACK_DATA_HANDLE) malloc( sizeof( HEAD_TRACK_DATA ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for head-tracking memory\n" ) );
+ }
+
+ /* Initialization */
+ ( *hHeadTrackData )->num_quaternions = 0;
+ ( *hHeadTrackData )->lrSwitchInterpVal = 0.0f;
+ ( *hHeadTrackData )->lrSwitchedCurrent = 0;
+ ( *hHeadTrackData )->lrSwitchedNext = 0;
+
+ /* Initialise Rmat_prev to I, Rmat will be computed later */
+ for ( i = 0; i < 3; i++ )
+ {
+ set_zero( ( *hHeadTrackData )->Rmat_prev[i], 3 );
+ ( *hHeadTrackData )->Rmat_prev[i][i] = 1.0f;
+ }
+
+ return IVAS_ERR_OK;
+}
diff --git a/lib_rend/ivas_lib_rend_internal.h b/lib_rend/ivas_lib_rend_internal.h
deleted file mode 100644
index 60d6ed7b51694d234b9154b21f9e2fce31823b97..0000000000000000000000000000000000000000
--- a/lib_rend/ivas_lib_rend_internal.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/******************************************************************************************************
-
- (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository. All Rights Reserved.
-
- This software is protected by copyright law and by international treaties.
- The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
- Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
- Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
- Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
- contributors to this repository retain full ownership rights in their respective contributions in
- the software. This notice grants no license of any kind, including but not limited to patent
- license, nor is any license granted by implication, estoppel or otherwise.
-
- Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
- contributions.
-
- This software is provided "AS IS", without any express or implied warranties. The software is in the
- development stage. It is intended exclusively for experts who have experience with such software and
- solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
- and fitness for a particular purpose are hereby disclaimed and excluded.
-
- Any dispute, controversy or claim arising under or in relation to providing this software shall be
- submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
- accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
- the United Nations Convention on Contracts on the International Sales of Goods.
-
-*******************************************************************************************************/
-
-#include "ivas_error.h"
-#ifdef FIX_197_CREND_INTERFACE
-#include "ivas_stat_rend.h"
-#else
-#include "lib_rend.h"
-#endif
-#include "ivas_stat_dec.h"
-
-#ifndef IVAS_LIB_REND_INTERNALS_H
-#define IVAS_LIB_REND_INTERNALS_H
-
-#ifndef FIX_197_CREND_INTERFACE
-typedef struct
-{
- int8_t headRotEnabled;
- IVAS_QUATERNION headPositions[RENDERER_HEAD_POSITIONS_PER_FRAME];
- float crossfade[L_FRAME48k / RENDERER_HEAD_POSITIONS_PER_FRAME];
-} IVAS_REND_HeadRotData;
-
-typedef struct
-{
- int32_t binaural_latency_ns;
- BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd;
- TDREND_HRFILT_FiltSet_t *hHrtfTD;
-} TDREND_WRAPPER;
-
-typedef struct
-{
- int32_t binaural_latency_ns;
- CREND_HANDLE hCrend;
- HRTFS_HANDLE hHrtfCrend;
-} CREND_WRAPPER;
-
-IVAS_REND_AudioConfigType getAudioConfigType(
- const IVAS_REND_AudioConfig config );
-
-ivas_error getAudioConfigNumChannels(
- const IVAS_REND_AudioConfig config,
- int16_t *numChannels );
-
-AUDIO_CONFIG getIvasAudioConfigFromRendAudioConfig(
- IVAS_REND_AudioConfig config );
-
-ivas_error ivas_rend_openCrend(
- CREND_WRAPPER *pCrend,
- const IVAS_REND_AudioConfig inConfig,
- const IVAS_REND_AudioConfig outConfig,
- RENDER_CONFIG_DATA *hRendCfg,
- HRTFS_CREND_HANDLE hSetOfHRTF,
- const int32_t output_Fs );
-
-ivas_error ivas_rend_initCrend(
- CREND_WRAPPER *pCrend,
- const IVAS_REND_AudioConfig inConfig,
- const IVAS_REND_AudioConfig outConfig,
- RENDER_CONFIG_DATA *hRendCfg,
- HRTFS_CREND_HANDLE hSetOfHRTF,
- const int32_t output_Fs );
-
-ivas_error ivas_rend_closeCrend(
- CREND_WRAPPER *pCrend );
-
-ivas_error ivas_rend_crendProcess(
- const CREND_WRAPPER *pCrend,
- const IVAS_REND_AudioConfig inConfig,
- const IVAS_REND_AudioConfig outConfig,
- float output[][L_FRAME48k], /* i/o: input/output audio channels */
- const int32_t output_Fs );
-
-ivas_error ivas_rend_crendConvolver(
- const CREND_WRAPPER *pCrend,
- const IVAS_REND_AudioConfig inConfig,
- const IVAS_REND_AudioConfig outConfig,
- float pcm_in[][L_FRAME48k],
- float pcm_out[][L_FRAME48k],
- const int32_t output_Fs,
- const int16_t i_ts );
-#endif
-
-ivas_error ivas_rend_TDObjRenderFrame(
- const TDREND_WRAPPER *pTDRend, /* i : TD Renderer wrapper structure */
- const IVAS_REND_AudioConfig inConfig, /* i : Input audio configuration */
- const LSSETUP_CUSTOM_STRUCT *customLsInput, /* i : Input custom loudspeaker layout */
- const IVAS_REND_HeadRotData *headRotData, /* i : Input head positions */
- const IVAS_REND_AudioObjectPosition *currentPos, /* i : Object position */
- const int16_t output_frame, /* i : output frame length */
- float output[][L_FRAME48k] /* i/o: SCE channels / Binaural synthesis */
-);
-
-ivas_error ivas_rend_TDObjRendOpen(
- TDREND_WRAPPER *pTDRend,
- const IVAS_REND_AudioConfig inConfig,
- LSSETUP_CUSTOM_STRUCT *customLsInput,
- const int32_t output_Fs );
-
-#endif
diff --git a/lib_rend/ivas_limiter.c b/lib_rend/ivas_limiter.c
index 19b1a828b7c7e2b9af57a1c5375cd366a6de1fb5..9ea9192e2ec20a1fdf708c40ef0a10eb2dbe9d9f 100644
--- a/lib_rend/ivas_limiter.c
+++ b/lib_rend/ivas_limiter.c
@@ -29,13 +29,12 @@
the United Nations Convention on Contracts on the International Sales of Goods.
*******************************************************************************************************/
-// VE2AT: keep in lib_rend or move to lib_dec ?
-#include
-#include
-#include
-#include "ivas_prot.h"
+#include
+#include "options.h"
+#include
#include "prot.h"
+#include "ivas_prot_rend.h"
#include "wmc_auto.h"
#include
diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c
index d52c0074b44b884dbc776879f298ad21629eb5eb..294c23c77f9d4d0a51fa85fb47f8f8d9f97d26e3 100644
--- a/lib_rend/ivas_objectRenderer.c
+++ b/lib_rend/ivas_objectRenderer.c
@@ -33,59 +33,29 @@
#include
#include "options.h"
#include "prot.h"
-#include "ivas_prot.h"
+#include "ivas_prot_rend.h"
#include
-#include "wmc_auto.h"
#include "ivas_rom_com.h"
-#include "lib_rend.h"
-#include "ivas_lib_rend_internal.h"
#ifdef DEBUGGING
#include "debug.h"
#endif
+#include "wmc_auto.h"
/*---------------------------------------------------------------------*
* Local function prototypes
*---------------------------------------------------------------------*/
-static ivas_error TDREND_GetMix( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, float output[][L_FRAME48k], const int16_t subframe_length, const int16_t subframe_idx );
static void TDREND_Clear_Update_flags( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd );
-static void TDREND_Update_listener_orientation( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd,
- const int16_t headRotEnabled,
- const IVAS_QUATERNION *headPosition );
-static void TDREND_Update_object_positions( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd,
- const int16_t numSources,
- const int16_t lfe_idx,
- const IVAS_FORMAT in_format,
- const ISM_METADATA_HANDLE *hIsmMetaData,
- float output[][L_FRAME48k] );
#ifdef FIX_198_TDREND_INTERFACE
-static ivas_error ivas_td_binaural_open_unwrap( TDREND_HRFILT_FiltSet_t **hHrtfTD, const int32_t output_Fs, const int16_t nchan_transport, const IVAS_FORMAT ivas_format, const AUDIO_CONFIG transport_config, const IVAS_OUTPUT_SETUP hTransSetup, BINAURAL_TD_OBJECT_RENDERER_HANDLE *hBinRendererTd, int32_t *binaural_latency_ns );
-static void ObjRenderIVASFrame_unwrap( RENDER_CONFIG_DATA *hRenderConfig, const int16_t ini_frame, CREND_WRAPPER_HANDLE hCrendWrapper, AUDIO_CONFIG transport_config, const int32_t output_Fs, BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, const int16_t nchan_transport, const int16_t lfe_idx, IVAS_FORMAT ivas_format, ISM_METADATA_HANDLE *hIsmMetaData, const int16_t Opt_Headrotation, const IVAS_QUATERNION *Quaternions, float output[][L_FRAME48k], const int16_t output_frame );
-
-/*---------------------------------------------------------------------*
- * ivas_td_binaural_open()
- *
- * Open and initialize TD Object binaural renderer
- *---------------------------------------------------------------------*/
-
-ivas_error ivas_td_binaural_open(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-)
-{
- return ivas_td_binaural_open_unwrap( &st_ivas->hHrtfTD, st_ivas->hDecoderConfig->output_Fs, st_ivas->nchan_transport, st_ivas->ivas_format,
- st_ivas->transport_config, st_ivas->hTransSetup, &st_ivas->hBinRendererTd, &st_ivas->binaural_latency_ns );
-}
-
-
/*---------------------------------------------------------------------*
* ivas_td_binaural_open_unwrap()
*
* Call TD open/init function without st_ivas
*---------------------------------------------------------------------*/
-static ivas_error ivas_td_binaural_open_unwrap(
+ivas_error ivas_td_binaural_open_unwrap(
TDREND_HRFILT_FiltSet_t **hHrtfTD, /* i/o: HR filter model (from file or NULL) */
const int32_t output_Fs, /* i : Output sampling rate */
const int16_t nchan_transport, /* i : Number of channels */
@@ -102,7 +72,7 @@ static ivas_error ivas_td_binaural_open_unwrap(
* Open and initialize TD Object binaural renderer
*---------------------------------------------------------------------*/
-ivas_error ivas_td_binaural_open(
+static ivas_error ivas_td_binaural_open(
Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
)
#endif
@@ -333,54 +303,40 @@ void ivas_td_binaural_close(
#ifdef FIX_198_TDREND_INTERFACE
/*---------------------------------------------------------------------*
- * ObjRenderIVASFrame()
+ * ivas_td_binaural_renderer_unwrap()
*
- * Receives the current frames for the object streams, updates metadata
- * and renders the current frame.
+ * Call ivas_td_binaural_renderer() without st_ivas.
*---------------------------------------------------------------------*/
-void ObjRenderIVASFrame(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
- float output[][L_FRAME48k], /* i/o: SCE channels / Binaural synthesis */
- const int16_t output_frame /* i : output frame length */
-)
-{
- ObjRenderIVASFrame_unwrap( st_ivas->hRenderConfig, st_ivas->ini_frame, st_ivas->hCrendWrapper, st_ivas->transport_config,
- st_ivas->hDecoderConfig->output_Fs, st_ivas->hBinRendererTd, st_ivas->nchan_transport, LFE_CHANNEL, st_ivas->ivas_format,
- st_ivas->hIsmMetaData, st_ivas->hDecoderConfig->Opt_Headrotation, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->Quaternions : NULL, output, output_frame );
-}
-
-/*---------------------------------------------------------------------*
- * ObjRenderIVASFrame_unwrap()
- *
- * Call ObjRenderIVASFrame without st_ivas.
- *---------------------------------------------------------------------*/
-
-static void ObjRenderIVASFrame_unwrap(
- RENDER_CONFIG_DATA *hRenderConfig, /*i : Renderer configuration */
- const int16_t ini_frame, /*i : Initialization frame counter */
- CREND_WRAPPER_HANDLE hCrendWrapper, /*i : Crend wrapper handle */
- AUDIO_CONFIG transport_config, /*i : Transport configuration */
- const int32_t output_Fs, /*i : Output sampling rate */
- BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /*i/o: TD binaural object renderer handle */
- const int16_t nchan_transport, /*i : Transport channels (ISms) */
- const int16_t lfe_idx, /*i : LFE channel index */
- IVAS_FORMAT ivas_format, /*i : IVAS format */
- ISM_METADATA_HANDLE *hIsmMetaData, /*i : ISM metadata handle */
- const int16_t Opt_Headrotation, /*i : Head rotation flag */
- const IVAS_QUATERNION *Quaternions, /*i : Head tracking data per subframe */
- float output[][L_FRAME48k], /* i/o: SCE channels / Binaural synthesis */
- const int16_t output_frame /* i : output frame length */
+void ivas_td_binaural_renderer_unwrap(
+ RENDER_CONFIG_DATA *hRenderConfig, /* i : Renderer configuration */
+ const int16_t ini_frame, /* i : Initialization frame counter */
+#ifdef FIX_197_CREND_INTERFACE
+ CREND_WRAPPER_HANDLE hCrendWrapper, /* i : Crend wrapper handle */
+#else
+ CREND_HANDLE hCrend, /* i : Crend handle */
+#endif
+ AUDIO_CONFIG transport_config, /* i : Transport configuration */
+ const int32_t output_Fs, /* i : Output sampling rate */
+ BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD binaural object renderer handle */
+ const int16_t nchan_transport, /* i : Transport channels (ISms) */
+ const int16_t lfe_idx, /* i : LFE channel index */
+ IVAS_FORMAT ivas_format, /* i : IVAS format */
+ ISM_METADATA_HANDLE *hIsmMetaData, /* i : ISM metadata handle */
+ const int16_t Opt_Headrotation, /* i : Head rotation flag */
+ const IVAS_QUATERNION *Quaternions, /* i : Head tracking data per subframe */
+ float output[][L_FRAME48k], /* i/o: SCE channels / Binaural synthesis */
+ const int16_t output_frame /* i : output frame length */
)
#else
/*---------------------------------------------------------------------*
- * ObjRenderIVASFrame()
+ * ivas_td_binaural_renderer()
*
* Receives the current frames for the object streams, updates metadata
* and renders the current frame.
*---------------------------------------------------------------------*/
-void ObjRenderIVASFrame(
+static void ivas_td_binaural_renderer(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
float output[][L_FRAME48k], /* i/o: SCE channels / Binaural synthesis */
const int16_t output_frame /* i : output frame length */
@@ -405,15 +361,29 @@ void ObjRenderIVASFrame(
if ( st_ivas->hRenderConfig->roomAcoustics.late_reverb_on && ( st_ivas->ini_frame == 0 ) )
#endif
{
-#ifdef FIX_197_CREND_INTERFACE
+ ivas_reverb_open(
#ifdef FIX_198_TDREND_INTERFACE
- ivas_reverb_open( &hCrendWrapper->hCrend->hReverb, transport_config, NULL, hRenderConfig, output_Fs );
+#ifdef FIX_197_CREND_INTERFACE
+ &hCrendWrapper->hCrend->hReverb,
#else
- ivas_reverb_open( &st_ivas->hCrendWrapper->hCrend->hReverb, st_ivas->transport_config, NULL, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs );
+ &hCrend->hReverb,
#endif
+ transport_config,
+ NULL,
+ hRenderConfig,
+ output_Fs
#else
- ivas_reverb_open( &st_ivas->hCrend->hReverb, st_ivas->transport_config, NULL, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs );
+#ifdef FIX_197_CREND_INTERFACE
+ &st_ivas->hCrendWrapper->hCrend->hReverb,
+#else
+ &st_ivas->hCrend->hReverb,
#endif
+ st_ivas->transport_config,
+ NULL,
+ st_ivas->hRenderConfig,
+ st_ivas->hDecoderConfig->output_Fs
+#endif
+ );
}
}
@@ -441,15 +411,47 @@ void ObjRenderIVASFrame(
if ( ( st_ivas->hRenderConfig != NULL ) && ( st_ivas->hRenderConfig->roomAcoustics.late_reverb_on ) )
#endif
{
+ ivas_reverb_process(
+#ifdef FIX_198_TDREND_INTERFACE
+#ifdef FIX_197_CREND_INTERFACE
+ hCrendWrapper->hCrend->hReverb,
+#else
+ hCrend->hReverb,
+#endif
+ transport_config,
+#else
#ifdef FIX_197_CREND_INTERFACE
+ st_ivas->hCrendWrapper->hCrend->hReverb,
+#else
+ st_ivas->hCrend->hReverb,
+#endif
+ st_ivas->transport_config,
+#endif
+ 0,
+ output,
+ reverb_signal,
+ subframe_idx );
+
+ ivas_reverb_process(
#ifdef FIX_198_TDREND_INTERFACE
- ivas_reverb_process( hCrendWrapper->hCrend->hReverb, transport_config, 0, output, reverb_signal, subframe_idx );
+#ifdef FIX_197_CREND_INTERFACE
+ hCrendWrapper->hCrend->hReverb,
#else
- ivas_reverb_process( st_ivas->hCrendWrapper->hCrend->hReverb, st_ivas->transport_config, 0, output, reverb_signal, subframe_idx );
+ hCrend->hReverb,
#endif
+ transport_config,
+#else
+#ifdef FIX_197_CREND_INTERFACE
+ st_ivas->hCrendWrapper->hCrend->hReverb,
#else
- ivas_reverb_process( st_ivas->hCrend->hReverb, st_ivas->transport_config, 0, output, reverb_signal, subframe_idx );
+ st_ivas->hCrend->hReverb,
+#endif
+ st_ivas->transport_config,
#endif
+ 0,
+ output,
+ reverb_signal,
+ subframe_idx );
}
/* Render subframe */
@@ -487,7 +489,8 @@ void ObjRenderIVASFrame(
*
* Render one 5 ms subframe from the mixer
*---------------------------------------------------------------------*/
-static ivas_error TDREND_GetMix(
+
+ivas_error TDREND_GetMix(
BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */
float output[][L_FRAME48k], /* i/o: ISm object synth / rendered output in 0,1 */
const int16_t subframe_length, /* i/o: subframe length */
@@ -569,13 +572,14 @@ static void TDREND_Clear_Update_flags(
return;
}
+
/*---------------------------------------------------------------------*
* TDREND_Update_object_positions()
*
* Update object position(s)
*---------------------------------------------------------------------*/
-static void TDREND_Update_object_positions(
+void TDREND_Update_object_positions(
BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o : TD Renderer handle */
const int16_t numSources, /* i : Number of sources to render */
const int16_t lfe_idx, /* i : Input LFE index */
@@ -631,13 +635,14 @@ static void TDREND_Update_object_positions(
return;
}
+
/*---------------------------------------------------------------------*
* TDREND_Update_listener_orientation()
*
* Update listener orientation (s)
*---------------------------------------------------------------------*/
-static void TDREND_Update_listener_orientation(
+void TDREND_Update_listener_orientation(
BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD Renderer handle */
const int16_t headRotEnabled, /* i : Headrotation flag */
const IVAS_QUATERNION *headPosition /* i : Head Position */
@@ -687,7 +692,13 @@ static void TDREND_Update_listener_orientation(
}
-ivas_error ivas_rend_TDObjRendOpen(
+/*---------------------------------------------------------------------*
+ * ivas_td_binaural_open_ext()
+ *
+ *
+ *---------------------------------------------------------------------*/
+
+ivas_error ivas_td_binaural_open_ext(
TDREND_WRAPPER *pTDRend,
IVAS_REND_AudioConfig inConfig,
LSSETUP_CUSTOM_STRUCT *customLsInput,
@@ -726,13 +737,16 @@ ivas_error ivas_rend_TDObjRendOpen(
{
nchan_transport = customLsInput->num_spk;
}
+#ifdef FIX_197_CREND_INTERFACE
transport_config = getIvasAudioConfigFromRendAudioConfig( inConfig );
+#else
+ transport_config = rendAudioConfigToIvasAudioConfig( inConfig );
+#endif
ivas_format = ( getAudioConfigType( inConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) ? MC_FORMAT : ISM_FORMAT;
hTransSetup.ls_azimuth = customLsInput->ls_azimuth;
hTransSetup.ls_elevation = customLsInput->ls_elevation;
- return ivas_td_binaural_open_unwrap( &pTDRend->hHrtfTD, outFs, nchan_transport, ivas_format, transport_config, hTransSetup, &pTDRend->hBinRendererTd,
- &pTDRend->binaural_latency_ns );
+ return ivas_td_binaural_open_unwrap( &pTDRend->hHrtfTD, outFs, nchan_transport, ivas_format, transport_config, hTransSetup, &pTDRend->hBinRendererTd, &pTDRend->binaural_latency_ns );
#else
error = IVAS_ERR_OK;
@@ -855,15 +869,16 @@ ivas_error ivas_rend_TDObjRendOpen(
#endif
}
+
/*---------------------------------------------------------------------*
- * ObjRenderIVASFrame()
+ * ivas_td_binaural_renderer_ext()
*
* Receives the current frames for the object streams, updates metadata
* and renders the current frame.
*---------------------------------------------------------------------*/
/*! r: TD Renderer result code. */
-ivas_error ivas_rend_TDObjRenderFrame(
+ivas_error ivas_td_binaural_renderer_ext(
const TDREND_WRAPPER *pTDRend, /* i : TD Renderer wrapper structure */
const IVAS_REND_AudioConfig inConfig, /* i : Input audio configuration */
const LSSETUP_CUSTOM_STRUCT *customLsInput, /* i : Input custom loudspeaker layout */
@@ -892,7 +907,7 @@ ivas_error ivas_rend_TDObjRenderFrame(
int32_t output_Fs;
#endif
- push_wmops( "ivas_rend_TDObjRenderFrame" );
+ push_wmops( "ivas_td_binaural_renderer_ext" );
inConfigType = getAudioConfigType( inConfig );
lfe_idx = LFE_CHANNEL;
@@ -931,12 +946,16 @@ ivas_error ivas_rend_TDObjRenderFrame(
#endif
#ifdef FIX_198_TDREND_INTERFACE
+#ifdef FIX_197_CREND_INTERFACE
transport_config = getIvasAudioConfigFromRendAudioConfig( inConfig );
+#else
+ transport_config = rendAudioConfigToIvasAudioConfig( inConfig );
+#endif
output_Fs = output_frame * 50;
- ObjRenderIVASFrame_unwrap( NULL, 1, NULL, transport_config, output_Fs, pTDRend->hBinRendererTd, num_src, lfe_idx,
- ivas_format, hIsmMetaData, headRotData->headRotEnabled, ( headRotData != NULL ) ? headRotData->headPositions : NULL,
- output, output_frame );
+ ivas_td_binaural_renderer_unwrap( NULL, 1, NULL, transport_config, output_Fs, pTDRend->hBinRendererTd, num_src, lfe_idx,
+ ivas_format, hIsmMetaData, headRotData->headRotEnabled, ( headRotData != NULL ) ? headRotData->headPositions : NULL,
+ output, output_frame );
#else
diff --git a/lib_rend/ivas_objectRenderer_hrFilt.c b/lib_rend/ivas_objectRenderer_hrFilt.c
index 206cd40e1e96b048f4ac55d4dd02b21b973d4b13..0220b481450f403294a5cc453e8931780e7f5f8e 100644
--- a/lib_rend/ivas_objectRenderer_hrFilt.c
+++ b/lib_rend/ivas_objectRenderer_hrFilt.c
@@ -35,10 +35,9 @@
#include "options.h"
#include "prot.h"
#include
-#include "ivas_prot.h"
+#include "ivas_prot_rend.h"
#include "ivas_rom_rend.h"
#include "ivas_cnst.h"
-#include "ivas_rom_TdBinauralRenderer.h"
#include "wmc_auto.h"
@@ -60,12 +59,12 @@ static void SkipSmallest_ValueIndex( int16_t *use_inds, const ValueIndex_t *VI,
--------------------------------------------------------------------*/
ivas_error TDREND_REND_RenderSourceHRFilt(
- TDREND_SRC_t *Src_p, /* i/o: The source to be rendered */
- const float *hrf_left_delta, /* i: Left filter interpolation delta */
- const float *hrf_right_delta, /* i: Right filter interpolation delta */
- const int16_t intp_count, /* i: Interpolation count */
- float output_buf[][L_SPATIAL_SUBFR_48k], /* o : Output buffer */
- const int16_t subframe_length /* i : Subframe length in use */
+ TDREND_SRC_t *Src_p, /* i/o: The source to be rendered */
+ const float *hrf_left_delta, /* i : Left filter interpolation delta */
+ const float *hrf_right_delta, /* i : Right filter interpolation delta */
+ const int16_t intp_count, /* i : Interpolation count */
+ float output_buf[][L_SPATIAL_SUBFR_48k], /* o : Output buffer */
+ const int16_t subframe_length /* i : Subframe length in use */
)
{
float LeftOutputFrame[L_SPATIAL_SUBFR_48k];
@@ -495,10 +494,10 @@ void HRTF_model_precalc(
maximum_s( model->azimDim3, model->elevDim3, &model->azimDim3Max );
-
return;
}
+
/*-------------------------------------------------------------------*
* BSplineModelEvalDealloc()
*
@@ -512,6 +511,7 @@ void BSplineModelEvalDealloc(
{
/* Allocated in LoadBSplineBinary() */
int16_t i;
+
if ( model->modelROM )
{
free( (void *) model->azimBsShape ); /* void* cast needed to please both gcc and Visual studio compilers. Deallocating const float** should be fine and gcc agrees, but Visual studio complains. */
diff --git a/lib_rend/ivas_objectRenderer_mix.c b/lib_rend/ivas_objectRenderer_mix.c
index 456bd4cd33370ea1a637420548c2af6a8ee7a8ec..9da9c2750c32b9d2227d402ee6b147cf3024ee83 100644
--- a/lib_rend/ivas_objectRenderer_mix.c
+++ b/lib_rend/ivas_objectRenderer_mix.c
@@ -33,13 +33,29 @@
#include
#include "options.h"
#include "prot.h"
-#include "ivas_prot.h"
+#include "ivas_prot_rend.h"
+#include "ivas_rom_TdBinauralRenderer.h"
#include "wmc_auto.h"
#ifdef DEBUGGING
#include "debug.h"
#endif
+/*-------------------------------------------------------------------*
+ * Local constants
+ *-------------------------------------------------------------------*/
+
+#define RESAMPLE_FACTOR_16_48 ( 16.0f / 48.0f )
+#define RESAMPLE_FACTOR_32_48 ( 32.0f / 48.0f )
+
+
+/*-------------------------------------------------------------------------
+ * Local functions
+ *-------------------------------------------------------------------------*/
+
+static void DefaultBSplineModel( TDREND_HRFILT_FiltSet_t *HrFiltSet_p, const int32_t output_Fs );
+
+
/*-------------------------------------------------------------------*
* TDREND_MIX_LIST_SetPos()
*
@@ -316,3 +332,174 @@ ivas_error TDREND_MIX_AddSrc(
return error;
}
+
+
+/*-------------------------------------------------------------------*
+ * BSplineModelEvalAlloc()
+ *
+ * Allocate the B Spline HR Filter model.
+ --------------------------------------------------------------------*/
+
+void BSplineModelEvalAlloc(
+ ModelParams_t *model, /* i : Model parameters */
+ ModelEval_t *modelEval /* i/o: Model evaluation structure */
+)
+{
+ modelEval->hrfModL = (float *) malloc( model->K * sizeof( float ) );
+ modelEval->hrfModR = (float *) malloc( model->K * sizeof( float ) );
+
+ return;
+}
+
+
+/*-------------------------------------------------------------------*
+ * DefaultBSplineModel()
+ *
+ * Init default HRTF model
+ --------------------------------------------------------------------*/
+
+static void DefaultBSplineModel(
+ TDREND_HRFILT_FiltSet_t *HrFiltSet_p, /* o : Loaded HR filter set */
+ const int32_t output_Fs /* i : Output sampling rate */
+)
+{
+ ModelParams_t *model;
+ ModelParamsITD_t *modelITD;
+ int16_t i, j;
+
+ HrFiltSet_p->FilterMethod = TDREND_HRFILT_Method_BSplineModel;
+ model = &( HrFiltSet_p->ModelParams );
+ modelITD = &( HrFiltSet_p->ModelParamsITD );
+
+ /* Set ROM flag for correct deallocation */
+ model->modelROM = TRUE;
+
+ /* int16_t parameters */
+ model->UseItdModel = 1;
+ model->SplineDegree = 4;
+ model->elevDim2 = 20;
+ model->elevDim3 = 18;
+ model->AlphaN = 578;
+ model->num_unique_azim_splines = 1;
+ model->elevSegSamples = 3;
+ model->elevBsLen[0] = 4;
+ model->elevBsLen[1] = 7;
+ model->elevBsLen[2] = 10;
+ model->elevBsLen[3] = 7;
+ model->elevBsStart[0] = 0;
+ model->elevBsStart[1] = 4;
+ model->elevBsStart[2] = 11;
+ model->elevBsStart[3] = 21;
+
+ model->azimDim2 = orange53_rom_azimDim2;
+ model->azimDim3 = orange53_rom_azimDim3;
+ model->azim_start_idx = orange53_rom_azim_start_idx;
+ model->azimSegSamples = orange53_rom_azimSegSamples;
+ model->azimShapeIdx = orange53_rom_azimShapeIdx;
+ model->azimShapeSampFactor = orange53_rom_azimShapeSampFactor;
+
+ /* float parameters */
+ model->elevKSeq = (const float *) orange53_rom_elevKSeq;
+ model->elevBsShape = (const float *) orange53_rom_elevBsShape;
+
+ model->azimBsShape = (const float **) malloc( model->num_unique_azim_splines * sizeof( float * ) );
+ model->azimBsShape[0] = (const float *) orange53_rom_azimBsShape;
+ model->azimKSeq = (float **) malloc( 18 * sizeof( float * ) );
+ model->azimKSeq[0] = (float *) malloc( 2 * sizeof( float * ) );
+ model->azimKSeq[17] = (float *) malloc( 2 * sizeof( float * ) );
+ model->azimKSeq[0][0] = 0.0f;
+ model->azimKSeq[17][0] = 0.0f;
+ model->azimKSeq[0][1] = 360.0f;
+ model->azimKSeq[17][1] = 360.0f;
+
+ for ( i = 1; i < 17; i++ )
+ {
+ model->azimKSeq[i] = (float *) malloc( model->azimDim2[i] * sizeof( float * ) ); /* azimDim2[i] = 91, i=2..15 */
+ for ( j = 0; j < model->azimDim2[i]; j++ )
+ {
+ model->azimKSeq[i][j] = (float) orange53_rom_azimSegSamples[0] * j;
+ }
+ }
+
+ switch ( output_Fs )
+ {
+ case 48000:
+ model->AlphaL = (const float *) orange53_rom_AlphaL48;
+ model->AlphaR = (const float *) orange53_rom_AlphaR48;
+ model->EL = (const float *) orange53_rom_EL48;
+ model->ER = (const float *) orange53_rom_ER48;
+ model->K = 128;
+ if ( HrFiltSet_p->ModelParams.UseItdModel )
+ {
+ modelITD->resamp_factor = 1.0f;
+ }
+ break;
+ case 32000:
+ model->AlphaL = (const float *) orange53_rom_AlphaL32;
+ model->AlphaR = (const float *) orange53_rom_AlphaR32;
+ model->EL = (const float *) orange53_rom_EL32;
+ model->ER = (const float *) orange53_rom_ER32;
+ model->K = 86;
+ if ( HrFiltSet_p->ModelParams.UseItdModel )
+ {
+ modelITD->resamp_factor = RESAMPLE_FACTOR_32_48;
+ }
+ break;
+ case 16000:
+ model->AlphaL = (const float *) orange53_rom_AlphaL16;
+ model->AlphaR = (const float *) orange53_rom_AlphaR16;
+ model->EL = (const float *) orange53_rom_EL16;
+ model->ER = (const float *) orange53_rom_ER16;
+ model->K = 43;
+ if ( HrFiltSet_p->ModelParams.UseItdModel )
+ {
+ modelITD->resamp_factor = RESAMPLE_FACTOR_16_48;
+ }
+ break;
+ default:
+ break;
+ }
+
+ modelITD->N = 4;
+ modelITD->elevDim2 = 20;
+ modelITD->elevDim3 = 18;
+ modelITD->azimDim2 = 41;
+ modelITD->azimDim3 = 41;
+ modelITD->elevSegSamples = 3;
+ modelITD->elevBsLen[0] = 4;
+ modelITD->elevBsLen[1] = 7;
+ modelITD->elevBsLen[2] = 10;
+ modelITD->elevBsLen[3] = 7;
+ modelITD->elevBsStart[0] = 0;
+ modelITD->elevBsStart[1] = 4;
+ modelITD->elevBsStart[2] = 11;
+ modelITD->elevBsStart[3] = 21;
+
+ modelITD->elevKSeq = model->elevKSeq;
+
+ modelITD->azimBsLen[0] = 11;
+ modelITD->azimBsLen[1] = 21;
+ modelITD->azimBsLen[2] = 31;
+ modelITD->azimBsLen[3] = 21;
+ modelITD->azimBsStart[0] = 0;
+ modelITD->azimBsStart[1] = 11;
+ modelITD->azimBsStart[2] = 32;
+ modelITD->azimBsStart[3] = 63;
+
+ modelITD->azimSegSamples = 10;
+
+ modelITD->azimKSeq = orange53_rom_ITD_azimKSeq;
+ modelITD->W = (const float *) orange53_rom_ITD_W;
+ modelITD->azimBsShape = (const float *) orange53_rom_ITD_azimBsShape;
+ modelITD->elevBsShape = (const float *) orange53_rom_ITD_elevBsShape;
+
+ HRTF_model_precalc( model );
+
+ HrFiltSet_p->latency_s = orange53_rom_latency_s;
+ HrFiltSet_p->SampleRate = output_Fs;
+ HrFiltSet_p->FiltLength = HrFiltSet_p->ModelParams.K;
+
+ BSplineModelEvalAlloc( &HrFiltSet_p->ModelParams, &HrFiltSet_p->ModelEval );
+
+ return;
+}
diff --git a/lib_rend/ivas_objectRenderer_sfx.c b/lib_rend/ivas_objectRenderer_sfx.c
index 7a9ddd6b85bb7a101b1917b179085159190901c7..005025827b8cc0c49158fb6fd7a83b11c86facf8 100644
--- a/lib_rend/ivas_objectRenderer_sfx.c
+++ b/lib_rend/ivas_objectRenderer_sfx.c
@@ -33,7 +33,7 @@
#include
#include "options.h"
#include
-#include "ivas_prot.h"
+#include "ivas_prot_rend.h"
#include "ivas_rom_rend.h"
#include "prot.h"
#include "wmc_auto.h"
@@ -47,6 +47,7 @@
/*---------------------------------------------------------------------*
* Local function prototypes
*---------------------------------------------------------------------*/
+
static void sincResample( const float *input, float *output, const int16_t length_in, const int16_t length_out );
diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources.c
index e56516d45473a6a46fa2b1c409eef7783009a0c8..694764979db139169078ac2e8b41278c43681ab6 100644
--- a/lib_rend/ivas_objectRenderer_sources.c
+++ b/lib_rend/ivas_objectRenderer_sources.c
@@ -33,25 +33,33 @@
#include
#include "options.h"
#include
-#include "ivas_prot.h"
#include "prot.h"
+#include "ivas_prot_rend.h"
#include "wmc_auto.h"
#ifdef DEBUGGING
#include "debug.h"
#endif
+
/*---------------------------------------------------------------------*
* Local function prototypes
*---------------------------------------------------------------------*/
static void TDREND_SRC_SPATIAL_Dealloc( TDREND_SRC_SPATIAL_t *SrcSpatial_p );
+
static void TDREND_SRC_SPATIAL_Init( TDREND_SRC_SPATIAL_t *SrcSpatial_p, const TDREND_PosType_t PosType );
+
static void TDREND_SRC_SPATIAL_SetDirAtten( TDREND_SRC_SPATIAL_t *SrcSpatial_p, const TDREND_DirAtten_t *DirAtten_p );
+
static float TDREND_SRC_SPATIAL_GetDirGain( const TDREND_DirAtten_t *DirAtten_p, const float *Front_p, const float *RelPos_p );
+
static float TDREND_SRC_SPATIAL_GetDistGain( const TDREND_DistAtten_t *DistAtten_p, const float Dist );
+
static ivas_error TDREND_SRC_REND_Alloc( TDREND_SRC_REND_t **SrcRend_pp );
+
static void TDREND_SRC_REND_Init( TDREND_SRC_REND_t *SrcRend_p );
+
/*-------------------------------------------------------------------*
* TDREND_MIX_SRC_SetPos()
*
diff --git a/lib_rend/ivas_objectRenderer_vec.c b/lib_rend/ivas_objectRenderer_vec.c
index 68d50bc55931785f66cc963b14114571ccee01bf..c3a780c725fa66aa07fe592adfb06dba643098b8 100644
--- a/lib_rend/ivas_objectRenderer_vec.c
+++ b/lib_rend/ivas_objectRenderer_vec.c
@@ -33,13 +33,14 @@
#include
#include "options.h"
#include
-#include "ivas_prot.h"
#include "prot.h"
+#include "ivas_prot_rend.h"
#include "wmc_auto.h"
#ifdef DEBUGGING
#include "debug.h"
#endif
+
/*-------------------------------------------------------------------*
* TDREND_SPATIAL_VecInit()
*
diff --git a/lib_rend/ivas_orient_trk.c b/lib_rend/ivas_orient_trk.c
index df7d80bf60cfbff9109ddcc5be16b1b6cd107903..4b72c16ce66f694a63e702e485f0c9f5f907caae 100644
--- a/lib_rend/ivas_orient_trk.c
+++ b/lib_rend/ivas_orient_trk.c
@@ -32,8 +32,8 @@
#include
#include "options.h"
-#include "prot.h"
#include "ivas_prot.h"
+#include "ivas_prot_rend.h"
#include "ivas_cnst.h"
#ifdef DEBUGGING
#include "debug.h"
diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c
index 2dfaa6da6857cfddd5f28c1d82f77f8ebe1ee173..193e775f22f2c44dddf64e6e4ca73520c76f3220 100644
--- a/lib_rend/ivas_output_init.c
+++ b/lib_rend/ivas_output_init.c
@@ -29,15 +29,12 @@
the United Nations Convention on Contracts on the International Sales of Goods.
*******************************************************************************************************/
-// VE2AT: keep in lib_rend or move to lib_dec ?
-#include
+
#include
#include "options.h"
#include "ivas_cnst.h"
-#include "ivas_prot.h"
#include "prot.h"
-#include "ivas_stat_dec.h"
-#include "ivas_rom_dec.h"
+#include "ivas_prot_rend.h"
#include "ivas_rom_com.h"
#ifdef DEBUGGING
#include "debug.h"
@@ -246,366 +243,3 @@ void ivas_output_init(
return;
}
-
-
-/*-------------------------------------------------------------------------*
- * ivas_renderer_select()
- *
- * Select and configure IVAS renderer parameters
- *-------------------------------------------------------------------------*/
-
-void ivas_renderer_select(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
-)
-{
- RENDERER_TYPE *renderer_type;
- AUDIO_CONFIG *internal_config;
- AUDIO_CONFIG output_config;
- AUDIO_CONFIG transport_config;
-
- int16_t nchan_internal;
-
- renderer_type = &( st_ivas->renderer_type );
- internal_config = &( st_ivas->intern_config );
- output_config = st_ivas->hDecoderConfig->output_config;
- transport_config = st_ivas->transport_config;
-
- /* disabled rendering by default */
- *renderer_type = RENDERER_DISABLE;
-
- /*-----------------------------------------------------------------*
- * Binaural rendering configurations
- *-----------------------------------------------------------------*/
-
- if ( st_ivas->hDecoderConfig->Opt_Headrotation )
- {
- st_ivas->hHeadTrackData->shd_rot_max_order = -1;
- }
-
- if ( output_config == AUDIO_CONFIG_BINAURAL || output_config == AUDIO_CONFIG_BINAURAL_ROOM )
- {
- if ( st_ivas->ivas_format == ISM_FORMAT )
- {
- if ( st_ivas->ism_mode == ISM_MODE_PARAM )
- {
- if ( output_config == AUDIO_CONFIG_BINAURAL )
- {
- *renderer_type = RENDERER_BINAURAL_PARAMETRIC;
- }
- else
- {
- *renderer_type = RENDERER_BINAURAL_PARAMETRIC_ROOM;
- }
- }
- else /* ISM_MODE_DISC */
- {
- if ( output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hRenderConfig->roomAcoustics.use_brir == 0 )
- {
-#ifdef DEBUGGING
- if ( st_ivas->hDecoderConfig->force_rend == FORCE_CLDFB_RENDERER )
- {
- *renderer_type = RENDERER_BINAURAL_FASTCONV;
- *internal_config = AUDIO_CONFIG_HOA3; /* Render ISM to HOA3 before binauralization*/
- }
- else
- {
- *renderer_type = RENDERER_BINAURAL_OBJECTS_TD;
- *internal_config = AUDIO_CONFIG_BINAURAL;
- }
-#else
- *renderer_type = RENDERER_BINAURAL_OBJECTS_TD;
- *internal_config = AUDIO_CONFIG_BINAURAL;
-#endif
- }
- else
- {
- *renderer_type = RENDERER_BINAURAL_MIXER_CONV_ROOM;
-#if defined( DEBUGGING )
- if ( st_ivas->hRenderConfig->renderer_type_override == RENDER_TYPE_OVERRIDE_FASTCONV )
- {
- *renderer_type = RENDERER_BINAURAL_FASTCONV_ROOM;
- }
-#endif
- *internal_config = AUDIO_CONFIG_7_1_4;
- }
- }
- }
- else if ( st_ivas->ivas_format == MASA_FORMAT || ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->nchan_transport <= 2 ) )
- {
- *internal_config = output_config;
- if ( output_config == AUDIO_CONFIG_BINAURAL )
- {
- *renderer_type = RENDERER_BINAURAL_PARAMETRIC;
- }
- else
- {
- *renderer_type = RENDERER_BINAURAL_PARAMETRIC_ROOM;
- }
- }
- else if ( st_ivas->ivas_format == SBA_FORMAT )
- {
- *internal_config = AUDIO_CONFIG_HOA3;
-
- if ( output_config == AUDIO_CONFIG_BINAURAL )
- {
- *renderer_type = RENDERER_BINAURAL_FASTCONV;
- }
- else
- {
- *renderer_type = RENDERER_BINAURAL_FASTCONV_ROOM;
- }
-
- if ( st_ivas->hDecoderConfig->Opt_Headrotation )
- {
-
- nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order );
- if ( nchan_internal == 2 )
- {
- st_ivas->hHeadTrackData->shd_rot_max_order = 1;
- }
- else if ( nchan_internal == 4 || nchan_internal == 3 )
- {
- st_ivas->hHeadTrackData->shd_rot_max_order = 0;
- }
- else if ( nchan_internal == 6 || nchan_internal == 5 )
- {
- st_ivas->hHeadTrackData->shd_rot_max_order = 2;
- }
- else if ( nchan_internal == 8 || nchan_internal == 7 )
- {
- st_ivas->hHeadTrackData->shd_rot_max_order = 3;
- }
- }
- }
- else if ( st_ivas->ivas_format == MC_FORMAT )
- {
- if ( st_ivas->mc_mode == MC_MODE_MCMASA )
- {
- *internal_config = output_config;
- if ( output_config == AUDIO_CONFIG_BINAURAL )
- {
- *renderer_type = RENDERER_BINAURAL_PARAMETRIC;
- }
- else
- {
- *renderer_type = RENDERER_BINAURAL_PARAMETRIC_ROOM;
- }
- }
- else
- {
- *internal_config = transport_config;
- if ( output_config == AUDIO_CONFIG_BINAURAL )
- {
-#ifdef DEBUGGING
- if ( ( ( ( st_ivas->transport_config == AUDIO_CONFIG_5_1 || st_ivas->transport_config == AUDIO_CONFIG_7_1 ) && st_ivas->hDecoderConfig->Opt_Headrotation ) || ( st_ivas->hDecoderConfig->force_rend == FORCE_TD_RENDERER ) ) && ( st_ivas->mc_mode == MC_MODE_MCT ) && !( st_ivas->hDecoderConfig->force_rend == FORCE_CLDFB_RENDERER ) )
-#else
- if ( ( st_ivas->transport_config == AUDIO_CONFIG_5_1 || st_ivas->transport_config == AUDIO_CONFIG_7_1 ) && st_ivas->hDecoderConfig->Opt_Headrotation && ( st_ivas->mc_mode == MC_MODE_MCT ) )
-#endif
- {
- *renderer_type = RENDERER_BINAURAL_OBJECTS_TD;
- }
- else
- {
- if ( st_ivas->mc_mode == MC_MODE_MCT )
- {
- *renderer_type = RENDERER_BINAURAL_MIXER_CONV;
- }
- else
- {
- *renderer_type = RENDERER_BINAURAL_FASTCONV;
- }
-
-#ifdef DEBUGGING
- if ( st_ivas->hRenderConfig->renderer_type_override == RENDER_TYPE_OVERRIDE_CREND )
- {
- *renderer_type = RENDERER_BINAURAL_MIXER_CONV;
- }
- else if ( st_ivas->hRenderConfig->renderer_type_override == RENDER_TYPE_OVERRIDE_FASTCONV )
- {
- *renderer_type = RENDERER_BINAURAL_FASTCONV;
- }
-#endif
- if ( st_ivas->hDecoderConfig->Opt_Headrotation )
- {
- /* force HOA3 domain for rotation*/
- *internal_config = AUDIO_CONFIG_HOA3;
- }
- }
- }
- else /* AUDIO_CONFIG_BINAURAL_ROOM */
- {
- if ( st_ivas->mc_mode == MC_MODE_MCT )
- {
- *renderer_type = RENDERER_BINAURAL_MIXER_CONV_ROOM;
- }
- else
- {
- *renderer_type = RENDERER_BINAURAL_FASTCONV_ROOM;
- }
-#ifdef DEBUGGING
- if ( st_ivas->hRenderConfig->renderer_type_override == RENDER_TYPE_OVERRIDE_CREND )
- {
- *renderer_type = RENDERER_BINAURAL_MIXER_CONV_ROOM;
- }
- else if ( st_ivas->hRenderConfig->renderer_type_override == RENDER_TYPE_OVERRIDE_FASTCONV )
- {
- *renderer_type = RENDERER_BINAURAL_FASTCONV_ROOM;
- }
-#endif
- }
- }
- }
- }
-
- /*-----------------------------------------------------------------*
- * Non-binaural rendering configurations
- *-----------------------------------------------------------------*/
-
- else if ( st_ivas->ivas_format == STEREO_FORMAT )
- {
- if ( output_config != AUDIO_CONFIG_STEREO && output_config != AUDIO_CONFIG_MONO )
- {
- *renderer_type = RENDERER_MC;
- }
- }
- else if ( st_ivas->ivas_format == ISM_FORMAT )
- {
- if ( st_ivas->ism_mode == ISM_MODE_PARAM )
- {
- *renderer_type = RENDERER_PARAM_ISM;
- if ( output_config == AUDIO_CONFIG_MONO )
- {
- *renderer_type = RENDERER_MONO_DOWNMIX;
- }
- else if ( output_config == AUDIO_CONFIG_STEREO )
- {
- *renderer_type = RENDERER_DISABLE;
- }
- else if ( output_config == AUDIO_CONFIG_FOA || output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_HOA3 )
- {
- *renderer_type = RENDERER_SBA_LINEAR_ENC;
- *internal_config = AUDIO_CONFIG_7_1_4;
- }
- }
- else /* ISM_MODE_DISC */
- {
- *renderer_type = RENDERER_TD_PANNING;
- if ( output_config == AUDIO_CONFIG_MONO )
- {
- *renderer_type = RENDERER_MONO_DOWNMIX;
- }
- else if ( output_config == AUDIO_CONFIG_FOA || output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_HOA3 )
- {
- *renderer_type = RENDERER_SBA_LINEAR_ENC;
- }
- else if ( output_config == AUDIO_CONFIG_EXTERNAL )
- {
- *renderer_type = RENDERER_DISABLE;
- }
- }
- }
- else if ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == SBA_FORMAT )
- {
- *renderer_type = RENDERER_DIRAC;
-
- if ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->sba_mode == SBA_MODE_SPAR &&
- ( output_config != AUDIO_CONFIG_5_1 && output_config != AUDIO_CONFIG_5_1_2 && output_config != AUDIO_CONFIG_5_1_4 && output_config != AUDIO_CONFIG_7_1 && output_config != AUDIO_CONFIG_7_1_4 && output_config != AUDIO_CONFIG_LS_CUSTOM ) )
- {
- if ( output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_FOA )
- {
- *internal_config = output_config;
- }
- else if ( output_config == AUDIO_CONFIG_MONO || output_config == AUDIO_CONFIG_STEREO )
- {
- *internal_config = AUDIO_CONFIG_FOA;
- }
- else
- {
- *internal_config = AUDIO_CONFIG_HOA3;
- }
- st_ivas->renderer_type = RENDERER_SBA_LINEAR_DEC;
- }
- else if ( ( st_ivas->ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_MONO && st_ivas->nchan_transport == 1 ) ||
- ( st_ivas->ivas_format == SBA_FORMAT && output_config == AUDIO_CONFIG_STEREO && st_ivas->nchan_transport == 1 ) )
- {
- *renderer_type = RENDERER_DISABLE;
- }
- else if ( ( st_ivas->ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_MONO && st_ivas->hDecoderConfig->ivas_total_brate < MASA_STEREO_MIN_BITRATE && st_ivas->hDecoderConfig->ivas_total_brate > IVAS_SID_5k2 ) )
- {
- *renderer_type = RENDERER_DISABLE;
- }
- else if ( st_ivas->ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_STEREO )
- {
- *renderer_type = RENDERER_STEREO_PARAMETRIC;
- }
- else if ( st_ivas->ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_EXTERNAL )
- {
- *renderer_type = RENDERER_DISABLE;
- }
- else if ( st_ivas->ivas_format == SBA_FORMAT && output_config == AUDIO_CONFIG_MONO )
- {
- *renderer_type = RENDERER_SBA_LINEAR_DEC;
- }
- }
- else if ( st_ivas->ivas_format == MC_FORMAT )
- {
- *internal_config = transport_config;
- if ( st_ivas->mc_mode == MC_MODE_MCT && *internal_config != output_config )
- {
- if ( output_config != AUDIO_CONFIG_FOA && output_config != AUDIO_CONFIG_HOA2 && output_config != AUDIO_CONFIG_HOA3 )
- {
- *renderer_type = RENDERER_MC;
- }
- else
- {
- *renderer_type = RENDERER_SBA_LINEAR_ENC;
- }
- }
- else if ( st_ivas->mc_mode == MC_MODE_PARAMMC )
- {
- if ( output_config == AUDIO_CONFIG_FOA || output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_HOA3 )
- {
- *renderer_type = RENDERER_SBA_LINEAR_ENC;
- }
- else
- {
- *renderer_type = RENDERER_MC_PARAMMC;
- }
- }
- else if ( st_ivas->mc_mode == MC_MODE_MCMASA )
- {
- *internal_config = output_config;
- /* No rendering for 1TC to Mono or Stereo and 2TC to Stereo */
- if ( output_config == AUDIO_CONFIG_MONO || output_config == AUDIO_CONFIG_STEREO )
- {
- if ( st_ivas->nchan_transport == 1 )
- {
- *renderer_type = RENDERER_DISABLE;
- }
- else if ( output_config == AUDIO_CONFIG_STEREO && st_ivas->nchan_transport == 2 && !st_ivas->hOutSetup.separateChannelEnabled )
- {
- *renderer_type = RENDERER_DISABLE;
- }
- else
- {
- *renderer_type = RENDERER_MCMASA_MONO_STEREO;
- }
- }
- else
- {
- *renderer_type = RENDERER_DIRAC;
- if ( output_config == AUDIO_CONFIG_FOA || output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_HOA3 )
- {
- *renderer_type = RENDERER_SBA_LINEAR_ENC;
- *internal_config = transport_config;
- }
- else if ( transport_config == AUDIO_CONFIG_5_1 && ( output_config == AUDIO_CONFIG_7_1 || output_config == AUDIO_CONFIG_5_1_4 ) )
- {
- *internal_config = transport_config;
- }
- }
- }
- }
-
- return;
-}
diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h
new file mode 100644
index 0000000000000000000000000000000000000000..e2156b4158050f40031a121c4433223efb4e40ba
--- /dev/null
+++ b/lib_rend/ivas_prot_rend.h
@@ -0,0 +1,906 @@
+/******************************************************************************************************
+
+ (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+ Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+ Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+ Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+ contributors to this repository. All Rights Reserved.
+
+ This software is protected by copyright law and by international treaties.
+ The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
+ Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+ Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+ Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+ contributors to this repository retain full ownership rights in their respective contributions in
+ the software. This notice grants no license of any kind, including but not limited to patent
+ license, nor is any license granted by implication, estoppel or otherwise.
+
+ Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
+ contributions.
+
+ This software is provided "AS IS", without any express or implied warranties. The software is in the
+ development stage. It is intended exclusively for experts who have experience with such software and
+ solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
+ and fitness for a particular purpose are hereby disclaimed and excluded.
+
+ Any dispute, controversy or claim arising under or in relation to providing this software shall be
+ submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
+ accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
+ the United Nations Convention on Contracts on the International Sales of Goods.
+
+*******************************************************************************************************/
+
+#ifndef IVAS_PROT_REND_H
+#define IVAS_PROT_REND_H
+
+#include
+#include "options.h"
+#include "ivas_error.h"
+#include "lib_rend.h"
+#include "ivas_stat_dec.h" // Note: needed until #156 is resolved
+
+/* clang-format off */
+
+/*----------------------------------------------------------------------------------*
+ * General renderer declarations
+ *----------------------------------------------------------------------------------*/
+
+IVAS_REND_AudioConfigType getAudioConfigType(
+ const IVAS_REND_AudioConfig config
+);
+
+ivas_error getAudioConfigNumChannels(
+ const IVAS_REND_AudioConfig config,
+ int16_t *numChannels
+);
+
+#ifdef FIX_197_CREND_INTERFACE
+AUDIO_CONFIG getIvasAudioConfigFromRendAudioConfig(
+#else
+AUDIO_CONFIG rendAudioConfigToIvasAudioConfig(
+#endif
+ IVAS_REND_AudioConfig rendConfig );
+
+IVAS_REND_AudioConfig getRendAudioConfigFromIvasAudioConfig(
+ AUDIO_CONFIG config );
+
+
+/*----------------------------------------------------------------------------------*
+ * output setup prototypes
+ *----------------------------------------------------------------------------------*/
+
+/*! r: number of output channels */
+int16_t audioCfg2channels(
+ const AUDIO_CONFIG output_config /* i : output audio configuration */
+);
+
+void ivas_output_init(
+ IVAS_OUTPUT_SETUP *hOutSetup, /* o : output setup structure */
+ const AUDIO_CONFIG output_config /* i : output audio configuration */
+);
+
+/*----------------------------------------------------------------------------------*
+ * Limiter prototypes
+ *----------------------------------------------------------------------------------*/
+
+/*! r: limiter struct handle */
+IVAS_LIMITER_HANDLE ivas_limiter_open(
+ const int16_t num_channels, /* i : number of I/O channels */
+ const int32_t sampling_rate /* i : sampling rate for processing */
+);
+
+void ivas_limiter_close(
+ IVAS_LIMITER_HANDLE* phLimiter /* i/o: pointer to limiter handle, can be NULL */
+);
+
+void ivas_limiter_dec
+(
+ IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */
+ float output[MAX_OUTPUT_CHANNELS][L_FRAME48k], /* i/o: input/output buffer */
+ const int16_t num_channels, /* i : number of channels to be processed */
+ const int16_t output_frame, /* i : number of samples per channel in the buffer */
+ const int16_t BER_detect /* i : BER detect flag */
+);
+
+void limiter_process(
+ IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */
+ const int16_t output_frame, /* i : number of samples to be processed per channel in the I/O buffer */
+ const float threshold, /* i : signal amplitude above which limiting starts to be applied */
+ const int16_t BER_detect, /* i : BER detect flag */
+ int16_t *strong_saturation_cnt /* i/o: counter of strong saturations (can be NULL) */
+);
+
+
+/*----------------------------------------------------------------------------------*
+ * Amplitude Panning EFAP prototypes
+ *----------------------------------------------------------------------------------*/
+
+ivas_error efap_init_data(
+ EFAP_HANDLE *hEFAPdata, /* i/o: handle for EFAP data structure that will be initialized */
+ const float *speaker_node_azi_deg, /* i : vector of speaker node azimuths (positive left) */
+ const float *speaker_node_ele_deg, /* i : vector of speaker node elevations (positive up) */
+ const int16_t num_speaker_nodes, /* i : number of speaker nodes in the set */
+ const int16_t efap_mode /* i : indicates whether EFAP or EFIP is used */
+);
+
+void efap_free_data(
+ EFAP_HANDLE *hEFAPdata /* i/o: EFAP handle to be freed */
+);
+
+void efap_determine_gains(
+ EFAP_HANDLE hEFAPdata, /* i : EFAP structure */
+ float *gains, /* o : gain vector for speaker nodes for given direction */
+ const float azi_deg, /* i : azimuth in degrees for panning direction (positive left) */
+ const float ele_deg, /* i : elevation in degrees for panning direction (positive up) */
+ const int16_t efap_mode /* i : indicates whether EFAP or EFIP is used */
+);
+
+
+/*----------------------------------------------------------------------------------*
+ * SBA rendering
+ *----------------------------------------------------------------------------------*/
+
+void ivas_sba_prototype_renderer(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */
+ float inRe[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */
+ float inIm[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, imag */
+ const int16_t firstSubframe, /* i : First subframe to map */
+ const int16_t nSubframes /* i : Number of subframes to map */
+);
+
+ivas_error ivas_sba_get_hoa_dec_matrix(
+ const IVAS_OUTPUT_SETUP hOutSetup, /* i : target output setup */
+ float **hoa_dec_mtx, /* o : ALLRAD decoder matrix */
+ const int16_t ambisonics_order /* i : Ambisonics order */
+);
+
+void ivas_dirac_dec_binaural(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */
+ const int16_t nchan_transport /* i : number of transport channels */
+);
+
+ivas_error ivas_dirac_dec_init_binaural_data(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ HRTFS_PARAMBIN_HANDLE hHrtfParambin /* i : HRTF structure for rendering */
+);
+
+void ivas_dirac_dec_close_binaural_data(
+ DIRAC_DEC_BIN_HANDLE *hBinaural /* i/o: decoder DirAC binaural data handle */
+);
+
+ivas_error ivas_dirac_dec_binaural_copy_hrtfs(
+ HRTFS_PARAMBIN_HANDLE *hHrtfParambin /* i/o: HRTF structure for rendering */
+);
+
+
+/*----------------------------------------------------------------------------------*
+ * HRTF
+ *----------------------------------------------------------------------------------*/
+
+ivas_error ivas_HRTF_binary_open(
+ TDREND_HRFILT_FiltSet_t **hHrtfTD /* i/o: TD renderer HRTF handle */
+);
+
+void ivas_HRTF_binary_close(
+ TDREND_HRFILT_FiltSet_t **hHrtfTD /* i/o: TD renderer HRTF handle */
+);
+
+ivas_error ivas_HRTF_fastconv_binary_open(
+ HRTFS_FASTCONV **hHrtfFastConv /* i/o: FASTCONV HRTF structure */
+);
+
+void ivas_HRTF_fastconv_binary_close(
+ HRTFS_FASTCONV **hHrtfFastConv /* i/o: FASTCONV HRTF structure */
+);
+
+ivas_error ivas_HRTF_parambin_binary_open(
+ HRTFS_PARAMBIN **hHrtfParambin /* i/o: Parametric binauralizer HRTF structure */
+);
+
+void ivas_HRTF_parambin_binary_close(
+ HRTFS_PARAMBIN **hHrtfParambin /* i/o: Parametric binauralizer HRTF structure */
+);
+
+ivas_error ivas_HRTF_CRend_binary_open(
+ HRTFS_CREND **hSetOfHRTF /* i/o: Set of HRTF handle */
+);
+
+void ivas_HRTF_CRend_binary_close(
+ HRTFS_CREND **hSetOfHRTF /* i/o: Set of HRTF handle */
+);
+
+
+/*----------------------------------------------------------------------------------*
+ * TD object renderer
+ *----------------------------------------------------------------------------------*/
+
+#ifdef FIX_198_TDREND_INTERFACE
+void ivas_td_binaural_renderer_unwrap(
+ RENDER_CONFIG_DATA *hRenderConfig, /* i : Renderer configuration */
+ const int16_t ini_frame, /* i : Initialization frame counter */
+#ifdef FIX_197_CREND_INTERFACE
+ CREND_WRAPPER_HANDLE hCrendWrapper, /* i : Crend wrapper handle */
+#else
+ CREND_HANDLE hCrend, /* i : Crend handle */
+#endif
+ AUDIO_CONFIG transport_config, /* i : Transport configuration */
+ const int32_t output_Fs, /* i : Output sampling rate */
+ BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD binaural object renderer handle */
+ const int16_t nchan_transport, /* i : Transport channels (ISms) */
+ const int16_t lfe_idx, /* i : LFE channel index */
+ IVAS_FORMAT ivas_format, /* i : IVAS format */
+ ISM_METADATA_HANDLE *hIsmMetaData, /* i : ISM metadata handle */
+ const int16_t Opt_Headrotation, /* i : Head rotation flag */
+ const IVAS_QUATERNION *Quaternions, /* i : Head tracking data per subframe */
+ float output[][L_FRAME48k], /* i/o: SCE channels / Binaural synthesis */
+ const int16_t output_frame /* i : output frame length */
+);
+#endif
+
+ivas_error ivas_td_binaural_renderer_ext(
+ const TDREND_WRAPPER *pTDRend, /* i : TD Renderer wrapper structure */
+ const IVAS_REND_AudioConfig inConfig, /* i : Input audio configuration */
+ const LSSETUP_CUSTOM_STRUCT *customLsInput, /* i : Input custom loudspeaker layout */
+ const IVAS_REND_HeadRotData *headRotData, /* i : Input head positions */
+ const IVAS_REND_AudioObjectPosition *currentPos, /* i : Object position */
+ const int16_t output_frame, /* i : output frame length */
+ float output[][L_FRAME48k] /* i/o: SCE channels / Binaural synthesis */
+);
+
+#ifdef FIX_198_TDREND_INTERFACE
+ivas_error ivas_td_binaural_open_unwrap(
+ TDREND_HRFILT_FiltSet_t **hHrtfTD, /* i/o: HR filter model (from file or NULL) */
+ const int32_t output_Fs, /* i : Output sampling rate */
+ const int16_t nchan_transport, /* i : Number of channels */
+ const IVAS_FORMAT ivas_format, /* i : IVAS format (ISM/MC) */
+ const AUDIO_CONFIG transport_config, /* i : Transport configuration */
+ const IVAS_OUTPUT_SETUP hTransSetup, /* i : Loudspeaker layout */
+ BINAURAL_TD_OBJECT_RENDERER_HANDLE *hBinRendererTd, /* o : TD renderer handle */
+ int32_t *binaural_latency_ns /* i : Binauralization delay */
+);
+#endif
+
+ivas_error ivas_td_binaural_open_ext(
+ TDREND_WRAPPER *pTDRend,
+ const IVAS_REND_AudioConfig inConfig,
+ LSSETUP_CUSTOM_STRUCT *customLsInput,
+ const int32_t output_Fs
+);
+
+void ivas_td_binaural_close(
+ BINAURAL_TD_OBJECT_RENDERER_HANDLE *hBinRendererTd /* i/o: TD binaural object renderer handle */
+);
+
+
+ivas_error TDREND_GetMix(
+ BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */
+ float output[][L_FRAME48k], /* i/o: ISm object synth / rendered output in 0,1 */
+ const int16_t subframe_length, /* i/o: subframe length */
+ const int16_t subframe_idx /* i : Subframe index to 5 ms subframe */
+);
+
+void TDREND_Update_listener_orientation(
+ BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD Renderer handle */
+ const int16_t headRotEnabled, /* i : Headrotation flag */
+ const IVAS_QUATERNION *headPosition /* i : Head Position */
+);
+
+void TDREND_Update_object_positions(
+ BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o : TD Renderer handle */
+ const int16_t numSources, /* i : Number of sources to render */
+ const int16_t lfe_idx, /* i : Input LFE index */
+ const IVAS_FORMAT in_format, /* i : Format of input sources */
+ const ISM_METADATA_HANDLE *hIsmMetaData, /* i : Input metadata for ISM objects */
+ float output[][L_FRAME48k] /* i/o: SCE/MC channels */
+);
+
+void BSplineModelEvalAlloc(
+ ModelParams_t *model, /* i : Model parameters */
+ ModelEval_t *modelEval /* i/o: Model evaluation structure */
+);
+
+void BSplineModelEvalDealloc(
+ ModelParams_t *model, /* i : Model parameters */
+ ModelEval_t *modelEval /* i : Model evaluation structure */
+);
+
+/* ----- Object renderer - hrfilt ----- */
+
+void GetFilterFromAngle(
+ TDREND_HRFILT_FiltSet_t *HrFiltSet_p, /* i/o: HR filter set structure */
+ const float Elev, /* i : Elevation, degrees */
+ float Azim, /* i : Azimuth, degrees */
+ float *LeftFilter, /* o : Left HR filter */
+ float *RightFilter, /* o : Right HR filter */
+ int16_t *itd /* o : ITD value */
+);
+
+void HRTF_model_precalc(
+ ModelParams_t *model /* i/o: HRTF Model parameters */
+);
+
+ivas_error TDREND_REND_RenderSourceHRFilt(
+ TDREND_SRC_t *Src_p, /* i/o: The source to be rendered */
+ const float *hrf_left_delta, /* i: Left filter interpolation delta */
+ const float *hrf_right_delta, /* i: Right filter interpolation delta */
+ const int16_t intp_count, /* i: Interpolation count */
+ float output_buf[][L_SPATIAL_SUBFR_48k], /* o : Output buffer */
+ const int16_t subframe_length /* i : Subframe length in use */
+);
+
+/* ----- Object renderer - sources ----- */
+
+ivas_error TDREND_MIX_SRC_SetPos(
+ BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */
+ const int16_t SrcInd, /* i : Source index */
+ const float *Vec_p /* i : Position vector */
+);
+
+ivas_error TDREND_MIX_SRC_SetDir(
+ BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */
+ const int16_t SrcInd, /* i : Source index */
+ const float *Vec_p /* i : Direction vector */
+);
+
+ivas_error TDREND_MIX_SRC_SetDirAtten(
+ BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */
+ const int16_t SrcInd, /* i : Source index */
+ const TDREND_DirAtten_t *DirAtten_p /* i : Directional attenuation specifier */
+);
+
+ivas_error TDREND_MIX_SRC_SetPlayState(
+ BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */
+ const int16_t SrcInd, /* i : Source index */
+ const TDREND_PlayStatus_t PlayStatus /* i : Play state */
+);
+
+void TDREND_SRC_REND_UpdateFiltersFromSpatialParams(
+ BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */
+ TDREND_SRC_REND_t *SrcRend_p, /* i/o: Source object */
+ TDREND_SRC_SPATIAL_t *SrcSpatial_p, /* i : Spatial aspects of source */
+ float *hrf_left_prev, /* o: Left filter */
+ float *hrf_right_prev, /* o: Right filter */
+ float *hrf_left_delta, /* o: Left filter interpolation delta */
+ float *hrf_right_delta, /* o: Right filter interpolation delta */
+ int16_t *intp_count, /* o: Interpolation count */
+ int16_t *filterlength, /* o: Length of filters */
+ int16_t *itd, /* o: ITD value */
+ float *Gain, /* o: Gain value */
+ TDREND_SRC_t *Src_p,
+ const int16_t subframe_idx /* i : Subframe index to 5 ms subframe */
+);
+
+ivas_error TDREND_SRC_Alloc(
+ TDREND_SRC_t **Src_pp /* i/o: Source */
+);
+
+void TDREND_SRC_Dealloc(
+ TDREND_SRC_t *Src_p /* i/o: Source to deallocate */
+);
+
+void TDREND_SRC_Init(
+ TDREND_SRC_t *Src_p, /* i/o: Source to initialize */
+ const TDREND_PosType_t PosType /* i : Position type specifier */
+);
+
+/* ----- Object renderer - vec ----- */
+
+void TDREND_SPATIAL_VecInit(
+ float *Pos_p, /* o : Output vector */
+ const float PosX, /* i : X value */
+ const float PosY, /* i : Y value */
+ const float PosZ /* i : Z value */
+);
+
+/*! r: Euclidian norm value */
+float TDREND_SPATIAL_VecNorm(
+ const float *Vec_p /* i : Vector for norm calculation */
+);
+
+void TDREND_SPATIAL_VecNormalize(
+ const float *Vec_p, /* i : Input vector */
+ float *VecNorm_p /* o : Output vector */
+);
+
+void TDREND_SPATIAL_VecMapToNewCoordSystem(
+ const float *Vec_p, /* i : Input vector */
+ const float *TranslVec_p, /* i : Translation vector */
+ const float *DirVec_p, /* i : Direction vector */
+ const float *UpVec_p, /* i : Up vector */
+ const float *RightVec_p, /* i : Right vector */
+ float *MappedVec_p /* o : Transformed vector */
+);
+
+/*! r: Flag if the orientation has been updated */
+int16_t TDREND_SPATIAL_EvalOrthonormOrient(
+ float *FrontVecON_p, /* o : Normalized front vector */
+ float *UpVecON_p, /* o : Normalized up vector */
+ float *RightVecON_p, /* o : Normalized right vector */
+ const float *FrontVec_p, /* i : Input front vector */
+ const float *UpVec_p /* i : Input up vector */
+);
+
+/* ----- Object renderer - mix ----- */
+
+ivas_error TDREND_MIX_AddSrc(
+ BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */
+ int16_t *SrcInd, /* o : Source index */
+ const TDREND_PosType_t PosType /* i : Position type (absolute/relative) */
+);
+
+ivas_error TDREND_MIX_SetDistAttenModel(
+ BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */
+ const TDREND_DistAttenModel_t DistAttenModel /* i : Distance attenuation model */
+);
+
+void TDREND_MIX_LIST_SetPos(
+ BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */
+ const float *Pos_p /* i : Listener's position */
+);
+
+ivas_error TDREND_MIX_LIST_SetOrient(
+ BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */
+ const float *FrontVec_p, /* i : Listener's orientation front vector */
+ const float *UpVec_p /* i : Listener's orientation up vector */
+);
+
+void TDREND_MIX_Dealloc(
+ BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd /* i/o: TD renderer handle */
+);
+
+ivas_error TDREND_MIX_Init(
+ BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */
+ TDREND_HRFILT_FiltSet_t **hHrtfTD, /* i/o: HRTF data (initialized in case of NULL) */
+ const TDREND_MixSpatSpec_t *MixSpatSpec_p, /* i : Mixer spatial specification */
+ const int32_t output_Fs /* i : Output sampling rate */
+);
+
+ /* ----- Object renderer - sfx ----- */
+
+void TDREND_Apply_ITD(
+ float *input, /* i: Input SCE subframe to be time adjusted */
+ float *out_left, /* o: Output left channels with ITD applied */
+ float *out_right, /* o: Output right channels with ITD applied */
+ int16_t *previtd, /*i/o: Previous ITD value */
+ const int16_t itd, /* i: Current subframe ITD value */
+ float *mem_itd, /*i/o: ITD buffer memory */
+ const int16_t length /* i: Subframe length */
+);
+
+void TDREND_firfilt(
+ float *signal, /* i/o: Input signal / Filtered signal */
+ float *filter, /* i/o: FIR filter */
+ const float *filter_delta, /* i : FIR filter delta */
+ const int16_t intp_count, /* i : interpolation count */
+ float *mem, /* i/o: filter memory */
+ const int16_t subframe_length, /* i : Length of signal */
+ const int16_t filterlength /* i : Filter length */
+);
+
+
+/*----------------------------------------------------------------------------------*
+ * Crend renderer
+ *----------------------------------------------------------------------------------*/
+
+ivas_error ivas_rend_openCrend(
+#ifdef FIX_197_CREND_INTERFACE
+ CREND_WRAPPER_HANDLE *pCrend,
+#else
+ CREND_WRAPPER *pCrend,
+#endif
+ const AUDIO_CONFIG inConfig,
+ const AUDIO_CONFIG outConfig,
+ RENDER_CONFIG_DATA *hRendCfg,
+#ifdef FIX_197_CREND_INTERFACE
+ int16_t Opt_Headrotation,
+#endif
+ HRTFS_CREND_HANDLE hSetOfHRTF,
+ const int32_t output_Fs
+);
+
+#ifdef FIX_197_CREND_INTERFACE
+void ivas_rend_closeCrend(
+ CREND_WRAPPER_HANDLE *pCrend );
+#else
+ivas_error ivas_rend_closeCrend(
+ CREND_WRAPPER *pCrend );
+#endif
+
+ivas_error ivas_rend_crendProcess(
+ const CREND_WRAPPER *pCrend,
+ const AUDIO_CONFIG inConfig,
+ const AUDIO_CONFIG outConfig,
+#ifdef FIX_197_CREND_INTERFACE
+ DECODER_CONFIG_HANDLE hDecoderConfig,
+ HEAD_TRACK_DATA_HANDLE hHeadTrackData,
+ IVAS_OUTPUT_SETUP_HANDLE hIntSetup,
+ EFAP_HANDLE hEFAPdata,
+#endif
+ float output[][L_FRAME48k], /* i/o: input/output audio channels */
+ const int32_t output_Fs
+);
+
+#ifndef FIX_197_CREND_INTERFACE
+
+ivas_error ivas_crend_init_from_setofhrtf(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+);
+
+ivas_error ivas_crend_init_from_hrtf_handle(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ HRTFS_HANDLE hrtf);
+
+#endif
+
+#ifndef FIX_MEMORY_COUNTING_HRTF_BINARY_FILE
+ivas_error destroy_SetOfHRTF(
+ HRTFS_CREND_HANDLE hSetOfHRTF /* i/o: Set of HRTF CRend handle */
+);
+#endif
+
+
+ivas_error ivas_crend_init_from_rom(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+);
+
+ivas_error ivas_crend_open(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+);
+
+ivas_error ivas_crend_close(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+);
+
+ivas_error ivas_crend_process(
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ float output[][L_FRAME48k] /* i/o: input/output audio channels */
+);
+
+
+/*----------------------------------------------------------------------------------*
+ * Reverberator
+ *----------------------------------------------------------------------------------*/
+
+ivas_error ivas_binaural_reverb_open(
+ REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */
+ const int16_t numBins, /* i : number of CLDFB bins */
+ const int16_t numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame */
+ ivas_roomAcoustics_t *roomAcoustics, /* i/o: room acoustics parameters */
+ const AUDIO_CONFIG output_config, /* i : output audio configuration */
+ const int32_t sampling_rate, /* i : sampling rate */
+ const RENDERER_TYPE renderer_type, /* i : renderer type */
+ const HRTFS_FASTCONV_HANDLE hHrtfFastConv, /* i : FastConv HRTF handle */
+ const HRTFS_PARAMBIN_HANDLE hHrtfParambin /* i : Parametric binauralizer HRTF handle */
+);
+
+void ivas_binaural_reverb_close(
+ REVERB_STRUCT_HANDLE *hReverb /* i/o: binaural reverb handle */
+);
+
+void ivas_binaural_reverb_processFrame(
+ REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */
+ const int16_t numInChannels, /* i : num input channels to be processed */
+ float inReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : input CLDFB data real */
+ float inImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : input CLDFB data imag */
+ float outReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : output CLDFB data real */
+ float outImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : output CLDFB data imag */
+ const uint8_t offsetSamplesIO /* i : number of offset samples */
+);
+
+ivas_error ivas_reverb_open(
+ REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */
+ const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */
+ const HRTFS_HANDLE hHrtf, /* i : HRTF handle */
+ RENDER_CONFIG_DATA *pConfig, /* i : Reverb configuration */
+ const int32_t output_Fs /* i : output sampling rate */
+);
+
+void ivas_reverb_close(
+ REVERB_HANDLE *hReverb /* i/o: Reverberator handle */
+);
+
+ivas_error ivas_reverb_process(
+ REVERB_HANDLE hReverb, /* i/o: reverb state */
+ const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */
+ const int16_t mix_signals, /* i : add reverb to output signal */
+ float pcm_in[][L_FRAME48k], /* i : the PCM audio to apply reverb on */
+ float pcm_out[][L_FRAME48k], /* o : the PCM audio with reverb applied */
+ const int16_t i_ts
+);
+
+void ivas_rev_delay_line_init(
+ ivas_rev_delay_line_t *pDelay, /* o : the delay line to initialize */
+ float *memory_buffer, /* i : the memory buffer to use for the delay line */
+ const uint16_t delay, /* i : the delay */
+ const uint16_t maxdelay /* i : maximum delay to be supported */
+);
+
+/* !r: sample gotten out of delay line, and amplified by set gain */
+float ivas_rev_delay_line_get_sample(
+ ivas_rev_delay_line_t *pDelay /* i/o: the delay line */
+);
+
+void ivas_rev_delay_line_feed_sample(
+ ivas_rev_delay_line_t *pDelay, /* i : the delay line */
+ float input /* i : the sample to feed */
+);
+
+void ivas_rev_delay_line_get_sample_blk(
+ ivas_rev_delay_line_t *pDelay, /* i : the delay line */
+ const uint16_t blk_size, /* i : number of samples in the data block */
+ float *output /* i/o: amples gotten out of delay line, and amplified by set gainin */
+);
+
+void ivas_rev_delay_line_feed_sample_blk(
+ ivas_rev_delay_line_t *pDelay, /* i/o: the delay line */
+ const uint16_t blk_size, /* i : number of samples in the input data block */
+ float *input /* i : the samples to feed */
+);
+
+void ivas_reverb_iir_filt_init(
+ ivas_rev_iir_filter_t *iirFilter, /* o : IIR filter */
+ const uint16_t maxTaps /* i : maximum number of filter taps */
+);
+
+void ivas_reverb_iir_filt_set(
+ ivas_rev_iir_filter_t *iirFilter, /* i/o: IIR filter */
+ uint16_t nr_taps, /* i : number of IIR filter taps */
+ const float *coefA, /* i : A filter coefficients to set */
+ const float *coefB /* i : the B filter coefficients to set */
+);
+
+void ivas_reverb_iir_filt_2taps_feed_blk(
+ ivas_rev_iir_filter_t *iirFilter, /* i/o: IIR filter */
+ const uint16_t blk_size, /* i : size */
+ const float *input, /* i : input buffer */
+ float *output /* i : output buffer */
+);
+
+uint16_t int_log2(
+ uint32_t powerOf2
+);
+
+int16_t ivas_reverb_t2f_f2t_init(
+ ivas_reverb_t2f_f2t_t *t2f_f2t,
+ const int16_t fft_size,
+ const int16_t block_size
+);
+
+void ivas_reverb_t2f_f2t_ClearHistory(
+ ivas_reverb_t2f_f2t_t *t2f_f2t
+);
+
+void ivas_reverb_t2f_f2t_in(
+ ivas_reverb_t2f_f2t_t *t2f_f2t,
+ float *input_L,
+ float *input_R, float *buffer_L,
+ float *buffer_R
+);
+
+void ivas_reverb_t2f_f2t_out(
+ ivas_reverb_t2f_f2t_t *t2f_f2t,
+ float *buffer_L,
+ float *buffer_R,
+ float *output_L,
+ float *output_R
+);
+
+int16_t ivas_reverb_fft_filter_init(
+ ivas_reverb_fft_filter_t *fft_filter,
+ const int16_t fft_size
+);
+
+void ivas_reverb_fft_filter_ComplexMul(
+ ivas_reverb_fft_filter_t *fft_filter,
+ float *buffer
+);
+
+void ivas_reverb_fft_filter_CrossMix(
+ float *buffer0,
+ float *buffer1,
+ const int16_t fft_size
+);
+
+void ivas_reverb_fft_filter_ConvertFFTWF_2_FFTR(
+ rv_fftwf_type_complex *spectrum,
+ float *fft_real,
+ const int16_t fft_size
+);
+
+void ivas_reverb_define_window_fft(
+ float *pWindow,
+ const int16_t transitionStart,
+ const int16_t transitionLength,
+ const int16_t spectrumLength
+);
+
+int16_t ivas_reverb_calc_color_filters(
+ const float *pTargetL,
+ const float *pTargetR,
+ const float *pWindow,
+ const int16_t fft_size,
+ const float delay,
+ rv_fftwf_type_complex *pBeqL,
+ rv_fftwf_type_complex *pBeqR
+);
+
+int16_t ivas_reverb_calc_correl_filters(
+ const float *pTargetICC,
+ const float *pWindow,
+ const int16_t fft_size,
+ const float delay,
+ rv_fftwf_type_complex *pU,
+ rv_fftwf_type_complex *pV
+);
+
+void ivas_reverb_calc_color_levels(
+ const int32_t output_Fs,
+ const int16_t freq_count,
+ const int16_t loop_count,
+ const float *pFc,
+ const float *pAcoustic_dsr,
+ const float *pHrtf_avg_pwr_L,
+ const float *pHrtf_avg_pwr_R,
+ const int16_t *pLoop_delays,
+ const float *pT60_filter_coeff,
+ float *pTarget_color_L,
+ float *pTarget_color_R
+);
+
+void ivas_reverb_prepare_cldfb_params(
+ ivas_roomAcoustics_t *pInput_params,
+ const HRTFS_FASTCONV_HANDLE hHrtfFastConv,
+ const AUDIO_CONFIG input_audio_config,
+ const int16_t use_brir,
+ const int32_t output_Fs,
+ float *pOutput_t60,
+ float *pOutput_ene );
+
+void ivas_reverb_interpolate_acoustic_data(
+ const int16_t input_table_size,
+ const float *pInput_fc,
+ const float *pInput_t60,
+ const float *pInput_dsrR,
+ const int16_t output_table_size,
+ const float *pOutput_fc,
+ float *pOutput_t60,
+ float *pOutput_dsr
+);
+
+void ivas_reverb_get_hrtf_set_properties(
+ float **ppHrtf_set_L_re,
+ float **ppHrtf_set_L_im,
+ float **ppHrtf_set_R_re,
+ float **ppHrtf_set_R_im,
+ const AUDIO_CONFIG input_audio_config,
+ const int16_t hrtf_count,
+ const int16_t in_freq_count,
+ const int16_t out_freq_count,
+ float *pOut_avg_pwr_L,
+ float *pOut_avg_pwr_R,
+ float *pOut_i_a_coherence
+);
+
+
+/*---------------------------------------------------------------------------------*
+ * Rotation Prototypes
+ *-----------------------------------------------------------------------------------*/
+
+ivas_error ivas_headTrack_open(
+ HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* o : head track handle */
+);
+
+void Quat2Euler(
+ const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */
+ float *yaw, /* o : yaw */
+ float *pitch, /* o : pitch */
+ float *roll /* o : roll */
+);
+
+void QuatToRotMat(
+ const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */
+ float Rmat[3][3] /* o : real-space rotation matrix for this rotation */
+);
+
+void rotateAziEle(
+ float azi_in, /* i : output elevation */
+ float ele_in, /* i : input elevation */
+ int16_t *azi, /* o : rotated azimuth */
+ int16_t *ele, /* o : rotated elevation */
+ float Rmat[3][3], /* i : real-space rotation matrix */
+ const int16_t isPlanar /* i : is roation planar and elevation meaningless? */
+);
+
+void SHrotmatgen(
+ float SHrotmat[SBA_NHARM_HOA3][SBA_NHARM_HOA3], /* o : SHD rotation matrix */
+ float Rmat[3][3], /* i : real-space rotation matrix */
+ const int16_t order /* i : ambisonics order */
+);
+
+void rotateFrame_shd(
+ HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : head track handle */
+ float output[][L_FRAME48k], /* i/o: unrotated HOA3 signal buffer in TD */
+ const int16_t subframe_len, /* i : subframe length per channel */
+ const IVAS_OUTPUT_SETUP hTransSetup, /* i : format for rotation */
+ const int16_t subframe_idx /* i : subframe index */
+);
+
+void rotateFrame_sd(
+ HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : head track handle */
+ float output[][L_FRAME48k], /* i/o: unrotated SD signal buffer in TD */
+ const int16_t subframe_len, /* i : subframe length per channel */
+ const IVAS_OUTPUT_SETUP hTransSetup, /* i : format for rotation */
+ const EFAP_HANDLE hEFAPdata, /* i : EFAP structure */
+ const int16_t subframe_idx /* i : subframe index */
+);
+
+void rotateFrame_shd_cldfb(
+ float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain real part */
+ float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain imag part */
+ float Rmat[3][3], /* i : real-space rotation matrix */
+ const int16_t nInChannels, /* i : number of channels */
+ const int16_t shd_rot_max_order /* i : split-order rotation method */
+);
+
+void rotateFrame_sd_cldfb(
+ HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : head track handle */
+ float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain real part */
+ float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain imag part */
+ const IVAS_OUTPUT_SETUP_HANDLE hOutputSetup, /* i : output format setup number of channels */
+ const EFAP_HANDLE hEFAPdata, /* i : EFAP structure */
+ const int16_t nb_band /* i : number of CLDFB bands to process */
+);
+
+
+/*----------------------------------------------------------------------------------*
+ * Renderer configuration
+ *----------------------------------------------------------------------------------*/
+
+ivas_error ivas_render_config_open(
+ RENDER_CONFIG_HANDLE *hRenderConfig /* i/o: Renderer config handle */
+);
+
+void ivas_render_config_close(
+ RENDER_CONFIG_HANDLE *hRenderConfig /* i/o: Renderer config handle */
+);
+
+ivas_error ivas_render_config_init_from_rom(
+ RENDER_CONFIG_HANDLE *hRenderConfig, /* i/o: Renderer config handle */
+ const int16_t room_flag_on /* i : room effect on/off flag */
+);
+
+
+/*----------------------------------------------------------------------------------*
+ * Orientation tracking
+ *----------------------------------------------------------------------------------*/
+
+void ivas_orient_trk_Init(
+ ivas_orient_trk_state_t *pOTR
+);
+
+ivas_error ivas_orient_trk_SetTrackingType(
+ ivas_orient_trk_state_t *pOTR,
+ OTR_TRACKING_T trackingType
+);
+
+ivas_error ivas_orient_trk_SetAbsoluteOrientation(
+ ivas_orient_trk_state_t *pOTR,
+ float yaw,
+ float pitch,
+ float roll
+);
+
+ivas_error ivas_orient_trk_Process(
+ ivas_orient_trk_state_t *pOTR
+);
+
+ivas_error ivas_orient_trk_GetTrackedOrientation(
+ ivas_orient_trk_state_t *pOTR,
+ float *yaw,
+ float *pitch,
+ float *roll
+);
+/* clang-format on */
+
+#endif /* IVAS_PROT_REND_H */
diff --git a/lib_rend/ivas_render_config.c b/lib_rend/ivas_render_config.c
index a27fc58f2dfefef6a77c44074ee4c813c19ee262..405ae8d72f343e7c614461aae8c83a36febe76ea 100644
--- a/lib_rend/ivas_render_config.c
+++ b/lib_rend/ivas_render_config.c
@@ -33,7 +33,7 @@
#include
#include "options.h"
#include "prot.h"
-#include "ivas_prot.h"
+#include "ivas_prot_rend.h"
#include "ivas_rom_rend.h"
#include "ivas_rom_TdBinauralRenderer.h"
#ifdef DEBUGGING
diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c
index 09e482234135a1e02c34b9aee1a6374563ac293d..a3d55584b406f5f1e41d578e7038bb47bb06ee3f 100644
--- a/lib_rend/ivas_reverb.c
+++ b/lib_rend/ivas_reverb.c
@@ -33,7 +33,7 @@
#include
#include "options.h"
#include "prot.h"
-#include "ivas_prot.h"
+#include "ivas_prot_rend.h"
#include "ivas_cnst.h"
#ifdef DEBUGGING
#include "debug.h"
@@ -44,6 +44,19 @@
#include "wmc_auto.h"
+/* The reverberator structure implemented here is described in detail in:
+ * Vilkamo, J., Neugebauer, B., & Plogsties, J. (2012). Sparse frequency-domain reverberator.
+ * Journal of the Audio Engineering Society, 59(12), 936-943. */
+
+/*-------------------------------------------------------------------------
+ * Local constants
+ *------------------------------------------------------------------------*/
+
+#define BIN_REND_RANDOM_SEED 1 /* random seed for generating reverb decorrelators */
+
+#define CLDFB_SLOTS_PER_SECOND 800 /* Used for initializing reverb */
+
+
/*------------------------------------------------------------------------------------------*
* Local constants
*------------------------------------------------------------------------------------------*/
@@ -117,6 +130,151 @@ typedef struct ivas_reverb_params_t
static ivas_error calc_jot_t60_coeffs( float *pH_dB, const uint16_t nrFrequencies, float *pFrequencies, float *pCoeffA, float *pCoeffB, const float fNyquist );
+/*-------------------------------------------------------------------------
+ * binRend_rand()
+ *
+ *
+ *------------------------------------------------------------------------*/
+
+static uint16_t binRend_rand(
+ REVERB_STRUCT_HANDLE hReverb /* i/o: binaural reverb handle */
+)
+{
+ hReverb->binRend_RandNext = hReverb->binRend_RandNext * 1103515245 + 12345;
+
+ return (uint16_t) ( hReverb->binRend_RandNext / 65536 ) % 32768;
+}
+
+
+/*-------------------------------------------------------------------------
+ * ivas_binaural_reverb_setPreDelay()
+ *
+ *
+ *------------------------------------------------------------------------*/
+
+static void ivas_binaural_reverb_setPreDelay(
+ REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */
+ const int16_t delaySamples /* i : reverb pre-delay in CLDFB slots */
+)
+{
+ if ( delaySamples < 1 )
+ {
+ hReverb->preDelayBufferLength = 1;
+
+ return;
+ }
+
+ if ( delaySamples > REVERB_PREDELAY_MAX )
+ {
+ hReverb->preDelayBufferLength = REVERB_PREDELAY_MAX;
+
+ return;
+ }
+
+ hReverb->preDelayBufferLength = delaySamples;
+
+ return;
+}
+
+
+/*-------------------------------------------------------------------------
+ * ivas_binaural_reverb_setReverbTimes()
+ *
+ *
+ *------------------------------------------------------------------------*/
+
+static void ivas_binaural_reverb_setReverbTimes(
+ REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */
+ const int32_t output_Fs, /* i : sampling_rate */
+ const float *revTimes, /* i : reverberation times T60 for each CLDFB bin in seconds */
+ const float *revEnes /* i : spectrum for reverberated sound at each CLDFB bin */
+)
+{
+ int16_t bin, ch, tap, sample;
+ float binCenterFreq, diffuseFieldICC, tmpVal, attenuationFactorPerSample;
+ float intendedEnergy, actualizedEnergy, energyBuildup, currentEnergy, attenuationFactorPerSampleSq;
+
+ hReverb->binRend_RandNext = (uint16_t) BIN_REND_RANDOM_SEED;
+ hReverb->highestBinauralCoherenceBin = 0;
+ for ( bin = 0; bin < hReverb->numBins; bin++ )
+ {
+ /* Determine the diffuse field binaural coherence */
+ binCenterFreq = ( (float) bin + 0.5f ) / ( (float) hReverb->numBins ) * ( (float) output_Fs ) / 2.0f;
+ if ( bin == 0 )
+ {
+ diffuseFieldICC = 1.0f;
+ }
+ else if ( binCenterFreq < 2700.0f )
+ {
+ diffuseFieldICC = sinf( EVS_PI * binCenterFreq / 550.0f + 1e-20f ) / ( EVS_PI * binCenterFreq / 550.0f + 1e-20f ) * ( 1.0f - binCenterFreq / 2700.0f );
+ hReverb->highestBinauralCoherenceBin = bin;
+ }
+ else
+ {
+ diffuseFieldICC = 0.0f;
+ }
+
+ /* Mixing gains to generate a diffuse-binaural sound based on incoherent sound */
+ tmpVal = ( 1.0f - sqrtf( 1.0f - powf( diffuseFieldICC, 2.0 ) ) ) / 2.0f;
+ if ( diffuseFieldICC > 0 )
+ {
+ hReverb->binauralCoherenceCrossmixGains[bin] = sqrtf( fabsf( tmpVal ) );
+ }
+ else
+ {
+ hReverb->binauralCoherenceCrossmixGains[bin] = -sqrtf( fabsf( tmpVal ) );
+ }
+ hReverb->binauralCoherenceDirectGains[bin] = sqrtf( 1.0f - fabsf( tmpVal ) );
+
+ /* Determine attenuation factor that generates the appropriate energy decay according to reverberation time */
+ attenuationFactorPerSample = powf( 10.0f, -3.0f * ( 1.0f / ( (float) CLDFB_SLOTS_PER_SECOND * revTimes[bin] ) ) );
+ hReverb->loopAttenuationFactor[bin] = powf( attenuationFactorPerSample, hReverb->loopBufLength[bin] );
+ attenuationFactorPerSampleSq = attenuationFactorPerSample * attenuationFactorPerSample;
+
+ /* Design sparse decorrelation filters. The decorrelation filters, due to random procedures involved,
+ * may affect the spectrum of the output. The spectral effect is therefore monitored and compensated for. */
+ intendedEnergy = 0.0f;
+ actualizedEnergy = 0.0f;
+
+ for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
+ {
+ energyBuildup = 0.0f;
+ currentEnergy = 1.0f;
+ tap = 0;
+
+ for ( sample = 0; sample < hReverb->loopBufLength[bin]; sample++ )
+ {
+ intendedEnergy += currentEnergy;
+
+ /* The randomization at the energy build up affects where the sparse taps are located */
+ energyBuildup += currentEnergy + 0.1f * ( (float) binRend_rand( hReverb ) / PCM16_TO_FLT_FAC - 0.5f );
+
+ if ( energyBuildup >= 1.0f ) /* A new filter tap is added at this condition */
+ {
+ /* Four efficient phase operations: n*pi/2, n=0,1,2,3 */
+ hReverb->tapPhaseShiftType[bin][ch][tap] = (int16_t) ( binRend_rand( hReverb ) % 4 );
+ /* Set the tapPointer to point to the determined sample at the loop buffer */
+ hReverb->tapPointersReal[bin][ch][tap] = &( hReverb->loopBufReal[bin][sample] );
+ hReverb->tapPointersImag[bin][ch][tap] = &( hReverb->loopBufImag[bin][sample] );
+ energyBuildup -= 1.0f; /* A tap is added, thus remove its energy from the buildup */
+ tap++;
+ actualizedEnergy += 1.0f;
+ }
+ currentEnergy *= attenuationFactorPerSampleSq;
+ }
+ hReverb->taps[bin][ch] = tap; /* Number of taps determined at the above random procedure */
+ }
+
+ /* The decorrelator design and IIR attenuation rate affects the energy of reverb, which is compensated here */
+ hReverb->reverbEqGains[bin] = sqrtf( revEnes[bin] ); /* Determined reverb spectrum */
+ hReverb->reverbEqGains[bin] *= sqrtf( intendedEnergy / actualizedEnergy ); /* Correction of random effects at the decorrelator design */
+ hReverb->reverbEqGains[bin] *= sqrtf( 0.5f * ( 1.0f - attenuationFactorPerSampleSq ) ); /* Correction of IIR decay rate */
+ }
+
+ return;
+}
+
+
/*-----------------------------------------------------------------------------------------*
* Function compute_feedback_matrix()
*
@@ -1440,3 +1598,349 @@ ivas_error ivas_reverb_process(
return IVAS_ERR_OK;
}
+
+
+/*-------------------------------------------------------------------------
+ * ivas_binaural_reverb_processFrame()
+ *
+ * Compute the reverberation - room effect
+ *------------------------------------------------------------------------*/
+
+void ivas_binaural_reverb_processFrame(
+ REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */
+ const int16_t numInChannels, /* i : num inputs to be processed */
+ float inReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : input CLDFB data real, Comment: This change swaps two first dimensions as first dimension is not constant. */
+ float inImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : input CLDFB data imag */
+ float outReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : output CLDFB data real */
+ float outImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : output CLDFB data imag */
+ const uint8_t offsetSamplesIO /* i : number of offset samples */
+)
+{
+ /* Declare the required variables */
+ int16_t idx, bin, ch, sample, invertSampleIndex, tapIdx, *phaseShiftTypePr;
+ float **tapRealPr, **tapImagPr;
+
+ /* 1) Rotate the data in the loop buffer of the reverberator.
+ * Notice that the audio at the loop buffers is at time-inverted order
+ * for convolution purposes later on. */
+ for ( bin = 0; bin < hReverb->numBins; bin++ )
+ {
+ /* Move the data forwards by blockSize (i.e. by the frame size of 16 CLDFB slots) */
+ mvr2r( hReverb->loopBufReal[bin], hReverb->loopBufReal[bin] + hReverb->blockSize, hReverb->loopBufLength[bin] );
+ mvr2r( hReverb->loopBufImag[bin], hReverb->loopBufImag[bin] + hReverb->blockSize, hReverb->loopBufLength[bin] );
+
+ /* Add the data from the end of the loop to the beginning, with an attenuation factor
+ * according to RT60. This procedure generates an IIR decaying response. The response
+ * is decorrelated later on. */
+ v_multc( hReverb->loopBufReal[bin] + hReverb->loopBufLength[bin], hReverb->loopAttenuationFactor[bin], hReverb->loopBufReal[bin], hReverb->blockSize );
+ v_multc( hReverb->loopBufImag[bin] + hReverb->loopBufLength[bin], hReverb->loopAttenuationFactor[bin], hReverb->loopBufImag[bin], hReverb->blockSize );
+ }
+
+ /* 2) Apply the determined pre-delay to the input audio, and add the delayed audio to the loop. */
+ idx = hReverb->preDelayBufferIndex;
+ for ( sample = 0; sample < hReverb->blockSize; sample++ )
+ {
+ uint16_t sampleWithOffset;
+ sampleWithOffset = sample + offsetSamplesIO;
+ invertSampleIndex = hReverb->blockSize - sample - 1;
+ for ( bin = 0; bin < hReverb->numBins; bin++ )
+ {
+ /* Add from pre-delay buffer a sample to the loop buffer, in a time-inverted order.
+ * Also apply the spectral gains determined for the reverberation */
+ hReverb->loopBufReal[bin][invertSampleIndex] += hReverb->preDelayBufferReal[idx][bin] * hReverb->reverbEqGains[bin];
+ hReverb->loopBufImag[bin][invertSampleIndex] += hReverb->preDelayBufferImag[idx][bin] * hReverb->reverbEqGains[bin];
+ hReverb->preDelayBufferReal[idx][bin] = 0.0f;
+ hReverb->preDelayBufferImag[idx][bin] = 0.0f;
+ }
+
+ /* Add every second input channel as is to the pre-delay buffer, and every second input channel with
+ * 90 degrees phase shift to reduce energy imbalances between coherent and incoherent sounds */
+ for ( ch = 0; ch < numInChannels; ch++ )
+ {
+ if ( ch % 2 )
+ {
+ v_add( hReverb->preDelayBufferReal[idx], inReal[ch][sampleWithOffset], hReverb->preDelayBufferReal[idx], hReverb->numBins );
+ v_add( hReverb->preDelayBufferImag[idx], inImag[ch][sampleWithOffset], hReverb->preDelayBufferImag[idx], hReverb->numBins );
+ }
+ else
+ {
+ v_sub( hReverb->preDelayBufferReal[idx], inImag[ch][sampleWithOffset], hReverb->preDelayBufferReal[idx], hReverb->numBins );
+ v_add( hReverb->preDelayBufferImag[idx], inReal[ch][sampleWithOffset], hReverb->preDelayBufferImag[idx], hReverb->numBins );
+ }
+ }
+ idx = ( idx + 1 ) % hReverb->preDelayBufferLength;
+ }
+ hReverb->preDelayBufferIndex = idx;
+
+ /* 3) Perform the filtering/decorrelating, using complex and sparse FIR filtering */
+ for ( bin = 0; bin < hReverb->numBins; bin++ )
+ {
+ for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
+ {
+ /* These tap pointers have been determined to point to the loop buffer at sparse locations */
+ tapRealPr = hReverb->tapPointersReal[bin][ch];
+ tapImagPr = hReverb->tapPointersImag[bin][ch];
+ phaseShiftTypePr = hReverb->tapPhaseShiftType[bin][ch];
+
+ /* Flush output */
+ set_f( hReverb->outputBufferReal[bin][ch], 0.0f, hReverb->blockSize );
+ set_f( hReverb->outputBufferImag[bin][ch], 0.0f, hReverb->blockSize );
+
+ /* Add from temporally decaying sparse tap locations the audio to the output. */
+ for ( tapIdx = 0; tapIdx < hReverb->taps[bin][ch]; tapIdx++ )
+ {
+ switch ( phaseShiftTypePr[tapIdx] )
+ {
+ case 0: /* 0 degrees phase */
+ v_add( hReverb->outputBufferReal[bin][ch], tapRealPr[tapIdx], hReverb->outputBufferReal[bin][ch], hReverb->blockSize );
+ v_add( hReverb->outputBufferImag[bin][ch], tapImagPr[tapIdx], hReverb->outputBufferImag[bin][ch], hReverb->blockSize );
+ break;
+ case 1: /* 90 degrees phase */
+ v_sub( hReverb->outputBufferReal[bin][ch], tapImagPr[tapIdx], hReverb->outputBufferReal[bin][ch], hReverb->blockSize );
+ v_add( hReverb->outputBufferImag[bin][ch], tapRealPr[tapIdx], hReverb->outputBufferImag[bin][ch], hReverb->blockSize );
+ break;
+ case 2: /* 180 degrees phase */
+ v_sub( hReverb->outputBufferReal[bin][ch], tapRealPr[tapIdx], hReverb->outputBufferReal[bin][ch], hReverb->blockSize );
+ v_sub( hReverb->outputBufferImag[bin][ch], tapImagPr[tapIdx], hReverb->outputBufferImag[bin][ch], hReverb->blockSize );
+ break;
+ default: /* 270 degrees phase */
+ v_add( hReverb->outputBufferReal[bin][ch], tapImagPr[tapIdx], hReverb->outputBufferReal[bin][ch], hReverb->blockSize );
+ v_sub( hReverb->outputBufferImag[bin][ch], tapRealPr[tapIdx], hReverb->outputBufferImag[bin][ch], hReverb->blockSize );
+ break;
+ }
+ }
+ }
+
+ /* Generate diffuse field binaural coherence by mixing the incoherent reverberated channels with pre-defined gains */
+ if ( bin <= hReverb->highestBinauralCoherenceBin )
+ {
+ if ( hReverb->useBinauralCoherence )
+ {
+ for ( sample = 0; sample < hReverb->blockSize; sample++ )
+ {
+ float leftRe, rightRe, leftIm, rightIm;
+
+ leftRe = hReverb->binauralCoherenceDirectGains[bin] * hReverb->outputBufferReal[bin][0][sample] + hReverb->binauralCoherenceCrossmixGains[bin] * hReverb->outputBufferReal[bin][1][sample];
+ rightRe = hReverb->binauralCoherenceDirectGains[bin] * hReverb->outputBufferReal[bin][1][sample] + hReverb->binauralCoherenceCrossmixGains[bin] * hReverb->outputBufferReal[bin][0][sample];
+ leftIm = hReverb->binauralCoherenceDirectGains[bin] * hReverb->outputBufferImag[bin][0][sample] + hReverb->binauralCoherenceCrossmixGains[bin] * hReverb->outputBufferImag[bin][1][sample];
+ rightIm = hReverb->binauralCoherenceDirectGains[bin] * hReverb->outputBufferImag[bin][1][sample] + hReverb->binauralCoherenceCrossmixGains[bin] * hReverb->outputBufferImag[bin][0][sample];
+
+ hReverb->outputBufferReal[bin][0][sample] = leftRe;
+ hReverb->outputBufferReal[bin][1][sample] = rightRe;
+ hReverb->outputBufferImag[bin][0][sample] = leftIm;
+ hReverb->outputBufferImag[bin][1][sample] = rightIm;
+ }
+ }
+ }
+ }
+
+ /* 4) Write data to output */
+ for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
+ {
+ for ( sample = 0; sample < hReverb->blockSize; sample++ )
+ {
+ uint16_t sampleWithOffset;
+
+ sampleWithOffset = sample + offsetSamplesIO;
+ /* Audio was in the temporally inverted order for convolution, re-invert audio to output */
+ invertSampleIndex = hReverb->blockSize - sample - 1;
+
+ for ( bin = 0; bin < hReverb->numBins; bin++ )
+ {
+ outReal[ch][sampleWithOffset][bin] = hReverb->outputBufferReal[bin][ch][invertSampleIndex];
+ outImag[ch][sampleWithOffset][bin] = hReverb->outputBufferImag[bin][ch][invertSampleIndex];
+ }
+ for ( ; bin < CLDFB_NO_CHANNELS_MAX; bin++ )
+ {
+ outReal[ch][sampleWithOffset][bin] = 0.0f;
+ outImag[ch][sampleWithOffset][bin] = 0.0f;
+ }
+ }
+ }
+
+ return;
+}
+
+
+/*-------------------------------------------------------------------------
+ * ivas_binaural_reverb_open()
+ *
+ * Allocate and initialize binaural room reverberator handle
+ *------------------------------------------------------------------------*/
+
+ivas_error ivas_binaural_reverb_open(
+ REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */
+ const int16_t numBins, /* i : number of CLDFB bins */
+ const int16_t numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame */
+ ivas_roomAcoustics_t *roomAcoustics, /* i/o: room acoustics parameters */
+ const AUDIO_CONFIG output_config, /* i : output audio configuration */
+ const int32_t sampling_rate, /* i : sampling rate */
+ const RENDERER_TYPE renderer_type, /* i : renderer type */
+ const HRTFS_FASTCONV_HANDLE hHrtfFastConv, /* i : FastConv HRTF handle */
+ const HRTFS_PARAMBIN_HANDLE hHrtfParambin /* i : Parametric binauralizer HRTF handle */
+)
+{
+ int16_t bin, chIdx, k, len;
+ REVERB_STRUCT_HANDLE hReverb;
+ const float *revTimes;
+ float t60[CLDFB_NO_CHANNELS_MAX];
+ float ene[CLDFB_NO_CHANNELS_MAX];
+
+ if ( ( *hReverbPr = (REVERB_STRUCT_HANDLE) malloc( sizeof( REVERB_STRUCT ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) );
+ }
+
+ hReverb = *hReverbPr;
+
+ hReverb->useBinauralCoherence = 1;
+ hReverb->preDelayBufferLength = 1;
+ hReverb->preDelayBufferIndex = 0;
+
+ hReverb->numBins = numBins;
+ hReverb->blockSize = numCldfbSlotsPerFrame;
+
+ for ( k = 0; k < REVERB_PREDELAY_MAX + 1; k++ )
+ {
+ set_f( hReverb->preDelayBufferReal[k], 0.0f, hReverb->numBins );
+ set_f( hReverb->preDelayBufferImag[k], 0.0f, hReverb->numBins );
+ }
+
+ if ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM )
+ {
+ if ( !roomAcoustics->override )
+ {
+ revTimes = hHrtfFastConv->fastconvReverberationTimes;
+ }
+ else
+ {
+ revTimes = t60;
+ }
+ }
+ else
+ {
+ revTimes = hHrtfParambin->parametricReverberationTimes;
+ }
+
+ for ( bin = 0; bin < hReverb->numBins; bin++ )
+ {
+ /* Loop Buffer */
+ hReverb->loopBufLengthMax[bin] = (int16_t) ( 500 / ( 1 + bin ) + ( CLDFB_NO_CHANNELS_MAX - bin ) );
+
+ len = hReverb->loopBufLengthMax[bin] + hReverb->blockSize;
+ if ( ( hReverb->loopBufReal[bin] = (float *) malloc( len * sizeof( float ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) );
+ }
+
+ if ( ( hReverb->loopBufImag[bin] = (float *) malloc( len * sizeof( float ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) );
+ }
+
+ set_f( hReverb->loopBufReal[bin], 0.0f, len );
+ set_f( hReverb->loopBufImag[bin], 0.0f, len );
+
+ /* Determine loop buffer length. The following formula is manually tuned to generate sufficiently long
+ * but not excessively long loops to generate reverberation. */
+ /* Note: the resulted length is very sensitive to the precision of the constants below (e.g. 1.45 vs. 1.45f) */
+ hReverb->loopBufLength[bin] = (int16_t) ( 1.45 * (int16_t) ( revTimes[bin] * 150.0 ) + 1 );
+ hReverb->loopBufLength[bin] = min( hReverb->loopBufLength[bin], hReverb->loopBufLengthMax[bin] );
+
+ /* Sparse Filter Tap Locations */
+ for ( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ )
+ {
+ len = hReverb->loopBufLength[bin];
+
+ if ( ( hReverb->tapPhaseShiftType[bin][chIdx] = (int16_t *) malloc( len * sizeof( int16_t ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) );
+ }
+ set_s( hReverb->tapPhaseShiftType[bin][chIdx], 0, len );
+
+ if ( ( hReverb->tapPointersReal[bin][chIdx] = (float **) malloc( len * sizeof( float * ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) );
+ }
+
+ if ( ( hReverb->tapPointersImag[bin][chIdx] = (float **) malloc( len * sizeof( float * ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) );
+ }
+
+ len = hReverb->blockSize;
+ if ( ( hReverb->outputBufferReal[bin][chIdx] = (float *) malloc( len * sizeof( float ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) );
+ }
+
+ if ( ( hReverb->outputBufferImag[bin][chIdx] = (float *) malloc( len * sizeof( float ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) );
+ }
+
+ set_f( hReverb->outputBufferReal[bin][chIdx], 0.0f, len );
+ set_f( hReverb->outputBufferImag[bin][chIdx], 0.0f, len );
+ }
+ }
+
+ if ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM )
+ {
+ if ( !roomAcoustics->override )
+ {
+ ivas_binaural_reverb_setReverbTimes( hReverb, sampling_rate, hHrtfFastConv->fastconvReverberationTimes, hHrtfFastConv->fastconvReverberationEneCorrections );
+ ivas_binaural_reverb_setPreDelay( hReverb, 10 );
+ }
+ else
+ {
+ ivas_reverb_prepare_cldfb_params( roomAcoustics, hHrtfFastConv, output_config, roomAcoustics->use_brir, sampling_rate, t60, ene );
+ ivas_binaural_reverb_setReverbTimes( hReverb, sampling_rate, t60, ene );
+ ivas_binaural_reverb_setPreDelay( hReverb, (int16_t) roundf( 48000.0f * roomAcoustics->acousticPreDelay / CLDFB_NO_CHANNELS_MAX ) );
+ }
+ }
+ else
+ {
+ ivas_binaural_reverb_setReverbTimes( hReverb, sampling_rate, hHrtfParambin->parametricReverberationTimes, hHrtfParambin->parametricReverberationEneCorrections );
+ ivas_binaural_reverb_setPreDelay( hReverb, 10 );
+ }
+
+ return IVAS_ERR_OK;
+}
+
+
+/*-------------------------------------------------------------------------
+ * ivas_binaural_reverb_close()
+ *
+ * Close binaural room reverberator handle
+ *------------------------------------------------------------------------*/
+
+void ivas_binaural_reverb_close(
+ REVERB_STRUCT_HANDLE *hReverb /* i/o: binaural reverb handle */
+)
+{
+ int16_t bin, chIdx;
+
+ if ( hReverb == NULL || *hReverb == NULL )
+ {
+ return;
+ }
+
+ for ( bin = 0; bin < ( *hReverb )->numBins; bin++ )
+ {
+ for ( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ )
+ {
+ free( ( *hReverb )->tapPhaseShiftType[bin][chIdx] );
+ free( ( *hReverb )->tapPointersReal[bin][chIdx] );
+ free( ( *hReverb )->tapPointersImag[bin][chIdx] );
+ free( ( *hReverb )->outputBufferReal[bin][chIdx] );
+ free( ( *hReverb )->outputBufferImag[bin][chIdx] );
+ }
+ free( ( *hReverb )->loopBufReal[bin] );
+ free( ( *hReverb )->loopBufImag[bin] );
+ }
+
+ free( ( *hReverb ) );
+ ( *hReverb ) = NULL;
+
+ return;
+}
diff --git a/lib_rend/ivas_reverb_delay_line.c b/lib_rend/ivas_reverb_delay_line.c
index ef0ca8b6c19792d6b705b9fa97db91c9bc51f39b..892a0d21c9854000fce1f913f16ff88ac3f3a7d8 100644
--- a/lib_rend/ivas_reverb_delay_line.c
+++ b/lib_rend/ivas_reverb_delay_line.c
@@ -33,6 +33,7 @@
#include
#include "options.h"
#include "ivas_prot.h"
+#include "ivas_prot_rend.h"
#include "prot.h"
#ifdef DEBUGGING
#include "debug.h"
diff --git a/lib_rend/ivas_reverb_fft_filter.c b/lib_rend/ivas_reverb_fft_filter.c
index 2c6a77ec2bd80dcd12bd1e3fb9897ff72bebaa96..725f5e6bc14dc5a43eecb292e2e23745d85c2be5 100644
--- a/lib_rend/ivas_reverb_fft_filter.c
+++ b/lib_rend/ivas_reverb_fft_filter.c
@@ -32,12 +32,12 @@
#include
#include "options.h"
-#include "ivas_prot.h"
+#include "prot.h"
+#include "ivas_prot_rend.h"
#ifdef DEBUGGING
#include "debug.h"
#endif
#include
-#include "prot.h"
#include "wmc_auto.h"
@@ -46,6 +46,7 @@
*------------------------------------------------------------------------------------------*/
static void fft_wrapper_2ch( float *buffer_L, float *buffer_R, const int16_t fft_size );
+
static void ifft_wrapper_2ch( float *buffer_L, float *buffer_R, const int16_t fft_size );
diff --git a/lib_rend/ivas_reverb_filter_design.c b/lib_rend/ivas_reverb_filter_design.c
index 80044e3e653d960f239321c833c6248fb7fba4f2..3069d1248af05a5429d318a1b7ea331de1dd0131 100644
--- a/lib_rend/ivas_reverb_filter_design.c
+++ b/lib_rend/ivas_reverb_filter_design.c
@@ -32,14 +32,14 @@
#include
#include "options.h"
-#include "ivas_prot.h"
+#include "prot.h"
+#include "ivas_prot_rend.h"
#ifdef DEBUGGING
#include "debug.h"
#endif
#include
#include
#include
-#include "prot.h"
#include "wmc_auto.h"
diff --git a/lib_rend/ivas_reverb_iir_filter.c b/lib_rend/ivas_reverb_iir_filter.c
index db3534ee8aea722b87e4af35cfed7b22e52b0eb6..ce73c9d864ed12705a82e739e891aef31c558b30 100644
--- a/lib_rend/ivas_reverb_iir_filter.c
+++ b/lib_rend/ivas_reverb_iir_filter.c
@@ -32,12 +32,11 @@
#include
#include "options.h"
-#include "ivas_prot.h"
#include "prot.h"
+#include "ivas_prot_rend.h"
#ifdef DEBUGGING
#include "debug.h"
#endif
-#include
#include "wmc_auto.h"
diff --git a/lib_rend/ivas_reverb_utils.c b/lib_rend/ivas_reverb_utils.c
index 565fd46ff89e2fb9451c2eed15a9bca8628b0967..6ff101bec56d53d8b040a4504c027ec5b2e64250 100644
--- a/lib_rend/ivas_reverb_utils.c
+++ b/lib_rend/ivas_reverb_utils.c
@@ -33,8 +33,7 @@
#include
#include "options.h"
#include "prot.h"
-#include "ivas_prot.h"
-#include "ivas_rom_binauralRenderer.h"
+#include "ivas_prot_rend.h"
#include "ivas_rom_rend.h"
#include
#ifdef DEBUGGING
diff --git a/lib_rend/ivas_rom_rend.c b/lib_rend/ivas_rom_rend.c
index 2a68d832e02d0e9fa30d3a51a22aca3c5894a02e..9624dddf5408238bf372b53c08aa8bc9c3b05701 100644
--- a/lib_rend/ivas_rom_rend.c
+++ b/lib_rend/ivas_rom_rend.c
@@ -43,7 +43,7 @@
* FASTCONV and PARAMETRIC binaural renderer ROM tables
*----------------------------------------------------------------------------------*/
-const float dmxmtx[BINAURAL_CHANNELS][11] =
+const float dmxmtx_table[BINAURAL_CHANNELS][11] =
{
{ 1.0f, 0.0f, 0.70709997f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f },
{ 0.0f, 1.0f, 0.70709997f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f },
@@ -72,33 +72,47 @@ const int16_t channelIndex_CICP14[7] = { 0, 1, 2, 5, 6, 9, 10 };
const int16_t channelIndex_CICP16[9] = { 0, 1, 2, 5, 6, 9, 10, 11, 12 };
const int16_t channelIndex_CICP19[11] = { 0, 1, 2, 3, 4, 7, 8, 9, 10, 13, 14 };
-/*----------------------------------------------------------------------------------*
- * TD ISm binaural renderer ROM tables
- *----------------------------------------------------------------------------------*/
- /* The maximum target times set to 100 msec. */
-const int16_t TDREND_SRC_REND_MaxTargetTimes[IVAS_NUM_SUPPORTED_FS] =
-{
- 1600, 3200, 4800 /* Corresponds to 16kHz, 32kHz, 48kHz */
+const float surCohEne[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS] =
+{
+ 3.0903f, 2.0053f, 1.0860f, 0.8072f, 0.7079f
+};
+
+const float spreadCohEne05[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS] =
+{
+ 2.3988f, 1.7783f, 1.1220f, 1.1220f, 1.1220f
+};
+
+const float spreadCohEne1[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS] =
+{
+ 1.5975f, 1.1220f, 1.1220f, 1.1220f, 1.1220f
+};
+
+const float lowBitRateBinauralEQ[LOW_BIT_RATE_BINAURAL_EQ_BINS] =
+{
+ 0.979f, 0.893f, 0.762f, 0.615f, 0.52f, 0.48f, 0.477f, 0.477f, 0.48f, 0.501f, 0.546f, 0.602f, 0.652f, 0.664f, 0.652f, 0.639f, 0.635f
};
-/* The maximum lengths of the blocks internally in the effect. Corresponds to 6 msec. This means also that */
-/* if the length of the input block is just above 6 msec, the block will be divided into two 3 msec blocks. */
-const int16_t TDREND_SRC_REND_MaxBlockLengths[IVAS_NUM_SUPPORTED_FS] =
+const float diffuseFieldCoherenceDifferenceX[BINAURAL_COHERENCE_DIFFERENCE_BINS] =
{
- 96, 192, 288 /* Corresponds to 16kHz, 32kHz, 48kHz */
+ 0.047421f, 0.19773f, 0.22582f, 0.10637f, 0.0087111f, 0.012028f, 0.031972f, 0.019668f, 0.0079928f
};
-const int16_t TDREND_MaxITD[IVAS_NUM_SUPPORTED_FS] =
+const float diffuseFieldCoherenceDifferenceY[BINAURAL_COHERENCE_DIFFERENCE_BINS] =
{
- 111, 222, 333 /* Corresponds to 16kHz, 32kHz, 48kHz */
+ -0.095628f, -0.30569f, -0.34427f, -0.15425f, -0.044628f, -0.057224f, -0.050835f, -0.035214f, -0.02215f
};
-const float TDREND_MaxITD_Incr[IVAS_NUM_SUPPORTED_FS] =
+const float diffuseFieldCoherenceDifferenceZ[BINAURAL_COHERENCE_DIFFERENCE_BINS] =
{
- 0.0925f, 0.1850f, 0.2775f /* Corresponds to 16kHz, 32kHz, 48kHz, e.g. ( ( 2 * MaxITD ) / ( 0.05 * 48000 ) ) */
+ 0.048207f, 0.10796f, 0.11845f, 0.047886f, 0.035917f, 0.045196f, 0.018863f, 0.015547f, 0.014157f
};
+
+/*----------------------------------------------------------------------------------*
+ * TD ISm binaural renderer ROM tables
+ *----------------------------------------------------------------------------------*/
+
const int16_t HRTF_MODEL_N_CPTS_VAR[HRTF_MODEL_N_SECTIONS] =
{
13, 12, 11
@@ -333,25 +347,8 @@ const float ivas_reverb_default_DSR[IVAS_REVERB_DEFAULT_N_BANDS] =
/* CICP1 - Mono */
const float ls_azimuth_CICP1[1] = { 0.0f };
const float ls_elevation_CICP1[1] = { 0.0f };
-const uint32_t ls_LFE_last_idx_CICP1[1] = { 0 };
-
-/* CICP2 - Stereo */
-const uint32_t ls_LFE_last_idx_CICP2[2] = { 0, 1 };
-
-/* CICP6 - 5.1 */
-const uint32_t ls_LFE_last_idx_CICP6[6] = { 0, 1, 2, 4, 5, 3 };
-
-/* CICP12 - 7.1 */
-const uint32_t ls_LFE_last_idx_CICP12[8] = { 0, 1, 2, 4, 5, 6, 7, 3 };
-
-/* CICP14 - 5.1.2 */
-const uint32_t ls_LFE_last_idx_CICP14[8] = { 0, 1, 2, 4, 5, 6, 7, 3 };
-/* CICP16 - 5.1.4 */
-const uint32_t ls_LFE_last_idx_CICP16[10] = { 0, 1, 2, 4, 5, 6, 7, 8, 9, 3 };
-/* CICP19 - 7.1.4 */
-const uint32_t ls_LFE_last_idx_CICP19[12] = { 0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 3 };
/*----------------------------------------------------------------------------------*
* LS Renderer ROM tables
diff --git a/lib_rend/ivas_rom_rend.h b/lib_rend/ivas_rom_rend.h
index cba0fffb1bfcb2e1f8e2a17a4a3f815f95e24d08..cb43c2a0ff516d247a96e029fc65de28662d2b41 100644
--- a/lib_rend/ivas_rom_rend.h
+++ b/lib_rend/ivas_rom_rend.h
@@ -45,7 +45,7 @@
* FASTCONV and PARAMETRIC binaural renderer ROM tables
*----------------------------------------------------------------------------------*/
-extern const float dmxmtx[BINAURAL_CHANNELS][11];
+extern const float dmxmtx_table[BINAURAL_CHANNELS][11];
extern const int16_t channelIndex_CICP6[5];
extern const int16_t channelIndex_CICP12[7];
@@ -53,15 +53,25 @@ extern const int16_t channelIndex_CICP14[7];
extern const int16_t channelIndex_CICP16[9];
extern const int16_t channelIndex_CICP19[11];
+/* These are equalization values for spread and surround coherent sounds, approximating the spectrum
+ * for such sounds at anechoic multichannel listening. */
+extern const float surCohEne[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS];
+extern const float spreadCohEne05[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS];
+extern const float spreadCohEne1[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS];
+
+/* Values for low-bit-rate equalization */
+extern const float lowBitRateBinauralEQ[LOW_BIT_RATE_BINAURAL_EQ_BINS];
+
+/* Diffuse field binaural coherence directional adjustment values */
+extern const float diffuseFieldCoherenceDifferenceX[BINAURAL_COHERENCE_DIFFERENCE_BINS];
+extern const float diffuseFieldCoherenceDifferenceY[BINAURAL_COHERENCE_DIFFERENCE_BINS];
+extern const float diffuseFieldCoherenceDifferenceZ[BINAURAL_COHERENCE_DIFFERENCE_BINS];
+
+
/*----------------------------------------------------------------------------------*
* TD ISM Object renderer
*----------------------------------------------------------------------------------*/
-extern const int16_t TDREND_SRC_REND_MaxTargetTimes[IVAS_NUM_SUPPORTED_FS];
-extern const int16_t TDREND_SRC_REND_MaxBlockLengths[IVAS_NUM_SUPPORTED_FS];
-extern const int16_t TDREND_MaxITD[IVAS_NUM_SUPPORTED_FS];
-extern const float TDREND_MaxITD_Incr[IVAS_NUM_SUPPORTED_FS];
-
extern const int16_t HRTF_MODEL_N_CPTS_VAR[HRTF_MODEL_N_SECTIONS];
extern const float SincTable[321];
@@ -96,16 +106,9 @@ extern const float ivas_reverb_default_DSR[];
* Renderer SBA & MC enc/dec matrices
*----------------------------------------------------------------------------------*/
-extern const float hoa_dec_mtx_CICP1[16];
extern const float ls_azimuth_CICP1[1];
extern const float ls_elevation_CICP1[1];
-extern const uint32_t ls_LFE_last_idx_CICP1[1];
-extern const uint32_t ls_LFE_last_idx_CICP2[2];
-extern const uint32_t ls_LFE_last_idx_CICP6[6];
-extern const uint32_t ls_LFE_last_idx_CICP12[8];
-extern const uint32_t ls_LFE_last_idx_CICP14[8];
-extern const uint32_t ls_LFE_last_idx_CICP16[10];
-extern const uint32_t ls_LFE_last_idx_CICP19[12];
+
/*----------------------------------------------------------------------------------*
* LS Configuration Converter ROM tables
@@ -114,26 +117,6 @@ extern const uint32_t ls_LFE_last_idx_CICP19[12];
/* Downmix matrices */
extern const float ls_conversion_cicpX_mono[12][1];
extern const float ls_conversion_cicpX_stereo[12][2];
-extern const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp6[];
-extern const LS_CONVERSION_MATRIX ls_conversion_cicp14_cicp6[];
-#ifdef FIX_I54_LS_CONVERSION
-extern const LS_CONVERSION_MATRIX ls_conversion_cicp14_cicp12[];
-#endif
-extern const LS_CONVERSION_MATRIX ls_conversion_cicp16_cicp6[];
-extern const LS_CONVERSION_MATRIX ls_conversion_cicp16_cicp14[];
-extern const LS_CONVERSION_MATRIX ls_conversion_cicp19_cicp6[];
-extern const LS_CONVERSION_MATRIX ls_conversion_cicp19_cicp12[];
-extern const LS_CONVERSION_MATRIX ls_conversion_cicp19_cicp14[];
-extern const LS_CONVERSION_MATRIX ls_conversion_cicp19_cicp16[];
-
-/* Upmix matrices */
-extern const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp14[];
-extern const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp16[];
-#ifdef FIX_I54_LS_CONVERSION
-extern const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp19[];
-#endif
-extern const LS_CONVERSION_MATRIX ls_conversion_cicp14_cicp19[];
-extern const LS_CONVERSION_MATRIX ls_conversion_cicp16_cicp19[];
/* Mapping table of input config : output config with corresponding matrix */
extern const LS_CONVERSION_MAPPING ls_conversion_mapping[];
diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c
index ff9eeebf2f97e66338e2ccd3bdeccdf7569accc9..2622d02308b0c9dd25bd7cd67b301f2b2b214626 100644
--- a/lib_rend/ivas_rotation.c
+++ b/lib_rend/ivas_rotation.c
@@ -36,51 +36,13 @@
#include
#include "cnst.h"
#include "prot.h"
-#include "ivas_prot.h"
-#include "ivas_cnst.h"
-#include "ivas_rom_com.h"
-#include "ivas_rom_dec.h"
+#include "ivas_prot_rend.h"
#ifdef DEBUGGING
#include "debug.h"
#endif
#include "wmc_auto.h"
-/*-----------------------------------------------------------------------*
- * ivas_headTrack_open()
- *
- * Allocate and initialize Head-Tracking handle
- *-----------------------------------------------------------------------*/
-
-ivas_error ivas_headTrack_open(
- HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* o : head track handle */
-)
-{
- int16_t i;
-
- /* Allocate Head-Tracking handle */
- if ( ( *hHeadTrackData = (HEAD_TRACK_DATA_HANDLE) malloc( sizeof( HEAD_TRACK_DATA ) ) ) == NULL )
- {
- return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for head-tracking memory\n" ) );
- }
-
- /* Initialization */
- ( *hHeadTrackData )->num_quaternions = 0;
- ( *hHeadTrackData )->lrSwitchInterpVal = 0.0f;
- ( *hHeadTrackData )->lrSwitchedCurrent = 0;
- ( *hHeadTrackData )->lrSwitchedNext = 0;
-
- /* Initialise Rmat_prev to I, Rmat will be computed later */
- for ( i = 0; i < 3; i++ )
- {
- set_zero( ( *hHeadTrackData )->Rmat_prev[i], 3 );
- ( *hHeadTrackData )->Rmat_prev[i][i] = 1.0f;
- }
-
- return IVAS_ERR_OK;
-}
-
-
/*----------------------------------------------------------------------------------
* QuatToRotMat()
*
@@ -232,51 +194,6 @@ void rotateAziEle(
}
-/*-------------------------------------------------------------------------
- * rotateAziEle_DirAC()
- *
- * Apply rotation to DirAC DOAs
- *------------------------------------------------------------------------*/
-
-void rotateAziEle_DirAC(
- int16_t *azi, /* i/o: array of azimuth values */
- int16_t *ele, /* i/o: array of elevation values */
- const int16_t band1, /* i : bands to work on (lower limit) */
- const int16_t band2, /* i : bands to work on (upper bound) */
- const float *p_Rmat /* i : pointer to real-space rotation matrix */
-)
-{
- int16_t b;
- float dv_0, dv_1, dv_2;
- float dv_r_0, dv_r_1, dv_r_2;
- float w;
-
- push_wmops( "rotateAziEle_DirAC" );
-
- for ( b = band1; b < band2; b++ )
- {
-
- /*Conversion spherical to cartesian coordinates*/
- w = cosf( ele[b] * PI_OVER_180 );
- dv_0 = w * cosf( azi[b] * PI_OVER_180 );
- dv_1 = w * sinf( azi[b] * PI_OVER_180 );
- dv_2 = sinf( ele[b] * PI_OVER_180 );
-
- dv_r_0 = p_Rmat[0] * dv_0 + p_Rmat[1] * dv_1 + p_Rmat[2] * dv_2;
- dv_r_1 = p_Rmat[3] * dv_0 + p_Rmat[4] * dv_1 + p_Rmat[5] * dv_2;
- dv_r_2 = p_Rmat[6] * dv_0 + p_Rmat[7] * dv_1 + p_Rmat[8] * dv_2;
-
- /*Conversion spherical to cartesian coordinates*/
- azi[b] = (int16_t) ( atan2f( dv_r_1, dv_r_0 ) * _180_OVER_PI );
- ele[b] = (int16_t) ( atan2f( dv_r_2, sqrtf( dv_r_0 * dv_r_0 + dv_r_1 * dv_r_1 ) ) * _180_OVER_PI );
- }
-
- pop_wmops();
-
- return;
-}
-
-
/*-------------------------------------------------------------------------
* rotateFrame_shd()
*
diff --git a/lib_rend/ivas_sba_rendering.c b/lib_rend/ivas_sba_rendering.c
index 316792951704e054099b2cea3edeb4fa70dd87c2..8fd10d83ba3b261a3874eed9065197fbca20ab3a 100644
--- a/lib_rend/ivas_sba_rendering.c
+++ b/lib_rend/ivas_sba_rendering.c
@@ -34,6 +34,7 @@
#include "options.h"
#include "prot.h"
#include "ivas_prot.h"
+#include "ivas_prot_rend.h"
#include "ivas_stat_dec.h"
#include "ivas_cnst.h"
#include
@@ -43,549 +44,6 @@
#include "wmc_auto.h"
-/*-----------------------------------------------------------------------*
- * Local function prototypes
- *-----------------------------------------------------------------------*/
-
-
-#ifdef DEBUG_MODE_DIRAC
-static void debug_mode_dirac( float output[MAX_OUTPUT_CHANNELS][L_FRAME48k], const int16_t nchan_transport, const int16_t output_frame );
-#endif
-
-
-/*-------------------------------------------------------------------------*
- * ivas_mc2sba()
- *
- * MC signals transformed into SBA in TD domain
- *-------------------------------------------------------------------------*/
-
-void ivas_mc2sba(
- IVAS_OUTPUT_SETUP hIntSetup, /* i : Format of decoder output */
- float buffer_td[][L_FRAME48k], /* i/o: MC signals (on input) and the HOA3 (on output) */
- const int16_t output_frame, /* i : output frame length per channel */
- const int16_t sba_order, /* i : Ambisonic (SBA) order */
- const float gain_lfe /* i : gain for LFE, 0 = ignore LFE */
-)
-{
- int16_t i, j, k;
- int16_t idx_lfe, idx_in;
- float buffer_tmp[16][L_FRAME48k];
- float gains[16];
- int16_t azimuth, elevation;
- int16_t sba_num_chans;
-
- assert( ( sba_order <= 3 ) && "Only order up to 3 is supported!" );
-
- /* Init*/
- sba_num_chans = ( sba_order + 1 ) * ( sba_order + 1 );
- for ( j = 0; j < sba_num_chans; j++ )
- {
- set_zero( buffer_tmp[j], output_frame );
- }
-
- /* HOA encoding*/
- idx_lfe = 0;
- idx_in = 0;
- for ( i = 0; i < hIntSetup.nchan_out_woLFE + hIntSetup.num_lfe; i++ )
- {
- if ( ( hIntSetup.num_lfe > 0 ) && ( i == hIntSetup.index_lfe[idx_lfe] ) )
- {
- if ( gain_lfe > 0.f )
- {
- /* Add LFE to omni W with gain*/
- for ( k = 0; k < output_frame; k++ )
- {
- buffer_tmp[0][k] += gain_lfe * buffer_td[i][k];
- }
- }
-
- if ( idx_lfe < ( hIntSetup.num_lfe - 1 ) )
- {
- idx_lfe++;
- }
- }
- else
- {
- azimuth = (int16_t) ( hIntSetup.ls_azimuth[idx_in] );
- elevation = (int16_t) ( hIntSetup.ls_elevation[idx_in] );
- idx_in++;
-
- /* get HOA response for direction (ACN/SN3D)*/
- ivas_dirac_dec_get_response(
- azimuth,
- elevation,
- gains,
- sba_order );
-
- for ( j = 0; j < sba_num_chans; j++ )
- {
- for ( k = 0; k < output_frame; k++ )
- {
- buffer_tmp[j][k] += gains[j] * buffer_td[i][k];
- }
- }
- }
- }
-
- for ( j = 0; j < sba_num_chans; j++ )
- {
- mvr2r( buffer_tmp[j], buffer_td[j], output_frame );
- }
-
- return;
-}
-
-
-/*-------------------------------------------------------------------------*
- * ivas_sba2MC_cldfb()
- *
- * SBA signals transformed into MC in CLDFB domain
- *-------------------------------------------------------------------------*/
-
-void ivas_sba2mc_cldfb(
- IVAS_OUTPUT_SETUP hInSetup, /* i : Format of input layout */
- float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: cldfb real part */
- float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: cldfb imag part */
- const int16_t nb_channels_out, /* i : nb of output channels */
- const int16_t nb_bands, /* i : nb of CLDFB bands to process */
- const float *hoa_dec_mtx /* i : HOA decoding mtx */
-)
-{
- int16_t iBlock, iBand, n, m;
- float realOut[16][MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX], imagOut[16][MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX];
- float g;
- float *p_real, *p_imag, *p_realOut, *p_imagOut;
- int16_t nb_channels_in;
-
- push_wmops( "ivas_sba2mc_cldfb" );
-
- nb_channels_in = hInSetup.nchan_out_woLFE;
- assert( ( nb_channels_in == 16 ) && ( nb_channels_out == 11 ) && "ivas_sba2mc_cldfb; only HOA3 to CICP19 is for now supported!" );
-
- for ( n = 0; n < nb_channels_out; n++ )
- {
- set_zero( realOut[n], MAX_PARAM_SPATIAL_SUBFRAMES * nb_bands );
- set_zero( imagOut[n], MAX_PARAM_SPATIAL_SUBFRAMES * nb_bands );
-
- for ( m = 0; m < nb_channels_in; m++ )
- {
- g = hoa_dec_mtx[SBA_NHARM_HOA3 * n + m];
- p_realOut = realOut[n];
- p_imagOut = imagOut[n];
- for ( iBlock = 0; iBlock < MAX_PARAM_SPATIAL_SUBFRAMES; iBlock++ )
- {
- p_real = RealBuffer[m][iBlock];
- p_imag = ImagBuffer[m][iBlock];
- for ( iBand = 0; iBand < nb_bands; iBand++ )
- {
- *p_realOut = *p_realOut + g * *( p_real++ );
- *p_imagOut = *p_imagOut + g * *( p_imag++ );
- p_realOut++;
- p_imagOut++;
- }
- }
- }
- }
-
- for ( n = 0; n < nb_channels_out; n++ )
- {
- p_realOut = realOut[n];
- p_imagOut = imagOut[n];
- for ( iBlock = 0; iBlock < MAX_PARAM_SPATIAL_SUBFRAMES; iBlock++ )
- {
- p_real = RealBuffer[n][iBlock];
- p_imag = ImagBuffer[n][iBlock];
- for ( iBand = 0; iBand < nb_bands; iBand++ )
- {
- *( p_real++ ) = *p_realOut++;
- *( p_imag++ ) = *p_imagOut++;
- }
- }
- }
-
- pop_wmops();
-
- return;
-}
-
-/*-------------------------------------------------------------------*
- * ivas_sba_remapTCs()
- *
- * Get TCs from Ambisonics signal in ACN
- *-------------------------------------------------------------------*/
-
-int16_t ivas_sba_remapTCs(
- float sba_data[][L_FRAME48k], /* i/o: SBA signals */
- Decoder_Struct *st_ivas, /* i/o: decoder struct */
- const int16_t output_frame /* i : frame length */
-)
-{
- int16_t nchan_remapped;
-
-#ifdef DEBUG_MODE_DIRAC
- debug_mode_dirac( sba_data, st_ivas->nchan_transport, output_frame );
-#endif
-
- nchan_remapped = st_ivas->nchan_transport;
- if ( ( st_ivas->sba_mode != SBA_MODE_SPAR && st_ivas->sba_planar && nchan_remapped >= 3 ) ||
- ( ( st_ivas->sba_mode == SBA_MODE_SPAR ) && nchan_remapped == 3 ) )
- {
-
- nchan_remapped++;
- if ( st_ivas->sba_mode != SBA_MODE_SPAR )
- {
- assert( ( ( st_ivas->nchan_transport == 3 ) || ( st_ivas->nchan_transport == 5 ) || ( st_ivas->nchan_transport == 7 ) ) && "Number of channels must be odd for SBA planar!" );
- }
-
- if ( nchan_remapped == 4 )
- {
- /*For planar A-format channel 2 and 3 are identical -> Z=0*/
- mvr2r( sba_data[2], sba_data[3], output_frame );
- }
- }
-
- if ( st_ivas->nchan_transport >= 3 )
- {
- int16_t i = 0;
- float temp;
-
- /*convert WYXZ downmix to WYZX*/
- for ( i = 0; i < output_frame; i++ )
- {
- temp = sba_data[2][i];
- sba_data[2][i] = sba_data[3][i];
- sba_data[3][i] = temp;
- if ( st_ivas->nchan_transport == 3 )
- {
- sba_data[2][i] = 0;
- }
- }
- }
-
- if ( st_ivas->sba_mode != SBA_MODE_SPAR )
- {
- ivas_sba_zero_vert_comp( sba_data, st_ivas->sba_analysis_order, st_ivas->sba_planar, output_frame );
- }
-
- return ( nchan_remapped );
-}
-
-
-/*-------------------------------------------------------------------------*
- * ivas_ism2sba()
- *
- * ISM transformed into SBA in TD domain.
- *-------------------------------------------------------------------------*/
-
-void ivas_ism2sba(
- float buffer_td[][L_FRAME48k], /* i/o: TD signal buffers */
- ISM_RENDERER_HANDLE hIsmRendererData, /* i/o: renderer data */
- const ISM_METADATA_HANDLE hIsmMetaData[], /* i : object metadata */
- const int16_t num_objects, /* i : number of objects */
- const int16_t output_frame, /* i : output frame length per channel */
- const int16_t sba_order /* i : Ambisonic (SBA) order */
-)
-{
- int16_t i, j, k;
- float buffer_tmp[16][L_FRAME48k];
- float gains[16];
- float g1, g2;
- int16_t azimuth, elevation;
- int16_t sba_num_chans;
-
- assert( ( sba_order <= 3 ) && "Only order up to 3 is supported!" );
- assert( hIsmRendererData != NULL && "hIsmRendererData not allocated!" );
-
- /* Init*/
- sba_num_chans = ( sba_order + 1 ) * ( sba_order + 1 );
- for ( j = 0; j < sba_num_chans; j++ )
- {
- set_zero( buffer_tmp[j], output_frame );
- }
-
- for ( i = 0; i < num_objects; i++ )
- {
- // TODO tmu review when #215 is resolved
- azimuth = (int16_t) floorf( hIsmMetaData[i]->azimuth + 0.5f );
- elevation = (int16_t) floorf( hIsmMetaData[i]->elevation + 0.5f );
-
- /*get HOA gets for direction (ACN/SN3D)*/
- ivas_dirac_dec_get_response( azimuth, elevation, gains, sba_order );
-
- for ( j = 0; j < sba_num_chans; j++ )
- {
- g1 = 1.f;
- g2 = 0.f;
- for ( k = 0; k < output_frame; k++ )
- {
- buffer_tmp[j][k] += ( g2 * gains[j] + g1 * hIsmRendererData->prev_gains[i][j] ) * buffer_td[i][k];
- g2 += 1.f / ( output_frame - 1 );
- g1 = 1.0f - g2;
- }
- hIsmRendererData->prev_gains[i][j] = gains[j];
- }
- }
-
- for ( j = 0; j < sba_num_chans; j++ )
- {
- mvr2r( buffer_tmp[j], buffer_td[j], output_frame );
- }
-
- return;
-}
-
-
-/*-------------------------------------------------------------------*
- * ivas_sba_linear_renderer()
- *
- * Linear rendering for SBA format
- *-------------------------------------------------------------------*/
-
-ivas_error ivas_sba_linear_renderer(
- float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */
- const int16_t output_frame, /* i : output frame length per channel */
- const int16_t nchan_in, /* i : number of input ambisonics channels */
- const AUDIO_CONFIG output_config, /* i : output audio configuration */
- const IVAS_OUTPUT_SETUP output_setup, /* i : output format setup */
- const float hoa_dec_mtx[] /* i : HOA decoding mtx */
-)
-{
- int16_t i;
- float dmx_l;
- int16_t nchan_hoa;
- ivas_error error;
-
- error = IVAS_ERR_OK;
-
- /* Number of channels of HOA depends of transport format which is mixed order xH1V*/
- nchan_hoa = nchan_in;
-
- if ( nchan_in == 6 ) /*2H1V*/
- {
- nchan_hoa = 9;
- }
- else if ( nchan_in == 8 ) /*3H1V*/
- {
- nchan_hoa = 16;
- }
-
- switch ( output_config )
- {
- case AUDIO_CONFIG_MONO:
- /* If stereo DMX, MONO = W = Cardioids L + R*/
- if ( nchan_in == 2 )
- {
- for ( i = 0; i < output_frame; i++ )
- {
- output_f[0][i] += output_f[1][i];
- }
- }
- /* else: do nothing, MONO = W*/
- break;
- case AUDIO_CONFIG_STEREO:
- assert( ( nchan_in >= 2 ) && "Number of input channels must be at least 2 (for W and Y)!\n" );
-
- /* Compute L and R cardioids from SB format except if stereo DMX is transmitted already in this format*/
- if ( nchan_in > 2 )
- {
- /*Build L/R cardioids*/
- for ( i = 0; i < output_frame; i++ )
- {
- dmx_l = 0.5f * ( output_f[0][i] + output_f[1][i] ); /* cardioid_left = 0.5(W + Y) */
- output_f[1][i] = 0.5f * ( output_f[0][i] - output_f[1][i] ); /* cardioid_right = 0.5(W - Y) */
- output_f[0][i] = dmx_l;
- }
- }
- break;
- case AUDIO_CONFIG_5_1:
- case AUDIO_CONFIG_7_1:
- case AUDIO_CONFIG_5_1_2:
- case AUDIO_CONFIG_5_1_4:
- case AUDIO_CONFIG_7_1_4:
- case AUDIO_CONFIG_LS_CUSTOM:
- ivas_sba_mtx_mult( output_f, output_frame, nchan_hoa, output_setup, hoa_dec_mtx );
- break;
- case AUDIO_CONFIG_FOA: /* Ambisonics output, order: 1 */
- case AUDIO_CONFIG_HOA2: /* Ambisonics output, order: 2 */
- case AUDIO_CONFIG_HOA3: /* Ambisonics output, order: 3 */
- for ( i = nchan_hoa; i < output_setup.nchan_out_woLFE; i++ )
- {
- set_zero( output_f[i], output_frame );
- }
- break;
- default:
- return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: illegal output configuration, Exiting.\n" );
- }
-
- return error;
-}
-
-
-/*-------------------------------------------------------------------*
- * ivas_sba_mtx_mult()
- *
- * HOA decoding with LFE insertion
- *-------------------------------------------------------------------*/
-
-void ivas_sba_mtx_mult(
- float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */
- const int16_t output_frame, /* i : output frame length per channel */
- const int16_t nchan_in, /* i : Number of ambisonic channels */
- const IVAS_OUTPUT_SETUP output_setup, /* i : Output configuration */
- const float *mtx_hoa_decoder /* i : HOA decoding mtx */
-)
-{
- int16_t i, k, ch_idx;
- int16_t idx_lfe;
- float input_f[16];
- const float *hoa_decoder;
-
- assert( ( nchan_in >= FOA_CHANNELS ) && "Number of input channels must be at least 4 (FOA)!\n" );
-
- for ( i = 0; i < output_frame; i++ )
- {
- /* init*/
- idx_lfe = 0;
- hoa_decoder = &mtx_hoa_decoder[0];
- for ( k = 0; k < nchan_in; k++ )
- {
- input_f[k] = output_f[k][i];
- }
-
- /* mtx mult with LFE insertion*/
- for ( ch_idx = 0; ch_idx < ( output_setup.nchan_out_woLFE + output_setup.num_lfe ); ch_idx++ )
- {
- if ( ( output_setup.num_lfe > 0 ) && ( output_setup.index_lfe[idx_lfe] == ch_idx ) )
- {
- /*LFE insertion*/
- output_f[ch_idx][i] = 0.f;
- if ( idx_lfe < ( output_setup.num_lfe - 1 ) )
- {
- idx_lfe++;
- }
- }
- else
- {
- /*HOA decoding*/
- output_f[ch_idx][i] = input_f[0] * hoa_decoder[0];
- for ( k = 1; k < nchan_in; k++ )
- {
- output_f[ch_idx][i] += input_f[k] * hoa_decoder[k];
- }
- hoa_decoder += 16;
- }
- }
- }
-
- return;
-}
-
-
-/*-------------------------------------------------------------------*
- * ivas_sba_upmixer_renderer()
- *
- * SBA upmix & rendering
- *-------------------------------------------------------------------*/
-
-void ivas_sba_upmixer_renderer(
- Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */
- float output[][L_FRAME48k], /* i/o: transport/output audio channels */
- const int16_t output_frame /* i : output frame length */
-)
-{
- int16_t i, nchan_internal;
- float temp;
-
- push_wmops( "ivas_sba_upmixer_renderer" );
-
- nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order );
-
- if ( st_ivas->nchan_transport >= 3 )
- {
- /*convert WYZX downmix to WYXZ*/
- for ( i = 0; i < output_frame; i++ )
- {
- temp = output[2][i];
- output[2][i] = output[3][i];
- output[3][i] = temp;
- }
- }
-
- /* Upmixer + Renderer */
- ivas_spar_dec_upmixer( st_ivas, output, nchan_internal, output_frame );
-
- if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC )
- {
- ivas_sba_linear_renderer( output, output_frame, st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx );
- }
-
- pop_wmops();
-
- return;
-}
-
-
-/*-------------------------------------------------------------------*
- * ivas_sba_mix_matrix_determiner()
- *
- * Determine SBA mixing matrices
- *-------------------------------------------------------------------*/
-
-void ivas_sba_mix_matrix_determiner(
- SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */
- float output[][L_FRAME48k], /* i/o: transport/output audio channels */
- const int16_t bfi, /* i : BFI flag */
- const int16_t nchan_remapped, /* i : num channels after remapping of TCs */
- const int16_t output_frame /* i : output frame length */
-)
-{
- int16_t i, ch;
- float temp;
- int16_t num_bands_out, nchan_transport, nchan_out;
-
- /* Convert numeric range */
- for ( ch = 0; ch < nchan_remapped; ch++ )
- {
- for ( i = 0; i < output_frame; i++ )
- {
- temp = output[ch][i];
- temp = floorf( temp + 0.5f );
-
- if ( temp > MAX16B_FLT )
- {
- temp = MAX16B_FLT;
- }
- else if ( temp < ( -1.0f * PCM16_TO_FLT_FAC ) )
- {
- temp = ( -1.0f * PCM16_TO_FLT_FAC );
- }
- temp *= ( 1.0f / PCM16_TO_FLT_FAC );
- output[ch][i] = temp;
- }
- }
-
- /* AGC */
- nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport;
- nchan_out = nchan_transport;
- ivas_agc_dec_process( hSpar->hAgcDec, output, output, nchan_transport, output_frame );
-
- /* Convert numeric range back */
- for ( ch = 0; ch < nchan_out; ch++ )
- {
- for ( i = 0; i < output_frame; i++ )
- {
- output[ch][i] = output[ch][i] * PCM16_TO_FLT_FAC;
- }
- }
-
- /* Mixing matrix determiner */
- num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands;
- ivas_spar_dec_gen_umx_mat( hSpar->hMdDec, nchan_transport, num_bands_out, bfi );
-
- return;
-}
-
-
/*-------------------------------------------------------------------*
* ivas_sba_prototype_renderer()
*
@@ -744,44 +202,3 @@ void ivas_sba_prototype_renderer(
return;
}
-
-#ifdef DEBUG_MODE_DIRAC
-/*-----------------------------------------------------------------------*
- * Debugging function
- *-----------------------------------------------------------------------*/
-
-static void debug_mode_dirac(
- float output[MAX_OUTPUT_CHANNELS][L_FRAME48k],
- const int16_t nchan_transport,
- const int16_t output_frame )
-{
- int16_t i, n;
- int16_t tmp[L_FRAME48k];
- char file_name[50] = { 0 };
-
-#ifdef DEBUG_MODE_DIRAC_NOCORE
- for ( n = 0; n < nchan_transport; n++ )
- {
- sprintf( file_name, "./res/ivas_dirac_enc_%d.%d.pcm", n, (int16_t) ( output_frame * 0.05 ) );
- dbgread( tmp, sizeof( int16_t ), output_frame, file_name );
- for ( i = 0; i < output_frame; i++ )
- {
- output[n][i] = (float) ( tmp[i] );
- }
- }
-#else
- for ( n = 0; n < nchan_transport; n++ )
- {
- for ( i = 0; i < output_frame; i++ )
- {
- tmp[i] = (int16_t) ( output[n][i] + 0.5f );
- }
-
- sprintf( file_name, "./res/ivas_dirac_dec_%d.%d.pcm", n, (int16_t) ( output_frame * 0.05 ) );
- dbgwrite( tmp, sizeof( int16_t ), output_frame, 1, file_name );
- }
-#endif
-
- return;
-}
-#endif
diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h
index e57044930ec037e3743140f736e76639a17e67d5..586a43c4f8af75aad98de0c9f472aeb39ec2ced4 100644
--- a/lib_rend/ivas_stat_rend.h
+++ b/lib_rend/ivas_stat_rend.h
@@ -34,122 +34,40 @@
#define IVAS_STAT_REND_H
#include
-#ifdef FIX_197_CREND_INTERFACE
-#include "cnst.h"
+#include "options.h"
#include "ivas_cnst.h"
-#include "ivas_stat_com.h"
-#include "common_api_types.h" // VE2AT: don't we want to avoid this include in the library? I admit that the rules hefre are not 100% clear to me but introducing it just for IVAS_QUATERNION is not necessry I think
-#endif
-
-#define MAX_SPEAKERS 12 /* Max number of speakers (including LFE) in a channel-based config */
-
-
-#ifdef FIX_197_CREND_INTERFACE
-
-#define RENDERER_HEAD_POSITIONS_PER_FRAME 4 // todo (Marc) -> renanr IVAS_RENDERER_HEAD_POSITIONS_PER_FRAME ?
-
-typedef float IVAS_REND_LfePanMtx[IVAS_MAX_INPUT_LFE_CHANNELS][IVAS_MAX_OUTPUT_CHANNELS];
-typedef struct
-{
- int16_t numSamplesPerChannel;
- int16_t numChannels;
-} IVAS_REND_AudioBufferConfig;
-
-typedef struct
-{
- IVAS_REND_AudioBufferConfig config;
- float *data;
-} IVAS_REND_AudioBuffer;
-
-typedef struct
-{
- IVAS_REND_AudioBufferConfig config;
- const float *data;
-} IVAS_REND_ReadOnlyAudioBuffer;
+#include "ivas_stat_com.h" // note: needed for DIRAC_DEC_BIN_HANDLE until #156 is solved
+#include "common_api_types.h"
-typedef struct
-{
- float azimuth;
- float elevation;
-} IVAS_REND_AudioObjectPosition;
-typedef struct IVAS_REND *IVAS_REND_HANDLE;
-typedef struct IVAS_REND const *IVAS_REND_CONST_HANDLE;
+/*----------------------------------------------------------------------------------*
+ * Output configuration for renderer (e.g. DirAC, MASA, Binaural Renderer...)
+ *----------------------------------------------------------------------------------*/
-typedef enum
-{
- IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED = 0,
- IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS,
- IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED,
- IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL,
- IVAS_REND_AUDIO_CONFIG_TYPE_MASA,
- IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN,
-} IVAS_REND_AudioConfigType;
-
-/* TODO(sgi): Harmonize with AUDIO_CONFIG */
-/*
- Note: numerical values carry specific information here.
-
- MSB LSB
- --------------------------------------------------------------------------------
- ... unused (assumed all 0) ... | config type (1 byte) | config variant (1 byte) |
- --------------------------------------------------------------------------------
-
- Where "config type" is the general type from the following list:
- - unknown
- - channel-based
- - ambisonics
- - object-based
- - binaural
- - MASA
-
- Config variants are concrete configs of each type.
- */
-typedef enum
+typedef struct ivas_output_setup_structure
{
- IVAS_REND_AUDIO_CONFIG_MONO = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED << 8 | 0,
- IVAS_REND_AUDIO_CONFIG_STEREO = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED << 8 | 1,
- IVAS_REND_AUDIO_CONFIG_5_1 = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED << 8 | 2,
- IVAS_REND_AUDIO_CONFIG_7_1 = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED << 8 | 3,
- IVAS_REND_AUDIO_CONFIG_5_1_2 = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED << 8 | 4,
- IVAS_REND_AUDIO_CONFIG_5_1_4 = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED << 8 | 5,
- IVAS_REND_AUDIO_CONFIG_7_1_4 = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED << 8 | 6,
- IVAS_REND_AUDIO_CONFIG_LS_CUSTOM = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED << 8 | 255,
-
- IVAS_REND_AUDIO_CONFIG_FOA = IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS << 8 | 0,
- IVAS_REND_AUDIO_CONFIG_HOA2 = IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS << 8 | 1,
- IVAS_REND_AUDIO_CONFIG_HOA3 = IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS << 8 | 2,
-
- IVAS_REND_AUDIO_CONFIG_OBJECT = IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED << 8 | 0,
-
- IVAS_REND_AUDIO_CONFIG_BINAURAL = IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL << 8 | 0,
- IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM = IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL << 8 | 1,
-
- IVAS_REND_AUDIO_CONFIG_MASA1 = IVAS_REND_AUDIO_CONFIG_TYPE_MASA << 8 | 0,
- IVAS_REND_AUDIO_CONFIG_MASA2 = IVAS_REND_AUDIO_CONFIG_TYPE_MASA << 8 | 1,
+ AUDIO_CONFIG output_config;
+ int16_t nchan_out_woLFE; /* number of output audio channels without LFE */
+ int16_t ambisonics_order;
+ int8_t is_loudspeaker_setup;
+ int8_t is_planar_setup;
+ int8_t is_binaural_setup;
- IVAS_REND_AUDIO_CONFIG_UNKNOWN = IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN << 8 | 0,
-} IVAS_REND_AudioConfig;
+ int16_t num_lfe;
+ int16_t index_lfe[1];
+ const float *ls_azimuth;
+ const float *ls_elevation;
-typedef uint16_t IVAS_REND_InputId;
+ uint8_t separateChannelEnabled;
+ int16_t separateChannelIndex;
-typedef struct
-{
- int16_t numLfeChannels;
- float lfeOutputGains[IVAS_MAX_INPUT_LFE_CHANNELS][IVAS_MAX_OUTPUT_CHANNELS];
-} IVAS_REND_LfeRouting;
+} IVAS_OUTPUT_SETUP, *IVAS_OUTPUT_SETUP_HANDLE;
-typedef struct
-{
- int8_t headRotEnabled;
- IVAS_QUATERNION headPositions[RENDERER_HEAD_POSITIONS_PER_FRAME];
- float crossfade[L_FRAME48k / RENDERER_HEAD_POSITIONS_PER_FRAME];
-} IVAS_REND_HeadRotData;
/*----------------------------------------------------------------------------------*
- * Binaural Rendering structure
+ * Binaural FastConv Rendering structure
*----------------------------------------------------------------------------------*/
-// VE2AT: move to ivas_rom_rend.h ?
+
/* Binaural reverberator structure */
typedef struct ivas_binaural_reverb_struct
{
@@ -188,44 +106,6 @@ typedef struct ivas_binaural_reverb_struct
} REVERB_STRUCT, *REVERB_STRUCT_HANDLE;
-/* AGC structure */
-typedef struct ivas_agc_dec_chan_state_t
-{
- float lastGain;
- int16_t gainExpVal;
-
-} ivas_agc_dec_chan_state_t;
-
-typedef struct ivas_agc_dec_state_t
-{
- ivas_agc_com_state_t agc_com;
- ivas_agc_dec_chan_state_t *gain_state;
- ivas_agc_chan_data_t *gain_data;
-
-} ivas_agc_dec_state_t;
-
-/* TD decorr */
-typedef struct ivas_td_decorr_APD_filt_state_t
-{
- int16_t order[IVAS_MAX_DECORR_APD_SECTIONS];
- int16_t idx[IVAS_MAX_DECORR_APD_SECTIONS];
- float coeffs[IVAS_MAX_DECORR_APD_SECTIONS];
- float *state[IVAS_MAX_DECORR_APD_SECTIONS];
-
-} ivas_td_decorr_APD_filt_state_t;
-
-typedef struct ivas_td_decorr_state_t
-{
- ivas_trans_det_state_t *pTrans_det;
- float *look_ahead_buf;
- ivas_td_decorr_APD_filt_state_t APD_filt_state[IVAS_MAX_DECORR_CHS];
-
- int16_t num_apd_outputs;
- int16_t num_apd_sections;
- int16_t ducking_flag;
-
-} ivas_td_decorr_state_t;
-
/* Parametric binaural data structure */
typedef struct ivas_dirac_dec_binaural_data_structure
{
@@ -278,32 +158,11 @@ typedef struct ivas_binaural_rendering_conv_module_struct
} BINRENDERER_CONV_MODULE, *BINRENDERER_CONV_MODULE_HANDLE;
-/*----------------------------------------------------------------------------------*
- * Output configuration for renderer (e.g. DirAC, MASA, Binaural Renderer...)
- *----------------------------------------------------------------------------------*/
-typedef struct ivas_output_setup_structure
-{
- AUDIO_CONFIG output_config;
- int16_t nchan_out_woLFE; /* number of output audio channels without LFE */
- int16_t ambisonics_order;
- int8_t is_loudspeaker_setup;
- int8_t is_planar_setup;
- int8_t is_binaural_setup;
-
- int16_t num_lfe;
- int16_t index_lfe[1];
- const float *ls_azimuth;
- const float *ls_elevation;
-
- uint8_t separateChannelEnabled;
- int16_t separateChannelIndex;
-
-} IVAS_OUTPUT_SETUP, *IVAS_OUTPUT_SETUP_HANDLE;
/*----------------------------------------------------------------------------------*
* EFAP structures
*----------------------------------------------------------------------------------*/
-// VE2AT: move to ivas_rom_rend.h ?
+
typedef struct EFAP_VERTEX
{
float azi; /* azimuth of the loudspeaker */
@@ -364,121 +223,68 @@ typedef struct EFAP
/*----------------------------------------------------------------------------------*
- * VBAP structures
+ * Head rotation data structure
*----------------------------------------------------------------------------------*/
-// VE2AT: move to ivas_rom_rend.h ?
-enum SpeakerNodeGroup
-{
- SPEAKER_NODE_BOTTOM_HALF,
- SPEAKER_NODE_HORIZONTAL,
- SPEAKER_NODE_TOP_HALF,
- SPEAKER_NODE_BACK,
- SPEAKER_NODE_ALL
-};
-
-/* Defines a single virtual surface triplet of loudspeakers
- * with a precalculated inverse matrix */
-typedef struct vbap_vs_triplet_structure
-{
- uint8_t speaker_node[3];
- float inverse_matrix[3][3];
-} VBAP_VS_TRIPLET;
-
-/* Defines a single speaker node */
-typedef struct vbap_speaker_node_structure
+typedef struct
{
- float azi_deg;
- float ele_deg;
- float unit_vec[3];
- enum SpeakerNodeGroup group;
+ int8_t headRotEnabled;
+ IVAS_QUATERNION headPositions[RENDERER_HEAD_POSITIONS_PER_FRAME];
+ float crossfade[L_FRAME48k / RENDERER_HEAD_POSITIONS_PER_FRAME];
-} VBAP_SPEAKER_NODE;
+} IVAS_REND_HeadRotData;
-/* Storage structure for fast runtime triplet search */
-typedef struct triplet_search_structure
+typedef struct ivas_binaural_head_track_struct
{
- VBAP_VS_TRIPLET *triplets;
- int16_t num_triplets;
- int16_t initial_search_indices[VBAP_NUM_SEARCH_SECTORS];
+ int16_t num_quaternions;
+ IVAS_QUATERNION Quaternions[MAX_PARAM_SPATIAL_SUBFRAMES];
+ float Rmat[3][3];
+ float Rmat_prev[3][3];
-} VBAP_SEARCH_STRUCT;
+ uint8_t lrSwitchedNext;
+ uint8_t lrSwitchedCurrent;
+ float lrSwitchInterpVal;
-/* VBAP data structure. Contains the formed virtual surface arrangement * and supporting data. */
-typedef struct vbap_data_structure
-{
- VBAP_SEARCH_STRUCT search_struct[2]; /* Default to max two groups in this implementation */
- int16_t num_search_structs;
- int16_t num_speaker_nodes;
- int16_t num_speaker_nodes_internal;
- int16_t top_virtual_speaker_node_index; /* These indices can be negative */
- int16_t bottom_virtual_speaker_node_index;
- int16_t back_virtual_speaker_node_index;
- float *bottom_virtual_speaker_node_division_gains;
- float *top_virtual_speaker_node_division_gains;
- float *back_virtual_speaker_node_division_gains;
+ int16_t shd_rot_max_order;
-} VBAP_DATA, *VBAP_HANDLE;
+} HEAD_TRACK_DATA, *HEAD_TRACK_DATA_HANDLE;
/*----------------------------------------------------------------------------------*
- * renderer structures
+ * Orientation tracking structure
*----------------------------------------------------------------------------------*/
-// VE2AT: move to ivas_rom_rend.h ?
-typedef struct renderer_struct
-{
- float prev_gains[MAX_CICP_CHANNELS - 1][MAX_OUTPUT_CHANNELS];
- float interpolator[L_FRAME48k];
-
-} ISM_RENDERER_DATA, *ISM_RENDERER_HANDLE;
-/* Fastconv binaural data structure */
-typedef struct ivas_binaural_rendering_struct
+typedef struct ivas_orient_trk_state_t
{
- /* Common variables for all modules */
- IVAS_OUTPUT_SETUP_HANDLE hInputSetup; /* pointer to input spatial format for binaural renderer*/
- EFAP_HANDLE hEFAPdata; /* EFAP structure*/
- float *hoa_dec_mtx; /* pointer to HOA decoder mtx */
- int8_t rotInCldfb; /* Flag to enable rotation within bin Renderer in CLDFB*/
- int16_t max_band; /* band upto which rendering is performed */
- int16_t conv_band; /* band upto which convolution in cldfb domain is performed */
- int16_t timeSlots; /* number of time slots of binaural renderer */
- int16_t nInChannels; /* number input channels */
- int8_t render_lfe; /* Flag to render LFE in binaural rendering*/
- IVAS_FORMAT ivas_format; /* format; corresponds to st_ivas->ivas_format, unless the signal gets transormed to a different domain for rendering */
-
- /* Convolution module structure */
- BINRENDERER_CONV_MODULE_HANDLE hBinRenConvModule;
-
- /* Variables related to reverb module */
- float earlyPartEneCorrection[CLDFB_NO_CHANNELS_MAX];
- REVERB_STRUCT_HANDLE hReverb;
-
-} BINAURAL_RENDERER, *BINAURAL_RENDERER_HANDLE;
+ OTR_TRACKING_T trackingType;
+ float centerAdaptationRate;
+ float offCenterAdaptationRate;
+ float adaptationAngle;
+ float alpha;
-/*----------------------------------------------------------------------------------*
- * Head tracking data structure
- *----------------------------------------------------------------------------------*/
-// VE2AT: move to ivas_rom_rend.h ?
+ float absYaw; /* absolute orientation */
+ float absPitch;
+ float absRoll;
-typedef struct ivas_binaural_head_track_struct
-{
- int16_t num_quaternions;
- IVAS_QUATERNION Quaternions[MAX_PARAM_SPATIAL_SUBFRAMES];
- float Rmat[3][3];
- float Rmat_prev[3][3];
+ float absAvgYaw; /* average absolute orientation */
+ float absAvgPitch;
+ float absAvgRoll;
- uint8_t lrSwitchedNext;
- uint8_t lrSwitchedCurrent;
- float lrSwitchInterpVal;
+ float refYaw; /* reference orientation */
+ float refPitch;
+ float refRoll;
- int16_t shd_rot_max_order;
+ float trkYaw; /* tracked orientation */
+ float trkPitch;
+ float trkRoll;
-} HEAD_TRACK_DATA, *HEAD_TRACK_DATA_HANDLE;
+} ivas_orient_trk_state_t;
-/* Reverberator structures */
+/*----------------------------------------------------------------------------------*
+ * Reverberator structure
+ *----------------------------------------------------------------------------------*/
typedef struct ivas_roomAcoustics_t
{
@@ -503,7 +309,6 @@ typedef struct ivas_render_config_t
} RENDER_CONFIG_DATA, *RENDER_CONFIG_HANDLE;
-
typedef struct ivas_rev_delay_line_t
{
float *pBuffer;
@@ -549,7 +354,6 @@ typedef struct ivas_reverb_fft_filter_t
} ivas_reverb_fft_filter_t;
-
typedef struct ivas_reverb_state_t
{
RENDER_CONFIG_DATA pConfig;
@@ -584,39 +388,10 @@ typedef struct ivas_reverb_state_t
} REVERB_DATA, *REVERB_HANDLE;
-typedef struct ivas_orient_trk_state_t
-{
- OTR_TRACKING_T trackingType;
- float centerAdaptationRate;
- float offCenterAdaptationRate;
- float adaptationAngle;
-
- float alpha;
-
- float absYaw; /* absolute orientation */
- float absPitch;
- float absRoll;
-
- float absAvgYaw; /* average absolute orientation */
- float absAvgPitch;
- float absAvgRoll;
-
- float refYaw; /* reference orientation */
- float refPitch;
- float refRoll;
-
- float trkYaw; /* tracked orientation */
- float trkPitch;
- float trkRoll;
-
-} ivas_orient_trk_state_t;
-
-
/*----------------------------------------------------------------------------------*
* TD ISm Object Renderer structure
*----------------------------------------------------------------------------------*/
-
typedef struct
{
int16_t modelROM; /* Flag that indicates that the model resides in ROM (controls init/dealloc). */
@@ -762,7 +537,6 @@ typedef struct TDREND_HRFILT_FiltSet_struct
} TDREND_HRFILT_FiltSet_t;
-
/* Distance attenuation */
typedef struct
{
@@ -790,7 +564,6 @@ typedef struct
} TDREND_MixSpatSpec_t;
-
typedef struct TDREND_SRC_REND_s
{
int16_t InputAvailable;
@@ -858,10 +631,19 @@ typedef struct ivas_binaural_td_rendering_struct
} BINAURAL_TD_OBJECT_RENDERER, *BINAURAL_TD_OBJECT_RENDERER_HANDLE;
+typedef struct
+{
+ int32_t binaural_latency_ns;
+ BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd;
+ TDREND_HRFILT_FiltSet_t *hHrtfTD;
+
+} TDREND_WRAPPER, *TDREND_WRAPPER_HANDLE;
+
+
/*------------------------------------------------------------------------------------------*
* Crend structures
*------------------------------------------------------------------------------------------*/
-// VE2AT: move to ivas_rom_rend.h ?
+
typedef struct ivas_hrtfs_structure
{
float *pOut_to_bin_re[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS];
@@ -907,10 +689,13 @@ typedef struct ivas_binaural_crend_wrapper_struct
int32_t binaural_latency_ns;
CREND_HANDLE hCrend;
HRTFS_HANDLE hHrtfCrend;
+
} CREND_WRAPPER, *CREND_WRAPPER_HANDLE;
-/* htrfs from binary files. */
+/*------------------------------------------------------------------------------------------*
+ * HRTF structures - htrfs from binary files
+ *------------------------------------------------------------------------------------------*/
typedef struct ivas_hrtfs_crend_structure
{
@@ -920,24 +705,8 @@ typedef struct ivas_hrtfs_crend_structure
} HRTFS_CREND, *HRTFS_CREND_HANDLE;
-typedef struct ivas_hrtfs_header_t
-{
- int32_t rend_type;
- int32_t input_cfg;
- int32_t frequency;
- uint32_t data_size;
-
-} ivas_hrtfs_header_t;
-
-typedef struct ivas_hrtfs_file_header_t
-{
- char identifier[8];
- int32_t file_size;
- int16_t nb_hrtf;
- int32_t max_data_size;
-
-} ivas_hrtfs_file_header_t;
+/* Fastconv binaural data structure */
typedef struct ivas_hrtfs_fastconv_struct
{
@@ -961,6 +730,7 @@ typedef struct ivas_hrtfs_fastconv_struct
float fastconvReverberationTimes[CLDFB_NO_CHANNELS_MAX];
float fastconvReverberationEneCorrections[CLDFB_NO_CHANNELS_MAX];
+
} HRTFS_FASTCONV, *HRTFS_FASTCONV_HANDLE;
@@ -972,29 +742,8 @@ typedef struct ivas_hrtfs_parambin_struct
float parametricReverberationTimes[CLDFB_NO_CHANNELS_MAX];
float parametricReverberationEneCorrections[CLDFB_NO_CHANNELS_MAX];
float parametricEarlyPartEneCorrection[CLDFB_NO_CHANNELS_MAX];
-} HRTFS_PARAMBIN, *HRTFS_PARAMBIN_HANDLE;
-
-
-/*----------------------------------------------------------------------------------*
- * LFE decoder structure
- *----------------------------------------------------------------------------------*/
-typedef struct ivas_lfe_dec_data_structure
-{
- ivas_filters_process_state_t filter_state;
- LFE_WINDOW_HANDLE pWindow_state;
- const uint16_t *cum_freq_models[IVAS_MAX_NUM_QUANT_STRATS][IVAS_MAX_NUM_DCT_COEF_GROUPS];
- int16_t lfe_dec_indices_coeffs_tbl[IVAS_MAX_NUM_QUANT_STRATS][IVAS_MAX_NUM_DCT_COEF_GROUPS];
- float lfe_block_delay_s;
- int16_t lfe_prior_buf_len;
- float *prior_out_buffer;
-
- float *prevsynth_buf;
- float *lfe_delay_buf;
- int16_t lfe_addl_delay;
- int16_t bfi_count;
-
-} LFE_DEC_DATA, *LFE_DEC_HANDLE;
+} HRTFS_PARAMBIN, *HRTFS_PARAMBIN_HANDLE;
/*----------------------------------------------------------------------------------*
@@ -1018,40 +767,6 @@ typedef struct
} IVAS_LIMITER, *IVAS_LIMITER_HANDLE;
-/*----------------------------------------------------------------------------------*
- * Decoder configuration structure
- *----------------------------------------------------------------------------------*/
-
-typedef struct decoder_config_structure
-{
- int32_t ivas_total_brate; /* IVAS total bitrate in bps */
- int32_t last_ivas_total_brate; /* last IVAS total bitrate in bps */
- int32_t output_Fs; /* output signal sampling frequency in Hz */
- int16_t nchan_out; /* number of output audio channels */
- AUDIO_CONFIG output_config; /* output audio configuration */
- int16_t Opt_LsCustom; /* indicates whether loudspeaker custom setup is used */
- int16_t Opt_HRTF_binary; /* indicates whether HRTF binary file is used */
- int16_t Opt_Headrotation; /* indicates whether head-rotation is used */
- int16_t orientation_tracking; /* indicates orientation tracking type */
- float no_diegetic_pan;
- int16_t Opt_AMR_WB; /* flag indicating AMR-WB IO mode */
-
- /* temp. development parameters */
-#ifdef DEBUGGING
- int16_t forceSubframeBinauralization; /* Flag for forcing Parametric binauralizer to subframe mode */
- int16_t force_rend; /* forced TD/CLDFB binaural renderer (for ISM and MC) */
-#endif
-
-} DECODER_CONFIG, *DECODER_CONFIG_HANDLE;
-
-typedef struct
-{
- int32_t binaural_latency_ns;
- BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd;
- TDREND_HRFILT_FiltSet_t *hHrtfTD;
-} TDREND_WRAPPER, *TDREND_WRAPPER_HANDLE;
-#endif
-
/*----------------------------------------------------------------------------------*
* Loudspeaker Configuration Conversion structure
*----------------------------------------------------------------------------------*/
diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c
index 1da49b813b1f30f5ef32b929eeab35bd32599d9d..8f868bd58f4511d162e816da38fffe754d478ac1 100644
--- a/lib_rend/lib_rend.c
+++ b/lib_rend/lib_rend.c
@@ -31,25 +31,22 @@
*******************************************************************************************************/
#include "options.h"
-#include "ivas_cnst.h"
#include "lib_rend.h"
+#include "prot.h"
#include "ivas_prot.h"
+#include "ivas_prot_rend.h"
+#include "ivas_cnst.h"
#include "ivas_rom_com.h"
-#include "ivas_rom_dec.h"
#include "ivas_rom_rend.h"
-#include "ivas_lib_rend_internal.h"
-#ifdef FIX_197_CREND_INTERFACE
-#include "lib_rend.h"
-#endif
-#include "prot.h"
-#include "wmc_auto.h"
-
#include
#include
#include
-#include
-#include
-#include
+#include "wmc_auto.h"
+
+
+/*-------------------------------------------------------------------*
+ * Local constants
+ *-------------------------------------------------------------------*/
/* Maximum buffer length (per channel) in samples.
* Keep this separate from L_FRAME48k in case we want to support different size later */
@@ -62,6 +59,10 @@
#define BINAURAL_RENDERING_FRAME_SIZE_MS 20
+/*-------------------------------------------------------------------*
+ * Local types
+ *-------------------------------------------------------------------*/
+
typedef float pan_vector[MAX_OUTPUT_CHANNELS];
typedef float pan_matrix[MAX_INPUT_CHANNELS][MAX_OUTPUT_CHANNELS];
typedef float rotation_gains[MAX_INPUT_CHANNELS][MAX_INPUT_CHANNELS];
@@ -202,6 +203,11 @@ struct IVAS_REND
RENDER_CONFIG_DATA *hRendererConfig; /* Renderer config pointer */
};
+
+/*-------------------------------------------------------------------*
+ * Local functions
+ *-------------------------------------------------------------------*/
+
static IVAS_QUATERNION quaternionInit(
void )
{
@@ -213,8 +219,8 @@ static IVAS_QUATERNION quaternionInit(
static float *getSmplPtr(
IVAS_REND_AudioBuffer buffer,
- uint32_t chnlIdx,
- uint32_t smplIdx )
+ const uint32_t chnlIdx,
+ const uint32_t smplIdx )
{
return buffer.data + chnlIdx * buffer.config.numSamplesPerChannel + smplIdx;
}
@@ -263,8 +269,6 @@ static void accumulate2dArrayToBuffer(
* limitRendererOutput()
*
* In-place saturation control for multichannel buffers with adaptive release time
- *
- *
*-------------------------------------------------------------------*/
/*! r: number of clipped output samples */
@@ -312,10 +316,16 @@ static int32_t limitRendererOutput(
return numClipping;
}
+
+/*-------------------------------------------------------------------*
+ * getIvasAudioConfigFromRendAudioConfig()
+ *
+ *
+ *-------------------------------------------------------------------*/
#ifdef FIX_197_CREND_INTERFACE
AUDIO_CONFIG getIvasAudioConfigFromRendAudioConfig(
#else
-static AUDIO_CONFIG rendAudioConfigToIvasAudioConfig( // VE2AT: similar is defined again at line 397, why?
+AUDIO_CONFIG rendAudioConfigToIvasAudioConfig(
#endif
IVAS_REND_AudioConfig rendConfig )
{
@@ -360,6 +370,53 @@ static AUDIO_CONFIG rendAudioConfigToIvasAudioConfig( // VE2AT: similar is defin
return AUDIO_CONFIG_INVALID;
}
+/*-------------------------------------------------------------------*
+ * getRendAudioConfigFromIvasAudioConfig()
+ *
+ *
+ *-------------------------------------------------------------------*/
+
+IVAS_REND_AudioConfig getRendAudioConfigFromIvasAudioConfig(
+ AUDIO_CONFIG config )
+{
+ switch ( config )
+ {
+ case AUDIO_CONFIG_MONO:
+ return IVAS_REND_AUDIO_CONFIG_MONO;
+ case AUDIO_CONFIG_STEREO:
+ return IVAS_REND_AUDIO_CONFIG_STEREO;
+ case AUDIO_CONFIG_BINAURAL:
+ return IVAS_REND_AUDIO_CONFIG_BINAURAL;
+ case AUDIO_CONFIG_BINAURAL_ROOM:
+ return IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM;
+ case AUDIO_CONFIG_5_1:
+ return IVAS_REND_AUDIO_CONFIG_5_1;
+ case AUDIO_CONFIG_7_1:
+ return IVAS_REND_AUDIO_CONFIG_7_1;
+ case AUDIO_CONFIG_5_1_2:
+ return IVAS_REND_AUDIO_CONFIG_5_1_2;
+ case AUDIO_CONFIG_5_1_4:
+ return IVAS_REND_AUDIO_CONFIG_5_1_4;
+ case AUDIO_CONFIG_7_1_4:
+ return IVAS_REND_AUDIO_CONFIG_7_1_4;
+ case AUDIO_CONFIG_FOA:
+ return IVAS_REND_AUDIO_CONFIG_FOA;
+ case AUDIO_CONFIG_HOA2:
+ return IVAS_REND_AUDIO_CONFIG_HOA2;
+ case AUDIO_CONFIG_HOA3:
+ return IVAS_REND_AUDIO_CONFIG_HOA3;
+ default:
+ break;
+ }
+ return IVAS_REND_AUDIO_CONFIG_UNKNOWN;
+}
+
+/*-------------------------------------------------------------------*
+ * validateOutputAudioConfig()
+ *
+ *
+ *-------------------------------------------------------------------*/
+
static ivas_error validateOutputAudioConfig(
IVAS_REND_AudioConfig outConfig )
{
@@ -386,13 +443,27 @@ static ivas_error validateOutputAudioConfig(
return IVAS_ERR_INVALID_OUTPUT_FORMAT;
}
+
+/*-------------------------------------------------------------------*
+ * getAudioConfigType()
+ *
+ *
+ *-------------------------------------------------------------------*/
+
IVAS_REND_AudioConfigType getAudioConfigType(
IVAS_REND_AudioConfig config )
{
/* By definition, config type is the second byte (from LSB) of IVAS_REND_AudioConfig enum. */
- return ( config & 0xFF00 ) >> 8; // VE2AT: MSVC returns warning C4244: 'return': conversion from 'int' to 'IVAS_REND_InputId', possible loss of data
+ return ( config & 0xFF00 ) >> 8;
}
+
+/*-------------------------------------------------------------------*
+ * validateOutputSampleRate()
+ *
+ *
+ *-------------------------------------------------------------------*/
+
static ivas_error validateOutputSampleRate(
const int32_t sampleRate,
const IVAS_REND_AudioConfig outConfig )
@@ -416,6 +487,13 @@ static ivas_error validateOutputSampleRate(
return IVAS_ERR_INVALID_SAMPLING_RATE;
}
+
+/*-------------------------------------------------------------------*
+ * getAudioConfigNumChannels()
+ *
+ *
+ *-------------------------------------------------------------------*/
+
ivas_error getAudioConfigNumChannels(
const IVAS_REND_AudioConfig config,
int16_t *numChannels )
@@ -462,76 +540,10 @@ ivas_error getAudioConfigNumChannels(
return IVAS_ERR_OK;
}
-#ifdef FIX_197_CREND_INTERFACE
-IVAS_REND_AudioConfig getRendAudioConfigFromIvasAudioConfig(
- AUDIO_CONFIG config )
-#else
-AUDIO_CONFIG getIvasAudioConfigFromRendAudioConfig(
- IVAS_REND_AudioConfig config )
-#endif
-{
- switch ( config )
- {
-#ifdef FIX_197_CREND_INTERFACE
- case AUDIO_CONFIG_MONO:
- return IVAS_REND_AUDIO_CONFIG_MONO;
- case AUDIO_CONFIG_STEREO:
- return IVAS_REND_AUDIO_CONFIG_STEREO;
- case AUDIO_CONFIG_BINAURAL:
- return IVAS_REND_AUDIO_CONFIG_BINAURAL;
- case AUDIO_CONFIG_BINAURAL_ROOM:
- return IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM;
- case AUDIO_CONFIG_5_1:
- return IVAS_REND_AUDIO_CONFIG_5_1;
- case AUDIO_CONFIG_7_1:
- return IVAS_REND_AUDIO_CONFIG_7_1;
- case AUDIO_CONFIG_5_1_2:
- return IVAS_REND_AUDIO_CONFIG_5_1_2;
- case AUDIO_CONFIG_5_1_4:
- return IVAS_REND_AUDIO_CONFIG_5_1_4;
- case AUDIO_CONFIG_7_1_4:
- return IVAS_REND_AUDIO_CONFIG_7_1_4;
- case AUDIO_CONFIG_FOA:
- return IVAS_REND_AUDIO_CONFIG_FOA;
- case AUDIO_CONFIG_HOA2:
- return IVAS_REND_AUDIO_CONFIG_HOA2;
- case AUDIO_CONFIG_HOA3:
- return IVAS_REND_AUDIO_CONFIG_HOA3;
- default:
- break;
- }
- return IVAS_REND_AUDIO_CONFIG_UNKNOWN;
-#else
- case IVAS_REND_AUDIO_CONFIG_MONO:
- return AUDIO_CONFIG_MONO;
- case IVAS_REND_AUDIO_CONFIG_STEREO:
- return AUDIO_CONFIG_STEREO;
- case IVAS_REND_AUDIO_CONFIG_BINAURAL:
- return AUDIO_CONFIG_BINAURAL;
- case IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM:
- return AUDIO_CONFIG_BINAURAL_ROOM;
- case IVAS_REND_AUDIO_CONFIG_5_1:
- return AUDIO_CONFIG_5_1;
- case IVAS_REND_AUDIO_CONFIG_7_1:
- return AUDIO_CONFIG_7_1;
- case IVAS_REND_AUDIO_CONFIG_5_1_2:
- return AUDIO_CONFIG_5_1_2;
- case IVAS_REND_AUDIO_CONFIG_5_1_4:
- return AUDIO_CONFIG_5_1_4;
- case IVAS_REND_AUDIO_CONFIG_7_1_4:
- return AUDIO_CONFIG_7_1_4;
- case IVAS_REND_AUDIO_CONFIG_FOA:
- return AUDIO_CONFIG_FOA;
- case IVAS_REND_AUDIO_CONFIG_HOA2:
- return AUDIO_CONFIG_HOA2;
- case IVAS_REND_AUDIO_CONFIG_HOA3:
- return AUDIO_CONFIG_HOA3;
- default:
- break;
- }
- return AUDIO_CONFIG_INVALID;
-#endif
-}
+
+/*-------------------------------------------------------------------*
+ * Local functions
+ *-------------------------------------------------------------------*/
static ivas_error initLimiter(
IVAS_LIMITER_HANDLE *phLimiter,
@@ -1059,13 +1071,17 @@ static ivas_error setRendInputActiveIsm(
error = IVAS_ERR_OK;
if ( outConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL )
{
- error = ivas_rend_TDObjRendOpen( &inputIsm->tdRendWrapper, inConfig, NULL, *rendCtx.pOutSampleRate );
+ error = ivas_td_binaural_open_ext( &inputIsm->tdRendWrapper, inConfig, NULL, *rendCtx.pOutSampleRate );
}
else if ( outConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM )
{
error = ivas_rend_openCrend( &inputIsm->crendWrapper,
- IVAS_REND_AUDIO_CONFIG_7_1_4,
- outConfig,
+ AUDIO_CONFIG_7_1_4,
+#ifdef FIX_197_CREND_INTERFACE
+ getIvasAudioConfigFromRendAudioConfig( outConfig ),
+#else
+ rendAudioConfigToIvasAudioConfig( outConfig ),
+#endif
hRendCfg,
#ifdef FIX_197_CREND_INTERFACE
0,
@@ -1203,7 +1219,9 @@ static ivas_error initMcPanGainsWithConversionMapping(
return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Missing multichannel conversion mapping" );
}
-static ivas_error initMcPanGainsWithEfap( input_mc *inputMc, IVAS_REND_AudioConfig outConfig )
+static ivas_error initMcPanGainsWithEfap(
+ input_mc *inputMc,
+ const IVAS_REND_AudioConfig outConfig )
{
int16_t i;
int16_t numNonLfeInChannels;
@@ -1398,10 +1416,10 @@ static ivas_error initMcPanGainsWithStereoLookup(
/* Returns 1 (true) if configs A and B are equal, otherwise returns 0 (false).
* If both configs are custom LS layouts, layout details are compared to determine equality. */
static bool configsAreEqual(
- IVAS_REND_AudioConfig configA,
- LSSETUP_CUSTOM_STRUCT customLsA,
- IVAS_REND_AudioConfig configB,
- LSSETUP_CUSTOM_STRUCT customLsB )
+ const IVAS_REND_AudioConfig configA,
+ const LSSETUP_CUSTOM_STRUCT customLsA,
+ const IVAS_REND_AudioConfig configB,
+ const LSSETUP_CUSTOM_STRUCT customLsB )
{
int16_t i;
@@ -1761,7 +1779,7 @@ static ivas_error initMcBinauralRendering(
// if ( initTDRend )
{
- if ( ( error = ivas_rend_TDObjRendOpen( &inputMc->tdRendWrapper, inConfig, &inputMc->customLsInput, outSampleRate ) ) != IVAS_ERR_OK )
+ if ( ( error = ivas_td_binaural_open_ext( &inputMc->tdRendWrapper, inConfig, &inputMc->customLsInput, outSampleRate ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -1769,8 +1787,13 @@ static ivas_error initMcBinauralRendering(
{
if ( ( error = ivas_rend_openCrend( &inputMc->crendWrapper,
- ( inConfig == IVAS_REND_AUDIO_CONFIG_LS_CUSTOM ) ? IVAS_REND_AUDIO_CONFIG_7_1_4 : inConfig,
- outConfig,
+#ifdef FIX_197_CREND_INTERFACE
+ ( inConfig == IVAS_REND_AUDIO_CONFIG_LS_CUSTOM ) ? AUDIO_CONFIG_7_1_4 : getIvasAudioConfigFromRendAudioConfig( inConfig ),
+ getIvasAudioConfigFromRendAudioConfig( outConfig ),
+#else
+ ( inConfig == IVAS_REND_AUDIO_CONFIG_LS_CUSTOM ) ? AUDIO_CONFIG_7_1_4 : rendAudioConfigToIvasAudioConfig( inConfig ),
+ rendAudioConfigToIvasAudioConfig( outConfig ),
+#endif
hRendCfg,
#ifdef FIX_197_CREND_INTERFACE
0,
@@ -1792,10 +1815,10 @@ static ivas_error initMcBinauralRendering(
}
static lfe_routing defaultLfeRouting(
- IVAS_REND_AudioConfig inConfig,
- LSSETUP_CUSTOM_STRUCT customLsIn,
- IVAS_REND_AudioConfig outConfig,
- LSSETUP_CUSTOM_STRUCT customLsOut )
+ const IVAS_REND_AudioConfig inConfig,
+ const LSSETUP_CUSTOM_STRUCT customLsIn,
+ const IVAS_REND_AudioConfig outConfig,
+ const LSSETUP_CUSTOM_STRUCT customLsOut )
{
int32_t i;
lfe_routing routing;
@@ -2046,30 +2069,39 @@ static ivas_error updateSbaPanGains(
switch ( outConfig )
{
case IVAS_REND_AUDIO_CONFIG_BINAURAL:
+ error = ivas_rend_openCrend( &inputSba->crendWrapper,
#ifdef FIX_197_CREND_INTERFACE
- error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, 0,
- NULL,
- *rendCtx.pOutSampleRate );
+ getIvasAudioConfigFromRendAudioConfig( inConfig ),
+ getIvasAudioConfigFromRendAudioConfig( outConfig ),
#else
- error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg,
+ rendAudioConfigToIvasAudioConfig( inConfig ),
+ rendAudioConfigToIvasAudioConfig( outConfig ),
+#endif
+ hRendCfg,
+#ifdef FIX_197_CREND_INTERFACE
+ 0,
+#endif
NULL,
*rendCtx.pOutSampleRate );
-#endif
break;
case IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM:
if ( ( error = initSbaPanGainsForMcOut( inputSba, IVAS_REND_AUDIO_CONFIG_7_1_4, NULL ) ) != IVAS_ERR_OK )
{
return error;
}
+ error = ivas_rend_openCrend( &inputSba->crendWrapper,
+ AUDIO_CONFIG_7_1_4,
#ifdef FIX_197_CREND_INTERFACE
- error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_REND_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, 0,
- NULL,
- *rendCtx.pOutSampleRate );
+ getIvasAudioConfigFromRendAudioConfig( outConfig ),
#else
- error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_REND_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg,
+ rendAudioConfigToIvasAudioConfig( outConfig ),
+#endif
+ hRendCfg,
+#ifdef FIX_197_CREND_INTERFACE
+ 0,
+#endif
NULL,
*rendCtx.pOutSampleRate );
-#endif
break;
default:
return IVAS_ERR_INVALID_OUTPUT_FORMAT;
@@ -2141,7 +2173,9 @@ static void clearInputSba(
return;
}
-static ivas_error initMasaDummyDecForMcOut( input_masa *inputMasa, IVAS_REND_AudioConfig outConfig )
+static ivas_error initMasaDummyDecForMcOut(
+ input_masa *inputMasa,
+ const IVAS_REND_AudioConfig outConfig )
{
ivas_error error;
int16_t numCldfbAnalyses;
@@ -2227,7 +2261,9 @@ static ivas_error initMasaDummyDecForMcOut( input_masa *inputMasa, IVAS_REND_Aud
return IVAS_ERR_OK;
}
-static ivas_error initMasaDummyDecForSbaOut( input_masa *inputMasa, IVAS_REND_AudioConfig outConfig )
+static ivas_error initMasaDummyDecForSbaOut(
+ input_masa *inputMasa,
+ const IVAS_REND_AudioConfig outConfig )
{
ivas_error error;
int16_t numCldfbAnalyses;
@@ -2297,7 +2333,9 @@ static ivas_error initMasaDummyDecForSbaOut( input_masa *inputMasa, IVAS_REND_Au
return IVAS_ERR_OK;
}
-static ivas_error initMasaDummyDecForBinauralOut( input_masa *inputMasa, IVAS_REND_AudioConfig outConfig )
+static ivas_error initMasaDummyDecForBinauralOut(
+ input_masa *inputMasa,
+ const IVAS_REND_AudioConfig outConfig )
{
ivas_error error;
@@ -2373,7 +2411,9 @@ static ivas_error initMasaDummyDecForBinauralOut( input_masa *inputMasa, IVAS_RE
return IVAS_ERR_OK;
}
-static ivas_error updateMasaDummyDec( input_masa *inputMasa, IVAS_REND_AudioConfig outConfig )
+static ivas_error updateMasaDummyDec(
+ input_masa *inputMasa,
+ const IVAS_REND_AudioConfig outConfig )
{
ivas_error error;
@@ -2400,7 +2440,11 @@ static ivas_error updateMasaDummyDec( input_masa *inputMasa, IVAS_REND_AudioConf
return IVAS_ERR_OK;
}
-static DecoderDummy *initDecoderDummy( int32_t sampleRate, int16_t numTransChannels, IVAS_REND_AudioConfig outConfig, const uint8_t enableRenderConfig )
+static DecoderDummy *initDecoderDummy(
+ const int32_t sampleRate,
+ const int16_t numTransChannels,
+ const IVAS_REND_AudioConfig outConfig,
+ const uint8_t enableRenderConfig )
{
ivas_error error;
int16_t i;
@@ -2430,7 +2474,7 @@ static DecoderDummy *initDecoderDummy( int32_t sampleRate, int16_t numTransChann
decDummy->hHrtfTD = NULL;
decDummy->hSpar = NULL;
decDummy->hoa_dec_mtx = NULL;
- decDummy->hVBAPdata = NULL;
+ decDummy->hVBAPdata = NULL; // note: not used at the moment
decDummy->hMasa = NULL;
decDummy->hDiracDecBin = NULL;
decDummy->hQMetaData = NULL;
@@ -2511,7 +2555,8 @@ static ivas_error setRendInputActiveMasa(
return IVAS_ERR_OK;
}
-static void freeDecoderDummy( DecoderDummy **ppDecDummy )
+static void freeDecoderDummy(
+ DecoderDummy **ppDecDummy )
{
int16_t i;
DecoderDummy *pDecDummy;
@@ -2578,7 +2623,8 @@ static void freeDecoderDummy( DecoderDummy **ppDecDummy )
pDecDummy = NULL;
}
-static void clearInputMasa( input_masa *inputMasa )
+static void clearInputMasa(
+ input_masa *inputMasa )
{
rendering_context rendCtx;
@@ -2678,10 +2724,7 @@ ivas_error IVAS_REND_Open(
}
for ( i = 0; i < RENDERER_MAX_MASA_INPUTS; ++i )
{
- initRendInputBase( &hIvasRend->inputsMasa[i].base,
- IVAS_REND_AUDIO_CONFIG_UNKNOWN,
- 0,
- getRendCtx( hIvasRend ) );
+ initRendInputBase( &hIvasRend->inputsMasa[i].base, IVAS_REND_AUDIO_CONFIG_UNKNOWN, 0, getRendCtx( hIvasRend ) );
hIvasRend->inputsMasa[i].decDummy = NULL;
hIvasRend->inputsMasa[i].metadataHasBeenFed = false;
}
@@ -2995,8 +3038,8 @@ static ivas_error getConstInputById(
static ivas_error findFreeInputSlot(
const void *inputs,
- int32_t inputStructSize,
- int32_t maxInputs,
+ const int32_t inputStructSize,
+ const int32_t maxInputs,
int32_t *inputIndex )
{
/* Using a void pointer and a separately provided size is a hack for this function
@@ -3034,10 +3077,18 @@ static ivas_error findFreeInputSlot(
return IVAS_ERR_OK;
}
+
+/*-------------------------------------------------------------------*
+ * IVAS_REND_AddInput()
+ *
+ *
+ *-------------------------------------------------------------------*/
+
ivas_error IVAS_REND_AddInput(
- IVAS_REND_HANDLE hIvasRend,
- IVAS_REND_AudioConfig inConfig,
- IVAS_REND_InputId *inputId )
+ IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */
+ const IVAS_REND_AudioConfig inConfig, /* i : audio config for a new input */
+ IVAS_REND_InputId *inputId /* o : ID of the new input */
+)
{
ivas_error error;
int32_t maxNumInputsOfType;
@@ -3101,10 +3152,19 @@ ivas_error IVAS_REND_AddInput(
return IVAS_ERR_OK;
}
+
+/*-------------------------------------------------------------------*
+ * IVAS_REND_ConfigureCustomInputLoudspeakerLayout()
+ *
+ *
+ * Note: this will reset any custom LFE routing set for the input
+ *-------------------------------------------------------------------*/
+
ivas_error IVAS_REND_ConfigureCustomInputLoudspeakerLayout(
- IVAS_REND_HANDLE hIvasRend,
- const IVAS_REND_InputId inputId,
- const IVAS_CUSTOM_LS_DATA layout )
+ IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */
+ const IVAS_REND_InputId inputId, /* i : ID of the input */
+ const IVAS_CUSTOM_LS_DATA layout /* i : custom loudspeaker layout for input */
+)
{
input_mc *inputMc;
ivas_error error;
@@ -3155,10 +3215,17 @@ ivas_error IVAS_REND_ConfigureCustomInputLoudspeakerLayout(
return IVAS_ERR_OK;
}
+
+/*-------------------------------------------------------------------*
+ * IVAS_REND_SetInputGain()
+ *
+ *
+ *-------------------------------------------------------------------*/
+
ivas_error IVAS_REND_SetInputGain(
- IVAS_REND_HANDLE hIvasRend,
- const IVAS_REND_InputId inputId,
- const float gain /* linear gain, not in dB */
+ IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */
+ const IVAS_REND_InputId inputId, /* i : ID of the input */
+ const float gain /* i : linear gain (not in dB) */
)
{
input_base *inputBase;
@@ -3182,10 +3249,18 @@ ivas_error IVAS_REND_SetInputGain(
return IVAS_ERR_OK;
}
+
+/*-------------------------------------------------------------------*
+ * IVAS_REND_SetInputLfeMtx()
+ *
+ *
+ *-------------------------------------------------------------------*/
+
ivas_error IVAS_REND_SetInputLfeMtx(
- IVAS_REND_HANDLE hIvasRend,
- const IVAS_REND_InputId inputId,
- const IVAS_REND_LfePanMtx *lfePanMtx )
+ IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */
+ const IVAS_REND_InputId inputId, /* i : ID of the input */
+ const IVAS_REND_LfePanMtx *lfePanMtx /* i : LFE panning matrix */
+)
{
int16_t i;
input_base *pInputBase;
@@ -3225,12 +3300,20 @@ ivas_error IVAS_REND_SetInputLfeMtx(
return IVAS_ERR_OK;
}
+
+/*-------------------------------------------------------------------*
+ * IVAS_REND_SetInputLfePos()
+ *
+ *
+ *-------------------------------------------------------------------*/
+
ivas_error IVAS_REND_SetInputLfePos(
- IVAS_REND_HANDLE hIvasRend,
- const IVAS_REND_InputId inputId,
- const float inputGain,
- const float outputAzimuth,
- const float outputElevation )
+ IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */
+ const IVAS_REND_InputId inputId, /* i : ID of the input */
+ const float inputGain, /* i : Input gain to be applied to the LFE channel(s) */
+ const float outputAzimuth, /* i : Output azimuth position */
+ const float outputElevation /* i : Output elevation position */
+)
{
input_base *pInputBase;
input_mc *pInputMc;
@@ -3267,9 +3350,17 @@ ivas_error IVAS_REND_SetInputLfePos(
return IVAS_ERR_OK;
}
+
+/*-------------------------------------------------------------------*
+ * IVAS_REND_RemoveInput()
+ *
+ *
+ *-------------------------------------------------------------------*/
+
ivas_error IVAS_REND_RemoveInput(
- IVAS_REND_HANDLE hIvasRend,
- const IVAS_REND_InputId inputId )
+ IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */
+ const IVAS_REND_InputId inputId /* i : ID of the input */
+)
{
ivas_error error;
input_base *inputBase;
@@ -3308,10 +3399,18 @@ ivas_error IVAS_REND_RemoveInput(
return IVAS_ERR_OK;
}
+
+/*-------------------------------------------------------------------*
+ * IVAS_REND_GetInputNumChannels()
+ *
+ *
+ *-------------------------------------------------------------------*/
+
ivas_error IVAS_REND_GetInputNumChannels(
- IVAS_REND_CONST_HANDLE hIvasRend,
- const IVAS_REND_InputId inputId,
- int16_t *numChannels )
+ IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */
+ const IVAS_REND_InputId inputId, /* i : ID of the input */
+ int16_t *numChannels /* o : number of channels of the input */
+)
{
ivas_error error;
const input_base *pInput;
@@ -3337,6 +3436,13 @@ ivas_error IVAS_REND_GetInputNumChannels(
return IVAS_ERR_OK;
}
+
+/*-------------------------------------------------------------------*
+ * IVAS_REND_GetDelay()
+ *
+ *
+ *-------------------------------------------------------------------*/
+
ivas_error IVAS_REND_GetDelay(
IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer state */
int16_t *nSamples, /* o : Renderer delay in samples */
@@ -3421,10 +3527,18 @@ ivas_error IVAS_REND_GetDelay(
return IVAS_ERR_OK;
}
+
+/*-------------------------------------------------------------------*
+ * IVAS_REND_FeedInputAudio()
+ *
+ *
+ *-------------------------------------------------------------------*/
+
ivas_error IVAS_REND_FeedInputAudio(
- IVAS_REND_HANDLE hIvasRend,
- const IVAS_REND_InputId inputId,
- const IVAS_REND_ReadOnlyAudioBuffer inputAudio )
+ IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */
+ const IVAS_REND_InputId inputId, /* i : ID of the input */
+ const IVAS_REND_ReadOnlyAudioBuffer inputAudio /* i : buffer with input audio */
+)
{
ivas_error error;
input_base *inputBase;
@@ -3475,10 +3589,18 @@ ivas_error IVAS_REND_FeedInputAudio(
return IVAS_ERR_OK;
}
+
+/*-------------------------------------------------------------------*
+ * IVAS_REND_FeedInputObjectMetadata()
+ *
+ *
+ *-------------------------------------------------------------------*/
+
ivas_error IVAS_REND_FeedInputObjectMetadata(
- IVAS_REND_HANDLE hIvasRend,
- const IVAS_REND_InputId inputId,
- const IVAS_REND_AudioObjectPosition objectPosition )
+ IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */
+ const IVAS_REND_InputId inputId, /* i : ID of the input */
+ const IVAS_REND_AudioObjectPosition objectPosition /* i : object position struct */
+)
{
input_base *inputBase;
input_ism *inputIsm;
@@ -3509,10 +3631,18 @@ ivas_error IVAS_REND_FeedInputObjectMetadata(
return IVAS_ERR_OK;
}
+
+/*-------------------------------------------------------------------*
+ * IVAS_REND_FeedInputMasaMetadata()
+ *
+ *
+ *-------------------------------------------------------------------*/
+
ivas_error IVAS_REND_FeedInputMasaMetadata(
- IVAS_REND_HANDLE hIvasRend,
- const IVAS_REND_InputId inputId,
- IVAS_MASA_METADATA_HANDLE masaMetadata )
+ IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */
+ const IVAS_REND_InputId inputId, /* i : ID of the input */
+ IVAS_MASA_METADATA_HANDLE masaMetadata /* i : MASA metadata frame */
+)
{
ivas_error error;
input_base *inputBase;
@@ -3543,44 +3673,53 @@ ivas_error IVAS_REND_FeedInputMasaMetadata(
return IVAS_ERR_OK;
}
-ivas_error IVAS_REND_InitConfig( IVAS_REND_HANDLE st,
- bool rendererConfigEnabled )
+
+/*-------------------------------------------------------------------*
+ * IVAS_REND_InitConfig()
+ *
+ *
+ *-------------------------------------------------------------------*/
+
+ivas_error IVAS_REND_InitConfig(
+ IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */
+ const bool rendererConfigEnabled /* i : flag indicating if a renderer configuration file was supplied */
+)
{
ivas_error error;
if ( rendererConfigEnabled )
{
- st->rendererConfigEnabled = 1;
+ hIvasRend->rendererConfigEnabled = 1;
}
else
{
- st->rendererConfigEnabled = 0;
+ hIvasRend->rendererConfigEnabled = 0;
}
#ifdef FIX_197_CREND_INTERFACE
if ( rendererConfigEnabled )
{
- if ( ( error = ivas_render_config_open( &( st->hRendererConfig ) ) ) != IVAS_ERR_OK )
+ if ( ( error = ivas_render_config_open( &( hIvasRend->hRendererConfig ) ) ) != IVAS_ERR_OK )
{
return error;
}
- if ( ivas_render_config_init_from_rom( &st->hRendererConfig, st->rendererConfigEnabled ) != IVAS_ERR_OK )
+ if ( ivas_render_config_init_from_rom( &hIvasRend->hRendererConfig, hIvasRend->rendererConfigEnabled ) != IVAS_ERR_OK )
{
return IVAS_ERR_INTERNAL_FATAL;
}
}
else
{
- st->hRendererConfig = NULL;
+ hIvasRend->hRendererConfig = NULL;
}
#else
- if ( ( error = ivas_render_config_open( &( st->hRendererConfig ) ) ) != IVAS_ERR_OK )
+ if ( ( error = ivas_render_config_open( &( hIvasRend->hRendererConfig ) ) ) != IVAS_ERR_OK )
{
return error;
}
- if ( ivas_render_config_init_from_rom( &st->hRendererConfig, st->rendererConfigEnabled ) != IVAS_ERR_OK )
+ if ( ivas_render_config_init_from_rom( &hIvasRend->hRendererConfig, hIvasRend->rendererConfigEnabled ) != IVAS_ERR_OK )
{
return IVAS_ERR_INTERNAL_FATAL;
}
@@ -3589,6 +3728,13 @@ ivas_error IVAS_REND_InitConfig( IVAS_REND_HANDLE st,
return IVAS_ERR_OK;
}
+
+/*-------------------------------------------------------------------*
+ * IVAS_REND_GetRenderConfig()
+ *
+ *
+ *-------------------------------------------------------------------*/
+
int16_t IVAS_REND_GetRenderConfig(
IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS decoder handle */
const IVAS_RENDER_CONFIG_HANDLE hRCout /* o : Render configuration handle */
@@ -3631,6 +3777,12 @@ int16_t IVAS_REND_GetRenderConfig(
}
+/*-------------------------------------------------------------------*
+ * IVAS_REND_FeedRenderConfig()
+ *
+ *
+ *-------------------------------------------------------------------*/
+
int16_t IVAS_REND_FeedRenderConfig(
IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS decoder handle */
const IVAS_RENDER_CONFIG_DATA renderConfig /* i : Render configuration struct */
@@ -3669,9 +3821,16 @@ int16_t IVAS_REND_FeedRenderConfig(
}
+/*-------------------------------------------------------------------*
+ * IVAS_REND_SetHeadRotation()
+ *
+ *
+ *-------------------------------------------------------------------*/
+
ivas_error IVAS_REND_SetHeadRotation(
- IVAS_REND_HANDLE hIvasRend,
- const IVAS_QUATERNION headRot[RENDERER_HEAD_POSITIONS_PER_FRAME] )
+ IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */
+ const IVAS_QUATERNION headRot[RENDERER_HEAD_POSITIONS_PER_FRAME] /* i : head positions for next rendering call */
+)
{
int16_t i;
@@ -3705,6 +3864,11 @@ ivas_error IVAS_REND_SetHeadRotation(
return IVAS_ERR_OK;
}
+
+/*-------------------------------------------------------------------*
+ * Local functions
+ *-------------------------------------------------------------------*/
+
/* Take one channel from input buffer and copy it to each channel
in output buffer, with different gain applied per output channel.
This function takes 2 gain vectors - one for the beginning and one
@@ -4013,13 +4177,13 @@ static ivas_error renderIsmToBinaural(
copyBufferTo2dArray( ismInput->base.inputBuffer, tmpTDRendBuffer );
/* TODO tmu : missing: interpolation between positions, 5ms rendering */
- if ( ( error = ivas_rend_TDObjRenderFrame( &ismInput->tdRendWrapper,
- ismInput->base.inConfig,
- NULL,
- ismInput->base.ctx.pHeadRotData,
- &ismInput->currentPos,
- outAudio.config.numSamplesPerChannel,
- tmpTDRendBuffer ) ) != IVAS_ERR_OK )
+ if ( ( error = ivas_td_binaural_renderer_ext( &ismInput->tdRendWrapper,
+ ismInput->base.inConfig,
+ NULL,
+ ismInput->base.ctx.pHeadRotData,
+ &ismInput->currentPos,
+ outAudio.config.numSamplesPerChannel,
+ tmpTDRendBuffer ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -4119,11 +4283,24 @@ static ivas_error renderIsmToBinauralRoom(
copyBufferTo2dArray( tmpMcBuffer, tmpCrendBuffer );
+
+ ivas_rend_crendProcess(
#ifdef FIX_197_CREND_INTERFACE
- ivas_rend_crendProcess( ismInput->crendWrapper, IVAS_REND_AUDIO_CONFIG_7_1_4, IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM, NULL, NULL, NULL, NULL, tmpCrendBuffer, *ismInput->base.ctx.pOutSampleRate );
+ ismInput->crendWrapper,
#else
- ivas_rend_crendProcess( &ismInput->crendWrapper, IVAS_REND_AUDIO_CONFIG_7_1_4, IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM, tmpCrendBuffer, *ismInput->base.ctx.pOutSampleRate );
+ &ismInput->crendWrapper,
#endif
+ AUDIO_CONFIG_7_1_4,
+ AUDIO_CONFIG_BINAURAL_ROOM,
+#ifdef FIX_197_CREND_INTERFACE
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+#endif
+ tmpCrendBuffer,
+ *ismInput->base.ctx.pOutSampleRate );
+
accumulate2dArrayToBuffer( tmpCrendBuffer, &outAudio );
@@ -4388,13 +4565,13 @@ static ivas_error renderMcToBinaural(
{
copyBufferTo2dArray( mcInput->base.inputBuffer, tmpRendBuffer );
- if ( ( error = ivas_rend_TDObjRenderFrame( &mcInput->tdRendWrapper,
- mcInput->base.inConfig,
- &mcInput->customLsInput,
- mcInput->base.ctx.pHeadRotData,
- NULL,
- mcInput->base.inputBuffer.config.numSamplesPerChannel,
- tmpRendBuffer ) ) != IVAS_ERR_OK )
+ if ( ( error = ivas_td_binaural_renderer_ext( &mcInput->tdRendWrapper,
+ mcInput->base.inConfig,
+ &mcInput->customLsInput,
+ mcInput->base.ctx.pHeadRotData,
+ NULL,
+ mcInput->base.inputBuffer.config.numSamplesPerChannel,
+ tmpRendBuffer ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -4425,11 +4602,23 @@ static ivas_error renderMcToBinaural(
}
/* call CREND */
+
+ if ( ( error = ivas_rend_crendProcess(
#ifdef FIX_197_CREND_INTERFACE
- if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK )
+ mcInput->crendWrapper,
+ getIvasAudioConfigFromRendAudioConfig( mcInput->base.inConfig ),
+ getIvasAudioConfigFromRendAudioConfig( outConfig ),
+ NULL,
+ NULL,
+ NULL,
+ NULL,
#else
- if ( ( error = ivas_rend_crendProcess( &mcInput->crendWrapper, mcInput->base.inConfig, outConfig, tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK )
+ &mcInput->crendWrapper,
+ rendAudioConfigToIvasAudioConfig( mcInput->base.inConfig ),
+ rendAudioConfigToIvasAudioConfig( outConfig ),
#endif
+ tmpRendBuffer,
+ *mcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -4481,11 +4670,22 @@ static ivas_error renderMcToBinauralRoom(
}
/* call CREND */
+ if ( ( error = ivas_rend_crendProcess(
#ifdef FIX_197_CREND_INTERFACE
- if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, tmpCrendBuffer, *mcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK )
+ mcInput->crendWrapper,
+ getIvasAudioConfigFromRendAudioConfig( mcInput->base.inConfig ),
+ getIvasAudioConfigFromRendAudioConfig( outConfig ),
+ NULL,
+ NULL,
+ NULL,
+ NULL,
#else
- if ( ( error = ivas_rend_crendProcess( &mcInput->crendWrapper, mcInput->base.inConfig, outConfig, tmpCrendBuffer, *mcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK )
+ &mcInput->crendWrapper,
+ rendAudioConfigToIvasAudioConfig( mcInput->base.inConfig ),
+ rendAudioConfigToIvasAudioConfig( outConfig ),
#endif
+ tmpCrendBuffer,
+ *mcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -4552,11 +4752,22 @@ static ivas_error renderMcCustomLsToBinauralRoom(
copyBufferTo2dArray( tmpMcBuffer, tmpCrendBuffer );
/* call CREND */
+ if ( ( error = ivas_rend_crendProcess(
#ifdef FIX_197_CREND_INTERFACE
- if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, IVAS_REND_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, tmpCrendBuffer, *mcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK )
+ mcInput->crendWrapper,
+ AUDIO_CONFIG_7_1_4,
+ getIvasAudioConfigFromRendAudioConfig( outConfig ),
+ NULL,
+ NULL,
+ NULL,
+ NULL,
#else
- if ( ( error = ivas_rend_crendProcess( &mcInput->crendWrapper, IVAS_REND_AUDIO_CONFIG_7_1_4, outConfig, tmpCrendBuffer, *mcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK )
+ &mcInput->crendWrapper,
+ AUDIO_CONFIG_7_1_4,
+ rendAudioConfigToIvasAudioConfig( outConfig ),
#endif
+ tmpCrendBuffer,
+ *mcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -4784,11 +4995,22 @@ static ivas_error renderSbaToBinaural(
}
/* call CREND */
+ if ( ( error = ivas_rend_crendProcess(
#ifdef FIX_197_CREND_INTERFACE
- if ( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK )
+ sbaInput->crendWrapper,
+ getIvasAudioConfigFromRendAudioConfig( sbaInput->base.inConfig ),
+ getIvasAudioConfigFromRendAudioConfig( outConfig ),
+ NULL,
+ NULL,
+ NULL,
+ NULL,
#else
- if ( ( error = ivas_rend_crendProcess( &sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK )
+ &sbaInput->crendWrapper,
+ rendAudioConfigToIvasAudioConfig( sbaInput->base.inConfig ),
+ rendAudioConfigToIvasAudioConfig( outConfig ),
#endif
+ tmpCrendBuffer,
+ *sbaInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -4848,11 +5070,22 @@ static ivas_error renderSbaToBinauralRoom(
copyBufferTo2dArray( tmpMcBuffer, tmpCrendBuffer );
/* call CREND */
+ if ( ( error = ivas_rend_crendProcess(
#ifdef FIX_197_CREND_INTERFACE
- if ( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, IVAS_REND_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK )
+ sbaInput->crendWrapper,
+ AUDIO_CONFIG_7_1_4,
+ getIvasAudioConfigFromRendAudioConfig( outConfig ),
+ NULL,
+ NULL,
+ NULL,
+ NULL,
#else
- if ( ( error = ivas_rend_crendProcess( &sbaInput->crendWrapper, IVAS_REND_AUDIO_CONFIG_7_1_4, outConfig, tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK )
+ &sbaInput->crendWrapper,
+ AUDIO_CONFIG_7_1_4,
+ rendAudioConfigToIvasAudioConfig( outConfig ),
#endif
+ tmpCrendBuffer,
+ *sbaInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -4951,7 +5184,9 @@ static ivas_error renderActiveInputsSba(
return IVAS_ERR_OK;
}
-static void copyMasaMetadataToDiracRenderer( MASA_METADATA_FRAME *meta, DIRAC_DEC_HANDLE hDirAC )
+static void copyMasaMetadataToDiracRenderer(
+ MASA_METADATA_FRAME *meta,
+ DIRAC_DEC_HANDLE hDirAC )
{
int16_t band, sf, bin;
@@ -4981,9 +5216,13 @@ static void copyMasaMetadataToDiracRenderer( MASA_METADATA_FRAME *meta, DIRAC_DE
}
}
}
+
+ return;
}
-static ivas_error renderMasaToMc( input_masa *masaInput, IVAS_REND_AudioBuffer outAudio )
+static ivas_error renderMasaToMc(
+ input_masa *masaInput,
+ IVAS_REND_AudioBuffer outAudio )
{
float tmpBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k];
@@ -5005,7 +5244,9 @@ static ivas_error renderMasaToMc( input_masa *masaInput, IVAS_REND_AudioBuffer o
return IVAS_ERR_OK;
}
-static ivas_error renderMasaToSba( input_masa *masaInput, IVAS_REND_AudioBuffer outAudio )
+static ivas_error renderMasaToSba(
+ input_masa *masaInput,
+ IVAS_REND_AudioBuffer outAudio )
{
float tmpBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k];
@@ -5019,7 +5260,9 @@ static ivas_error renderMasaToSba( input_masa *masaInput, IVAS_REND_AudioBuffer
return IVAS_ERR_OK;
}
-static ivas_error renderMasaToBinaural( input_masa *masaInput, IVAS_REND_AudioBuffer outAudio )
+static ivas_error renderMasaToBinaural(
+ input_masa *masaInput,
+ IVAS_REND_AudioBuffer outAudio )
{
float tmpBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k];
@@ -5035,7 +5278,7 @@ static ivas_error renderMasaToBinaural( input_masa *masaInput, IVAS_REND_AudioBu
static ivas_error renderInputMasa(
input_masa *masaInput,
- IVAS_REND_AudioConfig outConfig,
+ const IVAS_REND_AudioConfig outConfig,
IVAS_REND_AudioBuffer outAudio )
{
ivas_error error;
@@ -5110,9 +5353,7 @@ static ivas_error renderActiveInputsMasa(
/* Skip inactive inputs */
continue;
}
- if ( ( error = renderInputMasa( pCurrentInput,
- hIvasRend->outputConfig,
- outAudio ) ) != IVAS_ERR_OK )
+ if ( ( error = renderInputMasa( pCurrentInput, hIvasRend->outputConfig, outAudio ) ) != IVAS_ERR_OK )
{
return error;
}
@@ -5121,9 +5362,17 @@ static ivas_error renderActiveInputsMasa(
return IVAS_ERR_OK;
}
+
+/*-------------------------------------------------------------------*
+ * IVAS_REND_GetSamples()
+ *
+ *
+ *-------------------------------------------------------------------*/
+
ivas_error IVAS_REND_GetSamples(
- IVAS_REND_HANDLE hIvasRend,
- IVAS_REND_AudioBuffer outAudio )
+ IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */
+ IVAS_REND_AudioBuffer outAudio /* i/o: buffer for output audio */
+)
{
ivas_error error;
int16_t numOutChannels;
@@ -5187,8 +5436,16 @@ ivas_error IVAS_REND_GetSamples(
return IVAS_ERR_OK;
}
+
+/*-------------------------------------------------------------------*
+ * IVAS_REND_Close()
+ *
+ *
+ *-------------------------------------------------------------------*/
+
void IVAS_REND_Close(
- IVAS_REND_HANDLE *phIvasRend )
+ IVAS_REND_HANDLE *phIvasRend /* i/o: Pointer to renderer handle */
+)
{
uint16_t i;
IVAS_REND_HANDLE hIvasRend;
@@ -5238,6 +5495,12 @@ void IVAS_REND_Close(
}
#ifdef DEBUGGING
+/*-------------------------------------------------------------------*
+ * IVAS_REND_GetNoCLipping()
+ *
+ *
+ *-------------------------------------------------------------------*/
+
int32_t IVAS_REND_GetNoCLipping(
IVAS_REND_CONST_HANDLE hIvasRend )
{
@@ -5255,23 +5518,3 @@ int32_t IVAS_REND_GetCntFramesLimited(
return hIvasRend->hLimiter->cnt_frames_limited;
}
#endif
-
-#ifdef FIX_197_CREND_INTERFACE
-ivas_error ivas_rend_initEfap(
- AUDIO_CONFIG outConfig,
- EFAP_HANDLE *hEfap )
-{
- ivas_error err;
- IVAS_REND_AudioConfig audioCfg;
- EFAP_WRAPPER wrap;
- LSSETUP_CUSTOM_STRUCT customLsOut;
- wrap.hEfap = NULL;
- wrap.pCustomLsSetup = NULL;
- audioCfg = getRendAudioConfigFromIvasAudioConfig( outConfig );
- memset( &customLsOut, 0, sizeof( LSSETUP_CUSTOM_STRUCT ) );
- err = initEfap( &wrap, audioCfg, &customLsOut );
- *hEfap = wrap.hEfap;
-
- return err;
-}
-#endif
diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h
index b2ca45c70c5e877cc5d123d74b8baaf0af112b20..1a7738d37fe979f5612946bb0fc478751f4d5c32 100644
--- a/lib_rend/lib_rend.h
+++ b/lib_rend/lib_rend.h
@@ -33,25 +33,17 @@
#ifndef LIB_REND_H
#define LIB_REND_H
+#include "common_api_types.h"
+#include "ivas_error.h"
#include
#include
-#include
-#include "options.h"
-#include "common_api_types.h"
-#include "ivas_error.h"
-#ifdef FIX_197_CREND_INTERFACE
-#include "ivas_stat_rend.h"
-#endif
#define RENDERER_MAX_ISM_INPUTS 4
#define RENDERER_MAX_MC_INPUTS 1
#define RENDERER_MAX_SBA_INPUTS 1
#define RENDERER_MAX_MASA_INPUTS 1
-#ifndef FIX_197_CREND_INTERFACE
-
-#define RENDERER_HEAD_POSITIONS_PER_FRAME 4
typedef float IVAS_REND_LfePanMtx[IVAS_MAX_INPUT_LFE_CHANNELS][IVAS_MAX_OUTPUT_CHANNELS];
@@ -73,12 +65,6 @@ typedef struct
const float *data;
} IVAS_REND_ReadOnlyAudioBuffer;
-typedef struct
-{
- float azimuth;
- float elevation;
-} IVAS_REND_AudioObjectPosition;
-
typedef struct IVAS_REND *IVAS_REND_HANDLE;
typedef struct IVAS_REND const *IVAS_REND_CONST_HANDLE;
@@ -140,13 +126,6 @@ typedef enum
typedef uint16_t IVAS_REND_InputId;
-#else
-
-AUDIO_CONFIG getIvasAudioConfigFromRendAudioConfig(
- IVAS_REND_AudioConfig config );
-
-#endif
-
/* clang-format off */
/*----------------------------------------------------------------------------------*
* Function prototypes
@@ -176,7 +155,7 @@ ivas_error IVAS_REND_SetCustomHrtf(
/* Functions to be called before/during rendering */
ivas_error IVAS_REND_NumOutChannels(
- IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */
+ IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */
int16_t *numOutChannels /* o : number of output channels */
);
@@ -251,18 +230,18 @@ ivas_error IVAS_REND_FeedInputMasaMetadata(
);
ivas_error IVAS_REND_InitConfig(
- IVAS_REND_HANDLE st, /* i/o: Renderer handle */
- bool rendererConfigEnabled /* i : flag indicating if a renderer configuration file was supplied */
+ IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */
+ const bool rendererConfigEnabled /* i : flag indicating if a renderer configuration file was supplied */
);
int16_t IVAS_REND_GetRenderConfig(
- IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS decoder handle */
- const IVAS_RENDER_CONFIG_HANDLE hRCout /* o : Render configuration handle */
+ IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS decoder handle */
+ const IVAS_RENDER_CONFIG_HANDLE hRCout /* o : Render configuration handle */
);
int16_t IVAS_REND_FeedRenderConfig(
- IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS decoder handle */
- const IVAS_RENDER_CONFIG_DATA renderConfig /* i : Render configuration struct */
+ IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS decoder handle */
+ const IVAS_RENDER_CONFIG_DATA renderConfig /* i : Render configuration struct */
);
ivas_error IVAS_REND_SetHeadRotation(
@@ -291,12 +270,6 @@ int32_t IVAS_REND_GetCntFramesLimited(
);
#endif
-#ifdef FIX_197_CREND_INTERFACE
-ivas_error ivas_rend_initEfap(
- AUDIO_CONFIG outConfig,
- EFAP_HANDLE *hEfap
- );
-#endif
/* clang-format on */
#endif
diff --git a/lib_util/cmdl_tools.c b/lib_util/cmdl_tools.c
index d9e4d5386ed2fac264b66552698cfb562bb03680..b0b7e906cca95b1bb64e66a62677ec1ef1eb21e9 100644
--- a/lib_util/cmdl_tools.c
+++ b/lib_util/cmdl_tools.c
@@ -31,6 +31,7 @@
*******************************************************************************************************/
#include "cmdl_tools.h"
+#include
/*---------------------------------------------------------------------*
* to_upper()
@@ -141,3 +142,86 @@ bool is_number( const char *str )
return true;
}
+
+
+/*---------------------------------------------------------------------*
+ * convert_backslash()
+ *
+ *
+ *---------------------------------------------------------------------*/
+
+void convert_backslash(
+ char *str )
+{
+ int16_t i, len;
+
+ /* check that all backslashes are correct on the given platform */
+ len = (int16_t) strlen( str );
+
+ for ( i = 0; i < len; i++ )
+ {
+#ifdef _WIN32
+ if ( str[i] == '/' )
+ {
+ str[i] = '\\';
+ }
+#else
+ if ( str[i] == '\\' )
+ {
+ str[i] = '/';
+ }
+#endif
+ }
+
+ return;
+}
+
+/*---------------------------------------------------------------------*
+ * remove_cr()
+ *
+ *
+ *---------------------------------------------------------------------*/
+
+void remove_cr(
+ char *str )
+{
+ char *pos;
+
+ /* remove all \r characters from the string */
+ pos = strchr( str, '\r' );
+ while ( pos != NULL )
+ {
+ strcpy( pos, pos + 1 );
+ pos = strchr( pos, '\r' );
+ }
+
+ return;
+}
+
+
+/*---------------------------------------------------------------------*
+ * clearString()
+ *
+ *
+ *---------------------------------------------------------------------*/
+
+void clearString(
+ char *str )
+{
+ str[0] = '\0';
+
+ return;
+}
+
+
+/*---------------------------------------------------------------------*
+ * isEmptyString()
+ *
+ *
+ *---------------------------------------------------------------------*/
+
+bool isEmptyString(
+ const char *str )
+{
+ return str[0] == '\0';
+}
diff --git a/lib_util/cmdl_tools.h b/lib_util/cmdl_tools.h
index 92dba6c1e1e8085c0777f47f9b553c5524a8c052..b160473002930dd2c980d9bfbdcfb8e1bad3722a 100644
--- a/lib_util/cmdl_tools.h
+++ b/lib_util/cmdl_tools.h
@@ -42,5 +42,12 @@ bool is_number( const char *str );
char *to_upper( char *str );
+void convert_backslash( char *str );
+
+void remove_cr( char *str );
+
+void clearString( char *str );
+
+bool isEmptyString( const char *str );
#endif /* CMDL_TOOLS_H */
diff --git a/lib_util/cmdln_parser.c b/lib_util/cmdln_parser.c
index 2a29505a393e6dd603928add74b0863f8d252d12..860765476abb481b0284551b34c5812ecd43d5fd 100644
--- a/lib_util/cmdln_parser.c
+++ b/lib_util/cmdln_parser.c
@@ -48,7 +48,9 @@ typedef struct
int8_t hasBeenParsed;
} Option;
-static int16_t validateNoDuplicateIds( const OptionProps *props, int32_t numOpts )
+static int16_t validateNoDuplicateIds(
+ const OptionProps *props,
+ int32_t numOpts )
{
for ( int32_t i = 0; i < numOpts; ++i )
{
@@ -65,7 +67,8 @@ static int16_t validateNoDuplicateIds( const OptionProps *props, int32_t numOpts
return 0;
}
-static int16_t validateOptionProps( OptionProps props )
+static int16_t validateOptionProps(
+ OptionProps props )
{
/* Check required properties */
if ( props.match == NULL )
@@ -85,7 +88,10 @@ static int16_t validateOptionProps( OptionProps props )
}
/* Validate given OptionProps and use them to initialize array of Options */
-static int16_t initOpts( const OptionProps *options, int32_t numOpts, Option *opts )
+static int16_t initOpts(
+ const OptionProps *options,
+ const int32_t numOpts,
+ Option *opts )
{
for ( int32_t i = 0; i < numOpts; ++i )
{
@@ -111,7 +117,8 @@ static int16_t initOpts( const OptionProps *options, int32_t numOpts, Option *op
return 0;
}
-static int8_t stringLooksLikeOption( const char *str )
+static int8_t stringLooksLikeOption(
+ const char *str )
{
if ( str[0] == '-' )
{
@@ -121,7 +128,8 @@ static int8_t stringLooksLikeOption( const char *str )
return 0;
}
-static const char *stringToOptionName( const char *str )
+static const char *stringToOptionName(
+ const char *str )
{
while ( *str == '-' )
{
@@ -131,7 +139,9 @@ static const char *stringToOptionName( const char *str )
return str;
}
-static int8_t optionMatchesString( Option opt, const char *str )
+static int8_t optionMatchesString(
+ Option opt,
+ const char *str )
{
if ( !stringLooksLikeOption( str ) )
{
@@ -148,12 +158,13 @@ static int8_t optionMatchesString( Option opt, const char *str )
return 0;
}
-static int16_t parseOpts( int32_t argc,
- char **argv,
- Option *opts,
- int32_t numOpts,
- void *pOutputStruct,
- CmdLnParser_FnPtr_ParseOption parseOption )
+static int16_t parseOpts(
+ int32_t argc,
+ char **argv,
+ Option *opts,
+ const int32_t numOpts,
+ void *pOutputStruct,
+ CmdLnParser_FnPtr_ParseOption parseOption )
{
Option *currOpt = NULL;
int32_t currOptIdx = 1;
@@ -234,7 +245,8 @@ static int16_t parseOpts( int32_t argc,
return 0;
}
-static const char *getBasename( const char *path )
+static const char *getBasename(
+ const char *path )
{
/* Find last forward slash in path */
const char *namePtr = strrchr( path, '/' );
@@ -254,12 +266,14 @@ static const char *getBasename( const char *path )
return path;
}
-static int32_t totalOptionNameLength( const OptionProps opt )
+static int32_t totalOptionNameLength(
+ const OptionProps opt )
{
return strlen( opt.match ) + strlen( opt.matchShort );
}
-static void printWhitespace( int32_t n )
+static void printWhitespace(
+ const int32_t n )
{
for ( int32_t i = 0; i < n; ++i )
{
@@ -267,7 +281,9 @@ static void printWhitespace( int32_t n )
}
}
-static void printOptDescriptionAligned( const char *descPtr, int32_t descriptionColumnIdx )
+static void printOptDescriptionAligned(
+ const char *descPtr,
+ int32_t descriptionColumnIdx )
{
if ( descPtr == NULL )
{
@@ -290,12 +306,14 @@ static void printOptDescriptionAligned( const char *descPtr, int32_t description
}
++descPtr;
}
+
+ return;
}
static void printUsage(
const char *argv0,
const OptionProps *optionProps,
- int32_t numOptions )
+ const int32_t numOptions )
{
fprintf( stderr, "\n" );
fprintf( stderr, "Usage: %s [options]\n", getBasename( argv0 ) );
@@ -326,14 +344,17 @@ static void printUsage(
printWhitespace( maxOptNameLength - optNameLength + preDescriptionWhitespace );
printOptDescriptionAligned( opt.description, maxOptNameLength + preDescriptionWhitespace + leftColumnAdditionalChars );
}
+
+ return;
}
-int16_t CmdLnParser_parseArgs( int32_t argc,
- char **argv,
- const OptionProps *optionProps,
- int32_t numOptions,
- void *pOutputStruct,
- CmdLnParser_FnPtr_ParseOption parseOption )
+int16_t CmdLnParser_parseArgs(
+ int32_t argc,
+ char **argv,
+ const OptionProps *optionProps,
+ const int32_t numOptions,
+ void *pOutputStruct,
+ CmdLnParser_FnPtr_ParseOption parseOption )
{
assert( numOptions <= MAX_SUPPORTED_OPTS );
@@ -357,9 +378,12 @@ fail:
return -1;
}
-void CmdLnParser_printUsage( char *executableName,
- const CmdLnParser_Option *options,
- int32_t numOptions )
+void CmdLnParser_printUsage(
+ char *executableName,
+ const CmdLnParser_Option *options,
+ const int32_t numOptions )
{
printUsage( executableName, options, numOptions );
+
+ return;
}
diff --git a/lib_util/cmdln_parser.h b/lib_util/cmdln_parser.h
index b5db25c19325be5f8a6b881ae8c9b0edfb00e49a..61f3ad4a30e2c2eec3136fbb52c4c806f25fa61e 100644
--- a/lib_util/cmdln_parser.h
+++ b/lib_util/cmdln_parser.h
@@ -47,21 +47,10 @@ typedef struct
} CmdLnParser_Option;
/* Function for parsing option values into an output struct, to be implemented by the user */
-typedef void ( *CmdLnParser_FnPtr_ParseOption )( int32_t optionId, /* i : option ID of matched option */
- char **optionValues, /* i : array of string values following the matched option in argv */
- int16_t numOptionValues, /* i : number of string values following the matched option in argv */
- void *pOutputStruct /* o : struct to store parsed values */
-);
+typedef void ( *CmdLnParser_FnPtr_ParseOption )( int32_t optionId, char **optionValues, int16_t numOptionValues, void *pOutputStruct );
-int16_t CmdLnParser_parseArgs( int32_t argc,
- char **argv,
- const CmdLnParser_Option *options,
- int32_t numOptions,
- void *pOutputStruct,
- CmdLnParser_FnPtr_ParseOption parseOption );
+int16_t CmdLnParser_parseArgs( int32_t argc, char **argv, const CmdLnParser_Option *options, const int32_t numOptions, void *pOutputStruct, CmdLnParser_FnPtr_ParseOption parseOption );
-void CmdLnParser_printUsage( char *executableName,
- const CmdLnParser_Option *options,
- int32_t numOptions );
+void CmdLnParser_printUsage( char *executableName, const CmdLnParser_Option *options, const int32_t numOptions );
#endif /* CMDLN_PARSER_H */
diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c
index c52b06d6f0aef4831c8c9120ecf22644fa548450..c58bb27000c222bed22a6790c4c1d6a74e461271 100644
--- a/lib_util/hrtf_file_reader.c
+++ b/lib_util/hrtf_file_reader.c
@@ -33,10 +33,13 @@
#include "hrtf_file_reader.h"
#include
#include
-#include "prot.h" // VE: !!!!!
-#include "ivas_prot.h" // VE: !!!!!
+#include "prot.h"
+#include "ivas_prot_rend.h"
-#include "lib_dec.h"
+
+/*---------------------------------------------------------------------*
+ * Local structures
+ *---------------------------------------------------------------------*/
struct hrtfFileReader
{
@@ -44,6 +47,16 @@ struct hrtfFileReader
char *file_path;
};
+typedef struct ivas_hrtfs_file_header_t
+{
+ char identifier[8];
+ int32_t file_size;
+ int16_t nb_hrtf;
+ int32_t max_data_size;
+
+} ivas_hrtfs_file_header_t;
+
+
/*---------------------------------------------------------------------*
* Local constants
*---------------------------------------------------------------------*/
@@ -124,15 +137,17 @@ void hrtfFileReader_close(
* Check the HRTF file header read from binary file
--------------------------------------------------------------------*/
-static ivas_error read_and_check_hrtf_binary_file_header( ivas_hrtfs_file_header_t *hrtf_file_header, FILE *f_hrtf )
+static ivas_error read_and_check_hrtf_binary_file_header(
+ ivas_hrtfs_file_header_t *hrtf_file_header,
+ FILE *f_hrtf )
{
int32_t file_size;
- // [Declaration of the binary file]
- // File Identifier (8 bytes)
- // Size of file in bytes (4 bytes)
- // Number of HRTF (2 bytes)
- // Max length of HRTF data (4 bytes)
+ /* [Declaration of the binary file] */
+ /* File Identifier (8 bytes) */
+ /* Size of file in bytes (4 bytes) */
+ /* Number of HRTF (2 bytes) */
+ /* Max length of HRTF data (4 bytes) */
fseek( f_hrtf, 0, SEEK_END );
file_size = ftell( f_hrtf );
@@ -168,9 +183,10 @@ static ivas_error read_and_check_hrtf_binary_file_header( ivas_hrtfs_file_header
* Check the HRTF section header - read from binary file
--------------------------------------------------------------------*/
-static ivas_error check_hrtf_binary_header( ivas_hrtfs_header_t *hrtf_header )
+static ivas_error check_hrtf_binary_header(
+ ivas_hrtfs_header_t *hrtf_header )
{
- // Check the renderer type
+ /* Check the renderer type */
if ( ( hrtf_header->rend_type != RENDERER_BINAURAL_MIXER_CONV ) && ( hrtf_header->rend_type != RENDERER_BINAURAL_MIXER_CONV_ROOM ) &&
( hrtf_header->rend_type != RENDERER_BINAURAL_FASTCONV ) && ( hrtf_header->rend_type != RENDERER_BINAURAL_FASTCONV_ROOM ) &&
( hrtf_header->rend_type != RENDERER_BINAURAL_PARAMETRIC ) && ( hrtf_header->rend_type != RENDERER_BINAURAL_PARAMETRIC_ROOM ) &&
@@ -179,34 +195,37 @@ static ivas_error check_hrtf_binary_header( ivas_hrtfs_header_t *hrtf_header )
return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Header of HRTF binary file not compliant (renderer type)" );
}
- // Check the output format of the decoder
+ /* Check the output format of the decoder */
if ( ( hrtf_header->input_cfg != BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) && ( hrtf_header->input_cfg != BINAURAL_INPUT_AUDIO_CONFIG_HOA ) && ( hrtf_header->input_cfg != BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED ) )
{
return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Header of HRTF binary file not compliant (input audio configuration)" );
}
- // Check the sampling frequency
+ /* Check the sampling frequency */
if ( ( hrtf_header->frequency != 48000 ) && ( hrtf_header->frequency != 32000 ) && ( hrtf_header->frequency != 16000 ) )
{
- return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Header of HRTF binary file not compliant (sampling frequency)" );
+ return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Header of HRTF binary file not compliant (sampling frequency)" );
}
return IVAS_ERR_OK;
}
+
/*-------------------------------------------------------------------*
* read_hrtf_binary_header()
*
* Read the HRTF header from binary file
--------------------------------------------------------------------*/
-static ivas_error read_hrtf_binary_header( ivas_hrtfs_header_t *hrtf_header, FILE *f_hrtf )
+static ivas_error read_hrtf_binary_header(
+ ivas_hrtfs_header_t *hrtf_header,
+ FILE *f_hrtf )
{
- // HRTF Header
- // Renderer type (4 bytes) : See "RENDERER_TYPE"
- // Input configuration (4 bytes) : See "BINAURAL_INPUT_AUDIO_CONFIG"
- // Sampling Frequency (4 bytes)
- // Raw data size (4 bytes)
+ /* HRTF Header */
+ /* Renderer type (4 bytes) : See "RENDERER_TYPE" */
+ /* Input configuration (4 bytes) : See "BINAURAL_INPUT_AUDIO_CONFIG" */
+ /* Sampling Frequency (4 bytes) */
+ /* Raw data size (4 bytes) */
if ( ( fread( &( hrtf_header->rend_type ), sizeof( int32_t ), 1, f_hrtf ) == 1 ) && ( fread( &( hrtf_header->input_cfg ), sizeof( int32_t ), 1, f_hrtf ) == 1 ) && ( fread( &( hrtf_header->frequency ), sizeof( int32_t ), 1, f_hrtf ) == 1 ) && ( fread( &( hrtf_header->data_size ), sizeof( int32_t ), 1, f_hrtf ) == 1 ) )
{
@@ -415,6 +434,7 @@ static ivas_error LoadBSplineBinary(
return IVAS_ERR_OK;
}
+
/*-------------------------------------------------------------------*
* TDREND_MIX_LoadHRTF()
*
@@ -428,8 +448,6 @@ static ivas_error TDREND_MIX_LoadHRTF(
{
int16_t tmp;
ivas_error error;
-
-
bool is_tdrend;
ivas_error header_check_result;
ivas_hrtfs_file_header_t hrtfs_file_header;
@@ -438,7 +456,6 @@ static ivas_error TDREND_MIX_LoadHRTF(
int32_t hrtf_data_size_max;
char *hrtf_data;
-
error = IVAS_ERR_OK;
@@ -702,6 +719,7 @@ static ivas_error ivas_hrtf_init(
return IVAS_ERR_OK;
}
+
/*---------------------------------------------------------------------*
* create_HRTF_from_rawdata()
*
@@ -713,7 +731,7 @@ static ivas_error create_HRTF_from_rawdata(
char *hrtf_data /* i: pointer to binary file */
)
{
- int i, j, k;
+ int16_t i, j, k;
int16_t max_num_iterations_diffuse;
uint16_t max_total_num_fsamp_per_iteration, max_total_num_fsamp_per_iteration_diff;
uint32_t mem_size;
@@ -736,26 +754,26 @@ static ivas_error create_HRTF_from_rawdata(
hrtf_data_rptr = hrtf_data;
- // latency_s
+ /* latency_s */
( *hHRTF )->latency_s = *( (float *) ( hrtf_data_rptr ) );
hrtf_data_rptr += sizeof( float );
- // max_num_ir
+ /* max_num_ir */
( *hHRTF )->max_num_ir = *( (uint16_t *) ( hrtf_data_rptr ) );
hrtf_data_rptr += sizeof( uint16_t );
- // BINAURAL_CHANNELS
+ /* BINAURAL_CHANNELS */
if ( BINAURAL_CHANNELS != *( (int16_t *) ( hrtf_data_rptr ) ) )
{
return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file format not compliant (BINAURAL_CHANNELS)" );
}
hrtf_data_rptr += sizeof( uint16_t );
- // max_num_iterations
+ /* max_num_iterations */
( *hHRTF )->max_num_iterations = *( (int16_t *) ( hrtf_data_rptr ) );
hrtf_data_rptr += sizeof( int16_t );
- // num_iterations
+ /* num_iterations */
for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ )
{
for ( j = 0; j < BINAURAL_CHANNELS; j++ )
@@ -765,7 +783,7 @@ static ivas_error create_HRTF_from_rawdata(
}
}
- // pIndex_frequency_max
+ /* pIndex_frequency_max */
for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ )
{
for ( j = 0; j < BINAURAL_CHANNELS; j++ )
@@ -781,20 +799,20 @@ static ivas_error create_HRTF_from_rawdata(
}
}
- // max_num_iterations_diffuse
+ /* max_num_iterations_diffuse */
max_num_iterations_diffuse = *( (int16_t *) ( hrtf_data_rptr ) );
hrtf_data_rptr += sizeof( int16_t );
if ( max_num_iterations_diffuse != 0 )
{
- // num_iterations_diffuse
+ /* num_iterations_diffuse */
for ( j = 0; j < BINAURAL_CHANNELS; j++ )
{
( *hHRTF )->num_iterations_diffuse[j] = *( (uint16_t *) ( hrtf_data_rptr ) );
hrtf_data_rptr += sizeof( uint16_t );
}
- // pIndex_frequency_max_diffuse (the size depends on num_iterations_diffuse)
+ /* pIndex_frequency_max_diffuse (the size depends on num_iterations_diffuse) */
for ( j = 0; j < BINAURAL_CHANNELS; j++ )
{
mem_size = ( *hHRTF )->num_iterations_diffuse[j] * sizeof( uint16_t );
@@ -808,22 +826,22 @@ static ivas_error create_HRTF_from_rawdata(
}
}
- // index_frequency_max_diffuse
+ /* index_frequency_max_diffuse */
( *hHRTF )->index_frequency_max_diffuse = *( (uint16_t *) ( hrtf_data_rptr ) );
hrtf_data_rptr += sizeof( uint16_t );
- // inv_diffuse_weight
+ /* inv_diffuse_weight */
for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ )
{
( *hHRTF )->inv_diffuse_weight[i] = *( (float *) ( hrtf_data_rptr ) );
hrtf_data_rptr += sizeof( float );
}
- // max_total_num_fsamp_per_iteration
+ /* max_total_num_fsamp_per_iteration */
max_total_num_fsamp_per_iteration = *( (uint16_t *) ( hrtf_data_rptr ) );
hrtf_data_rptr += sizeof( uint16_t );
- // coeff_re (the size depends on pIndex_frequency_max)
+ /* coeff_re (the size depends on pIndex_frequency_max) */
for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ )
{
for ( j = 0; j < BINAURAL_CHANNELS; j++ )
@@ -847,7 +865,7 @@ static ivas_error create_HRTF_from_rawdata(
}
}
- // coeff_im (the size depends on pIndex_frequency_max)
+ /* coeff_im (the size depends on pIndex_frequency_max) */
for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ )
{
for ( j = 0; j < BINAURAL_CHANNELS; j++ )
@@ -871,13 +889,13 @@ static ivas_error create_HRTF_from_rawdata(
}
}
- // max_total_num_fsamp_per_iteration_diff
+ /* max_total_num_fsamp_per_iteration_diff */
max_total_num_fsamp_per_iteration_diff = *( (uint16_t *) ( hrtf_data_rptr ) );
hrtf_data_rptr += sizeof( uint16_t );
if ( max_total_num_fsamp_per_iteration_diff != 0 )
{
- // coeff_diffuse_re : The size depends on pIndex_frequency_max_diffuse
+ /* coeff_diffuse_re : The size depends on pIndex_frequency_max_diffuse */
for ( j = 0; j < BINAURAL_CHANNELS; j++ )
{
mem_size = max_total_num_fsamp_per_iteration_diff * sizeof( float );
@@ -898,7 +916,7 @@ static ivas_error create_HRTF_from_rawdata(
}
}
- // coeff_diffuse_im : The size depends on pIndex_frequency_max_diffuse
+ /* coeff_diffuse_im : The size depends on pIndex_frequency_max_diffuse */
for ( j = 0; j < BINAURAL_CHANNELS; j++ )
{
mem_size = max_total_num_fsamp_per_iteration_diff * sizeof( float );
@@ -976,6 +994,7 @@ static ivas_error init_fastconv_HRTF_handle(
return IVAS_ERR_OK;
}
+
static ivas_error create_fastconv_HRTF_from_rawdata(
HRTFS_FASTCONV_HANDLE *hHRTF, /* i/o: HRTF FastConv handle */
char *hrtf_data, /* i : pointer to binary file */
@@ -983,7 +1002,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata(
BINAURAL_INPUT_AUDIO_CONFIG input_cfg /* i : Input binaural config */
)
{
- int i, j;
+ int16_t i, j;
char *hrtf_data_rptr;
// if ( hHRTF == NULL )
@@ -1002,14 +1021,14 @@ static ivas_error create_fastconv_HRTF_from_rawdata(
hrtf_data_rptr = hrtf_data;
- // BINAURAL_CONVBANDS
+ /* BINAURAL_CONVBANDS */
if ( BINAURAL_CONVBANDS != *( (uint16_t *) ( hrtf_data_rptr ) ) )
{
return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_CONVBANDS)" );
}
hrtf_data_rptr += sizeof( uint16_t );
- // HRIR
+ /* HRIR */
if ( rend_type == RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED )
{
( *hHRTF )->FASTCONV_HRIR_latency_s = *( (float *) ( hrtf_data_rptr ) );
@@ -1062,7 +1081,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata(
}
if ( rend_type == RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA )
{
- // HRIR_HOA3
+ /* HRIR_HOA3 */
( *hHRTF )->FASTCONV_HOA3_latency_s = *( (float *) ( hrtf_data_rptr ) );
hrtf_data_rptr += sizeof( float );
@@ -1111,7 +1130,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata(
}
}
}
- // BRIR
+ /* BRIR */
if ( rend_type == RENDERER_BINAURAL_FASTCONV_ROOM && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED )
{
( *hHRTF )->FASTCONV_BRIR_latency_s = *( (float *) ( hrtf_data_rptr ) );
@@ -1162,7 +1181,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata(
}
}
- // Reverb Parameters
+ /* Reverb Parameters */
if ( CLDFB_NO_CHANNELS_MAX != *( (uint16_t *) ( hrtf_data_rptr ) ) )
{
return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (CLDFB_NO_CHANNELS_MAX)" );
@@ -1175,9 +1194,17 @@ static ivas_error create_fastconv_HRTF_from_rawdata(
memcpy( ( *hHRTF )->fastconvReverberationEneCorrections, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) );
hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float );
}
+
return IVAS_ERR_OK;
}
+
+/*---------------------------------------------------------------------*
+ * load_fastconv_HRTF_from_binary()
+ *
+ * Load FastConv HRTF binary data into the handle
+ *---------------------------------------------------------------------*/
+
ivas_error load_fastconv_HRTF_from_binary(
IVAS_DEC_HRTF_FASTCONV_HANDLE hHrtfFastConv, /* i/o: FastConv HRTF handle */
const hrtfFileReader *hrtfReader /* i : pointer to hrtfFileReader handle */
@@ -1234,7 +1261,7 @@ ivas_error load_fastconv_HRTF_from_binary(
return IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF file reading" );
}
- // Create the HRTF reading the raw data from the binary file
+ /* Create the HRTF reading the raw data from the binary file */
if ( ( create_fastconv_HRTF_from_rawdata( &hHrtfFastConv, hrtf_data, hrtf_header.rend_type, hrtf_header.input_cfg ) ) != IVAS_ERR_OK )
{
free( hrtf_data );
@@ -1252,32 +1279,38 @@ ivas_error load_fastconv_HRTF_from_binary(
}
+/*---------------------------------------------------------------------*
+ * create_parambin_HRTF_from_rawdata()
+ *
+ *
+ *---------------------------------------------------------------------*/
+
static ivas_error create_parambin_HRTF_from_rawdata(
HRTFS_PARAMBIN_HANDLE *hHRTF, /* i/o: Parametric binauralizer HRTF handle */
char *hrtf_data /* i : pointer to binary file */
)
{
- int i, j;
+ int16_t i, j;
char *hrtf_data_rptr;
uint32_t data_size_tmp;
hrtf_data_rptr = hrtf_data;
- // HRTF_SH_CHANNELS
+ /* HRTF_SH_CHANNELS */
if ( HRTF_SH_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) )
{
return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_SH_CHANNELS)" );
}
hrtf_data_rptr += sizeof( uint16_t );
- // HRTF_NUM_BINS
+ /* HRTF_NUM_BINS */
if ( HRTF_NUM_BINS != *( (uint16_t *) ( hrtf_data_rptr ) ) )
{
return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_NUM_BINS)" );
}
hrtf_data_rptr += sizeof( uint16_t );
- // HRTF
+ /* HRTF */
data_size_tmp = HRTF_NUM_BINS * sizeof( float );
for ( i = 0; i < BINAURAL_CHANNELS; i++ )
{
@@ -1296,7 +1329,7 @@ static ivas_error create_parambin_HRTF_from_rawdata(
}
}
- // Reverb Parameters
+ /* Reverb Parameters */
if ( CLDFB_NO_CHANNELS_MAX != *( (uint16_t *) ( hrtf_data_rptr ) ) )
{
return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (CLDFB_NO_CHANNELS_MAX)" );
@@ -1315,6 +1348,13 @@ static ivas_error create_parambin_HRTF_from_rawdata(
return IVAS_ERR_OK;
}
+
+/*---------------------------------------------------------------------*
+ * load_parambin_HRTF_from_binary()
+ *
+ * Load parametric binauralizer HRTF binary data into the handle
+ *---------------------------------------------------------------------*/
+
ivas_error load_parambin_HRTF_from_binary(
IVAS_DEC_HRTF_PARAMBIN_HANDLE hHrtfParamBin, /* i/o: Parametric binauralizer HRTF handle */
const hrtfFileReader *hrtfReader /* i : pointer to hrtfFileReader handle */
@@ -1369,7 +1409,7 @@ ivas_error load_parambin_HRTF_from_binary(
return IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF file reading" );
}
- // Create the HRTF reading the raw data from the binary file
+ /* Create the HRTF reading the raw data from the binary file */
if ( ( create_parambin_HRTF_from_rawdata( &hHrtfParamBin, hrtf_data ) ) != IVAS_ERR_OK )
{
free( hrtf_data );
@@ -1394,9 +1434,9 @@ ivas_error load_parambin_HRTF_from_binary(
*---------------------------------------------------------------------*/
ivas_error create_SetOfHRTF_from_binary(
- IVAS_DEC_HRTF_CREND_HANDLE hSetOfHRTF, /* i/o: HRTF CRend handle */
- const hrtfFileReader *hrtfReader, /* i: pointer to hrtfFileReader handle */
- int32_t output_Fs ) /* i: Output sampling frequency */
+ IVAS_DEC_HRTF_CREND_HANDLE hSetOfHRTF, /* i/o: HRTF CRend handle */
+ const hrtfFileReader *hrtfReader, /* i : pointer to hrtfFileReader handle */
+ int32_t output_Fs ) /* i : Output sampling frequency */
{
FILE *f_hrtf;
int32_t hrtf_data_size_max;
@@ -1470,7 +1510,7 @@ ivas_error create_SetOfHRTF_from_binary(
if ( hHRTF != NULL )
{
- // Create the HRTF reading the raw data from the binary file
+ /* Create the HRTF reading the raw data from the binary file */
if ( ( create_HRTF_from_rawdata( hHRTF, hrtf_data ) ) != IVAS_ERR_OK )
{
return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Could not create HRTF from binary file" );
diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h
index 3d9a901c24fd1927f9c387a9f2813875fc3667ab..5a7e413f81ef47b20f7edad687658b7d0d01432f 100644
--- a/lib_util/hrtf_file_reader.h
+++ b/lib_util/hrtf_file_reader.h
@@ -33,14 +33,21 @@
#ifndef IVAS_HRTF_FILE_READER_H
#define IVAS_HRTF_FILE_READER_H
-#include
#include "common_api_types.h"
#include "ivas_error.h"
-#include "options.h"
-
+// VE2AT: would it make sense to put includes of "ivas_error.h" into "common_api_types" in order to not repeate it again and again? -> YES, TBD
typedef struct hrtfFileReader hrtfFileReader;
+typedef struct ivas_hrtfs_header_t
+{
+ int32_t rend_type;
+ int32_t input_cfg;
+ int32_t frequency;
+ uint32_t data_size;
+
+} ivas_hrtfs_header_t;
+
/*---------------------------------------------------------------------*
* hrtfFileReader_open()
*
@@ -85,6 +92,7 @@ ivas_error create_SetOfHRTF_from_binary(
int32_t output_Fs /* i: Output sampling frequency */
);
+
/*---------------------------------------------------------------------*
* destroy_SetOfHRTF()
*
diff --git a/lib_util/ls_custom_file_reader.c b/lib_util/ls_custom_file_reader.c
index d2e823c816cb85e7e12de6600a4cb5226b87101b..ace442029d3c1d47a4c4ad59e149039f2678e6a0 100644
--- a/lib_util/ls_custom_file_reader.c
+++ b/lib_util/ls_custom_file_reader.c
@@ -34,8 +34,8 @@
#include
#include
#include
-#include "ivas_prot.h" // VE: !!!!!
-#include "prot.h" // VE: !!!!!
+#include "ivas_prot.h"
+#include "prot.h"
struct LsCustomFileReader
@@ -269,7 +269,7 @@ LS_CUSTOM_FILEREADER_ERROR CustomLsFileReading(
tok++;
}
- if ( *tok == '\0' )
+ if ( *tok == '\0' ) // replace by isEmptyString()
{
continue;
}
diff --git a/lib_util/masa_file_reader.c b/lib_util/masa_file_reader.c
index 29ef9e347a608545fa029452741293328eea44d8..58ecf35c822ac7eaab5cc85840993a41c4394269 100644
--- a/lib_util/masa_file_reader.c
+++ b/lib_util/masa_file_reader.c
@@ -31,7 +31,7 @@
*******************************************************************************************************/
#include "masa_file_reader.h"
-#include "ivas_prot.h" // VE: !!!!!
+#include "ivas_prot.h"
#include "ivas_stat_com.h"
#include
#include
diff --git a/lib_util/mime_io.c b/lib_util/mime_io.c
index b640512466a1633ae442ad2b4b5ad4341400aaf4..4615a9219decfe99acc45456dca757cb37bcad09 100644
--- a/lib_util/mime_io.c
+++ b/lib_util/mime_io.c
@@ -33,7 +33,7 @@
#include "options.h"
#include "mime_io.h"
#include "mime.h"
-#include "prot.h" // VE: !!!!!
+#include "prot.h"
#include "string.h"
#include
#include
diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c
index 3ade7e576a2885837c42fe623648488219bd6dd1..c71590593804d49194799fae992577cbea892b1e 100644
--- a/lib_util/render_config_reader.c
+++ b/lib_util/render_config_reader.c
@@ -37,7 +37,7 @@
#include
#include
#include "cmdl_tools.h"
-#include "prot.h" // VE: !!!!!
+#include "prot.h"
/*------------------------------------------------------------------------------------------*
diff --git a/scripts/binauralRenderer_interface/Table_Format_Converter/generate_tables_from_rom_to_bin.c b/scripts/binauralRenderer_interface/Table_Format_Converter/generate_tables_from_rom_to_bin.c
index 89a33e1d45cfa5cce857908b87b017e43f23f73c..a0e2ddd94ce4f4c69f1fdc3fcb758aa2dd869965 100644
--- a/scripts/binauralRenderer_interface/Table_Format_Converter/generate_tables_from_rom_to_bin.c
+++ b/scripts/binauralRenderer_interface/Table_Format_Converter/generate_tables_from_rom_to_bin.c
@@ -38,6 +38,8 @@
#include "ivas_rom_binaural_crend_head.h"
#include "lib_rend.h"
#include "ivas_stat_dec.h"
+#include "hrtf_file_reader.h"
+
#define FILE_HEADER