From 000b42672515acd4c51cd2f6404e6ffafb3534dc Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 14 Oct 2025 13:26:46 +0200 Subject: [PATCH 1/5] port changes from MR 2132 (except for missing obj ed file stuff) --- apps/decoder.c | 5 +- lib_com/options.h | 1 + lib_com/tools.c | 6 ++ lib_debug/debug.c | 2 +- lib_rend/ivas_rom_rend.c | 6 ++ lib_rend/lib_rend.c | 80 +++++++++++++++++++++++++-- lib_util/aeid_file_reader.c | 4 +- lib_util/audio_file_reader.c | 2 +- lib_util/audio_file_writer.c | 2 +- lib_util/bitstream_reader.c | 7 +-- lib_util/bitstream_writer.c | 7 +-- lib_util/g192.c | 7 +-- lib_util/g192.h | 4 +- lib_util/ism_file_reader.c | 4 +- lib_util/ism_file_writer.c | 4 +- lib_util/jbm_file_reader.c | 4 +- lib_util/jbm_file_writer.c | 8 +-- lib_util/ls_custom_file_reader.c | 4 +- lib_util/masa_file_reader.c | 2 +- lib_util/masa_file_writer.c | 6 +- lib_util/mime_io.c | 4 ++ lib_util/render_config_reader.c | 2 +- lib_util/rotation_file_reader.c | 4 +- lib_util/rtpdump.c | 8 +++ lib_util/split_rend_bfi_file_reader.c | 4 +- lib_util/tinywavein_c.h | 8 +++ lib_util/tinywaveout_c.h | 38 +++++++++++++ lib_util/tsm_scale_file_reader.c | 4 +- lib_util/vector3_pair_file_reader.c | 4 +- 29 files changed, 192 insertions(+), 49 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 686c6ae0a..8446c70c3 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2036,8 +2036,12 @@ static ivas_error initOnFirstGoodFrame( } } +#ifdef CODE_IMPROVEMENTS + int16_t *zeroBuf = calloc( pcmFrameSize * sizeof( int16_t ) ); +#else int16_t *zeroBuf = malloc( pcmFrameSize * sizeof( int16_t ) ); memset( zeroBuf, 0, pcmFrameSize * sizeof( int16_t ) ); +#endif for ( int16_t i = 0; i < numInitialBadFrames; ++i ) { @@ -2061,7 +2065,6 @@ static ivas_error initOnFirstGoodFrame( } else { - if ( *pRemainingDelayNumSamples < *numOutSamples ) { if ( ( error = AudioFileWriter_write( *ppAfWriter, zeroBuf, *numOutSamples * *pNumOutChannels - ( *pRemainingDelayNumSamples * *pNumOutChannels ) ) ) != IVAS_ERR_OK ) diff --git a/lib_com/options.h b/lib_com/options.h index be5ac3943..9bb4597f0 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -211,6 +211,7 @@ #define NONBE_1200_ISM_JBM_BRATE_SW_FLUSH /* VA: issue 1200: fix bug in renderer flush in ISM JBM bitrate switching */ #define NONBE_1293_CRASH_FIRST_FRAME_LOST /* VA: issue 1293: fix G.192 decoder crash when first frame is lost */ #define FIX_1384_MSAN_stereo_tcx_core_enc /* VA: issue 1384: fix use-of-uninitialized value in stereo_tcx_core_enc() */ +#define CODE_IMPROVEMENTS // object-editing feature porting #define OBJ_EDITING_API /* object editing changes related to the API */ diff --git a/lib_com/tools.c b/lib_com/tools.c index 6945a9575..27673d200 100644 --- a/lib_com/tools.c +++ b/lib_com/tools.c @@ -1742,6 +1742,11 @@ double anint( int16_t is_numeric_float( float x ) { +#ifdef CODE_IMPROVEMENTS +#define WMC_TOOL_SKIP + return (int16_t) ( !isnan( x ) && !isinf( x ) ); +#undef WMC_TOOL_SKIP +#else union float_int { float float_val; @@ -1751,6 +1756,7 @@ int16_t is_numeric_float( float_int.float_val = x; return ( ( float_int.int_val & 0x7f800000 ) != 0x7f800000 ); +#endif } /*-------------------------------------------------------------------* diff --git a/lib_debug/debug.c b/lib_debug/debug.c index d8cdd6c8b..77823632b 100644 --- a/lib_debug/debug.c +++ b/lib_debug/debug.c @@ -838,7 +838,7 @@ int16_t make_dirs( const char *const pathname ) if ( sep != 0 ) { - temp = calloc( 1, strlen( pathname ) + 1 ); + temp = calloc( strlen( pathname ) + 1, sizeof( char ) ); p = pathname; while ( ( p = strchr( p, sep ) ) != NULL ) { diff --git a/lib_rend/ivas_rom_rend.c b/lib_rend/ivas_rom_rend.c index bf6776ab0..b14a5303a 100644 --- a/lib_rend/ivas_rom_rend.c +++ b/lib_rend/ivas_rom_rend.c @@ -163,9 +163,15 @@ const float ap_lattice_coeffs_3[DIRAC_DECORR_FILTER_LEN_3*DIRAC_MAX_NUM_DECORR_F const float * const ap_lattice_coeffs[DIRAC_DECORR_NUM_SPLIT_BANDS] = { +#ifdef CODE_IMPROVEMENTS + ap_lattice_coeffs_1, + ap_lattice_coeffs_2, + ap_lattice_coeffs_3, +#else &ap_lattice_coeffs_1[0], &ap_lattice_coeffs_2[0], &ap_lattice_coeffs_3[0], +#endif }; const float ap_split_frequencies[DIRAC_DECORR_NUM_SPLIT_BANDS + 1] = diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 07c3d6086..45e0fd135 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -3374,31 +3374,78 @@ static ivas_error getConstInputById( return IVAS_ERR_OK; } +#ifdef CODE_IMPROVEMENTS +static void *getInputByIndex( + void *inputsArray, + const size_t index, + const IVAS_REND_AudioConfigType inputType ) +{ + switch ( inputType ) + { + case IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED: + return (input_mc *) inputsArray + index; + case IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS: + return (input_sba *) inputsArray + index; + case IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED: + return (input_ism *) inputsArray + index; + case IVAS_REND_AUDIO_CONFIG_TYPE_MASA: + return (input_masa *) inputsArray + index; + default: + /* this should be unreachable */ + assert( 0 ); + return NULL; + } +} +#endif static ivas_error findFreeInputSlot( +#ifdef CODE_IMPROVEMENTS + void *inputs, + const IVAS_REND_AudioConfigType inputType, +#else const void *inputs, const int32_t inputStructSize, +#endif const int32_t maxInputs, int32_t *inputIndex ) { +#ifdef CODE_IMPROVEMENTS + /* Using a void pointer and a separately provided type is a hack for this function + to be reusable for arrays of any input type (input_ism, input_mc, input_sba, input_masa). + Assumptions: + - input_base is always the first member in the input struct + - memory alignments of original input type and input_base are the same + */ +#else /* Using a void pointer and a separately provided size is a hack for this function to be reusable for arrays of any input type (input_ism, input_mc, input_sba, input_masa). Assumptions: - input_base is always the first member in the input struct - provided size is correct */ +#endif int32_t i; bool canAddInput; +#ifndef CODE_IMPROVEMENTS const uint8_t *pByte; +#endif const input_base *pInputBase; canAddInput = false; /* Find first unused input in array */ +#ifdef CODE_IMPROVEMENTS + for ( i = 0; i < maxInputs; ++i ) +#else for ( i = 0, pByte = inputs; i < maxInputs; ++i, pByte += inputStructSize ) +#endif { +#ifdef CODE_IMPROVEMENTS + pInputBase = (const input_base *) getInputByIndex( inputs, i, inputType ); +#else pInputBase = (const input_base *) pByte; +#endif if ( pInputBase->inConfig == IVAS_AUDIO_CONFIG_INVALID ) { @@ -3538,7 +3585,11 @@ ivas_error IVAS_REND_AddInput( ivas_error error; int32_t maxNumInputsOfType; void *inputsArray; +#ifdef CODE_IMPROVEMENTS + IVAS_REND_AudioConfigType inputType; +#else int32_t inputStructSize; +#endif ivas_error ( *activateInput )( void *, AUDIO_CONFIG, IVAS_REND_InputId, RENDER_CONFIG_DATA *, hrtf_handles *hrtfs ); int32_t inputIndex; @@ -3559,44 +3610,65 @@ ivas_error IVAS_REND_AddInput( } } +#ifdef CODE_IMPROVEMENTS + inputType = getAudioConfigType( inConfig ); + switch ( inputType ) +#else switch ( getAudioConfigType( inConfig ) ) +#endif { case IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED: maxNumInputsOfType = RENDERER_MAX_ISM_INPUTS; inputsArray = hIvasRend->inputsIsm; +#ifndef CODE_IMPROVEMENTS inputStructSize = sizeof( *hIvasRend->inputsIsm ); +#endif activateInput = setRendInputActiveIsm; break; case IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED: maxNumInputsOfType = RENDERER_MAX_MC_INPUTS; inputsArray = hIvasRend->inputsMc; +#ifndef CODE_IMPROVEMENTS inputStructSize = sizeof( *hIvasRend->inputsMc ); +#endif activateInput = setRendInputActiveMc; break; case IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS: maxNumInputsOfType = RENDERER_MAX_SBA_INPUTS; inputsArray = hIvasRend->inputsSba; +#ifndef CODE_IMPROVEMENTS inputStructSize = sizeof( *hIvasRend->inputsSba ); +#endif activateInput = setRendInputActiveSba; break; case IVAS_REND_AUDIO_CONFIG_TYPE_MASA: maxNumInputsOfType = RENDERER_MAX_MASA_INPUTS; inputsArray = hIvasRend->inputsMasa; +#ifndef CODE_IMPROVEMENTS inputStructSize = sizeof( *hIvasRend->inputsMasa ); +#endif activateInput = setRendInputActiveMasa; break; default: return IVAS_ERR_INVALID_INPUT_FORMAT; } - /* Find first free input in array corresponding to input type */ + /* Find first free input in array corresponding to input type */ +#ifdef CODE_IMPROVEMENTS + if ( ( error = findFreeInputSlot( inputsArray, inputType, maxNumInputsOfType, &inputIndex ) ) != IVAS_ERR_OK ) +#else if ( ( error = findFreeInputSlot( inputsArray, inputStructSize, maxNumInputsOfType, &inputIndex ) ) != IVAS_ERR_OK ) +#endif { return error; } *inputId = makeInputId( inConfig, inputIndex ); +#ifdef CODE_IMPROVEMENTS + if ( ( error = activateInput( getInputByIndex( inputsArray, inputIndex, inputType ), inConfig, *inputId, hIvasRend->hRendererConfig, &hIvasRend->hHrtfs ) ) != IVAS_ERR_OK ) +#else if ( ( error = activateInput( (uint8_t *) inputsArray + inputStructSize * inputIndex, inConfig, *inputId, hIvasRend->hRendererConfig, &hIvasRend->hHrtfs ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -7363,8 +7435,8 @@ ivas_error IVAS_REND_MergeMasaMetadata( ) { MASA_DECODER_EXT_OUT_META_HANDLE inMeta2; - float( *inEne1 )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - float( *inEne2 )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + float ( *inEne1 )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + float ( *inEne2 )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; if ( hIvasRend == NULL ) { @@ -7651,7 +7723,7 @@ static ivas_error getSamplesInternal( &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, - ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), + (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, diff --git a/lib_util/aeid_file_reader.c b/lib_util/aeid_file_reader.c index 83dd4b4e1..00352143a 100644 --- a/lib_util/aeid_file_reader.c +++ b/lib_util/aeid_file_reader.c @@ -69,9 +69,9 @@ ivas_error aeidFileReader_open( return IVAS_ERR_FAILED_FILE_OPEN; } - self = calloc( sizeof( aeidFileReader ), 1 ); + self = calloc( 1, sizeof( aeidFileReader ) ); self->aeidFile = aeidFile; - self->file_path = calloc( sizeof( char ), strlen( aeidFilePath ) + 1 ); + self->file_path = calloc( strlen( aeidFilePath ) + 1, sizeof( char ) ); strcpy( self->file_path, aeidFilePath ); *aeidReader = self; diff --git a/lib_util/audio_file_reader.c b/lib_util/audio_file_reader.c index ca5e6e496..9d065b9f5 100644 --- a/lib_util/audio_file_reader.c +++ b/lib_util/audio_file_reader.c @@ -97,7 +97,7 @@ ivas_error AudioFileReader_open( { return IVAS_ERR_FAILED_FILE_OPEN; } - self = calloc( sizeof( AudioFileReader ), 1 ); + self = calloc( 1, sizeof( AudioFileReader ) ); self->samplingRate = 0; self->numChannels = 0; diff --git a/lib_util/audio_file_writer.c b/lib_util/audio_file_writer.c index fb7a64c42..67b54d3a0 100644 --- a/lib_util/audio_file_writer.c +++ b/lib_util/audio_file_writer.c @@ -90,7 +90,7 @@ ivas_error AudioFileWriter_open( return IVAS_ERR_FAILED_FILE_OPEN; } - self = calloc( sizeof( AudioFileWriter ), 1 ); + self = calloc( 1, sizeof( AudioFileWriter ) ); if ( self == NULL ) { return IVAS_ERR_FAILED_ALLOC; diff --git a/lib_util/bitstream_reader.c b/lib_util/bitstream_reader.c index 45c82ed4c..00fb6d9f3 100644 --- a/lib_util/bitstream_reader.c +++ b/lib_util/bitstream_reader.c @@ -204,16 +204,15 @@ static void init_for_mime( BS_READER_HANDLE hBsReader ) static ivas_error init_for_format( BS_READER_HANDLE *phBsReader, BS_READER_FORMAT format ) { /* Allocate memory under handle and check if allocation successful */ - ( *phBsReader ) = (BS_READER_HANDLE) malloc( sizeof( struct BS_Reader ) ); + /* Initialize all struct members to NULL - supported functions + * will be overwritten below in init_for_ */ + ( *phBsReader ) = (BS_READER_HANDLE) calloc( 1, sizeof( struct BS_Reader ) ); if ( *phBsReader == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "could not allocate bitstream reader" ); } - /* Initialize all struct members to NULL - supported functions - * will be overwritten below in init_for_ */ BS_READER_HANDLE hBsReader = *phBsReader; - memset( hBsReader, 0, sizeof( struct BS_Reader ) ); /* Set function pointers to selected format */ switch ( format ) diff --git a/lib_util/bitstream_writer.c b/lib_util/bitstream_writer.c index 8c4b64cd4..bff9f461b 100644 --- a/lib_util/bitstream_writer.c +++ b/lib_util/bitstream_writer.c @@ -156,16 +156,15 @@ static void init_for_mime( BS_WRITER_HANDLE hBsWriter ) static ivas_error init_for_format( BS_WRITER_HANDLE *phBsWriter, BS_WRITER_FORMAT format ) { /* Allocate memory under handle and check if allocation successful */ - ( *phBsWriter ) = (BS_WRITER_HANDLE) malloc( sizeof( struct BS_Writer ) ); + /* Initialize all struct members to NULL - supported functions + * will be overwritten below in init_for_ */ + ( *phBsWriter ) = (BS_WRITER_HANDLE) calloc( 1, sizeof( struct BS_Writer ) ); if ( *phBsWriter == NULL ) { IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "could not allocate bitstream writer" ); } - /* Initialize all struct members to NULL - supported functions - * will be overwritten below in init_for_ */ BS_WRITER_HANDLE hBsWriter = *phBsWriter; - memset( hBsWriter, 0, sizeof( struct BS_Writer ) ); /* Set function pointers to selected format */ switch ( format ) diff --git a/lib_util/g192.c b/lib_util/g192.c index f61971ef1..a96a8ee56 100644 --- a/lib_util/g192.c +++ b/lib_util/g192.c @@ -62,7 +62,7 @@ *-----------------------------------------------------------------------*/ /* main handle */ -struct __G192 +struct G192_STRUCT { FILE *file; int16_t ownFileHandle; /* flag whether FILE handle created by instance or externally */ @@ -79,12 +79,11 @@ G192_ERROR G192_Reader_Open_filename( const char *filename ) { /* create handle */ - *phG192 = (G192_HANDLE) calloc( 1, sizeof( struct __G192 ) ); + *phG192 = (G192_HANDLE) calloc( 1, sizeof( struct G192_STRUCT ) ); if ( !phG192 ) { return G192_MEMORY_ERROR; } - memset( *phG192, 0, sizeof( struct __G192 ) ); /* open file stream */ ( *phG192 )->file = fopen( filename, "rb" ); @@ -422,7 +421,7 @@ G192_ERROR G192_Writer_Open_filename( const char *filename ) { /* create handle */ - *phG192 = (G192_HANDLE) calloc( 1, sizeof( struct __G192 ) ); + *phG192 = (G192_HANDLE) calloc( 1, sizeof( struct G192_STRUCT ) ); if ( !phG192 ) { return G192_MEMORY_ERROR; diff --git a/lib_util/g192.h b/lib_util/g192.h index 8014f5236..751f1324f 100644 --- a/lib_util/g192.h +++ b/lib_util/g192.h @@ -67,8 +67,8 @@ typedef enum _G192_ERROR *-----------------------------------------------------------------------*/ /* main handle */ -struct __G192; -typedef struct __G192 *G192_HANDLE; +struct G192_STRUCT; +typedef struct G192_STRUCT *G192_HANDLE; /*-----------------------------------------------------------------------* diff --git a/lib_util/ism_file_reader.c b/lib_util/ism_file_reader.c index 088a4134f..83a32b7a0 100644 --- a/lib_util/ism_file_reader.c +++ b/lib_util/ism_file_reader.c @@ -72,9 +72,9 @@ IsmFileReader *IsmFileReader_open( return NULL; } - self = calloc( sizeof( IsmFileReader ), 1 ); + self = calloc( 1, sizeof( IsmFileReader ) ); self->file = file; - self->file_path = calloc( sizeof( char ), strlen( filePath ) + 1 ); + self->file_path = calloc( strlen( filePath ) + 1, sizeof( char ) ); strcpy( self->file_path, filePath ); return self; diff --git a/lib_util/ism_file_writer.c b/lib_util/ism_file_writer.c index fff4cc4ff..10efc1ea3 100644 --- a/lib_util/ism_file_writer.c +++ b/lib_util/ism_file_writer.c @@ -81,9 +81,9 @@ ivas_error IsmFileWriter_open( return IVAS_ERR_FAILED_FILE_OPEN; } - self = calloc( sizeof( IsmFileWriter ), 1 ); + self = calloc( 1, sizeof( IsmFileWriter ) ); self->file = file; - self->file_path = calloc( sizeof( char ), strlen( filePath ) + 1 ); + self->file_path = calloc( strlen( filePath ) + 1, sizeof( char ) ); strcpy( self->file_path, filePath ); *ismWriter = self; diff --git a/lib_util/jbm_file_reader.c b/lib_util/jbm_file_reader.c index b657ab789..68caf5ae7 100644 --- a/lib_util/jbm_file_reader.c +++ b/lib_util/jbm_file_reader.c @@ -68,9 +68,9 @@ JbmFileReader *JbmFileReader_open( return NULL; } - self = calloc( sizeof( JbmFileReader ), 1 ); + self = calloc( 1, sizeof( JbmFileReader ) ); self->file = file; - self->file_path = calloc( sizeof( char ), strlen( filePath ) + 1 ); + self->file_path = calloc( strlen( filePath ) + 1, sizeof( char ) ); strcpy( self->file_path, filePath ); return self; diff --git a/lib_util/jbm_file_writer.c b/lib_util/jbm_file_writer.c index 76a5a67d2..9d11dad90 100644 --- a/lib_util/jbm_file_writer.c +++ b/lib_util/jbm_file_writer.c @@ -77,9 +77,9 @@ ivas_error JbmOffsetFileWriter_open( return IVAS_ERR_FAILED_FILE_OPEN; } - self = calloc( sizeof( JbmOffsetFileWriter ), 1 ); + self = calloc( 1, sizeof( JbmOffsetFileWriter ) ); self->file = file; - self->file_path = calloc( sizeof( char ), strlen( jbmOffsetFilename ) + 1 ); + self->file_path = calloc( strlen( jbmOffsetFilename ) + 1, sizeof( char ) ); strcpy( self->file_path, jbmOffsetFilename ); *jbmOffsetWriter = self; @@ -204,9 +204,9 @@ ivas_error JbmTraceFileWriter_open( fprintf( file, "#rtpSeqNo;rtpTs;rcvTime;playTime;active\n" ); - self = calloc( sizeof( JbmTraceFileWriter ), 1 ); + self = calloc( 1, sizeof( JbmTraceFileWriter ) ); self->file = file; - self->file_path = calloc( sizeof( char ), strlen( jbmTraceFilename ) + 1 ); + self->file_path = calloc( strlen( jbmTraceFilename ) + 1, sizeof( char ) ); strcpy( self->file_path, jbmTraceFilename ); *jbmTraceWriter = self; diff --git a/lib_util/ls_custom_file_reader.c b/lib_util/ls_custom_file_reader.c index 01d1f0307..fbf9a2308 100644 --- a/lib_util/ls_custom_file_reader.c +++ b/lib_util/ls_custom_file_reader.c @@ -71,9 +71,9 @@ ivas_error CustomLsReader_open( return IVAS_ERR_FAILED_FILE_OPEN; } - self = calloc( sizeof( LsCustomFileReader ), 1 ); + self = calloc( 1, sizeof( LsCustomFileReader ) ); self->file = lsFile; - self->file_path = calloc( sizeof( char ), strlen( LsFilePath ) + 1 ); + self->file_path = calloc( strlen( LsFilePath ) + 1, sizeof( char ) ); strcpy( self->file_path, LsFilePath ); *hLsCustomReader = self; diff --git a/lib_util/masa_file_reader.c b/lib_util/masa_file_reader.c index 73396eeb6..7783cad05 100644 --- a/lib_util/masa_file_reader.c +++ b/lib_util/masa_file_reader.c @@ -70,7 +70,7 @@ MasaFileReader *MasaFileReader_open( return NULL; } - self = calloc( sizeof( MasaFileReader ), 1 ); + self = calloc( 1, sizeof( MasaFileReader ) ); self->file = file; generate_gridEq( &self->sph_grid16 ); diff --git a/lib_util/masa_file_writer.c b/lib_util/masa_file_writer.c index f3431a2b6..c1aa3ca37 100644 --- a/lib_util/masa_file_writer.c +++ b/lib_util/masa_file_writer.c @@ -209,14 +209,14 @@ ivas_error MasaFileWriter_open( return IVAS_ERR_FAILED_FILE_OPEN; } - self = calloc( sizeof( MasaFileWriter ), 1 ); + self = calloc( 1, sizeof( MasaFileWriter ) ); self->file = file; - self->file_path = calloc( sizeof( char ), strlen( filePath ) + 1 ); + self->file_path = calloc( strlen( filePath ) + 1, sizeof( char ) ); strcpy( self->file_path, filePath ); if ( !delayCompensationEnabled ) { - self->delayStorage = calloc( sizeof( MASA_META_DELAY_STORAGE ), 1 ); + self->delayStorage = calloc( 1, sizeof( MASA_META_DELAY_STORAGE ) ); self->delayStorage->prevDelay = DELAY_MASA_PARAM_DEC_SFR; } diff --git a/lib_util/mime_io.c b/lib_util/mime_io.c index 9bdd20e45..ee2a9c12a 100644 --- a/lib_util/mime_io.c +++ b/lib_util/mime_io.c @@ -317,7 +317,11 @@ static bool readByte( FILE *file, uint8_t *value ) static bool readLong( FILE *file, uint16_t *value ) { char buffer[4] = { 0 }; +#ifdef CODE_IMPROVEMENTS + if ( fread( buffer, 1, 4, file ) != 1U ) +#else if ( fread( buffer, 4, 1, file ) != 1U ) +#endif { return false; } diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 829152e1d..74b3db67a 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -1359,7 +1359,7 @@ ivas_error RenderConfigReader_open( return IVAS_ERR_FAILED_FILE_OPEN; } - pSelf = calloc( sizeof( RenderConfigReader ), 1 ); + pSelf = calloc( 1, sizeof( RenderConfigReader ) ); pSelf->pConfigFile = pConfigFile; pSelf->nFG = 0; pSelf->pFG = NULL; diff --git a/lib_util/rotation_file_reader.c b/lib_util/rotation_file_reader.c index b948a5152..cdf2582e8 100644 --- a/lib_util/rotation_file_reader.c +++ b/lib_util/rotation_file_reader.c @@ -73,10 +73,10 @@ ivas_error RotationFileReader_open( return IVAS_ERR_FAILED_FILE_OPEN; } - self = calloc( sizeof( RotFileReader ), 1 ); + self = calloc( 1, sizeof( RotFileReader ) ); self->trajFile = trajFile; self->frameCounter = 0; - self->file_path = calloc( sizeof( char ), strlen( trajFilePath ) + 1 ); + self->file_path = calloc( strlen( trajFilePath ) + 1, sizeof( char ) ); strcpy( self->file_path, trajFilePath ); self->fileRewind = false; diff --git a/lib_util/rtpdump.c b/lib_util/rtpdump.c index e3eb4c1f4..dfa15a9da 100644 --- a/lib_util/rtpdump.c +++ b/lib_util/rtpdump.c @@ -80,7 +80,11 @@ static unsigned char *parseByte( unsigned char *buffer, unsigned char *value ) static int readLong( FILE *file, unsigned int *value ) { char buffer[4] = { 0 }; +#ifdef CODE_IMPROVEMENTS + if ( fread( buffer, 1, 4, file ) != 1U ) +#else if ( fread( buffer, 4, 1, file ) != 1U ) +#endif { return -1; } @@ -96,7 +100,11 @@ static int readLong( FILE *file, unsigned int *value ) static int readShort( FILE *file, unsigned short *value ) { char buffer[2] = { 0 }; +#ifdef CODE_IMPROVEMENTS + if ( fread( buffer, 1, 2, file ) != 1U ) +#else if ( fread( buffer, 2, 1, file ) != 1U ) +#endif { return -1; } diff --git a/lib_util/split_rend_bfi_file_reader.c b/lib_util/split_rend_bfi_file_reader.c index 1573db5a9..38b843105 100644 --- a/lib_util/split_rend_bfi_file_reader.c +++ b/lib_util/split_rend_bfi_file_reader.c @@ -75,10 +75,10 @@ ivas_error SplitRendBFIFileReader_open( txtfile = ( strcmp( bfiFilePath + strlen( bfiFilePath ) - 4, ".txt" ) ? false : true ); - self = calloc( sizeof( SplitRendBFIFileReader ), 1 ); + self = calloc( 1, sizeof( SplitRendBFIFileReader ) ); self->bfiFile = bfiFile; self->frameCounter = 0; - self->file_path = calloc( sizeof( char ), strlen( bfiFilePath ) + 1 ); + self->file_path = calloc( strlen( bfiFilePath ) + 1, sizeof( char ) ); strcpy( self->file_path, bfiFilePath ); self->fileRewind = false; self->txtfile = txtfile; diff --git a/lib_util/tinywavein_c.h b/lib_util/tinywavein_c.h index b86d97c96..179c676a8 100644 --- a/lib_util/tinywavein_c.h +++ b/lib_util/tinywavein_c.h @@ -54,14 +54,22 @@ #define __TWI_SUCCESS ( 0 ) #define __TWI_ERROR ( -1 ) +#ifdef CODE_IMPROVEMENTS +typedef struct tinyWaveInHandle +#else typedef struct __tinyWaveInHandle +#endif { FILE *theFile; fpos_t dataChunkPos; uint32_t position; uint32_t length; uint32_t bps; +#ifdef CODE_IMPROVEMENTS +} tinyWaveInHandle, WAVEFILEIN; +#else } __tinyWaveInHandle, WAVEFILEIN; +#endif typedef struct { diff --git a/lib_util/tinywaveout_c.h b/lib_util/tinywaveout_c.h index 693beccf9..70373e3cc 100644 --- a/lib_util/tinywaveout_c.h +++ b/lib_util/tinywaveout_c.h @@ -70,15 +70,27 @@ #endif #endif +#ifdef CODE_IMPROVEMENTS +typedef struct tinyWaveOutHeader +#else typedef struct __tinyWaveOutHeader +#endif { uint32_t riffType; /* 'RIFF' */ uint32_t riffSize; /* file size */ uint32_t waveType; /* 'WAVE' */ +#ifdef CODE_IMPROVEMENTS +} tinyWaveOutHeader; +#else } __tinyWaveOutHeader; +#endif +#ifdef CODE_IMPROVEMENTS +typedef struct tinyWaveOutFmtChunk +#else typedef struct __tinyWaveOutFmtChunk +#endif { uint32_t formatType; uint32_t formatSize; @@ -91,16 +103,32 @@ typedef struct __tinyWaveOutFmtChunk uint16_t bitsPerSample; /* wav fmt ext hdr here */ +#ifdef CODE_IMPROVEMENTS +} tinyWaveOutFmtChunk; +#else } __tinyWaveOutFmtChunk; +#endif +#ifdef CODE_IMPROVEMENTS +typedef struct tinyWaveOutDataChunk +#else typedef struct __tinyWaveOutDataChunk +#endif { uint32_t dataType; uint32_t dataSize; +#ifdef CODE_IMPROVEMENTS +} tinyWaveOutDataChunk; +#else } __tinyWaveOutDataChunk; +#endif +#ifdef CODE_IMPROVEMENTS +typedef struct tinyWaveOutHandle +#else typedef struct __tinyWaveOutHandle +#endif { FILE *theFile; uint32_t dataSize; @@ -109,7 +137,11 @@ typedef struct __tinyWaveOutHandle uint32_t dataChunkOffset; uint32_t bps; uint32_t clipCount; +#ifdef CODE_IMPROVEMENTS +} tinyWaveOutHandle, WAVEFILEOUT; +#else } __tinyWaveOutHandle, WAVEFILEOUT; +#endif /*--- local protos --------------------------------------------------*/ static __inline uint32_t BigEndian32( char, char, char, char ); @@ -132,9 +164,15 @@ static WAVEFILEOUT *CreateBWF( /* ,const uint32_t writeWaveExt */ ) { WAVEFILEOUT *self; +#ifdef CODE_IMPROVEMENTS + tinyWaveOutHeader whdr; + tinyWaveOutFmtChunk wfch; + tinyWaveOutDataChunk wdch; +#else __tinyWaveOutHeader whdr; __tinyWaveOutFmtChunk wfch; __tinyWaveOutDataChunk wdch; +#endif uint32_t blockAlignment = 0; uint32_t ByteCnt = 0; /* Byte counter for fwrite */ diff --git a/lib_util/tsm_scale_file_reader.c b/lib_util/tsm_scale_file_reader.c index e61f80763..951227d3d 100644 --- a/lib_util/tsm_scale_file_reader.c +++ b/lib_util/tsm_scale_file_reader.c @@ -73,9 +73,9 @@ TsmScaleFileReader *TsmScaleFileReader_open( return NULL; } - self = calloc( sizeof( TsmScaleFileReader ), 1 ); + self = calloc( 1, sizeof( TsmScaleFileReader ) ); self->file = file; - self->file_path = calloc( sizeof( char ), strlen( filePath ) + 1 ); + self->file_path = calloc( strlen( filePath ) + 1, sizeof( char ) ); strcpy( self->file_path, filePath ); return self; diff --git a/lib_util/vector3_pair_file_reader.c b/lib_util/vector3_pair_file_reader.c index a6aee3eef..474c2c810 100644 --- a/lib_util/vector3_pair_file_reader.c +++ b/lib_util/vector3_pair_file_reader.c @@ -72,9 +72,9 @@ ivas_error Vector3PairFileReader_open( return IVAS_ERR_FAILED_FILE_OPEN; } - self = calloc( sizeof( Vector3PairFileReader ), 1 ); + self = calloc( 1, sizeof( Vector3PairFileReader ) ); self->trajFile = trajFile; - self->file_path = calloc( sizeof( char ), strlen( trajFilePath ) + 1 ); + self->file_path = calloc( strlen( trajFilePath ) + 1, sizeof( char ) ); strcpy( self->file_path, trajFilePath ); *vector3PairReader = self; -- GitLab From d8cd0d64f1a7cf3a7c2e3f5f3a59e9e8e081bedb Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 14 Oct 2025 13:29:39 +0200 Subject: [PATCH 2/5] port changes from MR 2191 --- lib_com/tools.c | 4 +++- lib_rend/lib_rend.c | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib_com/tools.c b/lib_com/tools.c index 27673d200..45e794148 100644 --- a/lib_com/tools.c +++ b/lib_com/tools.c @@ -1743,9 +1743,11 @@ int16_t is_numeric_float( float x ) { #ifdef CODE_IMPROVEMENTS + int16_t retval; #define WMC_TOOL_SKIP - return (int16_t) ( !isnan( x ) && !isinf( x ) ); + retval = (int16_t) ( !isnan( x ) && !isinf( x ) ); #undef WMC_TOOL_SKIP + return retval; #else union float_int { diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 45e0fd135..8a9c479e1 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -3391,10 +3391,13 @@ static void *getInputByIndex( case IVAS_REND_AUDIO_CONFIG_TYPE_MASA: return (input_masa *) inputsArray + index; default: - /* this should be unreachable */ - assert( 0 ); - return NULL; + break; } + /* this should be unreachable */ + assert( 0 ); + + /* include a final return to make the linter happy and avoid problems with wmc_tool (see #1355) */ + return NULL; } #endif -- GitLab From c058aa452d40e564a89447c7bd572975db484fce Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 14 Oct 2025 13:34:18 +0200 Subject: [PATCH 3/5] run clang-format --- lib_rend/lib_rend.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 8a9c479e1..fe5b597f6 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -7438,8 +7438,8 @@ ivas_error IVAS_REND_MergeMasaMetadata( ) { MASA_DECODER_EXT_OUT_META_HANDLE inMeta2; - float ( *inEne1 )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - float ( *inEne2 )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + float( *inEne1 )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + float( *inEne2 )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; if ( hIvasRend == NULL ) { @@ -7726,7 +7726,7 @@ static ivas_error getSamplesInternal( &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, - (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), + ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, -- GitLab From ef8361b0e3d6d368e185d4c7abf5fcf3c298f11d Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 14 Oct 2025 13:36:45 +0200 Subject: [PATCH 4/5] fix compilation --- apps/decoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/decoder.c b/apps/decoder.c index 8446c70c3..c15ef7f2c 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2037,7 +2037,7 @@ static ivas_error initOnFirstGoodFrame( } #ifdef CODE_IMPROVEMENTS - int16_t *zeroBuf = calloc( pcmFrameSize * sizeof( int16_t ) ); + int16_t *zeroBuf = calloc( pcmFrameSize, sizeof( int16_t ) ); #else int16_t *zeroBuf = malloc( pcmFrameSize * sizeof( int16_t ) ); memset( zeroBuf, 0, pcmFrameSize * sizeof( int16_t ) ); -- GitLab From 0a9042acf0adee3841fd2a41c5f272e256725caa Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 21 Oct 2025 10:32:22 +0200 Subject: [PATCH 5/5] port changes in previously missing file --- lib_util/obj_edit_file_reader.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_util/obj_edit_file_reader.c b/lib_util/obj_edit_file_reader.c index 62c12bd3f..336e69a87 100644 --- a/lib_util/obj_edit_file_reader.c +++ b/lib_util/obj_edit_file_reader.c @@ -70,13 +70,13 @@ ivas_error ObjectEditFileReader_open( return IVAS_ERR_FAILED_FILE_OPEN; } - self = (ObjectEditFileReader *) calloc( sizeof( ObjectEditFileReader ), 1 ); + self = (ObjectEditFileReader *) calloc( 1, sizeof( ObjectEditFileReader ) ); self->maxLineLen = 256; self->editFileHandle = fileHandle; - self->inLine = (char *) calloc( sizeof( char ), self->maxLineLen ); + self->inLine = (char *) calloc( self->maxLineLen, sizeof( char ) ); - self->readInfo = (ReadObjectEditInfo *) calloc( sizeof( ReadObjectEditInfo ), 1 ); + self->readInfo = (ReadObjectEditInfo *) calloc( 1, sizeof( ReadObjectEditInfo ) ); self->readInfo->bg_gain = 0.0f; self->readInfo->bg_gain_edited = false; -- GitLab