summaryrefslogtreecommitdiff
path: root/libavcodec/dvbsubdec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2015-07-27 16:31:05 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2015-08-04 14:24:13 +0200
commit3f87a17063314dd161d389761f5baa1cda8e61f1 (patch)
treedc31253d9825c411f3ad752875d6d38e93b748ca /libavcodec/dvbsubdec.c
parentf6518e51b8ed9909bb70ddeae24cff2a15bfa391 (diff)
downloadffmpeg-3f87a17063314dd161d389761f5baa1cda8e61f1.tar.gz
avcodec/dvbsubdec: Allow selecting the substream, or all substreams
Fixes Ticket 2161 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/dvbsubdec.c')
-rw-r--r--libavcodec/dvbsubdec.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c
index ce03e12d4a..71dd1fea8b 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 = {