summaryrefslogtreecommitdiff
path: root/libavformat/wav.c
diff options
context:
space:
mode:
authorTomas Härdin <tomas.hardin@codemill.se>2011-02-17 15:58:10 +0100
committerAnton Khirnov <anton@khirnov.net>2011-07-13 11:57:51 +0200
commit90f2ee8cb4d2b135dd33128a94ad6cf126821472 (patch)
treed857b8b3342471a30a99d1d775859ea5086f46ad /libavformat/wav.c
parent1cf18de982a0a62fa9214a6c4a5becc1a32d9caf (diff)
wav: Refactor the tag checking into a switch statement
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Diffstat (limited to 'libavformat/wav.c')
-rw-r--r--libavformat/wav.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/libavformat/wav.c b/libavformat/wav.c
index 9f902be818..cf815ef3df 100644
--- a/libavformat/wav.c
+++ b/libavformat/wav.c
@@ -334,7 +334,8 @@ static int wav_read_header(AVFormatContext *s,
size = next_tag(pb, &tag);
next_tag_ofs = avio_tell(pb) + size;
- if (tag == MKTAG('f', 'm', 't', ' ')) {
+ switch (tag) {
+ case MKTAG('f', 'm', 't', ' '):
/* only parse the first 'fmt ' tag found */
if (!got_fmt && (ret = wav_parse_fmt_tag(s, size, &st) < 0)) {
return ret;
@@ -342,18 +343,22 @@ static int wav_read_header(AVFormatContext *s,
av_log(s, AV_LOG_WARNING, "found more than one 'fmt ' tag\n");
got_fmt = 1;
- } else if (tag == MKTAG('d', 'a', 't', 'a')) {
+ break;
+ case MKTAG('d', 'a', 't', 'a'):
if (!got_fmt) {
av_log(s, AV_LOG_ERROR, "found no 'fmt ' tag before the 'data' tag\n");
return AVERROR_INVALIDDATA;
}
+ goto break_loop;
+ case MKTAG('f','a','c','t'):
+ if (!sample_count)
+ sample_count = avio_rl32(pb);
break;
- }else if (tag == MKTAG('f','a','c','t') && !sample_count){
- sample_count = avio_rl32(pb);
}
avio_seek(pb, next_tag_ofs, SEEK_SET);
}
+break_loop:
if (rf64)
size = data_size;
if (size < 0)