[FFmpeg-cvslog] avformat/av1dec: simplify annexb_probe()

James Almer git at videolan.org
Sat Nov 16 20:56:49 EET 2019


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Fri Nov 15 20:34:08 2019 -0300| [81d54531f788a1da65b124694c5ef389352289fc] | committer: James Almer

avformat/av1dec: simplify annexb_probe()

Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=81d54531f788a1da65b124694c5ef389352289fc
---

 libavformat/av1dec.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/libavformat/av1dec.c b/libavformat/av1dec.c
index 5e7a057cb7..1be2fac1c1 100644
--- a/libavformat/av1dec.c
+++ b/libavformat/av1dec.c
@@ -75,7 +75,7 @@ static int annexb_probe(const AVProbeData *p)
     AVIOContext pb;
     int64_t obu_size;
     uint32_t temporal_unit_size, frame_unit_size, obu_unit_size;
-    int seq = 0, frame_header = 0;
+    int seq = 0;
     int ret, type, cnt = 0;
 
     ffio_init_context(&pb, p->buf, p->buf_size, 0,
@@ -123,22 +123,25 @@ static int annexb_probe(const AVProbeData *p)
             return 0;
         cnt += obu_unit_size;
 
-        if (type == AV1_OBU_SEQUENCE_HEADER)
+        switch (type) {
+        case AV1_OBU_SEQUENCE_HEADER:
             seq = 1;
-        if (type == AV1_OBU_FRAME || type == AV1_OBU_FRAME_HEADER) {
-            if (frame_header || !seq)
-                return 0;
-            frame_header = 1;
             break;
-        }
-        if (type == AV1_OBU_TILE_GROUP && !frame_header)
+        case AV1_OBU_FRAME:
+        case AV1_OBU_FRAME_HEADER:
+            return seq ? AVPROBE_SCORE_EXTENSION + 1 : 0;
+        case AV1_OBU_TILE_GROUP:
+        case AV1_OBU_TEMPORAL_DELIMITER:
             return 0;
+        default:
+            break;
+        }
 
         temporal_unit_size -= obu_unit_size + ret;
         frame_unit_size -= obu_unit_size + ret;
-    } while (!frame_header && frame_unit_size);
+    } while (frame_unit_size);
 
-    return frame_header ? AVPROBE_SCORE_EXTENSION + 1 : 0;
+    return 0;
 }
 
 static int annexb_read_header(AVFormatContext *s)



More information about the ffmpeg-cvslog mailing list