Jan Ekström | 18713d2 | 2017-01-19 13:02:27 | [diff] [blame] | 1 | /* |
| 2 | * TTML subtitle encoder |
| 3 | * Copyright (c) 2020 24i |
| 4 | * |
| 5 | * This file is part of FFmpeg. |
| 6 | * |
| 7 | * FFmpeg is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Lesser General Public |
| 9 | * License as published by the Free Software Foundation; either |
| 10 | * version 2.1 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * FFmpeg is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * Lesser General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Lesser General Public |
| 18 | * License along with FFmpeg; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | */ |
| 21 | |
| 22 | /** |
| 23 | * @file |
| 24 | * TTML subtitle encoder |
| 25 | * @see https://www.w3.org/TR/ttml1/ |
| 26 | * @see https://www.w3.org/TR/ttml2/ |
| 27 | * @see https://www.w3.org/TR/ttml-imsc/rec |
| 28 | */ |
| 29 | |
| 30 | #include "avcodec.h" |
Andreas Rheinhardt | a688f3c | 2022-03-16 17:18:28 | [diff] [blame] | 31 | #include "codec_internal.h" |
Jan Ekström | 18713d2 | 2017-01-19 13:02:27 | [diff] [blame] | 32 | #include "libavutil/bprint.h" |
| 33 | #include "libavutil/internal.h" |
Andreas Rheinhardt | 790f793 | 2024-03-25 00:30:37 | [diff] [blame] | 34 | #include "libavutil/mem.h" |
Jan Ekström | 18713d2 | 2017-01-19 13:02:27 | [diff] [blame] | 35 | #include "ass_split.h" |
Jan Ekström | 18713d2 | 2017-01-19 13:02:27 | [diff] [blame] | 36 | #include "ttmlenc.h" |
| 37 | |
| 38 | typedef struct { |
| 39 | AVCodecContext *avctx; |
| 40 | ASSSplitContext *ass_ctx; |
| 41 | AVBPrint buffer; |
| 42 | } TTMLContext; |
| 43 | |
| 44 | static void ttml_text_cb(void *priv, const char *text, int len) |
| 45 | { |
| 46 | TTMLContext *s = priv; |
Andreas Rheinhardt | c1714a4 | 2023-09-11 14:08:05 | [diff] [blame] | 47 | AVBPrint cur_line; |
Jan Ekström | 18713d2 | 2017-01-19 13:02:27 | [diff] [blame] | 48 | AVBPrint *buffer = &s->buffer; |
| 49 | |
| 50 | av_bprint_init(&cur_line, len, AV_BPRINT_SIZE_UNLIMITED); |
| 51 | |
| 52 | av_bprint_append_data(&cur_line, text, len); |
| 53 | if (!av_bprint_is_complete(&cur_line)) { |
| 54 | av_log(s->avctx, AV_LOG_ERROR, |
| 55 | "Failed to move the current subtitle dialog to AVBPrint!\n"); |
| 56 | av_bprint_finalize(&cur_line, NULL); |
| 57 | return; |
| 58 | } |
| 59 | |
| 60 | |
| 61 | av_bprint_escape(buffer, cur_line.str, NULL, AV_ESCAPE_MODE_XML, |
| 62 | 0); |
| 63 | |
| 64 | av_bprint_finalize(&cur_line, NULL); |
| 65 | } |
| 66 | |
| 67 | static void ttml_new_line_cb(void *priv, int forced) |
| 68 | { |
| 69 | TTMLContext *s = priv; |
| 70 | |
| 71 | av_bprintf(&s->buffer, "<br/>"); |
| 72 | } |
| 73 | |
| 74 | static const ASSCodesCallbacks ttml_callbacks = { |
| 75 | .text = ttml_text_cb, |
| 76 | .new_line = ttml_new_line_cb, |
| 77 | }; |
| 78 | |
| 79 | static int ttml_encode_frame(AVCodecContext *avctx, uint8_t *buf, |
| 80 | int bufsize, const AVSubtitle *sub) |
| 81 | { |
| 82 | TTMLContext *s = avctx->priv_data; |
| 83 | ASSDialog *dialog; |
| 84 | int i; |
| 85 | |
Andreas Rheinhardt | 253a834 | 2024-02-18 00:23:26 | [diff] [blame] | 86 | av_bprint_init_for_buffer(&s->buffer, buf, bufsize); |
Jan Ekström | 18713d2 | 2017-01-19 13:02:27 | [diff] [blame] | 87 | |
| 88 | for (i=0; i<sub->num_rects; i++) { |
| 89 | const char *ass = sub->rects[i]->ass; |
Andreas Rheinhardt | 6c497ac | 2021-02-25 19:33:44 | [diff] [blame] | 90 | int ret; |
Jan Ekström | 18713d2 | 2017-01-19 13:02:27 | [diff] [blame] | 91 | |
| 92 | if (sub->rects[i]->type != SUBTITLE_ASS) { |
| 93 | av_log(avctx, AV_LOG_ERROR, "Only SUBTITLE_ASS type supported.\n"); |
| 94 | return AVERROR(EINVAL); |
| 95 | } |
| 96 | |
Andreas Rheinhardt | 5ad436f | 2021-08-07 21:52:42 | [diff] [blame] | 97 | dialog = ff_ass_split_dialog(s->ass_ctx, ass); |
Andreas Rheinhardt | 6c497ac | 2021-02-25 19:33:44 | [diff] [blame] | 98 | if (!dialog) |
| 99 | return AVERROR(ENOMEM); |
Jan Ekström | 18713d2 | 2017-01-19 13:02:27 | [diff] [blame] | 100 | |
Andreas Rheinhardt | 6c497ac | 2021-02-25 19:33:44 | [diff] [blame] | 101 | if (dialog->style) { |
| 102 | av_bprintf(&s->buffer, "<span region=\""); |
| 103 | av_bprint_escape(&s->buffer, dialog->style, NULL, |
| 104 | AV_ESCAPE_MODE_XML, |
| 105 | AV_ESCAPE_FLAG_XML_DOUBLE_QUOTES); |
| 106 | av_bprintf(&s->buffer, "\">"); |
| 107 | } |
Jan Ekström | 3ef5a8b | 2021-03-29 13:34:34 | [diff] [blame] | 108 | |
Andreas Rheinhardt | 6c497ac | 2021-02-25 19:33:44 | [diff] [blame] | 109 | ret = ff_ass_split_override_codes(&ttml_callbacks, s, dialog->text); |
| 110 | if (ret < 0) { |
| 111 | int log_level = (ret != AVERROR_INVALIDDATA || |
| 112 | avctx->err_recognition & AV_EF_EXPLODE) ? |
| 113 | AV_LOG_ERROR : AV_LOG_WARNING; |
| 114 | av_log(avctx, log_level, |
| 115 | "Splitting received ASS dialog text %s failed: %s\n", |
| 116 | dialog->text, |
| 117 | av_err2str(ret)); |
Jan Ekström | 18713d2 | 2017-01-19 13:02:27 | [diff] [blame] | 118 | |
Andreas Rheinhardt | 6c497ac | 2021-02-25 19:33:44 | [diff] [blame] | 119 | if (log_level == AV_LOG_ERROR) { |
Jan Ekström | 18713d2 | 2017-01-19 13:02:27 | [diff] [blame] | 120 | ff_ass_free_dialog(&dialog); |
Andreas Rheinhardt | 6c497ac | 2021-02-25 19:33:44 | [diff] [blame] | 121 | return ret; |
Jan Ekström | 18713d2 | 2017-01-19 13:02:27 | [diff] [blame] | 122 | } |
Andreas Rheinhardt | 6c497ac | 2021-02-25 19:33:44 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | if (dialog->style) |
| 126 | av_bprintf(&s->buffer, "</span>"); |
| 127 | |
| 128 | ff_ass_free_dialog(&dialog); |
Jan Ekström | 18713d2 | 2017-01-19 13:02:27 | [diff] [blame] | 129 | } |
| 130 | |
Jan Ekström | 18713d2 | 2017-01-19 13:02:27 | [diff] [blame] | 131 | if (!s->buffer.len) |
| 132 | return 0; |
Andreas Rheinhardt | 253a834 | 2024-02-18 00:23:26 | [diff] [blame] | 133 | if (!av_bprint_is_complete(&s->buffer)) { |
Jan Ekström | 18713d2 | 2017-01-19 13:02:27 | [diff] [blame] | 134 | av_log(avctx, AV_LOG_ERROR, "Buffer too small for TTML event.\n"); |
| 135 | return AVERROR_BUFFER_TOO_SMALL; |
| 136 | } |
| 137 | |
| 138 | return s->buffer.len; |
| 139 | } |
| 140 | |
| 141 | static av_cold int ttml_encode_close(AVCodecContext *avctx) |
| 142 | { |
| 143 | TTMLContext *s = avctx->priv_data; |
| 144 | |
| 145 | ff_ass_split_free(s->ass_ctx); |
| 146 | |
Jan Ekström | 18713d2 | 2017-01-19 13:02:27 | [diff] [blame] | 147 | return 0; |
| 148 | } |
| 149 | |
Jan Ekström | 3ef5a8b | 2021-03-29 13:34:34 | [diff] [blame] | 150 | static const char *ttml_get_display_alignment(int alignment) |
| 151 | { |
| 152 | switch (alignment) { |
| 153 | case 1: |
| 154 | case 2: |
| 155 | case 3: |
| 156 | return "after"; |
| 157 | case 4: |
| 158 | case 5: |
| 159 | case 6: |
| 160 | return "center"; |
| 161 | case 7: |
| 162 | case 8: |
| 163 | case 9: |
| 164 | return "before"; |
| 165 | default: |
| 166 | return NULL; |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | static const char *ttml_get_text_alignment(int alignment) |
| 171 | { |
| 172 | switch (alignment) { |
| 173 | case 1: |
| 174 | case 4: |
| 175 | case 7: |
| 176 | return "left"; |
| 177 | case 2: |
| 178 | case 5: |
| 179 | case 8: |
| 180 | return "center"; |
| 181 | case 3: |
| 182 | case 6: |
| 183 | case 9: |
| 184 | return "right"; |
| 185 | default: |
| 186 | return NULL; |
| 187 | } |
| 188 | } |
| 189 | |
Jan Ekström | b24488e | 2021-03-29 14:19:58 | [diff] [blame] | 190 | static void ttml_get_origin(ASSScriptInfo script_info, ASSStyle style, |
| 191 | int *origin_left, int *origin_top) |
| 192 | { |
| 193 | *origin_left = av_rescale(style.margin_l, 100, script_info.play_res_x); |
| 194 | *origin_top = |
| 195 | av_rescale((style.alignment >= 7) ? style.margin_v : 0, |
| 196 | 100, script_info.play_res_y); |
| 197 | } |
| 198 | |
| 199 | static void ttml_get_extent(ASSScriptInfo script_info, ASSStyle style, |
| 200 | int *width, int *height) |
| 201 | { |
| 202 | *width = av_rescale(script_info.play_res_x - style.margin_r, |
| 203 | 100, script_info.play_res_x); |
| 204 | *height = av_rescale((style.alignment <= 3) ? |
| 205 | script_info.play_res_y - style.margin_v : |
| 206 | script_info.play_res_y, |
| 207 | 100, script_info.play_res_y); |
| 208 | } |
| 209 | |
Jan Ekström | 3ef5a8b | 2021-03-29 13:34:34 | [diff] [blame] | 210 | static int ttml_write_region(AVCodecContext *avctx, AVBPrint *buf, |
Jan Ekström | b24488e | 2021-03-29 14:19:58 | [diff] [blame] | 211 | ASSScriptInfo script_info, ASSStyle style) |
Jan Ekström | 3ef5a8b | 2021-03-29 13:34:34 | [diff] [blame] | 212 | { |
| 213 | const char *display_alignment = NULL; |
| 214 | const char *text_alignment = NULL; |
Jan Ekström | b24488e | 2021-03-29 14:19:58 | [diff] [blame] | 215 | int origin_left = 0; |
| 216 | int origin_top = 0; |
| 217 | int width = 0; |
| 218 | int height = 0; |
Jan Ekström | 3ef5a8b | 2021-03-29 13:34:34 | [diff] [blame] | 219 | |
| 220 | if (!style.name) { |
| 221 | av_log(avctx, AV_LOG_ERROR, "Subtitle style name not set!\n"); |
| 222 | return AVERROR_INVALIDDATA; |
| 223 | } |
| 224 | |
| 225 | if (style.font_size < 0) { |
| 226 | av_log(avctx, AV_LOG_ERROR, "Invalid font size for TTML: %d!\n", |
| 227 | style.font_size); |
| 228 | return AVERROR_INVALIDDATA; |
| 229 | } |
| 230 | |
Jan Ekström | b24488e | 2021-03-29 14:19:58 | [diff] [blame] | 231 | if (style.margin_l < 0 || style.margin_r < 0 || style.margin_v < 0) { |
| 232 | av_log(avctx, AV_LOG_ERROR, |
| 233 | "One or more negative margin values in subtitle style: " |
| 234 | "left: %d, right: %d, vertical: %d!\n", |
| 235 | style.margin_l, style.margin_r, style.margin_v); |
| 236 | return AVERROR_INVALIDDATA; |
| 237 | } |
| 238 | |
Jan Ekström | 3ef5a8b | 2021-03-29 13:34:34 | [diff] [blame] | 239 | display_alignment = ttml_get_display_alignment(style.alignment); |
| 240 | text_alignment = ttml_get_text_alignment(style.alignment); |
| 241 | if (!display_alignment || !text_alignment) { |
| 242 | av_log(avctx, AV_LOG_ERROR, |
| 243 | "Failed to convert ASS style alignment %d of style %s to " |
| 244 | "TTML display and text alignment!\n", |
| 245 | style.alignment, |
| 246 | style.name); |
| 247 | return AVERROR_INVALIDDATA; |
| 248 | } |
| 249 | |
Jan Ekström | b24488e | 2021-03-29 14:19:58 | [diff] [blame] | 250 | ttml_get_origin(script_info, style, &origin_left, &origin_top); |
| 251 | ttml_get_extent(script_info, style, &width, &height); |
| 252 | |
Jan Ekström | 3ef5a8b | 2021-03-29 13:34:34 | [diff] [blame] | 253 | av_bprintf(buf, " <region xml:id=\""); |
| 254 | av_bprint_escape(buf, style.name, NULL, AV_ESCAPE_MODE_XML, |
| 255 | AV_ESCAPE_FLAG_XML_DOUBLE_QUOTES); |
| 256 | av_bprintf(buf, "\"\n"); |
| 257 | |
Jan Ekström | b24488e | 2021-03-29 14:19:58 | [diff] [blame] | 258 | av_bprintf(buf, " tts:origin=\"%d%% %d%%\"\n", |
| 259 | origin_left, origin_top); |
| 260 | av_bprintf(buf, " tts:extent=\"%d%% %d%%\"\n", |
| 261 | width, height); |
| 262 | |
Jan Ekström | 3ef5a8b | 2021-03-29 13:34:34 | [diff] [blame] | 263 | av_bprintf(buf, " tts:displayAlign=\""); |
| 264 | av_bprint_escape(buf, display_alignment, NULL, AV_ESCAPE_MODE_XML, |
| 265 | AV_ESCAPE_FLAG_XML_DOUBLE_QUOTES); |
| 266 | av_bprintf(buf, "\"\n"); |
| 267 | |
| 268 | av_bprintf(buf, " tts:textAlign=\""); |
| 269 | av_bprint_escape(buf, text_alignment, NULL, AV_ESCAPE_MODE_XML, |
| 270 | AV_ESCAPE_FLAG_XML_DOUBLE_QUOTES); |
| 271 | av_bprintf(buf, "\"\n"); |
| 272 | |
| 273 | // if we set cell resolution to our script reference resolution, |
| 274 | // then a single line is a single "point" on our canvas. Thus, by setting |
| 275 | // our font size to font size in cells, we should gain a similar enough |
| 276 | // scale without resorting to explicit pixel based font sizing, which is |
| 277 | // frowned upon in the TTML community. |
| 278 | av_bprintf(buf, " tts:fontSize=\"%dc\"\n", |
| 279 | style.font_size); |
| 280 | |
| 281 | if (style.font_name) { |
| 282 | av_bprintf(buf, " tts:fontFamily=\""); |
| 283 | av_bprint_escape(buf, style.font_name, NULL, AV_ESCAPE_MODE_XML, |
| 284 | AV_ESCAPE_FLAG_XML_DOUBLE_QUOTES); |
| 285 | av_bprintf(buf, "\"\n"); |
| 286 | } |
| 287 | |
| 288 | av_bprintf(buf, " tts:overflow=\"visible\" />\n"); |
| 289 | |
| 290 | return 0; |
| 291 | } |
| 292 | |
Jan Ekström | b71184f | 2021-03-15 10:41:18 | [diff] [blame] | 293 | static int ttml_write_header_content(AVCodecContext *avctx) |
Jan Ekström | 18713d2 | 2017-01-19 13:02:27 | [diff] [blame] | 294 | { |
Jan Ekström | 3ef5a8b | 2021-03-29 13:34:34 | [diff] [blame] | 295 | TTMLContext *s = avctx->priv_data; |
| 296 | ASS *ass = (ASS *)s->ass_ctx; |
| 297 | ASSScriptInfo script_info = ass->script_info; |
| 298 | const size_t base_extradata_size = TTMLENC_EXTRADATA_SIGNATURE_SIZE + 1 + |
| 299 | AV_INPUT_BUFFER_PADDING_SIZE; |
| 300 | size_t additional_extradata_size = 0; |
Andreas Rheinhardt | 253a834 | 2024-02-18 00:23:26 | [diff] [blame] | 301 | int ret; |
Jan Ekström | 3ef5a8b | 2021-03-29 13:34:34 | [diff] [blame] | 302 | |
| 303 | if (script_info.play_res_x <= 0 || script_info.play_res_y <= 0) { |
| 304 | av_log(avctx, AV_LOG_ERROR, |
| 305 | "Invalid subtitle reference resolution %dx%d!\n", |
| 306 | script_info.play_res_x, script_info.play_res_y); |
| 307 | return AVERROR_INVALIDDATA; |
| 308 | } |
| 309 | |
Andreas Rheinhardt | 253a834 | 2024-02-18 00:23:26 | [diff] [blame] | 310 | av_bprint_init(&s->buffer, 0, INT_MAX - base_extradata_size); |
| 311 | |
Jan Ekström | 3ef5a8b | 2021-03-29 13:34:34 | [diff] [blame] | 312 | // write the first string in extradata, attributes in the base "tt" element. |
Andreas Rheinhardt | 1368b5a | 2022-07-31 02:57:23 | [diff] [blame] | 313 | av_bprintf(&s->buffer, TTML_DEFAULT_NAMESPACING); |
Jan Ekström | 3ef5a8b | 2021-03-29 13:34:34 | [diff] [blame] | 314 | // the cell resolution is in character cells, so not exactly 1:1 against |
| 315 | // a pixel based resolution, but as the tts:extent in the root |
| 316 | // "tt" element is frowned upon (and disallowed in the EBU-TT profile), |
| 317 | // we mimic the reference resolution by setting it as the cell resolution. |
| 318 | av_bprintf(&s->buffer, " ttp:cellResolution=\"%d %d\"\n", |
| 319 | script_info.play_res_x, script_info.play_res_y); |
| 320 | av_bprint_chars(&s->buffer, '\0', 1); |
| 321 | |
| 322 | // write the second string in extradata, head element containing the styles |
| 323 | av_bprintf(&s->buffer, " <head>\n"); |
| 324 | av_bprintf(&s->buffer, " <layout>\n"); |
| 325 | |
| 326 | for (int i = 0; i < ass->styles_count; i++) { |
Andreas Rheinhardt | 253a834 | 2024-02-18 00:23:26 | [diff] [blame] | 327 | ret = ttml_write_region(avctx, &s->buffer, script_info, |
| 328 | ass->styles[i]); |
Jan Ekström | 3ef5a8b | 2021-03-29 13:34:34 | [diff] [blame] | 329 | if (ret < 0) |
Andreas Rheinhardt | 253a834 | 2024-02-18 00:23:26 | [diff] [blame] | 330 | goto fail; |
Jan Ekström | 3ef5a8b | 2021-03-29 13:34:34 | [diff] [blame] | 331 | } |
| 332 | |
| 333 | av_bprintf(&s->buffer, " </layout>\n"); |
| 334 | av_bprintf(&s->buffer, " </head>\n"); |
| 335 | av_bprint_chars(&s->buffer, '\0', 1); |
| 336 | |
| 337 | if (!av_bprint_is_complete(&s->buffer)) { |
Andreas Rheinhardt | 253a834 | 2024-02-18 00:23:26 | [diff] [blame] | 338 | ret = AVERROR(ENOMEM); |
| 339 | goto fail; |
Jan Ekström | 18713d2 | 2017-01-19 13:02:27 | [diff] [blame] | 340 | } |
| 341 | |
Jan Ekström | 3ef5a8b | 2021-03-29 13:34:34 | [diff] [blame] | 342 | additional_extradata_size = s->buffer.len; |
| 343 | |
| 344 | if (!(avctx->extradata = |
| 345 | av_mallocz(base_extradata_size + additional_extradata_size))) { |
Andreas Rheinhardt | 253a834 | 2024-02-18 00:23:26 | [diff] [blame] | 346 | ret = AVERROR(ENOMEM); |
| 347 | goto fail; |
Jan Ekström | 3ef5a8b | 2021-03-29 13:34:34 | [diff] [blame] | 348 | } |
| 349 | |
| 350 | avctx->extradata_size = |
| 351 | TTMLENC_EXTRADATA_SIGNATURE_SIZE + additional_extradata_size; |
Jan Ekström | 18713d2 | 2017-01-19 13:02:27 | [diff] [blame] | 352 | memcpy(avctx->extradata, TTMLENC_EXTRADATA_SIGNATURE, |
| 353 | TTMLENC_EXTRADATA_SIGNATURE_SIZE); |
| 354 | |
Andreas Rheinhardt | ed9de6d | 2024-02-18 00:27:23 | [diff] [blame] | 355 | memcpy(avctx->extradata + TTMLENC_EXTRADATA_SIGNATURE_SIZE, |
| 356 | s->buffer.str, additional_extradata_size); |
Jan Ekström | 3ef5a8b | 2021-03-29 13:34:34 | [diff] [blame] | 357 | |
Andreas Rheinhardt | 253a834 | 2024-02-18 00:23:26 | [diff] [blame] | 358 | ret = 0; |
| 359 | fail: |
| 360 | av_bprint_finalize(&s->buffer, NULL); |
Jan Ekström | 3ef5a8b | 2021-03-29 13:34:34 | [diff] [blame] | 361 | |
Andreas Rheinhardt | 253a834 | 2024-02-18 00:23:26 | [diff] [blame] | 362 | return ret; |
Jan Ekström | b71184f | 2021-03-15 10:41:18 | [diff] [blame] | 363 | } |
| 364 | |
| 365 | static av_cold int ttml_encode_init(AVCodecContext *avctx) |
| 366 | { |
| 367 | TTMLContext *s = avctx->priv_data; |
| 368 | int ret = AVERROR_BUG; |
| 369 | s->avctx = avctx; |
| 370 | |
Jan Ekström | b71184f | 2021-03-15 10:41:18 | [diff] [blame] | 371 | if (!(s->ass_ctx = ff_ass_split(avctx->subtitle_header))) { |
| 372 | return AVERROR_INVALIDDATA; |
| 373 | } |
| 374 | |
| 375 | if ((ret = ttml_write_header_content(avctx)) < 0) { |
| 376 | return ret; |
| 377 | } |
| 378 | |
Jan Ekström | 18713d2 | 2017-01-19 13:02:27 | [diff] [blame] | 379 | return 0; |
| 380 | } |
| 381 | |
Andreas Rheinhardt | 20f9727 | 2022-03-16 20:09:54 | [diff] [blame] | 382 | const FFCodec ff_ttml_encoder = { |
| 383 | .p.name = "ttml", |
Andreas Rheinhardt | 48286d4 | 2022-08-29 11:38:02 | [diff] [blame] | 384 | CODEC_LONG_NAME("TTML subtitle"), |
Andreas Rheinhardt | 20f9727 | 2022-03-16 20:09:54 | [diff] [blame] | 385 | .p.type = AVMEDIA_TYPE_SUBTITLE, |
| 386 | .p.id = AV_CODEC_ID_TTML, |
Jan Ekström | 18713d2 | 2017-01-19 13:02:27 | [diff] [blame] | 387 | .priv_data_size = sizeof(TTMLContext), |
| 388 | .init = ttml_encode_init, |
Andreas Rheinhardt | 4243da4 | 2022-03-30 21:28:24 | [diff] [blame] | 389 | FF_CODEC_ENCODE_SUB_CB(ttml_encode_frame), |
Jan Ekström | 18713d2 | 2017-01-19 13:02:27 | [diff] [blame] | 390 | .close = ttml_encode_close, |
Andreas Rheinhardt | 21b23ce | 2022-07-09 22:05:45 | [diff] [blame] | 391 | .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, |
Jan Ekström | 18713d2 | 2017-01-19 13:02:27 | [diff] [blame] | 392 | }; |