[FFmpeg-cvslog] avformat: add dvbsub demuxer

Michael Niedermayer git at videolan.org
Mon Jan 5 16:03:38 CET 2015


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sun Jan  4 23:20:52 2015 +0100| [e313735d7d7d0217540eb596904075f3d2e31c33] | committer: Michael Niedermayer

avformat: add dvbsub demuxer

This is needed for probing some dvbsub streams in mpegts

Fixes part of ticket4221

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 libavformat/Makefile     |    1 +
 libavformat/allformats.c |    1 +
 libavformat/dvbsub.c     |   66 ++++++++++++++++++++++++++++++++++++++++++++++
 libavformat/version.h    |    2 +-
 4 files changed, 69 insertions(+), 1 deletion(-)

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 7e4beac..5eb834e 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -130,6 +130,7 @@ OBJS-$(CONFIG_DTS_DEMUXER)               += dtsdec.o rawdec.o
 OBJS-$(CONFIG_DTS_MUXER)                 += rawenc.o
 OBJS-$(CONFIG_DV_DEMUXER)                += dv.o
 OBJS-$(CONFIG_DV_MUXER)                  += dvenc.o
+OBJS-$(CONFIG_DVBSUB_DEMUXER)            += dvbsub.o
 OBJS-$(CONFIG_DXA_DEMUXER)               += dxa.o
 OBJS-$(CONFIG_EA_CDATA_DEMUXER)          += eacdata.o
 OBJS-$(CONFIG_EA_DEMUXER)                += electronicarts.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index a55e209..bc033ef 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -113,6 +113,7 @@ void av_register_all(void)
     REGISTER_MUXDEMUX(DTS,              dts);
     REGISTER_DEMUXER (DTSHD,            dtshd);
     REGISTER_MUXDEMUX(DV,               dv);
+    REGISTER_DEMUXER (DVBSUB,           dvbsub);
     REGISTER_DEMUXER (DXA,              dxa);
     REGISTER_DEMUXER (EA,               ea);
     REGISTER_DEMUXER (EA_CDATA,         ea_cdata);
diff --git a/libavformat/dvbsub.c b/libavformat/dvbsub.c
new file mode 100644
index 0000000..73d9c3e
--- /dev/null
+++ b/libavformat/dvbsub.c
@@ -0,0 +1,66 @@
+/*
+ * RAW dvbsub demuxer
+ * Copyright (c) 2015 Michael Niedermayer <michaelni at gmx.at>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/intreadwrite.h"
+
+#include "avformat.h"
+#include "rawdec.h"
+
+
+static int dvbsub_probe(AVProbeData *p)
+{
+    int i, j, k;
+    const uint8_t *end = p->buf + p->buf_size;
+    int type, page_id, len;
+    int max_score = 0;
+
+    for(i=0; i<p->buf_size; i++){
+        const uint8_t *ptr = p->buf + i;
+        uint8_t histogram[6] = {0};
+        int min = 255;
+        for(j=0; ptr + 6 < end; j++) {
+            if (*ptr != 0x0f)
+                break;
+            type    = ptr[1];
+            page_id = AV_RB16(ptr + 2);
+            len     = AV_RB16(ptr + 4);
+            if (type == 0x80) {
+                ;
+            } else if (type >= 0x10 && type <= 0x14) {
+                histogram[type - 0x10] ++;
+            } else
+                break;
+            ptr += 6 + len;
+        }
+        for (k=0; k < 4; k++) {
+            min = FFMIN(min, histogram[k]);
+        }
+        if (min && j > max_score)
+            max_score = j;
+    }
+
+    if (max_score > 5)
+        return AVPROBE_SCORE_EXTENSION/2;
+
+    return 0;
+}
+
+FF_DEF_RAWSUB_DEMUXER(dvbsub, "raw dvbsub", dvbsub_probe, NULL, AV_CODEC_ID_DVB_SUBTITLE, AVFMT_GENERIC_INDEX)
diff --git a/libavformat/version.h b/libavformat/version.h
index 9c12164..d5c8f6b 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -30,7 +30,7 @@
 #include "libavutil/version.h"
 
 #define LIBAVFORMAT_VERSION_MAJOR 56
-#define LIBAVFORMAT_VERSION_MINOR  17
+#define LIBAVFORMAT_VERSION_MINOR  18
 #define LIBAVFORMAT_VERSION_MICRO 100
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \



More information about the ffmpeg-cvslog mailing list