[FFmpeg-cvslog] avcodec/dvbsubdec: Allow selecting the substream, or all substreams

Michael Niedermayer git at videolan.org
Tue Aug 4 14:27:20 CEST 2015


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Mon Jul 27 16:31:05 2015 +0200| [3f87a17063314dd161d389761f5baa1cda8e61f1] | committer: Michael Niedermayer

avcodec/dvbsubdec: Allow selecting the substream, or all substreams

Fixes Ticket 2161

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

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

 doc/decoders.texi      |    2 ++
 libavcodec/dvbsubdec.c |   19 +++++++++++++------
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/doc/decoders.texi b/doc/decoders.texi
index 5f7110c..a6eb573 100644
--- a/doc/decoders.texi
+++ b/doc/decoders.texi
@@ -209,6 +209,8 @@ Never compute CLUT
 @item 1
 Always compute CLUT and override the one provided in the stream.
 @end table
+ at item dvb_substream
+Selects the dvb substream, or all substreams if -1 which is default.
 
 @end table
 
diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c
index ce03e12..71dd1fe 100644
--- a/libavcodec/dvbsubdec.c
+++ b/libavcodec/dvbsubdec.c
@@ -238,6 +238,7 @@ typedef struct DVBSubContext {
     int compute_edt; /**< if 1 end display time calculated using pts
                           if 0 (Default) calculated using time out */
     int compute_clut;
+    int substream;
     int64_t prev_start;
     DVBSubRegion *region_list;
     DVBSubCLUT   *clut_list;
@@ -368,17 +369,22 @@ static av_cold int dvbsub_init_decoder(AVCodecContext *avctx)
     int i, r, g, b, a = 0;
     DVBSubContext *ctx = avctx->priv_data;
 
-    if (!avctx->extradata || (avctx->extradata_size < 4) || ((avctx->extradata_size % 5 != 0) && (avctx->extradata_size != 4))) {
+    if (ctx->substream < 0) {
+        ctx->composition_id = -1;
+        ctx->ancillary_id   = -1;
+    } else if (!avctx->extradata || (avctx->extradata_size < 4) || ((avctx->extradata_size % 5 != 0) && (avctx->extradata_size != 4))) {
         av_log(avctx, AV_LOG_WARNING, "Invalid DVB subtitles stream extradata!\n");
         ctx->composition_id = -1;
         ctx->ancillary_id   = -1;
     } else {
-        if (avctx->extradata_size > 5) {
-            av_log(avctx, AV_LOG_WARNING, "Decoding first DVB subtitles sub-stream\n");
+        if (avctx->extradata_size > 5*ctx->substream + 2) {
+            ctx->composition_id = AV_RB16(avctx->extradata + 5*ctx->substream);
+            ctx->ancillary_id   = AV_RB16(avctx->extradata + 5*ctx->substream + 2);
+        } else {
+            av_log(avctx, AV_LOG_WARNING, "Selected DVB subtitles sub-stream %d is not available\n", ctx->substream);
+            ctx->composition_id = AV_RB16(avctx->extradata);
+            ctx->ancillary_id   = AV_RB16(avctx->extradata + 2);
         }
-
-        ctx->composition_id = AV_RB16(avctx->extradata);
-        ctx->ancillary_id   = AV_RB16(avctx->extradata + 2);
     }
 
     ctx->version = -1;
@@ -1715,6 +1721,7 @@ end:
 static const AVOption options[] = {
     {"compute_edt", "compute end of time using pts or timeout", offsetof(DVBSubContext, compute_edt), FF_OPT_TYPE_INT, {.i64 = 0}, 0, 1, DS},
     {"compute_clut", "compute clut when not available(-1) or always(1) or never(0)", offsetof(DVBSubContext, compute_clut), FF_OPT_TYPE_INT, {.i64 = -1}, -1, 1, DS},
+    {"dvb_substream", "", offsetof(DVBSubContext, substream), FF_OPT_TYPE_INT, {.i64 = -1}, -1, 63, DS},
     {NULL}
 };
 static const AVClass dvbsubdec_class = {



More information about the ffmpeg-cvslog mailing list