2 * Closed Caption Decoding
3 * Copyright (c) 2015 Anshul Maheshwari
5 * This file is part of FFmpeg.
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.
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.
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
24 #include "libavutil/opt.h"
26 #define SCREEN_ROWS 15
27 #define SCREEN_COLUMNS 32
29 #define SET_FLAG(var, val) ( (var) |= ( 1 << (val)) )
30 #define UNSET_FLAG(var, val) ( (var) &= ~( 1 << (val)) )
31 #define CHECK_FLAG(var, val) ( (var) & ( 1 << (val)) )
33 static const AVRational ms_tb = {1, 1000};
59 CCFONT_UNDERLINED_ITALICS,
64 CCSET_SPECIAL_AMERICAN,
65 CCSET_EXTENDED_SPANISH_FRENCH_MISC,
66 CCSET_EXTENDED_PORTUGUESE_GERMAN_DANISH,
69 static const char *charset_overrides[4][128] =
71 [CCSET_BASIC_AMERICAN] = {
84 [CCSET_SPECIAL_AMERICAN] = {
102 [CCSET_EXTENDED_SPANISH_FRENCH_MISC] = {
136 [CCSET_EXTENDED_PORTUGUESE_GERMAN_DANISH] = {
172 static const unsigned char pac2_attribs[32][3] = // Color, font, ident
174 { CCCOL_WHITE, CCFONT_REGULAR, 0 }, // 0x40 || 0x60
175 { CCCOL_WHITE, CCFONT_UNDERLINED, 0 }, // 0x41 || 0x61
176 { CCCOL_GREEN, CCFONT_REGULAR, 0 }, // 0x42 || 0x62
177 { CCCOL_GREEN, CCFONT_UNDERLINED, 0 }, // 0x43 || 0x63
178 { CCCOL_BLUE, CCFONT_REGULAR, 0 }, // 0x44 || 0x64
179 { CCCOL_BLUE, CCFONT_UNDERLINED, 0 }, // 0x45 || 0x65
180 { CCCOL_CYAN, CCFONT_REGULAR, 0 }, // 0x46 || 0x66
181 { CCCOL_CYAN, CCFONT_UNDERLINED, 0 }, // 0x47 || 0x67
182 { CCCOL_RED, CCFONT_REGULAR, 0 }, // 0x48 || 0x68
183 { CCCOL_RED, CCFONT_UNDERLINED, 0 }, // 0x49 || 0x69
184 { CCCOL_YELLOW, CCFONT_REGULAR, 0 }, // 0x4a || 0x6a
185 { CCCOL_YELLOW, CCFONT_UNDERLINED, 0 }, // 0x4b || 0x6b
186 { CCCOL_MAGENTA, CCFONT_REGULAR, 0 }, // 0x4c || 0x6c
187 { CCCOL_MAGENTA, CCFONT_UNDERLINED, 0 }, // 0x4d || 0x6d
188 { CCCOL_WHITE, CCFONT_ITALICS, 0 }, // 0x4e || 0x6e
189 { CCCOL_WHITE, CCFONT_UNDERLINED_ITALICS, 0 }, // 0x4f || 0x6f
190 { CCCOL_WHITE, CCFONT_REGULAR, 0 }, // 0x50 || 0x70
191 { CCCOL_WHITE, CCFONT_UNDERLINED, 0 }, // 0x51 || 0x71
192 { CCCOL_WHITE, CCFONT_REGULAR, 4 }, // 0x52 || 0x72
193 { CCCOL_WHITE, CCFONT_UNDERLINED, 4 }, // 0x53 || 0x73
194 { CCCOL_WHITE, CCFONT_REGULAR, 8 }, // 0x54 || 0x74
195 { CCCOL_WHITE, CCFONT_UNDERLINED, 8 }, // 0x55 || 0x75
196 { CCCOL_WHITE, CCFONT_REGULAR, 12 }, // 0x56 || 0x76
197 { CCCOL_WHITE, CCFONT_UNDERLINED, 12 }, // 0x57 || 0x77
198 { CCCOL_WHITE, CCFONT_REGULAR, 16 }, // 0x58 || 0x78
199 { CCCOL_WHITE, CCFONT_UNDERLINED, 16 }, // 0x59 || 0x79
200 { CCCOL_WHITE, CCFONT_REGULAR, 20 }, // 0x5a || 0x7a
201 { CCCOL_WHITE, CCFONT_UNDERLINED, 20 }, // 0x5b || 0x7b
202 { CCCOL_WHITE, CCFONT_REGULAR, 24 }, // 0x5c || 0x7c
203 { CCCOL_WHITE, CCFONT_UNDERLINED, 24 }, // 0x5d || 0x7d
204 { CCCOL_WHITE, CCFONT_REGULAR, 28 }, // 0x5e || 0x7e
205 { CCCOL_WHITE, CCFONT_UNDERLINED, 28 } // 0x5f || 0x7f
206 /* total 32 entries */
210 /* +1 is used to compensate null character of string */
211 uint8_t characters[SCREEN_ROWS+1][SCREEN_COLUMNS+1];
212 uint8_t charsets[SCREEN_ROWS+1][SCREEN_COLUMNS+1];
213 uint8_t colors[SCREEN_ROWS+1][SCREEN_COLUMNS+1];
214 uint8_t fonts[SCREEN_ROWS+1][SCREEN_COLUMNS+1];
216 * Bitmask of used rows; if a bit is not set, the
217 * corresponding row is not used.
218 * for setting row 1 use row | (1 << 0)
219 * for setting row 15 use row | (1 << 14)
224 typedef struct CCaptionSubContext {
227 struct Screen screen[2];
230 uint8_t cursor_column;
231 uint8_t cursor_color;
233 uint8_t cursor_charset;
239 int64_t buffer_time[2];
241 int64_t last_real_time;
244 } CCaptionSubContext;
246 static av_cold int init_decoder(AVCodecContext *avctx)
249 CCaptionSubContext *ctx = avctx->priv_data;
251 av_bprint_init(&ctx->buffer[0], 0, AV_BPRINT_SIZE_UNLIMITED);
252 av_bprint_init(&ctx->buffer[1], 0, AV_BPRINT_SIZE_UNLIMITED);
253 /* taking by default roll up to 2 */
254 ctx->mode = CCMODE_ROLLUP;
256 ctx->cursor_row = 10;
257 ret = ff_ass_subtitle_header(avctx, "Monospace",
258 ASS_DEFAULT_FONT_SIZE,
260 ASS_DEFAULT_BACK_COLOR,
263 ASS_DEFAULT_UNDERLINE,
265 ASS_DEFAULT_ALIGNMENT);
273 static av_cold int close_decoder(AVCodecContext *avctx)
275 CCaptionSubContext *ctx = avctx->priv_data;
276 av_bprint_finalize(&ctx->buffer[0], NULL);
277 av_bprint_finalize(&ctx->buffer[1], NULL);
281 static void flush_decoder(AVCodecContext *avctx)
283 CCaptionSubContext *ctx = avctx->priv_data;
284 ctx->screen[0].row_used = 0;
285 ctx->screen[1].row_used = 0;
286 ctx->prev_cmd[0] = 0;
287 ctx->prev_cmd[1] = 0;
288 ctx->mode = CCMODE_ROLLUP;
290 ctx->cursor_row = 10;
291 ctx->cursor_column = 0;
292 ctx->cursor_font = 0;
293 ctx->cursor_color = 0;
294 ctx->cursor_charset = 0;
295 ctx->active_screen = 0;
296 ctx->last_real_time = 0;
297 ctx->screen_touched = 0;
298 ctx->buffer_changed = 0;
299 if (!(avctx->flags2 & AV_CODEC_FLAG2_RO_FLUSH_NOOP))
301 av_bprint_clear(&ctx->buffer[0]);
302 av_bprint_clear(&ctx->buffer[1]);
306 * @param ctx closed caption context just to print log
308 static void write_char(CCaptionSubContext *ctx, struct Screen *screen, char ch)
310 uint8_t col = ctx->cursor_column;
311 char *row = screen->characters[ctx->cursor_row];
312 char *font = screen->fonts[ctx->cursor_row];
313 char *color = screen->colors[ctx->cursor_row];
314 char *charset = screen->charsets[ctx->cursor_row];
316 if (col < SCREEN_COLUMNS) {
318 font[col] = ctx->cursor_font;
319 color[col] = ctx->cursor_color;
320 charset[col] = ctx->cursor_charset;
321 ctx->cursor_charset = CCSET_BASIC_AMERICAN;
322 if (ch) ctx->cursor_column++;
325 /* We have extra space at end only for null character */
326 else if (col == SCREEN_COLUMNS && ch == 0) {
331 av_log(ctx, AV_LOG_WARNING, "Data Ignored since exceeding screen width\n");
337 * This function after validating parity bit, also remove it from data pair.
338 * The first byte doesn't pass parity, we replace it with a solid blank
339 * and process the pair.
340 * If the second byte doesn't pass parity, it returns INVALIDDATA
341 * user can ignore the whole pair and pass the other pair.
343 static int validate_cc_data_pair(uint8_t *cc_data_pair)
345 uint8_t cc_valid = (*cc_data_pair & 4) >>2;
346 uint8_t cc_type = *cc_data_pair & 3;
349 return AVERROR_INVALIDDATA;
351 // if EIA-608 data then verify parity.
352 if (cc_type==0 || cc_type==1) {
353 if (!av_parity(cc_data_pair[2])) {
354 return AVERROR_INVALIDDATA;
356 if (!av_parity(cc_data_pair[1])) {
357 cc_data_pair[1]=0x7F;
362 if ((cc_data_pair[0] == 0xFA || cc_data_pair[0] == 0xFC || cc_data_pair[0] == 0xFD)
363 && (cc_data_pair[1] & 0x7F) == 0 && (cc_data_pair[2] & 0x7F) == 0)
364 return AVERROR_PATCHWELCOME;
367 if (cc_type == 3 || cc_type == 2)
368 return AVERROR_PATCHWELCOME;
373 static struct Screen *get_writing_screen(CCaptionSubContext *ctx)
377 // use Inactive screen
378 return ctx->screen + !ctx->active_screen;
383 return ctx->screen + ctx->active_screen;
385 /* It was never an option */
389 static void roll_up(CCaptionSubContext *ctx)
391 struct Screen *screen;
394 if (ctx->mode == CCMODE_TEXT)
397 screen = get_writing_screen(ctx);
399 /* +1 signify cursor_row starts from 0
400 * Can't keep lines less then row cursor pos
402 keep_lines = FFMIN(ctx->cursor_row + 1, ctx->rollup);
404 for (i = 0; i < SCREEN_ROWS; i++) {
405 if (i > ctx->cursor_row - keep_lines && i <= ctx->cursor_row)
407 UNSET_FLAG(screen->row_used, i);
410 for (i = 0; i < keep_lines && screen->row_used; i++) {
411 const int i_row = ctx->cursor_row - keep_lines + i + 1;
413 memcpy(screen->characters[i_row], screen->characters[i_row+1], SCREEN_COLUMNS);
414 memcpy(screen->colors[i_row], screen->colors[i_row+1], SCREEN_COLUMNS);
415 memcpy(screen->fonts[i_row], screen->fonts[i_row+1], SCREEN_COLUMNS);
416 memcpy(screen->charsets[i_row], screen->charsets[i_row+1], SCREEN_COLUMNS);
417 if (CHECK_FLAG(screen->row_used, i_row + 1))
418 SET_FLAG(screen->row_used, i_row);
421 UNSET_FLAG(screen->row_used, ctx->cursor_row);
424 static int capture_screen(CCaptionSubContext *ctx)
427 struct Screen *screen = ctx->screen + ctx->active_screen;
428 enum cc_font prev_font = CCFONT_REGULAR;
429 enum cc_color_code prev_color = CCCOL_WHITE;
430 const int bidx = ctx->buffer_index;
432 av_bprint_clear(&ctx->buffer[bidx]);
434 for (i = 0; screen->row_used && i < SCREEN_ROWS; i++)
436 if (CHECK_FLAG(screen->row_used, i)) {
437 const char *row = screen->characters[i];
438 const char *charset = screen->charsets[i];
440 while (row[j] == ' ' && charset[j] == CCSET_BASIC_AMERICAN)
447 for (i = 0; screen->row_used && i < SCREEN_ROWS; i++)
449 if (CHECK_FLAG(screen->row_used, i)) {
450 const char *row = screen->characters[i];
451 const char *font = screen->fonts[i];
452 const char *color = screen->colors[i];
453 const char *charset = screen->charsets[i];
454 const char *override;
455 int x, y, seen_char = 0;
458 /* skip leading space */
459 while (row[j] == ' ' && charset[j] == CCSET_BASIC_AMERICAN && j < tab)
462 x = ASS_DEFAULT_PLAYRESX * (0.1 + 0.0250 * j);
463 y = ASS_DEFAULT_PLAYRESY * (0.1 + 0.0533 * i);
464 av_bprintf(&ctx->buffer[bidx], "{\\an7}{\\pos(%d,%d)}", x, y);
466 for (; j < SCREEN_COLUMNS; j++) {
467 const char *e_tag = "", *s_tag = "", *c_tag = "";
472 if (prev_font != font[j]) {
477 case CCFONT_UNDERLINED:
480 case CCFONT_UNDERLINED_ITALICS:
481 e_tag = "{\\u0}{\\i0}";
488 case CCFONT_UNDERLINED:
491 case CCFONT_UNDERLINED_ITALICS:
492 s_tag = "{\\u1}{\\i1}";
496 if (prev_color != color[j]) {
499 c_tag = "{\\c&HFFFFFF&}";
502 c_tag = "{\\c&H00FF00&}";
505 c_tag = "{\\c&HFF0000&}";
508 c_tag = "{\\c&HFFFF00&}";
511 c_tag = "{\\c&H0000FF&}";
514 c_tag = "{\\c&H00FFFF&}";
517 c_tag = "{\\c&HFF00FF&}";
523 prev_color = color[j];
524 override = charset_overrides[(int)charset[j]][(int)row[j]];
526 av_bprintf(&ctx->buffer[bidx], "%s%s%s%s", e_tag, s_tag, c_tag, override);
528 } else if (row[j] == ' ' && !seen_char) {
529 av_bprintf(&ctx->buffer[bidx], "%s%s%s\\h", e_tag, s_tag, c_tag);
531 av_bprintf(&ctx->buffer[bidx], "%s%s%s%c", e_tag, s_tag, c_tag, row[j]);
536 av_bprintf(&ctx->buffer[bidx], "\\N");
539 if (!av_bprint_is_complete(&ctx->buffer[bidx]))
540 return AVERROR(ENOMEM);
541 if (screen->row_used && ctx->buffer[bidx].len >= 2) {
542 ctx->buffer[bidx].len -= 2;
543 ctx->buffer[bidx].str[ctx->buffer[bidx].len] = 0;
545 ctx->buffer_changed = 1;
549 static void update_time(CCaptionSubContext *ctx, int64_t pts)
551 ctx->buffer_time[0] = ctx->buffer_time[1];
552 ctx->buffer_time[1] = pts;
555 static void handle_textattr(CCaptionSubContext *ctx, uint8_t hi, uint8_t lo)
558 struct Screen *screen = get_writing_screen(ctx);
563 ctx->cursor_color = pac2_attribs[i][0];
564 ctx->cursor_font = pac2_attribs[i][1];
566 SET_FLAG(screen->row_used, ctx->cursor_row);
567 write_char(ctx, screen, ' ');
570 static void handle_pac(CCaptionSubContext *ctx, uint8_t hi, uint8_t lo)
572 static const int8_t row_map[] = {
573 11, -1, 1, 2, 3, 4, 12, 13, 14, 15, 5, 6, 7, 8, 9, 10
575 const int index = ( (hi<<1) & 0x0e) | ( (lo>>5) & 0x01 );
576 struct Screen *screen = get_writing_screen(ctx);
579 if (row_map[index] <= 0) {
580 av_log(ctx, AV_LOG_DEBUG, "Invalid pac index encountered\n");
586 ctx->cursor_row = row_map[index] - 1;
587 ctx->cursor_color = pac2_attribs[lo][0];
588 ctx->cursor_font = pac2_attribs[lo][1];
589 ctx->cursor_charset = CCSET_BASIC_AMERICAN;
590 ctx->cursor_column = 0;
591 indent = pac2_attribs[lo][2];
592 for (i = 0; i < indent; i++) {
593 write_char(ctx, screen, ' ');
597 static int handle_edm(CCaptionSubContext *ctx)
599 struct Screen *screen = ctx->screen + ctx->active_screen;
602 // In buffered mode, keep writing to screen until it is wiped.
603 // Before wiping the display, capture contents to emit subtitle.
605 ret = capture_screen(ctx);
607 screen->row_used = 0;
609 // In realtime mode, emit an empty caption so the last one doesn't
610 // stay on the screen.
612 ret = capture_screen(ctx);
617 static int handle_eoc(CCaptionSubContext *ctx)
621 ctx->active_screen = !ctx->active_screen;
623 // In buffered mode, we wait til the *next* EOC and
624 // capture what was already on the screen since the last EOC.
626 ret = handle_edm(ctx);
628 ctx->cursor_column = 0;
630 // In realtime mode, we display the buffered contents (after
631 // flipping the buffer to active above) as soon as EOC arrives.
633 ret = capture_screen(ctx);
638 static void handle_delete_end_of_row(CCaptionSubContext *ctx)
640 struct Screen *screen = get_writing_screen(ctx);
641 write_char(ctx, screen, 0);
644 static void handle_char(CCaptionSubContext *ctx, char hi, char lo)
646 struct Screen *screen = get_writing_screen(ctx);
648 SET_FLAG(screen->row_used, ctx->cursor_row);
652 ctx->cursor_charset = CCSET_SPECIAL_AMERICAN;
655 if (ctx->cursor_column > 0)
656 ctx->cursor_column -= 1;
657 ctx->cursor_charset = CCSET_EXTENDED_SPANISH_FRENCH_MISC;
660 if (ctx->cursor_column > 0)
661 ctx->cursor_column -= 1;
662 ctx->cursor_charset = CCSET_EXTENDED_PORTUGUESE_GERMAN_DANISH;
665 ctx->cursor_charset = CCSET_BASIC_AMERICAN;
666 write_char(ctx, screen, hi);
671 write_char(ctx, screen, lo);
673 write_char(ctx, screen, 0);
675 if (ctx->mode != CCMODE_POPON)
676 ctx->screen_touched = 1;
679 ff_dlog(ctx, "(%c,%c)\n", hi, lo);
681 ff_dlog(ctx, "(%c)\n", hi);
684 static int process_cc608(CCaptionSubContext *ctx, uint8_t hi, uint8_t lo)
688 if (hi == ctx->prev_cmd[0] && lo == ctx->prev_cmd[1]) {
692 /* set prev command */
693 ctx->prev_cmd[0] = hi;
694 ctx->prev_cmd[1] = lo;
696 if ( (hi == 0x10 && (lo >= 0x40 && lo <= 0x5f)) ||
697 ( (hi >= 0x11 && hi <= 0x17) && (lo >= 0x40 && lo <= 0x7f) ) ) {
698 handle_pac(ctx, hi, lo);
699 } else if ( ( hi == 0x11 && lo >= 0x20 && lo <= 0x2f ) ||
700 ( hi == 0x17 && lo >= 0x2e && lo <= 0x2f) ) {
701 handle_textattr(ctx, hi, lo);
702 } else if (hi == 0x14 || hi == 0x15 || hi == 0x1c) {
705 /* resume caption loading */
706 ctx->mode = CCMODE_POPON;
709 handle_delete_end_of_row(ctx);
714 ctx->rollup = lo - 0x23;
715 ctx->mode = CCMODE_ROLLUP;
718 /* resume direct captioning */
719 ctx->mode = CCMODE_PAINTON;
722 /* resume text display */
723 ctx->mode = CCMODE_TEXT;
726 /* erase display memory */
730 /* carriage return */
731 ff_dlog(ctx, "carriage return\n");
733 ret = capture_screen(ctx);
735 ctx->cursor_column = 0;
738 /* erase buffered (non displayed) memory */
739 // Only in realtime mode. In buffered mode, we re-use the inactive screen
740 // for our own buffering.
741 if (ctx->real_time) {
742 struct Screen *screen = ctx->screen + !ctx->active_screen;
743 screen->row_used = 0;
748 ff_dlog(ctx, "handle_eoc\n");
749 ret = handle_eoc(ctx);
752 ff_dlog(ctx, "Unknown command 0x%hhx 0x%hhx\n", hi, lo);
755 } else if (hi >= 0x11 && hi <= 0x13) {
756 /* Special characters */
757 handle_char(ctx, hi, lo);
758 } else if (hi >= 0x20) {
759 /* Standard characters (always in pairs) */
760 handle_char(ctx, hi, lo);
761 ctx->prev_cmd[0] = ctx->prev_cmd[1] = 0;
762 } else if (hi == 0x17 && lo >= 0x21 && lo <= 0x23) {
764 /* Tab offsets (spacing) */
765 for (i = 0; i < lo - 0x20; i++) {
766 handle_char(ctx, ' ', 0);
769 /* Ignoring all other non data code */
770 ff_dlog(ctx, "Unknown command 0x%hhx 0x%hhx\n", hi, lo);
776 static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
778 CCaptionSubContext *ctx = avctx->priv_data;
779 AVSubtitle *sub = data;
780 int64_t in_time = sub->pts;
783 int bidx = ctx->buffer_index;
784 uint8_t *bptr = NULL;
785 int len = avpkt->size;
791 for (i = 0; i < len; i += 3) {
792 uint8_t cc_type = *(bptr + i) & 3;
793 if (validate_cc_data_pair(bptr + i))
795 /* ignoring data field 1 */
799 ret = process_cc608(ctx, bptr[i + 1] & 0x7f, bptr[i + 2] & 0x7f);
803 if (!ctx->buffer_changed)
805 ctx->buffer_changed = 0;
807 if (!ctx->real_time && ctx->mode == CCMODE_POPON)
808 ctx->buffer_index = bidx = !ctx->buffer_index;
810 update_time(ctx, in_time);
812 if (ctx->buffer[bidx].str[0] || ctx->real_time) {
813 ff_dlog(ctx, "cdp writing data (%s)\n", ctx->buffer[bidx].str);
814 start_time = ctx->buffer_time[0];
815 sub->pts = start_time;
816 end_time = ctx->buffer_time[1];
818 sub->end_display_time = av_rescale_q(end_time - start_time,
819 AV_TIME_BASE_Q, ms_tb);
821 sub->end_display_time = -1;
822 ret = ff_ass_add_rect(sub, ctx->buffer[bidx].str, ctx->readorder++, 0, NULL, NULL);
825 ctx->last_real_time = sub->pts;
826 ctx->screen_touched = 0;
830 if (!bptr && !ctx->real_time && ctx->buffer[!ctx->buffer_index].str[0]) {
831 bidx = !ctx->buffer_index;
832 ret = ff_ass_add_rect(sub, ctx->buffer[bidx].str, ctx->readorder++, 0, NULL, NULL);
835 sub->pts = ctx->buffer_time[1];
836 sub->end_display_time = av_rescale_q(ctx->buffer_time[1] - ctx->buffer_time[0],
837 AV_TIME_BASE_Q, ms_tb);
838 if (sub->end_display_time == 0)
839 sub->end_display_time = ctx->buffer[bidx].len * 20;
842 if (ctx->real_time && ctx->screen_touched &&
843 sub->pts > ctx->last_real_time + av_rescale_q(200, ms_tb, AV_TIME_BASE_Q)) {
844 ctx->last_real_time = sub->pts;
845 ctx->screen_touched = 0;
848 ctx->buffer_changed = 0;
850 ret = ff_ass_add_rect(sub, ctx->buffer[bidx].str, ctx->readorder++, 0, NULL, NULL);
853 sub->end_display_time = -1;
856 *got_sub = sub->num_rects > 0;
860 #define OFFSET(x) offsetof(CCaptionSubContext, x)
861 #define SD AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_DECODING_PARAM
862 static const AVOption options[] = {
863 { "real_time", "emit subtitle events as they are decoded for real-time display", OFFSET(real_time), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, SD },
867 static const AVClass ccaption_dec_class = {
868 .class_name = "Closed caption Decoder",
869 .item_name = av_default_item_name,
871 .version = LIBAVUTIL_VERSION_INT,
874 AVCodec ff_ccaption_decoder = {
876 .long_name = NULL_IF_CONFIG_SMALL("Closed Caption (EIA-608 / CEA-708)"),
877 .type = AVMEDIA_TYPE_SUBTITLE,
878 .id = AV_CODEC_ID_EIA_608,
879 .priv_data_size = sizeof(CCaptionSubContext),
880 .init = init_decoder,
881 .close = close_decoder,
882 .flush = flush_decoder,
884 .priv_class = &ccaption_dec_class,
885 .capabilities = AV_CODEC_CAP_DELAY,