diff options
author | Kacper Michajłow <kasper93@gmail.com> | 2024-03-23 09:45:00 +0100 |
---|---|---|
committer | Kacper Michajłow <kasper93@gmail.com> | 2024-04-17 23:41:30 +0200 |
commit | 35c6b62ddc2ed60e0195173d0937714ce778bca8 (patch) | |
tree | 85bc0d8aa406a0a71123543dff105ef573c9db6c /sub/lavc_conv.c | |
parent | 73779a8c706cf5458260f44a9b5c5398a8683fb6 (diff) | |
download | mpv-35c6b62ddc2ed60e0195173d0937714ce778bca8.tar.bz2 mpv-35c6b62ddc2ed60e0195173d0937714ce778bca8.tar.xz |
sub/lavc_conv: set dvb teletext and arib caption output type to ASS
Also set teletext page while at it.
Diffstat (limited to 'sub/lavc_conv.c')
-rw-r--r-- | sub/lavc_conv.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/sub/lavc_conv.c b/sub/lavc_conv.c index 9513dbf0bb..605a58b585 100644 --- a/sub/lavc_conv.c +++ b/sub/lavc_conv.c @@ -32,6 +32,7 @@ struct lavc_conv { struct mp_log *log; + struct mp_subtitle_opts *opts; AVCodecContext *avctx; AVPacket *avpkt; AVPacket *avpkt_vtt; @@ -70,6 +71,7 @@ struct lavc_conv *lavc_conv_create(struct sd *sd) { struct lavc_conv *priv = talloc_zero(NULL, struct lavc_conv); priv->log = sd->log; + priv->opts = sd->opts; priv->cur_list = talloc_array(priv, char*, 0); priv->codec = talloc_strdup(priv, sd->codec->codec); AVCodecContext *avctx = NULL; @@ -89,6 +91,15 @@ struct lavc_conv *lavc_conv_create(struct sd *sd) if (!priv->avpkt || !priv->avpkt_vtt) goto error; + switch (codec->id) { + case AV_CODEC_ID_DVB_TELETEXT: + av_dict_set_int(&opts, "txt_format", 2, 0); + break; + case AV_CODEC_ID_ARIB_CAPTION: + av_dict_set_int(&opts, "sub_type", SUBTITLE_ASS, 0); + break; + } + #if LIBAVCODEC_VERSION_MAJOR < 59 av_dict_set(&opts, "sub_text_format", "ass", 0); #endif @@ -249,6 +260,18 @@ char **lavc_conv_decode(struct lavc_conv *priv, struct demux_packet *packet, curr_pkt = priv->avpkt_vtt; } + if (avctx->codec_id == AV_CODEC_ID_DVB_TELETEXT) { + if (!priv->opts->teletext_page) { + av_opt_set(avctx, "txt_page", "subtitle", AV_OPT_SEARCH_CHILDREN); + } else if (priv->opts->teletext_page == -1) { + av_opt_set(avctx, "txt_page", "*", AV_OPT_SEARCH_CHILDREN); + } else { + char page[4]; + snprintf(page, sizeof(page), "%d", priv->opts->teletext_page); + av_opt_set(avctx, "txt_page", page, AV_OPT_SEARCH_CHILDREN); + } + } + ret = avcodec_decode_subtitle2(avctx, &priv->cur, &got_sub, curr_pkt); if (ret < 0) { MP_ERR(priv, "Error decoding subtitle\n"); |