27 #define SCREEN_ROWS 15
28 #define SCREEN_COLUMNS 32
30 #define SET_FLAG(var, val) ( (var) |= ( 1 << (val)) )
31 #define UNSET_FLAG(var, val) ( (var) &= ~( 1 << (val)) )
32 #define CHECK_FLAG(var, val) ( (var) & ( 1 << (val)) )
106 1, 0, 0, 1, 0, 1, 1, 0,
107 1, 0, 0, 1, 0, 1, 1, 0,
108 0, 1, 1, 0, 1, 0, 0, 1,
109 1, 0, 0, 1, 0, 1, 1, 0,
110 0, 1, 1, 0, 1, 0, 0, 1,
111 0, 1, 1, 0, 1, 0, 0, 1,
112 1, 0, 0, 1, 0, 1, 1, 0,
113 1, 0, 0, 1, 0, 1, 1, 0,
114 0, 1, 1, 0, 1, 0, 0, 1,
115 0, 1, 1, 0, 1, 0, 0, 1,
116 1, 0, 0, 1, 0, 1, 1, 0,
117 0, 1, 1, 0, 1, 0, 0, 1,
118 1, 0, 0, 1, 0, 1, 1, 0,
119 1, 0, 0, 1, 0, 1, 1, 0,
120 0, 1, 1, 0, 1, 0, 0, 1,
121 1, 0, 0, 1, 0, 1, 1, 0,
122 0, 1, 1, 0, 1, 0, 0, 1,
123 0, 1, 1, 0, 1, 0, 0, 1,
124 1, 0, 0, 1, 0, 1, 1, 0,
125 0, 1, 1, 0, 1, 0, 0, 1,
126 1, 0, 0, 1, 0, 1, 1, 0,
127 1, 0, 0, 1, 0, 1, 1, 0,
128 0, 1, 1, 0, 1, 0, 0, 1,
129 0, 1, 1, 0, 1, 0, 0, 1,
130 1, 0, 0, 1, 0, 1, 1, 0,
131 1, 0, 0, 1, 0, 1, 1, 0,
132 0, 1, 1, 0, 1, 0, 0, 1,
133 1, 0, 0, 1, 0, 1, 1, 0,
134 0, 1, 1, 0, 1, 0, 0, 1,
135 0, 1, 1, 0, 1, 0, 0, 1,
136 1, 0, 0, 1, 0, 1, 1, 0 };
231 uint8_t cc_valid = (*cc_data_pair & 4) >>2;
232 uint8_t cc_type = *cc_data_pair & 3;
238 if (cc_type==0 || cc_type==1) {
243 cc_data_pair[1]=0x7F;
248 if( (cc_data_pair[0] == 0xFA || cc_data_pair[0] == 0xFC || cc_data_pair[0] == 0xFD )
249 && (cc_data_pair[1] & 0x7F) == 0 && (cc_data_pair[2] & 0x7F) == 0)
253 if(cc_type == 3 || cc_type == 2 )
257 cc_data_pair[1] &= 0x7F;
258 cc_data_pair[2] &= 0x7F;
298 for( i = 0; i < ctx->
cursor_row - keep_lines; i++ )
302 for( i = 0; i < keep_lines && screen->
row_used; i++ ) {
303 const int i_row = ctx->
cursor_row - keep_lines + i + 1;
370 static const int8_t row_map[] = {
371 11, -1, 1, 2, 3, 4, 12, 13, 14, 15, 5, 6, 7, 8, 9, 10
373 const int index = ( (hi<<1) & 0x0e) | ( (lo>>5) & 0x01 );
378 if( row_map[index] <= 0 ) {
391 for(i = 0;i < indent; i++) {
453 ff_dlog(ctx,
"(%c,%c)\n",hi,lo);
461 #define COR3(var, with1, with2, with3) ( (var) == (with1) || (var) == (with2) || (var) == (with3) )
464 }
else if ( (hi == 0x10 && (lo >= 0x40 || lo <= 0x5f)) ||
465 ( (hi >= 0x11 && hi <= 0x17) && (lo >= 0x40 && lo <= 0x7f) ) ) {
467 }
else if ( ( hi == 0x11 && lo >= 0x20 && lo <= 0x2f ) ||
468 ( hi == 0x17 && lo >= 0x2e && lo <= 0x2f) ) {
470 }
else if (
COR3(hi, 0x14, 0x15, 0x1C) && lo == 0x20 ) {
473 }
else if (
COR3(hi, 0x14, 0x15, 0x1C) && lo == 0x24 ) {
475 }
else if (
COR3(hi, 0x14, 0x15, 0x1C) && lo == 0x25 ) {
478 }
else if (
COR3(hi, 0x14, 0x15, 0x1C) && lo == 0x26 ) {
481 }
else if (
COR3(hi, 0x14, 0x15, 0x1C) && lo == 0x27 ) {
484 }
else if (
COR3(hi, 0x14, 0x15, 0x1C) && lo == 0x29 ) {
487 }
else if (
COR3(hi, 0x14, 0x15, 0x1C) && lo == 0x2B ) {
490 }
else if (
COR3(hi, 0x14, 0x15, 0x1C) && lo == 0x2C ) {
493 }
else if (
COR3(hi, 0x14, 0x15, 0x1C) && lo == 0x2D ) {
495 ff_dlog(ctx,
"carriage return\n");
500 }
else if (
COR3(hi, 0x14, 0x15, 0x1C) && lo == 0x2F ) {
504 }
else if (hi>=0x20) {
509 ff_dlog(ctx,
"Unknown command 0x%hhx 0x%hhx\n", hi, lo);
539 for (i = 0; i <
len; i += 3) {
540 uint8_t cc_type = *(bptr + i) & 3;
547 process_cc608(ctx, avpkt->
pts, *(bptr + i + 1) & 0x7f, *(bptr + i + 2) & 0x7f);
586 .priv_class = &ccaption_dec_class,
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
void av_bprintf(AVBPrint *buf, const char *fmt,...)
ptrdiff_t const GLvoid * data
static void handle_pac(CCaptionSubContext *ctx, uint8_t hi, uint8_t lo)
#define AV_LOG_WARNING
Something somehow does not look correct.
#define LIBAVUTIL_VERSION_INT
static av_cold int init(AVCodecContext *avctx)
void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
Same behaviour av_fast_malloc but the buffer has additional AV_INPUT_BUFFER_PADDING_SIZE at the end w...
static struct Screen * get_writing_screen(CCaptionSubContext *ctx)
static void handle_delete_end_of_row(CCaptionSubContext *ctx, char hi, char lo)
static void handle_char(CCaptionSubContext *ctx, char hi, char lo, int64_t pts)
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
#define CHECK_FLAG(var, val)
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
static int write_char(CCaptionSubContext *ctx, char *row, uint8_t col, char ch)
static int64_t start_time
static int handle_edm(CCaptionSubContext *ctx, int64_t pts)
int ff_ass_subtitle_header_default(AVCodecContext *avctx)
Generate a suitable AVCodecContext.subtitle_header for SUBTITLE_ASS with default style.
static int reap_screen(CCaptionSubContext *ctx, int64_t pts)
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
#define AV_BPRINT_SIZE_UNLIMITED
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define COR3(var, with1, with2, with3)
const char * name
Name of the codec implementation.
AVCodec ff_ccaption_decoder
Libavcodec external API header.
int64_t pts
Same as packet pts, in AV_TIME_BASE.
common internal API header
static SDL_Surface * screen
#define SET_FLAG(var, val)
static av_cold int init_decoder(AVCodecContext *avctx)
static int process_cc608(CCaptionSubContext *ctx, int64_t pts, uint8_t hi, uint8_t lo)
uint8_t characters[SCREEN_ROWS+1][SCREEN_COLUMNS+1]
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
static int handle_eoc(CCaptionSubContext *ctx, int64_t pts)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
uint8_t fonts[SCREEN_ROWS+1][SCREEN_COLUMNS+1]
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
static const unsigned char pac2_attribs[32][3]
int ff_ass_add_rect_bprint(AVSubtitle *sub, AVBPrint *buf, int ts_start, int duration)
Same as ff_ass_add_rect_bprint, but taking an AVBPrint buffer instead of a string, and assuming raw=0.
main external API structure.
Describe the class of an AVClass context structure.
rational number numerator/denominator
static int64_t pts
Global timestamp for the audio frames.
static const AVClass ccaption_dec_class
void av_bprint_clear(AVBPrint *buf)
Reset the string to "" but keep internal allocated data.
static void roll_up(CCaptionSubContext *ctx)
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
static const AVOption options[]
#define UNSET_FLAG(var, val)
static void handle_textattr(CCaptionSubContext *ctx, uint8_t hi, uint8_t lo)
static av_cold int close_decoder(AVCodecContext *avctx)
static const uint8_t parity_table[256]
static int validate_cc_data_pair(uint8_t *cc_data_pair)
This function after validating parity bit, also remove it from data pair.
This structure stores compressed data.
uint8_t colors[SCREEN_ROWS+1][SCREEN_COLUMNS+1]
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...