[PATCH 2/6] Refactor the tag checking into a switch statement

Tomas Härdin tomas.hardin
Thu Feb 17 15:58:10 CET 2011


---
 libavformat/wav.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/libavformat/wav.c b/libavformat/wav.c
index c214cfa..7aef85e 100644
--- a/libavformat/wav.c
+++ b/libavformat/wav.c
@@ -245,24 +245,28 @@ static int wav_read_header(AVFormatContext *s,
         size = next_tag(pb, &tag);
         next_tag_ofs = url_ftell(pb) + size;
 
-        if (tag == MKTAG('f', 'm', 't', ' ')) {
+        switch (tag) {
+        case MKTAG('f', 'm', 't', ' '):
             if ((ret = wav_parse_fmt_tag(s, size, &st) < 0))
                 return ret;
 
             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;
             }
 
-            break;
-        }else if (tag == MKTAG('f','a','c','t') && !sample_count){
+            goto break_loop;
+        case MKTAG('f','a','c','t'):
+            if(!sample_count)
             sample_count = avio_rl32(pb);
+            break;
         }
         avio_seek(pb, next_tag_ofs, SEEK_SET);
     }
+break_loop:
     if (rf64)
         size = data_size;
     if (size < 0)
-- 
1.7.1


--------------020501090207090200090101--



More information about the ffmpeg-devel mailing list