Skip to content

Commit

Permalink
fixed more warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
dnewman-gpsw committed Jan 15, 2019
1 parent 3d95478 commit 19c03b0
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
4 changes: 3 additions & 1 deletion GPMF_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ typedef enum

GPMF_TYPE_NEST = 0, // used to nest more GPMF formatted metadata

GPMF_TYPE_ERROR = 0xff // used to report an error
} GPMF_SampleType;


Expand All @@ -76,7 +77,7 @@ typedef enum
#define BYTESWAP64(a) (((a&0xff)<<56)|((a&0xff00)<<40)|((a&0xff0000)<<24)|((a&0xff000000)<<8) | ((a>>56)&0xff)|((a>>40)&0xff00)|((a>>24)&0xff0000)|((a>>8)&0xff000000) )
#define BYTESWAP32(a) (((a&0xff)<<24)|((a&0xff00)<<8)|((a>>8)&0xff00)|((a>>24)&0xff))
#define BYTESWAP16(a) ((((a)>>8)&0xff)|(((a)<<8)&0xff00))
#define BYTESWAPin32(a,s) ((s>=4)?(((a&0xff)<<24)|((a&0xff00)<<8)|((a>>8)&0xff00)|((a>>24)&0xff)):((s==2)?(((a>>8)&0xff)|((a<<8)&0xff00)|((a>>8)&0xff0000)|((a<<8)&0xff000000)):(a)))
#define BYTESWAP2x16(a) (((a>>8)&0xff)|((a<<8)&0xff00)|((a>>8)&0xff0000)|((a<<8)&0xff000000))
#define NOSWAP8(a) (a)

#define GPMF_SAMPLES(a) (((a>>24) & 0xff)|(((a>>16)&0xff)<<8))
Expand Down Expand Up @@ -114,6 +115,7 @@ typedef enum GPMFKey // TAG in all caps are GoPro preserved (are defined by GoPr
GPMF_KEY_PREFORMATTED = MAKEID('P','F','R','M'),//PFRM - GPMF data
GPMF_KEY_TEMPERATURE_C = MAKEID('T','M','P','C'),//TMPC - Temperature in Celsius
GPMF_KEY_EMPTY_PAYLOADS = MAKEID('E','M','P','T'),//EMPT - Payloads that are empty since the device start (e.g. BLE disconnect.)
GPMF_KEY_QUANTIZE = MAKEID('Q','U','A','N'),//QUAN - quantize used to enable stream compression - 1 - enable, 2+ enable and quantize by this value
GPMF_KEY_VERSION = MAKEID('V','E','R','S'),//VERS - version of the metadata stream (debugging)
GPMF_KEY_FREESPACE = MAKEID('F','R','E','E'),//FREE - n bytes reserved for more metadata added to an existing stream
GPMF_KEY_REMARK = MAKEID('R','M','R','K'),//RMRK - adding comments to the bitstream (debugging)
Expand Down
28 changes: 15 additions & 13 deletions GPMF_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,18 +546,18 @@ uint32_t GPMF_Key(GPMF_stream *ms)
}


uint32_t GPMF_Type(GPMF_stream *ms)
GPMF_SampleType GPMF_Type(GPMF_stream *ms)
{
if (ms && ms->pos+1 < ms->buffer_size_longs)
{
uint32_t type = GPMF_SAMPLE_TYPE(ms->buffer[ms->pos+1]);
GPMF_SampleType type = (GPMF_SampleType)GPMF_SAMPLE_TYPE(ms->buffer[ms->pos+1]);
if (type == GPMF_TYPE_COMPRESSED && ms->pos+2 < ms->buffer_size_longs)
{
type = GPMF_SAMPLE_TYPE(ms->buffer[ms->pos + 2]);
type = (GPMF_SampleType)GPMF_SAMPLE_TYPE(ms->buffer[ms->pos + 2]);
}
return type;
}
return 0;
return GPMF_TYPE_ERROR;
}


Expand Down Expand Up @@ -731,7 +731,7 @@ uint32_t GPMF_SizeofType(GPMF_SampleType type)
{
uint32_t ssize = 0;

switch ((int)type)
switch (type)
{
case GPMF_TYPE_STRING_ASCII: ssize = 1; break;
case GPMF_TYPE_SIGNED_BYTE: ssize = 1; break;
Expand All @@ -753,6 +753,7 @@ uint32_t GPMF_SizeofType(GPMF_SampleType type)
//All unknown or larger than 8-bytes stored as is:
case GPMF_TYPE_GUID: ssize = 16; break;
case GPMF_TYPE_UTC_DATE_TIME: ssize = 16; break;
default: ssize = 0; break;
}

return ssize;
Expand Down Expand Up @@ -1091,7 +1092,7 @@ GPMF_ERR GPMF_ScaledData(GPMF_stream *ms, void *buffer, uint32_t buffersize, uin
uint32_t elements = 1;
uint32_t noswap = 0;

type = GPMF_SAMPLE_TYPE(ms->buffer[ms->pos + 1]);
type = (GPMF_SampleType)GPMF_SAMPLE_TYPE(ms->buffer[ms->pos + 1]);

if (type == GPMF_TYPE_NEST)
return GPMF_ERROR_MEMORY;
Expand All @@ -1111,7 +1112,7 @@ GPMF_ERR GPMF_ScaledData(GPMF_stream *ms, void *buffer, uint32_t buffersize, uin
read_samples = samples;
elements = GPMF_ElementsInStruct(ms);
type = GPMF_Type(ms);
complextype[0] = type;
complextype[0] = (char)type;
inputtypesize = GPMF_SizeofType((GPMF_SampleType)type);
if (inputtypesize == 0)
{
Expand Down Expand Up @@ -1333,10 +1334,10 @@ GPMF_ERR GPMF_Decompress(GPMF_stream *ms, uint32_t *localbuf, uint32_t localbuf_
memset(localbuf, 0, localbuf_size);

// unpack here
uint8_t type = GPMF_SAMPLE_TYPE(ms->buffer[ms->pos + 2]);// The first 32-bit of data, is the uncomresseded type-size-repeat
GPMF_SampleType type = (GPMF_SampleType)GPMF_SAMPLE_TYPE(ms->buffer[ms->pos + 2]);// The first 32-bit of data, is the uncomresseded type-size-repeat
uint8_t *start = (uint8_t *)&ms->buffer[ms->pos + 3];
uint16_t quant;
uint32_t sOffset = 0;
size_t sOffset = 0;
uint16_t *compressed_data;
uint32_t sample_size = GPMF_SAMPLE_SIZE(ms->buffer[ms->pos + 2]);
uint32_t sizeoftype = GPMF_SizeofType(type);
Expand Down Expand Up @@ -1545,7 +1546,7 @@ GPMF_ERR GPMF_Decompress(GPMF_stream *ms, uint32_t *localbuf, uint32_t localbuf_
} while (!end);

if (nextBits == 16) compressed_data--;
sOffset = (uint32_t)compressed_data - (uint32_t)start;
sOffset = (size_t)compressed_data - (size_t)start;
end = 0;
}

Expand All @@ -1561,9 +1562,10 @@ GPMF_ERR GPMF_AllocCodebook(size_t *cbhandle)
*cbhandle = (size_t)malloc(65536 * sizeof(GPMF_codebook));
if (*cbhandle)
{
int i,v,z;
GPMF_codebook *cb = (GPMF_codebook *)*cbhandle;

for (int i = 0; i <= 0xffff; i++)
for (i = 0; i <= 0xffff; i++)
{
uint16_t code = (uint16_t)i;
uint16_t mask = 0x8000;
Expand Down Expand Up @@ -1591,7 +1593,7 @@ GPMF_ERR GPMF_AllocCodebook(size_t *cbhandle)
continue;
}

for (int z = enczerorunstable.length-1; z >= 0; z--)
for (z = enczerorunstable.length-1; z >= 0; z--)
{
if (16 - used >= enczerorunstable.entries[z].size)
{
Expand All @@ -1618,7 +1620,7 @@ GPMF_ERR GPMF_AllocCodebook(size_t *cbhandle)
code <<= used;

cb->bytes_stored = 0;
for (int v=enchuftable.length-1; v>0; v--)
for (v=enchuftable.length-1; v>0; v--)
{
if (16-used >= enchuftable.entries[v].size+1) // codeword + sign bit
{
Expand Down
2 changes: 1 addition & 1 deletion GPMF_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ GPMF_ERR GPMF_SeekToSamples(GPMF_stream *gs); //find the last FourCC

// Get information about the current GPMF KLV
uint32_t GPMF_Key(GPMF_stream *gs); //return the current Key (FourCC)
uint32_t GPMF_Type(GPMF_stream *gs); //return the current Type (GPMF_Type)
GPMF_SampleType GPMF_Type(GPMF_stream *gs); //return the current Type (GPMF_Type)
uint32_t GPMF_StructSize(GPMF_stream *gs); //return the current sample structure size
uint32_t GPMF_Repeat(GPMF_stream *gs); //return the current repeat or the number of samples of this structure
uint32_t GPMF_PayloadSampleCount(GPMF_stream *gs); //return the current number of samples of this structure, supporting multisample entries.
Expand Down
4 changes: 2 additions & 2 deletions demo/GPMF_print.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ void printfData(uint32_t type, uint32_t structsize, uint32_t repeat, void *data)

while (arraysize--)
{
DBG_MSG("%lld,", BYTESWAP64(*J));
DBG_MSG("%lld,", (long long int)BYTESWAP64(*J));
J++;
}
if (repeat) DBG_MSG(" ");
Expand All @@ -370,7 +370,7 @@ void printfData(uint32_t type, uint32_t structsize, uint32_t repeat, void *data)

while (arraysize--)
{
DBG_MSG("%llu,", BYTESWAP64(*J));
DBG_MSG("%llu,", (long long unsigned int)BYTESWAP64(*J));
J++;
}
if (repeat) DBG_MSG(" ");
Expand Down

0 comments on commit 19c03b0

Please sign in to comment.