changeset 1463:acf4dbb1a7e6 libavformat

mpeg4probe patch by (Thijs Vermeir ; thijs vermeir barco com) tabs removed by me VOL vs. VOP check fixed by me
author michael
date Wed, 08 Nov 2006 01:21:23 +0000
parents e5e2d80a859c
children ca301b0f2c7d
files raw.c
diffstat 1 files changed, 31 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/raw.c	Wed Nov 08 01:15:06 2006 +0000
+++ b/raw.c	Wed Nov 08 01:21:23 2006 +0000
@@ -346,6 +346,36 @@
     return 0;
 }
 
+#define VIDEO_OBJECT_START_CODE        0x00000100
+#define VIDEO_OBJECT_LAYER_START_CODE  0x00000120
+#define VISUAL_OBJECT_START_CODE       0x000001b5
+#define VOP_START_CODE                 0x000001b6
+
+static int mpeg4video_probe(AVProbeData *probe_packet)
+{
+    uint32_t temp_buffer= -1;
+    int VO=0, VOL=0, VOP = 0, VISO = 0;
+    int i;
+
+    for(i=0; i<probe_packet->buf_size; i++){
+        temp_buffer = (temp_buffer<<8) + probe_packet->buf[i];
+        if ((temp_buffer & 0xffffff00) == 0x100) {
+            switch(temp_buffer){
+            case VOP_START_CODE:             VOP++; break;
+            case VISUAL_OBJECT_START_CODE:  VISO++; break;
+            }
+            switch(temp_buffer & 0xfffffff0){
+            case VIDEO_OBJECT_START_CODE:            VO++; break;
+            case VIDEO_OBJECT_LAYER_START_CODE:     VOL++; break;
+            }
+        }
+    }
+
+    if ( VOP >= VISO && VOP >= VOL && VO >= VOL && VOL > 0)
+        return AVPROBE_SCORE_MAX/2;
+    return 0;
+}
+
 static int h263_probe(AVProbeData *p)
 {
     int code;
@@ -523,7 +553,7 @@
     "m4v",
     "raw MPEG4 video format",
     0,
-    NULL /*mpegvideo_probe*/,
+    mpeg4video_probe, /** probing for mpeg4 data */
     video_read_header,
     raw_read_partial_packet,
     raw_read_close,