Skip to content
......@@ -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;
......
......@@ -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_<format> */
( *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_<format> */
BS_READER_HANDLE hBsReader = *phBsReader;
memset( hBsReader, 0, sizeof( struct BS_Reader ) );
/* Set function pointers to selected format */
switch ( format )
......
......@@ -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_<format> */
( *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_<format> */
BS_WRITER_HANDLE hBsWriter = *phBsWriter;
memset( hBsWriter, 0, sizeof( struct BS_Writer ) );
/* Set function pointers to selected format */
switch ( format )
......
......@@ -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;
......
......@@ -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;
/*-----------------------------------------------------------------------*
......
......@@ -83,9 +83,9 @@ ivas_error hrtfFileReader_open(
return IVAS_ERR_FAILED_FILE_OPEN;
}
self = calloc( sizeof( hrtfFileReader ), 1 );
self = calloc( 1, sizeof( hrtfFileReader ) );
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 );
*hrtfReader = self;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......@@ -121,11 +121,11 @@ static LS_CUSTOM_FILEREADER_ERROR CustomLoudspeakerLayout_validate(
{
int16_t i, j;
int16_t dup_count;
int16_t dup[IVAS_MAX_OUTPUT_CHANNELS];
float azi_tmp[IVAS_MAX_OUTPUT_CHANNELS];
float ele_tmp[IVAS_MAX_OUTPUT_CHANNELS];
int16_t dup[IVAS_MAX_LS_CHANNELS];
float azi_tmp[IVAS_MAX_LS_CHANNELS];
float ele_tmp[IVAS_MAX_LS_CHANNELS];
for ( i = 0; i < IVAS_MAX_OUTPUT_CHANNELS; i++ )
for ( i = 0; i < IVAS_MAX_LS_CHANNELS; i++ )
{
dup[i] = 0;
azi_tmp[i] = 0.0f;
......@@ -143,7 +143,7 @@ static LS_CUSTOM_FILEREADER_ERROR CustomLoudspeakerLayout_validate(
return LS_CUSTOM_FILEREADER_LFE_NUM_SPK_EXCEEDED_ERROR;
}
if ( ( *num_azi + num_lfe ) > IVAS_MAX_OUTPUT_CHANNELS )
if ( ( *num_azi + num_lfe ) > IVAS_MAX_LS_CHANNELS )
{
return LS_CUSTOM_FILEREADER_OUTPUT_NCHAN_EXCEEDED_ERROR;
}
......@@ -182,7 +182,7 @@ static LS_CUSTOM_FILEREADER_ERROR CustomLoudspeakerLayout_validate(
( *num_azi ) -= dup_count;
for ( i = 0; i < IVAS_MAX_OUTPUT_CHANNELS; i++ )
for ( i = 0; i < IVAS_MAX_LS_CHANNELS; i++ )
{
azi[i] = azi_tmp[i];
ele[i] = ele_tmp[i];
......@@ -240,7 +240,7 @@ LS_CUSTOM_FILEREADER_ERROR CustomLsFileReading(
{
LS_CUSTOM_FILEREADER_ERROR error;
char line[200]; /* > (10 chars * IVAS_MAX_OUTPUT_CHANNELS) i.e. "-999, " */
char line[200]; /* > (10 chars * IVAS_MAX_LS_CHANNELS) i.e. "-999, " */
const char *tok;
int16_t i, num_azi, num_ele, num_lfe;
......@@ -250,7 +250,7 @@ LS_CUSTOM_FILEREADER_ERROR CustomLsFileReading(
num_ele = 0;
num_lfe = 0;
for ( i = 0; i < IVAS_MAX_OUTPUT_CHANNELS; i++ )
for ( i = 0; i < IVAS_MAX_LS_CHANNELS; i++ )
{
hLsCustomData->lfe_idx[i] = -1;
hLsCustomData->azimuth[i] = 0.0f;
......@@ -282,7 +282,7 @@ LS_CUSTOM_FILEREADER_ERROR CustomLsFileReading(
continue;
}
if ( num_azi >= IVAS_MAX_OUTPUT_CHANNELS )
if ( num_azi >= IVAS_MAX_LS_CHANNELS )
{
return LS_CUSTOM_FILEREADER_AZI_NUM_SPK_EXCEEDED_ERROR;
}
......@@ -311,7 +311,7 @@ LS_CUSTOM_FILEREADER_ERROR CustomLsFileReading(
continue;
}
if ( num_ele >= IVAS_MAX_OUTPUT_CHANNELS )
if ( num_ele >= IVAS_MAX_LS_CHANNELS )
{
return LS_CUSTOM_FILEREADER_ELE_NUM_SPK_EXCEEDED_ERROR;
}
......@@ -337,14 +337,14 @@ LS_CUSTOM_FILEREADER_ERROR CustomLsFileReading(
continue;
}
if ( num_lfe > IVAS_MAX_OUTPUT_CHANNELS )
if ( num_lfe > IVAS_MAX_LS_CHANNELS )
{
return LS_CUSTOM_FILEREADER_LFE_NUM_SPK_EXCEEDED_ERROR;
}
else
{
hLsCustomData->lfe_idx[num_lfe] = (int16_t) atoi( tok );
if ( hLsCustomData->lfe_idx[num_lfe] < 0 || hLsCustomData->lfe_idx[num_lfe] > ( IVAS_MAX_OUTPUT_CHANNELS - 1 ) )
if ( hLsCustomData->lfe_idx[num_lfe] < 0 || hLsCustomData->lfe_idx[num_lfe] > ( IVAS_MAX_LS_CHANNELS - 1 ) )
{
return LS_CUSTOM_FILEREADER_LFE_INDEX_ERROR;
}
......
......@@ -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 );
......
......@@ -212,14 +212,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;
}
......
......@@ -305,7 +305,9 @@ MIME_ERROR MIME_Writer_Close(
}
static bool readByte( FILE *file, uint8_t *value )
static bool readByte(
FILE *file,
uint8_t *value )
{
if ( fread( value, 1, 1, file ) != 1U )
{
......@@ -314,10 +316,13 @@ static bool readByte( FILE *file, uint8_t *value )
return true;
}
static bool readLong( FILE *file, uint16_t *value )
static bool readLong(
FILE *file,
uint16_t *value )
{
char buffer[4] = { 0 };
if ( fread( buffer, 4, 1, file ) != 1U )
if ( fread( buffer, 1, 4, file ) != 1U )
{
return false;
}
......@@ -342,7 +347,10 @@ static bool readLong( FILE *file, uint16_t *value )
* to the serial bitstream.
*-------------------------------------------------------------------*/
static void byteToSerialReordered( uint8_t byte, uint16_t *serial, const int16_t *sort_indices )
static void byteToSerialReordered(
uint8_t byte,
uint16_t *serial,
const int16_t *sort_indices )
{
for ( uint32_t i = 0; i < 8; ++i )
{
......@@ -356,8 +364,11 @@ static void byteToSerialReordered( uint8_t byte, uint16_t *serial, const int16_t
byte <<= 1;
}
return;
}
/*-------------------------------------------------------------------*
* byteToSerial()
*
......@@ -365,18 +376,25 @@ static void byteToSerialReordered( uint8_t byte, uint16_t *serial, const int16_t
* to the given serial bitstream array.
*-------------------------------------------------------------------*/
static void byteToSerial( uint8_t byte, uint16_t *serial )
static void byteToSerial(
uint8_t byte,
uint16_t *serial )
{
const int16_t indices[8] = { 0, 1, 2, 3, 4, 5, 6, 7 };
byteToSerialReordered( byte, serial, indices );
return;
}
static MIME_ERROR readHeader( MIME_HANDLE hMIME )
static MIME_ERROR readHeader(
MIME_HANDLE hMIME )
{
const char id[] = "#!EVS_MC1.0\n";
const uint16_t num_char_id = sizeof( id ) - 1;
char buffer[sizeof( id )] = { 0 };
if ( fread( buffer, sizeof( char ), num_char_id, hMIME->file ) != num_char_id )
{
return MIME_READ_ERROR;
......@@ -394,13 +412,17 @@ static MIME_ERROR readHeader( MIME_HANDLE hMIME )
return MIME_NO_ERROR;
}
/*-------------------------------------------------------------------*
* MIME_Reader_Open_filename()
*
* Open MIME reader
*-------------------------------------------------------------------*/
MIME_ERROR MIME_Reader_Open_filename( MIME_HANDLE *phMIME, const char *filename )
MIME_ERROR MIME_Reader_Open_filename(
MIME_HANDLE *phMIME,
const char *filename )
{
MIME_ERROR error = MIME_NO_ERROR;
......@@ -436,7 +458,8 @@ MIME_ERROR MIME_Reader_Open_filename( MIME_HANDLE *phMIME, const char *filename
* Rewind currently opened file to beginning
*-------------------------------------------------------------------*/
MIME_ERROR MIME_Reader_Rewind( MIME_HANDLE hMIME )
MIME_ERROR MIME_Reader_Rewind(
MIME_HANDLE hMIME )
{
if ( !hMIME || !hMIME->file )
{
......@@ -451,7 +474,13 @@ MIME_ERROR MIME_Reader_Rewind( MIME_HANDLE hMIME )
return MIME_NO_ERROR;
}
static MIME_ERROR readEvsFrame( FILE *file, uint8_t ToC, uint16_t *serial, int16_t *num_bits, int16_t *bfi )
static MIME_ERROR readEvsFrame(
FILE *file,
uint8_t ToC,
uint16_t *serial,
int16_t *num_bits,
int16_t *bfi )
{
switch ( ToC & 0x0f )
{
......@@ -520,7 +549,13 @@ static MIME_ERROR readEvsFrame( FILE *file, uint8_t ToC, uint16_t *serial, int16
return MIME_NO_ERROR;
}
static MIME_ERROR readAmrWbFrame( FILE *file, uint8_t ToC, uint16_t *serial, int16_t *num_bits, int16_t *bfi )
static MIME_ERROR readAmrWbFrame(
FILE *file,
uint8_t ToC,
uint16_t *serial,
int16_t *num_bits,
int16_t *bfi )
{
const uint8_t mode = ToC & 0x0f;
......@@ -591,12 +626,18 @@ static MIME_ERROR readAmrWbFrame( FILE *file, uint8_t ToC, uint16_t *serial, int
return MIME_NO_ERROR;
}
/*-------------------------------------------------------------------*
* MIME_ReadFrame_short()
*
* Read MIME frame to serial bitstream
*-------------------------------------------------------------------*/
MIME_ERROR MIME_ReadFrame_short( MIME_HANDLE hMIME, uint16_t *serial, int16_t *num_bits, int16_t *bfi )
MIME_ERROR MIME_ReadFrame_short(
MIME_HANDLE hMIME,
uint16_t *serial,
int16_t *num_bits,
int16_t *bfi )
{
if ( !hMIME )
{
......@@ -633,12 +674,16 @@ MIME_ERROR MIME_ReadFrame_short( MIME_HANDLE hMIME, uint16_t *serial, int16_t *n
return MIME_NO_ERROR;
}
/*-------------------------------------------------------------------*
* MIME_Reader_Close()
*
* Close MIME reader
*-------------------------------------------------------------------*/
MIME_ERROR MIME_Reader_Close( MIME_HANDLE *phMIME )
MIME_ERROR MIME_Reader_Close(
MIME_HANDLE *phMIME )
{
if ( phMIME == NULL || *phMIME == NULL )
{
......
......@@ -76,13 +76,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;
......
......@@ -1398,7 +1398,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;
......
......@@ -72,10 +72,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;
......@@ -175,6 +175,12 @@ ivas_error ExternalOrientationFileReading(
( externalOrientationReader->frameCounter )++;
/* Only Quaternion orientations are supported, raise an error if Euler angles are detected in the input */
if ( w == -3.0f )
{
return IVAS_ERR_EXTERNAL_ORIENTATION_INVALID_FORMAT;
}
pQuaternion->w = w;
pQuaternion->x = x;
pQuaternion->y = y;
......
......@@ -80,7 +80,7 @@ static unsigned char *parseByte( unsigned char *buffer, unsigned char *value )
static int readLong( FILE *file, unsigned int *value )
{
char buffer[4] = { 0 };
if ( fread( buffer, 4, 1, file ) != 1U )
if ( fread( buffer, 1, 4, file ) != 1U )
{
return -1;
}
......@@ -96,7 +96,7 @@ static int readLong( FILE *file, unsigned int *value )
static int readShort( FILE *file, unsigned short *value )
{
char buffer[2] = { 0 };
if ( fread( buffer, 2, 1, file ) != 1U )
if ( fread( buffer, 1, 2, file ) != 1U )
{
return -1;
}
......
......@@ -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;
......
......@@ -54,14 +54,14 @@
#define __TWI_SUCCESS ( 0 )
#define __TWI_ERROR ( -1 )
typedef struct __tinyWaveInHandle
typedef struct tinyWaveInHandle
{
FILE *theFile;
fpos_t dataChunkPos;
uint32_t position;
uint32_t length;
uint32_t bps;
} __tinyWaveInHandle, WAVEFILEIN;
} tinyWaveInHandle, WAVEFILEIN;
typedef struct
{
......