diff --git a/apps/decoder.c b/apps/decoder.c index 410d0c50298996ec598ca7deeb78e999857eab81..ac73553e7f0816edd6bd0dd0b7086f8f723b6aac 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1678,13 +1678,13 @@ static ivas_error initOnFirstGoodFrame( return error; } - int16_t *zeroBuf = malloc( pcmFrameSize * sizeof( int16_t ) ); + /* Write zeros to the output audio buffer */ + int16_t *zeroBuf = calloc( pcmFrameSize, sizeof( int16_t ) ); if ( zeroBuf == NULL ) { fprintf( stdout, "Error: Unable to allocate memory for output buffer.\n" ); return IVAS_ERR_FAILED_ALLOC; } - memset( zeroBuf, 0, pcmFrameSize * sizeof( int16_t ) ); for ( int16_t i = 0; i < numInitialBadFrames; ++i ) { diff --git a/lib_com/options.h b/lib_com/options.h index 2fad81542f641df9a052c3086668ea4bfd482f4a..181fc48743af514ff52538e6d989500fe2918770 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -111,7 +111,7 @@ #define FIX_RENDERER_STACK /* VA: issue 1322: reduction of renderers' buffers size */ #define FIX_1370_EXTERNAL_ORIENTATION_CHECK /* Nokia: add sanity check for Euler angles for external orientations */ #define FIX_1413_IGF_INIT_PRINTOUT /* FhG: use correct variable for IGF initiliazation */ - +#define CODE_IMPROVEMENTS // object-editing feature porting #define TMP_FIX_SPLIT_REND // temporary fix to split-rendering (it follows the later state of the framework but it is needed now because of current test-conditions) diff --git a/lib_debug/debug.c b/lib_debug/debug.c index ee6040fafc840e9ff52aac4e3418b02a6c8935cb..f9b0e34c3d44bbbfc4c40ae16464fc3dfa83caac 100644 --- a/lib_debug/debug.c +++ b/lib_debug/debug.c @@ -836,7 +836,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_fx.c b/lib_rend/ivas_rom_rend_fx.c index 467061cdd862d7290f19cd8fc82c46735fde66e7..f3f034c4da5bec02aa566575979e8cc8309a7f87 100644 --- a/lib_rend/ivas_rom_rend_fx.c +++ b/lib_rend/ivas_rom_rend_fx.c @@ -81,9 +81,15 @@ const Word32 ap_lattice_coeffs_2_fx[132] /* Q31 */ = { 1360843264, 1462880896, const Word32 ap_lattice_coeffs_3_fx[66] /* Q31 */ = { 1360843264, 1462880896, -106124344, 615715776, 313579872, 290773568, -880779712, -444026592, -1410828032, -218497872, 936944960, 729753600, -282142848, -1661606912, -647739072, 703431872, 713452032, 442076704, 1541038592, -1186205568, -322414592, 117158120, 514363136, -1392593792, -1550156800, 406684000, 146426176, 13348758, 165409920, 83060376, 909276800, -233341280, 927820288, -890434752, 596656832, 898691840, 167097856, -607873152, -766668864, 9951439, -950562176, -799540352, 866157440, 521887904, 675097984, 954584384, 746287104, 1065244224, 232804400, 1007990144, -365686400, 700745408, 369704352, 945610048, 125449552, 729442240, -418684160, 1054884800, -604078592, -92599496, -1036132928, -719417728, -721895936, 421913952, -353525216, 950242176}; const Word32 * const ap_lattice_coeffs_fx[DIRAC_DECORR_NUM_SPLIT_BANDS] = { +#ifdef CODE_IMPROVEMENTS + ap_lattice_coeffs_1_fx, + ap_lattice_coeffs_2_fx, + ap_lattice_coeffs_3_fx, +#else &ap_lattice_coeffs_1_fx[0], &ap_lattice_coeffs_2_fx[0], &ap_lattice_coeffs_3_fx[0], +#endif }; const Word16 ap_split_frequencies_fx[DIRAC_DECORR_NUM_SPLIT_BANDS + 1]/*Q14*/ = { diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index c4b0472e57a3af1a479f8c4fab5c0b9aeb0d735e..51127a8b5236c7f52115774d0ab3176337dde47d 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -3769,31 +3769,82 @@ static ivas_error getConstInputById( return IVAS_ERR_OK; } +#ifdef CODE_IMPROVEMENTS +static void *getInputByIndex_fx( + 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: + 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 + static ivas_error findFreeInputSlot_fx( +#ifdef CODE_IMPROVEMENTS + void *inputs, + const IVAS_REND_AudioConfigType inputType, +#else const void *inputs, - const Word32 inputStructSize, + const int32_t inputStructSize, +#endif const Word32 maxInputs, Word32 *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 - */ + 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 Word32 i; bool canAddInput; +#ifndef CODE_IMPROVEMENTS const UWord8 *pByte; +#endif const input_base *pInputBase; canAddInput = false; move16(); /* Find first unused input in array */ - FOR( ( i = 0, pByte = inputs ); i < maxInputs; ( ++i, pByte += inputStructSize ) ) +#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_fx( inputs, i, inputType ); +#else pInputBase = (const input_base *) pByte; +#endif IF( EQ_32( pInputBase->inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) { @@ -3966,7 +4017,11 @@ ivas_error IVAS_REND_AddInput_fx( ivas_error error; Word32 maxNumInputsOfType; void *inputsArray; +#ifdef CODE_IMPROVEMENTS + IVAS_REND_AudioConfigType inputType; +#else Word32 inputStructSize; +#endif ivas_error ( *activateInput )( void *, AUDIO_CONFIG, IVAS_REND_InputId, RENDER_CONFIG_DATA *, hrtf_handles *hrtfs ); Word32 inputIndex; @@ -3989,12 +4044,19 @@ ivas_error IVAS_REND_AddInput_fx( } +#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; move32(); move32(); @@ -4002,7 +4064,9 @@ ivas_error IVAS_REND_AddInput_fx( 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; move32(); move32(); @@ -4010,7 +4074,9 @@ ivas_error IVAS_REND_AddInput_fx( 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; move32(); move32(); @@ -4018,7 +4084,9 @@ ivas_error IVAS_REND_AddInput_fx( 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; move32(); move32(); @@ -4027,15 +4095,23 @@ ivas_error IVAS_REND_AddInput_fx( 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( NE_32( ( error = findFreeInputSlot_fx( inputsArray, inputType, maxNumInputsOfType, &inputIndex ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = findFreeInputSlot_fx( inputsArray, inputStructSize, maxNumInputsOfType, &inputIndex ) ), IVAS_ERR_OK ) ) +#endif { return error; } *inputId = makeInputId( inConfig, inputIndex ); move16(); +#ifdef CODE_IMPROVEMENTS + IF( NE_32( ( error = activateInput( getInputByIndex_fx( inputsArray, inputIndex, inputType ), inConfig, *inputId, hIvasRend->hRendererConfig, &hIvasRend->hHrtfs ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = activateInput( (uint8_t *) inputsArray + inputStructSize * inputIndex, inConfig, *inputId, hIvasRend->hRendererConfig, &hIvasRend->hHrtfs ) ), IVAS_ERR_OK ) ) +#endif { return error; } diff --git a/lib_util/aeid_file_reader.c b/lib_util/aeid_file_reader.c index 4f44feb5d252e293d6340839f5ba98530ca5ac28..02ec5de808a8183f04d19a91b18b4620b4df05f5 100644 --- a/lib_util/aeid_file_reader.c +++ b/lib_util/aeid_file_reader.c @@ -70,9 +70,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 fe5669fa562052c86617471a0254e7df9a8ad65b..0b6e44660de1d29b008868b1d847522f052bc56a 100644 --- a/lib_util/audio_file_reader.c +++ b/lib_util/audio_file_reader.c @@ -95,7 +95,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 321063101959dc6ecab0a60103f1f2de3246a52e..eb93018341780d232df13483268f295577e21cae 100644 --- a/lib_util/audio_file_writer.c +++ b/lib_util/audio_file_writer.c @@ -89,7 +89,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 509335d1feccc0177bf8b2ad54dbf6106939ff42..6d40260b56dc5b21d8834c16f6e988175d89892a 100644 --- a/lib_util/bitstream_reader.c +++ b/lib_util/bitstream_reader.c @@ -203,16 +203,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 8c4b64cd4816649cb6833ccd6bda13270eb0e179..bff9f461b15992ed3c953a83a19f2c22cc496ed6 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 f3eb704f5bde72ac9bfa9a34f16b5d8a6867c6a3..898e9753d6c4cf90605ff77fec5993afe68c2748 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 e39fe019735de61fe8352ac1afe43b938658418f..62eeaae8f1f042491341693c6949ea0ec9981e43 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 2c462883e80e361dd5fb12147d2451fbdb464df1..aa9c62661687a10033b358f3f9eaaaa44743cb3c 100644 --- a/lib_util/ism_file_reader.c +++ b/lib_util/ism_file_reader.c @@ -73,9 +73,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 fe52aa427b18ca175ed38f51edbab8e28f7fa1f8..8e55187c87caa7089da8f103533f738fdf6d601c 100644 --- a/lib_util/ism_file_writer.c +++ b/lib_util/ism_file_writer.c @@ -82,9 +82,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 b657ab78929f906eb29dd6c3435af8a7f91c73ca..68caf5ae73fc93637fbe3f08d7a4b1513bd284bc 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 76a5a67d2566db5d87ecefb0bb7d21bbeb9afcaf..9d11dad90490e74e44a1f8afc25e70e8fc196493 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 3be30c9f82839f0d4fdb4149de718d60e2d14e1c..37784a6305c237882477fd37292abdf89e78c79d 100644 --- a/lib_util/ls_custom_file_reader.c +++ b/lib_util/ls_custom_file_reader.c @@ -70,9 +70,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 fad9e5c717b20ab789fca9159d4388326583467d..d782cdfd06d5ec6d6fd7005dba134ad11d3ee210 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_fx( &self->sph_grid16 ); diff --git a/lib_util/masa_file_writer.c b/lib_util/masa_file_writer.c index 63c073ba1f2bf4e2108504f6b371fce2d6b363c5..a1c4d7054757b068aa1dec5e8a6e9da35c11ce29 100644 --- a/lib_util/masa_file_writer.c +++ b/lib_util/masa_file_writer.c @@ -211,14 +211,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 03ff3bbb705300ec3f07856f8b683470378d746f..87ce9d13143af4edd5c3ef7e8c1e34f1d8147eab 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/obj_edit_file_reader.c b/lib_util/obj_edit_file_reader.c index 76de8908c6f4af536bbf6eeee54dcaf367da5213..63a5420943e6337098ed2b9b92dbe4175185258b 100644 --- a/lib_util/obj_edit_file_reader.c +++ b/lib_util/obj_edit_file_reader.c @@ -69,13 +69,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; diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 55816d621948b2767da03f2d4100e4f7f34da910..14538b5ee9bb3fa4f251e0acdcf74df79798019a 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -1396,7 +1396,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 3d07ec3e94a96feb6b33d159debb429bdf97bc2b..2f32ea858de8a066ba9e09cd6968e626599d6f08 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 f798b63db6f12423130c449221e44755b8bce26e..d2f13f6bcf6f9fb37ce59e111ff8e6452397bcc4 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 f82308edfd8cd72f541091a1f91b3c1235f81773..6a86738e026d04149cf714d2b5b99e830a883b83 100644 --- a/lib_util/split_rend_bfi_file_reader.c +++ b/lib_util/split_rend_bfi_file_reader.c @@ -76,10 +76,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 b86d97c9640f1e91427a4b6cf8731df62a1596bb..179c676a81b274098fabbe5050c2c977572c82ec 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 693beccf9557dfaf7d6a507cb614064f76049f03..70373e3cca0850aacd3849376765690d3980927a 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/vector3_pair_file_reader.c b/lib_util/vector3_pair_file_reader.c index 11b87a13f7b709392e7f1759f75e63e6f8edbd7d..a4b8cc450bdb26b6f204a3cce6935cf906a19c33 100644 --- a/lib_util/vector3_pair_file_reader.c +++ b/lib_util/vector3_pair_file_reader.c @@ -70,9 +70,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;