Skip to content

Commit

Permalink
fix compile warning
Browse files Browse the repository at this point in the history
  • Loading branch information
ireader committed Mar 7, 2020
1 parent b19e9e3 commit a884e86
Show file tree
Hide file tree
Showing 88 changed files with 351 additions and 334 deletions.
4 changes: 2 additions & 2 deletions libdash/src/dash-mpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ int dash_mpd_add_video_adaptation_set(struct dash_mpd_t* mpd, const char* prefix
char name[N_NAME + 16];
struct dash_adaptation_set_t* track;

r = strlen(prefix);
r = (int)strlen(prefix);
if (mpd->count + 1 >= N_TRACK || extra_data_size < 4 || r >= N_NAME)
return -1;

Expand Down Expand Up @@ -358,7 +358,7 @@ int dash_mpd_add_audio_adaptation_set(struct dash_mpd_t* mpd, const char* prefix
char name[N_NAME + 16];
struct dash_adaptation_set_t* track;

r = strlen(prefix);
r = (int)strlen(prefix);
if (mpd->count + 1 >= N_TRACK || extra_data_size < 2 || r >= N_NAME)
return -1;

Expand Down
2 changes: 1 addition & 1 deletion libflv/include/mpeg4-aac.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct mpeg4_aac_t
int sbr; // sbr flag, valid only in decode
int ps; // ps flag, valid only in decode
uint8_t pce[64];
size_t npce; // pce bytes
int npce; // pce bytes
};

enum mpeg2_aac_profile
Expand Down
2 changes: 1 addition & 1 deletion libflv/include/mpeg4-avc.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ int mpeg4_avc_codecs(const struct mpeg4_avc_t* avc, char* codecs, size_t bytes);
/// @return <=0-error, >0-output bytes
int h264_annexbtomp4(struct mpeg4_avc_t* avc, const void* data, int bytes, void* out, int size, int* vcl, int* update);

/// @param[out] vcl 0-non VCL, 1-IDR, 2-P/B
/// @return <=0-error, >0-output bytes
int h264_mp4toannexb(const struct mpeg4_avc_t* avc, const void* data, int bytes, void* out, int size);

#if defined(__cplusplus)
Expand Down
2 changes: 1 addition & 1 deletion libflv/source/aom-av1.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ int aom_av1_codec_configuration_record_load(const uint8_t* data, size_t bytes, s

av1->bytes = (uint16_t)(bytes - 4);
memcpy(av1->data, data + 4, av1->bytes);
return bytes;
return (int)bytes;
}

int aom_av1_codec_configuration_record_save(const struct aom_av1_t* av1, uint8_t* data, size_t bytes)
Expand Down
14 changes: 7 additions & 7 deletions libflv/source/flv-demuxer.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct flv_demuxer_t
void* param;

uint8_t* ptr;
uint32_t capacity;
int capacity;
};

struct flv_demuxer_t* flv_demuxer_create(flv_demuxer_handler handler, void* param)
Expand All @@ -52,7 +52,7 @@ void flv_demuxer_destroy(struct flv_demuxer_t* flv)
free(flv);
}

static int flv_demuxer_check_and_alloc(struct flv_demuxer_t* flv, size_t bytes)
static int flv_demuxer_check_and_alloc(struct flv_demuxer_t* flv, int bytes)
{
if (bytes > flv->capacity)
{
Expand All @@ -65,7 +65,7 @@ static int flv_demuxer_check_and_alloc(struct flv_demuxer_t* flv, size_t bytes)
return 0;
}

static int flv_demuxer_audio(struct flv_demuxer_t* flv, const uint8_t* data, size_t bytes, uint32_t timestamp)
static int flv_demuxer_audio(struct flv_demuxer_t* flv, const uint8_t* data, int bytes, uint32_t timestamp)
{
int r, n;
struct flv_audio_tag_header_t audio;
Expand Down Expand Up @@ -111,9 +111,9 @@ static int flv_demuxer_audio(struct flv_demuxer_t* flv, const uint8_t* data, siz
}
}

static int flv_demuxer_video(struct flv_demuxer_t* flv, const uint8_t* data, size_t bytes, uint32_t timestamp)
static int flv_demuxer_video(struct flv_demuxer_t* flv, const uint8_t* data, int bytes, uint32_t timestamp)
{
size_t n;
int n;
struct flv_video_tag_header_t video;
n = flv_video_tag_header_read(&video, data, bytes);
if (n < 0)
Expand Down Expand Up @@ -235,10 +235,10 @@ int flv_demuxer_input(struct flv_demuxer_t* flv, int type, const void* data, siz
switch (type)
{
case FLV_TYPE_AUDIO:
return flv_demuxer_audio(flv, data, bytes, timestamp);
return flv_demuxer_audio(flv, data, (int)bytes, timestamp);

case FLV_TYPE_VIDEO:
return flv_demuxer_video(flv, data, bytes, timestamp);
return flv_demuxer_video(flv, data, (int)bytes, timestamp);

case FLV_TYPE_SCRIPT:
//return flv_demuxer_script(flv, data, bytes);
Expand Down
9 changes: 5 additions & 4 deletions libflv/source/flv-header.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ int flv_video_tag_header_read(struct flv_video_tag_header_t* video, const uint8_

int flv_data_tag_header_read(const uint8_t* buf, int len)
{
buf;
(void)buf;
return len;
}

Expand Down Expand Up @@ -178,13 +178,13 @@ int flv_audio_tag_header_write(const struct flv_audio_tag_header_t* audio, uint8
if (FLV_AUDIO_AAC == audio->codecid)
{
assert(FLV_SEQUENCE_HEADER == audio->avpacket || FLV_AVPACKET == audio->avpacket);
buf[0] = (FLV_AUDIO_AAC /*<< 4*/) /* SoundFormat */ | (3 << 2) /* 44k-SoundRate */ | (1 << 1) /* 16-bit samples */ | 1 /* Stereo sound */;
buf[0] = (FLV_AUDIO_AAC /* <<4 */) /* SoundFormat */ | (3 << 2) /* 44k-SoundRate */ | (1 << 1) /* 16-bit samples */ | 1 /* Stereo sound */;
buf[1] = audio->avpacket; // AACPacketType
return 2;
}
else
{
buf[0] = (audio->codecid /*<< 4*/) | ((audio->rate && 0x03) << 2) | ((audio->bits & 0x01) << 1) | (audio->channels & 0x01);
buf[0] = (audio->codecid /* <<4 */) | ((audio->rate & 0x03) << 2) | ((audio->bits & 0x01) << 1) | (audio->channels & 0x01);
return 1;
}
}
Expand Down Expand Up @@ -214,6 +214,7 @@ int flv_video_tag_header_write(const struct flv_video_tag_header_t* video, uint8

int flv_data_tag_header_write(uint8_t* buf, int len)
{
buf, len;
(void)buf;
(void)len;
return 0;
}
27 changes: 15 additions & 12 deletions libflv/source/flv-muxer.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ struct flv_muxer_t
int update; // avc/hevc sequence header update

uint8_t* ptr;
size_t bytes;
size_t capacity;
int bytes;
int capacity;
};

struct flv_muxer_t* flv_muxer_create(flv_muxer_handler handler, void* param)
Expand Down Expand Up @@ -70,7 +70,7 @@ int flv_muxer_reset(struct flv_muxer_t* flv)
return 0;
}

static int flv_muxer_alloc(struct flv_muxer_t* flv, size_t bytes)
static int flv_muxer_alloc(struct flv_muxer_t* flv, int bytes)
{
void* p;
p = realloc(flv->ptr, bytes);
Expand All @@ -82,12 +82,14 @@ static int flv_muxer_alloc(struct flv_muxer_t* flv, size_t bytes)
return 0;
}

int flv_muxer_mp3(struct flv_muxer_t* flv, const void* data, size_t bytes, uint32_t pts, uint32_t dts)
int flv_muxer_mp3(struct flv_muxer_t* flv, const void* data, size_t sz, uint32_t pts, uint32_t dts)
{
int bytes;
struct mp3_header_t mp3;
struct flv_audio_tag_header_t audio;
(void)pts;

bytes = (int)sz;
if (0 == mp3_header_load(&mp3, data, bytes))
{
return EINVAL;
Expand Down Expand Up @@ -119,12 +121,13 @@ int flv_muxer_mp3(struct flv_muxer_t* flv, const void* data, size_t bytes, uint3
return flv->handler(flv->param, FLV_TYPE_AUDIO, flv->ptr, bytes + 1, dts);
}

int flv_muxer_aac(struct flv_muxer_t* flv, const void* data, size_t bytes, uint32_t pts, uint32_t dts)
int flv_muxer_aac(struct flv_muxer_t* flv, const void* data, size_t sz, uint32_t pts, uint32_t dts)
{
int r, n, m;
int r, n, m, bytes;
struct flv_audio_tag_header_t audio;
(void)pts;

bytes = (int)sz;
if (flv->capacity < bytes + 2/*AudioTagHeader*/ + 2/*AudioSpecificConfig*/)
{
if (0 != flv_muxer_alloc(flv, bytes + 4))
Expand Down Expand Up @@ -198,14 +201,14 @@ static int flv_muxer_h264(struct flv_muxer_t* flv, uint32_t pts, uint32_t dts)

int flv_muxer_avc(struct flv_muxer_t* flv, const void* data, size_t bytes, uint32_t pts, uint32_t dts)
{
if (flv->capacity < bytes + 2048/*AVCDecoderConfigurationRecord*/)
if (flv->capacity < (int)bytes + 2048/*AVCDecoderConfigurationRecord*/)
{
if (0 != flv_muxer_alloc(flv, bytes + 2048))
if (0 != flv_muxer_alloc(flv, (int)bytes + 2048))
return ENOMEM;
}

flv->bytes = 5;
flv->bytes += h264_annexbtomp4(&flv->v.avc, data, bytes, flv->ptr + flv->bytes, flv->capacity - flv->bytes, &flv->vcl, &flv->update);
flv->bytes += h264_annexbtomp4(&flv->v.avc, data, (int)bytes, flv->ptr + flv->bytes, flv->capacity - flv->bytes, &flv->vcl, &flv->update);
if (flv->bytes <= 5)
return ENOMEM;

Expand Down Expand Up @@ -250,14 +253,14 @@ static int flv_muxer_h265(struct flv_muxer_t* flv, uint32_t pts, uint32_t dts)

int flv_muxer_hevc(struct flv_muxer_t* flv, const void* data, size_t bytes, uint32_t pts, uint32_t dts)
{
if (flv->capacity < bytes + 2048/*HEVCDecoderConfigurationRecord*/)
if (flv->capacity < (int)bytes + 2048/*HEVCDecoderConfigurationRecord*/)
{
if (0 != flv_muxer_alloc(flv, bytes + 2048))
if (0 != flv_muxer_alloc(flv, (int)bytes + 2048))
return ENOMEM;
}

flv->bytes = 5;
flv->bytes += h265_annexbtomp4(&flv->v.hevc, data, bytes, flv->ptr + flv->bytes, flv->capacity - flv->bytes, &flv->vcl, &flv->update);
flv->bytes += h265_annexbtomp4(&flv->v.hevc, data, (int)bytes, flv->ptr + flv->bytes, flv->capacity - flv->bytes, &flv->vcl, &flv->update);
if (flv->bytes <= 5)
return ENOMEM;

Expand Down
12 changes: 6 additions & 6 deletions libflv/source/flv-parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#define FLV_VIDEO_CODEC_NAME(codecid) (FLV_VIDEO_H264==(codecid) ? FLV_VIDEO_AVCC : (FLV_VIDEO_H265==(codecid) ? FLV_VIDEO_HVCC : FLV_VIDEO_AV1C))

static int flv_parser_audio(const uint8_t* data, size_t bytes, uint32_t timestamp, flv_parser_handler handler, void* param)
static int flv_parser_audio(const uint8_t* data, int bytes, uint32_t timestamp, flv_parser_handler handler, void* param)
{
int n;
struct flv_audio_tag_header_t audio;
Expand All @@ -21,7 +21,7 @@ static int flv_parser_audio(const uint8_t* data, size_t bytes, uint32_t timestam
return handler(param, audio.codecid, data + n, bytes - n, timestamp, timestamp, 0);
}

static int flv_parser_video(const uint8_t* data, size_t bytes, uint32_t timestamp, flv_parser_handler handler, void* param)
static int flv_parser_video(const uint8_t* data, int bytes, uint32_t timestamp, flv_parser_handler handler, void* param)
{
int n;
struct flv_video_tag_header_t video;
Expand Down Expand Up @@ -58,7 +58,7 @@ static int flv_parser_video(const uint8_t* data, size_t bytes, uint32_t timestam

// http://www.cnblogs.com/musicfans/archive/2012/11/07/2819291.html
// metadata keyframes/filepositions
static int flv_parser_script(const uint8_t* data, size_t bytes, uint32_t timestamp, flv_parser_handler handler, void* param)
static int flv_parser_script(const uint8_t* data, int bytes, uint32_t timestamp, flv_parser_handler handler, void* param)
{
int n;
n = flv_data_tag_header_read(data, bytes);
Expand All @@ -74,13 +74,13 @@ int flv_parser_input(int type, const void* data, size_t bytes, uint32_t timestam
switch (type)
{
case FLV_TYPE_AUDIO:
return flv_parser_audio(data, bytes, timestamp, handler, param);
return flv_parser_audio(data, (int)bytes, timestamp, handler, param);

case FLV_TYPE_VIDEO:
return flv_parser_video(data, bytes, timestamp, handler, param);
return flv_parser_video(data, (int)bytes, timestamp, handler, param);

case FLV_TYPE_SCRIPT:
return flv_parser_script(data, bytes, timestamp, handler, param);
return flv_parser_script(data, (int)bytes, timestamp, handler, param);

default:
assert(0);
Expand Down
2 changes: 1 addition & 1 deletion libflv/source/flv-reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static int flv_read_header(struct flv_reader_t* flv)

static int file_read(void* param, void* buf, int len)
{
return fread(buf, 1, len, (FILE*)param);
return (int)fread(buf, 1, len, (FILE*)param);
}

void* flv_reader_create(const char* file)
Expand Down
6 changes: 3 additions & 3 deletions libflv/source/flv-writer.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static int flv_write_eos(struct flv_writer_t* flv)

static int file_write(void* param, const void* buf, int len)
{
return fwrite(buf, 1, len, (FILE*)param);
return (int)fwrite(buf, 1, len, (FILE*)param);
}

void* flv_writer_create(const char* file)
Expand Down Expand Up @@ -111,14 +111,14 @@ int flv_writer_input(void* p, int type, const void* data, size_t bytes, uint32_t
flv = (struct flv_writer_t*)p;

memset(&tag, 0, sizeof(tag));
tag.size = bytes;
tag.size = (int)bytes;
tag.type = (uint8_t)type;
tag.timestamp = timestamp;
flv_tag_header_write(&tag, buf, FLV_TAG_HEADER_SIZE);
be_write_uint32(buf + FLV_TAG_HEADER_SIZE, (uint32_t)bytes + FLV_TAG_HEADER_SIZE);

if(FLV_TAG_HEADER_SIZE != flv->write(flv->param, buf, FLV_TAG_HEADER_SIZE) // FLV Tag Header
|| bytes != (size_t)flv->write(flv->param, data, bytes)
|| bytes != (size_t)flv->write(flv->param, data, (int)bytes)
|| 4 != flv->write(flv->param, buf + FLV_TAG_HEADER_SIZE, 4)) // TAG size
return -1;
return 0;
Expand Down
Loading

0 comments on commit a884e86

Please sign in to comment.