Also set teletext page while at it.
Unified · Split
| @@ -32,6 +32,7 @@ · 31 unmodified lines | |||
| 32 | 32 | ||
| 33 | struct lavc_conv { | 33 | struct lavc_conv { |
| 34 | struct mp_log *log; | 34 | struct mp_log *log; |
| 35 | struct mp_subtitle_opts *opts; | ||
| 35 | AVCodecContext *avctx; | 36 | AVCodecContext *avctx; |
| 36 | AVPacket *avpkt; | 37 | AVPacket *avpkt; |
| 37 | AVPacket *avpkt_vtt; | 38 | AVPacket *avpkt_vtt; |
| @@ -70,6 +71,7 @@ struct lavc_conv *lavc_conv_create(struct sd *sd) · 32 unmodified lines | |||
| 70 | { | 71 | { |
| 71 | struct lavc_conv *priv = talloc_zero(NULL, struct lavc_conv); | 72 | struct lavc_conv *priv = talloc_zero(NULL, struct lavc_conv); |
| 72 | priv->log = sd->log; | 73 | priv->log = sd->log; |
| 74 | priv->opts = sd->opts; | ||
| 73 | priv->cur_list = talloc_array(priv, char*, 0); | 75 | priv->cur_list = talloc_array(priv, char*, 0); |
| 74 | priv->codec = talloc_strdup(priv, sd->codec->codec); | 76 | priv->codec = talloc_strdup(priv, sd->codec->codec); |
| 75 | AVCodecContext *avctx = NULL; | 77 | AVCodecContext *avctx = NULL; |
| @@ -89,6 +91,15 @@ struct lavc_conv *lavc_conv_create(struct sd *sd) · 13 unmodified lines | |||
| 89 | if (!priv->avpkt || !priv->avpkt_vtt) | 91 | if (!priv->avpkt || !priv->avpkt_vtt) |
| 90 | goto error; | 92 | goto error; |
| 91 | 93 | ||
| 94 | switch (codec->id) { | ||
| 95 | case AV_CODEC_ID_DVB_TELETEXT: | ||
| 96 | av_dict_set_int(&opts, "txt_format", 2, 0); | ||
| 97 | break; | ||
| 98 | case AV_CODEC_ID_ARIB_CAPTION: | ||
| 99 | av_dict_set_int(&opts, "sub_type", SUBTITLE_ASS, 0); | ||
| 100 | break; | ||
| 101 | } | ||
| 102 | |||
| 92 | #if LIBAVCODEC_VERSION_MAJOR < 59 | 103 | #if LIBAVCODEC_VERSION_MAJOR < 59 |
| 93 | av_dict_set(&opts, "sub_text_format", "ass", 0); | 104 | av_dict_set(&opts, "sub_text_format", "ass", 0); |
| 94 | #endif | 105 | #endif |
| @@ -249,6 +260,18 @@ char **lavc_conv_decode(struct lavc_conv *priv, struct demux_packet *packet, · 154 unmodified lines | |||
| 249 | curr_pkt = priv->avpkt_vtt; | 260 | curr_pkt = priv->avpkt_vtt; |
| 250 | } | 261 | } |
| 251 | 262 | ||
| 263 | if (avctx->codec_id == AV_CODEC_ID_DVB_TELETEXT) { | ||
| 264 | if (!priv->opts->teletext_page) { | ||
| 265 | av_opt_set(avctx, "txt_page", "subtitle", AV_OPT_SEARCH_CHILDREN); | ||
| 266 | } else if (priv->opts->teletext_page == -1) { | ||
| 267 | av_opt_set(avctx, "txt_page", "*", AV_OPT_SEARCH_CHILDREN); | ||
| 268 | } else { | ||
| 269 | char page[4]; | ||
| 270 | snprintf(page, sizeof(page), "%d", priv->opts->teletext_page); | ||
| 271 | av_opt_set(avctx, "txt_page", page, AV_OPT_SEARCH_CHILDREN); | ||
| 272 | } | ||
| 273 | } | ||
| 274 | |||
| 252 | ret = avcodec_decode_subtitle2(avctx, &priv->cur, &got_sub, curr_pkt); | 275 | ret = avcodec_decode_subtitle2(avctx, &priv->cur, &got_sub, curr_pkt); |
| 253 | if (ret < 0) { | 276 | if (ret < 0) { |
| 254 | MP_ERR(priv, "Error decoding subtitle\n"); | 277 | MP_ERR(priv, "Error decoding subtitle\n"); |