diff --git a/Workspace_msvc/lib_debug.vcxproj b/Workspace_msvc/lib_debug.vcxproj index 7a2fcecef1353bc4e7bf229c4e584957bb3e89b9..1faca1b17c15de73e48646d09e9c798f5f45061c 100644 --- a/Workspace_msvc/lib_debug.vcxproj +++ b/Workspace_msvc/lib_debug.vcxproj @@ -73,7 +73,7 @@ Disabled - ..\lib_util;..\lib_com;..\lib_debug;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) false @@ -124,7 +124,7 @@ AnySuitable false false - ..\lib_util;..\lib_com;..\lib_debug;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) true diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj index 852cb8f14bc40454a9cb9881ce16996d5991d428..e615fe990feb1d04a6ef79358ead53982e7b1350 100644 --- a/Workspace_msvc/lib_rend.vcxproj +++ b/Workspace_msvc/lib_rend.vcxproj @@ -256,9 +256,16 @@ + + + + + + + diff --git a/Workspace_msvc/renderer.vcxproj b/Workspace_msvc/renderer.vcxproj index eee6eed340c3d05398a8f668cde3c5748399d4fc..b119e778db7d2c56aeffc3b0e20a35759bb53539 100644 --- a/Workspace_msvc/renderer.vcxproj +++ b/Workspace_msvc/renderer.vcxproj @@ -86,7 +86,7 @@ Disabled - ..\lib_com;..\lib_dec;..\lib_enc;..\lib_debug;..\lib_util;..\lib_rend;..\lc3plus;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_util;..\lib_rend;..\lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;WIN32;$(Macros);%(PreprocessorDefinitions) EnableFastChecks @@ -180,7 +180,7 @@ Neither false false - ..\lib_com;..\lib_dec;..\lib_enc;..\lib_debug;..\lib_util;..\lib_rend;..\lc3plus;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_util;..\lib_rend;..\lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) true diff --git a/apps/decoder.c b/apps/decoder.c index 4e59e521cf00b3ea98fd26f01c665763c04bfd3b..213803c466291b91bdaaf3ad3b541d60d9bc2823 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -30,35 +30,31 @@ *******************************************************************************************************/ -#include +#include "lib_dec.h" #include -#include #include -#include "options.h" -#include "lib_dec.h" #include "cmdl_tools.h" #include "audio_file_writer.h" #include "bitstream_reader.h" -#include "masa_file_writer.h" +#include "evs_rtp_payload.h" #include "ism_file_writer.h" -#include "ls_custom_file_reader.h" +#include "jbm_file_writer.h" #include "hrtf_file_reader.h" +#include "ls_custom_file_reader.h" +#include "masa_file_writer.h" +#include "render_config_reader.h" #include "rotation_file_reader.h" -#include "vector3_pair_file_reader.h" -#include "jbm_file_writer.h" -#include "evs_rtp_payload.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include "split_render_file_read_write.h" +#endif #ifdef VARIABLE_SPEED_DECODING #include "tsm_scale_file_reader.h" #endif +#include "vector3_pair_file_reader.h" #ifdef DEBUGGING #include "debug.h" #endif #include "wmc_auto.h" -#include "render_config_reader.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT -#include "split_render_file_read_write.h" -#endif -#include "hrtf_file_reader.h" #define WMC_TOOL_SKIP @@ -72,20 +68,15 @@ static #endif int32_t frame = 0; /* Counter of frames */ -#define MIN_NUM_BITS_ACTIVE_FRAME 56 -#define NUM_BITS_SID_IVAS_5K2 104 -#ifdef SPLIT_REND_WITH_HEAD_ROT -#define NUM_FRAMES_PER_SEC 50 -#define MAX_FRAME_SIZE ( 48000 / NUM_FRAMES_PER_SEC ) -#else -#define MAX_FRAME_SIZE ( 48000 / 50 ) -#endif +#define MIN_NUM_BITS_ACTIVE_FRAME 56 +#define NUM_BITS_SID_IVAS_5K2 104 #define MAX_NUM_OUTPUT_CHANNELS 16 -#define MAX_OUTPUT_PCM_BUFFER_SIZE ( MAX_NUM_OUTPUT_CHANNELS * MAX_FRAME_SIZE ) +#define MAX_OUTPUT_PCM_BUFFER_SIZE ( MAX_NUM_OUTPUT_CHANNELS * IVAS_MAX_FRAME_SIZE ) #ifdef SPLIT_REND_WITH_HEAD_ROT #define MAX_SPLIT_REND_BITRATE ( 768000 ) /* TODO tmu: unify with SPLIT_REND_MAX_BRATE ? */ -#define MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES ( ( ( (int32_t) MAX_SPLIT_REND_BITRATE / NUM_FRAMES_PER_SEC ) + 7 ) >> 3 ) +#define MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES ( ( ( (int32_t) MAX_SPLIT_REND_BITRATE / IVAS_NUM_FRAMES_PER_SEC ) + 7 ) >> 3 ) #endif + #define IVAS_PUBLIC_ORIENT_TRK_NONE ( 0 ) #define IVAS_PUBLIC_ORIENT_TRK_REF ( 1 ) #define IVAS_PUBLIC_ORIENT_TRK_AVG ( 2 ) diff --git a/apps/encoder.c b/apps/encoder.c index 672b3f55eddc5b16c7c7186aaf71015b0ce1e08f..c2574c953730b0e5781def272d82b5d64140a0a0 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -30,21 +30,20 @@ *******************************************************************************************************/ -#include -#include -#include #include "lib_enc.h" +#include #include "cmdl_tools.h" #include "audio_file_reader.h" #include "bitstream_writer.h" +#include "ism_file_reader.h" #include "jbm_file_reader.h" #include "masa_file_reader.h" -#include "ism_file_reader.h" #ifdef DEBUGGING #include "debug.h" #endif #include "wmc_auto.h" + #define WMC_TOOL_SKIP /*------------------------------------------------------------------------------------------* diff --git a/apps/renderer.c b/apps/renderer.c index 6255e87e44a90e478c4bc2b650ee9da170b75443..e072365d9dac28e3cf3c5cc2b22f659b4388d501 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -31,32 +31,33 @@ *******************************************************************************************************/ #include "lib_rend.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT -#include "split_render_file_read_write.h" -#include "split_rend_bfi_file_reader.h" -#endif #include -#include #include -#include -#include #include #include "audio_file_reader.h" #include "audio_file_writer.h" #include "cmdl_tools.h" #include "cmdln_parser.h" -#include "rotation_file_reader.h" -#include "vector3_pair_file_reader.h" #include "hrtf_file_reader.h" #include "ism_file_reader.h" #include "ls_custom_file_reader.h" #include "masa_file_reader.h" #include "masa_file_writer.h" -#include "prot.h" #include "render_config_reader.h" +#include "rotation_file_reader.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include "split_render_file_read_write.h" +#include "split_rend_bfi_file_reader.h" +#endif +#include "vector3_pair_file_reader.h" +#ifdef DEBUGGING +#include "debug.h" +#endif #include "wmc_auto.h" +#define WMC_TOOL_SKIP + /*------------------------------------------------------------------------------------------* * Local constants *------------------------------------------------------------------------------------------*/ @@ -66,9 +67,12 @@ #define RENDERER_MAX_METADATA_LINE_LENGTH 1024 #ifdef SPLIT_REND_WITH_HEAD_ROT -#define SPLIT_REND_BITS_BUFF_SIZE ( ( ( ( (int32_t) SPLIT_REND_MAX_BRATE / FRAMES_PER_SEC ) + 7 ) >> 3 ) + SPLIT_REND_ADDITIONAL_BYTES_TO_READ ) +#define SPLIT_REND_BITS_BUFF_SIZE ( ( ( ( (int32_t) SPLIT_REND_MAX_BRATE / IVAS_NUM_FRAMES_PER_SEC ) + 7 ) >> 3 ) + SPLIT_REND_ADDITIONAL_BYTES_TO_READ ) #endif +#define IVAS_MAX16B_FLT 32767.0f +#define IVAS_MIN16B_FLT ( -32768.0f ) + #if !defined( DEBUGGING ) && !defined( WMOPS ) static #endif @@ -80,6 +84,11 @@ static #define SEP_FOLDER '/' #endif +#ifndef _WIN32 +#define max( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) ) +#define min( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) ) +#endif + /*------------------------------------------------------------------------------------------* * Local structures @@ -438,7 +447,7 @@ static void convertInputBuffer( const int16_t *intBuffer, const int16_t numIntSa #ifdef SPLIT_REND_WITH_HEAD_ROT , const int16_t cldfb_in, - HANDLE_CLDFB_FILTER_BANK *cldfbAna + IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbAna #endif ); @@ -446,7 +455,7 @@ static void convertOutputBuffer( const float *floatBuffer, const int16_t numSamp #ifdef SPLIT_REND_WITH_HEAD_ROT , const int16_t cldfb_in, - HANDLE_CLDFB_FILTER_BANK *cldfbSyn + IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbSyn #endif ); @@ -655,61 +664,6 @@ static float dBToLin( } #ifdef SPLIT_REND_WITH_HEAD_ROT -static int16_t rend_openCldfb( - HANDLE_CLDFB_FILTER_BANK cldfbAna[MAX_INPUT_CHANNELS], - HANDLE_CLDFB_FILTER_BANK cldfbSyn[MAX_INPUT_CHANNELS], - const int16_t num_in_chs, - const int16_t num_out_chs, - const int32_t output_Fs ) -{ - int16_t n; - - for ( n = 0; n < num_in_chs; n++ ) - { - if ( openCldfb( &( cldfbAna[n] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) != IVAS_ERR_OK ) - { - return -1; - } - } - for ( ; n < MAX_INPUT_CHANNELS; n++ ) - { - cldfbAna[n] = NULL; - } - - for ( n = 0; n < num_out_chs; n++ ) - { - if ( openCldfb( &( cldfbSyn[n] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) != IVAS_ERR_OK ) - { - return -1; - } - } - for ( ; n < MAX_INPUT_CHANNELS; n++ ) - { - cldfbSyn[n] = NULL; - } - return 0; -} - -static void rend_closeCldfb( HANDLE_CLDFB_FILTER_BANK cldfbAna[MAX_INPUT_CHANNELS], HANDLE_CLDFB_FILTER_BANK cldfbSyn[MAX_INPUT_CHANNELS] ) -{ - int16_t n; - for ( n = 0; n < MAX_INPUT_CHANNELS; n++ ) - { - if ( cldfbAna[n] != NULL ) - { - deleteCldfb( &( cldfbAna[n] ) ); - cldfbAna[n] = NULL; - } - - if ( cldfbSyn[n] != NULL ) - { - deleteCldfb( &( cldfbSyn[n] ) ); - cldfbSyn[n] = NULL; - } - } - return; -} - static int16_t get_cldfb_in_flag( IVAS_REND_AudioConfig audioConfig, IVAS_RENDER_CONFIG_DATA *renderConfig ) { int16_t cldfb_in; @@ -770,8 +724,8 @@ int main( RotFileReader *externalOrientationFileReader = NULL; RotFileReader *referenceRotReader = NULL; #ifdef SPLIT_REND_WITH_HEAD_ROT - HANDLE_CLDFB_FILTER_BANK cldfbAna[MAX_INPUT_CHANNELS]; - HANDLE_CLDFB_FILTER_BANK cldfbSyn[MAX_INPUT_CHANNELS]; + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbAna[IVAS_MAX_INPUT_CHANNELS]; + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_INPUT_CHANNELS]; int16_t cldfb_in, CLDFBframeSize_smpls; SplitRendBFIFileReader *splitRendBFIReader = NULL; #endif @@ -1122,7 +1076,7 @@ int main( exit( -1 ); } #endif - renderConfig.room_acoustics.override = TRUE; + renderConfig.room_acoustics.override = 1; } if ( ( error = IVAS_REND_FeedRenderConfig( hIvasRend, renderConfig ) ) != IVAS_ERR_OK ) @@ -1367,7 +1321,7 @@ int main( #ifdef SPLIT_REND_WITH_HEAD_ROT if ( cldfb_in ) { - rend_openCldfb( cldfbAna, cldfbSyn, totalNumInChannels, numOutChannels, args.sampleRate ); + IVAS_REND_openCldfb( cldfbAna, cldfbSyn, totalNumInChannels, numOutChannels, args.sampleRate ); } if ( args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) @@ -1964,7 +1918,7 @@ int main( #ifdef FIX_488_SYNC_DELAY if ( args.inConfig.numAudioObjects != 0 && ( args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL || args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { - fprintf( stdout, "\n\nMetadata delayed %d subframes\n\n", (int16_t) round( args.syncMdDelay / ( 1000 / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); + fprintf( stdout, "\n\nMetadata delayed %d subframes\n\n", (int16_t) round( args.syncMdDelay / ( 1000 / IVAS_NUM_FRAMES_PER_SEC / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); } #endif @@ -2006,7 +1960,7 @@ int main( #ifdef SPLIT_REND_WITH_HEAD_ROT if ( cldfb_in ) { - rend_closeCldfb( cldfbAna, cldfbSyn ); + IVAS_REND_closeCldfb( cldfbAna, cldfbSyn ); } if ( hSplitRendFileReadWrite != NULL ) @@ -3422,12 +3376,20 @@ static ivas_error parseCustomLayoutFile( } pLsSetupCustom->num_spk = hLsCustomData.num_spk; - mvr2r( hLsCustomData.azimuth, pLsSetupCustom->azimuth, hLsCustomData.num_spk ); - mvr2r( hLsCustomData.elevation, pLsSetupCustom->elevation, hLsCustomData.num_spk ); + + for ( int16_t i = 0; i < hLsCustomData.num_spk; i++ ) + { + pLsSetupCustom->azimuth[i] = hLsCustomData.azimuth[i]; + pLsSetupCustom->elevation[i] = hLsCustomData.elevation[i]; + } /* Loudspeaker LFE */ pLsSetupCustom->num_lfe = hLsCustomData.num_lfe; - mvs2s( hLsCustomData.lfe_idx, pLsSetupCustom->lfe_idx, hLsCustomData.num_lfe ); + + for ( int16_t i = 0; i < hLsCustomData.num_lfe; i++ ) + { + pLsSetupCustom->lfe_idx[i] = hLsCustomData.lfe_idx[i]; + } CustomLsReader_close( &hLsCustomReader ); @@ -3634,7 +3596,7 @@ static ivas_error parseLfePanMtxFile( const char *lfeRoutingMatrixFilePath, IVAS_REND_LfePanMtx *lfePanMtx ) { - int16_t lfe_in, ch_out; + int16_t i, lfe_in, ch_out; const char *tok; char line[200]; /* > (10 chars * IVAS_MAX_OUTPUT_CHANNELS) i.e. "-999, " */ FILE *mtxFile; @@ -3655,7 +3617,10 @@ static ivas_error parseLfePanMtxFile( any subsequent issue in file reading will gracefully exit the function */ for ( lfe_in = 0; lfe_in < IVAS_MAX_INPUT_LFE_CHANNELS; lfe_in++ ) { - set_zero( ( *lfePanMtx )[lfe_in], IVAS_MAX_OUTPUT_CHANNELS ); + for ( i = 0; i < IVAS_MAX_OUTPUT_CHANNELS; i++ ) + { + ( *lfePanMtx )[lfe_in][i] = 0.0f; + } } for ( lfe_in = 0; lfe_in < IVAS_MAX_INPUT_LFE_CHANNELS; lfe_in++ ) @@ -3714,7 +3679,7 @@ static void convertInputBuffer( #ifdef SPLIT_REND_WITH_HEAD_ROT , const int16_t cldfb_in, - HANDLE_CLDFB_FILTER_BANK *cldfbAna + IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbAna #endif ) { @@ -3725,11 +3690,11 @@ static void convertInputBuffer( if ( cldfb_in ) { int16_t slotIdx, numCldfbBands, numFloatPcmSamples; - float fIn[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + float fIn[IVAS_MAX_OUTPUT_CHANNELS][IVAS_MAX_FRAME_SIZE]; numFloatPcmSamples = numFloatSamplesPerChannel >> 1; - numCldfbBands = numFloatPcmSamples / CLDFB_NO_COL_MAX; + numCldfbBands = numFloatPcmSamples / IVAS_CLDFB_NO_COL_MAX; /* CLDFB Analysis*/ - assert( numIntSamplesPerChannel <= MAX_OUTPUT_CHANNELS * L_FRAME48k ); + assert( numIntSamplesPerChannel <= IVAS_MAX_OUTPUT_CHANNELS * IVAS_MAX_FRAME_SIZE ); for ( smpl = 0; smpl < numFloatPcmSamples; ++smpl ) { for ( chnl = 0; chnl < numChannels; ++chnl ) @@ -3748,13 +3713,12 @@ static void convertInputBuffer( } for ( chnl = 0; chnl < numChannels; ++chnl ) { - for ( slotIdx = 0; slotIdx < CLDFB_NO_COL_MAX; slotIdx++ ) + for ( slotIdx = 0; slotIdx < IVAS_CLDFB_NO_COL_MAX; slotIdx++ ) { - cldfbAnalysis_ts( &fIn[chnl][numCldfbBands * slotIdx], - &floatBuffer[( chnl * numFloatSamplesPerChannel ) + ( 2 * slotIdx * numCldfbBands )], - &floatBuffer[numCldfbBands + ( chnl * numFloatSamplesPerChannel ) + ( 2 * slotIdx * numCldfbBands )], - numCldfbBands, - cldfbAna[chnl] ); + IVAS_REND_cldfbAnalysis_ts_wrapper( &fIn[chnl][numCldfbBands * slotIdx], + &floatBuffer[( chnl * numFloatSamplesPerChannel ) + ( 2 * slotIdx * numCldfbBands )], + &floatBuffer[numCldfbBands + ( chnl * numFloatSamplesPerChannel ) + ( 2 * slotIdx * numCldfbBands )], + numCldfbBands, cldfbAna[chnl] ); } } } @@ -3799,7 +3763,7 @@ static void convertOutputBuffer( #ifdef SPLIT_REND_WITH_HEAD_ROT , const int16_t cldfb_in, - HANDLE_CLDFB_FILTER_BANK *cldfbSyn + IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbSyn #endif ) { @@ -3812,15 +3776,15 @@ static void convertOutputBuffer( if ( cldfb_in ) { int16_t slotIdx, numCldfbBands, numPcmSamples, b; - float fIn[MAX_OUTPUT_CHANNELS][L_FRAME48k]; - float re[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - float im[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + float fIn[IVAS_MAX_OUTPUT_CHANNELS][IVAS_MAX_FRAME_SIZE]; + float re[IVAS_MAX_OUTPUT_CHANNELS][IVAS_CLDFB_NO_COL_MAX][IVAS_CLDFB_NO_CHANNELS_MAX]; + float im[IVAS_MAX_OUTPUT_CHANNELS][IVAS_CLDFB_NO_COL_MAX][IVAS_CLDFB_NO_CHANNELS_MAX]; numPcmSamples = numSamplesPerChannel >> 1; - numCldfbBands = numPcmSamples / CLDFB_NO_COL_MAX; + numCldfbBands = numPcmSamples / IVAS_CLDFB_NO_COL_MAX; /* CLDFB Synthesis*/ for ( chnl = 0; chnl < numChannels; ++chnl ) { - for ( slotIdx = 0; slotIdx < CLDFB_NO_COL_MAX; slotIdx++ ) + for ( slotIdx = 0; slotIdx < IVAS_CLDFB_NO_COL_MAX; slotIdx++ ) { for ( b = 0; b < numCldfbBands; b++ ) { @@ -3833,16 +3797,16 @@ static void convertOutputBuffer( /* Implement CLDFB synthesis */ for ( chnl = 0; chnl < numChannels; ++chnl ) { - float *RealBuffer[CLDFB_NO_COL_MAX]; - float *ImagBuffer[CLDFB_NO_COL_MAX]; + float *RealBuffer[IVAS_CLDFB_NO_COL_MAX]; + float *ImagBuffer[IVAS_CLDFB_NO_COL_MAX]; - for ( slotIdx = 0; slotIdx < CLDFB_NO_COL_MAX; slotIdx++ ) + for ( slotIdx = 0; slotIdx < IVAS_CLDFB_NO_COL_MAX; slotIdx++ ) { RealBuffer[slotIdx] = re[chnl][slotIdx]; ImagBuffer[slotIdx] = im[chnl][slotIdx]; } - cldfbSynthesis( RealBuffer, ImagBuffer, &( fIn[chnl][0] ), numCldfbBands * CLDFB_NO_COL_MAX, cldfbSyn[chnl] ); + IVAS_REND_cldfbSynthesis_wrapper( RealBuffer, ImagBuffer, &( fIn[chnl][0] ), numCldfbBands * IVAS_CLDFB_NO_COL_MAX, cldfbSyn[chnl] ); } for ( smpl = 0; smpl < numPcmSamples; ++smpl ) { @@ -3862,13 +3826,13 @@ static void convertOutputBuffer( { temp = floatBuffer[chnl * numSamplesPerChannel + smpl]; temp = (float) floor( temp + 0.5f ); - if ( temp > MAX16B_FLT ) + if ( temp > IVAS_MAX16B_FLT ) { - temp = MAX16B_FLT; + temp = IVAS_MAX16B_FLT; } - else if ( temp < MIN16B_FLT ) + else if ( temp < IVAS_MIN16B_FLT ) { - temp = MIN16B_FLT; + temp = IVAS_MIN16B_FLT; } intBuffer[i] = (int16_t) temp; diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 3cbc64e52a6e10bd17c97b853ae57853e617a96b..05b92b6e30ec320cf1c0b5ae6741fad007fdb325 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -44,13 +44,19 @@ * Common API constants *----------------------------------------------------------------------------------*/ +#define IVAS_NUM_FRAMES_PER_SEC 50 +#define IVAS_MAX_FRAME_SIZE ( 48000 / IVAS_NUM_FRAMES_PER_SEC ) + #define IVAS_MAX_BITS_PER_FRAME ( 512000 / 50 ) #define IVAS_MAX_NUM_OBJECTS 4 +#define IVAS_MAX_INPUT_CHANNELS 16 #define IVAS_MAX_OUTPUT_CHANNELS 16 -#define IVAS_CLDFB_NO_CHANNELS_MAX ( 60 ) +#define IVAS_CLDFB_NO_COL_MAX 16 +#define IVAS_CLDFB_NO_CHANNELS_MAX 60 #define IVAS_MAX_INPUT_LFE_CHANNELS 4 -#define RENDERER_HEAD_POSITIONS_PER_FRAME 4 +#define IVAS_MAX_PARAM_SPATIAL_SUBFRAMES 4 +#define RENDERER_HEAD_POSITIONS_PER_FRAME 4 // ToDo: should it be harmonized with IVAS_MAX_PARAM_SPATIAL_SUBFRAMES? #ifdef EARLY_REFLECTIONS #define QC_ABS_COEFF 6 @@ -137,6 +143,7 @@ typedef struct ivas_split_rend_bits_t IVAS_SPLIT_REND_POSE_CORRECTION_MODE pose_correction; } ivas_split_rend_bits_t, IVAS_SPLIT_REND_BITS, *IVAS_SPLIT_REND_BITS_HANDLE; #endif + typedef struct { float x, y, z; @@ -159,6 +166,8 @@ 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; +typedef struct cldfb_filter_bank_struct *IVAS_CLDFB_FILTER_BANK_HANDLE; + #ifdef DEBUGGING typedef enum { diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index abd6865ca09c1fa0288f35ebb264e03ca43f3f43..d335b0ac9cee22c374217ee8db5112bc02040356 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1882,19 +1882,6 @@ typedef enum #define QUANT_STRAT_0 0 #define QUANT_STRAT_2 2 -#ifdef SPLIT_REND_WITH_HEAD_ROT -/*----------------------------------------------------------------------------------* - * Split rendering bitrate constants - *----------------------------------------------------------------------------------*/ - -#define SPLIT_REND_256k 256000 -#define SPLIT_REND_320k 320000 -#define SPLIT_REND_384k 384000 -#define SPLIT_REND_512k 512000 -#define SPLIT_REND_768k 768000 -#define SPLIT_REND_MAX_BRATE SPLIT_REND_768k -#define SPLIT_REND_ADDITIONAL_BYTES_TO_READ ( 1 ) -#endif /*----------------------------------------------------------------------------------* * Limiter constants diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index 79976efa88ab63a6d3eb8948712e899a1e5e1f12..721698084000f3af011f490bb3dcad63af47bb7e 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -573,7 +573,7 @@ typedef struct } FrameSizeParams; -typedef struct +typedef struct cldfb_filter_bank_struct { int16_t no_channels; int16_t no_col; diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index b6a7eec20ac6f83d91f1e83a1aadcdcf05f49d6b..1a826eb90402b9f6736e5ab41d9094c0040429d4 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1484,25 +1484,6 @@ static void ivas_binRenderer_convModuleClose( return; } -#ifdef SPLIT_REND_WITH_HEAD_ROT -/*------------------------------------------------------------------------- - * ivas_rend_openCldfbRend() - * - * Close CLDFB based fastconv binaural renderer memories - *------------------------------------------------------------------------*/ -void ivas_rend_closeCldfbRend( CLDFB_REND_WRAPPER *pCldfbRend ) -{ - if ( pCldfbRend->hCldfbRend->hInputSetup != NULL ) - { - free( pCldfbRend->hCldfbRend->hInputSetup ); - pCldfbRend->hCldfbRend->hInputSetup = NULL; - } - ivas_binRenderer_close( &pCldfbRend->hCldfbRend ); - - ivas_HRTF_fastconv_binary_close( &pCldfbRend->hHrtfFastConv ); - return; -} -#endif /*------------------------------------------------------------------------- * ivas_binRenderer_close() diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 2ae5be6759580733454a932db3f87a7a4342c167..18bccfe298a6804f3617902b401f2b3b34f0116c 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -909,7 +909,6 @@ IVAS_QUATERNION ivas_split_rend_get_sf_rot_data( const IVAS_QUATERNION headPositions[RENDERER_HEAD_POSITIONS_PER_FRAME], int16_t subframe_idx ); -void ivas_rend_closeCldfbRend( CLDFB_REND_WRAPPER *pCldfbRend ); int32_t ivas_get_lcld_bitrate( const int32_t SplitRendBitRate, const IVAS_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode ); int32_t ivas_get_split_rend_md_target_brate( const int32_t SplitRendBitRate, const int16_t pcm_out ); int32_t ivas_get_lc3plus_bitrate( const int32_t SplitRendBitRate, IVAS_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode ); diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 253c1d84b6b5caa3c53f5093cd570fa91f2ed122..63f3d564836700b907ae06d0b169266fe3b5d8c2 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -2927,6 +2927,30 @@ static void clearInputSplitRend( return; } + + +/*------------------------------------------------------------------------- + * ivas_rend_openCldfbRend() + * + * Close CLDFB based fastconv binaural renderer memories + *------------------------------------------------------------------------*/ + +static void ivas_rend_closeCldfbRend( + CLDFB_REND_WRAPPER *pCldfbRend ) +{ + if ( pCldfbRend->hCldfbRend->hInputSetup != NULL ) + { + free( pCldfbRend->hCldfbRend->hInputSetup ); + pCldfbRend->hCldfbRend->hInputSetup = NULL; + } + + ivas_binRenderer_close( &pCldfbRend->hCldfbRend ); + + ivas_HRTF_fastconv_binary_close( &pCldfbRend->hHrtfFastConv ); + + return; +} + #endif /* SPLIT_REND_WITH_HEAD_ROT */ static void clearInputSba( @@ -8827,6 +8851,123 @@ void IVAS_REND_Close( return; } + +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*-------------------------------------------------------------------* + * IVAS_REND_openCldfb() + * + * + *-------------------------------------------------------------------*/ + +int16_t IVAS_REND_openCldfb( + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbAna[IVAS_MAX_INPUT_CHANNELS], + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_INPUT_CHANNELS], + const int16_t num_in_chs, + const int16_t num_out_chs, + const int32_t output_Fs ) +{ + int16_t n; + + for ( n = 0; n < num_in_chs; n++ ) + { + if ( openCldfb( &( cldfbAna[n] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) != IVAS_ERR_OK ) + { + return -1; + } + } + for ( ; n < IVAS_MAX_INPUT_CHANNELS; n++ ) + { + cldfbAna[n] = NULL; + } + + for ( n = 0; n < num_out_chs; n++ ) + { + if ( openCldfb( &( cldfbSyn[n] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) != IVAS_ERR_OK ) + { + return -1; + } + } + for ( ; n < IVAS_MAX_INPUT_CHANNELS; n++ ) + { + cldfbSyn[n] = NULL; + } + + return 0; +} + + +/*-------------------------------------------------------------------* + * IVAS_REND_closeCldfb() + * + * + *-------------------------------------------------------------------*/ + +void IVAS_REND_closeCldfb( + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbAna[IVAS_MAX_INPUT_CHANNELS], + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_INPUT_CHANNELS] ) +{ + int16_t n; + + for ( n = 0; n < IVAS_MAX_INPUT_CHANNELS; n++ ) + { + if ( cldfbAna[n] != NULL ) + { + deleteCldfb( &( cldfbAna[n] ) ); + cldfbAna[n] = NULL; + } + + if ( cldfbSyn[n] != NULL ) + { + deleteCldfb( &( cldfbSyn[n] ) ); + cldfbSyn[n] = NULL; + } + } + + return; +} + + +/*-------------------------------------------------------------------* + * IVAS_REND_cldfbSynthesis_wrapper() + * + * + *-------------------------------------------------------------------*/ + +void IVAS_REND_cldfbAnalysis_ts_wrapper( + const float *timeIn, /* i : time buffer */ + float realBuffer[IVAS_CLDFB_NO_CHANNELS_MAX], /* o : real value buffer */ + float imagBuffer[IVAS_CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer */ + const int16_t samplesToProcess, /* i : samples to process */ + IVAS_CLDFB_FILTER_BANK_HANDLE h_cldfb /* i : filterbank state */ +) +{ + cldfbAnalysis_ts( timeIn, realBuffer, imagBuffer, samplesToProcess, h_cldfb ); + + return; +} + + +/*-------------------------------------------------------------------* + * IVAS_REND_cldfbSynthesis_wrapper() + * + * + *-------------------------------------------------------------------*/ + +void IVAS_REND_cldfbSynthesis_wrapper( + float **realBuffer, /* i : real values */ + float **imagBuffer, /* i : imag values */ + float *timeOut, /* o : output time domain samples */ + const int16_t samplesToProcess, /* i : number of processed samples */ + IVAS_CLDFB_FILTER_BANK_HANDLE h_cldfb /* i : filter bank state */ +) +{ + cldfbSynthesis( realBuffer, imagBuffer, timeOut, samplesToProcess, h_cldfb ); + + return; +} +#endif + + #ifdef DEBUGGING /*-------------------------------------------------------------------* * IVAS_REND_GetNoCLipping() diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index c86b8bcbf2590d3167be4fbae00ad3922bd19440..0db8ddea59bc4a4f393fbed78dedfb70ae57e470 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -36,6 +36,9 @@ #include "common_api_types.h" #include +/*---------------------------------------------------------------------* + * Renderer constants + *---------------------------------------------------------------------*/ #define RENDERER_MAX_ISM_INPUTS 4 #define RENDERER_MAX_MC_INPUTS 1 @@ -45,6 +48,23 @@ #define RENDERER_MAX_BIN_INPUTS 1 #endif +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*----------------------------------------------------------------------------------* + * Split rendering bitrate constants + *----------------------------------------------------------------------------------*/ + +#define SPLIT_REND_256k 256000 +#define SPLIT_REND_320k 320000 +#define SPLIT_REND_384k 384000 +#define SPLIT_REND_512k 512000 +#define SPLIT_REND_768k 768000 +#define SPLIT_REND_MAX_BRATE SPLIT_REND_768k +#define SPLIT_REND_ADDITIONAL_BYTES_TO_READ 1 +#endif + +/*---------------------------------------------------------------------* + * Renderer structures + *---------------------------------------------------------------------*/ typedef float IVAS_REND_LfePanMtx[IVAS_MAX_INPUT_LFE_CHANNELS][IVAS_MAX_OUTPUT_CHANNELS]; @@ -153,7 +173,7 @@ typedef uint16_t IVAS_REND_InputId; /* clang-format off */ /*----------------------------------------------------------------------------------* - * Function prototypes + * Renderer function prototypes *----------------------------------------------------------------------------------*/ /* Functions to be called before rendering */ @@ -376,6 +396,40 @@ void IVAS_REND_Close( IVAS_REND_HANDLE* phIvasRend /* i/o: Pointer to renderer handle */ ); + +#ifdef SPLIT_REND_WITH_HEAD_ROT +/* Split binaural rendering functions */ + +int16_t IVAS_REND_openCldfb( + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbAna[IVAS_MAX_INPUT_CHANNELS], + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_INPUT_CHANNELS], + const int16_t num_in_chs, + const int16_t num_out_chs, + const int32_t output_Fs +); + +void IVAS_REND_closeCldfb( + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbAna[IVAS_MAX_INPUT_CHANNELS], + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_INPUT_CHANNELS] +); + +void IVAS_REND_cldfbAnalysis_ts_wrapper( + const float *timeIn, /* i : time buffer */ + float realBuffer[IVAS_CLDFB_NO_CHANNELS_MAX], /* o : real value buffer */ + float imagBuffer[IVAS_CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer */ + const int16_t samplesToProcess, /* i : samples to process */ + IVAS_CLDFB_FILTER_BANK_HANDLE h_cldfb /* i : filterbank state */ +); + +void IVAS_REND_cldfbSynthesis_wrapper( + float **realBuffer, /* i : real values */ + float **imagBuffer, /* i : imag values */ + float *timeOut, /* o : output time domain samples */ + const int16_t samplesToProcess, /* i : number of processed samples */ + IVAS_CLDFB_FILTER_BANK_HANDLE h_cldfb /* i : filter bank state */ +); +#endif + #ifdef DEBUGGING int32_t IVAS_REND_GetNoCLipping( IVAS_REND_CONST_HANDLE hIvasRend /* i : Renderer handle */ diff --git a/lib_util/g192.h b/lib_util/g192.h index 2dfd34b9e547a3acf40a40617ebb4d84b5997457..9e5e56d223c4a350b9e7f6d1775c6c3364101ef0 100644 --- a/lib_util/g192.h +++ b/lib_util/g192.h @@ -38,7 +38,6 @@ #define G192_H G192_H #include "common_api_types.h" -#include /*-----------------------------------------------------------------------* diff --git a/lib_util/masa_file_writer.h b/lib_util/masa_file_writer.h index 62aa8c6b48c0c990138621689f05fc665cabe914..6b1bcbb9fb1886db5e8fa56277c6cacebf6a5a84 100644 --- a/lib_util/masa_file_writer.h +++ b/lib_util/masa_file_writer.h @@ -33,10 +33,8 @@ #ifndef IVAS_MASA_FILE_WRITER_H #define IVAS_MASA_FILE_WRITER_H -#include -#include "options.h" -#include #include "common_api_types.h" +#include struct MasaFileWriter; diff --git a/lib_util/rotation_file_reader.h b/lib_util/rotation_file_reader.h index d597c67a7fa23aa2206079120878f70f285d241c..1ae772fceb19d61eb28392282f0494222b705ffc 100644 --- a/lib_util/rotation_file_reader.h +++ b/lib_util/rotation_file_reader.h @@ -36,8 +36,6 @@ #include "common_api_types.h" -#define IVAS_MAX_PARAM_SPATIAL_SUBFRAMES 4 - typedef struct RotFileReader RotFileReader; /*-----------------------------------------------------------------------* diff --git a/lib_util/split_rend_bfi_file_reader.h b/lib_util/split_rend_bfi_file_reader.h index 35418835138451078ac4fa005d009cd060eb762a..fc0a530ddcb5cdc78f3d5eb4b3a63bb49aeb7e35 100644 --- a/lib_util/split_rend_bfi_file_reader.h +++ b/lib_util/split_rend_bfi_file_reader.h @@ -33,17 +33,15 @@ #ifndef IVAS_SR_BFI_FILE_READER_H #define IVAS_SR_BFI_FILE_READER_H -#include "options.h" - #ifdef SPLIT_REND_WITH_HEAD_ROT #include "common_api_types.h" -#include "ivas_error.h" + typedef struct SplitRendBFIFileReader SplitRendBFIFileReader; ivas_error SplitRendBFIFileReader_open( - char *trajFilePath, /* i : head rotation trajectory file name */ - SplitRendBFIFileReader **SplitRendBFIReader /* o : SplitRendBFIFileReader handle */ + char *trajFilePath, /* i : head rotation trajectory file name */ + SplitRendBFIFileReader **SplitRendBFIReader /* o : SplitRendBFIFileReader handle */ ); ivas_error SplitRendBFIFileReading( @@ -55,7 +53,7 @@ void SplitRendBFIFileReader_close( ); const char *SplitRendBFIFileReader_getFilePath( - SplitRendBFIFileReader *SplitRendBFIReader /* i/o: SplitRendBFIFileReader handle */ + SplitRendBFIFileReader *SplitRendBFIReader /* i/o: SplitRendBFIFileReader handle */ ); diff --git a/lib_util/split_render_file_read_write.h b/lib_util/split_render_file_read_write.h index 19b4b7cf27e3cf164660f84aef8bea2a3d217dc3..29ca49aad7273d785182683e47c0d72485d13149 100644 --- a/lib_util/split_render_file_read_write.h +++ b/lib_util/split_render_file_read_write.h @@ -33,29 +33,27 @@ #ifndef SPLIT_RENDER_FILE_READ_WRITE_H #define SPLIT_RENDER_FILE_READ_WRITE_H -#include "options.h" - #ifdef SPLIT_REND_WITH_HEAD_ROT #include "common_api_types.h" -#include "ivas_error.h" + typedef struct SplitFileReadWrite SplitFileReadWrite; -/* Allocates and initializes a a split renderer reader instance */ +/* Allocates and initializes a a split renderer reader instance */ ivas_error split_rend_reader_open( SplitFileReadWrite **hhSplitRendFileReadWrite, char *filename ); -/* Allocates and initializes a a split renderer writer instance */ +/* Allocates and initializes a a split renderer writer instance */ ivas_error split_rend_writer_open( SplitFileReadWrite **hhSplitRendFileReadWrite, char *filename, int16_t delayNumSamples, int32_t delayTimeScale ); -/* Closes the split renderer reader/writer and deallocates memory */ +/* Closes the split renderer reader/writer and deallocates memory */ ivas_error split_rend_reader_writer_close( SplitFileReadWrite **hhSplitRendFileReadWrite ); -/*write split rend coded bitstream to file*/ +/*write split rend coded bitstream to file */ ivas_error split_rend_write_bitstream_to_file( SplitFileReadWrite *hSplitRendFileReadWrite, uint8_t *bits, @@ -64,7 +62,7 @@ ivas_error split_rend_write_bitstream_to_file( IVAS_SPLIT_REND_CODEC codec, IVAS_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection ); -/*read split rend coded bits from file*/ +/* read split rend coded bits from file */ ivas_error split_rend_read_bits_from_file( SplitFileReadWrite *hSplitRendFileReadWrite, uint8_t *bits, @@ -73,7 +71,7 @@ ivas_error split_rend_read_bits_from_file( IVAS_SPLIT_REND_CODEC *codec, IVAS_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection ); -/*read split pre rend delay*/ +/* read split pre rend delay */ ivas_error split_rend_read_pre_rend_delay_ns( SplitFileReadWrite *hSplitRendFileReadWrite, uint32_t *delay_ns ); diff --git a/lib_util/tsm_scale_file_reader.h b/lib_util/tsm_scale_file_reader.h index 7a795a25cb27316f36acef8bb07dfe67c6dcbf4c..55ee20f8cfdb47fd178bb84f948c833c9b3de10a 100644 --- a/lib_util/tsm_scale_file_reader.h +++ b/lib_util/tsm_scale_file_reader.h @@ -33,9 +33,7 @@ #ifndef IVAS_TSM_SCALE_FILE_READER_H #define IVAS_TSM_SCALE_FILE_READER_H -#include #include "common_api_types.h" -#include "ivas_error.h" /* clang-format off */ @@ -44,24 +42,23 @@ typedef struct TsmScaleFileReader TsmScaleFileReader; /*! r: TsmScaleFileReader handle */ TsmScaleFileReader *TsmScaleFileReader_open( - const char *filePath /* i : path to TSM scale file */ + const char *filePath /* i : path to TSM scale file */ ); ivas_error TsmScaleFileReader_readScale( - TsmScaleFileReader* self, /* i/o: TsmScaleFileReader handle */ - int16_t *scale /* o : next scale */ + TsmScaleFileReader* self, /* i/o: TsmScaleFileReader handle */ + int16_t *scale /* o : next scale */ ); void TsmScaleFileReader_close( - TsmScaleFileReader **selfPtr /* i/o: pointer to TsmScaleFileReader handle */ + TsmScaleFileReader **selfPtr /* i/o: pointer to TsmScaleFileReader handle */ ); /*! r: path to the currently opened file or NULL if `self` is NULL */ const char *TsmScaleFileReader_getFilePath( - TsmScaleFileReader* self /* i/o: TsmScaleFileReader handle */ + TsmScaleFileReader* self /* i/o: TsmScaleFileReader handle */ ); - /* clang-format on */ #endif /* IVAS_TSM_SCALE_FILE_READER_H */ diff --git a/lib_util/vector3_pair_file_reader.h b/lib_util/vector3_pair_file_reader.h index 4ab687848c25265bc08fc33a7f2d5e474516e25b..e4691939220cfaded272c9481c715f73cd018d65 100644 --- a/lib_util/vector3_pair_file_reader.h +++ b/lib_util/vector3_pair_file_reader.h @@ -34,8 +34,6 @@ #define IVAS_V3PAIR_FILE_READER_H #include "common_api_types.h" -#include "ivas_error.h" -#include "options.h" /* only included to get access to the feature-defines */ typedef struct Vector3PairFileReader Vector3PairFileReader;