History

sub/lavc_conv: set dvb teletext and arib caption output type to ASS

Also set teletext page while at it.

Kacper Michajłow committed 2 years ago

Commit 35c6b621 parent 73779a81 file · +23 −0Browse files

Unified · Split

sub/lavc_conv.c+23−0
@@ -32,6 +32,7 @@ · 31 unmodified lines
3232
3333 struct lavc_conv {
3434 struct mp_log *log;
35+ struct mp_subtitle_opts *opts;
3536 AVCodecContext *avctx;
3637 AVPacket *avpkt;
3738 AVPacket *avpkt_vtt;
@@ -70,6 +71,7 @@ struct lavc_conv *lavc_conv_create(struct sd *sd) · 32 unmodified lines
7071 {
7172 struct lavc_conv *priv = talloc_zero(NULL, struct lavc_conv);
7273 priv->log = sd->log;
74+ priv->opts = sd->opts;
7375 priv->cur_list = talloc_array(priv, char*, 0);
7476 priv->codec = talloc_strdup(priv, sd->codec->codec);
7577 AVCodecContext *avctx = NULL;
@@ -89,6 +91,15 @@ struct lavc_conv *lavc_conv_create(struct sd *sd) · 13 unmodified lines
8991 if (!priv->avpkt || !priv->avpkt_vtt)
9092 goto error;
9193
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+
92103 #if LIBAVCODEC_VERSION_MAJOR < 59
93104 av_dict_set(&opts, "sub_text_format", "ass", 0);
94105 #endif
@@ -249,6 +260,18 @@ char **lavc_conv_decode(struct lavc_conv *priv, struct demux_packet *packet, · 154 unmodified lines
249260 curr_pkt = priv->avpkt_vtt;
250261 }
251262
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+
252275 ret = avcodec_decode_subtitle2(avctx, &priv->cur, &got_sub, curr_pkt);
253276 if (ret < 0) {
254277 MP_ERR(priv, "Error decoding subtitle\n");

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t