diff options
author | wm4 <wm4@nowhere> | 2016-09-03 17:05:11 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-09-03 17:12:53 +0200 |
commit | 4f263dce34822a3f8356f88fa736353a20fd0c8c (patch) | |
tree | b67ba23fa637129581d5f8b54fceaa5c1787d513 /sub | |
parent | 590caeb2bdeddd85aa86e4b08c05db058c538433 (diff) |
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.
Diffstat (limited to 'sub')
-rw-r--r-- | sub/sd_lavc.c | 11 |
1 files changed, 11 insertions, 0 deletions
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 <libavcodec/avcodec.h> #include <libavutil/common.h> #include <libavutil/intreadwrite.h> +#include <libavutil/opt.h> #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) |