From ccd084ed7a8bd18fa744eeb2b566f7967dcc01a1 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 23 Apr 2026 13:43:15 +0200 Subject: [PATCH 1/2] Remove extra encoder app --- Makefile | 9 +- Workspace_msvc/Workspace_msvc.sln | 11 - apps/encoder_fmtsw.c | 2456 ----------------------------- readme.txt | 20 +- 4 files changed, 5 insertions(+), 2491 deletions(-) delete mode 100644 apps/encoder_fmtsw.c diff --git a/Makefile b/Makefile index d31439f90..1461dca21 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,6 @@ SRC_DIRS = $(sort -u $(SRC_LIBBASOP) $(SRC_LIBCOM) $(SRC_LIBDEBUG) $(SRC_LIBDEC # Name of CLI binaries CLI_APIDEC ?= IVAS_dec CLI_APIENC ?= IVAS_cod -CLI_APIENC_FMTSW ?= IVAS_cod_fmtsw CLI_APIREND ?= IVAS_rend CLI_APIPOSTREND ?= ISAR_post_rend CLI_AMBICONVERT ?= ambi_converter @@ -184,7 +183,6 @@ OBJS_LIBUTIL = $(addprefix $(OBJDIR)/,$(SRCS_LIBUTIL:.c=.o)) OBJS_AMBICONVERT = $(OBJDIR)/ambi_convert.o OBJS_CLI_APIDEC = $(OBJDIR)/decoder.o OBJS_CLI_APIENC = $(OBJDIR)/encoder.o -OBJS_CLI_APIENC_FMTSW = $(OBJDIR)/encoder_fmtsw.o OBJS_CLI_APPREND = $(OBJDIR)/renderer.o OBJS_CLI_APPPOSTREND = $(OBJDIR)/isar_post_rend.o OBJS_CLI_AMBICONVERT = $(OBJDIR)/ambi_converter.o @@ -197,7 +195,7 @@ DEPS = $(addprefix $(OBJDIR)/,$(SRCS_LIBBASOP:.c=.P) $(SRCS_LIBCOM:.c=.P) $(SRCS .PHONY: all clean -all: $(CLI_APIENC) $(CLI_APIENC_FMTSW) $(CLI_APIDEC) $(CLI_APIREND) $(CLI_APIPOSTREND) +all: $(CLI_APIENC) $(CLI_APIDEC) $(CLI_APIREND) $(CLI_APIPOSTREND) $(OBJDIR): $(QUIET)mkdir -p $(OBJDIR) @@ -233,9 +231,6 @@ $(LIB_LIBUTIL): $(OBJS_LIBUTIL) $(OBJS_LIBBASOP) $(OBJS_LIBCOM) $(CLI_APIENC): $(OBJS_CLI_APIENC) $(LIB_LIBBASOP) $(LIB_LIBENC) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) $(LIB_LC3PLUS) $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APIENC) -L. -livasbasop -livasenc -livascom -livasutil -livasdebug $(LDLIBS) -o $(CLI_APIENC) -$(CLI_APIENC_FMTSW): $(OBJS_CLI_APIENC_FMTSW) $(LIB_LIBBASOP) $(LIB_LIBENC) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) $(LIB_LC3PLUS) - $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APIENC_FMTSW) -L. -livasbasop -livasenc -livascom -livasutil -livasdebug $(LDLIBS) -o $(CLI_APIENC_FMTSW) - $(CLI_APIDEC): $(OBJS_CLI_APIDEC) $(LIB_LIBBASOP) $(LIB_LIBDEC) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) $(LIB_LC3PLUS) $(LIB_LIBISAR) $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APIDEC) -L. -livasbasop -livasdec -livascom -livasutil -livasdebug -llc3plus $(LDLIBS) -o $(CLI_APIDEC) @@ -254,7 +249,7 @@ clean: $(QUIET)$(RM) $(OBJS_LIBENC) $(OBJS_LIBDEC) $(DEPS) $(QUIET)$(RM) $(DEPS:.P=.d) $(QUIET)test ! -d $(OBJDIR) || rm -rf $(OBJDIR) - $(QUIET)$(RM) $(CLI_APIENC) $(CLI_APIENC_FMTSW) $(CLI_APIDEC) $(CLI_APIREND) $(CLI_APIPOSTREND) $(CLI_AMBICONVERT) $(LIB_LIBENC) $(LIB_LIBDEBUG) $(OBJS_LIBBASOP) $(LIB_LIBCOM) $(LIB_LIBDEC) $(LIB_LIBUTIL) $(LIB_LIBREND) $(LIB_LIBISAR) $(LIB_LC3PLUS) + $(QUIET)$(RM) $(CLI_APIENC) $(CLI_APIDEC) $(CLI_APIREND) $(CLI_APIPOSTREND) $(CLI_AMBICONVERT) $(LIB_LIBENC) $(LIB_LIBDEBUG) $(OBJS_LIBBASOP) $(LIB_LIBCOM) $(LIB_LIBDEC) $(LIB_LIBUTIL) $(LIB_LIBREND) $(LIB_LIBISAR) $(LIB_LC3PLUS) $(OBJDIR)/%.o : %.c | $(OBJDIR) $(QUIET_CC)$(CC) $(CFLAGS) -c -MD -o $@ $< diff --git a/Workspace_msvc/Workspace_msvc.sln b/Workspace_msvc/Workspace_msvc.sln index c9c1f0fde..abb9650fc 100644 --- a/Workspace_msvc/Workspace_msvc.sln +++ b/Workspace_msvc/Workspace_msvc.sln @@ -24,11 +24,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "encoder", "encoder.vcxproj" {63747FE7-94BA-410C-8D7F-EB47555DD994} = {63747FE7-94BA-410C-8D7F-EB47555DD994} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "encoder_fmtsw", "encoder_fmtsw.vcxproj", "{CA7EA15E-09A4-4196-A8EA-2A5F6F84862B}" - ProjectSection(ProjectDependencies) = postProject - {63747FE7-94BA-410C-8D7F-EB47555DD994} = {63747FE7-94BA-410C-8D7F-EB47555DD994} - EndProjectSection -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "renderer", "renderer.vcxproj", "{12B4C8A5-1E06-4E30-B443-D1F916F52B47}" ProjectSection(ProjectDependencies) = postProject {63747FE7-94BA-410C-8D7F-EB47555DD994} = {63747FE7-94BA-410C-8D7F-EB47555DD994} @@ -111,12 +106,6 @@ Global {B3FC9DFC-7268-8660-7C0D-B60BAF02C554}.Release|Win32.ActiveCfg = Release|Win32 {B3FC9DFC-7268-8660-7C0D-B60BAF02C554}.Release|Win32.Build.0 = Release|Win32 {B3FC9DFC-7268-8660-7C0D-B60BAF02C554}.Release|x64.ActiveCfg = Release|Win32 - {CA7EA15E-09A4-4196-A8EA-2A5F6F84862B}.Debug|Win32.ActiveCfg = Debug|Win32 - {CA7EA15E-09A4-4196-A8EA-2A5F6F84862B}.Debug|Win32.Build.0 = Debug|Win32 - {CA7EA15E-09A4-4196-A8EA-2A5F6F84862B}.Debug|x64.ActiveCfg = Debug|Win32 - {CA7EA15E-09A4-4196-A8EA-2A5F6F84862B}.Release|Win32.ActiveCfg = Release|Win32 - {CA7EA15E-09A4-4196-A8EA-2A5F6F84862B}.Release|Win32.Build.0 = Release|Win32 - {CA7EA15E-09A4-4196-A8EA-2A5F6F84862B}.Release|x64.ActiveCfg = Release|Win32 {12B4C8A5-1E06-4E30-B443-D1F916F52B47}.Debug|Win32.ActiveCfg = Debug|Win32 {12B4C8A5-1E06-4E30-B443-D1F916F52B47}.Debug|Win32.Build.0 = Debug|Win32 {12B4C8A5-1E06-4E30-B443-D1F916F52B47}.Debug|x64.ActiveCfg = Debug|Win32 diff --git a/apps/encoder_fmtsw.c b/apps/encoder_fmtsw.c deleted file mode 100644 index 0222bef66..000000000 --- a/apps/encoder_fmtsw.c +++ /dev/null @@ -1,2456 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -#include -#include "options.h" -#ifdef DEBUGGING -#include "debug.h" -#endif -#include "stl.h" -#include "lib_enc.h" -#include "cmdl_tools.h" -#include "audio_file_reader.h" -#include "bitstream_writer.h" -#include "ism_file_reader.h" -#include "jbm_file_reader.h" -#include "masa_file_reader.h" -#include "rotation_file_reader.h" -#include "ivas_rtp_file.h" -#include "wmc_auto.h" - - -#ifdef DEBUG_FORCE_DIR -/* Windows does not define the S_ISREG and S_ISDIR macros in stat.h, so we do. - We have to define _CRT_INTERNAL_NONSTDC_NAMES 1 before #including sys/stat.h - in order for Microsoft's stat.h to define names like S_IFMT, S_IFREG, and S_IFDIR, - rather than just defining _S_IFMT, _S_IFREG, and _S_IFDIR as it normally does. */ -#include -#if !defined( S_ISREG ) && defined( S_IFMT ) && defined( S_IFREG ) -#define S_ISREG( m ) ( ( ( m ) & S_IFMT ) == S_IFREG ) -#endif -#if !defined( S_ISDIR ) && defined( S_IFMT ) && defined( S_IFDIR ) -#define S_ISDIR( m ) ( ( ( m ) & S_IFMT ) == S_IFDIR ) -#endif -#endif - -#define WMC_TOOL_SKIP - -/*------------------------------------------------------------------------------------------* - * Local constants, enums - *------------------------------------------------------------------------------------------*/ - -#define MAX_ARGV 20 /* maximum number of command line arguments that can be \ - in one line of the format switching file */ - -#if !defined( DEBUGGING ) && !defined( WMOPS ) -static -#endif - int32_t frame = 0; /* Counter of frames */ - -#define RANDOM_INITSEED_ENC ( 0xDEAF ) - -#define DEFAULT_FIXED_SID_RATE 8 /* DTX SID rate */ - -/* Additional config info for each input format */ -typedef union _EncInputFormatConfig -{ - /* MONO details */ - bool stereoToMonoDownmix; - -#ifdef DEBUGGING - /* STEREO details */ - IVAS_ENC_STEREO_MODE stereoMode; -#endif - - /* ISM details */ - struct EncIsmConfig - { - int16_t numObjects; - const char *metadataFiles[IVAS_MAX_NUM_OBJECTS]; - } ism; - - /* SBA details */ - struct EncSbaConfig - { - IVAS_ENC_SBA_ORDER order; - bool isPlanar; - } sba; - - /* MASA details */ - IVAS_ENC_MASA_VARIANT masaVariant; - - /* MC details */ - IVAS_ENC_MC_LAYOUT mcLayout; - - struct EncMasaIsmConfig - { - int16_t numObjects; - const char *metadataFiles[IVAS_MAX_NUM_OBJECTS]; - IVAS_ENC_MASA_VARIANT masaVariant; - } masa_ism; - - struct EncSbaIsmConfig - { - int16_t numObjects; - const char *metadataFiles[IVAS_MAX_NUM_OBJECTS]; - IVAS_ENC_SBA_ORDER order; - bool isPlanar; - } sba_ism; - -} EncInputFormatConfig; - - -/*------------------------------------------------------------------------------------------* - * Local structure for storing cmdln arguments - *------------------------------------------------------------------------------------------*/ - -typedef struct -{ - char *inputWavFilename; - char *outputBitstreamFilename; - int32_t inputFs; - IVAS_ENC_INPUT_FORMAT inputFormat; - bool is_binaural; - EncInputFormatConfig inputFormatConfig; - bool max_bwidth_user; - IVAS_ENC_BANDWIDTH maxBandwidth; - const char *bandwithProfileFile; - IVAS_ENC_DTX_CONFIG dtxConfig; - int32_t initBitrate; - const char *bitrateProfileFile; - bool quietModeEnabled; - bool delayCompensationEnabled; - const char *masaMetadataFile; - IVAS_ENC_CHANNEL_AWARE_CONFIG caConfig; - const char *ca_config_file; - bool mimeOutput; - IVAS_ENC_COMPLEXITY_LEVEL complexityLevel; -#ifdef DEBUGGING - IVAS_ENC_FORCED_MODE forcedMode; - const char *forcedModeFile; -#ifdef DEBUG_FORCE_DIR - const char *forcedModeDir; -#endif -#endif - bool pca; - bool ism_extended_metadata; - bool rtpdumpOutput; - uint32_t numFramesPerPacket; - char *sceneOrientationTrajFileName; - char *deviceOrientationTrajFileName; - -} EncArguments; - - -/*------------------------------------------------------------------------------------------* - * Local functions prototypes - *------------------------------------------------------------------------------------------*/ - -static bool parseCmdlIVAS_enc( int16_t argc, char *argv[], EncArguments *arg ); -static void usage_enc( void ); -static bool readBandwidth( FILE *file, IVAS_ENC_BANDWIDTH *bandwidth, int32_t *bandwidthFrameCounter ); -static bool readBitrate( FILE *file, int32_t *bitrate ); -#ifdef DEBUGGING -static ivas_error readForcedMode( FILE *file, IVAS_ENC_FORCED_MODE *forcedMode, int32_t *forceFrameCounter ); -static IVAS_ENC_FORCED_MODE parseForcedMode( char *forcedModeChar ); -#endif -static void str2arg( char *str, int *argc_local, char *argv_local[] ); -static int encoder_main( int argc, char *argv[], IVAS_RTP *ivasRtp, int init_RtpWriter ); - - -/*------------------------------------------------------------------------------------------* - * main() - * - * Main IVAS encoder function for command-line interface - * supporting IVAS format switching - *------------------------------------------------------------------------------------------*/ - -int main( - int argc, - char *argv[] ) -{ - bool mainFailed = true; /* Assume main failed until cleanup is reached without errors */ - FILE *FmtSWFile = NULL; - char line[2048]; - int argc_local = 0; - char *argv_local[MAX_ARGV] = { 0 }; - IVAS_RTP ivasRtp = { 0 }; - char prev_outputBitstreamFilename[2048] = { 0 }; - int rtp_term = 0; - - IVAS_ENC_PrintDisclaimer(); - - if ( argc != 2 ) - { - fprintf( stdout, "Usage: IVAS_cod_fmtsw.exe format_switching_file\n\n" ); - fprintf( stdout, "where format_switching_file is a text file containing a valid encoder command line in each line\n\n" ); - goto cleanup; - } - fprintf( stdout, "Input format switching file: %s\n", argv[1] ); - - if ( ( FmtSWFile = fopen( argv[1], "r" ) ) == NULL ) - { - fprintf( stdout, "error: cannot open format switching file %s\n", argv[1] ); - goto cleanup; - } - - while ( fgets( line, sizeof( line ), FmtSWFile ) ) - { - /* remove trimming newline */ - line[strcspn( line, "\r\n" )] = 0; - printf( "Processing format switching commandline: %s\n", line ); - str2arg( line, &argc_local, argv_local ); - - if ( strcmp( argv_local[argc_local - 1], (char *) prev_outputBitstreamFilename ) == 0 ) - { - /* append to last Rtp file */ - if ( encoder_main( argc_local, argv_local, &ivasRtp, 0 ) != 0 ) - { - goto cleanup; - } - } - else - { - if ( rtp_term == 1 ) - { - IVAS_RTP_Term( &ivasRtp ); - } - - /* write in separate Rtp file */ - if ( encoder_main( argc_local, argv_local, &ivasRtp, 1 ) != 0 ) - { - goto cleanup; - } - - rtp_term = 1; - } - strcpy( (char *) prev_outputBitstreamFilename, argv_local[argc_local - 1] ); - } - - /*------------------------------------------------------------------------------------------* - * Close files and deallocate resources - *------------------------------------------------------------------------------------------*/ - - mainFailed = false; /* This will stay set to true if cleanup is reached via a goto due to an error */ - -cleanup: - - IVAS_RTP_Term( &ivasRtp ); - - if ( FmtSWFile ) - { - fclose( FmtSWFile ); - } - - return mainFailed ? -1 : 0; -} - - -/*-------------------------------------------------------------------* - * Local functions - *-------------------------------------------------------------------*/ - -void str2arg( - char *str, /* input string */ - int *argc_local, /* number of argument */ - char *argv_local[] /* array of arguments */ -) -{ - int i = 0; - char *token = strtok( str, " " ); - while ( token && ( i < MAX_ARGV - 1 ) ) - { - argv_local[i++] = token; - token = strtok( 0, " " ); - } - argv_local[i] = 0; - *argc_local = i; - return; -} - -int encoder_main( - int argc, - char *argv[], - IVAS_RTP *ivasRtp, - int init_RtpWriter ) -{ - bool mainFailed = true; /* Assume main failed until cleanup is reached without errors */ - EncArguments arg; - int16_t i; - ivas_error error = IVAS_ERR_UNKNOWN; - - /* Any handles that require cleanup must be declared here and initialized to NULL */ - IVAS_ENC_HANDLE hIvasEnc = NULL; - BS_WRITER_HANDLE hBsWriter = NULL; - AudioFileReader *audioReader = NULL; - FILE *f_bitrateProfile = NULL; - FILE *f_bwProfile = NULL; - JbmFileReader *jbmReader = NULL; - MasaFileReader *masaReader = NULL; - IsmFileReader *ismReaders[IVAS_MAX_NUM_OBJECTS] = { NULL, NULL, NULL, NULL }; - int16_t *pcmBuf = NULL; - RotFileReader *sceneOrientationFileReader = NULL; - RotFileReader *deviceOrientationFileReader = NULL; -#ifdef DEBUGGING - FILE *f_forcedModeProfile = NULL; -#endif - -#ifdef WMOPS - reset_wmops(); - reset_mem( USE_BYTES ); -#endif - - uint8_t au[IVAS_MAX_BITS_PER_FRAME / 8]; - /* IVAS_RTP ivasRtp = { 0 }; */ - - /* Ideally ssrc is negotiated via SDP and sequence number is radomized but we - use fixed seed for random num generator for regression based tests. Any realtime - application should implement this initialization seperately */ - uint16_t rtpEncSeed = RANDOM_INITSEED_ENC; - uint32_t ssrc = ( (uint32_t) IVAS_RTP_OwnRandom( &rtpEncSeed ) & 0x0000FFFF ) | ( (uint32_t) IVAS_RTP_OwnRandom( &rtpEncSeed ) << 16 ); - uint16_t seqNumInitVal = IVAS_RTP_OwnRandom( &rtpEncSeed ); -#ifdef FIX_1540_EXPOSE_PT_IN_RTP_HEADER_API - uint8_t payloadType = DEFAULT_IVAS_PAYLOAD_TYPE; /* Dynamic PT are in range [96, 127] */ -#endif - - /*------------------------------------------------------------------------------------------* - * Parse command-line arguments - *------------------------------------------------------------------------------------------*/ - - if ( !parseCmdlIVAS_enc( (int16_t) argc, argv, &arg ) ) - { - /* Error printout done internally in parseCmdlIVAS_enc() */ - goto cleanup; - } - - /*------------------------------------------------------------------------------------------* - * Open and initialize IVAS encoder - *------------------------------------------------------------------------------------------*/ - if ( ( error = IVAS_ENC_Open_fx( &hIvasEnc ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "Opening IVAS encoder failed: %s\n", IVAS_ENC_GetErrorMessage( error ) ); - goto cleanup; - } - /*------------------------------------------------------------------------------------------* - * Open output bitstream file - *------------------------------------------------------------------------------------------*/ - - const BS_WRITER_FORMAT bsWriterFormat = arg.mimeOutput ? BS_WRITER_FORMAT_MIME : BS_WRITER_FORMAT_G192; - - if ( !arg.rtpdumpOutput && BS_Writer_Open_filename( &hBsWriter, arg.outputBitstreamFilename, bsWriterFormat ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nCan't open %s\n\n", arg.outputBitstreamFilename ); - goto cleanup; - } - - /*------------------------------------------------------------------------------------------* - * Print out file names - *------------------------------------------------------------------------------------------*/ - - if ( arg.inputFormat == IVAS_ENC_INPUT_ISM || arg.inputFormat == IVAS_ENC_INPUT_SBA_ISM ) - { - for ( i = 0; i < arg.inputFormatConfig.ism.numObjects; i++ ) - { - fprintf( stdout, "Object %d input metadata: %s\n", i + 1, arg.inputFormatConfig.ism.metadataFiles[i] ); - } - } - - if ( arg.masaMetadataFile != NULL ) - { - fprintf( stdout, "MASA inp. metadata file: %s\n", arg.masaMetadataFile ); - } - - fprintf( stdout, "Input audio file: %s\n", arg.inputWavFilename ); - fprintf( stdout, "Output bitstream file: %s\n\n", arg.outputBitstreamFilename ); - - /*------------------------------------------------------------------------------------------* - * Open auxiliary input files - *------------------------------------------------------------------------------------------*/ - - int32_t totalBitrate = arg.initBitrate; - - if ( arg.bitrateProfileFile ) - { - if ( ( f_bitrateProfile = fopen( arg.bitrateProfileFile, "rb" ) ) == NULL ) - { - fprintf( stderr, "Error: bitrate profile file %s could not be opened\n\n", arg.bitrateProfileFile ); - usage_enc(); - goto cleanup; - } - - if ( !readBitrate( f_bitrateProfile, &totalBitrate ) ) - { - fprintf( stderr, "Error: bitrate profile file %s could not be read\n\n", arg.bitrateProfileFile ); - goto cleanup; - } - rewind( f_bitrateProfile ); - - fprintf( stdout, "Bitrate switching file: %s\n", arg.bitrateProfileFile ); - } - - int32_t bandwidthFrameCounter = 0; - IVAS_ENC_BANDWIDTH bandwidth = arg.maxBandwidth; - - if ( arg.bandwithProfileFile ) - { - if ( ( f_bwProfile = fopen( arg.bandwithProfileFile, "rb" ) ) == NULL ) - { - fprintf( stderr, "Error: incorrect bandwidth specification or the bandwidth profile file could not be opened: %s\n\n", arg.bandwithProfileFile ); - usage_enc(); - goto cleanup; - } - fprintf( stdout, "Bandwidth switching file: %s\n", arg.bandwithProfileFile ); - - if ( !readBandwidth( f_bwProfile, &bandwidth, &bandwidthFrameCounter ) ) - { - fprintf( stderr, "Error: bandwidth switching file %s could not be read\n\n", arg.bandwithProfileFile ); - goto cleanup; - } - rewind( f_bwProfile ); - bandwidthFrameCounter = 0; - } - else - { - if ( bandwidth == IVAS_ENC_BANDWIDTH_NB && arg.inputFormat != IVAS_ENC_INPUT_MONO ) - { - fprintf( stdout, "\nNB coding not supported in IVAS. Switching to WB.\n\n" ); - } - else - { - switch ( bandwidth ) - { - case IVAS_ENC_BANDWIDTH_UNDEFINED: - break; - case IVAS_ENC_BANDWIDTH_NB: - fprintf( stdout, "Max. encoded bandwidth: NB\n" ); - break; - case IVAS_ENC_BANDWIDTH_WB: - fprintf( stdout, "Max. encoded bandwidth: WB\n" ); - break; - case IVAS_ENC_BANDWIDTH_SWB: - fprintf( stdout, "Max. encoded bandwidth: SWB\n" ); - break; - case IVAS_ENC_BANDWIDTH_FB: - fprintf( stdout, "Max. encoded bandwidth: FB\n" ); - break; - default: - fprintf( stderr, "Error: Invalid bandwidth value\n" ); - usage_enc(); - goto cleanup; - } - } - } - - /*------------------------------------------------------------------------------------------* - * Handle Channel-aware mode - *------------------------------------------------------------------------------------------*/ - - IVAS_ENC_CHANNEL_AWARE_CONFIG caConfig = arg.caConfig; - - if ( arg.ca_config_file ) - { - if ( ( jbmReader = JbmFileReader_open( arg.ca_config_file ) ) == NULL ) - { - fprintf( stderr, "\nError: Channel aware configuration file could not be opened: %s\n\n", arg.ca_config_file ); - usage_enc(); - goto cleanup; - } - - fprintf( stdout, "Channel-aware mode: ON, config file: %s \n", arg.ca_config_file ); - } - else if ( caConfig.channelAwareModeEnabled ) - { - fprintf( stdout, "Channel-aware mode: ON, FEC indicator : %s FEC offset: %d \n\n", ( caConfig.fec_indicator == IVAS_ENC_FEC_LO ) ? "LO" : "HI", caConfig.fec_offset ); - } - - if ( arg.inputFormat != IVAS_ENC_INPUT_MONO && ( caConfig.channelAwareModeEnabled || arg.ca_config_file ) ) - { - fprintf( stderr, "Channel-aware mode is not supported in IVAS.\n\n" ); - usage_enc(); - goto cleanup; - } - -#ifdef SUPPORT_FORCE_TCX10_TCX20 -#ifdef DEBUGGING - if ( arg.forcedMode == IVAS_ENC_FORCE_TCX10 && totalBitrate < 48000 ) - { - fprintf( stderr, "Warning: Enforcing the TCX10 mode is only supported for bitrates higher or equal than 48 kbps!\n\n" ); - } -#endif -#endif - - /*------------------------------------------------------------------------------------------* - * Configure and initialize (allocate memory for static variables) the encoder - *------------------------------------------------------------------------------------------*/ - - switch ( arg.inputFormat ) - { - case IVAS_ENC_INPUT_MONO: - if ( ( error = IVAS_ENC_ConfigureForMono( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, caConfig, arg.inputFormatConfig.stereoToMonoDownmix, arg.is_binaural ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nIVAS_ENC_ConfigureForMono failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); - goto cleanup; - } - break; - case IVAS_ENC_INPUT_STEREO: -#ifdef DEBUGGING - if ( ( error = IVAS_ENC_ConfigureForStereo( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, arg.is_binaural, arg.inputFormatConfig.stereoMode ) ) != IVAS_ERR_OK ) -#else - if ( ( error = IVAS_ENC_ConfigureForStereo( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, arg.is_binaural ) ) != IVAS_ERR_OK ) -#endif - { - fprintf( stderr, "\nIVAS_ENC_ConfigureForStereo failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); - goto cleanup; - } - break; - case IVAS_ENC_INPUT_ISM: - 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 ) - { - fprintf( stderr, "\nIVAS_ENC_ConfigureForObjects failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); - goto cleanup; - } - break; - case IVAS_ENC_INPUT_SBA: - if ( ( error = IVAS_ENC_ConfigureForAmbisonics( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, arg.inputFormatConfig.sba.order, arg.inputFormatConfig.sba.isPlanar, - arg.pca ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nIVAS_ENC_ConfigureForAmbisonics failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); - goto cleanup; - } - break; - case IVAS_ENC_INPUT_MASA: - if ( ( error = IVAS_ENC_ConfigureForMasa( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, arg.inputFormatConfig.masaVariant ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nIVAS_ENC_ConfigureForMasa failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); - goto cleanup; - } - break; - case IVAS_ENC_INPUT_MC: - if ( ( error = IVAS_ENC_ConfigureForMultichannel( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, arg.inputFormatConfig.mcLayout ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nIVAS_ENC_ConfigureForMultichannel failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); - goto cleanup; - } - break; - case IVAS_ENC_INPUT_SBA_ISM: - if ( ( error = IVAS_ENC_ConfigureForSBAObjects( hIvasEnc, arg.inputFs, totalBitrate, bandwidth, arg.dtxConfig, arg.inputFormatConfig.sba_ism.numObjects, arg.inputFormatConfig.sba_ism.order, arg.inputFormatConfig.sba_ism.isPlanar, arg.pca ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nIVAS_ENC_ConfigureForSBAObjects failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); - goto cleanup; - } - break; - case IVAS_ENC_INPUT_MASA_ISM: - if ( ( error = IVAS_ENC_ConfigureForMASAObjects( hIvasEnc, arg.inputFs, totalBitrate, bandwidth, arg.dtxConfig, arg.inputFormatConfig.masa_ism.numObjects, arg.inputFormatConfig.masa_ism.masaVariant ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nIVAS_ENC_ConfigureForMASAObjects failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); - goto cleanup; - } - break; - default: - fprintf( stderr, "\nInvalid input type\n\n" ); - goto cleanup; - } - - if ( ( error = IVAS_ENC_PrintConfig( hIvasEnc, caConfig.channelAwareModeEnabled ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\n IVAS_ENC_PrintConfig failed %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); - goto cleanup; - } - - /*------------------------------------------------------------------------------------------* - * Open input audio file - *------------------------------------------------------------------------------------------*/ - - if ( AudioFileReader_open( &audioReader, arg.inputWavFilename ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nCan't open %s\n\n", arg.inputWavFilename ); - goto cleanup; - } - - /* Validate input sampling rate */ - int32_t inFileSampleRate = 0; - error = AudioFileReader_getSamplingRate( audioReader, &inFileSampleRate ); - switch ( error ) - { - case IVAS_ERR_OK: - if ( inFileSampleRate != arg.inputFs ) - { - fprintf( stderr, "\nSampling rate mismatch: %d Hz requested, but %d Hz found in file %s\n\n", arg.inputFs, inFileSampleRate, arg.inputWavFilename ); - goto cleanup; - } - break; - case IVAS_ERR_SAMPLING_RATE_UNKNOWN: - /* IVAS_ERR_SAMPLING_RATE_UNKNOWN will be returned for raw PCM files. - * Nothing to check here */ - break; - default: - fprintf( stderr, "\nError: %s\n", ivas_error_to_string( error ) ); - goto cleanup; - } - - /* Validate number of channels */ - int16_t encInNumChannels = 0; - if ( ( error = IVAS_ENC_GetNumInChannels( hIvasEnc, &encInNumChannels ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError: %s\n", ivas_error_to_string( error ) ); - goto cleanup; - } - - int16_t inFileNumChannels = 0; - error = AudioFileReader_getNumChannels( audioReader, &inFileNumChannels ); - switch ( error ) - { - case IVAS_ERR_OK: - if ( inFileNumChannels != encInNumChannels ) - { - fprintf( stderr, "\nNumber of input audio channels mismatch: %d accepted by encoder, but %d found in file %s\n\n", encInNumChannels, inFileNumChannels, arg.inputWavFilename ); - goto cleanup; - } - break; - case IVAS_ERR_NUM_CHANNELS_UNKNOWN: - /* IVAS_ERR_NUM_CHANNELS_UNKNOWN will be returned for raw PCM files. - * Nothing to check here */ - break; - default: - fprintf( stderr, "\nError: %s\n", ivas_error_to_string( error ) ); - goto cleanup; - } - - /*------------------------------------------------------------------------------------------* - * Open input metadata files - *------------------------------------------------------------------------------------------*/ - - if ( arg.masaMetadataFile ) - { - if ( ( masaReader = MasaFileReader_open( arg.masaMetadataFile ) ) == NULL ) - { - fprintf( stderr, "\nError: MASA input metadata file %s could not be opened\n\n", arg.masaMetadataFile ); - usage_enc(); - goto cleanup; - } - } - - const int16_t numIsmInputs = ( arg.inputFormat == IVAS_ENC_INPUT_ISM || arg.inputFormat == IVAS_ENC_INPUT_MASA_ISM || arg.inputFormat == IVAS_ENC_INPUT_SBA_ISM ) ? arg.inputFormatConfig.ism.numObjects : 0; - - for ( i = 0; i < numIsmInputs; ++i ) - { - if ( arg.inputFormatConfig.ism.metadataFiles[i] != NULL ) - { - if ( ( ismReaders[i] = IsmFileReader_open( arg.inputFormatConfig.ism.metadataFiles[i] ) ) == NULL ) - { - fprintf( stderr, "\nError: ISM input metadata file %s could not be opened\n\n", arg.inputFormatConfig.ism.metadataFiles[i] ); - usage_enc(); - goto cleanup; - } - } - } - -#ifdef DEBUGGING - IVAS_ENC_FORCED_MODE forcedMode = arg.forcedMode; - int32_t force_profile_cnt = 0; - - if ( arg.forcedModeFile ) - { - if ( ( f_forcedModeProfile = fopen( arg.forcedModeFile, "rb" ) ) == NULL ) - { - fprintf( stderr, "\nError: Incorrect mode specification or the profile file could not be opened: %s\n\n", arg.forcedModeFile ); - usage_enc(); - goto cleanup; - } - } -#endif - - /*------------------------------------------------------------------------------------------* - * Allocate input data buffer - *------------------------------------------------------------------------------------------*/ - - int16_t pcmBufSize; - if ( ( error = IVAS_ENC_GetInputBufferSize( hIvasEnc, &pcmBufSize ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nGetInputBufferSize failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); - goto cleanup; - } - - pcmBuf = malloc( pcmBufSize * sizeof( int16_t ) ); - - /*------------------------------------------------------------------------------------------* - * Compensate for encoder delay (bitstream aligned with input signal) - *------------------------------------------------------------------------------------------*/ - - int16_t encDelayInSamples; - if ( ( error = IVAS_ENC_GetDelay( hIvasEnc, &encDelayInSamples ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nGetDelay failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); - goto cleanup; - } - - if ( arg.delayCompensationEnabled && encDelayInSamples ) - { - /* read samples and throw them away */ - int16_t numSamplesRead = 0; - if ( ( error = AudioFileReader_read( audioReader, pcmBuf, encDelayInSamples, &numSamplesRead ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError reading from file %s\n%s\n", arg.inputWavFilename, IVAS_ENC_GetErrorMessage( error ) ); - goto cleanup; - } - } - - /*------------------------------------------------------------------------------------------* - * RTPDump - *------------------------------------------------------------------------------------------*/ - - if ( arg.rtpdumpOutput && init_RtpWriter ) - { -#ifdef FIX_1540_EXPOSE_PT_IN_RTP_HEADER_API - if ( ( error = IVAS_RTP_WRITER_Init( ivasRtp, arg.outputBitstreamFilename, arg.numFramesPerPacket, payloadType, ssrc, seqNumInitVal ) ) != IVAS_ERR_OK ) -#else - if ( ( error = IVAS_RTP_WRITER_Init( ivasRtp, arg.outputBitstreamFilename, arg.numFramesPerPacket, ssrc, seqNumInitVal ) ) != IVAS_ERR_OK ) -#endif - { - fprintf( stderr, "\nError: Can't open output bitstream file for RTP output %s \n\n", arg.outputBitstreamFilename ); - goto cleanup; - } - } - - /*------------------------------------------------------------------------------------------* - * Open scene orientation file - *------------------------------------------------------------------------------------------*/ - - if ( arg.sceneOrientationTrajFileName != NULL ) - { - if ( ( error = RotationFileReader_open( arg.sceneOrientationTrajFileName, &sceneOrientationFileReader ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError: Can't open scene orientation file %s \n\n", arg.sceneOrientationTrajFileName ); - goto cleanup; - } - } - - /*------------------------------------------------------------------------------------------* - * Open device orientation file - *------------------------------------------------------------------------------------------*/ - - if ( arg.deviceOrientationTrajFileName != NULL ) - { - if ( ( error = RotationFileReader_open( arg.deviceOrientationTrajFileName, &deviceOrientationFileReader ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError: Can't open device orientation file %s \n\n", arg.deviceOrientationTrajFileName ); - goto cleanup; - } - } - - /*------------------------------------------------------------------------------------------* - * Run the encoder - *------------------------------------------------------------------------------------------*/ - - int16_t numSamplesRead = 0; - uint16_t bitStream[IVAS_MAX_BITS_PER_FRAME]; - uint16_t numBits = 0; - - if ( !arg.quietModeEnabled ) - { - fprintf( stdout, "\n------ Running the encoder ------\n\n" ); - fprintf( stdout, "Frames processed: " ); - } - else - { - fprintf( stdout, "\n\n-- Start the encoder (quiet mode) --\n\n" ); - } - -#ifdef WMOPS - reset_stack(); - reset_wmops(); -#endif - - /*------------------------------------------------------------------------------------------* - * Loop for every frame of input data - * - Read the input data - * - Process switching files - * - Read input metadata - * - Run the encoder - * - Write the parameters into output bitstream file - *------------------------------------------------------------------------------------------*/ - - while ( 1 ) - { - /* Read the input data */ - if ( ( error = AudioFileReader_read( audioReader, pcmBuf, pcmBufSize, &numSamplesRead ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError reading from file %s\n%s\n", arg.inputWavFilename, IVAS_ENC_GetErrorMessage( error ) ); - goto cleanup; - } - - if ( numSamplesRead == 0 ) - { - /* end of input data */ - break; - } - - /* Zero-pad if not enough samples were read (expected in last frame) */ - if ( numSamplesRead < pcmBufSize ) - { - for ( i = numSamplesRead; i < pcmBufSize; ++i ) - { - pcmBuf[i] = 0; - } - } - - /* Process switching files */ - if ( f_bitrateProfile ) - { - if ( !readBitrate( f_bitrateProfile, &totalBitrate ) ) - { - fprintf( stderr, "Error: bitrate profile file %s could not be read\n\n", arg.bitrateProfileFile ); - goto cleanup; - } - - if ( ( error = IVAS_ENC_SetBitrate( hIvasEnc, totalBitrate ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nIVAS_ENC_SetBitrate failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); - goto cleanup; - } - } - - if ( f_bwProfile ) - { - if ( !readBandwidth( f_bwProfile, &bandwidth, &bandwidthFrameCounter ) ) - { - fprintf( stderr, "Error: bandwidth switching file %s could not be read\n\n", arg.bandwithProfileFile ); - goto cleanup; - } - - if ( ( error = IVAS_ENC_SetBandwidth( hIvasEnc, bandwidth ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nIVAS_ENC_SetBandwidth failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); - goto cleanup; - } - } - - if ( jbmReader ) - { - if ( ( error = JbmFileReader_readCAconfig( jbmReader, &caConfig ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError (%s) while reading Channel-Aware Config. from: %s\n\n", IVAS_ENC_GetErrorMessage( error ), JbmFileReader_getFilePath( jbmReader ) ); - goto cleanup; - } - - if ( ( error = IVAS_ENC_SetChannelAwareConfig( hIvasEnc, caConfig ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "IVAS_ENC_SetChannelAwareConfig failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); - goto cleanup; - } - } - -#ifdef DEBUGGING - if ( f_forcedModeProfile ) - { - if ( ( error = readForcedMode( f_forcedModeProfile, &forcedMode, &force_profile_cnt ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError reading from file: %s\n%s\n", arg.forcedModeFile, IVAS_ENC_GetErrorMessage( error ) ); - goto cleanup; - } - } - - /* Force mode not set when configuring, set in first frame even if not reading from file */ - if ( f_forcedModeProfile || frame == 0 ) - { - if ( ( error = IVAS_ENC_SetForcedMode( hIvasEnc, forcedMode -#ifdef DEBUG_FORCE_DIR - , - arg.forcedModeDir -#endif - ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nIVAS_ENC_SetForcedMode failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); - goto cleanup; - } - } -#endif - - /* Read ISM input metadata */ - for ( i = 0; i < numIsmInputs; ++i ) - { - if ( ismReaders[i] == NULL ) - { - continue; - } - - IVAS_ISM_METADATA ismMetadata; - if ( ( error = IsmFileReader_readNextFrame( ismReaders[i], &ismMetadata ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError (%s) while reading ism metadata from: %s\n\n", IVAS_ENC_GetErrorMessage( error ), IsmFileReader_getFilePath( ismReaders[i] ) ); - goto cleanup; - } - - if ( ( error = IVAS_ENC_FeedObjectMetadata( hIvasEnc, i, ismMetadata ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nfeed_ISM_metadata failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); - goto cleanup; - } - } - - /* Read MASA input metadata */ - if ( masaReader ) - { - if ( ( error = MasaFileReader_readNextFrame( masaReader ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError (%s) while reading masa metadata from: %s\n\n", IVAS_ENC_GetErrorMessage( error ), arg.masaMetadataFile ); - goto cleanup; - } - IVAS_MASA_METADATA_HANDLE hMetadata = MasaFileReader_getMetadataHandle( masaReader ); - - if ( ( error = IVAS_ENC_FeedMasaMetadata( hIvasEnc, hMetadata ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nfeed_MASA_frame failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); - goto cleanup; - } - } - - /* *** Encode one frame *** */ - if ( ivasRtp->hPack ) - { - bool isMono = ( arg.inputFormat == IVAS_ENC_INPUT_MONO ); - bool forcePacket = ( numSamplesRead < pcmBufSize ); /* If EoF force Packet generation */ - - ivasRtp->nWrittenPiData = 0; - - /* scene orientation */ - if ( sceneOrientationFileReader ) - { - IVAS_PIDATA_TS *piDataTs = &ivasRtp->piData[ivasRtp->nWrittenPiData++]; - IVAS_PIDATA_ORIENTATION *scene = &piDataTs->data.scene; - - memset( piDataTs, 0, sizeof( IVAS_PIDATA_TS ) ); - scene->size = sizeof( IVAS_PIDATA_ORIENTATION ); - scene->piDataType = IVAS_PI_SCENE_ORIENTATION; - - if ( ( error = HeadRotationFileReading( sceneOrientationFileReader, &scene->orientation, NULL ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError %s while reading scene orientation from %s\n", IVAS_ENC_GetErrorMessage( error ), RotationFileReader_getFilePath( sceneOrientationFileReader ) ); - goto cleanup; - } - } - - /* device orientation */ - if ( deviceOrientationFileReader ) - { - IVAS_PIDATA_TS *piDataTs = &ivasRtp->piData[ivasRtp->nWrittenPiData++]; - IVAS_PIDATA_ORIENTATION *device = &piDataTs->data.deviceUnCompensated; - - memset( piDataTs, 0, sizeof( IVAS_PIDATA_TS ) ); - device->size = sizeof( IVAS_PIDATA_ORIENTATION ); - device->piDataType = IVAS_PI_DEVICE_ORIENTATION_COMPENSATED; - - if ( ( error = HeadRotationFileReading( deviceOrientationFileReader, &device->orientation, NULL ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError %s while reading device orientation from %s\n", IVAS_ENC_GetErrorMessage( error ), RotationFileReader_getFilePath( deviceOrientationFileReader ) ); - goto cleanup; - } - } - - if ( ( error = IVAS_ENC_EncodeFrameToCompact( hIvasEnc, pcmBuf, pcmBufSize, au, &numBits ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nencodeFrame failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); - goto cleanup; - } - - if ( ( error = IVAS_RTP_WriteNextFrame( ivasRtp, au, NULL, numBits, isMono, forcePacket ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError %s while pushing audio frame to RTP pack\n", IVAS_ENC_GetErrorMessage( error ) ); - goto cleanup; - } - } - else - { - if ( ( error = IVAS_ENC_EncodeFrameToSerial( hIvasEnc, pcmBuf, pcmBufSize, bitStream, &numBits ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nencodeFrame failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); - goto cleanup; - } - - /* write bitstream */ - if ( ( error = BS_Writer_WriteFrame_short( hBsWriter, bitStream, numBits, totalBitrate ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nBS_Writer_WriteFrame_short failed, error code %d\n\n", error ); - goto cleanup; - } - } - - frame++; - if ( !arg.quietModeEnabled ) - { - fprintf( stdout, "%-8d\b\b\b\b\b\b\b\b", frame ); - } - -#ifdef WMOPS - update_mem(); - update_wmops(); -#endif - } - - if ( arg.quietModeEnabled ) - { - fprintf( stdout, "Encoding finished\n" ); - } - else - { - fprintf( stdout, "\n\nEncoding of %d frames finished\n", frame ); - } - - /*------------------------------------------------------------------------------------------* - * Close files and deallocate resources - *------------------------------------------------------------------------------------------*/ - - mainFailed = false; /* This will stay set to true if cleanup is reached via a goto due to an error */ - -cleanup: - - free( pcmBuf ); - - if ( ( error = BS_Writer_Close( &hBsWriter ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "Can't close bitstream writer, error code %d\n", error ); - mainFailed = true; - } - - AudioFileReader_close( &audioReader ); - - if ( jbmReader ) - { - JbmFileReader_close( &jbmReader ); - } - - for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i ) - { - if ( ismReaders[i] != NULL ) - { - IsmFileReader_close( &ismReaders[i] ); - } - } - - if ( masaReader ) - { - MasaFileReader_close( &masaReader ); - } - - if ( f_bwProfile ) - { - fclose( f_bwProfile ); - } - - if ( f_bitrateProfile ) - { - fclose( f_bitrateProfile ); - } - - if ( sceneOrientationFileReader ) - { - RotationFileReader_close( &sceneOrientationFileReader ); - } - - if ( deviceOrientationFileReader ) - { - RotationFileReader_close( &deviceOrientationFileReader ); - } - - /* IVAS_RTP_Term( &ivasRtp ); */ - - IVAS_ENC_Close( &hIvasEnc ); - -#ifdef WMOPS - print_wmops(); - print_mem( NULL ); -#endif - - return mainFailed ? -1 : 0; -} - - -/*---------------------------------------------------------------------* - * parseCmdlIVAS_enc() - * - * Encoder command-line parsing - *---------------------------------------------------------------------*/ - -static bool parseCmdlIVAS_enc( - int16_t argc, - char *argv[], - EncArguments *arg ) -{ - int16_t i, j; - char argv_to_upper[FILENAME_MAX]; - char stmp[FILENAME_MAX]; - int32_t tmp; - - /*-----------------------------------------------------------------* - * Set default values - *-----------------------------------------------------------------*/ - - arg->inputWavFilename = NULL; - arg->outputBitstreamFilename = NULL; - arg->inputFs = 0; - arg->inputFormat = IVAS_ENC_INPUT_MONO; - arg->is_binaural = false; - arg->inputFormatConfig.stereoToMonoDownmix = false; - arg->max_bwidth_user = false; - arg->maxBandwidth = IVAS_ENC_BANDWIDTH_UNDEFINED; - arg->bandwithProfileFile = NULL; - arg->dtxConfig = IVAS_ENC_GetDefaultDtxConfig(); - arg->initBitrate = 0; - arg->bitrateProfileFile = NULL; - arg->quietModeEnabled = false; - arg->delayCompensationEnabled = true; - arg->masaMetadataFile = NULL; - arg->caConfig = IVAS_ENC_GetDefaultChannelAwareConfig(); - arg->ca_config_file = NULL; - arg->mimeOutput = false; - arg->ism_extended_metadata = false; - arg->complexityLevel = IVAS_ENC_COMPLEXITY_LEVEL_THREE; - arg->rtpdumpOutput = false; - arg->sceneOrientationTrajFileName = NULL; - arg->deviceOrientationTrajFileName = NULL; -#ifdef DEBUGGING - arg->forcedMode = IVAS_ENC_FORCE_UNFORCED; - arg->forcedModeFile = NULL; -#ifdef DEBUG_FORCE_DIR - arg->forcedModeDir = NULL; -#endif -#endif - arg->pca = false; - - /*-----------------------------------------------------------------* - * Initialization - *-----------------------------------------------------------------*/ - - if ( argc < 5 ) - { - fprintf( stderr, "Error: Not enough input parameters. Exiting!\n\n" ); - usage_enc(); - return false; - } - - /*-----------------------------------------------------------------* - * Optional input arguments - *-----------------------------------------------------------------*/ - - i = 1; - while ( i < argc - 4 ) - { - strncpy( argv_to_upper, argv[i], sizeof( argv_to_upper ) - 1 ); - argv_to_upper[sizeof( argv_to_upper ) - 1] = '\0'; - to_upper( argv_to_upper ); - - /*-----------------------------------------------------------------* - * Bandwidth limitation - *-----------------------------------------------------------------*/ - - if ( strcmp( argv_to_upper, "-MAX_BAND" ) == 0 ) - { - arg->max_bwidth_user = true; - - strncpy( stmp, argv[i + 1], sizeof( stmp ) - 1 ); - stmp[sizeof( stmp ) - 1] = '\0'; - to_upper( stmp ); - - if ( strcmp( stmp, "-NB" ) == 0 || strcmp( stmp, "NB" ) == 0 ) - { - arg->maxBandwidth = IVAS_ENC_BANDWIDTH_NB; - } - else if ( strcmp( stmp, "-WB" ) == 0 || strcmp( stmp, "WB" ) == 0 ) - { - arg->maxBandwidth = IVAS_ENC_BANDWIDTH_WB; - } - else if ( strcmp( stmp, "-SWB" ) == 0 || strcmp( stmp, "SWB" ) == 0 ) - { - arg->maxBandwidth = IVAS_ENC_BANDWIDTH_SWB; - } - else if ( strcmp( stmp, "-FB" ) == 0 || strcmp( stmp, "FB" ) == 0 ) - { - arg->maxBandwidth = IVAS_ENC_BANDWIDTH_FB; - } - else - { - arg->bandwithProfileFile = argv[i + 1]; - } - - i += 2; - } - - /*-----------------------------------------------------------------* - * Quiet mode - *-----------------------------------------------------------------*/ - - else if ( strcmp( argv_to_upper, "-Q" ) == 0 ) - { - i++; - arg->quietModeEnabled = true; - } - - /*-----------------------------------------------------------------* - * DTX/CNG - *-----------------------------------------------------------------*/ - - else if ( strcmp( argv_to_upper, "-DTX" ) == 0 ) - { - i++; - if ( i < argc - 4 ) - { - if ( sscanf( argv[i], "%d", &tmp ) <= 0 ) - { - tmp = DEFAULT_FIXED_SID_RATE; - } - else - { - i++; - } - } - else - { - tmp = DEFAULT_FIXED_SID_RATE; - } - - arg->dtxConfig.enabled = true; - - if ( tmp == 0 ) - { - arg->dtxConfig.variable_SID_rate = true; - arg->dtxConfig.SID_interval = 0; - } - else if ( tmp >= 3 && tmp <= 100 ) - { - arg->dtxConfig.variable_SID_rate = false; - arg->dtxConfig.SID_interval = (int16_t) tmp; - } - else - { - fprintf( stderr, "Error: Incorrect SID update interval specified: %d (supported 3-100)\n\n", tmp ); - usage_enc(); - return false; - } - } -#ifdef DEBUGGING - /*-----------------------------------------------------------------* - * Force specific mode - *-----------------------------------------------------------------*/ - - else if ( strcmp( argv_to_upper, "-FORCE" ) == 0 ) - { - strncpy( stmp, argv[i + 1], sizeof( stmp ) ); - - arg->forcedMode = parseForcedMode( stmp ); - -#ifdef DEBUG_FORCE_DIR - if ( arg->forcedMode < IVAS_ENC_FORCE_FILE ) - { - fprintf( stdout, "Forcing codec to: %s\n", argv[i + 1] ); - } - else if ( arg->forcedMode == IVAS_ENC_FORCE_FILE ) - { - arg->forcedModeFile = argv[i + 1]; - fprintf( stdout, "Force switching file: %s\n", argv[i + 1] ); - } - else if ( arg->forcedMode == IVAS_ENC_FORCE_DIR ) - { - arg->forcedModeDir = argv[i + 1]; - fprintf( stdout, "Forcing switching directory: %s\n", argv[i + 1] ); - } - else - { - fprintf( stderr, "\nError: The force switching profile file/dir %s does not exist or could not be opened!\n\n", argv[i + 1] ); - usage_enc(); - return false; - } -#else - if ( arg->forcedMode == IVAS_ENC_FORCE_UNDEFINED ) - { - arg->forcedModeFile = argv[i + 1]; - fprintf( stdout, "Force switching file: %s\n", argv[i + 1] ); - } - else - { -#ifdef SUPPORT_FORCE_TCX10_TCX20 - if ( arg->forcedMode == IVAS_ENC_FORCE_TCX10 ) - { - strcpy( stmp, "TCX10" ); - } - else if ( arg->forcedMode == IVAS_ENC_FORCE_TCX20 ) - { - strcpy( stmp, "TCX20" ); - } - else - { - strncpy( stmp, argv[i + 1], sizeof( stmp ) ); - } - - fprintf( stdout, "Forcing codec to: %s\n", stmp ); -#else - fprintf( stdout, "Forcing codec to: %s\n", argv[i + 1] ); -#endif - } -#endif - - i += 2; - } -#ifdef DEBUG_MODE_INFO -#ifdef DEBUG_MODE_INFO_TWEAK - /*-----------------------------------------------------------------* - * Define additional subfolder for debug info output in ./res - *-----------------------------------------------------------------*/ - else if ( strcmp( argv_to_upper, "-INFO" ) == 0 ) - { - extern char infoFolder[FILENAME_MAX]; - strncpy( infoFolder, argv[i + 1], sizeof( infoFolder ) ); - i += 2; - } -#endif /* #ifdef DEBUG_MODE_INFO_TWEAK */ -#endif /* #ifdef DEBUG_MODE_INFO */ -#endif /* #ifdef DEBUGGING */ - - /*-----------------------------------------------------------------* - * deactivate delay compensation - *-----------------------------------------------------------------*/ - - else if ( strcmp( argv_to_upper, "-NO_DELAY_CMP" ) == 0 ) - { - arg->delayCompensationEnabled = false; - i++; - } - - /*-----------------------------------------------------------------* - * Activate channel-aware mode - *-----------------------------------------------------------------*/ - - else if ( strcmp( argv_to_upper, "-RF" ) == 0 ) - { - arg->caConfig.channelAwareModeEnabled = 1; - i++; - - if ( i < argc - 4 ) - { - strncpy( stmp, argv[i], sizeof( stmp ) ); - stmp[sizeof( stmp ) - 1] = '\0'; - to_upper( stmp ); - if ( strcmp( stmp, "LO" ) == 0 ) - { - arg->caConfig.fec_indicator = IVAS_ENC_FEC_LO; - } - else if ( strcmp( stmp, "HI" ) == 0 ) - { - arg->caConfig.fec_indicator = IVAS_ENC_FEC_HI; - } - else - { - arg->ca_config_file = argv[i]; - } - i++; - - if ( ( sscanf( argv[i], "%d", &tmp ) == 1 ) && ( i < argc - 4 ) ) - { - if ( tmp == 0 ) - { - arg->caConfig.channelAwareModeEnabled = 0; - arg->caConfig.fec_offset = 0; - i++; - } - else - { - arg->caConfig.fec_offset = (int16_t) tmp; - i++; - } - } - } - else - { - arg->caConfig.fec_indicator = IVAS_ENC_FEC_HI; - } - } - - /*-----------------------------------------------------------------* - * MIME output file format - *-----------------------------------------------------------------*/ - - else if ( strcmp( argv_to_upper, "-MIME" ) == 0 ) - { - arg->mimeOutput = true; - fprintf( stdout, "Output bitstream file format: MIME\n" ); - ++i; - } - - - /*-----------------------------------------------------------------* - * Complexity Level - *-----------------------------------------------------------------*/ - - /* actual parsing of level will be implemented after characterization */ - else if ( strcmp( argv_to_upper, "-LEVEL" ) == 0 ) - { - int16_t level; - - ++i; - level = (int16_t) atoi( argv[i++] ); - if ( level < IVAS_ENC_COMPLEXITY_LEVEL_ONE || level > IVAS_ENC_COMPLEXITY_LEVEL_THREE ) - { - fprintf( stdout, "Invalid complexity level specified.\n" ); - usage_enc(); - return false; - } - else if ( level == IVAS_ENC_COMPLEXITY_LEVEL_ONE || level == IVAS_ENC_COMPLEXITY_LEVEL_TWO ) - { - fprintf( stdout, "Complexity levels 1 and 2 will be defined after characterisation - default to level 3 (full functionality).\n" ); - } - } - - /*-----------------------------------------------------------------* - * IVAS Formats - *-----------------------------------------------------------------*/ - - else if ( strcmp( argv_to_upper, "-STEREO" ) == 0 ) - { - i++; - arg->inputFormat = IVAS_ENC_INPUT_STEREO; - -#ifdef DEBUGGING - if ( ( i < argc - 4 ) && argv[i][0] != 45 ) /* note: 45 corresponds to "-" */ - { - if ( sscanf( argv[i], "%d", &tmp ) > 0 ) - { - if ( tmp == 1 ) - { - arg->inputFormatConfig.stereoMode = IVAS_ENC_STEREO_MODE_DFT; - i++; - } - else if ( tmp == 2 ) - { - arg->inputFormatConfig.stereoMode = IVAS_ENC_STEREO_MODE_TD; - i++; - } - else if ( tmp == 3 ) - { - arg->inputFormatConfig.stereoMode = IVAS_ENC_STEREO_MODE_MDCT_DECISION; -#ifdef DEBUG_FORCE_MDCT_STEREO_MODE - i++; - - /* force mdct stereo mode for debugging purposes */ - if ( i < argc - 4 ) - { - if ( sscanf( argv[i], "%d", &tmp ) > 0 ) - { - if ( tmp == 0 ) - { - /* keep "DECISION" */ - arg->inputFormatConfig.stereoMode = IVAS_ENC_STEREO_MODE_MDCT_DECISION; - i++; - } - else if ( tmp == 1 ) - { - arg->inputFormatConfig.stereoMode = IVAS_ENC_STEREO_MODE_MDCT_FORCE_LR; - i++; - } - else if ( tmp == 2 ) - { - arg->inputFormatConfig.stereoMode = IVAS_ENC_STEREO_MODE_MDCT_FORCE_MS; - i++; - } - else - { - fprintf( stderr, "Error: Incorrect mdct stereo coding method (%d) specified\n\n", tmp ); - usage_enc(); - return false; - } - } - } -#endif - } - else - { - fprintf( stderr, "Error: Incorrect stereo mode (%d) specified\n\n", tmp ); - usage_enc(); - return false; - } - } - else - { - fprintf( stderr, "Error: Stereo mode not specified.\n\n" ); /* in the debugging stage */ - usage_enc(); - return false; - } - } - else - { - arg->inputFormatConfig.stereoMode = IVAS_ENC_STEREO_MODE_UNIFIED; - } -#endif /* DEBUGGING */ - } - else if ( strcmp( argv_to_upper, "-BINAURAL" ) == 0 ) - { - arg->is_binaural = true; - i++; - } - else if ( strcmp( argv_to_upper, "-ISM" ) == 0 ) - { - arg->inputFormat = IVAS_ENC_INPUT_ISM; - i++; - - if ( i < argc - 4 ) - { - if ( argv[i][0] == '+' ) - { - argv[i]++; - arg->ism_extended_metadata = true; - } - if ( !is_digits_only( argv[i] ) ) - { - fprintf( stderr, "Error: Number of ISM channels must be an integer number!\n\n" ); - usage_enc(); - return false; - } - - if ( sscanf( argv[i], "%d", &tmp ) > 0 ) - { - i++; - } - - if ( tmp <= 0 ) - { - fprintf( stderr, "Error: Too low number of ISM channels specified!\n\n" ); - usage_enc(); - return false; - } - else if ( tmp > IVAS_MAX_NUM_OBJECTS ) - { - fprintf( stderr, "Error: Too high number of ISM channels specified!\n\n" ); - usage_enc(); - return false; - } - else - { - arg->inputFormatConfig.ism.numObjects = (int16_t) tmp; - } - } - else - { - fprintf( stderr, "Error: Number of ISM channels not specified!\n\n" ); - usage_enc(); - return false; - } - - /* read input metadata files */ - for ( j = 0; j < arg->inputFormatConfig.ism.numObjects; j++ ) - { - if ( i < argc - 4 ) - { - if ( strcmp( argv[i], "NULL" ) == 0 || strcmp( argv[i], "null" ) == 0 ) - { - /* no metadata input file -> encode only audio streams */ - arg->inputFormatConfig.ism.metadataFiles[j] = NULL; - } - else - { - arg->inputFormatConfig.ism.metadataFiles[j] = argv[i]; - } - - i++; - } - else - { - fprintf( stderr, "Error: not enough metadata arguments specified!\n\n" ); - usage_enc(); - return false; - } - } - } - else if ( strcmp( argv_to_upper, "-SBA" ) == 0 ) - { - i++; - arg->inputFormat = IVAS_ENC_INPUT_SBA; - - /* SBA configuration */ - if ( i < argc - 4 && is_number( argv[i] ) && sscanf( argv[i], "%d", &tmp ) > 0 ) - { - i++; - } - else - { - tmp = -1; /* this is to avoid a compilation warning */ - fprintf( stderr, "Error: SBA order must be specified, expecting a number!\n\n" ); - usage_enc(); - return false; - } - - arg->inputFormatConfig.sba.isPlanar = ( tmp < 0 ); - - tmp = abs( tmp ); - switch ( tmp ) - { - case 1: - arg->inputFormatConfig.sba.order = IVAS_ENC_SBA_FOA; - break; - case 2: - arg->inputFormatConfig.sba.order = IVAS_ENC_SBA_HOA2; - break; - case 3: - arg->inputFormatConfig.sba.order = IVAS_ENC_SBA_HOA3; - break; - default: - fprintf( stderr, "Error: Wrong SBA order specified!\n\n" ); - usage_enc(); - return false; - } - } - else if ( strcmp( argv_to_upper, "-MASA" ) == 0 ) - { - arg->inputFormat = IVAS_ENC_INPUT_MASA; - i++; - - if ( i < argc - 4 ) - { - if ( !is_digits_only( argv[i] ) ) - { - fprintf( stderr, "Error: Number of MASA channels must be an integer number!\n\n" ); - usage_enc(); - return false; - } - - if ( sscanf( argv[i], "%d", &tmp ) > 0 ) - { - i++; - } - - switch ( tmp ) - { - case 1: - arg->inputFormatConfig.masaVariant = IVAS_ENC_MASA_1CH; - break; - case 2: - arg->inputFormatConfig.masaVariant = IVAS_ENC_MASA_2CH; - break; - default: - fprintf( stderr, "Error: MASA channels must be 1 or 2.\n\n" ); - usage_enc(); - return false; - } - } - - if ( i < argc - 4 ) - { - arg->masaMetadataFile = argv[i]; - i++; - } - else - { - fprintf( stderr, "Error: not enough MASA arguments\n\n" ); - usage_enc(); - return false; - } - } - else if ( strcmp( argv_to_upper, "-MC" ) == 0 ) - { - i++; - arg->inputFormat = IVAS_ENC_INPUT_MC; - - if ( i < argc - 4 ) - { - if ( strcmp( argv[i], "5_1" ) == 0 ) - { - arg->inputFormatConfig.mcLayout = IVAS_ENC_MC_5_1; - } - else if ( strcmp( argv[i], "7_1" ) == 0 ) - { - arg->inputFormatConfig.mcLayout = IVAS_ENC_MC_7_1; - } - else if ( strcmp( argv[i], "5_1_2" ) == 0 ) - { - arg->inputFormatConfig.mcLayout = IVAS_ENC_MC_5_1_2; - } - else if ( strcmp( argv[i], "5_1_4" ) == 0 ) - { - arg->inputFormatConfig.mcLayout = IVAS_ENC_MC_5_1_4; - } - else if ( strcmp( argv[i], "7_1_4" ) == 0 ) - { - arg->inputFormatConfig.mcLayout = IVAS_ENC_MC_7_1_4; - } - else - { - fprintf( stderr, "Error: Incorrect input configuration specified for Multi-channel\n\n" ); - usage_enc(); - return false; - } - i++; - } - else - { - fprintf( stderr, "Error: Multi-channel configuration not specified!\n\n" ); - usage_enc(); - return false; - } - } - else if ( strcmp( to_upper( argv[i] ), "-ISM_MASA" ) == 0 ) - { - arg->inputFormat = IVAS_ENC_INPUT_MASA_ISM; - i++; - - if ( i < argc - 5 ) - { - if ( sscanf( argv[i], "%d", &tmp ) > 0 ) - { - i++; - } - - if ( tmp <= 0 ) - { - fprintf( stderr, "Error: Too low number of ISM channels specified!\n\n" ); - usage_enc(); - return false; - } - else - { - if ( tmp <= IVAS_MAX_NUM_OBJECTS ) /* number of ISM channels */ - { - arg->inputFormatConfig.masa_ism.numObjects = (int16_t) tmp; - } - else - { - fprintf( stderr, "Error: Too high number of ISM channels!\n\n" ); - usage_enc(); - return false; - } - } - } - else - { - fprintf( stderr, "Error: Number of ISM channels not specified!\n\n" ); - usage_enc(); - return false; - } - if ( i < argc - 4 ) - { - if ( sscanf( argv[i], "%d", &tmp ) > 0 ) - { - i++; - } - - switch ( tmp ) - { - case 1: - arg->inputFormatConfig.masa_ism.masaVariant = IVAS_ENC_MASA_1CH; - break; - case 2: - arg->inputFormatConfig.masa_ism.masaVariant = IVAS_ENC_MASA_2CH; - break; - default: - fprintf( stderr, "Error: MASA channels must be 1 or 2.\n\n" ); - usage_enc(); - return false; - } - } - - /* read input metadata files */ - for ( j = 0; j < arg->inputFormatConfig.masa_ism.numObjects; j++ ) - { - if ( i < argc - 4 ) - { - if ( strcmp( argv[i], "NULL" ) == 0 || strcmp( argv[i], "null" ) == 0 ) - { - /* no metadata input file -> encode only audio streams */ - arg->inputFormatConfig.masa_ism.metadataFiles[j] = NULL; - } - else - { - arg->inputFormatConfig.masa_ism.metadataFiles[j] = argv[i]; - } - - i++; - } - else - { - fprintf( stderr, "Error: not enough arguments\n\n" ); - usage_enc(); - return false; - } - } - - if ( i < argc - 4 ) - { - arg->masaMetadataFile = argv[i]; - i++; - } - else - { - fprintf( stderr, "Error: not enough MASA arguments\n\n" ); - usage_enc(); - return false; - } - } - else if ( strcmp( to_upper( argv[i] ), "-ISM_SBA" ) == 0 ) - { - arg->inputFormat = IVAS_ENC_INPUT_SBA_ISM; - i++; - - if ( i < argc - 5 ) - { - if ( sscanf( argv[i], "%d", &tmp ) > 0 ) - { - i++; - } - - if ( tmp <= 0 ) - { - fprintf( stderr, "Error: Too low number of ISM channels specified!\n\n" ); - usage_enc(); - return false; - } - else - { - if ( tmp <= IVAS_MAX_NUM_OBJECTS ) /* number of ISM channels */ - { - arg->inputFormatConfig.sba_ism.numObjects = (int16_t) tmp; - } - else - { - fprintf( stderr, "Error: Too high number of ISM channels!\n\n" ); - usage_enc(); - return false; - } - } - } - else - { - fprintf( stderr, "Error: Number of ISM channels not specified!\n\n" ); - usage_enc(); - return false; - } - - if ( i < argc - 4 ) - { - if ( sscanf( argv[i], "%d", &tmp ) > 0 ) - { - i++; - } - - arg->inputFormatConfig.sba_ism.isPlanar = ( tmp < 0 ); - - tmp = abs( tmp ); - switch ( tmp ) - { - case 1: - arg->inputFormatConfig.sba_ism.order = IVAS_ENC_SBA_FOA; - break; - case 2: - arg->inputFormatConfig.sba_ism.order = IVAS_ENC_SBA_HOA2; - break; - case 3: - arg->inputFormatConfig.sba_ism.order = IVAS_ENC_SBA_HOA3; - break; - default: - fprintf( stderr, "Error: Wrong SBA order specified!\n\n" ); - usage_enc(); - return false; - } - } - - /* read input metadata files */ - for ( j = 0; j < arg->inputFormatConfig.sba_ism.numObjects; j++ ) - { - if ( i < argc - 4 ) - { - if ( strcmp( argv[i], "NULL" ) == 0 || strcmp( argv[i], "null" ) == 0 ) - { - /* no metadata input file -> encode only audio streams */ - arg->inputFormatConfig.sba_ism.metadataFiles[j] = NULL; - } - else - { - arg->inputFormatConfig.sba_ism.metadataFiles[j] = argv[i]; - } - - i++; - } - else - { - fprintf( stderr, "Error: not enough arguments\n\n" ); - usage_enc(); - return false; - } - } - } - else if ( strcmp( argv_to_upper, "-STEREO_DMX_EVS" ) == 0 ) - { - arg->inputFormat = IVAS_ENC_INPUT_MONO; - arg->inputFormatConfig.stereoToMonoDownmix = true; - - i++; - } - else if ( strcmp( argv_to_upper, "-PCA" ) == 0 ) - { - arg->pca = 1; - i++; - } - - /*-----------------------------------------------------------------* - * RTPDump output - *-----------------------------------------------------------------*/ - - else if ( strcmp( argv_to_upper, "-RTPDUMP" ) == 0 ) - { - i++; - arg->rtpdumpOutput = true; - if ( i < argc - 4 ) - { - if ( !is_digits_only( argv[i] ) ) - { - arg->numFramesPerPacket = 1; /* Default to 1 frame per packet */ - } - else - { - arg->numFramesPerPacket = atoi( argv[i++] ); - if ( arg->numFramesPerPacket > IVAS_MAX_FRAMES_PER_RTP_PACKET ) - { - fprintf( stderr, "numFramesPerPacket(%d) exceeds max frames per packet (%d) \n", arg->numFramesPerPacket, IVAS_MAX_FRAMES_PER_RTP_PACKET ); - arg->numFramesPerPacket = 1; - } - } - } - fprintf( stdout, "Output format: RTPDump using %d frames/packet \n", arg->numFramesPerPacket ); - } - - /*-----------------------------------------------------------------* - * Scene orientation - *-----------------------------------------------------------------*/ - - else if ( strcmp( argv_to_upper, "-SCENE_ORIENTATION" ) == 0 ) - { - i++; - if ( argc - i <= 4 || argv[i][0] == '-' ) - { - fprintf( stderr, "Error: Scene orientation file name not specified!\n\n" ); - usage_enc(); - return false; - } - - arg->sceneOrientationTrajFileName = argv[i]; - i++; - } - - /*-----------------------------------------------------------------* - * Device orientation - *-----------------------------------------------------------------*/ - - else if ( strcmp( argv_to_upper, "-DEVICE_ORIENTATION" ) == 0 ) - { - i++; - if ( argc - i <= 4 || argv[i][0] == '-' ) - { - fprintf( stderr, "Error: Device orientation file name not specified!\n\n" ); - usage_enc(); - return false; - } - - arg->deviceOrientationTrajFileName = argv[i]; - i++; - } - - /*-----------------------------------------------------------------* - * Option not recognized - *-----------------------------------------------------------------*/ - else - { - fprintf( stderr, "Error: option not recognized, %s\n\n", argv[i] ); - usage_enc(); - return false; - } - } /* end of while */ - - /*-----------------------------------------------------------------* - * Mandatory input arguments - *-----------------------------------------------------------------*/ - - /*-----------------------------------------------------------------* - * Bitrate - *-----------------------------------------------------------------*/ - - if ( i < argc - 2 ) - { - /* check if profile file has been entered instead of a fixed bitrate */ - if ( !is_digits_only( argv[i] ) ) - { - arg->bitrateProfileFile = argv[i]; - } - else - { - arg->initBitrate = atoi( argv[i] ); - } - - i++; - } - else - { - fprintf( stderr, "Error: no bitrate specified\n\n" ); - usage_enc(); - return false; - } - - /*-----------------------------------------------------------------* - * Input sampling frequency - *-----------------------------------------------------------------*/ - - if ( i < argc - 2 ) - { - arg->inputFs = atoi( argv[i] ) * 1000; - i++; - } - else - { - fprintf( stderr, "Error: no input sampling frequency specified\n\n" ); - usage_enc(); - return false; - } - - /* for EVS mono, restore default behavior, i.e. SWB as default maxBandwidth if not set by the user otherwise */ - if ( arg->max_bwidth_user == false ) - { - arg->maxBandwidth = IVAS_ENC_GetDefaultBandwidth( ( arg->inputFormat == IVAS_ENC_INPUT_MONO ) ? true : false ); - } - - /* Prevent maxBandwidth from being higher than inputFs/2 */ - if ( arg->inputFs == 8000 && arg->maxBandwidth > IVAS_ENC_BANDWIDTH_NB ) - { - arg->maxBandwidth = IVAS_ENC_BANDWIDTH_NB; - } - else if ( arg->inputFs == 16000 && arg->maxBandwidth > IVAS_ENC_BANDWIDTH_WB ) - { - arg->maxBandwidth = IVAS_ENC_BANDWIDTH_WB; - } - else if ( arg->inputFs == 32000 && arg->maxBandwidth > IVAS_ENC_BANDWIDTH_SWB ) - { - arg->maxBandwidth = IVAS_ENC_BANDWIDTH_SWB; - } - - /*-----------------------------------------------------------------* - * Input file - *-----------------------------------------------------------------*/ - - if ( i < argc - 1 ) - { - arg->inputWavFilename = argv[i]; - i++; - } - else - { - fprintf( stderr, "Error: no input file specified\n\n" ); - usage_enc(); - return false; - } - - /*-----------------------------------------------------------------* - * Output bitstream file - *-----------------------------------------------------------------*/ - - if ( i < argc ) - { - arg->outputBitstreamFilename = argv[i]; - i++; - } - else - { - fprintf( stderr, "Error: no output bitstream file specified\n\n" ); - usage_enc(); - return false; - } - - return true; -} - - -/*---------------------------------------------------------------------* - * usage_enc() - * - * Print the usage of the "ivas_cod" program - *---------------------------------------------------------------------*/ - -static void usage_enc( void ) -{ - fprintf( stdout, "Usage: IVAS_cod.exe [Options] R Fs input_file bitstream_file\n\n" ); - - fprintf( stdout, "Mandatory parameters:\n" ); - fprintf( stdout, "---------------------\n" ); - - fprintf( stdout, "R : Bitrate in bps, \n" ); - fprintf( stdout, " for EVS native modes R = (5900*, 7200, 8000, 9600, 13200, 16400,\n" ); - fprintf( stdout, " 24400, 32000, 48000, 64000, 96000, 128000) \n" ); - 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" ); - 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" ); - fprintf( stdout, " (24400, 32000, 48000, 64000, 80000, 96000, 128000) \n" ); - 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" ); - fprintf( stdout, " for IVAS SBA, MASA, MC, ISM-SBA, and ISM-MASA R=(13200, 16400, 24400, 32000, 48000, 64000,\n" ); - fprintf( stdout, " 80000, 96000, 128000, 160000, 192000, 256000, 384000, 512000) \n" ); - fprintf( stdout, " Alternatively, R can be a bitrate switching file which consists of R values\n" ); - fprintf( stdout, " indicating the bitrate for each frame in bps. These values are stored in\n" ); - fprintf( stdout, " binary format using 4 bytes per value\n" ); - fprintf( stdout, "Fs : Input sampling rate in kHz, Fs = (8, 16, 32 or 48) \n" ); - - fprintf( stdout, "input_file : Input audio filename \n" ); - fprintf( stdout, "bitstream_file : Output bitstream filename \n\n" ); - - fprintf( stdout, "Options:\n" ); - fprintf( stdout, "--------\n" ); - fprintf( stdout, "EVS mono is default, for IVAS choose one of the following: -stereo, -ism, -sba, -masa, -mc, -ism_sba, -ism_masa\n" ); - fprintf( stdout, "-stereo : Stereo format \n" ); - fprintf( stdout, "-ism (+)Ch Files : ISM format \n" ); - fprintf( stdout, " where Ch specifies the number of ISMs (1-4)\n" ); - fprintf( stdout, " where positive (+) indicates extended metadata (only 64 kbps and up) \n" ); - 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" ); - fprintf( stdout, " where Order specifies the Ambisionics order (1-3),\n" ); - fprintf( stdout, " where positive (+) means full 3D and negative (-) only 2D/planar components to be coded\n" ); - fprintf( stdout, "-masa Ch File : MASA format \n" ); - fprintf( stdout, " where Ch specifies the number of MASA input/transport channels (1 or 2): \n" ); - fprintf( stdout, " and File specifies input file containing parametric MASA metadata \n" ); - fprintf( stdout, "-ism_sba IsmCh +/-Order IsmFiles : SBA and ISM combined format\n" ); - fprintf( stdout, " where IsmCh specifies the number of ISMs (1-4)\n" ); - fprintf( stdout, " and Order specifies the SBA order (1 to 3) \n" ); - fprintf( stdout, " and IsmFiles specify input files containing ISM metadata, one file per object \n" ); - fprintf( stdout, "-ism_masa IsmCh MasaCh IsmFiles MasaFile : MASA and ISM combined format \n" ); - fprintf( stdout, " where IsmCh specifies the number of ISMs (1-4),\n" ); - fprintf( stdout, " MasaCh specifies the number of MASA input/transport channels (1-2), \n" ); - fprintf( stdout, " IsmFiles specify input files containing ISM metadata, one file per object, \n" ); - fprintf( stdout, " and MasaFile specifies input file containing parametric MASA metadata \n" ); - fprintf( stdout, "-mc InputConf : Multi-channel format\n" ); - fprintf( stdout, " where InputConf specifies the channel configuration: 5_1, 7_1, 5_1_2, 5_1_4, 7_1_4\n" ); - fprintf( stdout, " Loudspeaker positions are assumed to have azimuth and elevation as per \n" ); - fprintf( stdout, " ISO/IEC 23091-3:2018 Table 3. Channel order is as per ISO/IEC 23008-3:2015 Table 95.\n" ); - fprintf( stdout, " See readme.txt for details.\n" ); - fprintf( stdout, "-dtx D : Activate DTX mode, D = (0, 3-100) is the SID update rate\n" ); - fprintf( stdout, " where 0 = adaptive, 3-100 = fixed in number of frames,\n" ); - fprintf( stdout, " default is deactivated\n" ); - fprintf( stdout, "-dtx : Activate DTX mode with a SID update rate of 8 frames\n" ); - fprintf( stdout, " Note: DTX is supported on all bitrates for EVS, stereo, ISM, and MASA, and up to 80 kbps for SBA.\n" ); - fprintf( stdout, "-rf p o : Activate channel-aware mode for WB and SWB signal at 13.2kbps, \n" ); - fprintf( stdout, " where FEC indicator, p: LO or HI, and FEC offset, o: 2, 3, 5, or 7 in number of frames.\n" ); - fprintf( stdout, " Alternatively p and o can be replaced by a rf configuration file with each line \n" ); - fprintf( stdout, " contains the values of p and o separated by a space, \n" ); - fprintf( stdout, " default is deactivated \n" ); - fprintf( stdout, "-max_band B : Activate bandwidth limitation, B = (NB, WB, SWB or FB)\n" ); - fprintf( stdout, " alternatively, B can be a text file where each line contains \"nb_frames B\"\n" ); - fprintf( stdout, "-no_delay_cmp : Turn off delay compensation\n" ); - fprintf( stdout, "-stereo_dmx_evs : Activate stereo downmix function for EVS.\n" ); - fprintf( stdout, "-binaural : Optional indication that input is binaural audio (to be used with -stereo or -stereo_dmx_evs)\n" ); - fprintf( stdout, "-mime : Mime output bitstream file format\n" ); - fprintf( stdout, " The encoder produces TS26.445 Annex.2.6 Mime Storage Format, (not RFC4867 Mime Format).\n" ); - fprintf( stdout, " default output bitstream file format is G.192\n" ); - fprintf( stdout, "-pca : activate PCA in SBA format FOA at 256 kbps \n" ); - fprintf( stdout, "-level level : Complexity level, level = (1, 2, 3), will be defined after characterisation. \n" ); - fprintf( stdout, " Currently, all values default to level 3 (full functionality).\n" ); -#ifdef DEBUGGING - fprintf( stdout, "-force T : Force specific mode, T = (speech, music, ACELP, GSC, TCX, HQ),\n" ); - fprintf( stdout, " alternatively, T can be a text file where each line contains \"nb_frames T\"\n" ); -#ifdef DEBUG_FORCE_DIR - fprintf( stdout, " or T can be a directory containing external binary files for modes/parameters enforcement\n" ); -#endif -#endif -#ifdef DEBUG_MODE_INFO -#ifdef DEBUG_MODE_INFO_TWEAK - fprintf( stdout, "-info : specify subfolder name for debug output\n" ); -#endif -#endif - fprintf( stdout, "-q : Quiet mode, no frame counters\n" ); - fprintf( stdout, " default is deactivated\n" ); - fprintf( stdout, "-rtpdump : RTPDump output, hf_only=1 by default. The encoder will packetize the \n" ); - fprintf( stdout, " bitstream frames into TS26.253 Annex A IVAS RTP Payload Format packets and \n" ); - fprintf( stdout, " writes those to the output file. In EVS mono operating mode, TS26.445 Annex A.2.2 \n" ); - fprintf( stdout, " EVS RTP Payload Format is used. Optional N represents number of frames per RTP packet\n" ); - fprintf( stdout, "-scene_orientation : Scene orientation trajectory file. Only used with rtpdump output.\n" ); - fprintf( stdout, "-device_orientation : Device orientation trajectory file. Only used with rtpdump output.\n" ); - fprintf( stdout, "\n" ); - - return; -} - - -/*---------------------------------------------------------------------* - * readBandwidth() - * - * - *---------------------------------------------------------------------*/ - -static bool readBandwidth( - FILE *file, - IVAS_ENC_BANDWIDTH *bandwidth, - int32_t *bandwidthFrameCounter ) -{ - int16_t res; - char stmp[4]; - - if ( *bandwidthFrameCounter == 0 ) - { - /* read next bandwidth value and number of frames from the profile file */ - while ( ( res = (int16_t) fscanf( file, "%d %3s", bandwidthFrameCounter, stmp ) ) != 2 && feof( file ) ) - { - rewind( file ); - } - - ( *bandwidthFrameCounter )--; - - to_upper( stmp ); - - if ( strcmp( stmp, "NB" ) == 0 ) - { - *bandwidth = IVAS_ENC_BANDWIDTH_NB; - } - else if ( strcmp( stmp, "WB" ) == 0 ) - { - *bandwidth = IVAS_ENC_BANDWIDTH_WB; - } - else if ( strcmp( stmp, "SWB" ) == 0 ) - { - *bandwidth = IVAS_ENC_BANDWIDTH_SWB; - } - else if ( strcmp( stmp, "FB" ) == 0 ) - { - *bandwidth = IVAS_ENC_BANDWIDTH_FB; - } - else - { - fprintf( stderr, "Error: incorrect bandwidth specified (only NB, WB, SWB and FB are supported)\n\n" ); - usage_enc(); - return false; - } - } - else - { - /* current profile still active, only decrease the counter */ - ( *bandwidthFrameCounter )--; - } - - return true; -} - - -/*---------------------------------------------------------------------* - * readBitrate() - * - * - *---------------------------------------------------------------------*/ - -static bool readBitrate( - FILE *file, - int32_t *bitrate ) -{ - for ( int32_t i = 0; i < 2; ++i ) - { - if ( fread( bitrate, sizeof( int32_t ), 1, file ) == 1 ) - { - return true; - } - - rewind( file ); - } - - fprintf( stderr, "Error: cannot read the bitrate profile file\n\n" ); - usage_enc(); - return false; -} - - -#ifdef DEBUGGING -/*---------------------------------------------------------------------* - * parseForcedMode() - * - * - *---------------------------------------------------------------------*/ - -static IVAS_ENC_FORCED_MODE parseForcedMode( - char *forcedModeChar ) -{ -#ifdef DEBUG_FORCE_DIR - struct stat path_stat; -#endif - - to_upper( forcedModeChar ); - -#ifdef DEBUG_FORCE_DIR - if ( ( strcmp( forcedModeChar, "SPEECH" ) == 0 ) || ( strcmp( forcedModeChar, "'SPEECH'" ) == 0 ) || - ( strcmp( forcedModeChar, "0" ) == 0 ) ) - { - return IVAS_ENC_FORCE_SPEECH; - } - else if ( ( strcmp( forcedModeChar, "MUSIC" ) == 0 ) || ( strcmp( forcedModeChar, "'MUSIC'" ) == 0 ) || ( strcmp( forcedModeChar, "AUDIO" ) == 0 ) || ( strcmp( forcedModeChar, "'AUDIO'" ) == 0 ) || ( strcmp( forcedModeChar, "1" ) == 0 ) ) - { - return IVAS_ENC_FORCE_MUSIC; - } - else if ( ( strcmp( forcedModeChar, "ACELP" ) == 0 ) || ( strcmp( forcedModeChar, "'ACELP'" ) == 0 ) ) - { - return IVAS_ENC_FORCE_ACELP; - } - else if ( ( strcmp( forcedModeChar, "GSC" ) == 0 ) || ( strcmp( forcedModeChar, "'GSC'" ) == 0 ) ) - { - return IVAS_ENC_FORCE_GSC; - } - if ( ( strcmp( forcedModeChar, "TCX" ) == 0 ) || ( strcmp( forcedModeChar, "'TCX'" ) == 0 ) -#ifdef SUPPORT_FORCE_TCX10_TCX20 - || ( strcmp( forcedModeChar, "TCX20" ) == 0 ) || ( strcmp( forcedModeChar, "'TCX20'" ) == 0 ) -#endif - ) - { -#ifdef SUPPORT_FORCE_TCX10_TCX20 - return IVAS_ENC_FORCE_TCX20; -#else - return IVAS_ENC_FORCE_TCX; -#endif - } -#ifdef SUPPORT_FORCE_TCX10_TCX20 - if ( ( strcmp( forcedModeChar, "TCX10" ) == 0 ) || ( strcmp( forcedModeChar, "'TCX10'" ) == 0 ) ) - { - return IVAS_ENC_FORCE_TCX10; - } -#endif - else if ( ( strcmp( forcedModeChar, "HQ" ) == 0 ) || ( strcmp( forcedModeChar, "'HQ'" ) == 0 ) ) - { - return IVAS_ENC_FORCE_HQ; - } - else - { - if ( stat( forcedModeChar, &path_stat ) != 0 ) - { - return IVAS_ENC_FORCE_UNDEFINED; - } - - /* check if the argument represents an existing file or directory */ - if ( S_ISDIR( path_stat.st_mode ) ) - { - /* it's a directory */ - return IVAS_ENC_FORCE_DIR; - } - else - { - /* it's a file */ - return IVAS_ENC_FORCE_FILE; - } - } -#else - if ( ( strcmp( forcedModeChar, "SPEECH" ) == 0 ) || ( strcmp( forcedModeChar, "'SPEECH'" ) == 0 ) || - ( strcmp( forcedModeChar, "0" ) == 0 ) ) - { - return IVAS_ENC_FORCE_SPEECH; - } - if ( ( strcmp( forcedModeChar, "MUSIC" ) == 0 ) || ( strcmp( forcedModeChar, "'MUSIC'" ) == 0 ) || ( strcmp( forcedModeChar, "AUDIO" ) == 0 ) || ( strcmp( forcedModeChar, "'AUDIO'" ) == 0 ) || ( strcmp( forcedModeChar, "1" ) == 0 ) ) - { - return IVAS_ENC_FORCE_MUSIC; - } - if ( ( strcmp( forcedModeChar, "ACELP" ) == 0 ) || ( strcmp( forcedModeChar, "'ACELP'" ) == 0 ) ) - { - return IVAS_ENC_FORCE_ACELP; - } - if ( ( strcmp( forcedModeChar, "GSC" ) == 0 ) || ( strcmp( forcedModeChar, "'GSC'" ) == 0 ) ) - { - return IVAS_ENC_FORCE_GSC; - } - if ( ( strcmp( forcedModeChar, "TCX" ) == 0 ) || ( strcmp( forcedModeChar, "'TCX'" ) == 0 ) -#ifdef SUPPORT_FORCE_TCX10_TCX20 - || ( strcmp( forcedModeChar, "TCX20" ) == 0 ) || ( strcmp( forcedModeChar, "'TCX20'" ) == 0 ) -#endif - ) - { -#ifdef SUPPORT_FORCE_TCX10_TCX20 - return IVAS_ENC_FORCE_TCX20; -#else - return IVAS_ENC_FORCE_TCX; -#endif - } -#ifdef SUPPORT_FORCE_TCX10_TCX20 - if ( ( strcmp( forcedModeChar, "TCX10" ) == 0 ) || ( strcmp( forcedModeChar, "'TCX10'" ) == 0 ) ) - { - return IVAS_ENC_FORCE_TCX10; - } -#endif - if ( ( strcmp( forcedModeChar, "HQ" ) == 0 ) || ( strcmp( forcedModeChar, "'HQ'" ) == 0 ) ) - { - return IVAS_ENC_FORCE_HQ; - } - - return IVAS_ENC_FORCE_UNDEFINED; -#endif -} - - -/*---------------------------------------------------------------------* - * readForcedMode() - * - * - *---------------------------------------------------------------------*/ - -static ivas_error readForcedMode( - FILE *file, - IVAS_ENC_FORCED_MODE *forcedMode, - int32_t *forceFrameCounter ) -{ - int16_t res; - char stmp[8]; - - if ( *forceFrameCounter == 0 ) - { - /* read next force and number of frames from the profile file */ - while ( ( res = (int16_t) fscanf( file, "%d %7s", forceFrameCounter, stmp ) ) != 2 && feof( file ) ) - { - rewind( file ); - } - - *forcedMode = parseForcedMode( stmp ); - - if ( *forcedMode == IVAS_ENC_FORCE_UNDEFINED ) - { - fprintf( stderr, "Error: incorect mode specification or the force profile file could not be opened: %s\n\n", stmp ); - return IVAS_ERR_WRONG_PARAMS; - } - - if ( res != 2 && !feof( file ) ) - { - fprintf( stderr, "Error: incorrect format of the force profile file (please ensure that it does not contain any empty lines)\n\n" ); - return IVAS_ERR_WRONG_PARAMS; - } - } - - /* current profile still active, only decrease the counter */ - ( *forceFrameCounter )--; - - return IVAS_ERR_OK; -} -#endif - - -#undef WMC_TOOL_SKIP diff --git a/readme.txt b/readme.txt index 1db279fc5..2e7fa84e0 100644 --- a/readme.txt +++ b/readme.txt @@ -33,13 +33,12 @@ These files represent the 3GPP EVS Codec Extension for Immersive Voice and Audio Services (IVAS) BASOP C simulation. All code is writtten -in ISO/IEC C99. The system is implemented as six separate programs: +in ISO/IEC C99. The system is implemented as five separate programs: IVAS_cod IVAS Encoder IVAS_dec IVAS Decoder IVAS_rend IVAS External Renderer ISAR_post_rend ISAR Post Renderer - IVAS_cod_fmtsw IVAS Encoder with support for format switching ambi_converter example program for Ambisonics format conversion For encoding using the coder program, the input is a binary @@ -144,8 +143,7 @@ The package includes a Makefile for gcc, which has been verified on "c-code" and typing the command: make. The resulting encoder/decoder/renderer/ ISAR_post_renderer executables are named "IVAS_cod", "IVAS_dec", "IVAS_rend", and "ISAR_post_rend". All reside in the c-code directory. In addition, this -directory will contain a version of the encoder with support for format switching -(named "IVAS_cod_fmtsw") and an example program for Ambisonics format conversion +directory will contain an example program for Ambisonics format conversion (named "ambi_converter"). The package also includes a solution-file for Microsoft Visual Studio 2017 (x86). @@ -154,8 +152,7 @@ To compile the code, please open "Workspace_msvc\Workspace_msvc.sln" and build renderer executable. The resulting encoder/decoder/renderer/ISAR_post_renderer executables are "IVAS_cod.exe", "IVAS_dec.exe", "IVAS_rend.exe", and "ISAR_post_rend.exe". All reside in the c-code main directory. In addition, this -directory will contain a version of the encoder with support for format switching -(named "IVAS_cod_fmtsw.exe") and an example program for Ambisonics format conversion +directory will contain an example program for Ambisonics format conversion (named "ambi_converter.exe"). @@ -424,17 +421,6 @@ the following conventions are supported: Either the input or the output convention must always be ACN-SN3D. -The usage of the "IVAS_cod_fmtsw" program is as follows: --------------------------------------------------------- - -Usage: IVAS_cod_fmtsw format_switching_file - -Mandatory parameters: ---------------------- -format_switching_file: Text file containing a valid encoder command line in each line - - - MULTICHANNEL LOUDSPEAKER INPUT / OUTPUT CONFIGURATIONS ====================================================== The loudspeaker positions for each MC layouts are assumed to have the following azimuth and elevation -- GitLab From 5d8e393c2a07ad5b28d88982b46cc30c54338f4d Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 23 Apr 2026 18:11:45 +0200 Subject: [PATCH 2/2] Update also Cmake --- CMakeLists.txt | 7 ------- 1 file changed, 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 70c4a6e20..01339ec2f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -208,12 +208,6 @@ if(WIN32) target_link_libraries(IVAS_cod Ws2_32) endif() -add_executable(IVAS_cod_fmtsw apps/encoder_fmtsw.c) -target_link_libraries(IVAS_cod_fmtsw lib_enc lib_util) -if(WIN32) - target_link_libraries(IVAS_cod_fmtsw Ws2_32) -endif() - add_executable(IVAS_dec apps/decoder.c) target_link_libraries(IVAS_dec lib_dec lib_util) if(WIN32) @@ -238,7 +232,6 @@ target_include_directories(ambi_converter PRIVATE lib_basop lib_util lib_com lib if(COPY_EXECUTABLES_FROM_BUILD_DIR) # Optionally copy executables to the same place where Make puts them (useful for tests that expect executables in specific places) add_custom_command(TARGET IVAS_cod POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_CURRENT_SOURCE_DIR}/") - add_custom_command(TARGET IVAS_cod_fmtsw POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_CURRENT_SOURCE_DIR}/") add_custom_command(TARGET IVAS_dec POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_CURRENT_SOURCE_DIR}/") add_custom_command(TARGET IVAS_rend POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_CURRENT_SOURCE_DIR}/") add_custom_command(TARGET ISAR_post_rend POST_BUILD VERBATIM COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_CURRENT_SOURCE_DIR}/") -- GitLab