From 4f263dce34822a3f8356f88fa736353a20fd0c8c Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 3 Sep 2016 17:05:11 +0200 Subject: sd_lavc: enable teletext Whitelisting supported codecs is (probably) still better than just allowing everything, given the weird FFmpeg API. I'm also assuming Libav doesn't even have the codec ID, but I didn't check. Also add a --teletext-page option, since otherwise it decodes every teletext page and shows them in succession. And yes, we can't use av_opt_set_int() - instead we have to set it as string. Because FFmpeg's option system is terrible. --- sub/sd_lavc.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'sub') diff --git a/sub/sd_lavc.c b/sub/sd_lavc.c index f310367734..2c1b327b38 100644 --- a/sub/sd_lavc.c +++ b/sub/sd_lavc.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "config.h" @@ -106,6 +107,9 @@ static int init(struct sd *sd) // Supported codecs must be known to decode to paletted bitmaps switch (cid) { case AV_CODEC_ID_DVB_SUBTITLE: +#if LIBAVCODEC_VERSION_MICRO >= 100 + case AV_CODEC_ID_DVB_TELETEXT: +#endif case AV_CODEC_ID_HDMV_PGS_SUBTITLE: case AV_CODEC_ID_XSUB: case AV_CODEC_ID_DVD_SUBTITLE: @@ -339,6 +343,13 @@ static void decode(struct sd *sd, struct demux_packet *packet) MP_WARN(sd, "Subtitle with unknown start time.\n"); mp_set_av_packet(&pkt, packet, &priv->pkt_timebase); + + if (ctx->codec_id == AV_CODEC_ID_DVB_TELETEXT) { + char page[4]; + snprintf(page, sizeof(page), "%d", opts->teletext_page); + av_opt_set(ctx, "txt_page", page, AV_OPT_SEARCH_CHILDREN); + } + int got_sub; int res = avcodec_decode_subtitle2(ctx, &sub, &got_sub, &pkt); if (res < 0 || !got_sub) -- cgit v1.2.3