diff --git a/apps/decoder.c b/apps/decoder.c index 2a69e9006c6a21e85a7013a28bc8066d65328335..9c4329f32fe112435f8f83f83808f41eecb26ec1 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -124,9 +124,6 @@ typedef struct char *renderConfigFilename; #ifdef DEBUGGING -#ifndef REMOVE_FORCE_SUBFRAME_BIN - bool forceSubframeBinauralization; -#endif IVAS_DEC_FORCED_REND_MODE forcedRendMode; #ifdef DEBUG_FOA_AGC FILE *agcBitstream; /* temporary */ @@ -256,7 +253,6 @@ int main( if ( arg.hrtfReaderEnabled ) { -#ifdef FIX_351_HRTF_COMMAND /* sanity check */ if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM ) { @@ -264,13 +260,10 @@ int main( fprintf( stderr, "\nError: HRTF binary file cannot be used in this output configuration.\n\n" ); goto cleanup; } -#endif if ( ( error = hrtfFileReader_open( arg.hrtfFileName, &hrtfReader ) ) != IVAS_ERR_OK ) { -#ifdef FIX_351_HRTF_COMMAND arg.hrtfReaderEnabled = false; -#endif fprintf( stderr, "\nError: Can't open HRTF binary file %s \n\n", arg.hrtfFileName ); goto cleanup; } @@ -282,14 +275,12 @@ int main( if ( arg.enableHeadRotation ) { -#ifdef FIX_351_HRTF_COMMAND /* sanity check */ if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM ) { fprintf( stderr, "\nError: Head-rotation file file cannot be used in this output configuration.\n\n" ); goto cleanup; } -#endif if ( ( error = HeadRotationFileReader_open( arg.headrotTrajFileName, &headRotReader ) ) != IVAS_ERR_OK ) { @@ -344,14 +335,12 @@ int main( if ( arg.renderConfigEnabled ) { -#ifdef FIX_351_HRTF_COMMAND /* sanity check */ if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM ) { fprintf( stderr, "\nError: Renderer configuration file cannot be used in this output configuration.\n\n" ); goto cleanup; } -#endif if ( ( error = RenderConfigReader_open( arg.renderConfigFilename, &renderConfigReader ) ) != IVAS_ERR_OK ) { @@ -364,23 +353,7 @@ int main( * Configure the decoder *------------------------------------------------------------------------------------------*/ -#ifdef REMOVE_FORCE_SUBFRAME_BIN if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.renderConfigEnabled ) ) != IVAS_ERR_OK ) -#else -#ifdef DEBUGGING -#ifdef FIX_351_HRTF_COMMAND - if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.renderConfigEnabled, arg.forceSubframeBinauralization ) ) != IVAS_ERR_OK ) -#else - if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.forceSubframeBinauralization ) ) != IVAS_ERR_OK ) -#endif -#else -#ifdef FIX_351_HRTF_COMMAND - if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.renderConfigEnabled ) ) != IVAS_ERR_OK ) -#else - if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation ) ) != IVAS_ERR_OK ) -#endif -#endif -#endif { fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -486,9 +459,17 @@ int main( IVAS_RENDER_CONFIG_DATA renderConfig; /* sanity check */ +#ifdef TD5 + if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL ) +#else if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM ) +#endif { +#ifdef TD5 + fprintf( stderr, "\nExternal Renderer Config is supported only for BINAURAL and BINAURAL_ROOM. Exiting. \n\n" ); +#else fprintf( stderr, "\nExternal Renderer Config is supported only when BINAURAL_ROOM is used as output. Exiting. \n\n" ); +#endif goto cleanup; } @@ -784,9 +765,6 @@ static bool parseCmdlIVAS_dec( float ftmp; arg->forcedRendMode = IVAS_DEC_FORCE_REND_UNFORCED; -#ifndef REMOVE_FORCE_SUBFRAME_BIN - arg->forceSubframeBinauralization = false; -#endif #ifdef DEBUG_FOA_AGC arg->agcBitstream = NULL; #endif @@ -948,13 +926,6 @@ static bool parseCmdlIVAS_dec( i++; } } -#ifndef REMOVE_FORCE_SUBFRAME_BIN - else if ( strcmp( argv_to_upper, "-FORCE_SUBFRAME_BIN" ) == 0 ) /* Force binauralization to subframe (5 ms) resolution */ - { - arg->forceSubframeBinauralization = true; - i++; - } -#endif #ifdef DEBUG_MODE_INFO #ifdef DEBUG_MODE_INFO_TWEAK /*-----------------------------------------------------------------* @@ -1257,10 +1228,6 @@ static void usage_dec( void ) fprintf( stdout, "-T File : Head rotation specified by external trajectory File\n" ); fprintf( stdout, "-hrtf File : HRTF filter File used in BINAURAL output configuration\n" ); #ifdef DEBUGGING -#ifndef REMOVE_FORCE_SUBFRAME_BIN - fprintf( stdout, "-force_subframe_bin : Forces parametric binauralizer code to use 5 ms time resolution even when\n" ); - fprintf( stdout, " output time resolution is larger.\n" ); -#endif fprintf( stdout, "-FEC X : Insert frame erasures, X = 0-10 is the percentage\n" ); fprintf( stdout, " of erased frames, or X may be the name of binary file or \n" ); fprintf( stdout, " file with G192 headers indicating GOOD FRAME or BAD FRAME\n" ); @@ -1528,6 +1495,9 @@ static ivas_error decodeG192( ivas_error error = IVAS_ERR_UNKNOWN; uint16_t numObj = 0; IVAS_DEC_BS_FORMAT bsFormat = IVAS_DEC_BS_UNKOWN; +#ifdef TD5 + IVAS_POSITION Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; +#endif IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS]; for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i ) @@ -1620,7 +1590,11 @@ static ivas_error decodeG192( if ( arg.enableReferenceRotation ) { IVAS_QUATERNION quaternion; +#ifdef TD5 + if ( ( error = HeadRotationFileReading( refRotReader, &quaternion, NULL ) ) != IVAS_ERR_OK ) +#else if ( ( error = HeadRotationFileReading( refRotReader, &quaternion ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nError %s while reading reference rotation from %s\n", IVAS_DEC_GetErrorMessage( error ), HeadRotationFileReader_getFilePath( refRotReader ) ); goto cleanup; @@ -1641,21 +1615,33 @@ static ivas_error decodeG192( #ifdef FIX_I109_ORIENTATION_TRACKING for ( i = 0; i < IVAS_MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { +#ifdef TD5 + if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK ) +#else if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i] ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), HeadRotationFileReader_getFilePath( headRotReader ) ); goto cleanup; } } +#else +#ifdef TD5 + if ( ( error = HeadRotationFileReading( headRotReader, Quaternions, Pos ) ) != IVAS_ERR_OK ) #else if ( ( error = HeadRotationFileReading( headRotReader, Quaternions, frame ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), HeadRotationFileReader_getFilePath( headRotReader ) ); goto cleanup; } #endif +#ifdef TD5 + if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions, Pos ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; diff --git a/apps/encoder.c b/apps/encoder.c index 5fb6100034ba311d20fffd20ece5ee25bc7a6bd6..17cec67a3405c9ad59ef08f66ed579c339d6e8f0 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -126,6 +126,9 @@ typedef struct #endif #endif bool pca; +#ifdef TD5 + bool ism_extended_metadata; +#endif } EncArguments; @@ -213,23 +216,6 @@ int main( goto cleanup; } -#ifndef FIX_94_VERIFY_WAV_NUM_CHANNELS - /*------------------------------------------------------------------------------------------* - * Open input audio file - *------------------------------------------------------------------------------------------*/ - int32_t inFileSampleRate = 0; - if ( AudioFileReader_open( &audioReader, arg.inputWavFilename, &inFileSampleRate ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nCan't open %s\n\n", arg.inputWavFilename ); - goto cleanup; - } - if ( inFileSampleRate != 0 && /* inFileSampleRate will remain zero if input file is raw PCM */ - inFileSampleRate != arg.inputFs ) - { - fprintf( stderr, "Sampling rate mismatch: %d Hz requested, but %d Hz found in file %s\n", arg.inputFs, inFileSampleRate, arg.inputWavFilename ); - goto cleanup; - } -#endif /*------------------------------------------------------------------------------------------* * Open output bitstream file @@ -395,7 +381,11 @@ int main( } break; case IVAS_ENC_INPUT_ISM: +#ifdef TD5 + if ( ( error = IVAS_ENC_ConfigureForObjects( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, arg.inputFormatConfig.ism.numObjects, arg.ism_extended_metadata ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_ENC_ConfigureForObjects( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, arg.inputFormatConfig.ism.numObjects ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nIVAS_ENC_ConfigureForObjects failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); goto cleanup; @@ -452,7 +442,6 @@ int main( goto cleanup; } -#ifdef FIX_94_VERIFY_WAV_NUM_CHANNELS /*------------------------------------------------------------------------------------------* * Open input audio file *------------------------------------------------------------------------------------------*/ @@ -511,7 +500,6 @@ int main( fprintf( stderr, "\nError: %s\n", ivas_error_to_string( error ) ); goto cleanup; } -#endif /*------------------------------------------------------------------------------------------* * Open input metadata files @@ -895,6 +883,9 @@ static void initArgStruct( EncArguments *arg ) arg->caConfig = IVAS_ENC_GetDefaultChannelAwareConfig(); arg->ca_config_file = NULL; arg->mimeOutput = false; +#ifdef TD5 + arg->ism_extended_metadata = false; +#endif #ifdef DEBUGGING arg->forcedMode = IVAS_ENC_FORCE_UNFORCED; @@ -1282,6 +1273,13 @@ static bool parseCmdlIVAS_enc( if ( i < argc - 4 ) { +#ifdef TD5 + if ( argv[i][0] == '+' ) + { + argv[i]++; + arg->ism_extended_metadata = true; + } +#endif if ( !is_digits_only( argv[i] ) ) { fprintf( stderr, "Error: Number of ISM channels must be an integer number!\n\n" ); @@ -1640,7 +1638,6 @@ static void usage_enc( void ) fprintf( stdout, " *VBR mode (average bitrate),\n" ); fprintf( stdout, " for AMR-WB IO modes R = (6600, 8850, 12650, 14250, 15850, 18250,\n" ); fprintf( stdout, " 19850, 23050, 23850) \n" ); -#ifdef ISM_HIGHEST_BITRATE fprintf( stdout, " for IVAS stereo R = (13200, 16400, 24400, 32000, 48000, 64000, 80000, \n" ); fprintf( stdout, " 96000, 128000, 160000, 192000, 256000) \n" ); fprintf( stdout, " for IVAS ISM R = 13200 for 1 ISM, 16400 for 1 ISM and 2 ISM, \n" ); @@ -1648,10 +1645,6 @@ static void usage_enc( void ) fprintf( stdout, " for 2 ISM, 3 ISM and 4 ISM also 160000, 192000, 256000) \n" ); fprintf( stdout, " for 3 ISM and 4 ISM also 384000 \n" ); fprintf( stdout, " for 4 ISM also 512000 \n" ); -#else - fprintf( stdout, " for IVAS stereo & ISm R =(13200, 16400, 24400, 32000, 48000, 64000, 80000, \n" ); - fprintf( stdout, " 96000, 128000, 160000, 192000, 256000) \n" ); -#endif fprintf( stdout, " for IVAS SBA, MASA, MC R=(13200, 16400, 24400, 32000, 48000, 64000, 80000, \n" ); fprintf( stdout, " 96000, 128000, 160000, 192000, 256000, 384000, 512000) \n" ); fprintf( stdout, " Alternatively, R can be a bitrate switching file which consists of R values\n" ); @@ -1667,8 +1660,14 @@ static void usage_enc( void ) fprintf( stdout, "EVS mono is default, for IVAS choose one of the following: -stereo, -ism, -sba, -masa, -mc\n" ); fprintf( stdout, "-stereo [Mode] : Stereo format, default is unified stereo \n" ); fprintf( stdout, " optional for Mode: 1: DFT Stereo, 2: TD Stereo, 3: MDCT Stereo\n" ); +#ifdef TD5 + fprintf( stdout, "-ism (+)Ch Files : ISM format \n" ); + fprintf( stdout, " where Ch specifies the number of ISMs (1-4)\n" ); + fprintf( stdout, " where positive (+) means extended metadata format is used (including orientation and radius) \n" ); +#else fprintf( stdout, "-ism Channels Files : ISM format \n" ); fprintf( stdout, " where Channels specifies the number of ISMs (1-4)\n" ); +#endif fprintf( stdout, " and Files specify input files containing metadata, one file per object\n" ); fprintf( stdout, " (use NULL for no input metadata)\n" ); fprintf( stdout, "-sba +/-Order : Scene Based Audio input format (Ambisonics ACN/SN3D),\n" ); diff --git a/apps/renderer.c b/apps/renderer.c index 266be9a4fdc63c71bb9ab6c775cb65d9067042f9..46102c54b6f96b33de165a11f69026ea91aa8de4 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -558,6 +558,9 @@ int main( int32_t delayTimeScale = 0; int16_t i, numChannels; ivas_error error = IVAS_ERR_OK; +#ifdef TD5 + IVAS_POSITION Pos[RENDERER_HEAD_POSITIONS_PER_FRAME]; +#endif #ifdef WMOPS reset_wmops(); @@ -652,7 +655,6 @@ int main( setupWithSingleFormatInput( args, audioFilePath, positionProvider, masaReaders ); } -#ifdef FIX_94_VERIFY_WAV_NUM_CHANNELS if ( AudioFileReader_open( &audioReader, audioFilePath ) != IVAS_ERR_OK ) { fprintf( stderr, "Error opening file: %s\n", audioFilePath ); @@ -696,28 +698,6 @@ int main( fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); exit( -1 ); } -#else - int32_t inFileSampleRate = 0; - if ( AudioFileReader_open( &audioReader, audioFilePath, &inFileSampleRate ) != IVAS_ERR_OK ) - { - fprintf( stderr, "Error opening file: %s\n", audioFilePath ); - exit( -1 ); - } - if ( args.sampleRate == 0 && inFileSampleRate == 0 ) - { - fprintf( stderr, "Sampling rate must be specified on command line when using raw PCM input\n" ); - exit( -1 ); - } - if ( args.sampleRate != 0 && inFileSampleRate != 0 && args.sampleRate != inFileSampleRate ) - { - fprintf( stderr, "Sampling rate mismatch: %d Hz requested, but %d Hz found in file %s\n", args.sampleRate, inFileSampleRate, args.inputFilePath ); - exit( -1 ); - } - if ( args.sampleRate == 0 ) - { - args.sampleRate = inFileSampleRate; - } -#endif const int16_t frameSize_smpls = (int16_t) ( 20 * args.sampleRate / 1000 ); IVAS_REND_InputId mcIds[RENDERER_MAX_MC_INPUTS] = { 0 }; @@ -732,7 +712,11 @@ int main( } /* === Configure === */ +#ifdef TD5 + if ( ( error = IVAS_REND_InitConfig( hIvasRend, ( args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM ) || ( args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL ) ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_REND_InitConfig( hIvasRend, strlen( args.renderConfigFilePath ) != 0 ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "Error in Renderer Config Init\n" ); exit( -1 ); @@ -743,9 +727,17 @@ int main( IVAS_RENDER_CONFIG_DATA renderConfig; /* sanity check */ +#ifdef TD5 + if ( ( args.outConfig.audioConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM ) && ( args.outConfig.audioConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL ) ) +#else if ( args.outConfig.audioConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM ) +#endif { +#ifdef TD5 + fprintf( stderr, "\nExternal Renderer Config is supported only when BINAURAL or BINAURAL_ROOM is used as output. Exiting. \n" ); +#else fprintf( stderr, "\nExternal Renderer Config is supported only when BINAURAL_ROOM is used as output. Exiting. \n" ); +#endif exit( -1 ); } @@ -893,12 +885,7 @@ int main( const int16_t totalNumInChannels = getTotalNumInChannels( hIvasRend, mcIds, ismIds, sbaIds, masaIds ); -#ifdef FIX_94_VERIFY_WAV_NUM_CHANNELS if ( inFileNumChannels != 0 /* inFileNumChannels is 0 with raw PCM input */ && totalNumInChannels != inFileNumChannels ) -#else - if ( AudioFileReader_getNumChannels( audioReader ) != 0 /* If input file is raw PCM, audio reader has no info about number of channels */ - && totalNumInChannels != AudioFileReader_getNumChannels( audioReader ) ) -#endif { fprintf( stderr, "Number of channels in input file does not match selected configuration\n" ); exit( -1 ); @@ -1000,7 +987,11 @@ int main( if ( referenceRotReader != NULL ) { IVAS_QUATERNION quaternion; +#ifdef TD5 + if ( HeadRotationFileReading( referenceRotReader, &quaternion, NULL ) != IVAS_ERR_OK ) +#else if ( HeadRotationFileReading( referenceRotReader, &quaternion ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "Error in Head Rotation File Reading.\r\n" ); exit( -1 ); @@ -1020,16 +1011,28 @@ int main( #ifdef FIX_I109_ORIENTATION_TRACKING for ( i = 0; i < RENDERER_HEAD_POSITIONS_PER_FRAME; i++ ) { +#ifdef TD5 + if ( HeadRotationFileReading( headRotReader, &quatBuffer[i], &Pos[i] ) != IVAS_ERR_OK ) +#else if ( HeadRotationFileReading( headRotReader, &quatBuffer[i] ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "Error in Head Rotation File Reading.\r\n" ); exit( -1 ); } } +#else +#ifdef TD5 + HeadRotationFileReading( headRotReader, quatBuffer, Pos ); #else HeadRotationFileReading( headRotReader, quatBuffer, frame ); #endif +#endif +#ifdef TD5 + if ( IVAS_REND_SetHeadRotation( hIvasRend, quatBuffer, Pos ) != IVAS_ERR_OK ) +#else if ( IVAS_REND_SetHeadRotation( hIvasRend, quatBuffer ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "Error setting Head Rotation\n" ); exit( -1 ); @@ -1037,7 +1040,11 @@ int main( } else { +#ifdef TD5 + if ( ( IVAS_REND_SetHeadRotation( hIvasRend, NULL, NULL ) != IVAS_ERR_OK ) && ( IVAS_REND_SetHeadRotation( hIvasRend, NULL, NULL ) != IVAS_ERR_INVALID_OUTPUT_FORMAT ) ) +#else if ( ( IVAS_REND_SetHeadRotation( hIvasRend, NULL ) != IVAS_ERR_OK ) && ( IVAS_REND_SetHeadRotation( hIvasRend, NULL ) != IVAS_ERR_INVALID_OUTPUT_FORMAT ) ) +#endif { fprintf( stderr, "Error setting Head Rotation\n" ); exit( -1 ); @@ -1915,6 +1922,11 @@ void getMetadataFromFileReader( objectMetadataBuffer->positions[objIdx].azimuth = ismMetadata.azimuth; objectMetadataBuffer->positions[objIdx].elevation = ismMetadata.elevation; +#ifdef TD5 + objectMetadataBuffer->positions[objIdx].radius = ismMetadata.radius; + objectMetadataBuffer->positions[objIdx].yaw = ismMetadata.yaw; + objectMetadataBuffer->positions[objIdx].pitch = ismMetadata.pitch; +#endif return; } @@ -1969,6 +1981,11 @@ static void IsmPositionProvider_getNextFrame( { objectMetadataBuffer->positions[objIdx].azimuth = 0.0f; objectMetadataBuffer->positions[objIdx].elevation = 0.0f; +#ifdef TD5 + objectMetadataBuffer->positions[objIdx].radius = 1.0f; + objectMetadataBuffer->positions[objIdx].yaw = 0.0f; + objectMetadataBuffer->positions[objIdx].pitch = 0.0f; +#endif } /* Wrap azimuth to lie within (-180, 180] range */ @@ -1983,6 +2000,20 @@ static void IsmPositionProvider_getNextFrame( /* Clamp elevation to lie within [-90, 90] range (can't be wrapped easily) */ objectMetadataBuffer->positions[objIdx].elevation = min( max( objectMetadataBuffer->positions[objIdx].elevation, -90 ), 90 ); +#ifdef TD5 + /* Wrap yaw to lie within (-180, 180] range */ + while ( objectMetadataBuffer->positions[objIdx].yaw < 0.0f ) + { + objectMetadataBuffer->positions[objIdx].yaw += 360.0f; + } + while ( objectMetadataBuffer->positions[objIdx].yaw >= 360.0f ) + { + objectMetadataBuffer->positions[objIdx].yaw -= 360.0f; + } + + /* Clamp pitch to lie within [-90, 90] range (can't be wrapped easily) */ + objectMetadataBuffer->positions[objIdx].pitch = min( max( objectMetadataBuffer->positions[objIdx].pitch, -90 ), 90 ); +#endif } ++positionProvider->frameCounter; @@ -2217,6 +2248,28 @@ static void parseObjectPosition( uint16_t *positionDuration ) { char *endptr; +#ifdef TD5 + int16_t read_values; + float meta_prm[7] = { 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f }; + + readNextMetadataChunk( line, "," ); + *positionDuration = (uint16_t) strtol( line, &endptr, 10 ); + readNextMetadataChunk( line, "\n" ); + + read_values = (int16_t) sscanf( line, "%f,%f,%f,%f,%f,%f,%f", &meta_prm[0], &meta_prm[1], &meta_prm[2], &meta_prm[3], &meta_prm[4], &meta_prm[5], &meta_prm[6] ); + + if ( read_values < 2 ) + { + fprintf( stderr, "Error reading metadata\n" ); + exit( -1 ); + } + + position->azimuth = meta_prm[0]; + position->elevation = meta_prm[1]; + position->radius = meta_prm[2]; + position->yaw = meta_prm[5]; + position->pitch = meta_prm[6]; +#else readNextMetadataChunk( line, "," ); *positionDuration = (uint16_t) strtol( line, &endptr, 10 ); @@ -2243,7 +2296,7 @@ static void parseObjectPosition( fprintf( stderr, "Error reading metadata\n" ); exit( -1 ); } - +#endif return; } diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index bb942eee903b053378b636fcf6c5c0f86e617ede..0ca4d6b461ac97f9a0f0c7cf2009d9628270b934 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -78,6 +78,10 @@ typedef struct _IVAS_ISM_METADATA float radius; float spread; float gainFactor; +#ifdef TD5 + float yaw; + float pitch; +#endif } IVAS_ISM_METADATA; typedef struct @@ -93,6 +97,14 @@ typedef struct } IVAS_VECTOR3; #endif /* OTR_REFERENCE_VECTOR_TRACKING */ +#ifdef TD5 +typedef struct +{ + float x, y, z; + +} IVAS_POSITION; +#endif + typedef struct ivas_masa_metadata_frame_struct *IVAS_MASA_METADATA_HANDLE; #ifdef FIX_350_MASA_DELAY_COMP typedef struct ivas_masa_decoder_ext_out_meta_struct *MASA_DECODER_EXT_OUT_META_HANDLE; @@ -118,6 +130,11 @@ typedef struct { float azimuth; float elevation; +#ifdef TD5 + float radius; + float yaw; + float pitch; +#endif } IVAS_REND_AudioObjectPosition; typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG @@ -139,6 +156,9 @@ typedef struct _IVAS_RENDER_CONFIG IVAS_RENDER_TYPE_OVERRIDE renderer_type_override; #endif IVAS_ROOM_ACOUSTICS_CONFIG_DATA room_acoustics; +#ifdef TD5 + float directivity[3]; +#endif } IVAS_RENDER_CONFIG_DATA, *IVAS_RENDER_CONFIG_HANDLE; typedef struct _IVAS_LS_CUSTOM_LAYOUT diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 0204ad2b8f04b08fb4ee214c6277ccb4fec30a9f..a1716d0741016248b0733042a630799631912714 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -320,6 +320,14 @@ typedef enum #define ISM_Q_STEP 2.5f #define ISM_Q_STEP_BORDER 5.0f +#ifdef TD5 +#define ISM_RADIUS_NBITS 6 +#define ISM_RADIUS_MIN 0.0f +#define ISM_RADIUS_DELTA 0.25f /* Max radius = (2^ISM_RADIUS_NBITS-1)*0.25 = 15.75 */ +#define ISM_EXTENDED_METADATA_BRATE IVAS_64k +#define ISM_EXTENDED_METADATA_BITS 1 +#endif + /* Parametric ISM */ #define MAX_PARAM_ISM_NBANDS 11 #define MAX_PARAM_ISM_NBANDS_WB 9 @@ -333,11 +341,9 @@ typedef enum #define PARAM_ISM_MAX_CHAN 16 #define PARAM_ISM_HYS_BUF_SIZE 10 -#ifdef PARAM_ISM_DTX_CNG #define PARAM_ISM_DTX_COH_SCA_BITS 4 #define PARAM_ISM_DTX_AZI_BITS 5 #define PARAM_ISM_DTX_ELE_BITS 4 -#endif typedef enum { @@ -351,24 +357,27 @@ typedef enum enum { IND_ISM_NUM_OBJECTS, +#ifdef TD5 + IND_ISM_EXTENDED_FLAG = IND_ISM_NUM_OBJECTS + MAX_NUM_OBJECTS, + IND_ISM_METADATA_FLAG = IND_ISM_EXTENDED_FLAG + MAX_NUM_OBJECTS, /* EN2VE: Is this not supposed to be in the loop part below, since it is one per ISm? */ +#else IND_ISM_METADATA_FLAG = IND_ISM_NUM_OBJECTS + MAX_NUM_OBJECTS, +#endif IND_ISM_VAD_FLAG = IND_ISM_METADATA_FLAG + MAX_NUM_OBJECTS, -#ifdef PARAM_ISM_DTX_CNG IND_ISM_SCE_ID_DTX = IND_ISM_VAD_FLAG + MAX_NUM_OBJECTS, IND_ISM_NOISY_SPEECH_FLAG, IND_ISM_DTX_COH_SCA, -#endif /* ------------- loop for objects -------------- */ -#ifdef PARAM_ISM_DTX_CNG TAG_ISM_LOOP_START = IND_ISM_DTX_COH_SCA + MAX_NUM_OBJECTS, -#else - TAG_ISM_LOOP_START = IND_ISM_VAD_FLAG + MAX_NUM_OBJECTS, - #endif IND_ISM_AZIMUTH_DIFF_FLAG = TAG_ISM_LOOP_START, IND_ISM_AZIMUTH = TAG_ISM_LOOP_START, IND_ISM_ELEVATION_DIFF_FLAG = TAG_ISM_LOOP_START, IND_ISM_ELEVATION = TAG_ISM_LOOP_START, +#ifdef TD5 + IND_ISM_RADIUS_DIFF_FLAG = TAG_ISM_LOOP_START, + IND_ISM_RADIUS = TAG_ISM_LOOP_START, +#endif TAG_ISM_LOOP_END = TAG_ISM_LOOP_START + 100, /* IVAS_fmToDo: to be reviewed once the final metadata are defined */ /* --------- end of loop for objects ----------- */ diff --git a/lib_com/ivas_cov_smooth.c b/lib_com/ivas_cov_smooth.c index 57f74fb70ed95ad09f9ab9f5a22ba28f1915015b..35ce6b85465eca6da931f068f4dbeb384f25fe1f 100644 --- a/lib_com/ivas_cov_smooth.c +++ b/lib_com/ivas_cov_smooth.c @@ -39,9 +39,7 @@ #include "wmc_auto.h" #include "prot.h" -#ifdef SMOOTH_WITH_TRANS_DET #define BAND_SMOOTH_REST_START_IDX ( 2 ) -#endif /*-----------------------------------------------------------------------------------------* * Function ivas_set_up_cov_smoothing() * @@ -52,19 +50,14 @@ static void ivas_set_up_cov_smoothing( ivas_cov_smooth_state_t *hCovState, ivas_filterbank_t *pFb, const float max_update_rate, - const int16_t min_pool_size -#ifdef COV_SMOOTH_TUNING - , + const int16_t min_pool_size, const int16_t nchan_inp /* i : number of input channels */ -#endif ) { int16_t j, k; -#ifdef COV_SMOOTH_TUNING if ( nchan_inp <= FOA_CHANNELS ) { -#endif for ( j = 0; j < pFb->filterbank_num_bands; j++ ) { float update_factor; @@ -82,8 +75,6 @@ static void ivas_set_up_cov_smoothing( hCovState->pSmoothing_factor[j] = max_update_rate; } } - -#ifdef COV_SMOOTH_TUNING } else { @@ -107,7 +98,6 @@ static void ivas_set_up_cov_smoothing( } } } -#endif hCovState->prior_bank_idx = -1; return; @@ -152,12 +142,8 @@ ivas_error ivas_spar_covar_smooth_enc_open( } } - ivas_set_up_cov_smoothing( hCovState, pFb, cov_smooth_cfg->max_update_rate, cov_smooth_cfg->min_pool_size -#ifdef COV_SMOOTH_TUNING - , - nchan_inp -#endif - ); + ivas_set_up_cov_smoothing( hCovState, pFb, cov_smooth_cfg->max_update_rate, cov_smooth_cfg->min_pool_size, + nchan_inp ); *hCovState_out = hCovState; @@ -218,25 +204,17 @@ static void ivas_compute_smooth_cov( const int16_t start_band, const int16_t end_band, const int16_t num_ch, -#ifdef SMOOTH_WITH_TRANS_DET - const int16_t transient_det[2] -#else - const int16_t transient_det -#endif -) + const int16_t transient_det[2] ) { int16_t i, j, k; int16_t prev_idx = hCovState->prior_bank_idx; float factor = 0; -#ifdef SMOOTH_WITH_TRANS_DET int16_t sm_b; int16_t non_sm_b_idx; sm_b = BAND_SMOOTH_REST_START_IDX; -#endif assert( end_band <= pFb->filterbank_num_bands ); -#ifdef SMOOTH_WITH_TRANS_DET if ( prev_idx == -1 || transient_det[1] == 1 ) { for ( i = 0; i < num_ch; i++ ) @@ -277,18 +255,6 @@ static void ivas_compute_smooth_cov( } } } -#else - if ( prev_idx == -1 || transient_det == 1 ) - { - for ( i = 0; i < num_ch; i++ ) - { - for ( k = start_band; k < end_band; k++ ) - { - pCov_buf[i][i][k] += ( hCovState->pSmoothing_factor[k] * fac ); - } - } - } -#endif else if ( prev_idx == 0 ) { for ( i = 0; i < num_ch; i++ ) @@ -329,12 +295,7 @@ void ivas_cov_smooth_process( const int16_t start_band, const int16_t end_band, const int16_t num_ch, -#ifdef SMOOTH_WITH_TRANS_DET - const int16_t transient_det[2] -#else - const int16_t transient_det -#endif -) + const int16_t transient_det[2] ) { int16_t i, j; int16_t num_bands = end_band - start_band; diff --git a/lib_com/ivas_error.h b/lib_com/ivas_error.h index b384e8dee563a9c33a470e806c116fecd0eb4fbd..9438ad44a1d309ca433de3e9a420f441e2245dad 100644 --- a/lib_com/ivas_error.h +++ b/lib_com/ivas_error.h @@ -86,9 +86,7 @@ typedef enum IVAS_ERR_ISM_FILE_READER_INVALID_METADATA_FORMAT, IVAS_ERR_ISM_INVALID_METADATA_VALUE, IVAS_ERR_INVALID_MASA_FORMAT_METADATA_FILE, -#ifdef FIX_372_LIB_REND_VALIDATE_IO IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED, -#endif #ifdef DEBUGGING IVAS_ERR_INVALID_FORCE_MODE, #ifdef DEBUG_AGC_ENCODER_CMD_OPTION @@ -123,10 +121,8 @@ typedef enum IVAS_ERR_BITSTREAM_WRITER_INVALID_FORMAT, IVAS_ERR_BITSTREAM_READER_INVALID_DATA, IVAS_ERR_BITSTREAM_READER_INVALID_FORMAT, -#ifdef FIX_94_VERIFY_WAV_NUM_CHANNELS IVAS_ERR_NO_FILE_OPEN, IVAS_ERR_SAMPLING_RATE_UNKNOWN, -#endif /*----------------------------------------* * renderer (lib_rend only) * @@ -171,10 +167,8 @@ static inline const char *ivas_error_to_string( ivas_error error_code ) return "Wrong number of channels"; case IVAS_ERR_INVALID_BUFFER_SIZE: return "Invalid buffer size"; -#ifdef FIX_372_LIB_REND_VALIDATE_IO case IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED: return "Unsupported input/output config pair"; -#endif case IVAS_ERR_FAILED_FILE_OPEN: return "File open error"; case IVAS_ERR_FAILED_FILE_WRITE: diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index c3389288dedc3c1071630e2c9fa29237ea80ef0e..4543955cee0763017e24a1683f47cd9032573405 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -175,10 +175,8 @@ ivas_error ivas_FB_mixer_open( IVAS_FB_MIXER_HANDLE *hFbMixer_out, /* i/o: FB mixer handle */ const int32_t sampling_rate, /* i : sampling rate */ IVAS_FB_CFG *fb_cfg /* i : FB config. handle */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP , const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -#endif ) { IVAS_FB_MIXER_HANDLE hFbMixer; @@ -190,12 +188,10 @@ ivas_error ivas_FB_mixer_open( frame_len = (int16_t) ( sampling_rate / FRAMES_PER_SEC ); -#ifdef SBA_BR_SWITCHING_CLEAN_UP hFbMixer = *hFbMixer_out; if ( !spar_reconfig_flag ) { -#endif if ( ( hFbMixer = (IVAS_FB_MIXER_HANDLE) malloc( sizeof( IVAS_FB_MIXER_DATA ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" ); @@ -212,9 +208,7 @@ ivas_error ivas_FB_mixer_open( { hFbMixer->pFb = NULL; } -#ifdef SBA_BR_SWITCHING_CLEAN_UP } -#endif if ( fb_cfg->active_w_mixing == -1 ) { @@ -289,10 +283,8 @@ ivas_error ivas_FB_mixer_open( } } -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( !spar_reconfig_flag ) { -#endif if ( fb_cfg->num_out_chans > 0 ) { const int16_t *pActive_bins_per_band, *pActive_bins_per_band_abs, *pStart_offset, *pStart_offset_abs; @@ -341,25 +333,19 @@ ivas_error ivas_FB_mixer_open( /* ignore all the deeper filter bank stuff for now */ hFbMixer->num_diff_bands = 0; } -#ifdef SBA_BR_SWITCHING_CLEAN_UP } -#endif hFbMixer->fb_cfg = fb_cfg; -#ifdef SBA_BR_SWITCHING_CLEAN_UP set_s( hFbMixer->first_frame, 1, hFbMixer->fb_cfg->num_out_chans ); set_s( hFbMixer->first_frame + hFbMixer->fb_cfg->num_out_chans, 0, IVAS_SPAR_MAX_CH - hFbMixer->fb_cfg->num_out_chans ); if ( !spar_reconfig_flag ) { -#endif if ( ( error = ivas_filterbank_setup( hFbMixer, sampling_rate ) ) != IVAS_ERR_OK ) { return error; } -#ifdef SBA_BR_SWITCHING_CLEAN_UP } -#endif *hFbMixer_out = hFbMixer; @@ -376,10 +362,8 @@ ivas_error ivas_FB_mixer_open( void ivas_FB_mixer_close( IVAS_FB_MIXER_HANDLE *hFbMixer_in, /* i/o: FB mixer handle */ const int32_t sampling_rate /* i : sampling rate in Hz */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP , const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -#endif ) { IVAS_FB_MIXER_HANDLE hFbMixer; @@ -439,10 +423,8 @@ void ivas_FB_mixer_close( hFbMixer->prior_mixer[0][0] = NULL; } -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( !spar_reconfig_flag ) { -#endif if ( fb_cfg->num_out_chans > 0 ) { num_bands = hFbMixer->pFb->filterbank_num_bands; @@ -476,9 +458,7 @@ void ivas_FB_mixer_close( free( hFbMixer->pFb ); hFbMixer->pFb = NULL; } -#ifdef SBA_BR_SWITCHING_CLEAN_UP } -#endif if ( hFbMixer->fb_cfg != NULL ) { @@ -486,15 +466,11 @@ void ivas_FB_mixer_close( hFbMixer->fb_cfg = NULL; } -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( !spar_reconfig_flag ) { -#endif free( hFbMixer ); hFbMixer = NULL; -#ifdef SBA_BR_SWITCHING_CLEAN_UP } -#endif } return; @@ -1074,10 +1050,6 @@ static ivas_error ivas_filterbank_setup( IVAS_FB_CFG *pCfg = hFbMixer->fb_cfg; error = IVAS_ERR_OK; -#ifndef SBA_BR_SWITCHING_CLEAN_UP - set_s( hFbMixer->first_frame, 1, pCfg->num_out_chans ); - set_s( hFbMixer->first_frame + pCfg->num_out_chans, 0, IVAS_SPAR_MAX_CH - pCfg->num_out_chans ); -#endif if ( pCfg->num_out_chans > 0 ) { diff --git a/lib_com/ivas_ism_config.c b/lib_com/ivas_ism_config.c index b22d82a9da0c1dc1cade26bcaa9919b6b28c32a2..d6b0999f7ee17e8b52bcc538b6cb21887f71b36c 100644 --- a/lib_com/ivas_ism_config.c +++ b/lib_com/ivas_ism_config.c @@ -131,6 +131,12 @@ ivas_error ivas_ism_config( /* count ISm common signaling bits */ if ( hIsmMeta != NULL ) { +#ifdef TD5 + if ( ism_total_brate >= ISM_EXTENDED_METADATA_BRATE ) + { + nb_bits_metadata[0] += ISM_EXTENDED_METADATA_BITS; + } +#endif nb_bits_metadata[0] += n_ISms * ISM_METADATA_FLAG_BITS + num_obj; for ( ch = 0; ch < n_ISms; ch++ ) @@ -329,7 +335,11 @@ void ivas_ism_reset_metadata( { hIsmMeta->azimuth = 0.0f; hIsmMeta->elevation = 0.0f; - +#ifdef TD5 + hIsmMeta->yaw = 0.0f; + hIsmMeta->pitch = 0.0f; + hIsmMeta->radius = 1.0f; +#endif return; } diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index b1c636a1ecfb0603c970fb7ded85475c056a9bc6..a0506e7473af7485cc2b837f1de4bb2e6954e632 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -202,12 +202,7 @@ ivas_error pre_proc_front_ivas( const int16_t front_vad_flag, /* i : front-VAD flag to overwrite VAD decision */ const int16_t force_front_vad, /* i : flag to force VAD decision */ const int16_t front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision*/ -#ifdef LOW_RATE_TRANS_CORE_CODER const int32_t ivas_total_brate /* i : IVAS total bitrate */ -#else - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int16_t ivas_format /* i : IVAS format */ -#endif ); ivas_error pre_proc_ivas( @@ -505,11 +500,9 @@ void stereo_tcx_core_dec( const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */ STEREO_CNG_DEC_HANDLE hStereoCng, /* i : Stereo CNG handle */ const int16_t nchan_out /* i : number of output channels */ -#ifdef PARAM_ISM_DTX_CNG , const IVAS_FORMAT ivas_format, /* i : IVAS format */ const ISM_MODE ism_mode /* i : ISM mode (only needed if format is ISM) */ -#endif ); void stereo_tcx_init_dec( @@ -788,7 +781,14 @@ float ism_dequant_meta( ivas_error ivas_set_ism_metadata( ISM_METADATA_HANDLE hIsmMeta, /* o : ISM metadata handle */ const float azimuth, /* i : azimuth value */ +#ifdef TD5 + const float elevation, /* i : elevation value */ + float radius_meta, /* i : radius */ + float yaw, /* i : yaw */ + float pitch /* i : pitch */ +#else const float elevation /* i : elevation value */ +#endif ); ivas_error ivas_ism_metadata_enc_create( @@ -819,7 +819,12 @@ ivas_error ivas_ism_metadata_enc( int16_t nb_bits_metadata[], /* o : number of metadata bits */ const int16_t localVAD[], /* i : VAD flag */ const int16_t ism_mode, /* i : ISM mode */ +#ifdef TD5 + const PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i : Param ISM Config Handle */ + const int16_t ism_extended_metadata_flag /* i : Extended metadata flag */ +#else const PARAM_ISM_CONFIG_HANDLE hParamIsm /* i : Param ISM Config Handle */ +#endif ); ivas_error ivas_ism_metadata_dec( @@ -897,7 +902,6 @@ void ivas_param_ism_params_to_masa_param_mapping( ); -#ifdef PARAM_ISM_DTX_CNG /*----------------------------------------------------------------------------------* * ISM DTX prototypes *----------------------------------------------------------------------------------*/ @@ -945,7 +949,6 @@ void ivas_ism_coh_estim_dtx_enc( const int16_t nchan_transport, /* i : number of transport channels */ const int16_t input_frame /* i : input frame length */ ); -#endif /*----------------------------------------------------------------------------------* * DFT Stereo prototypes @@ -3751,18 +3754,14 @@ void FdCngDecodeDiracMDCTStereoSID( ivas_error ivas_spar_enc_open( Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP ,const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -#endif ); void ivas_spar_enc_close( SPAR_ENC_HANDLE hSpar, /* i/o: SPAR encoder handle */ const int32_t input_Fs, /* i : input sampling rate */ const int16_t nchan_inp /* i : number of input channels */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP ,const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -#endif ); ivas_error ivas_spar_enc( @@ -3775,19 +3774,15 @@ ivas_error ivas_spar_enc( ivas_error ivas_spar_dec_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP , const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -#endif ); void ivas_spar_dec_close( SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ const int32_t output_Fs /* i : output sampling rate */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP , const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -#endif ); ivas_error ivas_spar_dec( @@ -4157,11 +4152,7 @@ void ivas_enc_cov_handler_process( const int16_t end_band, const int16_t nchan_inp, const int16_t dtx_vad, -#ifdef SMOOTH_WITH_TRANS_DET const int16_t transient_det[2] -#else - const int16_t transient_det -#endif ); ivas_error ivas_spar_covar_smooth_enc_open( @@ -4183,11 +4174,7 @@ void ivas_cov_smooth_process( const int16_t start_band, const int16_t end_band, const int16_t num_ch, -#ifdef SMOOTH_WITH_TRANS_DET const int16_t transient_det[2] -#else - const int16_t transient_det -#endif ); /* Transient detector module */ @@ -4200,20 +4187,12 @@ void ivas_transient_det_close( ivas_trans_det_state_t **hTranDet /* i/o: Transient detector handle */ ); -#ifdef SMOOTH_WITH_TRANS_DET -void ivas_transient_det_process( +void ivas_transient_det_process( ivas_trans_det_state_t *hTranDet, /* i/o: SPAR TD handle */ float *pIn_pcm, /* i : input audio channels */ const int16_t frame_len, /* i : frame length in samples */ int16_t transient_det[2] /* o : transient det outputs */ ); -#else -int16_t ivas_transient_det_process( - 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: Transient detector handle */ @@ -4972,19 +4951,15 @@ ivas_error ivas_FB_mixer_open( IVAS_FB_MIXER_HANDLE *hFbMixer, /* i/o: FB mixer handle */ const int32_t sampling_rate, /* i : sampling rate */ IVAS_FB_CFG *fb_cfg /* i : FB config. handle */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP , const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -#endif ); void ivas_FB_mixer_close( IVAS_FB_MIXER_HANDLE *hFbMixer, /* i/o: FB mixer handle */ const int32_t sampling_rate /* i : sampling rate in Hz */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP , const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -#endif ); void ivas_fb_mixer_pcm_ingest( diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h index 0fea291b30d444282cd3ee13a73c27aa2b0e9bdc..f6a9cb6ef113c261b7a26b291ad84843870d791b 100644 --- a/lib_com/ivas_rom_com.h +++ b/lib_com/ivas_rom_com.h @@ -317,7 +317,9 @@ extern const float McMASA_LFEGain_vectors[64]; extern const float ism_azimuth_borders[4]; extern const float ism_elevation_borders[4]; - +#ifdef TD5 +extern const float ism_radius_borders[4]; +#endif // TD5 /*----------------------------------------------------------------------------------* * Param ISM ROM tables *----------------------------------------------------------------------------------*/ diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 8231588551aa246aa6f71ccd6ccd6ec0c457fc1b..244ba7ff768d6bdd2be5dfa1541f79626d5c29a9 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -43,7 +43,15 @@ /*----------------------------------------------------------------------------------* * Declaration of ISm common (encoder & decoder) structure *----------------------------------------------------------------------------------*/ - +#ifdef TD5 +typedef struct +{ + int16_t last_azimuth_idx; /* last frame index of coded azimuth */ + int16_t azimuth_diff_cnt; /* FEC counter of consecutive differentially azimuth coded frames */ + int16_t last_elevation_idx; /* last frame index of coded elevation */ + int16_t elevation_diff_cnt; /* FEC counter of consecutive differentially elevation coded frames */ +} ISM_METADATA_ANGLE, *ISM_METADATA_ANGLE_HANDLE; +#endif /* ISM metadata handle (storage for one frame of read ISM metadata) */ typedef struct { @@ -52,12 +60,19 @@ typedef struct float azimuth; /* azimuth value read from the input metadata file */ float elevation; /* azimuth value read from the input metadata file */ - +#ifdef TD5 + float radius; + float yaw; /* azimuth orientation value read from the input metadata file */ + float pitch; /* elevation orientation value read from the input metadata file */ + ISM_METADATA_ANGLE angle[2]; /* Angle structs for [0] azimuth/elevation and [1] yaw/pitch */ + int16_t last_radius_idx; /* last frame index of coded radius */ + int16_t radius_diff_cnt; /* FEC counter of consecutive differentially radius coded frames */ +#else int16_t last_azimuth_idx; /* last frame index of coded azimuth */ int16_t azimuth_diff_cnt; /* FEC counter of consecutive differentially azimuth coded frames */ int16_t last_elevation_idx; /* last frame index of coded elevation */ int16_t elevation_diff_cnt; /* FEC counter of consecutive differentially elevation coded frames */ - +#endif } ISM_METADATA_FRAME, *ISM_METADATA_HANDLE; diff --git a/lib_com/ivas_transient_det.c b/lib_com/ivas_transient_det.c index e2f2dfb7660404862618811be812c79de2c3b4e2..1e8f53c7ca5a1d17b7d49501169deaf7634914a6 100644 --- a/lib_com/ivas_transient_det.c +++ b/lib_com/ivas_transient_det.c @@ -211,43 +211,17 @@ void ivas_transient_det_close( * * Transient detection process call *-----------------------------------------------------------------------------------------*/ -#ifdef SMOOTH_WITH_TRANS_DET void ivas_transient_det_process( ivas_trans_det_state_t *hTranDet, /* i/o: SPAR TD handle */ float *pIn_pcm, /* i : input audio channels */ const int16_t frame_len, /* i : frame length in samples */ int16_t transient_det[2] /* o: transient det outputs */ ) -#else -int16_t ivas_transient_det_process( - ivas_trans_det_state_t *hTranDet, /* i/o: SPAR TD handle */ - float *pIn_pcm, /* i : input audio channels */ - const int16_t frame_len /* i : frame length in samples */ -) -#endif { -#ifdef SMOOTH_WITH_TRANS_DET float in_duck_gain[L_FRAME48k]; int16_t num_sf, sf, sf_samp, idx; -#else - int16_t trans; -#endif float mem = hTranDet->in_duck_gain; -#ifndef SMOOTH_WITH_TRANS_DET - ivas_td_decorr_get_ducking_gains( hTranDet, pIn_pcm, NULL, NULL, frame_len, IVAS_TDET_ONLY ); - - if ( mem - hTranDet->in_duck_gain > IVAS_TDET_PARM_TRANS_THR ) - { - trans = 1; - } - else - { - trans = 0; - } - - return trans; -#else ivas_td_decorr_get_ducking_gains( hTranDet, pIn_pcm, in_duck_gain, NULL, frame_len, IVAS_TDET_ONLY ); transient_det[0] = 0; @@ -270,7 +244,6 @@ int16_t ivas_transient_det_process( } return; -#endif } @@ -344,9 +317,7 @@ void ivas_td_decorr_get_ducking_gains( for ( i = 0; i < frame_len; i++ ) { in_duck_gain = ivas_calc_duck_gain( in_duck_gain, in_duck_coeff, e_slow[i], e_fast[i], duck_mult_fac ); -#ifdef SMOOTH_WITH_TRANS_DET pIn_duck_gains[i] = in_duck_gain; -#endif } hTranDet->in_duck_gain = in_duck_gain; } diff --git a/lib_com/options.h b/lib_com/options.h index f1810fd827b14258caff11c9eaf112b61c92f12a..a33ea2f8d73b7bcaca1b4aaa0a488d2326f4ed31 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -141,38 +141,15 @@ #define DISABLE_ADAP_RES_COD_TMP /* temporary fix for IVAS-403, disables adaptive residual coding */ /*#define ITD_WINNER_GAIN_MODIFY */ /* ITD optimization - WORK IN PROGRESS */ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ - #define FIX_I109_ORIENTATION_TRACKING /* Issue 109: Harmonize head and orientation tracking */ -#define SBA_BR_SWITCHING_CLEAN_UP /*Issue 114: Clean up changes for the SBA reconfiguation functions*/ -#define LOW_RATE_TRANS_CORE_CODER /* Eri: Activate low-rate-encoding-of-transients contribution for core coder, affects MC, MASA and SBA */ -#define FIX_197_CREND_INTERFACE -#define FIX_329_ENABLE_TD_RENDERER_REVERB_MC /* Eri: Enable reverb for TD renderer for 5.1 and 7.1 with headtracking enabled for IVAS_dec */ -#define FIX_330_ENABLE_TD_RENDERER_REVERB_REND /* Eri: Enable reverb for TD renderer for ISM, 5.1 and 7.1 with headtracking enabled for IVAS_rend */ - -#define FIX_347_DTX_CRASH /* FhG: Fix crash that can happen with DTX */ -#define DISABLE_RES_CHANNELS_MCT /* decode only W and residual for Y when outputting to stereo */ -#define FIX_107_5MS_SUBFRAME_RENDERING -#define REMOVE_FORCE_SUBFRAME_BIN /* Issue 355: remove obsolete "-force_subframe_bin" command-line option. */ - -#define PARAM_ISM_DTX_CNG /* FhG: contribution 9 - DTX-CNG for ParamISM */ - -#define FIX_331_SBA_HBR_HOA_FIXES /* DLB: issue 331 - fix addressing low frequency stuttering with HOA inputs at high bitrates */ -#ifdef FIX_331_SBA_HBR_HOA_FIXES -#define COV_SMOOTH_TUNING -#define SBA_HPF_TUNING_ENC /*#define SBA_HPF_TUNING_DEC*/ -#define SMOOTH_WITH_TRANS_DET -#endif #define BINAURALIZATION_DELAY_REPORT /* VA: Issue 255 - Changes the way the decoder delay is reported */ -#define FIX_351_HRTF_COMMAND /* VA: Issue 354 - improve "-hrtf" command-line option */ -#define FIX_94_VERIFY_WAV_NUM_CHANNELS /* FhG: Issue 94 - Check if number of channels in input wav file matches encoder/renderer configuration */ -#define ISM_HIGHEST_BITRATE /* VA: Issue 284: Update highest bitrate limit in ISM format */ #define TUNE_360_OBJECT_WITH_NOISE /* VA: issue 360: consider objects being speech+noise for active speech coding */ #define FIX_350_MASA_DELAY_COMP /* Nokia: Issue 350: MASA audio/meta delay compensation */ #define FIX_372_LIB_REND_VALIDATE_IO /* FhG: Issue 372: IVAS_rend segfaults with unsupported I/O configs - add validation checks of I/O config */ - -#define FIX_376_SBA_ROTATE /*DLB: Fix for issue 376*/ +#define FIX_376_SBA_ROTATE /*DLB: Fix for issue 376*/ +#define TD5 /* Eri: Contribution 17: Extended metadata for 6 DoF rendering in TD renderer */ #ifdef FIX_I109_ORIENTATION_TRACKING #define OTR_REFERENCE_VECTOR_TRACKING /* FhG: enables the reference position orientation tracking mode */ diff --git a/lib_com/prot.h b/lib_com/prot.h index 16d069759febe82257afd5e0f3455ca18c7c071f..69cc4e0d320bacbeb18b0d3cabcdad48c6bde35d 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -2229,10 +2229,8 @@ ivas_error init_encoder( const int16_t var_SID_rate_flag, /* i : flag for variable SID update rate */ const int16_t interval_SID, /* i : interval for SID update */ const int16_t vad_only_flag /* i : flag to indicate front-VAD structure */ -#ifdef PARAM_ISM_DTX_CNG , const ISM_MODE ism_mode /* i : ISM mode */ -#endif ); void LPDmem_enc_init( @@ -8524,10 +8522,8 @@ void generate_comfort_noise_dec_hf( float **bufferReal, /* o : Real part of input bands */ float **bufferImag, /* o : Imaginary part of input bands */ HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ -#ifdef PARAM_ISM_DTX_CNG , const int16_t cng_flag /*i : CNG Flag */ -#endif ); void generate_masking_noise( diff --git a/lib_dec/acelp_core_dec.c b/lib_dec/acelp_core_dec.c index 571311ed124250ec488242fa3d6acb6e56a19652..b0d30e88dd8fa9ed29921243169f2cd0c05ebfa7 100644 --- a/lib_dec/acelp_core_dec.c +++ b/lib_dec/acelp_core_dec.c @@ -512,11 +512,7 @@ ivas_error acelp_core_dec( } else { -#ifdef PARAM_ISM_DTX_CNG if ( st->core_brate == SID_2k40 && st->element_mode != IVAS_CPE_MDCT && st->read_sid_info ) -#else - if ( st->core_brate == SID_2k40 && st->element_mode != IVAS_CPE_MDCT ) -#endif { FdCng_decodeSID( st ); *sid_bw = 0; @@ -532,7 +528,6 @@ ivas_error acelp_core_dec( } ApplyFdCng( syn, NULL, realBuffer, imagBuffer, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); } -#ifdef PARAM_ISM_DTX_CNG if ( !st->read_sid_info ) // if (!st->read_sid_info && st->cng_paramISM_flag) /* read_sid_info can only be 0 in ParamISM mode */ { @@ -544,7 +539,6 @@ ivas_error acelp_core_dec( st->hFdCngDec->hFdCngCom->cngNoiseLevel[b] = noise_lvl_highest; } } -#endif generate_comfort_noise_dec( NULL, NULL, st, nchan_out ); @@ -1131,11 +1125,7 @@ ivas_error acelp_core_dec( st->lp_noise = st->hFdCngDec->lp_noise; } -#ifdef PARAM_ISM_DTX_CNG if ( st->element_mode != IVAS_CPE_TD && !st->cng_paramISM_flag ) -#else - if ( st->element_mode != IVAS_CPE_TD ) -#endif { /*Noise estimate*/ ApplyFdCng( syn, NULL, realBuffer, imagBuffer, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); @@ -1311,11 +1301,7 @@ ivas_error acelp_core_dec( /*WB/SWB-FD_CNG*/ if ( ( st->core_brate == FRAME_NO_DATA || st->core_brate == SID_2k40 ) && ( st->cng_type == FD_CNG ) && ( st->hFdCngDec->hFdCngCom->numCoreBands < st->cldfbSyn->no_channels ) ) { -#ifdef PARAM_ISM_DTX_CNG generate_comfort_noise_dec_hf( realBuffer, imagBuffer, st->hFdCngDec->hFdCngCom, st->cng_paramISM_flag ); -#else - generate_comfort_noise_dec_hf( realBuffer, imagBuffer, st->hFdCngDec->hFdCngCom ); -#endif if ( st->hFdCngDec->hFdCngCom->regularStopBand < st->cldfbSyn->no_channels ) { diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index 515188369cafb393093b0e59c546038841cfe018..0620b09d5f9321a4126c794adf467481fc7618b0 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -1091,11 +1091,7 @@ void generate_comfort_noise_dec( c2 = (float) sqrt( 1 - hFdCngCom->coherence ); seed2 = &( hFdCngCom->seed2 ); -#ifdef PARAM_ISM_DTX_CNG if ( ( st->element_mode == IVAS_CPE_MDCT && st->idchan == 1 ) || ( st->element_mode == IVAS_SCE && st->cng_paramISM_flag ) ) -#else - if ( st->element_mode == IVAS_CPE_MDCT && st->idchan == 1 ) -#endif { seed2 = &( hFdCngCom->seed3 ); } @@ -1105,11 +1101,7 @@ void generate_comfort_noise_dec( if ( hFdCngCom->startBand == 0 ) { -#ifdef PARAM_ISM_DTX_CNG if ( st->element_mode == IVAS_CPE_MDCT || ( st->element_mode == IVAS_SCE && st->cng_paramISM_flag ) ) -#else - if ( st->element_mode == IVAS_CPE_MDCT ) -#endif { rand_gauss( &tmp1, seed ); rand_gauss( &tmp2, seed2 ); @@ -1134,11 +1126,7 @@ void generate_comfort_noise_dec( for ( ; ptr_level < cngNoiseLevel + hFdCngCom->stopFFTbin - hFdCngCom->startBand; ptr_level++ ) { /* Real part in FFT bins */ -#ifdef PARAM_ISM_DTX_CNG if ( st->element_mode == IVAS_CPE_MDCT || ( st->element_mode == IVAS_SCE && st->cng_paramISM_flag ) ) -#else - if ( st->element_mode == IVAS_CPE_MDCT ) -#endif { rand_gauss( &tmp1, seed ); rand_gauss( &tmp2, seed2 ); @@ -1152,11 +1140,7 @@ void generate_comfort_noise_dec( ptr_r += 2; /* Imaginary part in FFT bins */ -#ifdef PARAM_ISM_DTX_CNG if ( st->element_mode == IVAS_CPE_MDCT || ( st->element_mode == IVAS_SCE && st->cng_paramISM_flag ) ) -#else - if ( st->element_mode == IVAS_CPE_MDCT ) -#endif { rand_gauss( &tmp1, seed ); rand_gauss( &tmp2, seed2 ); @@ -1234,11 +1218,7 @@ void generate_comfort_noise_dec( for ( i = 0; i < hFdCngCom->numSlots; i++ ) { /* Real part in CLDFB band */ -#ifdef PARAM_ISM_DTX_CNG if ( st->element_mode == IVAS_CPE_MDCT || ( st->element_mode == IVAS_SCE && st->cng_paramISM_flag ) ) -#else - if ( st->element_mode == IVAS_CPE_MDCT ) -#endif { rand_gauss( &tmp1, seed ); rand_gauss( &tmp2, seed2 ); @@ -1251,11 +1231,7 @@ void generate_comfort_noise_dec( bufferReal[i][j] *= (float) sqrt( ( scaleCldfb * *ptr_level ) * 0.5f ); /* Imaginary part in CLDFB band */ -#ifdef PARAM_ISM_DTX_CNG if ( st->element_mode == IVAS_CPE_MDCT || ( st->element_mode == IVAS_SCE && st->cng_paramISM_flag ) ) -#else - if ( st->element_mode == IVAS_CPE_MDCT ) -#endif { rand_gauss( &tmp1, seed ); rand_gauss( &tmp2, seed2 ); @@ -1355,10 +1331,8 @@ void generate_comfort_noise_dec_hf( float **bufferReal, /* o : Real part of input bands */ float **bufferImag, /* o : Imaginary part of input bands */ HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ -#ifdef PARAM_ISM_DTX_CNG , const int16_t cng_coh_flag /* i : CNG Flag for coherence handling */ -#endif ) { int16_t i, j; @@ -1367,7 +1341,6 @@ void generate_comfort_noise_dec_hf( int16_t *seed = &( hFdCngCom->seed ); float scale = CLDFB_SCALING / hFdCngCom->scalingFactor; -#ifdef PARAM_ISM_DTX_CNG int16_t *seed2 = &( hFdCngCom->seed ); float tmp1, tmp2, c1 = 0.f, c2 = 0.f; @@ -1378,7 +1351,6 @@ void generate_comfort_noise_dec_hf( c1 = (float) sqrt( hFdCngCom->coherence ); c2 = (float) sqrt( 1 - hFdCngCom->coherence ); } -#endif ptr_level = hFdCngCom->cngNoiseLevel + hFdCngCom->stopFFTbin - hFdCngCom->startBand; /* @@ -1391,7 +1363,6 @@ void generate_comfort_noise_dec_hf( { for ( i = 0; i < hFdCngCom->numSlots; i++ ) { -#ifdef PARAM_ISM_DTX_CNG if ( cng_coh_flag ) { /* Real part in CLDFB band */ @@ -1415,14 +1386,6 @@ void generate_comfort_noise_dec_hf( rand_gauss( &bufferImag[i][j], seed ); bufferImag[i][j] *= (float) sqrt( ( scale * *ptr_level ) * 0.5f ); } -#else - /* Real part in CLDFB band */ - rand_gauss( &bufferReal[i][j], seed ); - bufferReal[i][j] *= (float) sqrt( ( scale * *ptr_level ) * 0.5f ); - /* Imaginary part in CLDFB band */ - rand_gauss( &bufferImag[i][j], seed ); - bufferImag[i][j] *= (float) sqrt( ( scale * *ptr_level ) * 0.5f ); -#endif } ptr_level++; } diff --git a/lib_dec/init_dec.c b/lib_dec/init_dec.c index 402fdc78f5449592d418d2baf9ffdacb270d793d..ca3c88b8d1ce5d7a672fd3ec93d5ab7c96cfd5f9 100644 --- a/lib_dec/init_dec.c +++ b/lib_dec/init_dec.c @@ -738,10 +738,8 @@ ivas_error init_decoder( st->tdm_LRTD_flag = 0; st->cna_dirac_flag = 0; st->cng_sba_flag = 0; -#ifdef PARAM_ISM_DTX_CNG st->cng_paramISM_flag = 0; st->read_sid_info = 1; /* by default read the sid info from bitstream */ -#endif return error; diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 9c7e07734e61ece45dacff9152ec9788a5d907af..2db5602519dd28b45f9741760b409d062bfc4d8c 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -866,8 +866,6 @@ void ivas_binaural_add_LFE( if ( render_lfe ) { -#ifdef FIX_197_CREND_INTERFACE -#ifdef FIX_329_ENABLE_TD_RENDERER_REVERB_MC if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { gain = GAIN_LFE; @@ -876,12 +874,6 @@ void ivas_binaural_add_LFE( { gain = ( ( st_ivas->hCrendWrapper != NULL ) && ( st_ivas->hCrendWrapper->hHrtfCrend != NULL ) ) ? st_ivas->hCrendWrapper->hHrtfCrend->gain_lfe : GAIN_LFE; } -#else - gain = ( ( st_ivas->hCrendWrapper != NULL ) && ( st_ivas->hCrendWrapper->hHrtfCrend != NULL ) ) ? st_ivas->hCrendWrapper->hHrtfCrend->gain_lfe : GAIN_LFE; -#endif -#else - gain = st_ivas->hHrtf != NULL ? st_ivas->hHrtf->gain_lfe : GAIN_LFE; -#endif for ( idx_lfe = 0; idx_lfe < st_ivas->hIntSetup.num_lfe; idx_lfe++ ) { v_multc( output_f[st_ivas->hIntSetup.index_lfe[idx_lfe]], gain, output_f[st_ivas->hIntSetup.index_lfe[idx_lfe]], output_frame ); diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index 49429e0381c4645717e06756add56caf71b1893d..f1a897351f795869ed103400eb180358e0c9e8af 100755 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -240,11 +240,7 @@ ivas_error ivas_core_dec( hCPE->hStereoCng->flag_cna_fade = 0; } -#ifdef FIX_347_DTX_CRASH if ( sba_dirac_stereo_flag && hSCE && sts[0]->total_brate <= SID_2k40 && sts[0]->cng_type == FD_CNG ) -#else - if ( sba_dirac_stereo_flag && sts[0]->total_brate <= SID_2k40 && sts[0]->cng_type == FD_CNG ) -#endif { save_hb_synth = hSCE->save_hb_synth; } @@ -345,11 +341,7 @@ ivas_error ivas_core_dec( if ( ( st->core == TCX_20_CORE || st->core == TCX_10_CORE ) && st->element_mode != IVAS_CPE_MDCT ) { /* TCX decoder */ -#ifdef PARAM_ISM_DTX_CNG stereo_tcx_core_dec( st, frameMode[n], output[n], synth[n], pitch_buf[n], sba_dirac_stereo_flag, hStereoTD, last_element_mode, flag_sec_CNA, hCPE == NULL ? NULL : hCPE->hStereoCng, nchan_out, st_ivas == NULL ? 0 : st_ivas->ivas_format, st_ivas == NULL ? 0 : st_ivas->ism_mode ); -#else - stereo_tcx_core_dec( st, frameMode[n], output[n], synth[n], pitch_buf[n], sba_dirac_stereo_flag, hStereoTD, last_element_mode, flag_sec_CNA, hCPE == NULL ? NULL : hCPE->hStereoCng, nchan_out ); -#endif } if ( st->core == HQ_CORE ) @@ -461,11 +453,7 @@ ivas_error ivas_core_dec( /* for FD-CNG we need the delay compensation in the synth, so do this afterwards */ -#ifdef FIX_347_DTX_CRASH if ( sba_dirac_stereo_flag && hSCE && st->core_brate == SID_2k40 && st->cng_type == FD_CNG ) -#else - if ( sba_dirac_stereo_flag && st->core_brate == SID_2k40 && st->cng_type == FD_CNG ) -#endif { mvr2r( synth[n], hSCE->save_synth, output_frame ); } diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index ca4666ae769ce3fa3341a149cd01e74072589d6e..45f31e9f84206b65ef423ef898fadd2d32afbc7b 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -140,7 +140,6 @@ ivas_error ivas_dec( else if ( st_ivas->ivas_format == ISM_FORMAT ) { /* Metadata decoding and configuration */ -#ifdef PARAM_ISM_DTX_CNG if ( ivas_total_brate == IVAS_SID_5k2 || ivas_total_brate == FRAME_NO_DATA ) { if ( ( error = ivas_ism_dtx_dec( st_ivas, nb_bits_metadata ) ) != IVAS_ERR_OK ) @@ -148,9 +147,7 @@ ivas_error ivas_dec( return error; } } - else -#endif - if ( st_ivas->ism_mode == ISM_MODE_PARAM ) + else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { ivas_ism_metadata_dec( ivas_total_brate, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hDirAC->hParamIsm ); } @@ -222,14 +219,10 @@ ivas_error ivas_dec( } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { -#ifdef FIX_197_CREND_INTERFACE if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_BINAURAL_ROOM, NULL, NULL, NULL, NULL, output, output_Fs ) ) != IVAS_ERR_OK ) { return error; } -#else - ivas_crend_process( st_ivas, output ); -#endif ivas_binaural_add_LFE( st_ivas, output_frame, output ); } #ifdef DEBUGGING @@ -433,14 +426,10 @@ ivas_error ivas_dec( /* Rendering */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { -#ifdef FIX_197_CREND_INTERFACE if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hHeadTrackData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, output, output_Fs ) ) != IVAS_ERR_OK ) { return error; } -#else - ivas_crend_process( st_ivas, output ); -#endif ivas_binaural_add_LFE( st_ivas, output_frame, output ); } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 9a5b7cdb19fc849c0908eba98486a243c68f69bc..244060fb6d78f405f29fcf39304cd96d293a609f 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -402,7 +402,6 @@ static ivas_error ivas_read_format( break; case SID_ISM: st_ivas->ivas_format = ISM_FORMAT; -#ifdef PARAM_ISM_DTX_CNG if ( st_ivas->ism_mode == ISM_MODE_DISC ) { @@ -413,9 +412,6 @@ static ivas_error ivas_read_format( { ivas_ism_dec_config( st_ivas, st_ivas->nSCE ); /* for Param-ISM, we need to generate 2 TCs */ } -#else - ivas_ism_dec_config( st_ivas, 1 ); /* currently DTX supported for 1ISM only */ -#endif break; case SID_MULTICHANNEL: st_ivas->ivas_format = MC_FORMAT; @@ -869,12 +865,10 @@ ivas_error ivas_init_decoder( reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] ); } -#ifdef PARAM_ISM_DTX_CNG if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { st_ivas->hSCE[1]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed3 = st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed2; } -#endif } else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) { @@ -895,11 +889,7 @@ ivas_error ivas_init_decoder( { if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( ( error = ivas_spar_dec_open( st_ivas, 0 ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_spar_dec_open( st_ivas ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -1258,29 +1248,10 @@ ivas_error ivas_init_decoder( if ( st_ivas->hRenderConfig->roomAcoustics.late_reverb_on ) { -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_config, NULL, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; } -#else -#ifdef FIX_197_CREND_INTERFACE -#ifdef FIX_329_ENABLE_TD_RENDERER_REVERB_MC - if ( ( error = ivas_rend_initCrendWrapper( &st_ivas->hCrendWrapper ) ) != IVAS_ERR_OK ) -#else - if ( ( st_ivas->hCrendWrapper = (CREND_WRAPPER_HANDLE) malloc( sizeof( CREND_WRAPPER ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend Wrapper\n" ); - } - if ( ( st_ivas->hCrendWrapper->hCrend = (CREND_HANDLE) malloc( sizeof( CREND_DATA ) ) ) == NULL ) -#endif -#else - if ( ( st_ivas->hCrend = (CREND_HANDLE) malloc( sizeof( CREND_DATA ) ) ) == NULL ) -#endif - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend\n" ); - } -#endif } } else if ( st_ivas->renderer_type == RENDERER_MC ) @@ -1299,7 +1270,6 @@ ivas_error ivas_init_decoder( } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { -#ifdef FIX_197_CREND_INTERFACE if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM && st_ivas->ivas_format == MC_FORMAT && st_ivas->hDecoderConfig->Opt_Headrotation ) { if ( ( error = efap_init_data( &( st_ivas->hEFAPdata ), st_ivas->hIntSetup.ls_azimuth, st_ivas->hIntSetup.ls_elevation, st_ivas->hIntSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK ) @@ -1315,12 +1285,6 @@ ivas_error ivas_init_decoder( } st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns; -#else - if ( ivas_crend_open( st_ivas ) != IVAS_ERR_OK ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "ivas_crend_open failed" ); - } -#endif } if ( st_ivas->ivas_format == ISM_FORMAT && @@ -1626,15 +1590,8 @@ void ivas_initialize_handles_dec( st_ivas->hIsmRendererData = NULL; st_ivas->hBinRendererTd = NULL; st_ivas->hMonoDmxRenderer = NULL; -#ifdef FIX_197_CREND_INTERFACE st_ivas->hCrendWrapper = NULL; -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND st_ivas->hReverb = NULL; -#endif -#else - st_ivas->hCrend = NULL; - st_ivas->hHrtf = NULL; -#endif st_ivas->hSetOfHRTF = NULL; st_ivas->hHrtfFastConv = NULL; st_ivas->hHrtfParambin = NULL; @@ -1759,11 +1716,7 @@ void ivas_destroy_dec( /* Spar handle */ if ( st_ivas->hSpar != NULL ) { -#ifdef SBA_BR_SWITCHING_CLEAN_UP ivas_spar_dec_close( st_ivas->hSpar, st_ivas->hDecoderConfig->output_Fs, 0 ); -#else - ivas_spar_dec_close( st_ivas->hSpar, st_ivas->hDecoderConfig->output_Fs ); -#endif st_ivas->hSpar = NULL; } @@ -1796,15 +1749,9 @@ void ivas_destroy_dec( ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); /* Crend handle */ -#ifdef FIX_197_CREND_INTERFACE ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) ); -#else - ivas_crend_close( st_ivas ); -#endif -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND /* Reverb handle */ ivas_reverb_close( &st_ivas->hReverb ); -#endif /* LS config converter handle */ ivas_ls_setup_conversion_close( &st_ivas->hLsSetUpConversion ); @@ -2136,20 +2083,6 @@ static ivas_error doSanityChecks_IVAS( } #ifdef DEBUGGING -#ifndef REMOVE_FORCE_SUBFRAME_BIN - if ( st_ivas->hDecoderConfig->forceSubframeBinauralization ) - { - /* Note about resolution of Binaural Renderers: * - * - Parametric Binaural Renderer: 20 ms by default, can be forced to subframe (5 ms) resolution * - * - FastConv Binaural Renderer: 5 ms by default * - * - TD objects Binaural Renderer: 20 ms by default */ - - if ( !( output_config == AUDIO_CONFIG_BINAURAL || output_config == AUDIO_CONFIG_BINAURAL_ROOM ) || !( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MC_FORMAT || st_ivas->ivas_format == ISM_FORMAT ) ) - { - return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Wrong set-up: Forced subframe resolution parametric binauralization activated for non-binaural output." ); - } - } -#endif 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" ); diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 0bda9f5ae033f20287d0068835d357d9e9b04d3f..28a36d36d491bae828a23519b3c6b3fbba16c97a 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -151,7 +151,6 @@ static ivas_error ivas_ism_bitrate_switching( ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); /* Open Crend Binaural renderer */ -#ifdef FIX_197_CREND_INTERFACE if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, @@ -164,9 +163,6 @@ static ivas_error ivas_ism_bitrate_switching( } st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns; -#else - ivas_crend_open( st_ivas ); -#endif } } @@ -227,16 +223,7 @@ static ivas_error ivas_ism_bitrate_switching( } /* close the crend binaural renderer */ -#ifdef FIX_197_CREND_INTERFACE ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) ); -#else - ivas_crend_close( st_ivas ); - - if ( st_ivas->hHrtf != NULL ) - { - st_ivas->hHrtf = NULL; - } -#endif } } @@ -306,13 +293,11 @@ ivas_error ivas_ism_dec_config( } else if ( !st_ivas->bfi && ivas_total_brate == IVAS_SID_5k2 ) { -#ifdef PARAM_ISM_DTX_CNG if ( last_ism_mode == ISM_MODE_PARAM ) { nchan_transport_old = MAX_PARAM_ISM_WAVE; } else -#endif { st_ivas->nchan_transport = num_obj; } diff --git a/lib_dec/ivas_ism_dtx_dec.c b/lib_dec/ivas_ism_dtx_dec.c index bd15569f9e26884d2b51cdf78a6ed8909e27b759..b9d00792df2fca472c46ed04235568b6327aa8a6 100644 --- a/lib_dec/ivas_ism_dtx_dec.c +++ b/lib_dec/ivas_ism_dtx_dec.c @@ -40,7 +40,6 @@ #include "wmc_auto.h" -#ifdef PARAM_ISM_DTX_CNG /*-------------------------------------------------------------------* * ivas_ism_preprocessing() * @@ -170,4 +169,3 @@ ivas_error ivas_ism_dtx_dec( return IVAS_ERR_OK; } -#endif diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index 53c1e9d2e9d4d4e920fa304b9944f9b130940599..7c8946fc437b46305b6467ecae21c12db52b6113 100644 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -42,6 +42,14 @@ #endif #include "wmc_auto.h" +/* Local Functions */ +#ifdef TD5 +/*-----------------------------------------------------------------------* + * Local functions + *-----------------------------------------------------------------------*/ +static void decode_angle_indices( DEC_CORE_HANDLE st0, ISM_METADATA_ANGLE_HANDLE angle, int16_t *flag_abs_azimuth ); +int16_t decode_radius( DEC_CORE_HANDLE st0, int16_t *last_radius_idx, int16_t *flag_abs_radius ); +#endif /*-------------------------------------------------------------------------* * ivas_ism_metadata_dec() @@ -60,11 +68,24 @@ ivas_error ivas_ism_metadata_dec( const PARAM_ISM_CONFIG_HANDLE hParamIsm /* i : Param ISM Config Handle */ ) { +#ifdef TD5 + int16_t ch, nb_bits_start = 0, last_bit_pos; + int16_t idx_radius; +#else int16_t ch, nb_bits_start = 0, last_bit_pos, sgn, diff; +#endif int32_t element_brate[MAX_NUM_OBJECTS], total_brate[MAX_NUM_OBJECTS]; DEC_CORE_HANDLE st0; +#ifdef TD5 + int16_t ism_extended_metadata_flag; + int16_t flag_abs_radius; + int16_t flag_abs_orientation; + int16_t idx_azimuth, flag_abs_azimuth; + int16_t idx_elevation; +#else int16_t idx_azimuth, nbits_diff_azimuth, flag_abs_azimuth; int16_t idx_elevation, nbits_diff_elevation; +#endif int16_t next_bit_pos_orig; uint16_t i, bstr_meta[MAX_BITS_METADATA], *bstr_orig; ISM_METADATA_HANDLE hIsmMetaData; @@ -110,6 +131,9 @@ ivas_error ivas_ism_metadata_dec( bstr_orig = st0->bit_stream; next_bit_pos_orig = st0->next_bit_pos; st0->next_bit_pos = 0; +#ifdef TD5 + ism_extended_metadata_flag = 0; +#endif /* reverse the bitstream for easier reading of indices */ for ( i = 0; i < min( MAX_BITS_METADATA, last_bit_pos ); i++ ) @@ -148,7 +172,12 @@ ivas_error ivas_ism_metadata_dec( /* IVAS_fmToDo: more work needed when the number of transported objects is not constant */ return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "wrong number of objects signalled!" ); } - +#ifdef TD5 + if ( ism_total_brate >= ISM_EXTENDED_METADATA_BRATE ) + { + ism_extended_metadata_flag = get_next_indice( st0, ISM_EXTENDED_METADATA_BITS ); + } +#endif /* Read ISm present flags (one per object) */ for ( ch = 0; ch < *nchan_transport; ch++ ) { @@ -208,9 +237,46 @@ ivas_error ivas_ism_metadata_dec( } flag_abs_azimuth = 0; - +#ifdef TD5 + flag_abs_orientation = 0; + flag_abs_radius = 0; +#endif if ( hIsmMeta[ch]->ism_metadata_flag ) { +#ifdef TD5 + decode_angle_indices( st0, &( hIsmMetaData->angle[0] ), &flag_abs_azimuth ); + idx_azimuth = hIsmMetaData->angle[0].last_azimuth_idx; + idx_elevation = hIsmMetaData->angle[0].last_elevation_idx; + + /* Azimuth/Elevation dequantization */ + if ( ism_mode == ISM_MODE_PARAM ) + { + hParamIsm->azi_index[ch] = idx_azimuth; + hParamIsm->ele_index[ch] = idx_elevation; + } + else /* ISM_MODE_DISC */ + { + hIsmMetaData->azimuth = ism_dequant_meta( idx_azimuth, ism_azimuth_borders, 1 << ISM_AZIMUTH_NBITS ); + hIsmMetaData->elevation = ism_dequant_meta( idx_elevation, ism_elevation_borders, 1 << ISM_ELEVATION_NBITS ); + + if ( ism_extended_metadata_flag ) + { + decode_angle_indices( st0, &( hIsmMetaData->angle[1] ), &flag_abs_orientation ); + idx_azimuth = hIsmMetaData->angle[1].last_azimuth_idx; + idx_elevation = hIsmMetaData->angle[1].last_elevation_idx; + + hIsmMetaData->yaw = ism_dequant_meta( idx_azimuth, ism_azimuth_borders, 1 << ISM_AZIMUTH_NBITS ); + hIsmMetaData->pitch = ism_dequant_meta( idx_elevation, ism_elevation_borders, 1 << ISM_ELEVATION_NBITS ); + + idx_radius = decode_radius( st0, &hIsmMetaData->last_radius_idx, &flag_abs_radius ); + hIsmMetaData->radius = usdequant( idx_radius, ISM_RADIUS_MIN, ISM_RADIUS_DELTA ); + } + else + { + hIsmMetaData->radius = 1.0f; + } + } +#else /*----------------------------------------------------------------* * Azimuth decoding and dequantization *----------------------------------------------------------------*/ @@ -359,6 +425,7 @@ ivas_error ivas_ism_metadata_dec( /* updates */ hIsmMetaData->last_azimuth_idx = idx_azimuth; hIsmMetaData->last_elevation_idx = idx_elevation; +#endif } /* save number of metadata bits read */ @@ -443,8 +510,13 @@ ivas_error ivas_ism_metadata_dec( hParamIsm->ele_index[ch] = hParamIsm->ele_index[ch] + hParamIsm->last_el_sgn[ch] * hParamIsm->last_el_diff[ch]; /*hParamIsm->ele_index[ch] = hParamIsm->ele_index[ch] % hParamIsm->ele_alpha;*/ hParamIsm->ele_index[ch] = hParamIsm->ele_index[ch]; +#ifdef TD5 + hIsmMeta[ch]->angle[0].last_azimuth_idx = hParamIsm->azi_index[ch]; + hIsmMeta[ch]->angle[0].last_elevation_idx = hParamIsm->ele_index[ch]; +#else hIsmMeta[ch]->last_azimuth_idx = hParamIsm->azi_index[ch]; hIsmMeta[ch]->last_elevation_idx = hParamIsm->ele_index[ch]; +#endif } } } @@ -502,12 +574,10 @@ ivas_error ivas_ism_metadata_dec( hSCE[ch]->hCoreCoder[0]->bit_stream = hSCE[ch - 1]->hCoreCoder[0]->bit_stream + ( hSCE[ch - 1]->hCoreCoder[0]->total_brate / FRAMES_PER_SEC ); } -#ifdef PARAM_ISM_DTX_CNG for ( ch = 0; ch < *nchan_transport; ch++ ) { hSCE[ch]->hCoreCoder[0]->cng_paramISM_flag = 0; } -#endif pop_wmops(); @@ -539,8 +609,16 @@ ivas_error ivas_ism_metadata_dec_create( } st_ivas->hIsmMetaData[ch]->last_ism_metadata_flag = 0; +#ifdef TD5 + st_ivas->hIsmMetaData[ch]->angle[0].last_azimuth_idx = 0; + st_ivas->hIsmMetaData[ch]->angle[0].last_elevation_idx = 1 << ( ISM_ELEVATION_NBITS - 1 ); + st_ivas->hIsmMetaData[ch]->angle[1].last_azimuth_idx = 0; + st_ivas->hIsmMetaData[ch]->angle[1].last_elevation_idx = 1 << ( ISM_ELEVATION_NBITS - 1 ); + st_ivas->hIsmMetaData[ch]->last_radius_idx = 8; /* Init to radius 1.0 */ +#else st_ivas->hIsmMetaData[ch]->last_azimuth_idx = 0; st_ivas->hIsmMetaData[ch]->last_elevation_idx = 1 << ( ISM_ELEVATION_NBITS - 1 ); +#endif ivas_ism_reset_metadata( st_ivas->hIsmMetaData[ch] ); } @@ -552,3 +630,211 @@ ivas_error ivas_ism_metadata_dec_create( return IVAS_ERR_OK; } + +#ifdef TD5 +static void decode_angle_indices( + DEC_CORE_HANDLE st0, /* i/o: bitstream handle */ + ISM_METADATA_ANGLE_HANDLE angle, /* i/o: angle handle */ + int16_t *flag_abs_azimuth /* o : Azimuth encoding mode */ +) +{ + /*----------------------------------------------------------------* + * Azimuth decoding and dequantization + *----------------------------------------------------------------*/ + int16_t idx_azimuth, nbits_diff_azimuth, diff, sgn; + int16_t idx_elevation, nbits_diff_elevation; + + /* Decode azimuth index */ + if ( get_next_indice( st0, 1 ) == 1 ) /* azimuth_abs_flag */ + { + idx_azimuth = get_next_indice( st0, ISM_AZIMUTH_NBITS ); + *flag_abs_azimuth = 1; + } + else + { + diff = 0; + sgn = 1; + + if ( get_next_indice( st0, 1 ) == 0 ) + { + nbits_diff_azimuth = 1; + } + else + { + nbits_diff_azimuth = 1; + + if ( get_next_indice( st0, 1 ) == 1 ) /* negative sign */ + { + sgn = -1; + } + + nbits_diff_azimuth++; + + /* read until the stop bit */ + while ( ( nbits_diff_azimuth < ISM_AZIMUTH_NBITS - 1 ) && ( get_next_indice( st0, 1 ) == 1 ) ) + { + diff++; + nbits_diff_azimuth++; + } + + if ( nbits_diff_azimuth < ISM_AZIMUTH_NBITS - 1 ) + { + /* count stop bit */ + nbits_diff_azimuth++; + } + } + idx_azimuth = angle->last_azimuth_idx + sgn * diff; + } + + /* azimuth is on a circle - check for diff coding for -180° -> 180° and vice versa changes */ + if ( idx_azimuth > ( 1 << ISM_AZIMUTH_NBITS ) - 1 ) + { + idx_azimuth -= ( 1 << ISM_AZIMUTH_NBITS ) - 1; /* +180° -> -180° */ + } + else if ( idx_azimuth < 0 ) + { + idx_azimuth += ( 1 << ISM_AZIMUTH_NBITS ) - 1; /* -180° -> +180° */ + } + + /* +180° == -180° */ + if ( idx_azimuth == ( 1 << ISM_AZIMUTH_NBITS ) - 1 ) + { + idx_azimuth = 0; + } + + /* sanity check in case of FER or BER */ + if ( idx_azimuth < 0 || idx_azimuth > ( 1 << ISM_AZIMUTH_NBITS ) - 1 ) + { + idx_azimuth = angle->last_azimuth_idx; + } + + /*----------------------------------------------------------------* + * Elevation decoding and dequantization + *----------------------------------------------------------------*/ + + /* Decode elevation index */ + if ( *flag_abs_azimuth == 0 && get_next_indice( st0, 1 ) == 1 ) /* elevation_abs_flag */ + { + idx_elevation = get_next_indice( st0, ISM_ELEVATION_NBITS ); + } + else + { + diff = 0; + sgn = 1; + + if ( get_next_indice( st0, 1 ) == 0 ) + { + nbits_diff_elevation = 1; + } + else + { + nbits_diff_elevation = 1; + + if ( get_next_indice( st0, 1 ) == 1 ) /* negative sign */ + { + sgn = -1; + } + + nbits_diff_elevation++; + + /* read until the stop bit */ + while ( ( nbits_diff_elevation < ISM_ELEVATION_NBITS ) && ( get_next_indice( st0, 1 ) == 1 ) ) + { + diff++; + nbits_diff_elevation++; + } + + if ( nbits_diff_elevation < ISM_ELEVATION_NBITS ) + { + /* count stop bit */ + nbits_diff_elevation++; + } + } + + idx_elevation = angle->last_elevation_idx + sgn * diff; + } + + /* sanity check in case of FER or BER */ + if ( idx_elevation < 0 || idx_elevation > ( 1 << ISM_ELEVATION_NBITS ) - 1 ) + { + idx_elevation = angle->last_elevation_idx; + } + /*----------------------------------------------------------------* + * Final updates + *----------------------------------------------------------------*/ + + /* updates */ + angle->last_azimuth_idx = idx_azimuth; + angle->last_elevation_idx = idx_elevation; + return; +} + +int16_t decode_radius( + DEC_CORE_HANDLE st0, /* i/o: bitstream handle */ + int16_t *last_radius_idx, /* i/o: last radius index */ + int16_t *flag_abs_radius /* o : Radius encoding mode */ +) +{ + /*----------------------------------------------------------------* + * Radius decoding and dequantization + *----------------------------------------------------------------*/ + int16_t idx_radius, nbits_diff_radius, diff, sgn; + + + /* Decode radius index */ + if ( get_next_indice( st0, 1 ) == 1 ) /* elevation_abs_flag */ + { + *flag_abs_radius = 1; + idx_radius = get_next_indice( st0, ISM_RADIUS_NBITS ); + } + else + { + diff = 0; + sgn = 1; + + if ( get_next_indice( st0, 1 ) == 0 ) + { + nbits_diff_radius = 1; + } + else + { + nbits_diff_radius = 1; + + if ( get_next_indice( st0, 1 ) == 1 ) /* negative sign */ + { + sgn = -1; + } + + nbits_diff_radius++; + + /* read until the stop bit */ + while ( ( nbits_diff_radius < ISM_RADIUS_NBITS ) && ( get_next_indice( st0, 1 ) == 1 ) ) + { + diff++; + nbits_diff_radius++; + } + + if ( nbits_diff_radius < ISM_RADIUS_NBITS ) + { + /* count stop bit */ + nbits_diff_radius++; + } + } + idx_radius = *last_radius_idx + sgn * diff; + } + + /* sanity check in case of FER or BER */ + if ( idx_radius < 0 || idx_radius > ( 1 << ISM_RADIUS_NBITS ) - 1 ) + { + idx_radius = *last_radius_idx; + } + + /*----------------------------------------------------------------* + * Final updates + *----------------------------------------------------------------*/ + + /* updates */ + *last_radius_idx = idx_radius; + return idx_radius; +} +#endif diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 81a4744726d7805f543e3d7d2b3feec0c2c9cad2..f34aa023f695ae2175a5baa88c3519b7db3f0c4f 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -157,10 +157,8 @@ static void ivas_ism_get_proto_matrix( static void ivas_param_ism_compute_mixing_matrix( - DIRAC_DEC_HANDLE hDirAC, /* i/o: decoder DirAC handle */ -#ifdef PARAM_ISM_DTX_CNG + DIRAC_DEC_HANDLE hDirAC, /* i/o: decoder DirAC handle */ ISM_DTX_DATA_DEC hISMDTX, /* i : ISM DTX handle */ -#endif float Cldfb_RealBuffer_in[PARAM_ISM_MAX_DMX][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], float Cldfb_ImagBuffer_in[PARAM_ISM_MAX_DMX][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], float direct_response[MAX_NUM_OBJECTS][PARAM_ISM_MAX_CHAN], @@ -188,11 +186,7 @@ static void ivas_param_ism_compute_mixing_matrix( assert( ( hDirAC->hParamIsm->num_obj == 3 ) || ( hDirAC->hParamIsm->num_obj == 4 ) ); assert( nchan_transport == 2 ); -#ifdef PARAM_ISM_DTX_CNG if ( hDirAC->hParamIsm->flag_noisy_speech || hISMDTX.dtx_flag ) -#else - if ( hDirAC->hParamIsm->flag_noisy_speech ) -#endif { num_wave = hDirAC->hParamIsm->num_obj; } @@ -214,11 +208,7 @@ static void ivas_param_ism_compute_mixing_matrix( { set_zero( cy_diag_tmp[w], nchan_out_woLFE ); -#ifdef PARAM_ISM_DTX_CNG if ( hDirAC->hParamIsm->flag_noisy_speech || hISMDTX.dtx_flag ) -#else - if ( hDirAC->hParamIsm->flag_noisy_speech ) -#endif { dir_res_ptr = direct_response[w]; } @@ -257,11 +247,7 @@ static void ivas_param_ism_compute_mixing_matrix( set_zero( cy_diag, nchan_out_woLFE ); for ( w = 0; w < num_wave; w++ ) { -#ifdef PARAM_ISM_DTX_CNG if ( hDirAC->hParamIsm->flag_noisy_speech || hISMDTX.dtx_flag ) -#else - if ( hDirAC->hParamIsm->flag_noisy_speech ) -#endif { direct_power[w] = ( 1.0f / hDirAC->hParamIsm->num_obj ) * ref_power; } @@ -619,9 +605,7 @@ ivas_error ivas_param_ism_dec_open( } } -#ifdef PARAM_ISM_DTX_CNG st_ivas->hISMDTX.dtx_flag = 0; -#endif st_ivas->hDirAC = hDirAC; @@ -817,9 +801,7 @@ void ivas_param_ism_dec( { int16_t ch, nchan_transport, nchan_out, nchan_out_woLFE, i; int16_t subframe_idx, slot_idx, index_slot, bin_idx; -#ifdef PARAM_ISM_DTX_CNG int32_t ivas_total_brate; -#endif /* CLDFB Input Buffers */ float Cldfb_RealBuffer_in[PARAM_ISM_MAX_DMX][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; @@ -856,9 +838,7 @@ void ivas_param_ism_dec( nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE; } -#ifdef PARAM_ISM_DTX_CNG ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; -#endif hSetup = st_ivas->hIntSetup; @@ -866,7 +846,6 @@ void ivas_param_ism_dec( /* Frame-level Processing */ /* De-quantization */ -#ifdef PARAM_ISM_DTX_CNG if ( !( ivas_total_brate == IVAS_SID_5k2 || ivas_total_brate == FRAME_NO_DATA ) ) { ivas_param_ism_dec_dequant_DOA( hDirAC ); @@ -877,10 +856,6 @@ void ivas_param_ism_dec( { st_ivas->hISMDTX.dtx_flag = 1; } -#else - ivas_param_ism_dec_dequant_DOA( hDirAC ); - ivas_param_ism_dec_dequant_powrat( hDirAC ); -#endif /* obtain the direct response using EFAP */ if ( !( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_EXTERNAL ) ) @@ -943,11 +918,7 @@ void ivas_param_ism_dec( } /* Compute mixing matrix */ -#ifdef PARAM_ISM_DTX_CNG ivas_param_ism_compute_mixing_matrix( hDirAC, st_ivas->hISMDTX, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, direct_response, nchan_transport, nchan_out_woLFE, 0, CLDFB_NO_COL_MAX, mixing_matrix ); -#else - ivas_param_ism_compute_mixing_matrix( hDirAC, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, direct_response, nchan_transport, nchan_out_woLFE, 0, CLDFB_NO_COL_MAX, mixing_matrix ); -#endif /* subframe loop for synthesis*/ for ( subframe_idx = 0; subframe_idx < hDirAC->nb_subframes; subframe_idx++ ) @@ -1053,14 +1024,11 @@ void ivas_param_ism_params_to_masa_param_mapping( int16_t azimuth[2]; int16_t elevation[2]; float power_ratio[2]; -#ifdef PARAM_ISM_DTX_CNG int32_t ivas_total_brate; -#endif hDirAC = st_ivas->hDirAC; nBins = hDirAC->num_freq_bands; -#ifdef PARAM_ISM_DTX_CNG ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; if ( !( ivas_total_brate == IVAS_SID_5k2 || ivas_total_brate == FRAME_NO_DATA ) ) @@ -1073,14 +1041,9 @@ void ivas_param_ism_params_to_masa_param_mapping( { st_ivas->hISMDTX.dtx_flag = 1; } -#else - ivas_param_ism_dec_dequant_DOA( hDirAC ); - ivas_param_ism_dec_dequant_powrat( hDirAC ); -#endif if ( hDirAC->hParamIsm->num_obj > 1 ) { -#ifdef PARAM_ISM_DTX_CNG if ( st_ivas->hISMDTX.dtx_flag ) { float energy_ratio; @@ -1142,44 +1105,6 @@ void ivas_param_ism_params_to_masa_param_mapping( } } } -#else - hDirAC->numSimultaneousDirections = 2; - for ( band_idx = 0; band_idx < hDirAC->hParamIsm->nbands; band_idx++ ) - { - brange[0] = hDirAC->hParamIsm->band_grouping[band_idx]; - brange[1] = hDirAC->hParamIsm->band_grouping[band_idx + 1]; - - azimuth[0] = (int16_t) roundf( hDirAC->azimuth_values[hDirAC->hParamIsm->obj_indices[band_idx][0][0]] ); - elevation[0] = (int16_t) roundf( hDirAC->elevation_values[hDirAC->hParamIsm->obj_indices[band_idx][0][0]] ); - power_ratio[0] = hDirAC->power_ratios[band_idx][0][0]; - - azimuth[1] = (int16_t) roundf( hDirAC->azimuth_values[hDirAC->hParamIsm->obj_indices[band_idx][0][1]] ); - elevation[1] = (int16_t) roundf( hDirAC->elevation_values[hDirAC->hParamIsm->obj_indices[band_idx][0][1]] ); - power_ratio[1] = hDirAC->power_ratios[band_idx][0][1]; - - for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) - { - for ( bin_idx = brange[0]; bin_idx < brange[1]; bin_idx++ ) - { - hDirAC->azimuth[sf_idx][bin_idx] = azimuth[0]; - hDirAC->elevation[sf_idx][bin_idx] = elevation[0]; - hDirAC->energy_ratio1[sf_idx][bin_idx] = power_ratio[0]; - hDirAC->azimuth2[sf_idx][bin_idx] = azimuth[1]; - hDirAC->elevation2[sf_idx][bin_idx] = elevation[1]; - hDirAC->energy_ratio2[sf_idx][bin_idx] = power_ratio[1]; - } - } - } - for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) - { - for ( bin_idx = 0; bin_idx < nBins; bin_idx++ ) - { - hDirAC->spreadCoherence[sf_idx][bin_idx] = 0.0f; - hDirAC->spreadCoherence2[sf_idx][bin_idx] = 0.0f; - hDirAC->surroundingCoherence[sf_idx][bin_idx] = 0.0; - } - } -#endif } else { @@ -1203,7 +1128,6 @@ void ivas_param_ism_params_to_masa_param_mapping( } -#ifdef PARAM_ISM_DTX_CNG static void ivas_param_ism_dec_dequantize_DOA_dtx( int16_t azi_bits, int16_t ele_bits, @@ -1334,4 +1258,3 @@ void ivas_param_ism_metadata_dtx_dec( return; } -#endif diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 332455974c4bce1eefac40d4e61d6fa1ca7f3e9c..1e34ef397a23e54e5e037dbc8a7d6f8096810fdd 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -166,7 +166,6 @@ ivas_error ivas_mct_dec( /* MCT core decoder */ ivas_mct_core_dec( hMCT, st_ivas->hCPE, nCPE, output ); -#ifdef DISABLE_RES_CHANNELS_MCT /* for sba to stereo output disable any further processing for TCs > 2 as it is not needed*/ if ( st_ivas->sba_dirac_stereo_flag ) { @@ -178,7 +177,6 @@ ivas_error ivas_mct_dec( } } } -#endif /* MCT reconstruction and CoreCoder updates */ for ( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) @@ -1070,17 +1068,9 @@ static ivas_error ivas_mc_dec_reconfig( ivas_binRenderer_close( &st_ivas->hBinRenderer ); } -#ifdef FIX_197_CREND_INTERFACE if ( ( st_ivas->hCrendWrapper != NULL ) && ( st_ivas->hCrendWrapper->hCrend != NULL ) && ( st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV && st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV_ROOM && ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD || st_ivas->hRenderConfig->roomAcoustics.late_reverb_on == 0 ) ) ) -#else - if ( st_ivas->hCrend != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV && st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV_ROOM && ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD || st_ivas->hRenderConfig->roomAcoustics.late_reverb_on == 0 ) ) ) -#endif { -#ifdef FIX_197_CREND_INTERFACE ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) ); -#else - ivas_crend_close( st_ivas ); -#endif } if ( st_ivas->hBinRendererTd != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) ) @@ -1136,37 +1126,20 @@ static ivas_error ivas_mc_dec_reconfig( return error; } -#ifdef FIX_197_CREND_INTERFACE if ( st_ivas->hRenderConfig->roomAcoustics.late_reverb_on ) { -#ifdef FIX_329_ENABLE_TD_RENDERER_REVERB_MC if ( ( error = ivas_rend_initCrendWrapper( &st_ivas->hCrendWrapper ) ) != IVAS_ERR_OK ) -#else - if ( ( st_ivas->hCrendWrapper = (CREND_WRAPPER_HANDLE) malloc( sizeof( CREND_WRAPPER ) ) ) == NULL ) -#endif { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend Wrapper\n" ); } -#ifdef FIX_329_ENABLE_TD_RENDERER_REVERB_MC st_ivas->hCrendWrapper->hCrend = NULL; st_ivas->hCrendWrapper->hHrtfCrend = NULL; -#endif if ( ( st_ivas->hCrendWrapper->hCrend = (CREND_HANDLE) malloc( sizeof( CREND_DATA ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend\n" ); } } -#else - if ( st_ivas->hCrend == NULL && st_ivas->hRenderConfig->roomAcoustics.late_reverb_on ) - { - if ( ( st_ivas->hCrend = (CREND_HANDLE) malloc( sizeof( CREND_DATA ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend\n" ); - } - } -#endif } -#ifdef FIX_197_CREND_INTERFACE 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 ), @@ -1180,15 +1153,6 @@ static ivas_error ivas_mc_dec_reconfig( } st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns; } -#else - else if ( st_ivas->hCrend == NULL && ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) - { - if ( ivas_crend_open( st_ivas ) != IVAS_ERR_OK ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "ivas_crend_open failed" ); - } - } -#endif } /* mono/stereo */ else if ( output_config == AUDIO_CONFIG_MONO || output_config == AUDIO_CONFIG_STEREO ) diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 8780b4ea98d6397edf69a7ec701bc73a07d6021b..d06a2b8f5b6d9ecdd2d1ccd30309004f2e771e72 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -53,8 +53,13 @@ ivas_error ivas_td_binaural_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { +#ifdef TD5 + 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->hRenderConfig->directivity, st_ivas->hTransSetup, &st_ivas->hBinRendererTd, &st_ivas->binaural_latency_ns ); +#else 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 ); +#endif } @@ -72,20 +77,13 @@ ivas_error ivas_td_binaural_renderer( ) { return ivas_td_binaural_renderer_unwrap( -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND st_ivas->hReverb, -#else - st_ivas->hRenderConfig, st_ivas->ini_frame, -#ifdef FIX_197_CREND_INTERFACE - st_ivas->hCrendWrapper, -#else - st_ivas->hCrend, -#endif -#endif st_ivas->transport_config, -#ifndef FIX_330_ENABLE_TD_RENDERER_REVERB_REND - st_ivas->hDecoderConfig->output_Fs, -#endif st_ivas->hBinRendererTd, st_ivas->nchan_transport, LFE_CHANNEL, st_ivas->ivas_format, +#ifdef TD5 + st_ivas->hIsmMetaData, st_ivas->hDecoderConfig->Opt_Headrotation, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->Quaternions : NULL, + ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->Pos : NULL, output, output_frame ); +#else st_ivas->hIsmMetaData, st_ivas->hDecoderConfig->Opt_Headrotation, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->Quaternions : NULL, output, output_frame ); +#endif } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 525e775eb9f5361b886a14d07b3bd96f023295bb..76ac3578f9eab5d3eea290d4ba459d5fda9cbe08 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -65,9 +65,7 @@ ivas_error ivas_sba_dec_reconfigure( RENDERER_TYPE old_renderer_type; DECODER_CONFIG_HANDLE hDecoderConfig; ivas_error error; -#ifdef SBA_BR_SWITCHING_CLEAN_UP int16_t band_grouping[IVAS_MAX_NUM_BANDS + 1]; -#endif error = IVAS_ERR_OK; @@ -112,11 +110,7 @@ ivas_error ivas_sba_dec_reconfigure( if ( st_ivas->sba_mode != SBA_MODE_SPAR ) { -#ifndef SBA_BR_SWITCHING_CLEAN_UP - ivas_spar_dec_close( st_ivas->hSpar, hDecoderConfig->output_Fs ); -#else ivas_spar_dec_close( st_ivas->hSpar, hDecoderConfig->output_Fs, 0 ); -#endif st_ivas->hSpar = NULL; if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, st_ivas->sba_mode, -1 ) ) != IVAS_ERR_OK ) @@ -128,78 +122,11 @@ ivas_error ivas_sba_dec_reconfigure( } else { -#ifdef SBA_BR_SWITCHING_CLEAN_UP int16_t sba_order_internal; -#else - int16_t i, sba_order_internal, nchan_internal; - DIRAC_DEC_HANDLE hDirAC = st_ivas->hDirAC; -#endif SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); -#ifndef SBA_BR_SWITCHING_CLEAN_UP - nchan_internal = ivas_sba_get_nchan_metadata( sba_order_internal ); - if ( hSpar != NULL && nchan_transport_old != ivas_get_sba_num_TCs( ivas_total_brate, sba_order_internal ) ) - { - // VE: dirty patch -> reconfiguration of SPAR modules should be used instead !! - IVAS_FB_CFG *fb_cfg; - int16_t active_w_mixing; - - /* MD handle */ - ivas_spar_md_dec_close( &hSpar->hMdDec ); - - if ( ( error = ivas_spar_md_dec_open( &hSpar->hMdDec, st_ivas->hDecoderConfig, nchan_internal, sba_order_internal, st_ivas->sid_format ) ) != IVAS_ERR_OK ) - { - return error; - } - hSpar->hMdDec->td_decorr_flag = 1; - hSpar->hMdDec->table_idx = -1; - - /* TD decorr. */ - ivas_td_decorr_dec_close( &hSpar->hTdDecorr ); - - if ( ( error = ivas_td_decorr_dec_open( &hSpar->hTdDecorr, hDecoderConfig->output_Fs, nchan_internal, 1 ) ) != IVAS_ERR_OK ) - { - return error; - } - - /* FB mixer handle */ - ivas_FB_mixer_close( &hSpar->hFbMixer, hDecoderConfig->output_Fs ); - - /* set FB config. */ - active_w_mixing = -1; - if ( ( error = ivas_fb_set_cfg( &fb_cfg, SBA_FORMAT, SBA_MODE_SPAR, nchan_internal, nchan_internal, active_w_mixing, hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) - { - return error; - } - fb_cfg->pcm_offset = NS2SA( hDecoderConfig->output_Fs, DELAY_FB_1_NS + IVAS_ENC_DELAY_NS + IVAS_DEC_DELAY_NS ); - fb_cfg->remix_order = remix_order_set[hSpar->hMdDec->spar_md_cfg.remix_unmix_order]; - - /* FB mixer handle */ - if ( ( error = ivas_FB_mixer_open( &hSpar->hFbMixer, hDecoderConfig->output_Fs, fb_cfg ) ) != IVAS_ERR_OK ) - { - return error; - } - - /* mixer_mat intitialization */ - for ( i = 0; i < nchan_internal; i++ ) - { - for ( int16_t j = 0; j < nchan_internal; j++ ) - { - for ( int16_t b = 0; b < IVAS_MAX_NUM_BANDS; b++ ) - { - hSpar->hMdDec->mixer_mat[i][j][b] = 0.0f; - for ( int16_t i_ts = 0; i_ts < ( MAX_PARAM_SPATIAL_SUBFRAMES + 1 ); i_ts++ ) - { - hSpar->hMdDec->mixer_mat_prev[i_ts][i][j][b] = 0.0f; - } - } - } - } - hSpar->i_subframe = 0; - } -#else if ( hSpar != NULL ) { if ( ( hSpar->hPCA != NULL ) && ( ( hDecoderConfig->ivas_total_brate != PCA_BRATE ) || ( sba_order_internal != 1 ) ) ) @@ -230,61 +157,6 @@ ivas_error ivas_sba_dec_reconfigure( hSpar = st_ivas->hSpar; st_ivas->sba_dirac_stereo_flag = 0; -#endif -#ifndef SBA_BR_SWITCHING_CLEAN_UP - /* PCA handle */ - if ( hSpar != NULL ) - { - if ( hDecoderConfig->ivas_total_brate == PCA_BRATE && sba_order_internal == 1 ) - { - if ( ( hSpar->hPCA = (PCA_DEC_STATE *) malloc( sizeof( PCA_DEC_STATE ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for PCA decoder" ); - } - - ivas_pca_dec_init( hSpar->hPCA ); - } - else if ( hSpar->hPCA != NULL ) - { - free( st_ivas->hSpar->hPCA ); - hSpar->hPCA = NULL; - } - } - - if ( hSpar == NULL && st_ivas->sba_mode == SBA_MODE_SPAR ) - { - if ( ( error = ivas_spar_dec_open( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - - hSpar = st_ivas->hSpar; - } - st_ivas->sba_dirac_stereo_flag = 0; - - sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); - ivas_spar_config( ivas_total_brate, sba_order_internal, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, st_ivas->sid_format ); - - if ( hDirAC == NULL && st_ivas->sba_mode == SBA_MODE_DIRAC ) - { - if ( ( error = ivas_dirac_dec_open( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - - hDirAC = st_ivas->hDirAC; - } - - if ( hDirAC != NULL && sba_mode_old == st_ivas->sba_mode ) - { - ivas_dirac_dec_config( st_ivas, DIRAC_RECONFIGURE_MODE ); - } - - if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, st_ivas->sba_mode, IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) != IVAS_ERR_OK ) - { - return error; - } -#endif } if ( st_ivas->nchan_transport == 1 ) @@ -351,7 +223,6 @@ ivas_error ivas_sba_dec_reconfigure( ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); } -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) || ( sba_mode_old != st_ivas->sba_mode ) || ( ( st_ivas->sba_mode == SBA_MODE_SPAR ) && ( ( hDecoderConfig->output_config != AUDIO_CONFIG_FOA ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_STEREO ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_MONO ) ) ) ) { DIRAC_CONFIG_FLAG flag_config; @@ -393,27 +264,6 @@ ivas_error ivas_sba_dec_reconfigure( ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 ); } -#else - if ( ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) || ( sba_mode_old != st_ivas->sba_mode ) ) - { - DIRAC_CONFIG_FLAG flag_config; - - flag_config = DIRAC_OPEN; - if ( st_ivas->hDirAC != NULL ) - { - flag_config = DIRAC_RECONFIGURE; - if ( sba_mode_old != st_ivas->sba_mode && st_ivas->sba_mode != SBA_MODE_SPAR ) - { - flag_config = DIRAC_RECONFIGURE_MODE; - } - } - - if ( ( error = ivas_dirac_dec_config( st_ivas, flag_config ) ) != IVAS_ERR_OK ) - { - return error; - } - } -#endif else if ( st_ivas->renderer_type == RENDERER_DISABLE || ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC && st_ivas->sba_mode != SBA_MODE_SPAR ) ) { diff --git a/lib_dec/ivas_sce_dec.c b/lib_dec/ivas_sce_dec.c index ac948a59c402df48e298559593200cbe746b7506..228a6e7b3aeba421b73bcd7025ad25525fbe8b83 100644 --- a/lib_dec/ivas_sce_dec.c +++ b/lib_dec/ivas_sce_dec.c @@ -77,12 +77,10 @@ ivas_error ivas_sce_dec( ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; last_ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate; -#ifdef PARAM_ISM_DTX_CNG if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { st->cng_type = FD_CNG; /* TODO: move to init if possible */ } -#endif /*------------------------------------------------------------------* * Read audio bandwidth info @@ -100,15 +98,11 @@ ivas_error ivas_sce_dec( } else if ( !st_ivas->bfi && ( last_ivas_total_brate <= SID_2k40 || last_ivas_total_brate == IVAS_SID_5k2 ) ) { -#ifdef PARAM_ISM_DTX_CNG /* check if this is indeed needed? */ if ( st_ivas->ivas_format != ISM_FORMAT ) { st->total_brate = hSCE->element_brate - nb_bits_metadata * FRAMES_PER_SEC; } -#else - st->total_brate = hSCE->element_brate - nb_bits_metadata * FRAMES_PER_SEC; -#endif } /* read the bandwidth */ @@ -229,11 +223,7 @@ ivas_error ivas_sce_dec( * Decoder *----------------------------------------------------------------*/ -#ifdef PARAM_ISM_DTX_CNG if ( ( error = ivas_core_dec( st_ivas, hSCE, NULL, NULL, 1, output, outputHB, NULL, st_ivas->sba_dirac_stereo_flag ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_core_dec( NULL, hSCE, NULL, NULL, 1, output, outputHB, NULL, st_ivas->sba_dirac_stereo_flag ) ) != IVAS_ERR_OK ) -#endif { return error; } diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 7515300681b4cf38a149ac22ad0055011a87b224..53c60c3d3401d82898ef72a8464080c3186df47c 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -62,10 +62,8 @@ static void ivas_spar_dec_MD( Decoder_Struct *st_ivas, Decoder_State *st0 ); ivas_error ivas_spar_dec_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP , const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -#endif ) { SPAR_DEC_HANDLE hSpar; @@ -78,20 +76,16 @@ ivas_error ivas_spar_dec_open( error = IVAS_ERR_OK; sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); num_channels_internal = ivas_sba_get_nchan_metadata( sba_order_internal ); -#ifdef SBA_BR_SWITCHING_CLEAN_UP hSpar = st_ivas->hSpar; if ( !spar_reconfig_flag ) { -#endif /* SPAR decoder handle */ if ( ( hSpar = (SPAR_DEC_HANDLE) malloc( sizeof( SPAR_DEC_DATA ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR decoder" ); } -#ifdef SBA_BR_SWITCHING_CLEAN_UP } -#endif output_Fs = st_ivas->hDecoderConfig->output_Fs; @@ -119,11 +113,7 @@ ivas_error ivas_spar_dec_open( fb_cfg->remix_order = remix_order_set[hSpar->hMdDec->spar_md_cfg.remix_unmix_order]; /* FB mixer handle */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( ( error = ivas_FB_mixer_open( &hSpar->hFbMixer, output_Fs, fb_cfg, spar_reconfig_flag ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_FB_mixer_open( &hSpar->hFbMixer, output_Fs, fb_cfg ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -199,10 +189,8 @@ ivas_error ivas_spar_dec_open( void ivas_spar_dec_close( SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ const int32_t output_Fs /* i : output sampling rate */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP , const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -#endif ) { if ( hSpar != NULL ) @@ -214,11 +202,7 @@ void ivas_spar_dec_close( ivas_td_decorr_dec_close( &hSpar->hTdDecorr ); /* FB mixer handle */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP ivas_FB_mixer_close( &hSpar->hFbMixer, output_Fs, spar_reconfig_flag ); -#else - ivas_FB_mixer_close( &hSpar->hFbMixer, output_Fs ); -#endif /* AGC */ ivas_spar_agc_dec_close( &hSpar->hAgcDec ); @@ -230,15 +214,11 @@ void ivas_spar_dec_close( hSpar->hPCA = NULL; } -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( !spar_reconfig_flag ) { -#endif free( hSpar ); hSpar = NULL; -#ifdef SBA_BR_SWITCHING_CLEAN_UP } -#endif } return; @@ -826,57 +806,38 @@ void ivas_spar_get_parameters( weight = ivas_spar_get_cldfb_slot_gain( hSpar, hDecoderConfig, ts, &ts0, &ts1, &weight_20ms ); -#ifdef COV_SMOOTH_TUNING split_band = SPAR_DIRAC_SPLIT_START_BAND; -#else - split_band = hSpar->hMdDec->spar_md.num_bands; -#endif for ( spar_band = 0; spar_band < num_spar_bands; spar_band++ ) { for ( out_ch = 0; out_ch < num_ch_out; out_ch++ ) { -#ifndef COV_SMOOTH_TUNING - for ( in_ch = 0; in_ch < num_ch_in; in_ch++ ) + if ( split_band < IVAS_MAX_NUM_BANDS + /* 20ms cross-fade for Transport channels in all frequency bands */ + && ( 0 == ivas_is_res_channel( out_ch, hSpar->hMdDec->spar_md_cfg.nchan_transport ) ) /* sub-frame processing for missing channels in all frequency bands*/ + ) { -#endif - if ( split_band < IVAS_MAX_NUM_BANDS - /* 20ms cross-fade for Transport channels in all frequency bands */ - && ( 0 == ivas_is_res_channel( out_ch, hSpar->hMdDec->spar_md_cfg.nchan_transport ) ) /* sub-frame processing for missing channels in all frequency bands*/ - ) + for ( in_ch = 0; in_ch < num_ch_in; in_ch++ ) { -#ifdef COV_SMOOTH_TUNING - for ( in_ch = 0; in_ch < num_ch_in; in_ch++ ) + if ( hSpar->i_subframe > 3 ) { -#endif - if ( hSpar->i_subframe > 3 ) - { - par_mat[out_ch][in_ch][spar_band] = ( 1.0f - weight ) * hSpar->hMdDec->mixer_mat_prev[ts0][out_ch][in_ch][spar_band] + - weight * hSpar->hMdDec->mixer_mat_prev[ts1][out_ch][in_ch][spar_band]; - } - else - { - par_mat[out_ch][in_ch][spar_band] = hSpar->hMdDec->mixer_mat[out_ch][in_ch][spar_band]; - } -#ifdef COV_SMOOTH_TUNING + par_mat[out_ch][in_ch][spar_band] = ( 1.0f - weight ) * hSpar->hMdDec->mixer_mat_prev[ts0][out_ch][in_ch][spar_band] + + weight * hSpar->hMdDec->mixer_mat_prev[ts1][out_ch][in_ch][spar_band]; } -#endif - } - else - { -#ifdef COV_SMOOTH_TUNING - for ( in_ch = 0; in_ch < num_ch_in; in_ch++ ) + else { -#endif - /* 20ms Transport channel reconstruction with matching encoder/decoder processing */ - int16_t prev_idx = SPAR_DIRAC_SPLIT_START_BAND < IVAS_MAX_NUM_BANDS ? 1 : 0; /* if SPAR_DIRAC_SPLIT_START_BAND == IVAS_MAX_NUM_BANDS, then the sub-frame mixer_mat delay line is not active */ - par_mat[out_ch][in_ch][spar_band] = ( 1.0f - weight_20ms ) * hSpar->hMdDec->mixer_mat_prev[prev_idx][out_ch][in_ch][spar_band] + weight_20ms * hSpar->hMdDec->mixer_mat[out_ch][in_ch][spar_band]; -#ifdef COV_SMOOTH_TUNING + par_mat[out_ch][in_ch][spar_band] = hSpar->hMdDec->mixer_mat[out_ch][in_ch][spar_band]; } -#endif } -#ifndef COV_SMOOTH_TUNING } -#endif + else + { + for ( in_ch = 0; in_ch < num_ch_in; in_ch++ ) + { + /* 20ms Transport channel reconstruction with matching encoder/decoder processing */ + int16_t prev_idx = SPAR_DIRAC_SPLIT_START_BAND < IVAS_MAX_NUM_BANDS ? 1 : 0; /* if SPAR_DIRAC_SPLIT_START_BAND == IVAS_MAX_NUM_BANDS, then the sub-frame mixer_mat delay line is not active */ + par_mat[out_ch][in_ch][spar_band] = ( 1.0f - weight_20ms ) * hSpar->hMdDec->mixer_mat_prev[prev_idx][out_ch][in_ch][spar_band] + weight_20ms * hSpar->hMdDec->mixer_mat[out_ch][in_ch][spar_band]; + } + } } } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 4157438f80a1ea635c01b984a77422c03c24ba2f..51d825c0fb63277c478e8c1ba0051bdf2e5125d2 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -382,7 +382,6 @@ typedef struct stereo_icbwe_dec_data_structure } STEREO_ICBWE_DEC_DATA, *STEREO_ICBWE_DEC_HANDLE; -#ifdef PARAM_ISM_DTX_CNG /*----------------------------------------------------------------------------------* * ISM DTX structure *----------------------------------------------------------------------------------*/ @@ -393,7 +392,6 @@ typedef struct int16_t sce_id_dtx; } ISM_DTX_DATA_DEC; -#endif /*----------------------------------------------------------------------------------* * DirAC decoder structure @@ -1145,18 +1143,13 @@ typedef struct decoder_config_structure 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 */ -#ifdef FIX_351_HRTF_COMMAND - int16_t Opt_RendConfigCustom; /* indicates whether Renderer configuration custom setup is used */ -#endif - int16_t orientation_tracking; /* indicates orientation tracking type */ + int16_t Opt_RendConfigCustom; /* indicates whether Renderer configuration custom setup 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 -#ifndef REMOVE_FORCE_SUBFRAME_BIN - int16_t forceSubframeBinauralization; /* Flag for forcing Parametric binauralizer to subframe mode */ -#endif int16_t force_rend; /* forced TD/CLDFB binaural renderer (for ISM and MC) */ #endif @@ -1206,9 +1199,7 @@ typedef struct Decoder_Struct /* multichannel modules */ ISM_METADATA_HANDLE hIsmMetaData[MAX_NUM_OBJECTS]; /* ISM metadata handles (storage for one frame of read ISM metadata) */ -#ifdef PARAM_ISM_DTX_CNG ISM_DTX_DATA_DEC hISMDTX; /* ISM DTX structure */ -#endif ISM_RENDERER_HANDLE hIsmRendererData; /* ISM renderer handle */ DIRAC_DEC_HANDLE hDirAC; /* DirAC handle */ SPAR_DEC_HANDLE hSpar; /* SPAR handle */ @@ -1238,15 +1229,8 @@ typedef struct Decoder_Struct EFAP_HANDLE hEFAPdata; /* EFAP structure */ VBAP_HANDLE hVBAPdata; /* VBAP structure */ MONO_DOWNMIX_RENDERER_HANDLE hMonoDmxRenderer; /* Mono downmix structure */ -#ifdef FIX_197_CREND_INTERFACE CREND_WRAPPER_HANDLE hCrendWrapper; -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND REVERB_HANDLE hReverb; /* Reverb handle */ -#endif -#else - CREND_HANDLE hCrend; /* Convolution mixer renderer structure */ - HRTFS_HANDLE hHrtf; /* HRTFs handle */ -#endif HRTFS_CREND_HANDLE hSetOfHRTF; /* Set of HRTFs handle (CRend) */ HRTFS_FASTCONV_HANDLE hHrtfFastConv; /* FASTCONV HRTF tables for binaural rendering */ HRTFS_PARAMBIN_HANDLE hHrtfParambin; /* HRTF tables for parametric binauralizer */ diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index 378ddec9aa921002273f5e12022674cc1b4b9819..b8d96233dbe4d44d311cc6e71a04e3b0c8d0decf 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -161,11 +161,9 @@ void stereo_tcx_core_dec( const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */ STEREO_CNG_DEC_HANDLE hStereoCng, /* i : Stereo CNG handle */ const int16_t nchan_out /* i : number of output channels */ -#ifdef PARAM_ISM_DTX_CNG , const IVAS_FORMAT ivas_format, /* i : IVAS format */ const ISM_MODE ism_mode /* i : ISM mode (only needed if format is ISM) */ -#endif ) { int16_t i, k; @@ -729,7 +727,6 @@ void stereo_tcx_core_dec( if ( st->element_mode != IVAS_CPE_TD ) { -#ifdef PARAM_ISM_DTX_CNG if ( ivas_format == ISM_FORMAT && ism_mode == ISM_MODE_PARAM ) { float buffer[L_FRAME16k]; @@ -740,9 +737,6 @@ void stereo_tcx_core_dec( { ApplyFdCng( signal_out, NULL, NULL, NULL, st, st->bfi, 0 ); } -#else - ApplyFdCng( signal_out, NULL, NULL, NULL, st, st->bfi, 0 ); -#endif } /* Generate additional comfort noise to mask potential coding artefacts */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 6e9393672058219f1debb63d451cf117fa7a6592..da9c6efae4d79165cbeeee6784bf1622abd1bd1b 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -223,14 +223,7 @@ static void init_decoder_config( hDecoderConfig->Opt_LsCustom = 0; hDecoderConfig->Opt_HRTF_binary = 0; hDecoderConfig->Opt_Headrotation = 0; -#ifdef FIX_351_HRTF_COMMAND hDecoderConfig->Opt_RendConfigCustom = 0; -#endif -#ifndef REMOVE_FORCE_SUBFRAME_BIN -#ifdef DEBUGGING - hDecoderConfig->forceSubframeBinauralization = 0; -#endif -#endif hDecoderConfig->orientation_tracking = orientation_tracking; hDecoderConfig->no_diegetic_pan = no_diegetic_pan; @@ -395,16 +388,8 @@ ivas_error IVAS_DEC_Configure( const int16_t customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ const int16_t hrtfReaderEnabled, /* i : enable HRTF binary file input */ const int16_t enableHeadRotation /* i : enable head rotation for binaural output */ -#ifdef FIX_351_HRTF_COMMAND , const int16_t renderConfigEnabled /* i : enable Renderer config. file for binaural output */ -#endif -#ifndef REMOVE_FORCE_SUBFRAME_BIN -#ifdef DEBUGGING - , - const int16_t forceSubframeBinauralization /* i : enable subframe binauralization */ -#endif -#endif ) { Decoder_Struct *st_ivas; @@ -450,17 +435,10 @@ ivas_error IVAS_DEC_Configure( hDecoderConfig->nchan_out = audioCfg2channels( hDecoderConfig->output_config ); } -#ifndef REMOVE_FORCE_SUBFRAME_BIN -#ifdef DEBUGGING - hDecoderConfig->forceSubframeBinauralization = forceSubframeBinauralization; -#endif -#endif hDecoderConfig->Opt_LsCustom = customLsOutputEnabled; hDecoderConfig->Opt_Headrotation = enableHeadRotation; hDecoderConfig->Opt_HRTF_binary = hrtfReaderEnabled; -#ifdef FIX_351_HRTF_COMMAND hDecoderConfig->Opt_RendConfigCustom = renderConfigEnabled; -#endif /* Set decoder parameters to initial values */ if ( ( error = ivas_init_decoder_front( st_ivas ) ) != IVAS_ERR_OK ) @@ -856,7 +834,13 @@ ivas_error IVAS_DEC_GetObjectMetadata( { metadata->azimuth = hIsmMeta->azimuth; metadata->elevation = hIsmMeta->elevation; +#ifdef TD5 + metadata->radius = hIsmMeta->radius; + metadata->yaw = hIsmMeta->yaw; + metadata->pitch = hIsmMeta->pitch; +#else metadata->radius = 0.f; +#endif metadata->spread = 0.f; metadata->gainFactor = 1.f; } @@ -906,8 +890,13 @@ ivas_error IVAS_DEC_GetMasaMetadata( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_FeedHeadTrackData( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_QUATERNION *orientation /* i : head-tracking data */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ +#ifdef TD5 + IVAS_QUATERNION *orientation, /* i : head-tracking data, listener orientation */ + IVAS_POSITION *Pos /* i : listener position */ +#else + IVAS_QUATERNION *orientation /* i : head-tracking data, listener orientation */ +#endif ) { HEAD_TRACK_DATA_HANDLE hHeadTrackData; @@ -945,6 +934,11 @@ ivas_error IVAS_DEC_FeedHeadTrackData( hHeadTrackData->Quaternions[i].x = orientation[i].x; hHeadTrackData->Quaternions[i].y = orientation[i].y; hHeadTrackData->Quaternions[i].z = orientation[i].z; +#endif +#ifdef TD5 + hHeadTrackData->Pos[i].x = Pos[i].x; + hHeadTrackData->Pos[i].y = Pos[i].y; + hHeadTrackData->Pos[i].z = Pos[i].z; #endif } @@ -1192,6 +1186,9 @@ ivas_error IVAS_DEC_GetRenderConfig( mvr2r( hRCin->roomAcoustics.pFc_input, hRCout->room_acoustics.pFc_input, CLDFB_NO_CHANNELS_MAX ); mvr2r( hRCin->roomAcoustics.pAcoustic_rt60, hRCout->room_acoustics.pAcoustic_rt60, CLDFB_NO_CHANNELS_MAX ); mvr2r( hRCin->roomAcoustics.pAcoustic_dsr, hRCout->room_acoustics.pAcoustic_dsr, CLDFB_NO_CHANNELS_MAX ); +#ifdef TD5 + mvr2r( hRCin->directivity, hRCout->directivity, 3 ); +#endif return IVAS_ERR_OK; } @@ -1236,6 +1233,9 @@ ivas_error IVAS_DEC_FeedRenderConfig( mvr2r( renderConfig.room_acoustics.pFc_input, hRenderConfig->roomAcoustics.pFc_input, CLDFB_NO_CHANNELS_MAX ); mvr2r( renderConfig.room_acoustics.pAcoustic_rt60, hRenderConfig->roomAcoustics.pAcoustic_rt60, CLDFB_NO_CHANNELS_MAX ); mvr2r( renderConfig.room_acoustics.pAcoustic_dsr, hRenderConfig->roomAcoustics.pAcoustic_dsr, CLDFB_NO_CHANNELS_MAX ); +#ifdef TD5 + mvr2r( renderConfig.directivity, hRenderConfig->directivity, 3 ); +#endif return IVAS_ERR_OK; } @@ -2010,7 +2010,6 @@ static ivas_error printConfigInfo_dec( get_channel_config( st_ivas->hDecoderConfig->output_config, &config_str[0] ); fprintf( stdout, "Output configuration: %s\n", config_str ); -#ifdef FIX_351_HRTF_COMMAND if ( st_ivas->hDecoderConfig->Opt_HRTF_binary ) { fprintf( stdout, "HRIR/BRIR file: ON\n" ); @@ -2020,7 +2019,6 @@ static ivas_error printConfigInfo_dec( { fprintf( stdout, "Renderer config. file: ON\n" ); } -#endif if ( st_ivas->hDecoderConfig->Opt_Headrotation ) { diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 2e1f1d9557aed04124d5f80284585117ab3c7263..e115ecd1989773491b23185f65f91e02a77db492 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -130,16 +130,8 @@ ivas_error IVAS_DEC_Configure( const int16_t customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ const int16_t hrtfReaderEnabled, /* i : enable HRTF binary file input */ const int16_t enableHeadRotation /* i : enable head rotation for binaural output */ -#ifdef FIX_351_HRTF_COMMAND ,const int16_t renderConfigEnabled /* i : enable Renderer config. file for binaural output */ -#endif -#ifndef REMOVE_FORCE_SUBFRAME_BIN -#ifdef DEBUGGING - , - const int16_t forceSubframeBinauralization /* i : enable subframe binauralization */ -#endif -#endif ); void IVAS_DEC_Close( @@ -185,7 +177,12 @@ ivas_error IVAS_DEC_GetMasaMetadata( /*! r: error code */ ivas_error IVAS_DEC_FeedHeadTrackData( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ +#ifdef TD5 + IVAS_QUATERNION *orientation, /* i : head-tracking data */ + IVAS_POSITION *Pos /* i : listener position */ +#else IVAS_QUATERNION *orientation /* i : head-tracking data */ +#endif ); #ifdef FIX_I109_ORIENTATION_TRACKING diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index 0950b529f67151e65578f61417c3e9eaae4cbfb7..9ba901352c2af44ebc5a816c044e8a25158cb38a 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -1345,10 +1345,8 @@ typedef struct Decoder_State /* MCT Channel mode indication: LFE, ignore channel? */ MCT_CHAN_MODE mct_chan_mode; -#ifdef PARAM_ISM_DTX_CNG int16_t cng_paramISM_flag; /* CNG in Param-ISM flag */ int16_t read_sid_info; /* For ParamISM, use the transmitted noise */ -#endif } Decoder_State, *DEC_CORE_HANDLE; diff --git a/lib_enc/acelp_core_enc.c b/lib_enc/acelp_core_enc.c index 272d36fb9c53484bf7bd4e564c7d5b7db96c42d2..48cdb5c53614619ab4a6e765bdb1450ef659d48a 100644 --- a/lib_enc/acelp_core_enc.c +++ b/lib_enc/acelp_core_enc.c @@ -314,17 +314,13 @@ ivas_error acelp_core_enc( if ( st->core_brate == SID_2k40 ) { -#ifdef PARAM_ISM_DTX_CNG if ( st->hTdCngEnc != NULL ) { -#endif tmpF = cng_energy( st->element_mode, st->bwidth, st->hDtxEnc->CNG_mode, st->hTdCngEnc->CNG_att, exc, st->L_frame ); i = (int16_t) ( ( tmpF + 2.0f ) * STEP_SID ); i = min( max( i, 0 ), 127 ); st->hTdCngEnc->old_enr_index = i; -#ifdef PARAM_ISM_DTX_CNG } -#endif } } diff --git a/lib_enc/fd_cng_enc.c b/lib_enc/fd_cng_enc.c index 5789f0dfd9abb6cc9e10c40fa3c5209bc0bf50d0..e43b65d56a88383a225e5228d77b2c06bf1d4018 100644 --- a/lib_enc/fd_cng_enc.c +++ b/lib_enc/fd_cng_enc.c @@ -708,18 +708,14 @@ void generate_comfort_noise_enc( /* Perform STFT synthesis */ SynthesisSTFT( fftBuffer, timeDomainOutput, hFdCngCom->olapBufferSynth, hFdCngCom->olapWinSyn, tcx_transition, hFdCngCom, -1, -1 ); -#ifdef PARAM_ISM_DTX_CNG if ( st->hTdCngEnc != NULL ) { -#endif /* update CNG excitation energy for LP_CNG */ /* calculate the residual signal energy */ enr = cng_energy( st->element_mode, st->bwidth, st->hDtxEnc->CNG_mode, st->hTdCngEnc->CNG_att, hFdCngCom->exc_cng, hFdCngCom->frameSize ); st->hTdCngEnc->lp_ener = (float) ( 0.8f * st->hTdCngEnc->lp_ener + 0.2f * pow( 2.0f, enr ) ); -#ifdef PARAM_ISM_DTX_CNG } -#endif /* Overlap-add when previous frame is active */ if ( st->last_core_brate > SID_2k40 && st->codec_mode == MODE2 ) diff --git a/lib_enc/init_enc.c b/lib_enc/init_enc.c index 683356c6c084d7bb0abd5d72739d18835d46e4c8..7019beca8ea04742ef56a7e255f8b3f0aa0a836d 100644 --- a/lib_enc/init_enc.c +++ b/lib_enc/init_enc.c @@ -59,10 +59,8 @@ ivas_error init_encoder( const int16_t var_SID_rate_flag, /* i : flag for variable SID update rate */ const int16_t interval_SID, /* i : interval for SID update */ const int16_t vad_only_flag /* i : flag to indicate front-VAD structure */ -#ifdef PARAM_ISM_DTX_CNG , const ISM_MODE ism_mode /* i : ISM mode */ -#endif ) { int16_t i; @@ -466,11 +464,7 @@ ivas_error init_encoder( * LP-CNG *-----------------------------------------------------------------*/ -#ifdef PARAM_ISM_DTX_CNG if ( ( ( idchan == 0 && st->Opt_DTX_ON && st->element_mode != IVAS_CPE_MDCT ) || st->element_mode == EVS_MONO ) && !( ism_mode == ISM_MODE_PARAM ) ) -#else - if ( ( ( idchan == 0 && st->Opt_DTX_ON && st->element_mode != IVAS_CPE_MDCT ) || st->element_mode == EVS_MONO ) ) -#endif { if ( ( st->hTdCngEnc = (TD_CNG_ENC_HANDLE) malloc( sizeof( TD_CNG_ENC_DATA ) ) ) == NULL ) { diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index 000fbab33ebbabbaaba7787b9a47abc6181da856..6e2f6b6db2e1cf38298085f9fa7e38edf8de9af6 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -107,12 +107,7 @@ ivas_error pre_proc_front_ivas( const int16_t front_vad_flag, /* i : front-VAD flag to overwrite VAD decision */ const int16_t force_front_vad, /* i : flag to force VAD decision */ const int16_t front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision*/ -#ifdef LOW_RATE_TRANS_CORE_CODER - const int32_t ivas_total_brate /* i : IVAS total bitrate - for setting the DTX */ -#else - const int32_t ivas_total_brate, /* i : IVAS total bitrate - for setting the DTX */ - const int16_t ivas_format /* i : IVAS format */ -#endif + const int32_t ivas_total_brate /* i : IVAS total bitrate - for setting the DTX */ ) { @@ -811,11 +806,7 @@ ivas_error pre_proc_front_ivas( } } /* Switch to ACELP for non-harmonic transient signals */ -#ifdef LOW_RATE_TRANS_CORE_CODER else if ( ( ( element_mode >= IVAS_CPE_DFT && element_brate <= IVAS_16k4 ) || ( element_mode == IVAS_SCE && element_brate < SCE_SMC_THR ) ) && ( loc_harm[0] != 1 ) && smc_dec == MUSIC ) -#else - else if ( ( ( ivas_format == STEREO_FORMAT && element_brate <= IVAS_16k4 ) || ( ivas_format == ISM_FORMAT && element_brate < SCE_SMC_THR ) ) && ( loc_harm[0] != 1 ) && smc_dec == MUSIC ) -#endif { if ( element_mode == IVAS_SCE ) { diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 8339b03399153d04975eaa281f190f842c3ed16e..f9b787ac563f21c3015b916703110ae0362031bc 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -429,19 +429,11 @@ ivas_error ivas_cpe_enc( for ( n = 0; n < n_CoreChannels; n++ ) { -#ifdef LOW_RATE_TRANS_CORE_CODER error = pre_proc_front_ivas( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8[n], old_inp_16k[n], &ener[n], &relE[n], A[n], Aw[n], epsP[n], lsp_new[n], lsp_mid[n], &vad_hover_flag[n], &attack_flag[n], realBuffer[n], imagBuffer[n], old_wsp[n], pitch_fr[n], voicing_fr[n], &loc_harm[n], &cor_map_sum[n], &vad_flag_dtx[n], enerBuffer[n], fft_buff[n], A[0], lsp_new[0], currFlatness[n], tdm_ratio_idx, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, band_energies_LR, 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, 0, 0, ivas_total_brate ); -#else - error = pre_proc_front_ivas( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8[n], old_inp_16k[n], - &ener[n], &relE[n], A[n], Aw[n], epsP[n], lsp_new[n], lsp_mid[n], - &vad_hover_flag[n], &attack_flag[n], realBuffer[n], imagBuffer[n], old_wsp[n], pitch_fr[n], voicing_fr[n], &loc_harm[n], &cor_map_sum[n], &vad_flag_dtx[n], enerBuffer[n], - fft_buff[n], A[0], lsp_new[0], currFlatness[n], tdm_ratio_idx, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, band_energies_LR, 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, 0, 0, - ivas_total_brate, st_ivas->hEncoderConfig->ivas_format ); -#endif if ( error != IVAS_ERR_OK ) { return error; @@ -840,11 +832,7 @@ ivas_error create_cpe_enc( st->mct_chan_mode = MCT_CHAN_MODE_LFE; } -#ifdef PARAM_ISM_DTX_CNG if ( ( error = init_encoder( st, n, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 0, st_ivas->ism_mode ) ) != IVAS_ERR_OK ) -#else - if ( ( error = init_encoder( st, n, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 0 ) ) != IVAS_ERR_OK ) -#endif { return error; } diff --git a/lib_enc/ivas_dirac_enc.c b/lib_enc/ivas_dirac_enc.c index a143ff37d27439adf9ec2ff991f8a0ec48bd4de3..61edd0b9a973a3b590c90216ae37fdda137fc55c 100644 --- a/lib_enc/ivas_dirac_enc.c +++ b/lib_enc/ivas_dirac_enc.c @@ -104,11 +104,7 @@ ivas_error ivas_dirac_enc_open( return error; } /* Allocate and initialize FB mixer handle */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( ( error = ivas_FB_mixer_open( &( hDirAC->hFbMixer ), input_Fs, fb_cfg, 0 ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_FB_mixer_open( &( hDirAC->hFbMixer ), input_Fs, fb_cfg ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -261,11 +257,7 @@ void ivas_dirac_enc_close( if ( hDirAC->hFbMixer != NULL ) { -#ifdef SBA_BR_SWITCHING_CLEAN_UP ivas_FB_mixer_close( &hDirAC->hFbMixer, input_Fs, 0 ); -#else - ivas_FB_mixer_close( &hDirAC->hFbMixer, input_Fs ); -#endif } for ( i = 0; i < DIRAC_MAX_ANA_CHANS; i++ ) diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 0500a8e775da18d1c9e0b07ca3285b761ad4909a..1e4ba82207b1c46175653b55353b9f09e912e4ef 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -132,14 +132,11 @@ ivas_error ivas_enc( /* bypass EVS coding in float precision, emulating EVS encoder/decoder delay */ for ( i = 0; i < n; i++ ) { -#ifdef SBA_HPF_TUNING_ENC if ( ( ivas_format == SBA_FORMAT ) && ( st_ivas->sba_mode == SBA_MODE_SPAR ) ) { hp20( data_f[HOA_keep_ind[i]], input_frame, st_ivas->mem_hp20_in[i], input_Fs ); } - else -#endif - if ( !( ivas_format == MC_FORMAT && i == LFE_CHANNEL ) ) /*TODO: is the HPF needed for LFE channel? */ + else if ( !( ivas_format == MC_FORMAT && i == LFE_CHANNEL ) ) /*TODO: is the HPF needed for LFE channel? */ { hp20( data_f[i], input_frame, st_ivas->mem_hp20_in[i], input_Fs ); } diff --git a/lib_enc/ivas_enc_cov_handler.c b/lib_enc/ivas_enc_cov_handler.c index b70c05e96205010bdbdf0b759ee87dfaed3aadc4..23d0bdd0e59c253aad7756ce36fc77976dc1a94e 100644 --- a/lib_enc/ivas_enc_cov_handler.c +++ b/lib_enc/ivas_enc_cov_handler.c @@ -150,12 +150,7 @@ void ivas_enc_cov_handler_process( const int16_t end_band, const int16_t num_ch, const int16_t dtx_vad, -#ifdef SMOOTH_WITH_TRANS_DET - const int16_t transient_det[2] -#else - const int16_t transient_det -#endif -) + const int16_t transient_det[2] ) { int16_t i, j; int16_t dtx_cov_flag; @@ -218,11 +213,7 @@ void ivas_enc_cov_handler_process( } else { -#ifdef SMOOTH_WITH_TRANS_DET if ( ( transient_det[0] == 0 ) && ( transient_det[1] == 0 ) ) -#else - if ( transient_det == 0 ) -#endif { ivas_cov_smooth_process( hCovEnc->pCov_dtx_state, cov_dtx_real, pFb, start_band, end_band, num_ch, transient_det ); hCovEnc->prior_dtx_present = 1; diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index cce80138cb7202e2384b3304174f8f42d6281afc..766caa1519443179cc46ca125ff0c395a9f333cf 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -184,11 +184,7 @@ int16_t getNumChanAnalysis( n = st_ivas->nSCE + CPE_CHANNELS * st_ivas->nCPE; if ( st_ivas->hEncoderConfig->ivas_format == SBA_FORMAT ) { -#ifdef SBA_HPF_TUNING_ENC n = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order ); -#else - n = DIRAC_MAX_ANA_CHANS; -#endif } else if ( st_ivas->hEncoderConfig->ivas_format == MC_FORMAT && ( st_ivas->mc_mode == MC_MODE_PARAMMC || st_ivas->mc_mode == MC_MODE_MCMASA ) ) { @@ -276,10 +272,8 @@ void ivas_initialize_handles_enc( st_ivas->hIsmMetaData[i] = NULL; } -#ifdef PARAM_ISM_DTX_CNG /* ISM DTX handle */ st_ivas->hISMDTX = NULL; -#endif /* Q Metadata handle */ st_ivas->hQMetaData = NULL; @@ -437,7 +431,6 @@ ivas_error ivas_init_encoder( } } -#ifdef PARAM_ISM_DTX_CNG if ( st_ivas->hEncoderConfig->Opt_DTX_ON && st_ivas->ism_mode == ISM_MODE_PARAM ) { if ( ( error = ivas_ism_dtx_open( st_ivas ) ) != IVAS_ERR_OK ) @@ -445,7 +438,6 @@ ivas_error ivas_init_encoder( return error; } } -#endif } else if ( ivas_format == SBA_FORMAT || ivas_format == MASA_FORMAT ) { @@ -462,11 +454,7 @@ ivas_error ivas_init_encoder( if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( ( error = ivas_spar_enc_open( st_ivas, 0 ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_spar_enc_open( st_ivas ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -937,14 +925,12 @@ void ivas_destroy_enc( } } -#ifdef PARAM_ISM_DTX_CNG /* ISM DTX Handle */ if ( st_ivas->hISMDTX != NULL ) { free( st_ivas->hISMDTX ); st_ivas->hISMDTX = NULL; } -#endif /* Q Metadata handle */ ivas_qmetadata_close( &( st_ivas->hQMetaData ) ); @@ -966,11 +952,7 @@ void ivas_destroy_enc( /* SPAR handle */ if ( st_ivas->hSpar != NULL ) { -#ifdef SBA_BR_SWITCHING_CLEAN_UP ivas_spar_enc_close( st_ivas->hSpar, st_ivas->hEncoderConfig->input_Fs, nchan_inp, 0 ); -#else - ivas_spar_enc_close( st_ivas->hSpar, st_ivas->hEncoderConfig->input_Fs, nchan_inp ); -#endif st_ivas->hSpar = NULL; } diff --git a/lib_enc/ivas_ism_dtx_enc.c b/lib_enc/ivas_ism_dtx_enc.c index 2fea85e44a05fd0f017ea0038928218082d08099..fe358f6c90815691223046ce81053b5b023dfe66 100644 --- a/lib_enc/ivas_ism_dtx_enc.c +++ b/lib_enc/ivas_ism_dtx_enc.c @@ -41,7 +41,6 @@ #endif #include "wmc_auto.h" -#ifdef PARAM_ISM_DTX_CNG /*-------------------------------------------------------------------* * ivas_ism_dtx_open() @@ -333,4 +332,3 @@ void ivas_ism_coh_estim_dtx_enc( return; } -#endif diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index 85b8e0c4aa8092cdaa951dfbde8472bddd650df0..42f877aa1730524c7cbf9b8bafcb4bcb06a0920a 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -86,9 +86,7 @@ ivas_error ivas_ism_enc( float lf_E[1][2 * VOIC_BINS]; /* per bin spectrum energy in lf */ int16_t localVAD_HE_SAD[1]; /* local HE VAD */ int16_t i, nBits; -#ifdef PARAM_ISM_DTX_CNG int16_t dtx_flag, sid_flag; -#endif ivas_error error; push_wmops( "ivas_ism_enc" ); @@ -99,10 +97,8 @@ ivas_error ivas_ism_enc( error = IVAS_ERR_OK; -#ifdef PARAM_ISM_DTX_CNG dtx_flag = 0; sid_flag = 0; -#endif /*------------------------------------------------------------------* * Preprocesing @@ -158,19 +154,11 @@ ivas_error ivas_ism_enc( * Front Pre-processing *----------------------------------------------------------------*/ -#ifdef LOW_RATE_TRANS_CORE_CODER error = pre_proc_front_ivas( hSCE, NULL, hSCE->element_brate, nb_bits_metadata[sce_id], input_frame, 0, old_inp_12k8[sce_id][0], old_inp_16k[sce_id][0], &ener[sce_id][0], &relE[sce_id][0], A[sce_id][0], Aw[sce_id][0], epsP[sce_id][0], lsp_new[sce_id][0], lsp_mid[sce_id][0], &vad_hover_flag[sce_id][0], &attack_flag[sce_id][0], realBuffer[sce_id][0], imagBuffer[sce_id][0], old_wsp[sce_id][0], pitch_fr[sce_id][0], voicing_fr[sce_id][0], &loc_harm[sce_id][0], &cor_map_sum[sce_id][0], &vad_flag_dtx[sce_id][0], enerBuffer[sce_id][0], fft_buff[sce_id][0], A[sce_id][0], lsp_new[sce_id][0], currFlatness[0], 0, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, NULL, 0, 0, 0, 0, st_ivas->hEncoderConfig->ivas_total_brate ); -#else - error = pre_proc_front_ivas( hSCE, NULL, hSCE->element_brate, nb_bits_metadata[sce_id], input_frame, 0, old_inp_12k8[sce_id][0], old_inp_16k[sce_id][0], - &ener[sce_id][0], &relE[sce_id][0], A[sce_id][0], Aw[sce_id][0], epsP[sce_id][0], lsp_new[sce_id][0], lsp_mid[sce_id][0], - &vad_hover_flag[sce_id][0], &attack_flag[sce_id][0], realBuffer[sce_id][0], imagBuffer[sce_id][0], old_wsp[sce_id][0], pitch_fr[sce_id][0], voicing_fr[sce_id][0], &loc_harm[sce_id][0], &cor_map_sum[sce_id][0], &vad_flag_dtx[sce_id][0], enerBuffer[sce_id][0], - fft_buff[sce_id][0], A[sce_id][0], lsp_new[sce_id][0], currFlatness[0], 0, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, NULL, 0, 0, 0, 0, - st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->hEncoderConfig->ivas_format ); -#endif if ( error != IVAS_ERR_OK ) { return error; @@ -179,7 +167,6 @@ ivas_error ivas_ism_enc( vad_flag[sce_id] = st->vad_flag; } -#ifdef PARAM_ISM_DTX_CNG /*------------------------------------------------------------------* * DTX analysis *-----------------------------------------------------------------*/ @@ -203,14 +190,12 @@ ivas_error ivas_ism_enc( dbgwrite( &( st_ivas->hISMDTX->dtx_flag ), sizeof( int16_t ), 1, 1, "./res/ParamISM_DTX_CNG_flag_enc.dat" ); #endif } -#endif /*------------------------------------------------------------------* * Analysis of objects, configuration and decision about bitrates per channel * Metadata quantization and encoding *-----------------------------------------------------------------*/ -#ifdef PARAM_ISM_DTX_CNG if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { ivas_param_ism_compute_noisy_speech_flag( st_ivas ); @@ -223,46 +208,21 @@ ivas_error ivas_ism_enc( ivas_param_ism_metadata_dtx_enc( st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData, st_ivas->hIsmMetaData, st_ivas->hISMDTX, st_ivas->hDirAC->hParamIsm ); } } - else -#endif - if ( st_ivas->ism_mode == ISM_MODE_PARAM ) + else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { -#ifndef PARAM_ISM_DTX_CNG - /* Move the Noisy speech buffer */ - for ( i = 0; i < ( PARAM_ISM_HYS_BUF_SIZE - 1 ); i++ ) - { - st_ivas->hDirAC->hParamIsm->noisy_speech_buffer[i] = st_ivas->hDirAC->hParamIsm->noisy_speech_buffer[i + 1]; - } - - /* For the current frame, make a decision based on some core-coder flags */ - if ( st_ivas->hSCE[0]->hCoreCoder[0]->flag_noisy_speech_snr && st_ivas->hSCE[1]->hCoreCoder[0]->flag_noisy_speech_snr ) - { - if ( st_ivas->hSCE[0]->hCoreCoder[0]->vad_flag || st_ivas->hSCE[1]->hCoreCoder[0]->vad_flag ) - { - st_ivas->hDirAC->hParamIsm->noisy_speech_buffer[i] = 0; - } - else - { - st_ivas->hDirAC->hParamIsm->noisy_speech_buffer[i] = 1; - } - } - else - { - st_ivas->hDirAC->hParamIsm->noisy_speech_buffer[i] = 0; - } - - /* Do a decision based on hysterisis */ - st_ivas->hDirAC->hParamIsm->flag_noisy_speech = 1; - for ( i = 0; i < PARAM_ISM_HYS_BUF_SIZE; i++ ) - { - st_ivas->hDirAC->hParamIsm->flag_noisy_speech = st_ivas->hDirAC->hParamIsm->flag_noisy_speech && st_ivas->hDirAC->hParamIsm->noisy_speech_buffer[i]; - } -#endif +#ifdef TD5 + ivas_ism_metadata_enc( st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData, nb_bits_metadata, vad_flag, st_ivas->ism_mode, st_ivas->hDirAC->hParamIsm, st_ivas->hEncoderConfig->ism_extended_metadata_flag ); +#else ivas_ism_metadata_enc( st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData, nb_bits_metadata, vad_flag, st_ivas->ism_mode, st_ivas->hDirAC->hParamIsm ); +#endif } else /* ISM_MODE_DISC */ { +#ifdef TD5 + ivas_ism_metadata_enc( st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData, nb_bits_metadata, vad_flag, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag ); +#else ivas_ism_metadata_enc( st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData, nb_bits_metadata, vad_flag, st_ivas->ism_mode, NULL ); +#endif } /*----------------------------------------------------------------* @@ -275,9 +235,7 @@ ivas_error ivas_ism_enc( { ivas_write_format_sid( st_ivas->hEncoderConfig->ivas_format, IVAS_SCE, st->hBstr ); -#ifdef PARAM_ISM_DTX_CNG if ( st_ivas->ism_mode != ISM_MODE_PARAM ) -#endif { /* write unused bits */ nBits = ( IVAS_SID_5k2 - SID_2k40 ) / 50 - SID_FORMAT_NBITS; @@ -329,9 +287,7 @@ ivas_error ivas_ism_enc( * Encoder *----------------------------------------------------------------*/ -#ifdef PARAM_ISM_DTX_CNG if ( !dtx_flag || ( dtx_flag && sce_id == st_ivas->hISMDTX->sce_id_dtx ) ) -#endif { if ( ( error = ivas_core_enc( hSCE, NULL, NULL, 1, old_inp_12k8[sce_id], old_inp_16k[sce_id], ener[sce_id], A[sce_id], Aw[sce_id], epsP[sce_id], lsp_new[sce_id], lsp_mid[sce_id], vad_hover_flag[sce_id], attack_flag[sce_id], realBuffer[sce_id], imagBuffer[sce_id], old_wsp[sce_id], loc_harm[sce_id], cor_map_sum[sce_id], vad_flag_dtx[sce_id], enerBuffer[sce_id], fft_buff[sce_id], 0, ISM_FORMAT, 0 ) ) != IVAS_ERR_OK ) { @@ -350,7 +306,6 @@ ivas_error ivas_ism_enc( st->hTranDet->transientDetector.prev_bIsAttackPresent = st->hTranDet->transientDetector.bIsAttackPresent; } -#ifdef PARAM_ISM_DTX_CNG if ( dtx_flag ) { for ( sce_id = 0; sce_id < st_ivas->nchan_transport; sce_id++ ) @@ -362,7 +317,6 @@ ivas_error ivas_ism_enc( } } } -#endif pop_wmops(); diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index 2c7150b6c3107748a1db8dcf36c5a7a2a55c15fd..3472de0c5a1fc3bafa98b8158edde9aa2e758e0c 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -49,15 +49,30 @@ * Local constants *-----------------------------------------------------------------------*/ +#ifdef TD5 +#define ISM_NUM_PARAM 5 /* number of coded metadata parameters */ +#else #define ISM_NUM_PARAM 2 /* number of coded metadata parameters */ +#endif #define ISM_MAX_AZIMUTH_DIFF_IDX ( ISM_AZIMUTH_NBITS - 1 /*zero*/ - 1 /*sign*/ ) #define ISM_MAX_ELEVATION_DIFF_IDX ( ISM_ELEVATION_NBITS - 1 /*zero*/ - 1 /*sign*/ ) +#ifdef TD5 +#define ISM_MAX_RADIUS_DIFF_IDX ( ISM_RADIUS_NBITS - 1 /*zero*/ - 1 /*sign*/ ) +#endif #define ISM_FEC_MAX 10 #define INTER_OBJECT_PARAM_CHECK ( ( ISM_FEC_MAX / 2 ) - 2 ) /* note: constant must be less than (ISM_FEC_MAX / number of coded parameters) */ +#ifdef TD5 +/*-----------------------------------------------------------------------* + * Local functions + *-----------------------------------------------------------------------*/ +static void encode_angle_indices( BSTR_ENC_HANDLE hBstr, ISM_METADATA_ANGLE_HANDLE angle, const int16_t last_ism_metadata_flag, const int16_t ini_frame, const int16_t idx_azimuth_abs, const int16_t idx_elevation_abs, int16_t *flag_abs_azimuth, int16_t *flag_abs_elevation ); +static void encode_radius( BSTR_ENC_HANDLE hBstr, int16_t *last_radius_idx, int16_t *radius_diff_cnt, const int16_t last_ism_metadata_flag, const int16_t idx_radius_abs, int16_t *flag_abs_radius ); + +#endif /*-------------------------------------------------------------------------* * ivas_set_ism_metadata() @@ -68,7 +83,14 @@ ivas_error ivas_set_ism_metadata( ISM_METADATA_HANDLE hIsmMeta, /* o : ISM metadata handle */ const float azimuth, /* i : azimuth value */ - const float elevation /* i : elevation value */ +#ifdef TD5 + const float elevation, /* i : elevation */ + float radius_meta, /* i : radius */ + float yaw, /* i : yaw */ + float pitch /* i : pitch */ +#else + const float elevation /* i : elevation value */ +#endif ) { if ( hIsmMeta == NULL ) @@ -81,7 +103,11 @@ ivas_error ivas_set_ism_metadata( /* save read metadata parameters to the internal codec structure */ hIsmMeta->azimuth = azimuth; hIsmMeta->elevation = elevation; - +#ifdef TD5 + hIsmMeta->radius = radius_meta; + hIsmMeta->yaw = yaw; + hIsmMeta->pitch = pitch; +#endif return IVAS_ERR_OK; } @@ -146,20 +172,37 @@ static void rate_ism_importance( *-------------------------------------------------------------------------*/ ivas_error ivas_ism_metadata_enc( - const int32_t ism_total_brate, /* i : ISms total bitrate */ - const int16_t nchan_transport, /* i : number of transport channels */ - ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ - SCE_ENC_HANDLE hSCE[], /* i/o: SCE encoder handles */ - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - int16_t nb_bits_metadata[], /* o : number of metadata bits */ - const int16_t localVAD[], /* i : VAD flag */ - const int16_t ism_mode, /* i : ISM mode */ + const int32_t ism_total_brate, /* i : ISms total bitrate */ + const int16_t nchan_transport, /* i : number of transport channels */ + ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ + SCE_ENC_HANDLE hSCE[], /* i/o: SCE encoder handles */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + int16_t nb_bits_metadata[], /* o : number of metadata bits */ + const int16_t localVAD[], /* i : VAD flag */ + const int16_t ism_mode, /* i : ISM mode */ +#ifdef TD5 + const PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i : Param ISM Enc Handle */ + const int16_t ism_extended_metadata_flag /* i : Extended metadata flag */ +#else const PARAM_ISM_CONFIG_HANDLE hParamIsm /* i : Param ISM Enc Handle */ +#endif ) { +#ifdef TD5 +#ifdef TUNE_360_OBJECT_WITH_NOISE + int16_t i, ch, nb_bits_start = 0; +#else + int16_t i, ch, nb_bits_start = 0, diff; +#endif + int16_t idx_azimuth_abs = 0, flag_abs_azimuth[MAX_NUM_OBJECTS]; + int16_t idx_elevation_abs = 0, flag_abs_elevation[MAX_NUM_OBJECTS]; + int16_t flag_abs_azimuth_orientation[MAX_NUM_OBJECTS]; + int16_t idx_radius_abs = 0, flag_abs_radius[MAX_NUM_OBJECTS]; +#else int16_t i, ch, nb_bits_start = 0, diff; int16_t idx_azimuth, idx_azimuth_abs = 0, flag_abs_azimuth[MAX_NUM_OBJECTS], nbits_diff_azimuth; int16_t idx_elevation, idx_elevation_abs = 0, flag_abs_elevation[MAX_NUM_OBJECTS], nbits_diff_elevation; +#endif float valQ; ISM_METADATA_HANDLE hIsmMetaData; int32_t element_brate[MAX_NUM_OBJECTS], total_brate[MAX_NUM_OBJECTS]; @@ -198,6 +241,11 @@ ivas_error ivas_ism_metadata_enc( set_s( nb_bits_metadata, 0, nchan_transport ); set_s( flag_abs_azimuth, 0, num_obj ); set_s( flag_abs_elevation, 0, num_obj ); +#ifdef TD5 + set_s( flag_abs_azimuth_orientation, 0, num_obj ); + set_s( flag_abs_radius, 0, num_obj ); +#endif + /*----------------------------------------------------------------* * Set Metadata presence / importance flag @@ -211,6 +259,35 @@ ivas_error ivas_ism_metadata_enc( } else if ( ism_mode == ISM_MODE_DISC ) { +#ifdef TD5 +#ifdef TUNE_360_OBJECT_WITH_NOISE + /* In case of low level noise for low bitrate inactive frames, do not sent metadata */ + if ( localVAD[ch] == 0 && !( hSCE[ch]->hCoreCoder[0]->tcxonly ) && ( hSCE[ch]->hCoreCoder[0]->lp_noise <= 10 ) ) + { + hIsmMeta[ch]->ism_metadata_flag = 0; + } +#else + if ( hIsmMeta[ch]->ism_metadata_flag ) + { + /* at highest bitrates (with TCX core only) metadata are sent also for inactive frames */ + if ( localVAD[ch] == 0 && !( hSCE[ch]->hCoreCoder[0]->tcxonly ) ) + { + /* send metadata even in inactive segments when noise is audible and metadata are changing */ + diff = (int16_t) fabsf( hIsmMeta[ch]->azimuth - ism_dequant_meta( hIsmMeta[ch]->angle[0].last_azimuth_idx, ism_azimuth_borders, 1 << ISM_AZIMUTH_NBITS ) ); + diff = max( diff, (int16_t) fabsf( hIsmMeta[ch]->elevation - ism_dequant_meta( hIsmMeta[ch]->angle[0].last_elevation_idx, ism_elevation_borders, 1 << ISM_ELEVATION_NBITS ) ) ); + if ( ism_total_brate >= ISM_EXTENDED_METADATA_BRATE && ism_extended_metadata_flag ) + { + diff = max( diff, (int16_t) fabsf( hIsmMeta[ch]->yaw - ism_dequant_meta( hIsmMeta[ch]->angle[1].last_azimuth_idx, ism_azimuth_borders, 1 << ISM_AZIMUTH_NBITS ) ) ); + diff = max( diff, (int16_t) fabsf( hIsmMeta[ch]->pitch - ism_dequant_meta( hIsmMeta[ch]->angle[1].last_elevation_idx, ism_elevation_borders, 1 << ISM_ELEVATION_NBITS ) ) ); + } + if ( !( hSCE[ch]->hCoreCoder[0]->lp_noise > 15 && diff >= 10 ) ) + { + hIsmMeta[ch]->ism_metadata_flag = 0; + } + } + } +#endif +#else #ifdef TUNE_360_OBJECT_WITH_NOISE hIsmMeta[ch]->ism_metadata_flag = localVAD[ch] || hSCE[ch]->hCoreCoder[0]->lp_noise > 10; #else @@ -234,6 +311,7 @@ ivas_error ivas_ism_metadata_enc( /* at highest bitrates (with TCX core only) metadata are sent in every frame */ hIsmMeta[ch]->ism_metadata_flag = 1; } +#endif } } @@ -274,7 +352,12 @@ ivas_error ivas_ism_metadata_enc( push_indice( hBstr, IND_ISM_NUM_OBJECTS, 1, 1 ); } push_indice( hBstr, IND_ISM_NUM_OBJECTS, 0, 1 ); - +#ifdef TD5 + if ( ism_total_brate >= ISM_EXTENDED_METADATA_BRATE ) + { + push_indice( hBstr, IND_ISM_EXTENDED_FLAG, ism_extended_metadata_flag, ISM_EXTENDED_METADATA_BITS ); + } +#endif /* write ISm metadata flag (one per object) */ for ( ch = 0; ch < nchan_transport; ch++ ) { @@ -323,6 +406,39 @@ ivas_error ivas_ism_metadata_enc( if ( hIsmMeta[ch]->ism_metadata_flag ) { + +#ifdef TD5 + /*----------------------------------------------------------------* + * Obtain quantizer indices for azimuth and elevation + *----------------------------------------------------------------*/ + if ( ism_mode == ISM_MODE_DISC ) + { + idx_azimuth_abs = ism_quant_meta( hIsmMetaData->azimuth, &valQ, ism_azimuth_borders, 1 << ISM_AZIMUTH_NBITS ); + idx_elevation_abs = ism_quant_meta( hIsmMetaData->elevation, &valQ, ism_elevation_borders, 1 << ISM_ELEVATION_NBITS ); + } + else /* ISM_MODE_PARAM */ + { + idx_azimuth_abs = hParamIsm->azi_index[ch]; + idx_elevation_abs = hParamIsm->ele_index[ch]; + } + + encode_angle_indices( hBstr, &( hIsmMetaData->angle[0] ), hIsmMetaData->last_ism_metadata_flag, hSCE[0]->hCoreCoder[0]->ini_frame, idx_azimuth_abs, idx_elevation_abs, &flag_abs_azimuth[ch], &flag_abs_elevation[ch] ); + + /* Encode orientation and radius, if above certain bit rate etc, discrete ISM */ + if ( ism_mode == ISM_MODE_DISC && ism_extended_metadata_flag ) + { + idx_azimuth_abs = ism_quant_meta( hIsmMetaData->yaw, &valQ, ism_azimuth_borders, 1 << ISM_AZIMUTH_NBITS ); + idx_elevation_abs = ism_quant_meta( hIsmMetaData->pitch, &valQ, ism_elevation_borders, 1 << ISM_ELEVATION_NBITS ); + idx_radius_abs = usquant( hIsmMetaData->radius, &valQ, ISM_RADIUS_MIN, ISM_RADIUS_DELTA, 1 << ISM_RADIUS_NBITS ); + encode_angle_indices( hBstr, &( hIsmMetaData->angle[1] ), hIsmMetaData->last_ism_metadata_flag, hSCE[0]->hCoreCoder[0]->ini_frame, idx_azimuth_abs, idx_elevation_abs, &flag_abs_azimuth_orientation[ch], &flag_abs_elevation[ch] ); + encode_radius( hBstr, &hIsmMetaData->last_radius_idx, &hIsmMetaData->radius_diff_cnt, hIsmMetaData->last_ism_metadata_flag, idx_radius_abs, &flag_abs_radius[ch] ); + } + /* save number of metadata bits written */ + if ( ism_mode == ISM_MODE_DISC ) + { + nb_bits_metadata[ch] = hBstr->nb_bits_tot - nb_bits_start; + } +#else /*----------------------------------------------------------------* * Azimuth quantization and encoding *----------------------------------------------------------------*/ @@ -567,6 +683,7 @@ ivas_error ivas_ism_metadata_enc( { nb_bits_metadata[ch] = hBstr->nb_bits_tot - nb_bits_start; } +#endif } } @@ -579,7 +696,11 @@ ivas_error ivas_ism_metadata_enc( while ( i == 0 || i < num_obj / INTER_OBJECT_PARAM_CHECK ) { int16_t num, abs_num, abs_first, abs_next, pos_zero; +#ifdef TD5 + int16_t abs_matrice[INTER_OBJECT_PARAM_CHECK * ISM_NUM_PARAM]; +#else int16_t abs_matrice[INTER_OBJECT_PARAM_CHECK * 2]; +#endif num = min( INTER_OBJECT_PARAM_CHECK, num_obj - i * INTER_OBJECT_PARAM_CHECK ); i++; @@ -627,12 +748,20 @@ ivas_error ivas_ism_metadata_enc( if ( abs_next % ISM_NUM_PARAM == 0 ) { +#ifdef TD5 + hIsmMeta[ch]->angle[0].azimuth_diff_cnt = abs_num - 1; +#else hIsmMeta[ch]->azimuth_diff_cnt = abs_num - 1; +#endif } if ( abs_next % ISM_NUM_PARAM == 1 ) { +#ifdef TD5 + hIsmMeta[ch]->angle[0].elevation_diff_cnt = abs_num - 1; +#else hIsmMeta[ch]->elevation_diff_cnt = abs_num - 1; +#endif /*hIsmMeta[ch]->elevation_diff_cnt = min( hIsmMeta[ch]->elevation_diff_cnt, ISM_FEC_MAX );*/ } @@ -767,10 +896,23 @@ ivas_error ivas_ism_metadata_enc_create( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for ISm MetaData\n" ) ); } +#ifdef TD5 + st_ivas->hIsmMetaData[ch]->angle[0].last_azimuth_idx = 0; + st_ivas->hIsmMetaData[ch]->angle[0].azimuth_diff_cnt = ISM_FEC_MAX; + st_ivas->hIsmMetaData[ch]->angle[0].last_elevation_idx = 0; + st_ivas->hIsmMetaData[ch]->angle[0].elevation_diff_cnt = ISM_FEC_MAX - 1; + st_ivas->hIsmMetaData[ch]->last_radius_idx = 0; + st_ivas->hIsmMetaData[ch]->radius_diff_cnt = ISM_FEC_MAX - 2; + st_ivas->hIsmMetaData[ch]->angle[1].last_azimuth_idx = 0; + st_ivas->hIsmMetaData[ch]->angle[1].azimuth_diff_cnt = ISM_FEC_MAX - 2; + st_ivas->hIsmMetaData[ch]->angle[1].last_elevation_idx = 0; + st_ivas->hIsmMetaData[ch]->angle[1].elevation_diff_cnt = ISM_FEC_MAX - 2; +#else st_ivas->hIsmMetaData[ch]->last_azimuth_idx = 0; st_ivas->hIsmMetaData[ch]->azimuth_diff_cnt = ISM_FEC_MAX; st_ivas->hIsmMetaData[ch]->last_elevation_idx = 0; st_ivas->hIsmMetaData[ch]->elevation_diff_cnt = ISM_FEC_MAX - 1; +#endif st_ivas->hIsmMetaData[ch]->last_ism_metadata_flag = 0; ivas_ism_reset_metadata( st_ivas->hIsmMetaData[ch] ); @@ -783,3 +925,346 @@ ivas_error ivas_ism_metadata_enc_create( return IVAS_ERR_OK; } + +#ifdef TD5 +static void encode_radius( + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + int16_t *last_radius_idx, /* i/o: last radius index */ + int16_t *radius_diff_cnt, /* i/o: radius diff coding counter */ + const int16_t last_ism_metadata_flag, /* last frame ism_metadata_flag */ + const int16_t idx_radius_abs, /* i : Azimuth index */ + int16_t *flag_abs_radius /* o : Radius encoding mode */ +) +{ + int16_t idx_radius, nbits_diff_radius, diff; + + + /*----------------------------------------------------------------* + * Radius index encoding + *----------------------------------------------------------------*/ + idx_radius = idx_radius_abs; + + nbits_diff_radius = 0; + + *flag_abs_radius = 0; /* differential coding by default */ + + if ( *radius_diff_cnt == ISM_FEC_MAX /* make differential encoding in ISM_FEC_MAX consecutive frames at maximum (in order to control the decoding in FEC) */ + || last_ism_metadata_flag == 0 /* If last frame had no metadata coded, do not use differential coding */ + ) + { + *flag_abs_radius = 1; + } + + diff = idx_radius_abs - *last_radius_idx; + + /* try differential coding */ + if ( *flag_abs_radius == 0 ) + { + if ( diff == 0 ) + { + idx_radius = 0; + nbits_diff_radius = 1; + } + else if ( ABSVAL( diff ) <= ISM_MAX_RADIUS_DIFF_IDX ) + { + idx_radius = 1 << 1; + nbits_diff_radius = 1; + + if ( diff < 0 ) + { + idx_radius += 1; /* negative sign */ + diff *= -1; + } + else + { + idx_radius += 0; /* positive sign */ + } + + idx_radius = idx_radius << diff; + nbits_diff_radius++; + + /* unary coding of "diff */ + idx_radius += ( ( 1 << diff ) - 1 ); + nbits_diff_radius += diff; + + if ( nbits_diff_radius < ISM_RADIUS_NBITS ) + { + /* add stop bit */ + idx_radius = idx_radius << 1; + nbits_diff_radius++; + } + } + else + { + *flag_abs_radius = 1; + } + } + + /* update counter */ + if ( *flag_abs_radius == 0 ) + { + ( *radius_diff_cnt )++; + *radius_diff_cnt = min( *radius_diff_cnt, ISM_FEC_MAX ); + } + else + { + *radius_diff_cnt = 0; + } + + /* Write radius */ + push_indice( hBstr, IND_ISM_RADIUS_DIFF_FLAG, *flag_abs_radius, 1 ); + + if ( *flag_abs_radius ) + { + push_indice( hBstr, IND_ISM_RADIUS, idx_radius, ISM_RADIUS_NBITS ); + } + else + { + push_indice( hBstr, IND_ISM_RADIUS, idx_radius, nbits_diff_radius ); + } + + /*----------------------------------------------------------------* + * Updates + *----------------------------------------------------------------*/ + *last_radius_idx = idx_radius_abs; + return; +} + +static void encode_angle_indices( + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + ISM_METADATA_ANGLE_HANDLE angle, /* i/o: angle handle */ + const int16_t last_ism_metadata_flag, /* last frame ism_metadata_flag */ + const int16_t ini_frame, /* i : initialization frames counter */ + const int16_t idx_azimuth_abs, /* i : Azimuth index */ + const int16_t idx_elevation_abs, /* i : Elevation index */ + int16_t *flag_abs_azimuth, /* o : Azimuth encoding mode */ + int16_t *flag_abs_elevation /* o : Elevation encoding mode */ +) +{ + int16_t idx_azimuth, nbits_diff_azimuth, diff; + int16_t idx_elevation, nbits_diff_elevation; + + + /*----------------------------------------------------------------* + * Azimuth index encoding + *----------------------------------------------------------------*/ + + idx_azimuth = idx_azimuth_abs; + + nbits_diff_azimuth = 0; + + *flag_abs_azimuth = 0; /* differential coding by default */ + if ( angle->azimuth_diff_cnt == ISM_FEC_MAX /* make differential encoding in ISM_FEC_MAX consecutive frames at maximum (in order to control the decoding in FEC) */ + || last_ism_metadata_flag == 0 /* If last frame had no metadata coded, do not use differential coding */ + ) + { + *flag_abs_azimuth = 1; + } + + /* try differential coding */ + if ( *flag_abs_azimuth == 0 ) + { + diff = idx_azimuth_abs - angle->last_azimuth_idx; + + /* azimuth is on a circle - check for diff coding for -180° -> 180° and vice versa changes */ + if ( abs( diff ) > ( ( 1 << ISM_AZIMUTH_NBITS ) - 1 ) - ISM_MAX_AZIMUTH_DIFF_IDX ) + { + if ( diff > 0 ) + { + diff -= ( 1 << ISM_AZIMUTH_NBITS ) - 1; + } + else + { + diff += ( 1 << ISM_AZIMUTH_NBITS ) - 1; + } + } + + if ( diff == 0 ) + { + idx_azimuth = 0; + nbits_diff_azimuth = 1; + } + else if ( ABSVAL( diff ) < ISM_MAX_AZIMUTH_DIFF_IDX ) /* when diff bits >= abs bits, prefer abs */ + { + idx_azimuth = 1 << 1; + nbits_diff_azimuth = 1; + + if ( diff < 0 ) + { + idx_azimuth += 1; /* negative sign */ + diff *= -1; + } + else + { + idx_azimuth += 0; /* positive sign */ + } + + idx_azimuth = idx_azimuth << diff; + nbits_diff_azimuth++; + + /* unary coding of "diff */ + idx_azimuth += ( ( 1 << diff ) - 1 ); + nbits_diff_azimuth += diff; + + if ( nbits_diff_azimuth < ISM_AZIMUTH_NBITS - 1 ) + { + /* add stop bit - only for codewords shorter than ISM_AZIMUTH_NBITS */ + idx_azimuth = idx_azimuth << 1; + nbits_diff_azimuth++; + } + } + else + { + *flag_abs_azimuth = 1; + } + } + + /* update counter */ + if ( *flag_abs_azimuth == 0 ) + { + angle->azimuth_diff_cnt++; + angle->elevation_diff_cnt = min( angle->elevation_diff_cnt, ISM_FEC_MAX ); + } + else + { + angle->azimuth_diff_cnt = 0; + } + + /* Write azimuth */ + push_indice( hBstr, IND_ISM_AZIMUTH_DIFF_FLAG, *flag_abs_azimuth, 1 ); + + if ( *flag_abs_azimuth ) + { + push_indice( hBstr, IND_ISM_AZIMUTH, idx_azimuth, ISM_AZIMUTH_NBITS ); + } + else + { + push_indice( hBstr, IND_ISM_AZIMUTH, idx_azimuth, nbits_diff_azimuth ); + } + + /*----------------------------------------------------------------* + * Elevation index encoding + *----------------------------------------------------------------*/ + idx_elevation = idx_elevation_abs; + + nbits_diff_elevation = 0; + + *flag_abs_elevation = 0; /* differential coding by default */ + if ( angle->elevation_diff_cnt == ISM_FEC_MAX /* make differential encoding in ISM_FEC_MAX consecutive frames at maximum (in order to control the decoding in FEC) */ + || last_ism_metadata_flag == 0 /* If last frame had no metadata coded, do not use differential coding */ + ) + { + *flag_abs_elevation = 1; + } + + /* note: elevation is coded starting from the second frame only (it is meaningless in the init_frame) */ + if ( ini_frame == 0 ) + { + *flag_abs_elevation = 1; + angle->last_elevation_idx = idx_elevation_abs; + } + + diff = idx_elevation_abs - angle->last_elevation_idx; + + /* avoid absolute coding of elevation if absolute coding was already used for azimuth */ + if ( *flag_abs_azimuth == 1 ) + { + int16_t diff_orig = diff; + + *flag_abs_elevation = 0; + + + if ( diff >= 0 ) + { + diff = min( diff, ISM_MAX_ELEVATION_DIFF_IDX ); + } + else + { + diff = -1 * min( -diff, ISM_MAX_ELEVATION_DIFF_IDX ); + } + + if ( last_ism_metadata_flag == 0 || abs( diff_orig - diff ) > ISM_MAX_ELEVATION_DIFF_IDX ) + { + angle->elevation_diff_cnt = ISM_FEC_MAX - 1; + } + } + + /* try differential coding */ + if ( *flag_abs_elevation == 0 ) + { + if ( diff == 0 ) + { + idx_elevation = 0; + nbits_diff_elevation = 1; + } + else if ( ABSVAL( diff ) <= ISM_MAX_ELEVATION_DIFF_IDX ) + { + idx_elevation = 1 << 1; + nbits_diff_elevation = 1; + + if ( diff < 0 ) + { + idx_elevation += 1; /* negative sign */ + diff *= -1; + } + else + { + idx_elevation += 0; /* positive sign */ + } + + idx_elevation = idx_elevation << diff; + nbits_diff_elevation++; + + /* unary coding of "diff */ + idx_elevation += ( ( 1 << diff ) - 1 ); + nbits_diff_elevation += diff; + + if ( nbits_diff_elevation < ISM_ELEVATION_NBITS ) + { + /* add stop bit */ + idx_elevation = idx_elevation << 1; + nbits_diff_elevation++; + } + } + else + { + *flag_abs_elevation = 1; + } + } + + /* update counter */ + if ( *flag_abs_elevation == 0 ) + { + angle->elevation_diff_cnt++; + angle->elevation_diff_cnt = min( angle->elevation_diff_cnt, ISM_FEC_MAX ); + } + else + { + angle->elevation_diff_cnt = 0; + } + + /* Write elevation */ + if ( *flag_abs_azimuth == 0 ) /* do not write "flag_abs_elevation" if "flag_abs_azimuth == 1" */ + { + push_indice( hBstr, IND_ISM_ELEVATION_DIFF_FLAG, *flag_abs_elevation, 1 ); + } + + if ( *flag_abs_elevation ) + { + push_indice( hBstr, IND_ISM_ELEVATION, idx_elevation, ISM_ELEVATION_NBITS ); + } + else + { + push_indice( hBstr, IND_ISM_ELEVATION, idx_elevation, nbits_diff_elevation ); + } + + /*----------------------------------------------------------------* + * Updates + *----------------------------------------------------------------*/ + + angle->last_azimuth_idx = idx_azimuth_abs; + angle->last_elevation_idx = idx_elevation_abs; + + return; +} +#endif diff --git a/lib_enc/ivas_ism_param_enc.c b/lib_enc/ivas_ism_param_enc.c index ef66df5a90cc409d4c634afe68e10eebcaf07ba0..fb69537bc2e96e65aec85ba8a438b2f17c612efb 100644 --- a/lib_enc/ivas_ism_param_enc.c +++ b/lib_enc/ivas_ism_param_enc.c @@ -281,11 +281,7 @@ ivas_error ivas_param_ism_enc_open( } /* Allocate and initialize FB mixer handle */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( ( error = ivas_FB_mixer_open( &( hDirAC->hFbMixer ), input_Fs, fb_cfg, 0 ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_FB_mixer_open( &( hDirAC->hFbMixer ), input_Fs, fb_cfg ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -324,11 +320,7 @@ void ivas_param_ism_enc_close( const int32_t input_Fs /* i : input sampling_rate */ ) { -#ifdef SBA_BR_SWITCHING_CLEAN_UP ivas_FB_mixer_close( &hDirAC->hFbMixer, input_Fs, 0 ); -#else - ivas_FB_mixer_close( &hDirAC->hFbMixer, input_Fs ); -#endif if ( hDirAC->hParamIsm != NULL ) { @@ -407,7 +399,6 @@ void ivas_param_ism_enc( } -#ifdef PARAM_ISM_DTX_CNG static void ivas_param_ism_enc_quantize_DOA_dtx( float azimuth, float elevation, @@ -580,4 +571,3 @@ void ivas_param_ism_compute_noisy_speech_flag( return; } -#endif diff --git a/lib_enc/ivas_mc_param_enc.c b/lib_enc/ivas_mc_param_enc.c index 9b1241f234da333c866f7439fb23ad3ae123f270..e51887d455a0ed719b7c51a78b91736e3f9a327f 100644 --- a/lib_enc/ivas_mc_param_enc.c +++ b/lib_enc/ivas_mc_param_enc.c @@ -146,11 +146,7 @@ ivas_error ivas_param_mc_enc_open( } /* Allocate and initialize FB mixer handle */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( ( error = ivas_FB_mixer_open( &( hParamMC->hFbMixer ), input_Fs, fb_cfg, 0 ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_FB_mixer_open( &( hParamMC->hFbMixer ), input_Fs, fb_cfg ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -369,11 +365,7 @@ void ivas_param_mc_enc_close( { ivas_param_mc_metadata_close( &hParamMC->hMetadataPMC ); -#ifdef SBA_BR_SWITCHING_CLEAN_UP ivas_FB_mixer_close( &hParamMC->hFbMixer, sampling_rate, 0 ); -#else - ivas_FB_mixer_close( &hParamMC->hFbMixer, sampling_rate ); -#endif free( hParamMC ); diff --git a/lib_enc/ivas_mcmasa_enc.c b/lib_enc/ivas_mcmasa_enc.c index 153bc3ecade61d184618543f687084ae52961a7d..b79f4b62e4a068efb206ac752a2f9535add96ec3 100644 --- a/lib_enc/ivas_mcmasa_enc.c +++ b/lib_enc/ivas_mcmasa_enc.c @@ -194,11 +194,7 @@ ivas_error ivas_mcmasa_enc_open( } /* Allocate and initialize FB mixer handle */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( ( error = ivas_FB_mixer_open( &( hMcMasa->hFbMixer ), input_Fs, fb_cfg, 0 ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_FB_mixer_open( &( hMcMasa->hFbMixer ), input_Fs, fb_cfg ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -228,11 +224,7 @@ ivas_error ivas_mcmasa_enc_open( return error; } -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( ( error = ivas_FB_mixer_open( &( hMcMasa->hFbMixerLfe ), input_Fs, fb_cfgLfe, 0 ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_FB_mixer_open( &( hMcMasa->hFbMixerLfe ), input_Fs, fb_cfgLfe ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -508,19 +500,11 @@ void ivas_mcmasa_enc_close( } } -#ifdef SBA_BR_SWITCHING_CLEAN_UP ivas_FB_mixer_close( &hMcMasa->hFbMixer, input_Fs, 0 ); -#else - ivas_FB_mixer_close( &hMcMasa->hFbMixer, input_Fs ); -#endif if ( !hMcMasa->separateChannelEnabled ) { -#ifdef SBA_BR_SWITCHING_CLEAN_UP ivas_FB_mixer_close( &hMcMasa->hFbMixerLfe, input_Fs, 0 ); -#else - ivas_FB_mixer_close( &hMcMasa->hFbMixerLfe, input_Fs ); -#endif } /* intensity 3-dim */ diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index e878d7418372886865942dd0420090234c67367c..11d9c3540fba8580532a28c980a379442aa10e4a 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -120,14 +120,10 @@ ivas_error ivas_sba_enc_reconfigure( DIRAC_ENC_HANDLE hDirAC = st_ivas->hDirAC; SPAR_ENC_HANDLE hSpar; SBA_MODE sba_mode_old; -#ifdef SBA_HPF_TUNING_ENC int16_t analysis_order_old; -#endif -#ifdef SBA_BR_SWITCHING_CLEAN_UP int16_t spar_reconfig_flag; spar_reconfig_flag = 0; -#endif nchan_transport_old = st_ivas->nchan_transport; nCPE_old = st_ivas->nCPE; nSCE_old = st_ivas->nSCE; @@ -136,7 +132,6 @@ ivas_error ivas_sba_enc_reconfigure( st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, hEncoderConfig->sba_order ); st_ivas->sba_mode = ivas_sba_mode_select( ivas_total_brate ); -#ifdef SBA_HPF_TUNING_ENC analysis_order_old = ivas_sba_get_analysis_order( hEncoderConfig->last_ivas_total_brate, hEncoderConfig->sba_order ); if ( analysis_order_old != st_ivas->sba_analysis_order ) @@ -204,17 +199,12 @@ ivas_error ivas_sba_enc_reconfigure( old_mem_hp20_in = NULL; } } -#endif if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { if ( st_ivas->hSpar == NULL ) { -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( ( error = ivas_spar_enc_open( st_ivas, spar_reconfig_flag ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_spar_enc_open( st_ivas ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -223,7 +213,6 @@ ivas_error ivas_sba_enc_reconfigure( ivas_spar_config( ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->hSpar->core_nominal_brate, -1 ); -#ifdef SBA_BR_SWITCHING_CLEAN_UP for ( n = 0; n < DIRAC_MAX_ANA_CHANS; n++ ) { if ( hDirAC->sba_synchro_buffer[n] != NULL ) @@ -233,16 +222,11 @@ ivas_error ivas_sba_enc_reconfigure( } } hDirAC->num_samples_synchro_delay = 0; -#endif } else { -#ifdef SBA_BR_SWITCHING_CLEAN_UP ivas_spar_enc_close( st_ivas->hSpar, hEncoderConfig->input_Fs, hEncoderConfig->nchan_inp, spar_reconfig_flag ); -#else - ivas_spar_enc_close( st_ivas->hSpar, hEncoderConfig->input_Fs, hEncoderConfig->nchan_inp ); -#endif st_ivas->hSpar = NULL; } @@ -264,60 +248,12 @@ ivas_error ivas_sba_enc_reconfigure( { if ( hDirAC->hFbMixer != NULL ) { -#ifndef SBA_BR_SWITCHING_CLEAN_UP - ivas_FB_mixer_close( &( hDirAC->hFbMixer ), hEncoderConfig->input_Fs ); -#else ivas_FB_mixer_close( &( hDirAC->hFbMixer ), hEncoderConfig->input_Fs, 0 ); -#endif hDirAC->hFbMixer = NULL; } if ( sba_mode_old == SBA_MODE_SPAR ) { -#ifndef SBA_BR_SWITCHING_CLEAN_UP - IVAS_FB_CFG *fb_cfg; - int16_t nchan_internal, sba_order_internal; - int16_t table_idx, active_w_mixing; - - sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); - nchan_internal = ivas_sba_get_nchan_metadata( sba_order_internal ); - - /* Covar. State handle */ - ivas_spar_covar_enc_close( &hSpar->hCovEnc, hSpar->hFbMixer->fb_cfg->num_in_chans ); - - /* MD handle */ - ivas_spar_md_enc_close( &hSpar->hMdEnc ); - - if ( ( error = ivas_spar_md_enc_open( &( hSpar->hMdEnc ), hEncoderConfig, sba_order_internal ) ) != IVAS_ERR_OK ) - { - return error; - } - - /*Initialization*/ - hSpar->hMdEnc->table_idx = -1; - - /* FB mixer handle */ - ivas_FB_mixer_close( &hSpar->hFbMixer, hEncoderConfig->input_Fs ); - - table_idx = ivas_get_spar_table_idx( ivas_total_brate, sba_order_internal, SPAR_CONFIG_BW, NULL, NULL ); - active_w_mixing = ivas_spar_br_table_consts[table_idx].active_w; - if ( ( error = ivas_fb_set_cfg( &fb_cfg, SBA_FORMAT, SBA_MODE_SPAR, nchan_internal, st_ivas->nchan_transport, active_w_mixing, hEncoderConfig->input_Fs ) ) != IVAS_ERR_OK ) - { - return error; - } - fb_cfg->remix_order = remix_order_set[hSpar->hMdEnc->spar_md_cfg.remix_unmix_order]; - - if ( ( error = ivas_FB_mixer_open( &( hSpar->hFbMixer ), hEncoderConfig->input_Fs, fb_cfg ) ) != IVAS_ERR_OK ) - { - return error; - } - - /* Covar. State handle */ - if ( ( error = ivas_spar_covar_enc_open( &( hSpar->hCovEnc ), hSpar->hFbMixer->pFb, hEncoderConfig->input_Fs, nchan_internal ) ) != IVAS_ERR_OK ) - { - return error; - } -#else spar_reconfig_flag = 1; ivas_spar_enc_close( st_ivas->hSpar, hEncoderConfig->input_Fs, hEncoderConfig->nchan_inp, spar_reconfig_flag ); @@ -325,7 +261,6 @@ ivas_error ivas_sba_enc_reconfigure( { return error; } -#endif } } else @@ -340,11 +275,7 @@ ivas_error ivas_sba_enc_reconfigure( } /* Allocate and initialize FB mixer handle */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( ( error = ivas_FB_mixer_open( &( hDirAC->hFbMixer ), hEncoderConfig->input_Fs, fb_cfg, 0 ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_FB_mixer_open( &( hDirAC->hFbMixer ), hEncoderConfig->input_Fs, fb_cfg ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -368,43 +299,6 @@ ivas_error ivas_sba_enc_reconfigure( } } } -#ifndef SBA_BR_SWITCHING_CLEAN_UP - /* initialize delay for SPAR/DirAC delay synchronization */ - if ( ( st_ivas->sba_mode == SBA_MODE_DIRAC ) && ( ( sba_mode_old != st_ivas->sba_mode ) || ( nchan_transport_old != st_ivas->nchan_transport ) ) ) - { - if ( hDirAC->num_samples_synchro_delay == 0 ) - { - hDirAC->num_samples_synchro_delay = NS2SA( hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ); - - for ( n = 0; n < DIRAC_MAX_ANA_CHANS; n++ ) - { - if ( ( hDirAC->sba_synchro_buffer[n] = (float *) malloc( hDirAC->num_samples_synchro_delay * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hDirAC synchro buffer\n" ) ); - } - set_zero( hDirAC->sba_synchro_buffer[n], hDirAC->num_samples_synchro_delay ); - } - for ( ; n < DIRAC_MAX_ANA_CHANS; n++ ) - { - hDirAC->sba_synchro_buffer[n] = NULL; - } - } - } - else - { - for ( n = 0; n < DIRAC_MAX_ANA_CHANS; n++ ) - { - if ( hDirAC->sba_synchro_buffer[n] != NULL ) - { - free( hDirAC->sba_synchro_buffer[n] ); - hDirAC->sba_synchro_buffer[n] = NULL; - } - } - hDirAC->num_samples_synchro_delay = 0; - } - - -#endif } if ( ( error = ivas_dirac_enc_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index 195fc01cf757e155ade5d714b45c947321b6377b..c8577a85bae41f124907bdd60809cca4d529b7d6 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -180,21 +180,12 @@ ivas_error ivas_sce_enc( * Front Pre-processing *----------------------------------------------------------------*/ -#ifdef LOW_RATE_TRANS_CORE_CODER error = pre_proc_front_ivas( hSCE, NULL, hSCE->element_brate, nb_bits_metadata, input_frame, 0, old_inp_12k8[0], old_inp_16k[0], &ener[0], &relE[0], A[0], Aw[0], epsP[0], lsp_new[0], lsp_mid[0], &vad_hover_flag[0], &attack_flag[0], realBuffer[0], imagBuffer[0], old_wsp[0], pitch_fr[0], voicing_fr[0], &loc_harm[0], &cor_map_sum[0], &vad_flag_dtx[0], enerBuffer[0], fft_buff[0], A[0], lsp_new[0], currFlatness[0], 0, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, NULL, flag_16k_smc, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->force_front_vad : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_dtx_flag : 0, st_ivas->hEncoderConfig->ivas_total_brate ); -#else - error = pre_proc_front_ivas( hSCE, NULL, hSCE->element_brate, nb_bits_metadata, input_frame, 0, old_inp_12k8[0], old_inp_16k[0], - &ener[0], &relE[0], A[0], Aw[0], epsP[0], lsp_new[0], lsp_mid[0], - &vad_hover_flag[0], &attack_flag[0], realBuffer[0], imagBuffer[0], old_wsp[0], pitch_fr[0], voicing_fr[0], &loc_harm[0], &cor_map_sum[0], &vad_flag_dtx[0], enerBuffer[0], - fft_buff[0], A[0], lsp_new[0], currFlatness[0], 0, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, NULL, flag_16k_smc, - st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->force_front_vad : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_dtx_flag : 0, - st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->hEncoderConfig->ivas_format ); -#endif if ( error != IVAS_ERR_OK ) { return error; @@ -260,10 +251,8 @@ ivas_error ivas_sce_enc( hSCE->last_element_brate = hSCE->element_brate; -#ifdef LOW_RATE_TRANS_CORE_CODER /* Store previous attack detection flag */ st->hTranDet->transientDetector.prev_bIsAttackPresent = st->hTranDet->transientDetector.bIsAttackPresent; -#endif #ifdef DEBUG_MODE_INFO { @@ -343,11 +332,7 @@ ivas_error create_sce_enc( st->total_brate = hSCE->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ st->mct_chan_mode = MCT_CHAN_MODE_REGULAR; -#ifdef PARAM_ISM_DTX_CNG if ( ( error = init_encoder( st, 0, st_ivas->hEncoderConfig->var_SID_rate_flag, st_ivas->hEncoderConfig->interval_SID, 0, st_ivas->ism_mode ) ) != IVAS_ERR_OK ) -#else - if ( ( error = init_encoder( st, 0, st_ivas->hEncoderConfig->var_SID_rate_flag, st_ivas->hEncoderConfig->interval_SID, 0 ) ) != IVAS_ERR_OK ) -#endif { return error; } diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index b156c524d27aecd99b375a67541ad869dcf0712d..7b2155d767e08ca68841147f9a84b72e5a155110 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -59,10 +59,8 @@ static ivas_error ivas_spar_enc_process( Encoder_Struct *st_ivas, const ENCODER_ ivas_error ivas_spar_enc_open( Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP , const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -#endif ) { SPAR_ENC_HANDLE hSpar; @@ -75,20 +73,16 @@ ivas_error ivas_spar_enc_open( hEncoderConfig = st_ivas->hEncoderConfig; error = IVAS_ERR_OK; -#ifdef SBA_BR_SWITCHING_CLEAN_UP hSpar = st_ivas->hSpar; if ( !spar_reconfig_flag ) { -#endif /* SPAR encoder handle */ if ( ( hSpar = (SPAR_ENC_HANDLE) malloc( sizeof( SPAR_ENC_DATA ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR encoder" ); } -#ifdef SBA_BR_SWITCHING_CLEAN_UP } -#endif input_Fs = hEncoderConfig->input_Fs; sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); @@ -113,12 +107,8 @@ ivas_error ivas_spar_enc_open( ivas_fb_set_cfg( &fb_cfg, SBA_FORMAT, SBA_MODE_SPAR, nchan_inp, nchan_transport, active_w_mixing, input_Fs ); fb_cfg->remix_order = remix_order_set[hSpar->hMdEnc->spar_md_cfg.remix_unmix_order]; -/* FB mixer handle */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP + /* FB mixer handle */ if ( ( error = ivas_FB_mixer_open( &( hSpar->hFbMixer ), input_Fs, fb_cfg, spar_reconfig_flag ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_FB_mixer_open( &( hSpar->hFbMixer ), input_Fs, fb_cfg ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -129,18 +119,14 @@ ivas_error ivas_spar_enc_open( return error; } -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( !spar_reconfig_flag ) { -#endif /* Transient Detector handle */ if ( ( error = ivas_transient_det_open( &( hSpar->hTranDet ), input_Fs ) ) != IVAS_ERR_OK ) { return error; } -#ifdef SBA_BR_SWITCHING_CLEAN_UP } -#endif /* initialization */ hSpar->hMdEnc->table_idx = -1; @@ -194,10 +180,8 @@ ivas_error ivas_spar_enc_open( * Allocate and initialize Front-VAD handle *-----------------------------------------------------------------*/ -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( !spar_reconfig_flag ) { -#endif hSpar->front_vad_flag = 0; hSpar->front_vad_dtx_flag = 0; hSpar->force_front_vad = 0; @@ -219,11 +203,7 @@ ivas_error ivas_spar_enc_open( hSpar->hCoreCoderVAD->total_brate = hEncoderConfig->ivas_total_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ hSpar->hCoreCoderVAD->mct_chan_mode = MCT_CHAN_MODE_IGNORE; -#ifdef PARAM_ISM_DTX_CNG if ( ( error = init_encoder( hSpar->hCoreCoderVAD, 0, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 1, st_ivas->ism_mode ) ) != IVAS_ERR_OK ) -#else - if ( ( error = init_encoder( hSpar->hCoreCoderVAD, 0, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 1 ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -233,9 +213,7 @@ ivas_error ivas_spar_enc_open( hSpar->hCoreCoderVAD = NULL; hSpar->hFrontVad = NULL; } -#ifdef SBA_BR_SWITCHING_CLEAN_UP } -#endif /*-----------------------------------------------------------------* * Final assignment @@ -257,20 +235,16 @@ void ivas_spar_enc_close( SPAR_ENC_HANDLE hSpar, /* i/o: SPAR encoder handle */ const int32_t input_Fs, /* i : input sampling rate */ const int16_t nchan_inp /* i : number of input channels */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP , const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -#endif ) { int16_t num_chans; if ( hSpar != NULL ) { -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( !spar_reconfig_flag ) { -#endif /* core-coder-VAD handle */ if ( hSpar->hCoreCoderVAD != NULL ) { @@ -284,9 +258,7 @@ void ivas_spar_enc_close( front_vad_destroy( &hSpar->hFrontVad ); hSpar->hFrontVad = NULL; } -#ifdef SBA_BR_SWITCHING_CLEAN_UP } -#endif num_chans = hSpar->hFbMixer->fb_cfg->num_in_chans; assert( num_chans <= nchan_inp ); @@ -298,14 +270,7 @@ void ivas_spar_enc_close( ivas_spar_covar_enc_close( &hSpar->hCovEnc, num_chans ); /* FB mixer handle */ -#ifdef SBA_BR_SWITCHING_CLEAN_UP ivas_FB_mixer_close( &hSpar->hFbMixer, input_Fs, spar_reconfig_flag ); -#else - ivas_FB_mixer_close( &hSpar->hFbMixer, input_Fs ); - - /* Trans Det handle */ - ivas_transient_det_close( &hSpar->hTranDet ); -#endif /* AGC */ ivas_spar_agc_enc_close( &hSpar->hAgcEnc ); @@ -317,17 +282,13 @@ void ivas_spar_enc_close( hSpar->hPCA = NULL; } -#ifdef SBA_BR_SWITCHING_CLEAN_UP if ( !spar_reconfig_flag ) { /* Trans Det handle */ ivas_transient_det_close( &hSpar->hTranDet ); -#endif free( hSpar ); hSpar = NULL; -#ifdef SBA_BR_SWITCHING_CLEAN_UP } -#endif } return; @@ -430,11 +391,7 @@ static ivas_error ivas_spar_enc_process( float pcm_tmp[IVAS_SPAR_MAX_CH][L_FRAME48k * 2]; float *p_pcm_tmp[IVAS_SPAR_MAX_CH]; int16_t i, j, b, i_ts, input_frame, dtx_vad; -#ifdef SMOOTH_WITH_TRANS_DET int16_t transient_det[2]; -#else - int16_t transient_det; -#endif int32_t ivas_total_brate, input_Fs; float *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; float *cov_dtx_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; @@ -477,15 +434,11 @@ static ivas_error ivas_spar_enc_process( * Transient detector *-----------------------------------------------------------------------------------------*/ -#ifdef SMOOTH_WITH_TRANS_DET ivas_transient_det_process( hSpar->hTranDet, data_f[0], input_frame, transient_det ); if ( sba_order == 1 ) { transient_det[1] = transient_det[0]; } -#else - transient_det = ivas_transient_det_process( hSpar->hTranDet, data_f[0], input_frame ); -#endif /* store previous input samples for W in local buffer */ assert( num_del_samples <= IVAS_FB_1MS_48K_SAMP ); diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index e4509902548f2d07141b3da9debcecad759605a3..896dc0563b7c3137a98c11af442ff0ac982c12b3 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -550,7 +550,6 @@ typedef struct ivas_stereo_classifier_data_structure } STEREO_CLASSIF_DATA, *STEREO_CLASSIF_HANDLE; -#ifdef PARAM_ISM_DTX_CNG /*----------------------------------------------------------------------------------* * ISM DTX structure *----------------------------------------------------------------------------------*/ @@ -566,7 +565,6 @@ typedef struct float coh[MAX_NUM_OBJECTS]; } ISM_DTX_DATA, *ISM_DTX_HANDLE; -#endif /*----------------------------------------------------------------------------------* * Front-VAD structure @@ -1029,6 +1027,10 @@ typedef struct encoder_config_structure int16_t Opt_SC_VBR; /* flag indicating SC-VBR mode */ int16_t last_Opt_SC_VBR; /* flag indicating prev frame's SC-VBR mode */ +#ifdef TD5 + int16_t ism_extended_metadata_flag; /* flag indicating whether extended metadata encoding, including radius and orientation (yaw, pitch) */ +#endif + /* temp. development parameters */ int16_t Opt_PCA_ON; /* flag indicating PCA operation in SBA */ @@ -1071,9 +1073,7 @@ typedef struct /* multichannel modules */ ISM_METADATA_HANDLE hIsmMetaData[MAX_NUM_OBJECTS]; /* ISM metadata handles (storage for one frame of read ISM metadata) */ -#ifdef PARAM_ISM_DTX_CNG ISM_DTX_HANDLE hISMDTX; /* ISM DTX handle */ -#endif DIRAC_ENC_HANDLE hDirAC; /* DirAC data handle */ SPAR_ENC_HANDLE hSpar; /* SPAR encoder handle */ MASA_ENCODER_HANDLE hMasa; /* MASA encoder data and configuration */ diff --git a/lib_enc/ivas_tcx_core_enc.c b/lib_enc/ivas_tcx_core_enc.c index 3971c6740edf18f5608ab7ec590f765dc0ed736e..40a97cc33e712c50fed8ea33204153e82bd57c03 100644 --- a/lib_enc/ivas_tcx_core_enc.c +++ b/lib_enc/ivas_tcx_core_enc.c @@ -457,11 +457,7 @@ void stereo_tcx_core_enc( mvr2r( lsp_q, st->lsp_old, M ); } -#ifdef PARAM_ISM_DTX_CNG if ( st->Opt_DTX_ON && !st->tcxonly && st->hTdCngEnc != NULL ) -#else - if ( st->Opt_DTX_ON && !st->tcxonly ) -#endif { /* update CNG parameters in active frames */ if ( st->bwidth == NB && st->enableTcxLpc && st->core != ACELP_CORE ) diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 7ed8d4f2ec2f2d967147be2326ecb124e5fd1e09..3742dbcfdcc01d239eaed8465acd513e78370f09 100755 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -366,7 +366,12 @@ ivas_error IVAS_ENC_ConfigureForObjects( const bool max_bwidth_user, /* i : shows if bandwidth limitation was set by the user (true) or if default bandwidth was used (false) */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ - const uint16_t numObjects /* i : number of objects to be encoded */ +#ifdef TD5 + const uint16_t numObjects, /* i : number of objects to be encoded */ + const bool ism_extended_metadata /* i : Extended metadata used (true/false), where extended metadata includes radius and orientation */ +#else + const uint16_t numObjects /* i : number of objects to be encoded */ +#endif ) { Encoder_Struct *st_ivas; @@ -386,7 +391,9 @@ ivas_error IVAS_ENC_ConfigureForObjects( st_ivas->hEncoderConfig->ivas_format = ISM_FORMAT; st_ivas->hEncoderConfig->element_mode_init = IVAS_SCE; st_ivas->hEncoderConfig->nchan_inp = numObjects; - +#ifdef TD5 + st_ivas->hEncoderConfig->ism_extended_metadata_flag = ism_extended_metadata; +#endif hIvasEnc->maxBandwidthUser = max_bwidth_user; error = configureEncoder( hIvasEnc, inputFs, bitrate, maxBandwidth, dtxConfig, IVAS_ENC_GetDefaultChannelAwareConfig() ); @@ -426,7 +433,12 @@ ivas_error IVAS_ENC_FeedObjectMetadata( return IVAS_ERR_INDEX_OUT_OF_BOUNDS; } +#ifdef TD5 + error = ivas_set_ism_metadata( hIvasEnc->st_ivas->hIsmMetaData[ismIndex], metadata.azimuth, metadata.elevation, metadata.radius, metadata.yaw, metadata.pitch ); +#else error = ivas_set_ism_metadata( hIvasEnc->st_ivas->hIsmMetaData[ismIndex], metadata.azimuth, metadata.elevation ); +#endif + if ( error != IVAS_ERR_OK ) { return error; @@ -873,7 +885,6 @@ static ivas_error configureEncoder( return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "8kHz input sampling rate is not supported in IVAS." ); } -#ifdef PARAM_ISM_DTX_CNG if ( hEncoderConfig->Opt_DTX_ON && hEncoderConfig->ivas_format != MONO_FORMAT && ( ( hEncoderConfig->ivas_format == ISM_FORMAT && hEncoderConfig->nchan_inp == 2 ) || // ToDo: see Issue 113 ( hEncoderConfig->ivas_format == ISM_FORMAT && hEncoderConfig->nchan_inp > 2 && hEncoderConfig->ivas_total_brate != IVAS_24k4 && hEncoderConfig->ivas_total_brate != IVAS_32k ) || // ParamISM @@ -881,14 +892,6 @@ static ivas_error configureEncoder( ( hEncoderConfig->ivas_format == SBA_FORMAT && ivas_get_sba_num_TCs( hEncoderConfig->ivas_total_brate, 1 ) > 2 ) || // ToDo: support for 3+ TCs to be done hEncoderConfig->ivas_format == MC_FORMAT // ToDo: TBD ) ) -#else - if ( hEncoderConfig->Opt_DTX_ON && hEncoderConfig->ivas_format != MONO_FORMAT && - ( ( hEncoderConfig->ivas_format == ISM_FORMAT && hEncoderConfig->nchan_inp > 1 ) || // ToDo: see Issue 113 - ( hEncoderConfig->ivas_format == MASA_FORMAT && hEncoderConfig->ivas_total_brate > IVAS_128k ) || // ToDo: remove the bitrate limitation - ( hEncoderConfig->ivas_format == SBA_FORMAT && ivas_get_sba_num_TCs( hEncoderConfig->ivas_total_brate, 1 ) > 2 ) || // ToDo: support for 3+ TCs to be done - hEncoderConfig->ivas_format == MC_FORMAT // ToDo: TBD - ) ) -#endif { return IVAS_ERROR( IVAS_ERR_DTX_NOT_SUPPORTED, "DTX is not supported in this IVAS format and element mode." ); } @@ -919,12 +922,10 @@ static ivas_error configureEncoder( return error; } -#ifdef PARAM_ISM_DTX_CNG if ( hEncoderConfig->Opt_DTX_ON && ( hEncoderConfig->ivas_format == ISM_FORMAT ) && !( st_ivas->ism_mode == ISM_MODE_DISC && hEncoderConfig->nchan_inp == 1 ) && !( st_ivas->ism_mode == ISM_MODE_PARAM && ( hEncoderConfig->nchan_inp == 3 || hEncoderConfig->nchan_inp == 4 ) ) ) { return IVAS_ERROR( IVAS_ERR_UNKNOWN, "DTX is not supported in this IVAS format and element mode." ); } -#endif if ( hEncoderConfig->ivas_format == MONO_FORMAT ) { @@ -994,7 +995,6 @@ static int16_t getInputBufferSize( return (int16_t) ( st_ivas->hEncoderConfig->input_Fs * st_ivas->hEncoderConfig->nchan_inp / FRAMES_PER_SEC ); } -#ifdef FIX_94_VERIFY_WAV_NUM_CHANNELS /*---------------------------------------------------------------------* * IVAS_ENC_GetNumInChannels() * @@ -1019,7 +1019,6 @@ ivas_error IVAS_ENC_GetNumInChannels( return IVAS_ERR_OK; } -#endif /*---------------------------------------------------------------------* @@ -1985,7 +1984,6 @@ static ivas_error sanitizeBandwidth( static ivas_error sanitizeBitrateISM( const ENCODER_CONFIG_HANDLE hEncoderConfig ) { -#ifdef ISM_HIGHEST_BITRATE if ( hEncoderConfig->ivas_total_brate > IVAS_128k && hEncoderConfig->nchan_inp == 1 ) { return IVAS_ERROR( IVAS_ERR_INVALID_BITRATE, "Too high bitrate for 1 ISM specified in IVAS: %d", hEncoderConfig->ivas_total_brate ); @@ -2000,12 +1998,6 @@ static ivas_error sanitizeBitrateISM( { return IVAS_ERROR( IVAS_ERR_INVALID_BITRATE, "Too high bitrate for 3 ISM specified in IVAS: %d", hEncoderConfig->ivas_total_brate ); } -#else - if ( hEncoderConfig->ivas_total_brate > IVAS_256k ) - { - return IVAS_ERROR( IVAS_ERR_INVALID_BITRATE, "Too high bitrate for ISm specified in IVAS: %d", hEncoderConfig->ivas_total_brate ); - } -#endif if ( hEncoderConfig->ivas_total_brate < IVAS_16k4 && hEncoderConfig->nchan_inp == 2 ) { @@ -2021,6 +2013,12 @@ static ivas_error sanitizeBitrateISM( { return IVAS_ERROR( IVAS_ERR_INVALID_BITRATE, "Too low bitrate for 4 ISM specified in IVAS: %d", hEncoderConfig->ivas_total_brate ); } +#ifdef TD5 + if ( hEncoderConfig->ivas_total_brate < ISM_EXTENDED_METADATA_BRATE && hEncoderConfig->ism_extended_metadata_flag == 1 ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_BITRATE, "Too low bitrate for extended metadata format specified in IVAS: %d", hEncoderConfig->ivas_total_brate ); + } +#endif return IVAS_ERR_OK; } diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h index 74308226420f551ccae785ec374fd0c387fe772f..37fd4b4deeeffe927a899fc08900998e221cb8f8 100644 --- a/lib_enc/lib_enc.h +++ b/lib_enc/lib_enc.h @@ -180,7 +180,12 @@ ivas_error IVAS_ENC_ConfigureForObjects( const bool max_bwidth_user, /* i : shows if bandwidth limitation was set by the user (true) or if default bandwidth was used (false) */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ +#ifdef TD5 + const uint16_t numObjects, /* i : number of objects to be encoded */ + const bool ism_extended_metadata /* i : Extended metadata used (true/false), where extended metadata includes radius and orientation */ +#else const uint16_t numObjects /* i : number of objects to be encoded */ +#endif ); /*! r: error code */ @@ -298,13 +303,11 @@ ivas_error IVAS_ENC_GetDelay( int16_t *delay /* o : encoder delay */ ); -#ifdef FIX_94_VERIFY_WAV_NUM_CHANNELS /*! r: encoder error code */ ivas_error IVAS_ENC_GetNumInChannels( const IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ int16_t *numInChannels /* o : total number of samples expected in the input buffer for current encoder configuration */ ); -#endif /*! r: encoder error code */ ivas_error IVAS_ENC_GetInputBufferSize( diff --git a/lib_enc/rst_enc.c b/lib_enc/rst_enc.c index 2f19c41665aba07c87b803d0589eb8e2041e6090..3a2041875941a62f4e4b09796f49084332c77ad4 100644 --- a/lib_enc/rst_enc.c +++ b/lib_enc/rst_enc.c @@ -84,15 +84,11 @@ void CNG_reset_enc( set_f( voice_factors, 1.0, NB_SUBFR16k ); -#ifdef PARAM_ISM_DTX_CNG if ( st->hTdCngEnc != NULL ) { -#endif /* Reset active frame counter */ st->hTdCngEnc->act_cnt2 = 0; -#ifdef PARAM_ISM_DTX_CNG } -#endif /* deactivate bass post-filter */ st->bpf_off = 1; diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 84f3fb87ea3725ebb2e1f27b172bb01275fc5f5f..6fa03ba7dd10aa611aeddbc42d57f0a0cac0bc9f 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -147,1233 +147,6 @@ static ivas_error ivas_hrtf_close( return IVAS_ERR_OK; } - -#ifndef FIX_197_CREND_INTERFACE -/*------------------------------------------------------------------------- - * ivas_crend_init_from_rom() - * - * Allocate and initialize crend renderer handle - *------------------------------------------------------------------------*/ - -ivas_error ivas_crend_init_from_rom( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -) -{ - int16_t i, j, tmp; - int32_t output_Fs; - AUDIO_CONFIG intern_config; - HRTFS_HANDLE hHrtf; - -#ifdef FIX_197_CREND_INTERFACE - hHrtf = st_ivas->hCrendWrapper->hHrtfCrend; -#else - hHrtf = st_ivas->hHrtf; -#endif - - output_Fs = st_ivas->hDecoderConfig->output_Fs; - - intern_config = st_ivas->intern_config; - - if ( intern_config == AUDIO_CONFIG_BINAURAL || intern_config == AUDIO_CONFIG_BINAURAL_ROOM ) - { - return IVAS_ERR_INTERNAL_FATAL; - } - - if ( hHrtf == NULL ) - { - if ( ivas_hrtf_open( &hHrtf ) != IVAS_ERR_OK ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for HRTF handle" ); - } - } - - hHrtf->max_num_ir = audioCfg2channels( intern_config ); - - if ( hHrtf->max_num_ir <= 0 ) - { - return IVAS_ERR_INTERNAL_FATAL; - } - - /* Do all error checks up front so that the nested if later is easier */ - if ( st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV && st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV_ROOM ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Encountered unsupported renderer type" ); - } - - if ( intern_config != AUDIO_CONFIG_5_1 && intern_config != AUDIO_CONFIG_5_1_2 && intern_config != AUDIO_CONFIG_5_1_4 && - intern_config != AUDIO_CONFIG_7_1 && intern_config != AUDIO_CONFIG_7_1_4 && - intern_config != AUDIO_CONFIG_FOA && intern_config != AUDIO_CONFIG_HOA2 && intern_config != AUDIO_CONFIG_HOA3 ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Encountered unsupported transport config in Crend" ); - } - - if ( ( ( st_ivas->hRenderConfig != NULL ) && !st_ivas->hRenderConfig->roomAcoustics.use_brir ) || ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV ) ) - { - if ( intern_config == AUDIO_CONFIG_5_1 || intern_config == AUDIO_CONFIG_5_1_2 || intern_config == AUDIO_CONFIG_5_1_4 || - intern_config == AUDIO_CONFIG_7_1 || intern_config == AUDIO_CONFIG_7_1_4 ) - { - hHrtf->max_num_ir -= 1; /* subtract LFE */ - hHrtf->gain_lfe = GAIN_LFE; - - if ( output_Fs == 48000 ) - { - hHrtf->latency_s = CRendBin_Combined_HRIR_latency_s; - - hHrtf->max_num_iterations = CRendBin_Combined_HRIR_max_num_iterations_48kHz; - hHrtf->index_frequency_max_diffuse = CRendBin_Combined_HRIR_index_frequency_max_diffuse_48kHz; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations_diffuse[j] = CRendBin_Combined_HRIR_num_iterations_diffuse_48kHz[j]; - hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_48kHz[j]; - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_Combined_HRIR_coeff_diffuse_re_48kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_Combined_HRIR_coeff_diffuse_im_48kHz[j]; - } - } - else if ( output_Fs == 32000 ) - { - hHrtf->latency_s = CRendBin_Combined_HRIR_latency_s; - - hHrtf->max_num_iterations = CRendBin_Combined_HRIR_max_num_iterations_32kHz; - hHrtf->index_frequency_max_diffuse = CRendBin_Combined_HRIR_index_frequency_max_diffuse_32kHz; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations_diffuse[j] = CRendBin_Combined_HRIR_num_iterations_diffuse_32kHz[j]; - hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_32kHz[j]; - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_Combined_HRIR_coeff_diffuse_re_32kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_Combined_HRIR_coeff_diffuse_im_32kHz[j]; - } - } - else if ( output_Fs == 16000 ) - { - hHrtf->latency_s = CRendBin_Combined_HRIR_latency_s; - - hHrtf->max_num_iterations = CRendBin_Combined_HRIR_max_num_iterations_16kHz; - hHrtf->index_frequency_max_diffuse = CRendBin_Combined_HRIR_index_frequency_max_diffuse_16kHz; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations_diffuse[j] = CRendBin_Combined_HRIR_num_iterations_diffuse_16kHz[j]; - hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_16kHz[j]; - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_Combined_HRIR_coeff_diffuse_re_16kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_Combined_HRIR_coeff_diffuse_im_16kHz[j]; - } - } - else - { - return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Encountered Unsupported sampling rate in Crend" ); - } - - for ( i = 0; i < hHrtf->max_num_ir; i++ ) - { - if ( intern_config == AUDIO_CONFIG_5_1 ) - { - tmp = channelIndex_CICP6[i]; - } - else if ( intern_config == AUDIO_CONFIG_7_1 ) - { - tmp = channelIndex_CICP12[i]; - } - else if ( intern_config == AUDIO_CONFIG_5_1_2 ) - { - tmp = channelIndex_CICP14[i]; - } - else if ( intern_config == AUDIO_CONFIG_5_1_4 ) - { - tmp = channelIndex_CICP16[i]; - } - else if ( intern_config == AUDIO_CONFIG_7_1_4 ) - { - tmp = channelIndex_CICP19[i]; - } - else - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Channel configuration not specified!\n\n" ); - } - - if ( output_Fs == 48000 ) - { - hHrtf->inv_diffuse_weight[i] = CRendBin_Combined_HRIR_inv_diffuse_weight_48kHz[tmp]; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations[i][j] = CRendBin_Combined_HRIR_num_iterations_48kHz[tmp][j]; - hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_HRIR_pIndex_frequency_max_48kHz[tmp][j]; - hHrtf->pOut_to_bin_re[i][j] = CRendBin_Combined_HRIR_coeff_re_48kHz[tmp][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_Combined_HRIR_coeff_im_48kHz[tmp][j]; - } - } - else if ( output_Fs == 32000 ) - { - hHrtf->inv_diffuse_weight[i] = CRendBin_Combined_HRIR_inv_diffuse_weight_32kHz[tmp]; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations[i][j] = CRendBin_Combined_HRIR_num_iterations_32kHz[tmp][j]; - hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_HRIR_pIndex_frequency_max_32kHz[tmp][j]; - hHrtf->pOut_to_bin_re[i][j] = CRendBin_Combined_HRIR_coeff_re_32kHz[tmp][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_Combined_HRIR_coeff_im_32kHz[tmp][j]; - } - } - else if ( output_Fs == 16000 ) - { - hHrtf->inv_diffuse_weight[i] = CRendBin_Combined_HRIR_inv_diffuse_weight_16kHz[tmp]; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations[i][j] = CRendBin_Combined_HRIR_num_iterations_16kHz[tmp][j]; - hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_HRIR_pIndex_frequency_max_16kHz[tmp][j]; - hHrtf->pOut_to_bin_re[i][j] = CRendBin_Combined_HRIR_coeff_re_16kHz[tmp][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_Combined_HRIR_coeff_im_16kHz[tmp][j]; - } - } - else - { - return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Encountered Unsupported sampling rate in Crend" ); - } - } - } - else if ( intern_config == AUDIO_CONFIG_FOA || intern_config == AUDIO_CONFIG_HOA2 || intern_config == AUDIO_CONFIG_HOA3 ) - { - if ( output_Fs == 48000 ) - { - hHrtf->latency_s = CRendBin_HOA3_HRIR_latency_s; - - hHrtf->max_num_iterations = CRendBin_HOA3_HRIR_max_num_iterations_48kHz; - hHrtf->index_frequency_max_diffuse = CRendBin_HOA3_HRIR_index_frequency_max_diffuse_48kHz; - - for ( i = 0; i < hHrtf->max_num_ir; i++ ) - { - hHrtf->inv_diffuse_weight[i] = CRendBin_HOA3_HRIR_inv_diffuse_weight_48kHz[i]; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations[i][j] = CRendBin_HOA3_HRIR_num_iterations_48kHz[i][j]; - hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_48kHz[i][j]; - hHrtf->pOut_to_bin_re[i][j] = CRendBin_HOA3_HRIR_coeff_re_48kHz[i][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_HOA3_HRIR_coeff_im_48kHz[i][j]; - } - } - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations_diffuse[j] = CRendBin_HOA3_HRIR_num_iterations_diffuse_48kHz[j]; - hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_48kHz[j]; - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_HOA3_HRIR_coeff_diffuse_re_48kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_HOA3_HRIR_coeff_diffuse_im_48kHz[j]; - } - } - else if ( output_Fs == 32000 ) - { - hHrtf->latency_s = CRendBin_HOA3_HRIR_latency_s; - - hHrtf->max_num_iterations = CRendBin_HOA3_HRIR_max_num_iterations_32kHz; - hHrtf->index_frequency_max_diffuse = CRendBin_HOA3_HRIR_index_frequency_max_diffuse_32kHz; - - for ( i = 0; i < hHrtf->max_num_ir; i++ ) - { - hHrtf->inv_diffuse_weight[i] = CRendBin_HOA3_HRIR_inv_diffuse_weight_32kHz[i]; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations[i][j] = CRendBin_HOA3_HRIR_num_iterations_32kHz[i][j]; - hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_32kHz[i][j]; - hHrtf->pOut_to_bin_re[i][j] = CRendBin_HOA3_HRIR_coeff_re_32kHz[i][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_HOA3_HRIR_coeff_im_32kHz[i][j]; - } - } - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations_diffuse[j] = CRendBin_HOA3_HRIR_num_iterations_diffuse_32kHz[j]; - hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_32kHz[j]; - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_HOA3_HRIR_coeff_diffuse_re_32kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_HOA3_HRIR_coeff_diffuse_im_32kHz[j]; - } - } - else if ( output_Fs == 16000 ) - { - hHrtf->latency_s = CRendBin_HOA3_HRIR_latency_s; - - hHrtf->max_num_iterations = CRendBin_HOA3_HRIR_max_num_iterations_16kHz; - hHrtf->index_frequency_max_diffuse = CRendBin_HOA3_HRIR_index_frequency_max_diffuse_16kHz; - - for ( i = 0; i < hHrtf->max_num_ir; i++ ) - { - hHrtf->inv_diffuse_weight[i] = CRendBin_HOA3_HRIR_inv_diffuse_weight_16kHz[i]; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations[i][j] = CRendBin_HOA3_HRIR_num_iterations_16kHz[i][j]; - hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_16kHz[i][j]; - hHrtf->pOut_to_bin_re[i][j] = CRendBin_HOA3_HRIR_coeff_re_16kHz[i][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_HOA3_HRIR_coeff_im_16kHz[i][j]; - } - } - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations_diffuse[j] = CRendBin_HOA3_HRIR_num_iterations_diffuse_16kHz[j]; - hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_16kHz[j]; - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_HOA3_HRIR_coeff_diffuse_re_16kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_HOA3_HRIR_coeff_diffuse_im_16kHz[j]; - } - } - else - { - return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Encountered Unsupported sampling rate in Crend" ); - } - } - } - else if ( ( ( st_ivas->hRenderConfig != NULL ) && st_ivas->hRenderConfig->roomAcoustics.use_brir ) || ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) - { - if ( intern_config == AUDIO_CONFIG_5_1 || intern_config == AUDIO_CONFIG_5_1_2 || intern_config == AUDIO_CONFIG_5_1_4 || - intern_config == AUDIO_CONFIG_7_1 || intern_config == AUDIO_CONFIG_7_1_4 ) - { - hHrtf->max_num_ir -= 1; /* subtract LFE */ - hHrtf->gain_lfe = GAIN_LFE; - - if ( output_Fs == 48000 ) - { - hHrtf->latency_s = CRendBin_Combined_BRIR_latency_s; - - hHrtf->max_num_iterations = CRendBin_Combined_BRIR_max_num_iterations_48kHz; - hHrtf->index_frequency_max_diffuse = CRendBin_Combined_BRIR_index_frequency_max_diffuse_48kHz; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations_diffuse[j] = CRendBin_Combined_BRIR_num_iterations_diffuse_48kHz[j]; - hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_48kHz[j]; - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_Combined_BRIR_coeff_diffuse_re_48kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_Combined_BRIR_coeff_diffuse_im_48kHz[j]; - } - } - else if ( output_Fs == 32000 ) - { - hHrtf->latency_s = CRendBin_Combined_BRIR_latency_s; - - hHrtf->max_num_iterations = CRendBin_Combined_BRIR_max_num_iterations_32kHz; - hHrtf->index_frequency_max_diffuse = CRendBin_Combined_BRIR_index_frequency_max_diffuse_32kHz; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations_diffuse[j] = CRendBin_Combined_BRIR_num_iterations_diffuse_32kHz[j]; - hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_32kHz[j]; - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_Combined_BRIR_coeff_diffuse_re_32kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_Combined_BRIR_coeff_diffuse_im_32kHz[j]; - } - } - else if ( output_Fs == 16000 ) - { - hHrtf->latency_s = CRendBin_Combined_BRIR_latency_s; - - hHrtf->max_num_iterations = CRendBin_Combined_BRIR_max_num_iterations_16kHz; - hHrtf->index_frequency_max_diffuse = CRendBin_Combined_BRIR_index_frequency_max_diffuse_16kHz; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations_diffuse[j] = CRendBin_Combined_BRIR_num_iterations_diffuse_16kHz[j]; - hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_16kHz[j]; - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_Combined_BRIR_coeff_diffuse_re_16kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_Combined_BRIR_coeff_diffuse_im_16kHz[j]; - } - } - else - { - return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Encountered Unsupported sampling rate in Crend" ); - } - - for ( i = 0; i < hHrtf->max_num_ir; i++ ) - { - if ( intern_config == AUDIO_CONFIG_5_1 ) - { - tmp = channelIndex_CICP6[i]; - } - else if ( intern_config == AUDIO_CONFIG_7_1 ) - { - tmp = channelIndex_CICP12[i]; - } - else if ( intern_config == AUDIO_CONFIG_5_1_2 ) - { - tmp = channelIndex_CICP14[i]; - } - else if ( intern_config == AUDIO_CONFIG_5_1_4 ) - { - tmp = channelIndex_CICP16[i]; - } - else if ( intern_config == AUDIO_CONFIG_7_1_4 ) - { - tmp = channelIndex_CICP19[i]; - } - else - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Channel configuration not specified!\n\n" ); - } - - if ( output_Fs == 48000 ) - { - hHrtf->inv_diffuse_weight[i] = CRendBin_Combined_BRIR_inv_diffuse_weight_48kHz[tmp]; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations[i][j] = CRendBin_Combined_BRIR_num_iterations_48kHz[tmp][j]; - hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_BRIR_pIndex_frequency_max_48kHz[tmp][j]; - hHrtf->pOut_to_bin_re[i][j] = CRendBin_Combined_BRIR_coeff_re_48kHz[tmp][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_Combined_BRIR_coeff_im_48kHz[tmp][j]; - } - } - else if ( output_Fs == 32000 ) - { - hHrtf->inv_diffuse_weight[i] = CRendBin_Combined_BRIR_inv_diffuse_weight_32kHz[tmp]; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations[i][j] = CRendBin_Combined_BRIR_num_iterations_32kHz[tmp][j]; - hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_BRIR_pIndex_frequency_max_32kHz[tmp][j]; - hHrtf->pOut_to_bin_re[i][j] = CRendBin_Combined_BRIR_coeff_re_32kHz[tmp][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_Combined_BRIR_coeff_im_32kHz[tmp][j]; - } - } - else if ( output_Fs == 16000 ) - { - hHrtf->inv_diffuse_weight[i] = CRendBin_Combined_BRIR_inv_diffuse_weight_16kHz[tmp]; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations[i][j] = CRendBin_Combined_BRIR_num_iterations_16kHz[tmp][j]; - hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_BRIR_pIndex_frequency_max_16kHz[tmp][j]; - hHrtf->pOut_to_bin_re[i][j] = CRendBin_Combined_BRIR_coeff_re_16kHz[tmp][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_Combined_BRIR_coeff_im_16kHz[tmp][j]; - } - } - else - { - return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Encountered Unsupported sampling rate in Crend" ); - } - } - } - else if ( intern_config == AUDIO_CONFIG_FOA || intern_config == AUDIO_CONFIG_HOA2 || intern_config == AUDIO_CONFIG_HOA3 ) - { - if ( output_Fs == 48000 ) - { - hHrtf->latency_s = CRendBin_HOA3_HRIR_latency_s; - - hHrtf->max_num_iterations = CRendBin_HOA3_HRIR_max_num_iterations_48kHz; - hHrtf->index_frequency_max_diffuse = CRendBin_HOA3_HRIR_index_frequency_max_diffuse_48kHz; - - for ( i = 0; i < hHrtf->max_num_ir; i++ ) - { - hHrtf->inv_diffuse_weight[i] = CRendBin_HOA3_HRIR_inv_diffuse_weight_48kHz[i]; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations[i][j] = CRendBin_HOA3_HRIR_num_iterations_48kHz[i][j]; - hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_48kHz[i][j]; - hHrtf->pOut_to_bin_re[i][j] = CRendBin_HOA3_HRIR_coeff_re_48kHz[i][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_HOA3_HRIR_coeff_im_48kHz[i][j]; - } - } - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations_diffuse[j] = CRendBin_HOA3_HRIR_num_iterations_diffuse_48kHz[j]; - hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_48kHz[j]; - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_HOA3_HRIR_coeff_diffuse_re_48kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_HOA3_HRIR_coeff_diffuse_im_48kHz[j]; - } - } - else if ( output_Fs == 32000 ) - { - hHrtf->latency_s = CRendBin_HOA3_HRIR_latency_s; - - hHrtf->max_num_iterations = CRendBin_HOA3_HRIR_max_num_iterations_32kHz; - hHrtf->index_frequency_max_diffuse = CRendBin_HOA3_HRIR_index_frequency_max_diffuse_32kHz; - - for ( i = 0; i < hHrtf->max_num_ir; i++ ) - { - hHrtf->inv_diffuse_weight[i] = CRendBin_HOA3_HRIR_inv_diffuse_weight_32kHz[i]; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations[i][j] = CRendBin_HOA3_HRIR_num_iterations_32kHz[i][j]; - hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_32kHz[i][j]; - hHrtf->pOut_to_bin_re[i][j] = CRendBin_HOA3_HRIR_coeff_re_32kHz[i][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_HOA3_HRIR_coeff_im_32kHz[i][j]; - } - } - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations_diffuse[j] = CRendBin_HOA3_HRIR_num_iterations_diffuse_32kHz[j]; - hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_32kHz[j]; - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_HOA3_HRIR_coeff_diffuse_re_32kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_HOA3_HRIR_coeff_diffuse_im_32kHz[j]; - } - } - else if ( output_Fs == 16000 ) - { - hHrtf->latency_s = CRendBin_HOA3_HRIR_latency_s; - - hHrtf->max_num_iterations = CRendBin_HOA3_HRIR_max_num_iterations_16kHz; - hHrtf->index_frequency_max_diffuse = CRendBin_HOA3_HRIR_index_frequency_max_diffuse_16kHz; - - for ( i = 0; i < hHrtf->max_num_ir; i++ ) - { - hHrtf->inv_diffuse_weight[i] = CRendBin_HOA3_HRIR_inv_diffuse_weight_16kHz[i]; - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations[i][j] = CRendBin_HOA3_HRIR_num_iterations_16kHz[i][j]; - hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_16kHz[i][j]; - hHrtf->pOut_to_bin_re[i][j] = CRendBin_HOA3_HRIR_coeff_re_16kHz[i][j]; - hHrtf->pOut_to_bin_im[i][j] = CRendBin_HOA3_HRIR_coeff_im_16kHz[i][j]; - } - } - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHrtf->num_iterations_diffuse[j] = CRendBin_HOA3_HRIR_num_iterations_diffuse_16kHz[j]; - hHrtf->pIndex_frequency_max_diffuse[j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_16kHz[j]; - hHrtf->pOut_to_bin_diffuse_re[j] = CRendBin_HOA3_HRIR_coeff_diffuse_re_16kHz[j]; - hHrtf->pOut_to_bin_diffuse_im[j] = CRendBin_HOA3_HRIR_coeff_diffuse_im_16kHz[j]; - } - } - else - { - return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Encountered Unsupported sampling rate in Crend" ); - } - } - else - { - return IVAS_ERROR( IVAS_ERR_INTERNAL, "Unsupported intern_config type in Crend" ); - } - } - else - { - return IVAS_ERROR( IVAS_ERR_INTERNAL, "Unsupported renderer type in Crend" ); - } - -#ifdef FIX_197_CREND_INTERFACE - st_ivas->hCrendWrapper->hHrtfCrend = hHrtf; -#else - st_ivas->hHrtf = hHrtf; -#endif - - return IVAS_ERR_OK; -} -#endif - -#ifndef FIX_197_CREND_INTERFACE -/*------------------------------------------------------------------------- - * ivas_crend_init_from_hrtf_handle() - * - * Allocate and initialize Crend HRTF handle from external file - *------------------------------------------------------------------------*/ - -ivas_error ivas_crend_init_from_hrtf_handle( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - HRTFS_HANDLE hrtf ) -{ - int16_t i, j, as_lfe_filter; - const int16_t *hchannelIndex = NULL; - AUDIO_CONFIG transport_config; - - if ( st_ivas == NULL ) - { - return IVAS_ERR_INTERNAL; - } - - if ( hrtf == NULL ) - { - return IVAS_ERR_INVALID_HRTF; - } - - if ( st_ivas->hHrtf != NULL ) - { - ivas_hrtf_close( &st_ivas->hHrtf ); - } - - if ( ivas_hrtf_open( &( st_ivas->hHrtf ) ) != IVAS_ERR_OK ) - { - return IVAS_ERR_INTERNAL; - } - - if ( st_ivas->hHrtf != NULL ) - { - st_ivas->hHrtf->latency_s = hrtf->latency_s; - // st_ivas->hHrtf->max_num_ir->max_ir_len = hrtf->max_ir_len; - st_ivas->hHrtf->max_num_iterations = hrtf->max_num_iterations; - st_ivas->hHrtf->gain_lfe = hrtf->gain_lfe; - // st_ivas->hHrtf->crend_hr_gain_foa_to_bin = hrtf->crend_hr_gain_foa_to_bin; - st_ivas->hHrtf->max_num_ir = 0; - st_ivas->hIntSetup.nchan_out_woLFE = 0; - st_ivas->hIntSetup.num_lfe = 0; - st_ivas->hIntSetup.nchan_out_woLFE = 0; - - transport_config = st_ivas->intern_config == AUDIO_CONFIG_INVALID ? st_ivas->transport_config : st_ivas->intern_config; - - switch ( transport_config ) - { - case AUDIO_CONFIG_5_1: - st_ivas->hHrtf->max_num_ir = 5; - st_ivas->hHrtf->gain_lfe = GAIN_LFE; - st_ivas->hIntSetup.nchan_out_woLFE = st_ivas->hHrtf->max_num_ir; - st_ivas->hIntSetup.num_lfe = 1; - hchannelIndex = (const int16_t *) &channelIndex_CICP6; - break; - case AUDIO_CONFIG_7_1: - st_ivas->hHrtf->max_num_ir = 7; - st_ivas->hHrtf->gain_lfe = GAIN_LFE; - st_ivas->hIntSetup.nchan_out_woLFE = st_ivas->hHrtf->max_num_ir; - st_ivas->hIntSetup.num_lfe = 1; - hchannelIndex = (const int16_t *) &channelIndex_CICP12; - break; - case AUDIO_CONFIG_5_1_2: - st_ivas->hHrtf->max_num_ir = 7; - st_ivas->hHrtf->gain_lfe = GAIN_LFE; - st_ivas->hIntSetup.nchan_out_woLFE = st_ivas->hHrtf->max_num_ir; - st_ivas->hIntSetup.num_lfe = 1; - hchannelIndex = (const int16_t *) &channelIndex_CICP14; - break; - case AUDIO_CONFIG_5_1_4: - st_ivas->hHrtf->max_num_ir = 9; - st_ivas->hHrtf->gain_lfe = GAIN_LFE; - st_ivas->hIntSetup.nchan_out_woLFE = st_ivas->hHrtf->max_num_ir; - st_ivas->hIntSetup.num_lfe = 1; - hchannelIndex = (const int16_t *) &channelIndex_CICP16; - break; - case AUDIO_CONFIG_7_1_4: - st_ivas->hHrtf->max_num_ir = 11; - st_ivas->hHrtf->gain_lfe = GAIN_LFE; - st_ivas->hIntSetup.nchan_out_woLFE = st_ivas->hHrtf->max_num_ir; - st_ivas->hIntSetup.num_lfe = 1; - hchannelIndex = (const int16_t *) &channelIndex_CICP19; - break; - case AUDIO_CONFIG_FOA: - st_ivas->hIntSetup.ambisonics_order = 1; - st_ivas->hHrtf->max_num_ir = 4; - break; - case AUDIO_CONFIG_HOA2: - st_ivas->hIntSetup.ambisonics_order = 2; - st_ivas->hHrtf->max_num_ir = 9; - break; - case AUDIO_CONFIG_HOA3: - st_ivas->hIntSetup.ambisonics_order = 3; - st_ivas->hHrtf->max_num_ir = 16; - break; - default: - break; - } - - as_lfe_filter = 0; - if ( ( st_ivas->hHrtf->max_num_ir != hrtf->max_num_ir ) && ( st_ivas->hHrtf->max_num_ir + 1 == hrtf->max_num_ir ) ) - { - as_lfe_filter = 1; - hchannelIndex = NULL; - } - - if ( st_ivas->hHrtf->max_num_ir == 0 ) - { - return IVAS_ERR_INTERNAL; - } - - for ( i = 0; i < st_ivas->hHrtf->max_num_ir; i++ ) - { - int16_t tmp = i; - if ( hchannelIndex != NULL ) - { - tmp = hchannelIndex[i]; - } - if ( as_lfe_filter ) - { - if ( tmp > 2 ) - { - tmp++; - } - } - - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - st_ivas->hHrtf->pOut_to_bin_re[i][j] = hrtf->pOut_to_bin_re[tmp][j]; - st_ivas->hHrtf->pOut_to_bin_im[i][j] = hrtf->pOut_to_bin_im[tmp][j]; - st_ivas->hHrtf->num_iterations[i][j] = hrtf->num_iterations[tmp][j]; - st_ivas->hHrtf->pIndex_frequency_max[i][j] = hrtf->pIndex_frequency_max[tmp][j]; - } - st_ivas->hHrtf->inv_diffuse_weight[i] = hrtf->inv_diffuse_weight[tmp]; - } - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - st_ivas->hHrtf->pOut_to_bin_diffuse_re[j] = hrtf->pOut_to_bin_diffuse_re[j]; - st_ivas->hHrtf->pOut_to_bin_diffuse_im[j] = hrtf->pOut_to_bin_diffuse_im[j]; - st_ivas->hHrtf->num_iterations_diffuse[j] = hrtf->num_iterations_diffuse[j]; - st_ivas->hHrtf->pIndex_frequency_max_diffuse[j] = hrtf->pIndex_frequency_max_diffuse[j]; - } - st_ivas->hHrtf->index_frequency_max_diffuse = hrtf->index_frequency_max_diffuse; - } - return IVAS_ERR_OK; -} - -/*------------------------------------------------------------------------- - * ivas_crend_init_from_setofhrtf() - * - * Allocate and initialize crend renderer handle - *------------------------------------------------------------------------*/ - -ivas_error ivas_crend_init_from_setofhrtf( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -) -{ - ivas_error error; - AUDIO_CONFIG transport_config; - - transport_config = st_ivas->intern_config == AUDIO_CONFIG_INVALID ? st_ivas->transport_config : st_ivas->intern_config; - switch ( transport_config ) - { - case AUDIO_CONFIG_5_1: - case AUDIO_CONFIG_5_1_2: - case AUDIO_CONFIG_5_1_4: - case AUDIO_CONFIG_7_1: - case AUDIO_CONFIG_7_1_4: - if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) - { - if ( ( error = ivas_crend_init_from_hrtf_handle( st_ivas, st_ivas->hSetOfHRTF->hHRTF_brir_combined ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else - { - if ( ( error = ivas_crend_init_from_hrtf_handle( st_ivas, st_ivas->hSetOfHRTF->hHRTF_hrir_combined ) ) != IVAS_ERR_OK ) - { - return error; - } - } - break; - case AUDIO_CONFIG_FOA: - case AUDIO_CONFIG_HOA2: - case AUDIO_CONFIG_HOA3: - if ( ( error = ivas_crend_init_from_hrtf_handle( st_ivas, st_ivas->hSetOfHRTF->hHRTF_hrir_hoa3 ) ) != IVAS_ERR_OK ) - { - return error; - } - break; - default: - return IVAS_ERR_INTERNAL; - } - - return IVAS_ERR_OK; -} - -#endif - -#ifndef FIX_197_CREND_INTERFACE -/*------------------------------------------------------------------------- - * ivas_crend_open() - * - * Allocate and initialize Crend renderer handle - *------------------------------------------------------------------------*/ - -ivas_error ivas_crend_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -) -{ - int16_t i, subframe_length; - int16_t max_total_ir_len; - HRTFS_HANDLE hHrtf; - CREND_HANDLE hCrend; - ivas_error error; - - error = IVAS_ERR_OK; - subframe_length = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ) / MAX_PARAM_SPATIAL_SUBFRAMES; - - if ( ( st_ivas->hHrtf == NULL ) && ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) - { - if ( st_ivas->hSetOfHRTF != NULL ) - { - if ( ( error = ivas_crend_init_from_setofhrtf( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else - { - if ( ( error = ivas_crend_init_from_rom( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - } - } - - if ( ( hCrend = (CREND_HANDLE) malloc( sizeof( CREND_DATA ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for renderer handle" ); - } - - hCrend->lfe_delay_line = NULL; - - for ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) - { - hCrend->freq_buffer_re[i] = NULL; - hCrend->freq_buffer_im[i] = NULL; - } - - for ( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - hCrend->prev_out_buffer[i] = NULL; - } - - hCrend->freq_buffer_re_diffuse = NULL; - hCrend->freq_buffer_im_diffuse = NULL; - hCrend->hReverb = NULL; - hCrend->delay_line_rw_index = 0; - hCrend->diffuse_delay_line_rw_index = 0; -#ifndef FIX_I109_ORIENTATION_TRACKING - hCrend->hTrack = NULL; - hCrend->m_fYaw = 0; - hCrend->m_fPitch = 0; - hCrend->m_fRoll = 0; -#endif - - hHrtf = st_ivas->hHrtf; - - if ( ( hHrtf != NULL ) && ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) - { - max_total_ir_len = hHrtf->max_num_iterations * subframe_length; - - for ( i = 0; i < hHrtf->max_num_ir; i++ ) - { - if ( ( hCrend->freq_buffer_re[i] = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } - set_f( hCrend->freq_buffer_re[i], 0, max_total_ir_len ); - - if ( ( hCrend->freq_buffer_im[i] = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } - set_f( hCrend->freq_buffer_im[i], 0, max_total_ir_len ); - } - - for ( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - if ( ( hCrend->prev_out_buffer[i] = (float *) malloc( sizeof( float ) * subframe_length ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } - set_f( hCrend->prev_out_buffer[i], 0, subframe_length ); - } - - max_total_ir_len = hHrtf->num_iterations_diffuse[0] * subframe_length; - - if ( max_total_ir_len > 0 ) - { - if ( ( hCrend->freq_buffer_re_diffuse = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } - set_f( hCrend->freq_buffer_re_diffuse, 0, max_total_ir_len ); - - if ( ( hCrend->freq_buffer_im_diffuse = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } - set_f( hCrend->freq_buffer_im_diffuse, 0, max_total_ir_len ); - } - else - { - hCrend->freq_buffer_re_diffuse = NULL; - hCrend->freq_buffer_im_diffuse = NULL; - } - - max_total_ir_len = (int16_t) ( hHrtf->latency_s * st_ivas->hDecoderConfig->output_Fs + 0.5f ) + subframe_length; - if ( max_total_ir_len > 0 ) - { - if ( ( hCrend->lfe_delay_line = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } - set_f( hCrend->lfe_delay_line, 0, max_total_ir_len ); - } - else - { - hCrend->lfe_delay_line = NULL; - } - -#ifndef FIX_I109_ORIENTATION_TRACKING - if ( st_ivas->hDecoderConfig->Opt_Headrotation ) - { - if ( ( hCrend->hTrack = (ivas_orient_trk_state_t *) malloc( sizeof( ivas_orient_trk_state_t ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Orientation tracking" ); - } - - ivas_orient_trk_Init( hCrend->hTrack ); - } - else - { - hCrend->hTrack = NULL; - } -#endif - - if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM && st_ivas->ivas_format == MC_FORMAT && st_ivas->hDecoderConfig->Opt_Headrotation ) - { - if ( ( error = efap_init_data( &( st_ivas->hEFAPdata ), st_ivas->hIntSetup.ls_azimuth, st_ivas->hIntSetup.ls_elevation, st_ivas->hIntSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - if ( ( ( st_ivas->hRenderConfig != NULL ) && st_ivas->hRenderConfig->roomAcoustics.late_reverb_on ) ) - { - if ( ( error = ivas_reverb_open( &( hCrend->hReverb ), st_ivas->intern_config, hHrtf, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else - { - hCrend->hReverb = NULL; - } - - st_ivas->binaural_latency_ns = (int32_t) ( st_ivas->hHrtf->latency_s * 1000000000.f ); - } - - st_ivas->hCrend = hCrend; - - return error; -} -#endif - -#ifndef FIX_197_CREND_INTERFACE - -/*------------------------------------------------------------------------- - * ivas_crend_close() - * - * Deallocate Crend renderer handle - *------------------------------------------------------------------------*/ - -ivas_error ivas_crend_close( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -) -{ - int16_t i; - - if ( st_ivas->hHrtf != NULL ) - { - ivas_hrtf_close( &st_ivas->hHrtf ); - } - - if ( st_ivas->hCrend != NULL ) - { - if ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) - { - for ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) - { - if ( st_ivas->hCrend->freq_buffer_re[i] != NULL ) - { - free( st_ivas->hCrend->freq_buffer_re[i] ); - st_ivas->hCrend->freq_buffer_re[i] = NULL; - } - if ( st_ivas->hCrend->freq_buffer_im[i] != NULL ) - { - free( st_ivas->hCrend->freq_buffer_im[i] ); - st_ivas->hCrend->freq_buffer_im[i] = NULL; - } - } - - for ( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - if ( st_ivas->hCrend->prev_out_buffer[i] != NULL ) - { - free( st_ivas->hCrend->prev_out_buffer[i] ); - st_ivas->hCrend->prev_out_buffer[i] = NULL; - } - } - - if ( st_ivas->hCrend->lfe_delay_line != NULL ) - { - free( st_ivas->hCrend->lfe_delay_line ); - st_ivas->hCrend->lfe_delay_line = NULL; - } - - if ( st_ivas->hCrend->freq_buffer_re_diffuse != NULL ) - { - free( st_ivas->hCrend->freq_buffer_re_diffuse ); - st_ivas->hCrend->freq_buffer_re_diffuse = NULL; - } - - if ( st_ivas->hCrend->freq_buffer_im_diffuse != NULL ) - { - free( st_ivas->hCrend->freq_buffer_im_diffuse ); - st_ivas->hCrend->freq_buffer_im_diffuse = NULL; - } - -#ifndef FIX_I109_ORIENTATION_TRACKING - if ( st_ivas->hCrend->hTrack != NULL ) - { - free( st_ivas->hCrend->hTrack ); - st_ivas->hCrend->hTrack = NULL; - } -#endif - } - - ivas_reverb_close( &st_ivas->hCrend->hReverb ); - - free( st_ivas->hCrend ); - st_ivas->hCrend = NULL; - } - - return IVAS_ERR_OK; -} -#endif - -#ifndef FIX_197_CREND_INTERFACE - -/*-----------------------------------------------------------------------------------------* - * Function ivas_crend_convolver() - * - * Convolver block - *-----------------------------------------------------------------------------------------*/ - -static ivas_error ivas_crend_convolver( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float pcm_in[][L_FRAME48k], - float pcm_out[][L_FRAME48k], - const int16_t i_ts ) -{ - float *pIn; - float *pFreq_buf_re; - float *pFreq_buf_im; - float *pFreq_filt_re; - float *pFreq_filt_im; - int16_t i, j, k, m, nchan_out, subframe_length, nchan_intern, idx_in; - float pOut[L_FRAME48k * 2]; - float tmp_out_re[L_FRAME48k], tmp_out_im[L_FRAME48k]; - int16_t offset, offset_in, offset_diffuse; - int32_t output_Fs; - - nchan_intern = audioCfg2channels( st_ivas->intern_config ); - nchan_out = st_ivas->hDecoderConfig->nchan_out; - output_Fs = st_ivas->hDecoderConfig->output_Fs; - subframe_length = (int16_t) ( output_Fs / FRAMES_PER_SEC ) / MAX_PARAM_SPATIAL_SUBFRAMES; - - offset = st_ivas->hCrend->delay_line_rw_index * subframe_length; /* subframe_length * ( st_ivas->hHrtf->max_num_iterations - 1 ); */ - offset_diffuse = st_ivas->hCrend->diffuse_delay_line_rw_index * subframe_length; /* subframe_length *( st_ivas->hHrtf->num_iterations_diffuse[0] - 1 ); */ - - if ( st_ivas->hHrtf->num_iterations_diffuse[0] > 0 ) - { - set_zero( &st_ivas->hCrend->freq_buffer_re_diffuse[offset_diffuse], subframe_length ); - set_zero( &st_ivas->hCrend->freq_buffer_im_diffuse[offset_diffuse], subframe_length ); - } - - i = 0; - for ( idx_in = 0; idx_in < nchan_intern; idx_in++ ) - { - pIn = &pcm_in[idx_in][i_ts * subframe_length]; - if ( st_ivas->hIntSetup.index_lfe[0] != idx_in ) - { - if ( st_ivas->hHrtf->num_iterations_diffuse[0] > 0 ) - { - pFreq_buf_re = &st_ivas->hCrend->freq_buffer_re_diffuse[offset_diffuse]; - pFreq_buf_im = &st_ivas->hCrend->freq_buffer_im_diffuse[offset_diffuse]; - pFreq_filt_re = &st_ivas->hCrend->freq_buffer_re[i][offset]; - pFreq_filt_im = &st_ivas->hCrend->freq_buffer_im[i][offset]; - - for ( k = 0; k < st_ivas->hHrtf->index_frequency_max_diffuse; k++ ) - { - pFreq_buf_re[k] += pFreq_filt_re[k] * st_ivas->hHrtf->inv_diffuse_weight[i]; - pFreq_buf_im[k] += pFreq_filt_im[k] * st_ivas->hHrtf->inv_diffuse_weight[i]; - } - } - - pFreq_buf_re = &st_ivas->hCrend->freq_buffer_re[i][offset]; - pFreq_buf_im = &st_ivas->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_intern; idx_in++ ) - { - if ( idx_in != st_ivas->hIntSetup.index_lfe[0] ) - { - offset = 0; - for ( m = 0; m < st_ivas->hHrtf->num_iterations[i][j]; m++ ) - { - offset_in = ( st_ivas->hCrend->delay_line_rw_index + st_ivas->hHrtf->max_num_iterations - st_ivas->hHrtf->num_iterations[i][j] + m + 1 ); - offset_in = offset_in % ( st_ivas->hHrtf->max_num_iterations ); - offset_in = offset_in * subframe_length; - pFreq_buf_re = &st_ivas->hCrend->freq_buffer_re[i][offset_in]; - pFreq_buf_im = &st_ivas->hCrend->freq_buffer_im[i][offset_in]; - pFreq_filt_re = &st_ivas->hHrtf->pOut_to_bin_re[i][j][offset]; - pFreq_filt_im = &st_ivas->hHrtf->pOut_to_bin_im[i][j][offset]; - - for ( k = 0; k < st_ivas->hHrtf->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 < st_ivas->hHrtf->num_iterations_diffuse[j]; m++ ) - { - offset_diffuse = ( st_ivas->hCrend->diffuse_delay_line_rw_index + m + 1 ); - offset_diffuse = offset_diffuse % st_ivas->hHrtf->num_iterations_diffuse[0]; - offset_diffuse = offset_diffuse * subframe_length; - pFreq_buf_re = &st_ivas->hCrend->freq_buffer_re_diffuse[offset_diffuse]; - pFreq_buf_im = &st_ivas->hCrend->freq_buffer_im_diffuse[offset_diffuse]; - pFreq_filt_re = &st_ivas->hHrtf->pOut_to_bin_diffuse_re[j][offset]; - pFreq_filt_im = &st_ivas->hHrtf->pOut_to_bin_diffuse_im[j][offset]; - - for ( k = 0; k < st_ivas->hHrtf->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] + st_ivas->hCrend->prev_out_buffer[j][k]; - st_ivas->hCrend->prev_out_buffer[j][k] = pOut[k + subframe_length]; - } - } - - st_ivas->hCrend->delay_line_rw_index++; - st_ivas->hCrend->delay_line_rw_index = st_ivas->hCrend->delay_line_rw_index % ( st_ivas->hHrtf->max_num_iterations ); - if ( st_ivas->hHrtf->num_iterations_diffuse[0] > 0 ) - { - st_ivas->hCrend->diffuse_delay_line_rw_index++; - st_ivas->hCrend->diffuse_delay_line_rw_index = st_ivas->hCrend->diffuse_delay_line_rw_index % ( st_ivas->hHrtf->num_iterations_diffuse[0] ); - } - - return IVAS_ERR_OK; -} -#endif - -#ifndef FIX_197_CREND_INTERFACE - -/*-----------------------------------------------------------------------------------------* - * Function ivas_crend_process() - * - * Process call for IVAS Crend renderer - *-----------------------------------------------------------------------------------------*/ - -ivas_error ivas_crend_process( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float output[][L_FRAME48k] /* i/o: input/output audio channels */ -) -{ - int16_t i, nchan_out, output_frame; - int16_t subframe_len, subframe_idx; - float pcm_tmp[BINAURAL_CHANNELS][L_FRAME48k]; - AUDIO_CONFIG intern_config; - ivas_error error; - - push_wmops( "ivas_crend_process" ); - - intern_config = st_ivas->intern_config; - nchan_out = st_ivas->hDecoderConfig->nchan_out; - output_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); - subframe_len = output_frame / MAX_PARAM_SPATIAL_SUBFRAMES; - - for ( subframe_idx = 0; subframe_idx < MAX_PARAM_SPATIAL_SUBFRAMES; subframe_idx++ ) - { - if ( st_ivas->hDecoderConfig->Opt_Headrotation && st_ivas->hHeadTrackData && st_ivas->hHeadTrackData->num_quaternions >= 0 ) - { - /* Orientation tracking */ -#ifndef FIX_I109_ORIENTATION_TRACKING - if ( st_ivas->hCrend->hTrack != NULL ) - { - if ( st_ivas->hDecoderConfig->orientation_tracking == IVAS_ORIENT_TRK_AVG ) - { - ivas_orient_trk_SetTrackingType( st_ivas->hCrend->hTrack, OTR_TRACKING_AVG_ORIENT ); - } - else - { - ivas_orient_trk_SetTrackingType( st_ivas->hCrend->hTrack, OTR_TRACKING_REF_ORIENT ); - } - - /* get current subframe quaternion and convert to euler angles */ - Quat2Euler( st_ivas->hHeadTrackData->Quaternions[subframe_idx], &( st_ivas->hCrend->m_fYaw ), &( st_ivas->hCrend->m_fPitch ), &( st_ivas->hCrend->m_fRoll ) ); - ivas_orient_trk_SetAbsoluteOrientation( st_ivas->hCrend->hTrack, st_ivas->hCrend->m_fYaw, st_ivas->hCrend->m_fPitch, st_ivas->hCrend->m_fRoll ); - ivas_orient_trk_Process( st_ivas->hCrend->hTrack ); - ivas_orient_trk_GetTrackedOrientation( st_ivas->hCrend->hTrack, &( st_ivas->hCrend->m_fYaw ), &( st_ivas->hCrend->m_fPitch ), &( st_ivas->hCrend->m_fRoll ) ); - } -#endif - - /* Rotation in SHD for: - MC with elevation (5_1_2 / 5_1_4 / 7_1_4) -> BINAURAL - SBA SPAR -> BINAURAL or BINAURAL_ROOM - */ - if ( intern_config == AUDIO_CONFIG_FOA || intern_config == AUDIO_CONFIG_HOA2 || intern_config == AUDIO_CONFIG_HOA3 ) - { - rotateFrame_shd( st_ivas->hHeadTrackData, output, subframe_len, st_ivas->hIntSetup, subframe_idx ); - } - /* Rotation in SD for MC -> BINAURAL_ROOM */ - else if ( st_ivas->ivas_format != ISM_FORMAT && st_ivas->hIntSetup.is_loudspeaker_setup ) - { - rotateFrame_sd( st_ivas->hHeadTrackData, output, subframe_len, st_ivas->hIntSetup, st_ivas->hEFAPdata, subframe_idx ); - } - } - - if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) - { - if ( ( intern_config == AUDIO_CONFIG_FOA ) || ( intern_config == AUDIO_CONFIG_HOA2 ) || ( intern_config == AUDIO_CONFIG_HOA3 ) || - ( intern_config == AUDIO_CONFIG_5_1 ) || ( intern_config == AUDIO_CONFIG_7_1 ) || - ( intern_config == AUDIO_CONFIG_5_1_2 ) || ( intern_config == AUDIO_CONFIG_5_1_4 ) || ( intern_config == AUDIO_CONFIG_7_1_4 ) ) - { - ivas_crend_convolver( st_ivas, output, pcm_tmp, subframe_idx ); - - if ( st_ivas->hCrend->hReverb != NULL ) - { - if ( ( error = ivas_reverb_process( st_ivas->hCrend->hReverb, intern_config, 1, output, pcm_tmp, subframe_idx ) ) != IVAS_ERR_OK ) - { - return error; - } - } - } - else - { - return IVAS_ERR_INVALID_INPUT_FORMAT; - } - } - else - { - return IVAS_ERR_INTERNAL_FATAL; - } - } - - /* move to output */ - for ( i = 0; i < nchan_out; i++ ) - { - mvr2r( pcm_tmp[i], output[i], output_frame ); - } - - pop_wmops(); - - return IVAS_ERR_OK; -} -#endif - - /*------------------------------------------------------------------------- * initCrend_from_rom() * @@ -1424,17 +197,10 @@ static ivas_error ivas_rend_initCrend( /* set BRIR flag */ use_brir = false; -#ifdef FIX_197_CREND_INTERFACE if ( ( ( hRendCfg != NULL ) && hRendCfg->roomAcoustics.use_brir ) || ( ( hRendCfg == NULL ) && ( outConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM ) ) ) { use_brir = true; } -#else - if ( ( hRendCfg != NULL && hRendCfg->roomAcoustics.use_brir ) || outConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM ) - { - use_brir = true; - } -#endif if ( ( error = getAudioConfigNumChannels( inConfig, &nchan_in ) ) != IVAS_ERR_OK ) @@ -1901,8 +667,6 @@ static ivas_error ivas_rend_initCrend( return IVAS_ERR_OK; } -#ifdef FIX_197_CREND_INTERFACE -#ifdef FIX_329_ENABLE_TD_RENDERER_REVERB_MC /*------------------------------------------------------------------------- * ivas_rend_initCrendWrapper() * @@ -1958,8 +722,6 @@ ivas_error ivas_rend_initCrendWrapper( return IVAS_ERR_OK; } -#endif -#endif /*------------------------------------------------------------------------- * ivas_rend_openCrend() * @@ -1967,17 +729,11 @@ ivas_error ivas_rend_initCrendWrapper( *------------------------------------------------------------------------*/ 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 ) { @@ -1989,35 +745,14 @@ ivas_error ivas_rend_openCrend( ivas_error error; error = IVAS_ERR_OK; -#ifdef FIX_197_CREND_INTERFACE -#ifdef FIX_329_ENABLE_TD_RENDERER_REVERB_MC if ( ( error = ivas_rend_initCrendWrapper( pCrend ) ) != IVAS_ERR_OK ) { return error; } hCrend = ( *pCrend )->hCrend; -#else - if ( pCrend == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend Wrapper\n" ); - } - - if ( *pCrend == NULL ) - { - if ( ( *pCrend = (CREND_WRAPPER_HANDLE) malloc( sizeof( CREND_WRAPPER ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend Wrapper\n" ); - } - ( *pCrend )->binaural_latency_ns = 0; - ( *pCrend )->hCrend = NULL; - ( *pCrend )->hHrtfCrend = NULL; - } -#endif -#endif subframe_length = (int16_t) ( output_Fs / FRAMES_PER_SEC ) / MAX_PARAM_SPATIAL_SUBFRAMES; -#ifdef FIX_197_CREND_INTERFACE if ( ( *pCrend )->hHrtfCrend == NULL ) { if ( ( error = ivas_rend_initCrend( *pCrend, inConfig, outConfig, hRendCfg, hSetOfHRTF, output_Fs ) ) != IVAS_ERR_OK ) @@ -2025,55 +760,8 @@ ivas_error ivas_rend_openCrend( return error; } } -#else - if ( pCrend->hHrtfCrend == NULL ) - { - if ( ( error = ivas_rend_initCrend( pCrend, inConfig, outConfig, hRendCfg, hSetOfHRTF, output_Fs ) ) != IVAS_ERR_OK ) - { - return error; - } - } -#endif - -#ifndef FIX_329_ENABLE_TD_RENDERER_REVERB_MC - - if ( ( hCrend = (CREND_HANDLE) malloc( sizeof( CREND_DATA ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for renderer handle" ); - } - - hCrend->lfe_delay_line = NULL; - - for ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) - { - hCrend->freq_buffer_re[i] = NULL; - hCrend->freq_buffer_im[i] = NULL; - } - - for ( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - hCrend->prev_out_buffer[i] = NULL; - } - hCrend->freq_buffer_re_diffuse = NULL; - hCrend->freq_buffer_im_diffuse = NULL; - hCrend->hReverb = NULL; - hCrend->delay_line_rw_index = 0; - hCrend->diffuse_delay_line_rw_index = 0; -#ifndef FIX_I109_ORIENTATION_TRACKING - hCrend->hTrack = NULL; - hCrend->m_fYaw = 0; - hCrend->m_fPitch = 0; - hCrend->m_fRoll = 0; -#endif -#endif - - -#ifdef FIX_197_CREND_INTERFACE hHrtf = ( *pCrend )->hHrtfCrend; -#else - hHrtf = pCrend->hHrtfCrend; -#endif if ( hHrtf != NULL ) { @@ -2138,36 +826,12 @@ ivas_error ivas_rend_openCrend( { hCrend->lfe_delay_line = NULL; } -#ifdef FIX_197_CREND_INTERFACE -#ifndef FIX_I109_ORIENTATION_TRACKING - if ( Opt_Headrotation ) -#else - (void) Opt_Headrotation; - if ( false ) /* TODO tmu : check renderer headrotation flag */ -#endif - { - if ( ( hCrend->hTrack = (ivas_orient_trk_state_t *) malloc( sizeof( ivas_orient_trk_state_t ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Orientation tracking" ); - } - - ivas_orient_trk_Init( hCrend->hTrack ); - } - else - { - hCrend->hTrack = NULL; - } -#endif if ( ( hRendCfg != NULL ) && ( hRendCfg->roomAcoustics.late_reverb_on ) ) { if ( ( error = ivas_reverb_open( &( hCrend->hReverb ), inConfig, -#ifdef FIX_197_CREND_INTERFACE ( *pCrend )->hHrtfCrend, -#else - pCrend->hHrtfCrend, -#endif hRendCfg, output_Fs ) ) != IVAS_ERR_OK ) { @@ -2179,18 +843,10 @@ ivas_error ivas_rend_openCrend( hCrend->hReverb = NULL; } -#ifdef FIX_197_CREND_INTERFACE ( *pCrend )->binaural_latency_ns = (int32_t) ( ( *pCrend )->hHrtfCrend->latency_s * 1000000000.f ); -#else - pCrend->binaural_latency_ns = (int32_t) ( pCrend->hHrtfCrend->latency_s * 1000000000.f ); -#endif } -#ifdef FIX_197_CREND_INTERFACE ( *pCrend )->hCrend = hCrend; -#else - pCrend->hCrend = hCrend; -#endif return IVAS_ERR_OK; } @@ -2201,17 +857,11 @@ ivas_error ivas_rend_openCrend( * Deallocate Crend renderer handle *------------------------------------------------------------------------*/ -#ifdef FIX_197_CREND_INTERFACE void ivas_rend_closeCrend( CREND_WRAPPER_HANDLE *pCrend ) -#else -ivas_error ivas_rend_closeCrend( - CREND_WRAPPER *pCrend ) -#endif { int16_t i; -#ifdef FIX_197_CREND_INTERFACE if ( pCrend == NULL ) { return; @@ -2284,71 +934,6 @@ ivas_error ivas_rend_closeCrend( *pCrend = NULL; } return; -#else - if ( pCrend->hHrtfCrend != NULL ) - { - ivas_hrtf_close( &pCrend->hHrtfCrend ); - } - - if ( pCrend->hCrend != NULL ) - { - - for ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) - { - if ( pCrend->hCrend->freq_buffer_re[i] != NULL ) - { - free( pCrend->hCrend->freq_buffer_re[i] ); - pCrend->hCrend->freq_buffer_re[i] = NULL; - } - if ( pCrend->hCrend->freq_buffer_im[i] != NULL ) - { - free( pCrend->hCrend->freq_buffer_im[i] ); - pCrend->hCrend->freq_buffer_im[i] = NULL; - } - } - - for ( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - if ( pCrend->hCrend->prev_out_buffer[i] != NULL ) - { - free( pCrend->hCrend->prev_out_buffer[i] ); - pCrend->hCrend->prev_out_buffer[i] = NULL; - } - } - - if ( pCrend->hCrend->lfe_delay_line != NULL ) - { - free( pCrend->hCrend->lfe_delay_line ); - pCrend->hCrend->lfe_delay_line = NULL; - } - - if ( pCrend->hCrend->freq_buffer_re_diffuse != NULL ) - { - free( pCrend->hCrend->freq_buffer_re_diffuse ); - pCrend->hCrend->freq_buffer_re_diffuse = NULL; - } - - if ( pCrend->hCrend->freq_buffer_im_diffuse != NULL ) - { - free( pCrend->hCrend->freq_buffer_im_diffuse ); - pCrend->hCrend->freq_buffer_im_diffuse = NULL; - } - -#ifndef FIX_I109_ORIENTATION_TRACKING - if ( pCrend->hCrend->hTrack != NULL ) - { - free( pCrend->hCrend->hTrack ); - pCrend->hCrend->hTrack = NULL; - } -#endif - - ivas_reverb_close( &pCrend->hCrend->hReverb ); - - free( pCrend->hCrend ); - pCrend->hCrend = NULL; - } - return IVAS_ERR_OK; -#endif } /*-----------------------------------------------------------------------------------------* @@ -2523,20 +1108,14 @@ 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 ) { -#ifdef FIX_197_CREND_INTERFACE int16_t i, subframe_idx, output_frame, subframe_len; -#else - int16_t i, subframe_idx, output_frame; -#endif int16_t nchan_out; float pcm_tmp[BINAURAL_CHANNELS][L_FRAME48k]; AUDIO_CONFIG in_config; @@ -2550,11 +1129,7 @@ ivas_error ivas_rend_crendProcess( inRendConfig = getRendAudioConfigFromIvasAudioConfig( inConfig ); outRendConfig = getRendAudioConfigFromIvasAudioConfig( outConfig ); -#ifdef FIX_197_CREND_INTERFACE in_config = getIvasAudioConfigFromRendAudioConfig( inRendConfig ); -#else - in_config = rendAudioConfigToIvasAudioConfig( inRendConfig ); -#endif inConfigType = getAudioConfigType( inRendConfig ); @@ -2564,12 +1139,9 @@ ivas_error ivas_rend_crendProcess( } output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); -#ifdef FIX_197_CREND_INTERFACE subframe_len = output_frame / MAX_PARAM_SPATIAL_SUBFRAMES; -#endif for ( subframe_idx = 0; subframe_idx < MAX_PARAM_SPATIAL_SUBFRAMES; subframe_idx++ ) { -#ifdef FIX_197_CREND_INTERFACE if ( hDecoderConfig && hDecoderConfig->Opt_Headrotation && hHeadTrackData && hHeadTrackData->num_quaternions >= 0 ) { /* Orientation tracking */ @@ -2612,7 +1184,6 @@ ivas_error ivas_rend_crendProcess( rotateFrame_sd( hHeadTrackData, output, subframe_len, *hIntSetup, hEFAPdata, subframe_idx ); } } -#endif if ( ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) || ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS ) ) { diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 020dd27cfa1b47d827fcf82d00f7e45094865297..ebd7c737a212f4a969491a088145f76a716326a1 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -139,22 +139,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( set_zero( hBinaural->ChCrossImOutPrev, nBins ); hBinaural->renderStereoOutputInsteadOfBinaural = 0; -#ifdef FIX_107_5MS_SUBFRAME_RENDERING hBinaural->useSubframeMode = 1; -#else - if ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->sba_mode == SBA_MODE_SPAR ) /* Use subframe-mode with SPAR, since the metadata is not in sync on a frame level */ - { - hBinaural->useSubframeMode = 1; - } - else - { -#ifdef DEBUGGING - hBinaural->useSubframeMode = st_ivas->hDecoderConfig->forceSubframeBinauralization; -#else - hBinaural->useSubframeMode = 0; /* Default to 20 ms mode. */ -#endif - } -#endif hBinaural->useTdDecorr = 0; if ( st_ivas->ivas_format == SBA_FORMAT ) diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 61c78083a90af6db97d66f7077837ad6b2d2e1c9..4a72b76384a9617bbdf2329b44712160f5930658 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -48,6 +48,9 @@ *---------------------------------------------------------------------*/ static void TDREND_Clear_Update_flags( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd ); +#ifdef TD5 +static void angles_to_vec( const float radius, const float azimuth, const float elevation, float *vec ); +#endif /*---------------------------------------------------------------------* * ivas_td_binaural_open_unwrap() @@ -56,11 +59,14 @@ static void TDREND_Clear_Update_flags( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRe *---------------------------------------------------------------------*/ 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 */ + 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 */ +#ifdef TD5 + const float *directivity, /* i : Directivity pattern (used for ISm) */ +#endif 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 */ @@ -169,9 +175,13 @@ ivas_error ivas_td_binaural_open_unwrap( for ( nS = 0; nS < nchan_rend; nS++ ) { /* Set source positions according to loudspeaker layout */ +#ifdef TD5 + angles_to_vec( 1.0f, ls_azimuth[nS], ls_elevation[nS], Pos ); +#else 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 ); +#endif Dir[0] = 1.0f; Dir[1] = 0.0f; Dir[2] = 0.0f; @@ -187,6 +197,20 @@ ivas_error ivas_td_binaural_open_unwrap( TDREND_MIX_SRC_SetDirAtten( pBinRendTd, nS, DirAtten_p ); } } +#ifdef TD5 + if ( ivas_format == ISM_FORMAT ) + { + DirAtten_p = pBinRendTd->DirAtten_p; + DirAtten_p->ConeInnerAngle = directivity[0]; + DirAtten_p->ConeOuterAngle = directivity[1]; + DirAtten_p->ConeOuterGain = directivity[2]; + + for ( nS = 0; nS < nchan_rend; nS++ ) + { + TDREND_MIX_SRC_SetDirAtten( pBinRendTd, nS, DirAtten_p ); + } + } +#endif *hBinRendererTd = pBinRendTd; *binaural_latency_ns = (int32_t) ( ( *hBinRendererTd )->HrFiltSet_p->latency_s * 1000000000.f ); @@ -228,21 +252,8 @@ void ivas_td_binaural_close( *---------------------------------------------------------------------*/ ivas_error ivas_td_binaural_renderer_unwrap( -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND - REVERB_HANDLE hReverb, /* i : reverb handle */ -#else - 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 -#endif - AUDIO_CONFIG transport_config, /* i : Transport configuration */ -#ifndef FIX_330_ENABLE_TD_RENDERER_REVERB_REND - const int32_t output_Fs, /* i : Output sampling rate */ -#endif + REVERB_HANDLE hReverb, /* i : reverb handle */ + AUDIO_CONFIG transport_config, /* i : Transport configuration */ 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 */ @@ -250,8 +261,11 @@ ivas_error ivas_td_binaural_renderer_unwrap( 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 */ +#ifdef TD5 + const IVAS_POSITION *Pos, /* i : Listener position data per subframe */ +#endif + float output[][L_FRAME48k], /* i/o: SCE channels / Binaural synthesis */ + const int16_t output_frame /* i : output frame length */ ) { int16_t subframe_length; @@ -260,25 +274,6 @@ ivas_error ivas_td_binaural_renderer_unwrap( ivas_error error; subframe_length = output_frame / MAX_PARAM_SPATIAL_SUBFRAMES; -#ifndef FIX_330_ENABLE_TD_RENDERER_REVERB_REND - if ( hRenderConfig != NULL ) - { - - if ( hRenderConfig->roomAcoustics.late_reverb_on && ( ini_frame == 0 ) ) - { - ivas_reverb_open( -#ifdef FIX_197_CREND_INTERFACE - &hCrendWrapper->hCrend->hReverb, -#else - &hCrend->hReverb, -#endif - transport_config, - NULL, - hRenderConfig, - output_Fs ); - } - } -#endif /* Update object position(s) */ TDREND_Update_object_positions( hBinRendererTd, nchan_transport, lfe_idx, ivas_format, hIsmMetaData, output ); @@ -286,42 +281,20 @@ ivas_error ivas_td_binaural_renderer_unwrap( for ( subframe_idx = 0; subframe_idx < MAX_PARAM_SPATIAL_SUBFRAMES; subframe_idx++ ) { /* Update the listener's location/orientation */ +#ifdef TD5 + TDREND_Update_listener_orientation( hBinRendererTd, Opt_Headrotation, ( Quaternions != NULL ) ? &Quaternions[subframe_idx] : NULL, ( Pos != NULL ) ? &Pos[subframe_idx] : NULL ); +#else TDREND_Update_listener_orientation( hBinRendererTd, Opt_Headrotation, ( Quaternions != NULL ) ? &Quaternions[subframe_idx] : NULL ); +#endif -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND if ( ( hReverb != NULL ) && ( hReverb->pConfig.roomAcoustics.late_reverb_on ) ) -#else - if ( ( hRenderConfig != NULL ) && ( hRenderConfig->roomAcoustics.late_reverb_on ) ) -#endif { if ( ( error = ivas_reverb_process( -#ifdef FIX_197_CREND_INTERFACE -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND hReverb, -#else - hCrendWrapper->hCrend->hReverb, -#endif -#else - hCrend->hReverb, -#endif transport_config, 0, output, reverb_signal, subframe_idx ) ) != IVAS_ERR_OK ) { return error; } - -#ifndef FIX_330_ENABLE_TD_RENDERER_REVERB_REND - ivas_reverb_process( -#ifdef FIX_197_CREND_INTERFACE - hCrendWrapper->hCrend->hReverb, -#else - hCrend->hReverb, -#endif - transport_config, - 0, - output, - reverb_signal, - subframe_idx ); -#endif } /* Render subframe */ @@ -332,24 +305,12 @@ ivas_error ivas_td_binaural_renderer_unwrap( } -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND if ( ( hReverb != NULL ) && ( hReverb->pConfig.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 ); } -#else - if ( hRenderConfig != NULL ) /* Renderer Configuration not enabled in TD standalone renderer */ - { - if ( 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 ); - } - } -#endif return IVAS_ERR_OK; } @@ -483,6 +444,10 @@ void TDREND_Update_object_positions( /* Update the source positions */ /* Source position and direction */ +#ifdef TD5 + angles_to_vec( hIsmMetaData[nS]->radius, hIsmMetaData[nS]->azimuth, hIsmMetaData[nS]->elevation, Pos ); + angles_to_vec( 1.0f, hIsmMetaData[nS]->yaw, hIsmMetaData[nS]->pitch, Dir ); +#else Pos[0] = cosf( hIsmMetaData[nS]->elevation * PI_OVER_180 ) * cosf( hIsmMetaData[nS]->azimuth * PI_OVER_180 ); Pos[1] = cosf( hIsmMetaData[nS]->elevation * PI_OVER_180 ) * sinf( hIsmMetaData[nS]->azimuth * PI_OVER_180 ); Pos[2] = sinf( hIsmMetaData[nS]->elevation * PI_OVER_180 ); @@ -490,6 +455,7 @@ void TDREND_Update_object_positions( Dir[1] = 0.0f; Dir[2] = 0.0f; +#endif /* Source directivity info */ DirAtten_p->ConeInnerAngle = 360.0f; DirAtten_p->ConeOuterAngle = 360.0f; @@ -516,19 +482,29 @@ void TDREND_Update_object_positions( 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 */ +#ifdef TD5 + const IVAS_QUATERNION *headPosition, /* i : Listener orientation */ + const IVAS_POSITION *Pos /* i : Listener Position */ +#else + const IVAS_QUATERNION *headPosition /* i : Head Position */ +#endif ) { +#ifndef TD5 float Pos[3]; +#endif float FrontVec[3]; float UpVec[3]; float Rmat[3][3]; - +#ifdef TD5 + float Pos_p[3]; +#else /* Update the listener's location/orientation */ /* Listener at the origin */ Pos[0] = 0.0f; Pos[1] = 0.0f; Pos[2] = 0.0f; +#endif if ( headRotEnabled ) { @@ -542,6 +518,12 @@ void TDREND_Update_listener_orientation( UpVec[0] = Rmat[2][0]; UpVec[1] = Rmat[2][1]; UpVec[2] = Rmat[2][2]; +#ifdef TD5 + /* Input position */ + Pos_p[0] = ( *Pos ).x; + Pos_p[1] = ( *Pos ).y; + Pos_p[2] = ( *Pos ).z; +#endif } else { @@ -553,10 +535,20 @@ void TDREND_Update_listener_orientation( UpVec[0] = 0.0f; UpVec[1] = 0.0f; UpVec[2] = 1.0f; +#ifdef TD5 + /* Listener at the origin */ + Pos_p[0] = 0.0f; + Pos_p[1] = 0.0f; + Pos_p[2] = 0.0f; +#endif } /* Set the listener position and orientation:*/ +#ifdef TD5 + TDREND_MIX_LIST_SetPos( hBinRendererTd, Pos_p ); +#else TDREND_MIX_LIST_SetPos( hBinRendererTd, Pos ); +#endif TDREND_MIX_LIST_SetOrient( hBinRendererTd, FrontVec, UpVec ); return; @@ -572,6 +564,9 @@ void TDREND_Update_listener_orientation( ivas_error ivas_td_binaural_open_ext( TDREND_WRAPPER *pTDRend, IVAS_REND_AudioConfig inConfig, +#ifdef TD5 + RENDER_CONFIG_DATA *hRendCfg, /* i : Renderer configuration */ +#endif LSSETUP_CUSTOM_STRUCT *customLsInput, const int32_t outFs ) { @@ -593,16 +588,16 @@ ivas_error ivas_td_binaural_open_ext( 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; +#ifdef TD5 + return ivas_td_binaural_open_unwrap( &pTDRend->hHrtfTD, outFs, nchan_transport, ivas_format, transport_config, hRendCfg->directivity, hTransSetup, &pTDRend->hBinRendererTd, &pTDRend->binaural_latency_ns ); +#else return ivas_td_binaural_open_unwrap( &pTDRend->hHrtfTD, outFs, nchan_transport, ivas_format, transport_config, hTransSetup, &pTDRend->hBinRendererTd, &pTDRend->binaural_latency_ns ); +#endif } @@ -619,28 +614,19 @@ ivas_error ivas_td_binaural_renderer_ext( 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 */ -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND - const REVERB_HANDLE reverb, /* i : reverb handle */ -#endif - const int16_t output_frame, /* i : output frame length */ - float output[][L_FRAME48k] /* i/o: SCE channels / Binaural synthesis */ + const REVERB_HANDLE reverb, /* i : reverb handle */ + const int16_t output_frame, /* i : output frame length */ + float output[][L_FRAME48k] /* i/o: SCE channels / Binaural synthesis */ ) { ISM_METADATA_FRAME hIsmMetaDataFrame; ISM_METADATA_HANDLE hIsmMetaData[1]; int16_t lfe_idx; int16_t num_src; -#ifndef FIX_330_ENABLE_TD_RENDERER_REVERB_REND - /* TODO tmu : pass down renderer config struct */ - // float reverb_signal[BINAURAL_CHANNELS][L_FRAME48k]; -#endif IVAS_FORMAT ivas_format; IVAS_REND_AudioConfigType inConfigType; AUDIO_CONFIG transport_config; ivas_error error; -#ifndef FIX_330_ENABLE_TD_RENDERER_REVERB_REND - int32_t output_Fs; -#endif push_wmops( "ivas_td_binaural_renderer_ext" ); @@ -651,9 +637,7 @@ ivas_error ivas_td_binaural_renderer_ext( if ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) { ivas_format = MC_FORMAT; -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND transport_config = getIvasAudioConfigFromRendAudioConfig( inConfig ); -#endif if ( inConfig != IVAS_REND_AUDIO_CONFIG_LS_CUSTOM ) { if ( ( error = getAudioConfigNumChannels( inConfig, &num_src ) ) != IVAS_ERR_OK ) @@ -671,37 +655,51 @@ ivas_error ivas_td_binaural_renderer_ext( { ivas_format = ISM_FORMAT; num_src = 1; -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND transport_config = AUDIO_CONFIG_ISM1; -#endif hIsmMetaData[0] = &hIsmMetaDataFrame; hIsmMetaData[0]->azimuth = currentPos->azimuth; hIsmMetaData[0]->elevation = currentPos->elevation; +#ifdef TD5 + hIsmMetaData[0]->yaw = currentPos->yaw; + hIsmMetaData[0]->pitch = currentPos->pitch; + hIsmMetaData[0]->radius = currentPos->radius; +#endif } -#ifndef FIX_330_ENABLE_TD_RENDERER_REVERB_REND -#ifdef FIX_197_CREND_INTERFACE - transport_config = getIvasAudioConfigFromRendAudioConfig( inConfig ); -#else - transport_config = rendAudioConfigToIvasAudioConfig( inConfig ); -#endif - output_Fs = output_frame * 50; -#endif -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND if ( ( error = ivas_td_binaural_renderer_unwrap( reverb, transport_config, pTDRend->hBinRendererTd, num_src, lfe_idx, ivas_format, hIsmMetaData, headRotData->headRotEnabled, - ( headRotData != NULL ) ? headRotData->headPositions : NULL, output, output_frame ) ) != IVAS_ERR_OK ) - { - return error; - } + ( headRotData != NULL ) ? headRotData->headPositions : NULL, +#ifdef TD5 + ( headRotData != NULL ) ? headRotData->Pos : NULL, output, output_frame ) ) != IVAS_ERR_OK ) #else - if ( ( error = 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 ) ) != IVAS_ERR_OK ) + output, output_frame ) ) != IVAS_ERR_OK ) +#endif { return error; } -#endif pop_wmops(); return IVAS_ERR_OK; } + +#ifdef TD5 +/*---------------------------------------------------------------------* + * angles_to_vec() + * + * Convert azimuth and elevation angles to position/orientation vector + *---------------------------------------------------------------------*/ + +static void angles_to_vec( + const float radius, /* i : radius */ + const float azimuth, /* i : Azimuth angle */ + const float elevation, /* i : Elevation angle */ + float *vec /* o : Pos/Dir vector */ +) +{ + vec[0] = radius * cosf( elevation * PI_OVER_180 ) * cosf( azimuth * PI_OVER_180 ); + vec[1] = radius * cosf( elevation * PI_OVER_180 ) * sinf( azimuth * PI_OVER_180 ); + vec[2] = radius * sinf( elevation * PI_OVER_180 ); + + return; +} +#endif diff --git a/lib_rend/ivas_objectRenderer_hrFilt.c b/lib_rend/ivas_objectRenderer_hrFilt.c index 0220b481450f403294a5cc453e8931780e7f5f8e..d28abdba30626bed51d1485baf0899c67c08b264 100644 --- a/lib_rend/ivas_objectRenderer_hrFilt.c +++ b/lib_rend/ivas_objectRenderer_hrFilt.c @@ -69,10 +69,21 @@ ivas_error TDREND_REND_RenderSourceHRFilt( { float LeftOutputFrame[L_SPATIAL_SUBFR_48k]; float RightOutputFrame[L_SPATIAL_SUBFR_48k]; +#ifdef TD5 + float Gain; + + Gain = ( *Src_p->SrcRend_p->DirGain_p ) * ( *Src_p->SrcRend_p->DistGain_p ); +#endif TDREND_Apply_ITD( Src_p->InputFrame_p, LeftOutputFrame, RightOutputFrame, &Src_p->previtd, Src_p->itd, Src_p->mem_itd, subframe_length ); +#ifdef TD5 + TDREND_firfilt( LeftOutputFrame, Src_p->hrf_left_prev, hrf_left_delta, intp_count, Src_p->mem_hrf_left, subframe_length, Src_p->filterlength, Gain ); + TDREND_firfilt( RightOutputFrame, Src_p->hrf_right_prev, hrf_right_delta, intp_count, Src_p->mem_hrf_right, subframe_length, Src_p->filterlength, Gain ); +#else TDREND_firfilt( LeftOutputFrame, Src_p->hrf_left_prev, hrf_left_delta, intp_count, Src_p->mem_hrf_left, subframe_length, Src_p->filterlength ); TDREND_firfilt( RightOutputFrame, Src_p->hrf_right_prev, hrf_right_delta, intp_count, Src_p->mem_hrf_right, subframe_length, Src_p->filterlength ); +#endif + /* Copy to accumulative output frame */ v_add( LeftOutputFrame, output_buf[0], output_buf[0], subframe_length ); v_add( RightOutputFrame, output_buf[1], output_buf[1], subframe_length ); diff --git a/lib_rend/ivas_objectRenderer_sfx.c b/lib_rend/ivas_objectRenderer_sfx.c index 10f5ef91f042fdef2bec853a160559ef7bab5681..72493b050117d115f653f1afe9c5b4c6d3770cb4 100644 --- a/lib_rend/ivas_objectRenderer_sfx.c +++ b/lib_rend/ivas_objectRenderer_sfx.c @@ -235,7 +235,12 @@ void TDREND_firfilt( 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 */ +#ifdef TD5 + const int16_t filterlength, /* i : Filter length */ + const float Gain /* i : Gain */ +#else + const int16_t filterlength /* i : Filter length */ +#endif ) { float buffer[SFX_SPAT_BIN_MAX_FILTER_LENGTH - 1 + L_SUBFRAME5MS_48k]; @@ -261,7 +266,11 @@ void TDREND_firfilt( { tmp += ( *p_filter++ ) * ( *p_tmp-- ); } +#ifdef TD5 + signal[i] = tmp * Gain; +#else signal[i] = tmp; +#endif if ( i < intp_count ) { diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources.c index d52422881292a65957e4c2d0c9d99a38f0d6ea7b..2a13efc24c219dec2e8d608a01e71498df33fee3 100644 --- a/lib_rend/ivas_objectRenderer_sources.c +++ b/lib_rend/ivas_objectRenderer_sources.c @@ -266,6 +266,9 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams( TDREND_MIX_Listener_t *Listener_p; TDREND_HRFILT_FiltSet_t *HrFiltSet_p; float ListRelPos[3], ListRelDist; +#ifdef TD5 + float ListRelPosAbs[3]; /* Relative position, ignoring orientation of listener */ +#endif float Azim, Elev; float hrf_left[SFX_SPAT_BIN_MAX_FILTER_LENGTH]; float hrf_right[SFX_SPAT_BIN_MAX_FILTER_LENGTH]; @@ -287,14 +290,22 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams( break; case TDREND_POSTYPE_ABSOLUTE: /* Absolute position */ +#ifdef TD5 + TDREND_SPATIAL_VecMapToNewCoordSystem( SrcSpatial_p->Pos_p, Listener_p->Pos, Listener_p->Front, Listener_p->Up, Listener_p->Right, ListRelPos, ListRelPosAbs ); +#else TDREND_SPATIAL_VecMapToNewCoordSystem( SrcSpatial_p->Pos_p, Listener_p->Pos, Listener_p->Front, Listener_p->Up, Listener_p->Right, ListRelPos ); +#endif break; default: /* Illegal position type */ #ifdef DEBUGGING printf( "Warning! TDREND_SRC_REND_UpdateFiltersFromSpatialParams: Invalid position type. Assuming absolute position!\n" ); #endif /* Assume absolute position */ +#ifdef TD5 + TDREND_SPATIAL_VecMapToNewCoordSystem( SrcSpatial_p->Pos_p, Listener_p->Pos, Listener_p->Front, Listener_p->Up, Listener_p->Right, ListRelPos, ListRelPosAbs ); +#else TDREND_SPATIAL_VecMapToNewCoordSystem( SrcSpatial_p->Pos_p, Listener_p->Pos, Listener_p->Front, Listener_p->Up, Listener_p->Right, ListRelPos ); +#endif break; } @@ -320,7 +331,11 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams( *SrcRend_p->DirGain_p = 1.0f; if ( SrcSpatial_p->DirAttenEnabled ) { +#ifdef TD5 + *SrcRend_p->DirGain_p = TDREND_SRC_SPATIAL_GetDirGain( &SrcSpatial_p->DirAtten, SrcSpatial_p->Front_p, ListRelPosAbs ); +#else *SrcRend_p->DirGain_p = TDREND_SRC_SPATIAL_GetDirGain( &SrcSpatial_p->DirAtten, SrcSpatial_p->Front_p, ListRelPos ); +#endif } /* Distance gain */ diff --git a/lib_rend/ivas_objectRenderer_vec.c b/lib_rend/ivas_objectRenderer_vec.c index c3a780c725fa66aa07fe592adfb06dba643098b8..f17d769821ab9e3abee43fed7b53d02829a14dfd 100644 --- a/lib_rend/ivas_objectRenderer_vec.c +++ b/lib_rend/ivas_objectRenderer_vec.c @@ -111,9 +111,22 @@ void TDREND_SPATIAL_VecMapToNewCoordSystem( 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 */ +#ifdef TD5 + float *MappedVec_p, /* o : Transformed vector */ + float *LisRelPosAbs /* o : Transformed vector ignoring orientation */ +#else + float *MappedVec_p /* o : Transformed vector */ +#endif ) { +#ifdef TD5 + v_sub( Vec_p, TranslVec_p, LisRelPosAbs, 3 ); + /* Evalute the relative Vec in the coordinates of the Orientation vectors, */ + /* which form an orthonormal basis */ + MappedVec_p[0] = dotp( LisRelPosAbs, DirVec_p, 3 ); + MappedVec_p[1] = dotp( LisRelPosAbs, RightVec_p, 3 ); + MappedVec_p[2] = dotp( LisRelPosAbs, UpVec_p, 3 ); +#else float RelVec[3]; /* Evaluate Vec relative to the new origin given by TranslVec */ @@ -124,7 +137,7 @@ void TDREND_SPATIAL_VecMapToNewCoordSystem( MappedVec_p[0] = dotp( RelVec, DirVec_p, 3 ); MappedVec_p[1] = dotp( RelVec, RightVec_p, 3 ); MappedVec_p[2] = dotp( RelVec, UpVec_p, 3 ); - +#endif return; } diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index c1b0c184908b61f06c5859c25ee41fd0970e6c93..a01d9ccbcc4599ae59038a0418bc3c3cd49be94f 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -54,11 +54,7 @@ ivas_error getAudioConfigNumChannels( int16_t *numChannels ); -#ifdef FIX_197_CREND_INTERFACE AUDIO_CONFIG getIvasAudioConfigFromRendAudioConfig( -#else -AUDIO_CONFIG rendAudioConfigToIvasAudioConfig( -#endif IVAS_REND_AudioConfig rendConfig ); IVAS_REND_AudioConfig getRendAudioConfigFromIvasAudioConfig( @@ -216,21 +212,8 @@ void ivas_HRTF_CRend_binary_close( *----------------------------------------------------------------------------------*/ ivas_error ivas_td_binaural_renderer_unwrap( -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND REVERB_HANDLE hReverb, /* i : reverb handle */ -#else - 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 -#endif AUDIO_CONFIG transport_config, /* i : Transport configuration */ -#ifndef FIX_330_ENABLE_TD_RENDERER_REVERB_REND - const int32_t output_Fs, /* i : Output sampling rate */ -#endif 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 */ @@ -238,6 +221,9 @@ ivas_error ivas_td_binaural_renderer_unwrap( 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 */ +#ifdef TD5 + const IVAS_POSITION *Pos, /* i : Listener position data per subframe */ +#endif float output[][L_FRAME48k], /* i/o: SCE channels / Binaural synthesis */ const int16_t output_frame /* i : output frame length */ ); @@ -248,9 +234,7 @@ ivas_error ivas_td_binaural_renderer_ext( 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 */ -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND const REVERB_HANDLE reverb, /* i : reverb handle */ -#endif const int16_t output_frame, /* i : output frame length */ float output[][L_FRAME48k] /* i/o: SCE channels / Binaural synthesis */ ); @@ -261,6 +245,9 @@ ivas_error ivas_td_binaural_open_unwrap( 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 */ +#ifdef TD5 + const float *directivity, /* i : Directivity pattern (used for ISm) */ +#endif 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 */ @@ -269,6 +256,9 @@ ivas_error ivas_td_binaural_open_unwrap( ivas_error ivas_td_binaural_open_ext( TDREND_WRAPPER *pTDRend, const IVAS_REND_AudioConfig inConfig, +#ifdef TD5 + RENDER_CONFIG_DATA *hRendCfg, /* i : Renderer configuration */ +#endif LSSETUP_CUSTOM_STRUCT *customLsInput, const int32_t output_Fs ); @@ -288,7 +278,12 @@ ivas_error TDREND_GetMix( void TDREND_Update_listener_orientation( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD Renderer handle */ const int16_t headRotEnabled, /* i : Headrotation flag */ +#ifdef TD5 + const IVAS_QUATERNION *headPosition, /* i : Listener orientation */ + const IVAS_POSITION *Pos /* i : Listener Position */ +#else const IVAS_QUATERNION *headPosition /* i : Head Position */ +#endif ); void TDREND_Update_object_positions( @@ -409,7 +404,12 @@ void TDREND_SPATIAL_VecMapToNewCoordSystem( const float *DirVec_p, /* i : Direction vector */ const float *UpVec_p, /* i : Up vector */ const float *RightVec_p, /* i : Right vector */ +#ifdef TD5 + float *MappedVec_p, /* o : Transformed vector */ + float *LisRelPosAbs /* o : Transformed vector ignoring orientation */ +#else float *MappedVec_p /* o : Transformed vector */ +#endif ); /*! r: Flag if the orientation has been updated */ @@ -475,7 +475,12 @@ void TDREND_firfilt( const int16_t intp_count, /* i : interpolation count */ float *mem, /* i/o: filter memory */ const int16_t subframe_length, /* i : Length of signal */ +#ifdef TD5 + const int16_t filterlength, /* i : Filter length */ + const float Gain /* i : Gain */ +#else const int16_t filterlength /* i : Filter length */ +#endif ); @@ -484,59 +489,33 @@ void TDREND_firfilt( *----------------------------------------------------------------------------------*/ 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 -#ifdef FIX_329_ENABLE_TD_RENDERER_REVERB_MC ivas_error ivas_rend_initCrendWrapper( CREND_WRAPPER_HANDLE *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 diff --git a/lib_rend/ivas_render_config.c b/lib_rend/ivas_render_config.c index ccee4ffe724264ba1e4ef2150797b1bb634fe6b1..2fdbeff0eb1840ecd60eb4d579c4baecb3097cfe 100644 --- a/lib_rend/ivas_render_config.c +++ b/lib_rend/ivas_render_config.c @@ -103,6 +103,7 @@ ivas_error ivas_render_config_init_from_rom( const int16_t room_flag_on /* i : room effect on/off flag */ ) { + if ( hRenderConfig == NULL || *hRenderConfig == NULL ) { return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "Unexpected null pointer while attempting to fill renderer configuration from ROM" ); @@ -125,5 +126,11 @@ ivas_error ivas_render_config_init_from_rom( mvr2r( ivas_reverb_default_RT60, ( *hRenderConfig )->roomAcoustics.pAcoustic_rt60, IVAS_REVERB_DEFAULT_N_BANDS ); mvr2r( ivas_reverb_default_DSR, ( *hRenderConfig )->roomAcoustics.pAcoustic_dsr, IVAS_REVERB_DEFAULT_N_BANDS ); +#ifdef TD5 + ( *hRenderConfig )->directivity[0] = 360.0f; /* Front cone */ + ( *hRenderConfig )->directivity[1] = 360.0f; /* Back cone */ + ( *hRenderConfig )->directivity[2] = 1.0f; /* Back attenuation */ +#endif + return IVAS_ERR_OK; } diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index 3911c36601c9722ba7544cab608d4b3ef240fcc2..ec5bd928d20031e172e23725aa5c1d26bef00afe 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -1175,7 +1175,6 @@ ivas_error ivas_reverb_open( /* set up reverb acoustic data on the basis of HRTF data and renderer config */ set_reverb_acoustic_data( ¶ms, input_audio_config, hHrtf, &hRenderConfig->roomAcoustics, subframe_len, nr_fc_input, nr_fc_fft_filter ); -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND /* set reverb acoustic configuration based on renderer config */ #ifdef DEBUGGING pState->pConfig.renderer_type_override = hRenderConfig->renderer_type_override; @@ -1184,7 +1183,6 @@ ivas_error ivas_reverb_open( pState->pConfig.roomAcoustics.use_brir = hRenderConfig->roomAcoustics.use_brir; pState->pConfig.roomAcoustics.late_reverb_on = hRenderConfig->roomAcoustics.late_reverb_on; pState->pConfig.roomAcoustics.nBands = hRenderConfig->roomAcoustics.nBands; -#endif /* set up input downmix */ pState->dmx_gain = calc_dmx_gain(); diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 5f9c89ef7ead50f9e92c22207d559978bbb8469f..9dafb5fb65b3ea577bcb076e1e9eebc2a3cb8176 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -221,7 +221,6 @@ typedef struct EFAP } EFAP, *EFAP_HANDLE; - /*----------------------------------------------------------------------------------* * Orientation tracking structure *----------------------------------------------------------------------------------*/ @@ -277,6 +276,9 @@ typedef struct { int8_t headRotEnabled; IVAS_QUATERNION headPositions[RENDERER_HEAD_POSITIONS_PER_FRAME]; +#ifdef TD5 + IVAS_POSITION Pos[RENDERER_HEAD_POSITIONS_PER_FRAME]; +#endif float crossfade[L_FRAME48k / RENDERER_HEAD_POSITIONS_PER_FRAME]; #ifdef FIX_I109_ORIENTATION_TRACKING ivas_orient_trk_state_t *hOrientationTracker; @@ -288,6 +290,9 @@ typedef struct ivas_binaural_head_track_struct { int16_t num_quaternions; IVAS_QUATERNION Quaternions[MAX_PARAM_SPATIAL_SUBFRAMES]; +#ifdef TD5 + IVAS_POSITION Pos[MAX_PARAM_SPATIAL_SUBFRAMES]; +#endif float Rmat[3][3]; float Rmat_prev[3][3]; @@ -302,7 +307,6 @@ typedef struct ivas_binaural_head_track_struct } HEAD_TRACK_DATA, *HEAD_TRACK_DATA_HANDLE; - /*----------------------------------------------------------------------------------* * Reverberator structure *----------------------------------------------------------------------------------*/ @@ -329,7 +333,9 @@ typedef struct ivas_render_config_t ivas_renderTypeOverride renderer_type_override; #endif ivas_roomAcoustics_t roomAcoustics; - +#ifdef TD5 + float directivity[3]; +#endif } RENDER_CONFIG_DATA, *RENDER_CONFIG_HANDLE; typedef struct ivas_rev_delay_line_t diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 89e25285af973c80898fcfbc40c044dcb9f45922..1c84149ef120d9ea7bfe506cc0765f877925d6f0 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -115,14 +115,8 @@ typedef struct IVAS_REND_AudioObjectPosition currentPos; IVAS_REND_AudioObjectPosition previousPos; TDREND_WRAPPER tdRendWrapper; -#ifdef FIX_197_CREND_INTERFACE CREND_WRAPPER_HANDLE crendWrapper; -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND REVERB_HANDLE reverb; -#endif -#else - CREND_WRAPPER crendWrapper; -#endif rotation_matrix rot_mat_prev; } input_ism; @@ -147,14 +141,8 @@ typedef struct LSSETUP_CUSTOM_STRUCT customLsInput; EFAP_WRAPPER efapInWrapper; TDREND_WRAPPER tdRendWrapper; -#ifdef FIX_197_CREND_INTERFACE CREND_WRAPPER_HANDLE crendWrapper; -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND REVERB_HANDLE reverb; -#endif -#else - CREND_WRAPPER crendWrapper; -#endif rotation_gains rot_gains_prev; lfe_routing lfeRouting; } input_mc; @@ -163,11 +151,7 @@ typedef struct { input_base base; pan_matrix hoaDecMtx; -#ifdef FIX_197_CREND_INTERFACE CREND_WRAPPER_HANDLE crendWrapper; -#else - CREND_WRAPPER crendWrapper; -#endif rotation_gains rot_gains_prev; } input_sba; @@ -329,11 +313,7 @@ static int32_t limitRendererOutput( * *-------------------------------------------------------------------*/ -#ifdef FIX_197_CREND_INTERFACE AUDIO_CONFIG getIvasAudioConfigFromRendAudioConfig( -#else -AUDIO_CONFIG rendAudioConfigToIvasAudioConfig( -#endif IVAS_REND_AudioConfig rendConfig ) { switch ( rendConfig ) @@ -1030,6 +1010,11 @@ static IVAS_REND_AudioObjectPosition defaultObjectPosition( pos.azimuth = 0.0f; pos.elevation = 0.0f; +#ifdef TD5 + pos.radius = 1.0f; + pos.yaw = 0.0f; + pos.pitch = 0.0f; +#endif return pos; } @@ -1075,7 +1060,6 @@ static CREND_WRAPPER defaultCrendWrapper( return w; } -#ifdef FIX_372_LIB_REND_VALIDATE_IO static bool isIoConfigPairSupported( IVAS_REND_AudioConfig inConfig, IVAS_REND_AudioConfig outConfig ) { /* Rendering mono or stereo to binaural is not supported */ @@ -1088,7 +1072,6 @@ static bool isIoConfigPairSupported( IVAS_REND_AudioConfig inConfig, IVAS_REND_A /* If not returned so far, config pair is supported */ return true; } -#endif static ivas_error setRendInputActiveIsm( void *input, @@ -1105,42 +1088,41 @@ static ivas_error setRendInputActiveIsm( rendCtx = inputIsm->base.ctx; outConfig = *rendCtx.pOutConfig; -#ifdef FIX_372_LIB_REND_VALIDATE_IO if ( !isIoConfigPairSupported( inConfig, outConfig ) ) { return IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED; } -#endif initRendInputBase( &inputIsm->base, inConfig, id, rendCtx ); inputIsm->currentPos = defaultObjectPosition(); inputIsm->previousPos = defaultObjectPosition(); -#ifdef FIX_197_CREND_INTERFACE inputIsm->crendWrapper = NULL; -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND inputIsm->reverb = NULL; -#endif -#else - inputIsm->crendWrapper = defaultCrendWrapper(); -#endif inputIsm->tdRendWrapper = defaultTdRendWrapper(); initRotMatrix( inputIsm->rot_mat_prev ); error = IVAS_ERR_OK; if ( outConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL ) { +#ifdef TD5 + if ( ( error = ivas_td_binaural_open_ext( &inputIsm->tdRendWrapper, inConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_td_binaural_open_ext( &inputIsm->tdRendWrapper, inConfig, NULL, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#endif { return error; } } else if ( outConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM ) { -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND if ( hRendCfg != NULL && hRendCfg->roomAcoustics.use_brir == 0 && hRendCfg->roomAcoustics.late_reverb_on ) { +#ifdef TD5 + if ( ( error = ivas_td_binaural_open_ext( &inputIsm->tdRendWrapper, inConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_td_binaural_open_ext( &inputIsm->tdRendWrapper, inConfig, NULL, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1152,24 +1134,15 @@ static ivas_error setRendInputActiveIsm( } else { -#endif if ( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, AUDIO_CONFIG_7_1_4, -#ifdef FIX_197_CREND_INTERFACE getIvasAudioConfigFromRendAudioConfig( outConfig ), -#else - rendAudioConfigToIvasAudioConfig( outConfig ), -#endif hRendCfg, -#ifdef FIX_197_CREND_INTERFACE 0, -#endif NULL, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) { return error; } -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND } -#endif } return IVAS_ERR_OK; @@ -1185,21 +1158,15 @@ static void clearInputIsm( initRendInputBase( &inputIsm->base, IVAS_REND_AUDIO_CONFIG_UNKNOWN, 0, rendCtx ); /* Free input's internal handles */ -#ifdef FIX_197_CREND_INTERFACE if ( inputIsm->crendWrapper != NULL ) -#else - if ( inputIsm->crendWrapper.hCrend != NULL ) -#endif { ivas_rend_closeCrend( &inputIsm->crendWrapper ); } -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND if ( inputIsm->reverb != NULL ) { ivas_reverb_close( &inputIsm->reverb ); } -#endif if ( inputIsm->tdRendWrapper.hBinRendererTd != NULL ) { @@ -1274,13 +1241,8 @@ static ivas_error initMcPanGainsWithConversionMapping( AUDIO_CONFIG ivasConfigIn, ivasConfigOut; int16_t i; -#ifdef FIX_197_CREND_INTERFACE ivasConfigIn = getIvasAudioConfigFromRendAudioConfig( inputMc->base.inConfig ); ivasConfigOut = getIvasAudioConfigFromRendAudioConfig( outConfig ); -#else - ivasConfigIn = rendAudioConfigToIvasAudioConfig( inputMc->base.inConfig ); - ivasConfigOut = rendAudioConfigToIvasAudioConfig( outConfig ); -#endif /* Find conversion mapping for current I/O config pair. * Stay with default panning matrix if conversion_matrix is NULL */ @@ -1843,21 +1805,15 @@ static ivas_error initMcBinauralRendering( inputMc->tdRendWrapper.hHrtfTD = NULL; } -#ifdef FIX_197_CREND_INTERFACE if ( inputMc->crendWrapper != NULL ) -#else - if ( inputMc->crendWrapper.hCrend != NULL ) -#endif { ivas_rend_closeCrend( &inputMc->crendWrapper ); } -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND if ( inputMc->reverb != NULL ) { ivas_reverb_close( &inputMc->reverb ); } -#endif if ( inputMc->efapInWrapper.hEfap != NULL ) { @@ -1884,12 +1840,15 @@ static ivas_error initMcBinauralRendering( // if ( initTDRend ) { +#ifdef TD5 + if ( ( error = ivas_td_binaural_open_ext( &inputMc->tdRendWrapper, inConfig, hRendCfg, &inputMc->customLsInput, outSampleRate ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_td_binaural_open_ext( &inputMc->tdRendWrapper, inConfig, &inputMc->customLsInput, outSampleRate ) ) != IVAS_ERR_OK ) +#endif { return error; } -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND if ( hRendCfg != NULL && hRendCfg->roomAcoustics.use_brir == 0 && hRendCfg->roomAcoustics.late_reverb_on ) { if ( ( error = ivas_reverb_open( &( inputMc->reverb ), getIvasAudioConfigFromRendAudioConfig( outConfig ), NULL, hRendCfg, outSampleRate ) ) != IVAS_ERR_OK ) @@ -1897,21 +1856,13 @@ static ivas_error initMcBinauralRendering( return error; } } -#endif } { if ( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, -#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, -#endif NULL, outSampleRate ) ) != IVAS_ERR_OK ) { return error; @@ -2003,25 +1954,17 @@ static ivas_error setRendInputActiveMc( rendCtx = inputMc->base.ctx; outConfig = *rendCtx.pOutConfig; -#ifdef FIX_372_LIB_REND_VALIDATE_IO if ( !isIoConfigPairSupported( inConfig, outConfig ) ) { return IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED; } -#endif initRendInputBase( &inputMc->base, inConfig, id, rendCtx ); setZeroPanMatrix( inputMc->panGains ); inputMc->customLsInput = defaultCustomLs(); inputMc->tdRendWrapper = defaultTdRendWrapper(); -#ifdef FIX_197_CREND_INTERFACE inputMc->crendWrapper = NULL; -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND inputMc->reverb = NULL; -#endif -#else - inputMc->crendWrapper = defaultCrendWrapper(); -#endif initRotGains( inputMc->rot_gains_prev ); inputMc->lfeRouting = defaultLfeRouting( inConfig, inputMc->customLsInput, outConfig, *inputMc->base.ctx.pCustomLsOut ); @@ -2056,21 +1999,15 @@ static void clearInputMc( efap_free_data( &inputMc->efapInWrapper.hEfap ); } -#ifdef FIX_197_CREND_INTERFACE if ( inputMc->crendWrapper != NULL ) -#else - if ( inputMc->crendWrapper.hCrend != NULL ) -#endif { ivas_rend_closeCrend( &inputMc->crendWrapper ); } -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND if ( inputMc->reverb != NULL ) { ivas_reverb_close( &inputMc->reverb ); } -#endif if ( inputMc->tdRendWrapper.hBinRendererTd != NULL ) { @@ -2108,11 +2045,7 @@ static ivas_error initSbaPanGainsForMcOut( case IVAS_REND_AUDIO_CONFIG_MONO: hOutSetup.ls_azimuth = ls_azimuth_CICP1; hOutSetup.ls_elevation = ls_elevation_CICP1; -#ifdef FIX_197_CREND_INTERFACE ivas_output_init( &hOutSetup, getIvasAudioConfigFromRendAudioConfig( outConfig ) ); -#else - ivas_output_init( &hOutSetup, rendAudioConfigToIvasAudioConfig( outConfig ) ); -#endif break; case IVAS_REND_AUDIO_CONFIG_STEREO: case IVAS_REND_AUDIO_CONFIG_5_1: @@ -2120,11 +2053,7 @@ static ivas_error initSbaPanGainsForMcOut( case IVAS_REND_AUDIO_CONFIG_5_1_2: case IVAS_REND_AUDIO_CONFIG_5_1_4: case IVAS_REND_AUDIO_CONFIG_7_1_4: -#ifdef FIX_197_CREND_INTERFACE ivas_output_init( &hOutSetup, getIvasAudioConfigFromRendAudioConfig( outConfig ) ); -#else - ivas_output_init( &hOutSetup, rendAudioConfigToIvasAudioConfig( outConfig ) ); -#endif break; case IVAS_REND_AUDIO_CONFIG_LS_CUSTOM: ivas_ls_custom_setup( &hOutSetup, outSetupCustom ); @@ -2205,17 +2134,10 @@ static ivas_error updateSbaPanGains( { case IVAS_REND_AUDIO_CONFIG_BINAURAL: error = ivas_rend_openCrend( &inputSba->crendWrapper, -#ifdef FIX_197_CREND_INTERFACE getIvasAudioConfigFromRendAudioConfig( inConfig ), getIvasAudioConfigFromRendAudioConfig( outConfig ), -#else - rendAudioConfigToIvasAudioConfig( inConfig ), - rendAudioConfigToIvasAudioConfig( outConfig ), -#endif hRendCfg, -#ifdef FIX_197_CREND_INTERFACE 0, -#endif NULL, *rendCtx.pOutSampleRate ); break; @@ -2227,15 +2149,9 @@ static ivas_error updateSbaPanGains( error = ivas_rend_openCrend( &inputSba->crendWrapper, AUDIO_CONFIG_7_1_4, -#ifdef FIX_197_CREND_INTERFACE getIvasAudioConfigFromRendAudioConfig( outConfig ), -#else - rendAudioConfigToIvasAudioConfig( outConfig ), -#endif hRendCfg, -#ifdef FIX_197_CREND_INTERFACE 0, -#endif NULL, *rendCtx.pOutSampleRate ); break; @@ -2270,20 +2186,14 @@ static ivas_error setRendInputActiveSba( rendCtx = inputSba->base.ctx; outConfig = *rendCtx.pOutConfig; -#ifdef FIX_372_LIB_REND_VALIDATE_IO if ( !isIoConfigPairSupported( inConfig, outConfig ) ) { return IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED; } -#endif initRendInputBase( &inputSba->base, inConfig, id, rendCtx ); setZeroPanMatrix( inputSba->hoaDecMtx ); -#ifdef FIX_197_CREND_INTERFACE inputSba->crendWrapper = NULL; -#else - inputSba->crendWrapper = defaultCrendWrapper(); -#endif initRotGains( inputSba->rot_gains_prev ); if ( ( error = updateSbaPanGains( inputSba, outConfig, hRendCfg ) ) != IVAS_ERR_OK ) @@ -2304,11 +2214,7 @@ static void clearInputSba( initRendInputBase( &inputSba->base, IVAS_REND_AUDIO_CONFIG_UNKNOWN, 0, rendCtx ); /* Free input's internal handles */ -#ifdef FIX_197_CREND_INTERFACE if ( inputSba->crendWrapper != NULL ) -#else - if ( inputSba->crendWrapper.hCrend != NULL ) -#endif { ivas_rend_closeCrend( &inputSba->crendWrapper ); } @@ -2328,11 +2234,7 @@ static ivas_error initMasaDummyDecForMcOut( DecoderDummy *decDummy; decDummy = inputMasa->decDummy; -#ifdef FIX_197_CREND_INTERFACE output_config = getIvasAudioConfigFromRendAudioConfig( outConfig ); -#else - output_config = rendAudioConfigToIvasAudioConfig( outConfig ); -#endif decDummy->hDecoderConfig->output_config = output_config; decDummy->hDecoderConfig->ivas_total_brate = IVAS_512k; /* Todo Nokia: This is preventing initialization of 2TC as 1TC, should be fixed properly in ivas_dirac_dec_config() */ @@ -2369,9 +2271,6 @@ static ivas_error initMasaDummyDecForMcOut( { return error; } -#ifndef FIX_107_5MS_SUBFRAME_RENDERING - decDummy->hDiracDecBin->useSubframeMode = 0; /* Todo Nokia: This will disappear in later work but needs to be this now. */ -#endif } numCldfbAnalyses = decDummy->nchan_transport; @@ -2417,11 +2316,7 @@ static ivas_error initMasaDummyDecForSbaOut( decDummy = inputMasa->decDummy; -#ifdef FIX_197_CREND_INTERFACE output_config = getIvasAudioConfigFromRendAudioConfig( outConfig ); -#else - output_config = rendAudioConfigToIvasAudioConfig( outConfig ); -#endif decDummy->hDecoderConfig->output_config = output_config; decDummy->hDecoderConfig->ivas_total_brate = IVAS_512k; /* Todo Nokia: This is preventing initialization of 2TC as 1TC, should be fixed properly in ivas_dirac_dec_config() */ @@ -2488,11 +2383,7 @@ static ivas_error initMasaDummyDecForBinauralOut( decDummy = inputMasa->decDummy; -#ifdef FIX_197_CREND_INTERFACE output_config = getIvasAudioConfigFromRendAudioConfig( outConfig ); -#else - output_config = rendAudioConfigToIvasAudioConfig( outConfig ); -#endif decDummy->hDecoderConfig->output_config = output_config; output_config = decDummy->hDecoderConfig->output_config; @@ -2512,11 +2403,6 @@ static ivas_error initMasaDummyDecForBinauralOut( } decDummy->ivas_format = MASA_FORMAT; decDummy->transport_config = AUDIO_CONFIG_INVALID; -#ifndef REMOVE_FORCE_SUBFRAME_BIN -#ifdef DEBUGGING - decDummy->hDecoderConfig->forceSubframeBinauralization = 0; -#endif -#endif if ( ( error = ivas_dirac_dec_open( decDummy ) ) != IVAS_ERR_OK ) { @@ -2533,9 +2419,6 @@ static ivas_error initMasaDummyDecForBinauralOut( return error; } -#ifndef FIX_107_5MS_SUBFRAME_RENDERING - decDummy->hDiracDecBin->useSubframeMode = 0; /* Todo Nokia: This will disappear in later work but needs to be this now. */ -#endif for ( i = 0; i < BINAURAL_CHANNELS; i++ ) { @@ -2606,12 +2489,7 @@ static DecoderDummy *initDecoderDummy( decDummy->hBinRenderer = NULL; decDummy->hEFAPdata = NULL; -#ifdef FIX_197_CREND_INTERFACE decDummy->hCrendWrapper = NULL; -#else - decDummy->hHrtf = NULL; - decDummy->hCrend = NULL; -#endif decDummy->hHrtfTD = NULL; decDummy->hSpar = NULL; decDummy->hoa_dec_mtx = NULL; @@ -2619,11 +2497,7 @@ static DecoderDummy *initDecoderDummy( decDummy->hMasa = NULL; decDummy->hDiracDecBin = NULL; decDummy->hQMetaData = NULL; -#ifdef FIX_197_CREND_INTERFACE decDummy->hDecoderConfig->output_config = getIvasAudioConfigFromRendAudioConfig( outConfig ); -#else - decDummy->hDecoderConfig->output_config = rendAudioConfigToIvasAudioConfig( outConfig ); -#endif decDummy->nchan_transport = numTransChannels; if ( outConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM || outConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM ) @@ -2683,12 +2557,10 @@ static ivas_error setRendInputActiveMasa( outConfig = *rendCtx.pOutConfig; (void) hRendCfg; /* Suppress warning */ -#ifdef FIX_372_LIB_REND_VALIDATE_IO if ( !isIoConfigPairSupported( inConfig, outConfig ) ) { return IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED; } -#endif initRendInputBase( &inputMasa->base, inConfig, id, rendCtx ); @@ -2873,14 +2745,8 @@ ivas_error IVAS_REND_Open( for ( i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i ) { initRendInputBase( &hIvasRend->inputsIsm[i].base, IVAS_REND_AUDIO_CONFIG_UNKNOWN, 0, getRendCtx( hIvasRend ) ); -#ifdef FIX_197_CREND_INTERFACE hIvasRend->inputsIsm[i].crendWrapper = NULL; -#else - hIvasRend->inputsIsm[i].crendWrapper.hCrend = NULL; -#endif -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND hIvasRend->inputsIsm[i].reverb = NULL; -#endif hIvasRend->inputsIsm[i].tdRendWrapper.hBinRendererTd = NULL; } @@ -2888,25 +2754,15 @@ ivas_error IVAS_REND_Open( { initRendInputBase( &hIvasRend->inputsMc[i].base, IVAS_REND_AUDIO_CONFIG_UNKNOWN, 0, getRendCtx( hIvasRend ) ); hIvasRend->inputsMc[i].efapInWrapper.hEfap = NULL; -#ifdef FIX_197_CREND_INTERFACE hIvasRend->inputsMc[i].crendWrapper = NULL; -#else - hIvasRend->inputsMc[i].crendWrapper.hCrend = NULL; -#endif -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND hIvasRend->inputsMc[i].reverb = NULL; -#endif hIvasRend->inputsMc[i].tdRendWrapper.hBinRendererTd = NULL; } for ( i = 0; i < RENDERER_MAX_SBA_INPUTS; ++i ) { initRendInputBase( &hIvasRend->inputsSba[i].base, IVAS_REND_AUDIO_CONFIG_UNKNOWN, 0, getRendCtx( hIvasRend ) ); -#ifdef FIX_197_CREND_INTERFACE hIvasRend->inputsSba[i].crendWrapper = NULL; -#else - hIvasRend->inputsSba[i].crendWrapper.hCrend = NULL; -#endif } for ( i = 0; i < RENDERER_MAX_MASA_INPUTS; ++i ) @@ -3687,13 +3543,8 @@ ivas_error IVAS_REND_GetDelay( { if ( hIvasRend->inputsIsm[i].base.inConfig != IVAS_REND_AUDIO_CONFIG_UNKNOWN ) { -#ifdef FIX_197_CREND_INTERFACE latency_ns = max( ( hIvasRend->inputsIsm[i].crendWrapper != NULL ) ? hIvasRend->inputsIsm[i].crendWrapper->binaural_latency_ns : 0, hIvasRend->inputsIsm[i].tdRendWrapper.binaural_latency_ns ); -#else - latency_ns = max( hIvasRend->inputsIsm[i].crendWrapper.binaural_latency_ns, - hIvasRend->inputsIsm[i].tdRendWrapper.binaural_latency_ns ); -#endif max_latency_ns = max( max_latency_ns, latency_ns ); } } @@ -3702,13 +3553,8 @@ ivas_error IVAS_REND_GetDelay( { if ( hIvasRend->inputsMc[i].base.inConfig != IVAS_REND_AUDIO_CONFIG_UNKNOWN ) { -#ifdef FIX_197_CREND_INTERFACE latency_ns = max( ( hIvasRend->inputsMc[i].crendWrapper != NULL ) ? hIvasRend->inputsMc[i].crendWrapper->binaural_latency_ns : 0, hIvasRend->inputsMc[i].tdRendWrapper.binaural_latency_ns ); -#else - latency_ns = max( hIvasRend->inputsMc[i].crendWrapper.binaural_latency_ns, - hIvasRend->inputsMc[i].tdRendWrapper.binaural_latency_ns ); -#endif max_latency_ns = max( max_latency_ns, latency_ns ); } } @@ -3717,11 +3563,7 @@ ivas_error IVAS_REND_GetDelay( { if ( hIvasRend->inputsSba[i].base.inConfig != IVAS_REND_AUDIO_CONFIG_UNKNOWN ) { -#ifdef FIX_197_CREND_INTERFACE latency_ns = ( hIvasRend->inputsSba[i].crendWrapper != NULL ) ? hIvasRend->inputsSba[i].crendWrapper->binaural_latency_ns : 0; -#else - latency_ns = hIvasRend->inputsSba[i].crendWrapper.binaural_latency_ns; -#endif max_latency_ns = max( max_latency_ns, latency_ns ); } } @@ -3918,7 +3760,6 @@ ivas_error IVAS_REND_InitConfig( hIvasRend->rendererConfigEnabled = 0; } -#ifdef FIX_197_CREND_INTERFACE if ( rendererConfigEnabled ) { if ( ( error = ivas_render_config_open( &( hIvasRend->hRendererConfig ) ) ) != IVAS_ERR_OK ) @@ -3935,17 +3776,6 @@ ivas_error IVAS_REND_InitConfig( { hIvasRend->hRendererConfig = NULL; } -#else - if ( ( error = ivas_render_config_open( &( hIvasRend->hRendererConfig ) ) ) != IVAS_ERR_OK ) - { - return error; - } - - if ( ivas_render_config_init_from_rom( &hIvasRend->hRendererConfig, hIvasRend->rendererConfigEnabled ) != IVAS_ERR_OK ) - { - return IVAS_ERR_INTERNAL_FATAL; - } -#endif return IVAS_ERR_OK; } @@ -4018,6 +3848,9 @@ int16_t IVAS_REND_FeedRenderConfig( } hRenderConfig = hIvasRend->hRendererConfig; +#ifdef TD5 + mvr2r( renderConfig.directivity, hRenderConfig->directivity, 3 ); +#endif #ifdef DEBUGGING hRenderConfig->renderer_type_override = RENDER_TYPE_OVERRIDE_NONE; if ( renderConfig.renderer_type_override == IVAS_RENDER_TYPE_OVERRIDE_FASTCONV ) @@ -4050,8 +3883,13 @@ int16_t IVAS_REND_FeedRenderConfig( *-------------------------------------------------------------------*/ ivas_error IVAS_REND_SetHeadRotation( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ +#ifdef TD5 + const IVAS_QUATERNION headRot[RENDERER_HEAD_POSITIONS_PER_FRAME], /* i : head orientations for next rendering call */ + const IVAS_POSITION Pos[RENDERER_HEAD_POSITIONS_PER_FRAME] /* i : listener positions for next rendering call */ +#else const IVAS_QUATERNION headRot[RENDERER_HEAD_POSITIONS_PER_FRAME] /* i : head positions for next rendering call */ +#endif ) { int16_t i; @@ -4097,6 +3935,9 @@ ivas_error IVAS_REND_SetHeadRotation( ivas_orient_trk_Process( hIvasRend->headRotData.hOrientationTracker, rotQuat, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES, &hIvasRend->headRotData.headPositions[i] ); #else hIvasRend->headRotData.headPositions[i] = headRot[i]; +#endif +#ifdef TD5 + hIvasRend->headRotData.Pos[i] = Pos[i]; #endif } } @@ -4559,9 +4400,7 @@ static ivas_error renderIsmToBinaural( NULL, ismInput->base.ctx.pHeadRotData, &ismInput->currentPos, -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND ismInput->reverb, -#endif outAudio.config.numSamplesPerChannel, tmpTDRendBuffer ) ) != IVAS_ERR_OK ) { @@ -4584,11 +4423,7 @@ static ivas_error renderIsmToBinauralRoom( int16_t subframe_idx, subframe_len; int16_t tmp; rotation_matrix Rmat; -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND float tmpRendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; -#else - float tmpCrendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; -#endif IVAS_QUATERNION quat; ivas_error error; pan_vector currentPanGains; @@ -4602,7 +4437,6 @@ static ivas_error renderIsmToBinauralRoom( headRotData = ismInput->base.ctx.pHeadRotData; rotatedPos = defaultObjectPosition(); -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND if ( ismInput->reverb != NULL && ismInput->reverb->pConfig.roomAcoustics.use_brir == 0 && ismInput->reverb->pConfig.roomAcoustics.late_reverb_on == 1 && headRotData->headRotEnabled ) { copyBufferTo2dArray( ismInput->base.inputBuffer, tmpRendBuffer ); @@ -4613,21 +4447,16 @@ static ivas_error renderIsmToBinauralRoom( NULL, ismInput->base.ctx.pHeadRotData, &ismInput->currentPos, -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND ismInput->reverb, -#endif outAudio.config.numSamplesPerChannel, tmpRendBuffer ) ) != IVAS_ERR_OK ) { return error; } -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND accumulate2dArrayToBuffer( tmpRendBuffer, &outAudio ); -#endif } else { -#endif if ( headRotData->headRotEnabled ) { @@ -4699,43 +4528,23 @@ static ivas_error renderIsmToBinauralRoom( renderBufferChannelLerp( ismInput->base.inputBuffer, 0, currentPanGains, previousPanGains, tmpMcBuffer ); -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND copyBufferTo2dArray( tmpMcBuffer, tmpRendBuffer ); -#else - copyBufferTo2dArray( tmpMcBuffer, tmpCrendBuffer ); -#endif if ( ( error = ivas_rend_crendProcess( -#ifdef FIX_197_CREND_INTERFACE ismInput->crendWrapper, -#else - &ismInput->crendWrapper, -#endif AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_BINAURAL_ROOM, -#ifdef FIX_197_CREND_INTERFACE NULL, NULL, NULL, NULL, -#endif -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND tmpRendBuffer, -#else - tmpCrendBuffer, -#endif *ismInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) { return error; } -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND accumulate2dArrayToBuffer( tmpRendBuffer, &outAudio ); -#else - accumulate2dArrayToBuffer( tmpCrendBuffer, &outAudio ); -#endif free( tmpMcBuffer.data ); -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND } -#endif pop_wmops(); return IVAS_ERR_OK; @@ -5002,9 +4811,7 @@ static ivas_error renderMcToBinaural( &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, NULL, -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND mcInput->reverb, -#endif mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer ) ) != IVAS_ERR_OK ) { @@ -5041,14 +4848,8 @@ static ivas_error renderMcToBinaural( /* call CREND */ if ( ( error = ivas_rend_crendProcess( -#ifdef FIX_197_CREND_INTERFACE mcInput->crendWrapper, getIvasAudioConfigFromRendAudioConfig( mcInput->base.inConfig ), getIvasAudioConfigFromRendAudioConfig( outConfig ), NULL, NULL, NULL, NULL, -#else - &mcInput->crendWrapper, - rendAudioConfigToIvasAudioConfig( mcInput->base.inConfig ), - rendAudioConfigToIvasAudioConfig( outConfig ), -#endif tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) { return error; @@ -5073,19 +4874,14 @@ static ivas_error renderMcToBinauralRoom( const IVAS_REND_AudioConfig outConfig, IVAS_REND_AudioBuffer outAudio ) { -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND int8_t headRotEnabled; float tmpRendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; IVAS_REND_AudioConfig inConfig; -#else - float tmpCrendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; -#endif ivas_error error; IVAS_REND_AudioBuffer tmpRotBuffer; push_wmops( "renderMcToBinauralRoom" ); -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND headRotEnabled = mcInput->base.ctx.pHeadRotData->headRotEnabled; inConfig = mcInput->base.inConfig; @@ -5110,10 +4906,6 @@ static ivas_error renderMcToBinauralRoom( /* apply rotation */ if ( headRotEnabled ) -#else - /* apply rotation */ - if ( mcInput->base.ctx.pHeadRotData->headRotEnabled ) -#endif { tmpRotBuffer = mcInput->base.inputBuffer; tmpRotBuffer.data = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( float ) ); @@ -5130,48 +4922,26 @@ static ivas_error renderMcToBinauralRoom( return error; } -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND copyBufferTo2dArray( tmpRotBuffer, tmpRendBuffer ); -#else - copyBufferTo2dArray( tmpRotBuffer, tmpCrendBuffer ); -#endif free( tmpRotBuffer.data ); } else { -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND copyBufferTo2dArray( mcInput->base.inputBuffer, tmpRendBuffer ); -#else - copyBufferTo2dArray( mcInput->base.inputBuffer, tmpCrendBuffer ); -#endif } /* call CREND */ if ( ( error = ivas_rend_crendProcess( -#ifdef FIX_197_CREND_INTERFACE mcInput->crendWrapper, getIvasAudioConfigFromRendAudioConfig( mcInput->base.inConfig ), getIvasAudioConfigFromRendAudioConfig( outConfig ), NULL, NULL, NULL, NULL, -#else - &mcInput->crendWrapper, - rendAudioConfigToIvasAudioConfig( mcInput->base.inConfig ), - rendAudioConfigToIvasAudioConfig( outConfig ), -#endif -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND tmpRendBuffer, -#else - tmpCrendBuffer, -#endif *mcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) { return error; } -#ifdef FIX_330_ENABLE_TD_RENDERER_REVERB_REND } accumulate2dArrayToBuffer( tmpRendBuffer, &outAudio ); -#else - accumulate2dArrayToBuffer( tmpCrendBuffer, &outAudio ); -#endif /* TODO tmu : needs delay compensation */ if ( ( error = renderLfeToBinaural( mcInput, outAudio ) ) != IVAS_ERR_OK ) @@ -5238,13 +5008,7 @@ static ivas_error renderMcCustomLsToBinauralRoom( /* call CREND */ if ( ( error = ivas_rend_crendProcess( -#ifdef FIX_197_CREND_INTERFACE mcInput->crendWrapper, AUDIO_CONFIG_7_1_4, getIvasAudioConfigFromRendAudioConfig( outConfig ), NULL, NULL, NULL, NULL, -#else - &mcInput->crendWrapper, - AUDIO_CONFIG_7_1_4, - rendAudioConfigToIvasAudioConfig( outConfig ), -#endif tmpCrendBuffer, *mcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) { return error; @@ -5474,13 +5238,7 @@ static ivas_error renderSbaToBinaural( /* call CREND */ if ( ( error = ivas_rend_crendProcess( -#ifdef FIX_197_CREND_INTERFACE sbaInput->crendWrapper, getIvasAudioConfigFromRendAudioConfig( sbaInput->base.inConfig ), getIvasAudioConfigFromRendAudioConfig( outConfig ), NULL, NULL, NULL, NULL, -#else - &sbaInput->crendWrapper, - rendAudioConfigToIvasAudioConfig( sbaInput->base.inConfig ), - rendAudioConfigToIvasAudioConfig( outConfig ), -#endif tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) { return error; @@ -5550,14 +5308,8 @@ static ivas_error renderSbaToBinauralRoom( /* call CREND */ if ( ( error = ivas_rend_crendProcess( -#ifdef FIX_197_CREND_INTERFACE sbaInput->crendWrapper, AUDIO_CONFIG_7_1_4, getIvasAudioConfigFromRendAudioConfig( outConfig ), NULL, NULL, NULL, NULL, -#else - &sbaInput->crendWrapper, - AUDIO_CONFIG_7_1_4, - rendAudioConfigToIvasAudioConfig( outConfig ), -#endif tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 38166f3b82c45c388013c3534ac6eb0cc1df45d0..b313bea5c12ff1fdec424b910158322f863c2f9c 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -244,7 +244,12 @@ int16_t IVAS_REND_FeedRenderConfig( ivas_error IVAS_REND_SetHeadRotation( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ +#ifdef TD5 + const IVAS_QUATERNION headRot[RENDERER_HEAD_POSITIONS_PER_FRAME], /* i : head orientations for next rendering call */ + const IVAS_POSITION Pos[RENDERER_HEAD_POSITIONS_PER_FRAME] /* i : listener positions for next rendering call */ +#else const IVAS_QUATERNION headRot[RENDERER_HEAD_POSITIONS_PER_FRAME] /* i : head positions for next rendering call */ +#endif ); #ifdef FIX_I109_ORIENTATION_TRACKING diff --git a/lib_util/audio_file_reader.c b/lib_util/audio_file_reader.c index c7feefd7b7d58ae04de932265d9d1e6c18104094..4f6bd0c34d13fd62439775d31933f9d67a4197f4 100644 --- a/lib_util/audio_file_reader.c +++ b/lib_util/audio_file_reader.c @@ -40,9 +40,7 @@ struct AudioFileReader { FILE *rawFile; WAVEFILEIN *wavFile; -#ifdef FIX_94_VERIFY_WAV_NUM_CHANNELS uint32_t samplingRate; -#endif int16_t numChannels; }; @@ -57,26 +55,12 @@ static int8_t AudioFileReader_open_raw( static int8_t AudioFileReader_open_wav( AudioFileReader *self, - const char *fileName -#ifndef FIX_94_VERIFY_WAV_NUM_CHANNELS - , - int32_t *sampleRate -#endif -) + const char *fileName ) { -#ifdef FIX_94_VERIFY_WAV_NUM_CHANNELS uint32_t samplesInFile; -#else - uint32_t sampleRate_, samplesInFile; -#endif int16_t bps; -#ifdef FIX_94_VERIFY_WAV_NUM_CHANNELS self->wavFile = OpenWav( fileName, &self->samplingRate, &self->numChannels, &samplesInFile, &bps ); -#else - self->wavFile = OpenWav( fileName, &sampleRate_, &self->numChannels, &samplesInFile, &bps ); - *sampleRate = sampleRate_; -#endif if ( !self->wavFile ) { @@ -92,10 +76,6 @@ static int8_t AudioFileReader_open_wav( ivas_error AudioFileReader_open( AudioFileReader **audioReader, /* o : AudioFileReader handle */ const char *fileName /* i : path to wav/raw pcm file */ -#ifndef FIX_94_VERIFY_WAV_NUM_CHANNELS - , - int32_t *sampleRate /* o : sample rate of wav file, unused with pcm */ -#endif ) { AudioFileReader *self; @@ -118,19 +98,12 @@ ivas_error AudioFileReader_open( return IVAS_ERR_FAILED_FILE_OPEN; } self = calloc( sizeof( AudioFileReader ), 1 ); -#ifdef FIX_94_VERIFY_WAV_NUM_CHANNELS self->samplingRate = 0; -#endif self->numChannels = 0; if ( fileNameLen > wavSuffixLen && strncmp( fileName + fileNameLen - wavSuffixLen, wavSuffix, wavSuffixLen ) == 0 ) { - retCode = AudioFileReader_open_wav( self, fileName -#ifndef FIX_94_VERIFY_WAV_NUM_CHANNELS - , - sampleRate -#endif - ); + retCode = AudioFileReader_open_wav( self, fileName ); } else { @@ -206,7 +179,6 @@ ivas_error AudioFileReader_read( return error; } -#ifdef FIX_94_VERIFY_WAV_NUM_CHANNELS ivas_error AudioFileReader_getSamplingRate( AudioFileReader *self, int32_t *samplingRate ) @@ -257,17 +229,3 @@ ivas_error AudioFileReader_getNumChannels( return IVAS_ERR_OK; } -#else -/*! r: number of channels of the opened file */ -int16_t AudioFileReader_getNumChannels( - AudioFileReader *self /* i/o: AudioFileReader handle */ -) -{ - if ( self != NULL ) - { - return self->numChannels; - } - - return 0; -} -#endif diff --git a/lib_util/audio_file_reader.h b/lib_util/audio_file_reader.h index a944c85dc1a44279efa3596c3219943c70ae78a6..0fd4da5ac76c25285d3b49d67166ce651a96eeb8 100644 --- a/lib_util/audio_file_reader.h +++ b/lib_util/audio_file_reader.h @@ -43,9 +43,6 @@ typedef struct AudioFileReader AudioFileReader; ivas_error AudioFileReader_open( AudioFileReader **audioReader, /* o : AudioFileReader handle */ const char *fileName /* i : path to wav/raw pcm file */ -#ifndef FIX_94_VERIFY_WAV_NUM_CHANNELS - ,int32_t *sampleRate /* o : sample rate of wav file, unused with pcm */ -#endif ); ivas_error AudioFileReader_read( @@ -55,7 +52,6 @@ ivas_error AudioFileReader_read( int16_t *numSamplesRead /* i : number of samples actualy read */ ); -#ifdef FIX_94_VERIFY_WAV_NUM_CHANNELS /*! r: ivas error - in particular, IVAS_ERR_SAMPLING_RATE_UNKNOWN if the opened file has no sampling rate metadata */ ivas_error AudioFileReader_getSamplingRate( AudioFileReader *self, /* i/o: AudioFileReader handle */ @@ -67,12 +63,6 @@ ivas_error AudioFileReader_getNumChannels( AudioFileReader *self, /* i/o: AudioFileReader handle */ int16_t * numChannels /* o : number fo channels in opened audio file */ ); -#else -/*! r: number of channels of the opened file */ -int16_t AudioFileReader_getNumChannels( - AudioFileReader *self /* i/o: AudioFileReader handle */ -); -#endif void AudioFileReader_close( AudioFileReader **selfPtr /* i/o: pointer to AudioFileReader handle */ diff --git a/lib_util/head_rotation_file_reader.c b/lib_util/head_rotation_file_reader.c index cb235de8213a1e6d361a377a4422e54081a69cec..a7ef6b04ea47102de571a0549fd1eded3d0ca009 100644 --- a/lib_util/head_rotation_file_reader.c +++ b/lib_util/head_rotation_file_reader.c @@ -94,18 +94,40 @@ ivas_error HeadRotationFileReader_open( #ifdef FIX_I109_ORIENTATION_TRACKING ivas_error HeadRotationFileReading( HeadRotFileReader *headRotReader, /* i/o: HeadRotFileReader handle */ - IVAS_QUATERNION *pQuaternion /* o : head-tracking data */ +#ifdef TD5 + IVAS_QUATERNION *pQuaternion, /* o : head-tracking data */ + IVAS_POSITION *pPos /* o : listener position */ +#else + IVAS_QUATERNION *pQuaternion /* o : head-tracking data */ +#endif ) { float w, x, y, z; +#ifdef TD5 + float posx, posy, posz; + int32_t read_values; + + posx = 0.0f; + posy = 0.0f; + posz = 0.0f; +#endif +#ifdef TD5 + read_values = fscanf( headRotReader->trajFile, "%f,%f,%f,%f,%f,%f,%f", &w, &x, &y, &z, &posx, &posy, &posz ); + if ( ( read_values != 4 ) && ( read_values != 7 ) ) /* Allow either orientation (4) or orientation+position (4+3) */ +#else if ( 4 != fscanf( headRotReader->trajFile, "%f,%f,%f,%f", &w, &x, &y, &z ) ) +#endif { if ( feof( headRotReader->trajFile ) ) { rewind( headRotReader->trajFile ); headRotReader->fileRewind = true; +#ifdef TD5 + return HeadRotationFileReading( headRotReader, pQuaternion, pPos ); +#else return HeadRotationFileReading( headRotReader, pQuaternion ); +#endif } return IVAS_ERR_FAILED_FILE_PARSE; } @@ -116,6 +138,14 @@ ivas_error HeadRotationFileReading( pQuaternion->x = x; pQuaternion->y = y; pQuaternion->z = z; +#ifdef TD5 + if ( pPos != NULL ) + { + pPos->x = posx; + pPos->y = posy; + pPos->z = posz; + } +#endif return IVAS_ERR_OK; } @@ -123,33 +153,58 @@ ivas_error HeadRotationFileReading( #else ivas_error HeadRotationFileReading( HeadRotFileReader *headRotReader, /* i/o: HeadRotFileReader handle */ - IVAS_QUATERNION *Quaternions, /* o : head-tracking data */ - const int32_t frame_dec /* i : decoded frame number */ + IVAS_QUATERNION *Quaternions, /* o : head-tracking data, listener orientation */ +#ifdef TD5 + IVAS_POSITION *Pos /* o : listener position */ +#else + const int32_t frame_dec /* i : decoded frame number */ +#endif ) { uint16_t i; float w, x, y, z; +#ifdef TD5 + float posx, posy, posz; + int32_t read_values; + + posx = 0.0f; + posy = 0.0f; + posz = 0.0f; +#endif for ( i = 0; i < IVAS_MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { +#ifdef TD5 + read_values = fscanf( headRotReader->trajFile, "%f,%f,%f,%f,%f,%f,%f", &w, &x, &y, &z, &posx, &posy, &posz ); + if ( ( read_values != 4 ) && ( read_values != 7 ) ) /* Allow either orientation (4) or orientation+position (4+3) */ +#else if ( 4 != fscanf( headRotReader->trajFile, "%f,%f,%f,%f", &w, &x, &y, &z ) ) +#endif { if ( feof( headRotReader->trajFile ) ) { rewind( headRotReader->trajFile ); headRotReader->fileRewind = true; +#ifdef TD5 + return HeadRotationFileReading( headRotReader, Quaternions, Pos ); +#else return HeadRotationFileReading( headRotReader, Quaternions, frame_dec ); +#endif } return IVAS_ERR_FAILED_FILE_PARSE; } - ( headRotReader->frameCounter )++; Quaternions[i].w = w; Quaternions[i].x = x; Quaternions[i].y = y; Quaternions[i].z = z; +#ifdef TD5 + Pos[i].x = posx; + Pos[i].y = posy; + Pos[i].z = posz; +#endif } return IVAS_ERR_OK; diff --git a/lib_util/head_rotation_file_reader.h b/lib_util/head_rotation_file_reader.h index c74124812e845b0232e15570bf109cc2da60fd22..2a995f15f617ef248158d1c41b4184195462265c 100644 --- a/lib_util/head_rotation_file_reader.h +++ b/lib_util/head_rotation_file_reader.h @@ -60,13 +60,22 @@ ivas_error HeadRotationFileReader_open( #ifdef FIX_I109_ORIENTATION_TRACKING ivas_error HeadRotationFileReading( HeadRotFileReader *headRotReader, /* i/o: HeadRotFileReader handle */ - IVAS_QUATERNION *pQuaternion /* o : head-tracking data */ +#ifdef TD5 + IVAS_QUATERNION *pQuaternion, /* o : head-tracking data */ + IVAS_POSITION *pPos /* o : listener position */ +#else + IVAS_QUATERNION *pQuaternion /* o : head-tracking data */ +#endif ); #else ivas_error HeadRotationFileReading( HeadRotFileReader *headRotReader, /* i/o: HeadRotFileReader handle */ IVAS_QUATERNION *Quaternions, /* o : head-tracking data */ - const int32_t frame_dec /* i : decoded frame number */ +#ifdef TD5 + IVAS_POSITION *Pos /* o : listener position */ +#else + const int32_t frame_dec /* i : decoded frame number */ +#endif ); #endif diff --git a/lib_util/ism_file_reader.c b/lib_util/ism_file_reader.c index 77912f5c586251110a57d708b529499f483aecd9..b6166af95bd3fab2e471bec982ef9cc02c010d80 100644 --- a/lib_util/ism_file_reader.c +++ b/lib_util/ism_file_reader.c @@ -36,8 +36,13 @@ #include -#define META_LINE_LENGTH 200 /* max number of characters at one line of metadata input/output file */ -#define NUM_ISM_METADATA_PER_LINE 5 /* Number of ISM metadata per line in a metadata file */ +#define META_LINE_LENGTH 200 /* max number of characters at one line of metadata input/output file */ +#ifdef TD5 +#define NUM_ISM_METADATA_PER_LINE 7 /* Number of ISM metadata per line in a metadata file */ +#define NUM_MIN_ISM_METADATA 2 /* Minimum number of metadata parameters (azimuth and elevation) */ +#else +#define NUM_ISM_METADATA_PER_LINE 5 /* Number of ISM metadata per line in a metadata file */ +#endif struct IsmFileReader @@ -95,10 +100,21 @@ ivas_error IsmFileReader_readNextFrame( { char char_buff[META_LINE_LENGTH]; float meta_prm[NUM_ISM_METADATA_PER_LINE]; +#ifdef TD5 + float meta_prm_default[NUM_ISM_METADATA_PER_LINE] = { 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f }; +#endif char *char_ptr; int16_t i; FILE *file; +#ifdef TD5 + /* Set default metadata parameters */ + for ( i = 0; i < NUM_ISM_METADATA_PER_LINE; i++ ) + { + meta_prm[i] = meta_prm_default[i]; + } +#endif + if ( ismMetadata == NULL || self->file == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; @@ -127,24 +143,34 @@ ivas_error IsmFileReader_readNextFrame( meta_prm[i++] = (float) atof( char_ptr ); } - +#ifdef TD5 + /* Check if minimum number of metadata values were read. Additional values are ignored. */ + if ( i < NUM_MIN_ISM_METADATA ) +#else if ( i != NUM_ISM_METADATA_PER_LINE ) +#endif { /* Not enough values provided in one line */ return IVAS_ERR_ISM_FILE_READER_INVALID_METADATA_FORMAT; } +#ifndef TD5 if ( char_ptr != NULL ) { /* Too many values provided in one line */ return IVAS_ERR_ISM_FILE_READER_INVALID_METADATA_FORMAT; } +#endif ismMetadata->azimuth = meta_prm[0]; ismMetadata->elevation = meta_prm[1]; ismMetadata->radius = meta_prm[2]; ismMetadata->spread = meta_prm[3]; ismMetadata->gainFactor = meta_prm[4]; +#ifdef TD5 + ismMetadata->yaw = meta_prm[5]; + ismMetadata->pitch = meta_prm[6]; +#endif /* verify whether the read metadata values are in an expected range */ if ( ismMetadata->azimuth > 180 || ismMetadata->azimuth < -180 ) @@ -171,6 +197,17 @@ ivas_error IsmFileReader_readNextFrame( { return IVAS_ERR_ISM_INVALID_METADATA_VALUE; } +#ifdef TD5 + if ( ismMetadata->yaw > 180 || ismMetadata->yaw < -180 ) + { + return IVAS_ERR_ISM_INVALID_METADATA_VALUE; + } + + if ( ismMetadata->pitch > 90 || ismMetadata->pitch < -90 ) + { + return IVAS_ERR_ISM_INVALID_METADATA_VALUE; + } +#endif return IVAS_ERR_OK; } diff --git a/lib_util/ism_file_writer.c b/lib_util/ism_file_writer.c index c4dffe38b03462337e460558d84449f53977aebc..7c9227a65ce1b56821ff24e9a0cf7f426e02b7a1 100644 --- a/lib_util/ism_file_writer.c +++ b/lib_util/ism_file_writer.c @@ -35,8 +35,10 @@ #include -#define META_LINE_LENGTH 200 /* max number of characters at one line of metadata input/output file */ -#define NUM_ISM_METADATA_PER_LINE 5 /* Number of ISM metadata per line in a metadata file */ +#define META_LINE_LENGTH 200 /* max number of characters at one line of metadata input/output file */ +#ifndef TD5 +#define NUM_ISM_METADATA_PER_LINE 5 /* Number of ISM metadata per line in a metadata file */ +#endif struct IsmFileWriter @@ -115,7 +117,18 @@ ivas_error IsmFileWriter_writeFrame( file = ismWriter->file; /* IVAS_fmToDo: work in progress; currently position_azimuth, position_elevation, position_radius, spread, gain_factor */ +#ifdef FIX_293_EXT_RENDERER_CLI +#ifdef TD5 + sprintf( char_buff, "%+07.2f,%+06.2f,%05.2f,%06.2f,%04.2f,%+07.2f,%+06.2f\n", ismMetadata.azimuth, ismMetadata.elevation, ismMetadata.radius, ismMetadata.spread, ismMetadata.gainFactor, ismMetadata.yaw, ismMetadata.pitch ); +#else + sprintf( char_buff, "%+07.2f,%+06.2f,%05.2f,%06.2f,%04.2f\n", ismMetadata.azimuth, ismMetadata.elevation, ismMetadata.radius, ismMetadata.spread, ismMetadata.gainFactor ); +#endif +#endif +#ifdef TD5 + snprintf( char_buff, sizeof( char_buff ), "%+07.2f,%+06.2f,%05.2f,%06.2f,%04.2f,%+07.2f,%+06.2f\n", ismMetadata.azimuth, ismMetadata.elevation, ismMetadata.radius, ismMetadata.spread, ismMetadata.gainFactor, ismMetadata.yaw, ismMetadata.pitch ); +#else snprintf( char_buff, sizeof( char_buff ), "%+07.2f,%+06.2f,%05.2f,%06.2f,%04.2f\n", ismMetadata.azimuth, ismMetadata.elevation, ismMetadata.radius, ismMetadata.spread, ismMetadata.gainFactor ); +#endif if ( file ) { diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 9fe7f019ebb767c5dfe384ab94eaf142fb47fe4a..907d148a6e7523172e6e2e8aa28f287abf357d75 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -522,6 +522,15 @@ ivas_error RenderConfigReader_read( errorHandler( pValue, ERROR_VALUE_INVALID ); } } +#ifdef TD5 + else if ( strcmp( item, "DIRECTIVITY" ) == 0 ) + { + if ( read_vector( pValue, 3, hRenderConfig->directivity ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + } + } +#endif #ifdef DEBUGGING else {