diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-02-03 21:53:29 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-02-03 21:53:29 +0100 |
commit | 46a16ca15a68bfd7341dd9783ecf39bbdf80d08e (patch) | |
tree | 44bfaeb9dcce7a96e9a05733d4326dee21fe52af /libavformat/siff.c | |
parent | b37858eae186ff84afd38cf3e845ba6e037e6397 (diff) | |
parent | 75439bb31b3ab76f9a4d30c5de4ff9f407ec8128 (diff) | |
download | ffmpeg-46a16ca15a68bfd7341dd9783ecf39bbdf80d08e.tar.gz |
Merge commit '75439bb31b3ab76f9a4d30c5de4ff9f407ec8128'
* commit '75439bb31b3ab76f9a4d30c5de4ff9f407ec8128':
siff: K&R formatting cosmetics
Conflicts:
libavformat/siff.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/siff.c')
-rw-r--r-- | libavformat/siff.c | 83 |
1 files changed, 42 insertions, 41 deletions
diff --git a/libavformat/siff.c b/libavformat/siff.c index 8da6c2f67a..3b54e90777 100644 --- a/libavformat/siff.c +++ b/libavformat/siff.c @@ -21,11 +21,12 @@ #include "libavutil/channel_layout.h" #include "libavutil/intreadwrite.h" + #include "avformat.h" #include "internal.h" #include "avio_internal.h" -enum SIFFTags{ +enum SIFFTags { TAG_SIFF = MKTAG('S', 'I', 'F', 'F'), TAG_BODY = MKTAG('B', 'O', 'D', 'Y'), TAG_VBHD = MKTAG('V', 'B', 'H', 'D'), @@ -34,7 +35,7 @@ enum SIFFTags{ TAG_SOUN = MKTAG('S', 'O', 'U', 'N'), }; -enum VBFlags{ +enum VBFlags { VB_HAS_GMC = 0x01, VB_HAS_AUDIO = 0x04, VB_HAS_VIDEO = 0x08, @@ -42,7 +43,7 @@ enum VBFlags{ VB_HAS_LENGTH = 0x20 }; -typedef struct SIFFContext{ +typedef struct SIFFContext { int frames; int cur_frame; int rate; @@ -59,7 +60,7 @@ typedef struct SIFFContext{ int flags; uint8_t gmc[4]; -}SIFFContext; +} SIFFContext; static int siff_probe(AVProbeData *p) { @@ -77,14 +78,14 @@ static int create_audio_stream(AVFormatContext *s, SIFFContext *c) ast = avformat_new_stream(s, NULL); if (!ast) return AVERROR(ENOMEM); - ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; - ast->codec->codec_id = AV_CODEC_ID_PCM_U8; - ast->codec->channels = 1; - ast->codec->channel_layout = AV_CH_LAYOUT_MONO; + ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; + ast->codec->codec_id = AV_CODEC_ID_PCM_U8; + ast->codec->channels = 1; + ast->codec->channel_layout = AV_CH_LAYOUT_MONO; ast->codec->bits_per_coded_sample = 8; - ast->codec->sample_rate = c->rate; + ast->codec->sample_rate = c->rate; avpriv_set_pts_info(ast, 16, 1, c->rate); - ast->start_time = 0; + ast->start_time = 0; return 0; } @@ -93,31 +94,31 @@ static int siff_parse_vbv1(AVFormatContext *s, SIFFContext *c, AVIOContext *pb) AVStream *st; int width, height; - if (avio_rl32(pb) != TAG_VBHD){ + if (avio_rl32(pb) != TAG_VBHD) { av_log(s, AV_LOG_ERROR, "Header chunk is missing\n"); return AVERROR_INVALIDDATA; } - if(avio_rb32(pb) != 32){ + if (avio_rb32(pb) != 32) { av_log(s, AV_LOG_ERROR, "Header chunk size is incorrect\n"); return AVERROR_INVALIDDATA; } - if(avio_rl16(pb) != 1){ + if (avio_rl16(pb) != 1) { av_log(s, AV_LOG_ERROR, "Incorrect header version\n"); return AVERROR_INVALIDDATA; } - width = avio_rl16(pb); + width = avio_rl16(pb); height = avio_rl16(pb); avio_skip(pb, 4); c->frames = avio_rl16(pb); - if(!c->frames){ + if (!c->frames) { av_log(s, AV_LOG_ERROR, "File contains no frames ???\n"); return AVERROR_INVALIDDATA; } - c->bits = avio_rl16(pb); - c->rate = avio_rl16(pb); + c->bits = avio_rl16(pb); + c->rate = avio_rl16(pb); c->block_align = c->rate * (c->bits >> 3); - avio_skip(pb, 16); //zeroes + avio_skip(pb, 16); // zeroes st = avformat_new_stream(s, NULL); if (!st) @@ -135,7 +136,7 @@ static int siff_parse_vbv1(AVFormatContext *s, SIFFContext *c, AVIOContext *pb) c->cur_frame = 0; c->has_video = 1; c->has_audio = !!c->rate; - c->curstrm = -1; + c->curstrm = -1; if (c->has_audio && create_audio_stream(s, c) < 0) return AVERROR(ENOMEM); return 0; @@ -143,17 +144,17 @@ static int siff_parse_vbv1(AVFormatContext *s, SIFFContext *c, AVIOContext *pb) static int siff_parse_soun(AVFormatContext *s, SIFFContext *c, AVIOContext *pb) { - if (avio_rl32(pb) != TAG_SHDR){ + if (avio_rl32(pb) != TAG_SHDR) { av_log(s, AV_LOG_ERROR, "Header chunk is missing\n"); return AVERROR_INVALIDDATA; } - if(avio_rb32(pb) != 8){ + if (avio_rb32(pb) != 8) { av_log(s, AV_LOG_ERROR, "Header chunk size is incorrect\n"); return AVERROR_INVALIDDATA; } - avio_skip(pb, 4); //unknown value - c->rate = avio_rl16(pb); - c->bits = avio_rl16(pb); + avio_skip(pb, 4); // unknown value + c->rate = avio_rl16(pb); + c->bits = avio_rl16(pb); c->block_align = c->rate * (c->bits >> 3); return create_audio_stream(s, c); } @@ -161,16 +162,16 @@ static int siff_parse_soun(AVFormatContext *s, SIFFContext *c, AVIOContext *pb) static int siff_read_header(AVFormatContext *s) { AVIOContext *pb = s->pb; - SIFFContext *c = s->priv_data; + SIFFContext *c = s->priv_data; uint32_t tag; int ret; if (avio_rl32(pb) != TAG_SIFF) return AVERROR_INVALIDDATA; - avio_skip(pb, 4); //ignore size + avio_skip(pb, 4); // ignore size tag = avio_rl32(pb); - if (tag != TAG_VBV1 && tag != TAG_SOUN){ + if (tag != TAG_VBV1 && tag != TAG_SOUN) { av_log(s, AV_LOG_ERROR, "Not a VBV file\n"); return AVERROR_INVALIDDATA; } @@ -179,11 +180,11 @@ static int siff_read_header(AVFormatContext *s) return ret; if (tag == TAG_SOUN && (ret = siff_parse_soun(s, c, pb)) < 0) return ret; - if (avio_rl32(pb) != MKTAG('B', 'O', 'D', 'Y')){ + if (avio_rl32(pb) != MKTAG('B', 'O', 'D', 'Y')) { av_log(s, AV_LOG_ERROR, "'BODY' chunk is missing\n"); return AVERROR_INVALIDDATA; } - avio_skip(pb, 4); //ignore size + avio_skip(pb, 4); // ignore size return 0; } @@ -193,20 +194,20 @@ static int siff_read_packet(AVFormatContext *s, AVPacket *pkt) SIFFContext *c = s->priv_data; int size; - if (c->has_video){ + if (c->has_video) { if (c->cur_frame >= c->frames) return AVERROR_EOF; - if (c->curstrm == -1){ + if (c->curstrm == -1) { c->pktsize = avio_rl32(s->pb) - 4; - c->flags = avio_rl16(s->pb); + c->flags = avio_rl16(s->pb); c->gmcsize = (c->flags & VB_HAS_GMC) ? 4 : 0; if (c->gmcsize) avio_read(s->pb, c->gmc, c->gmcsize); - c->sndsize = (c->flags & VB_HAS_AUDIO) ? avio_rl32(s->pb): 0; + c->sndsize = (c->flags & VB_HAS_AUDIO) ? avio_rl32(s->pb) : 0; c->curstrm = !!(c->flags & VB_HAS_AUDIO); } - if (!c->curstrm){ + if (!c->curstrm) { size = c->pktsize - c->sndsize - c->gmcsize - 2; size = ffio_limit(s->pb, size); if(size < 0 || c->pktsize < c->sndsize) @@ -221,23 +222,23 @@ static int siff_read_packet(AVFormatContext *s, AVPacket *pkt) return AVERROR_INVALIDDATA; } pkt->stream_index = 0; - c->curstrm = -1; - }else{ + c->curstrm = -1; + } else { if ((size = av_get_packet(s->pb, pkt, c->sndsize - 4)) < 0) return AVERROR(EIO); pkt->stream_index = 1; pkt->duration = size; - c->curstrm = 0; + c->curstrm = 0; } - if(!c->cur_frame || c->curstrm) + if (!c->cur_frame || c->curstrm) pkt->flags |= AV_PKT_FLAG_KEY; if (c->curstrm == -1) c->cur_frame++; - }else{ + } else { size = av_get_packet(s->pb, pkt, c->block_align); - if(!size) + if (!size) return AVERROR_EOF; - if(size < 0) + if (size < 0) return AVERROR(EIO); pkt->duration = size; } |