add raw demuxer for Chinese AVS elementary streams
authorStefan Gehrer <stefan.gehrer@gmx.de>
Sat, 21 Feb 2009 10:34:29 +0000 (10:34 +0000)
committerStefan Gehrer <stefan.gehrer@gmx.de>
Sat, 21 Feb 2009 10:34:29 +0000 (10:34 +0000)
Originally committed as revision 17473 to svn://svn.ffmpeg.org/ffmpeg/trunk

libavformat/Makefile
libavformat/allformats.c
libavformat/raw.c

index bf6fce20e924a04a2a6870a841886e1129a708a5..4dcb2d491c1f7a95f5921c835cd9bfdc14534fbf 100644 (file)
@@ -33,6 +33,7 @@ OBJS-$(CONFIG_AVS_DEMUXER)               += avs.o vocdec.o voc.o
 OBJS-$(CONFIG_BETHSOFTVID_DEMUXER)       += bethsoftvid.o
 OBJS-$(CONFIG_BFI_DEMUXER)               += bfi.o
 OBJS-$(CONFIG_C93_DEMUXER)               += c93.o vocdec.o voc.o
+OBJS-$(CONFIG_CAVSVIDEO_DEMUXER)         += raw.o
 OBJS-$(CONFIG_CRC_MUXER)                 += crcenc.o
 OBJS-$(CONFIG_DAUD_DEMUXER)              += daud.o
 OBJS-$(CONFIG_DAUD_MUXER)                += daud.o
index 1eaab3ce990c752cd52f916a20b1ee44895a6334..4be6a87d7ed586b67e12a6dbe9c65a7b0633c825 100644 (file)
@@ -65,6 +65,7 @@ void av_register_all(void)
     REGISTER_DEMUXER  (BETHSOFTVID, bethsoftvid);
     REGISTER_DEMUXER  (BFI, bfi);
     REGISTER_DEMUXER  (C93, c93);
+    REGISTER_DEMUXER  (CAVSVIDEO, cavsvideo);
     REGISTER_MUXER    (CRC, crc);
     REGISTER_MUXDEMUX (DAUD, daud);
     REGISTER_MUXDEMUX (DIRAC, dirac);
index 9ddd55fd8852e13e1e8de010753112a9053113ef..ca28b57b924d1581c718bb3d8d54aff3fe0d8cf4 100644 (file)
@@ -365,6 +365,49 @@ static int mpegvideo_probe(AVProbeData *p)
         return AVPROBE_SCORE_MAX/2+1; // +1 for .mpg
     return 0;
 }
+
+#define CAVS_SEQ_START_CODE       0x000001b0
+#define CAVS_PIC_I_START_CODE     0x000001b3
+#define CAVS_UNDEF_START_CODE     0x000001b4
+#define CAVS_PIC_PB_START_CODE    0x000001b6
+#define CAVS_VIDEO_EDIT_CODE      0x000001b7
+#define CAVS_PROFILE_JIZHUN       0x20
+
+static int cavsvideo_probe(AVProbeData *p)
+{
+    uint32_t code= -1;
+    int pic=0, seq=0, slice_pos = 0;
+    int i;
+
+    for(i=0; i<p->buf_size; i++){
+        code = (code<<8) + p->buf[i];
+        if ((code & 0xffffff00) == 0x100) {
+            if(code < CAVS_SEQ_START_CODE) {
+                /* slices have to be consecutive */
+                if(code < slice_pos)
+                    return 0;
+                slice_pos = code;
+            } else {
+                slice_pos = 0;
+            }
+            if (code == CAVS_SEQ_START_CODE) {
+                seq++;
+                /* check for the only currently supported profile */
+                if(p->buf[i+1] != CAVS_PROFILE_JIZHUN)
+                    return 0;
+            } else if ((code == CAVS_PIC_I_START_CODE) ||
+                       (code == CAVS_PIC_PB_START_CODE)) {
+                pic++;
+            } else if ((code == CAVS_UNDEF_START_CODE) ||
+                       (code >  CAVS_VIDEO_EDIT_CODE)) {
+                return 0;
+            }
+        }
+    }
+    if(seq && seq*9<=pic*10)
+        return AVPROBE_SCORE_MAX/2;
+    return 0;
+}
 #endif
 
 #if CONFIG_M4V_DEMUXER
@@ -1054,6 +1097,19 @@ AVInputFormat mpegvideo_demuxer = {
 };
 #endif
 
+#if CONFIG_CAVSVIDEO_DEMUXER
+AVInputFormat cavsvideo_demuxer = {
+    "cavsvideo",
+    NULL_IF_CONFIG_SMALL("Chinese AVS video"),
+    0,
+    cavsvideo_probe,
+    video_read_header,
+    raw_read_partial_packet,
+    .flags= AVFMT_GENERIC_INDEX,
+    .value = CODEC_ID_CAVS,
+};
+#endif
+
 #if CONFIG_NULL_MUXER
 AVOutputFormat null_muxer = {
     "null",