Cosmetic changes in cc_caption

Signed-off-by: Anshul Maheshwari <er.anshul.maheshwari@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Anshul Maheshwari 2015-01-20 15:51:23 +05:30 committed by Michael Niedermayer
parent ff5b9a1cbe
commit 012559f2bb
1 changed files with 49 additions and 39 deletions

View File

@ -27,8 +27,8 @@
#define SCREEN_ROWS 15 #define SCREEN_ROWS 15
#define SCREEN_COLUMNS 32 #define SCREEN_COLUMNS 32
#define SET_FLAG(var, val) ( var |= ( 1 << (val) ) ) #define SET_FLAG(var, val) ( (var) |= ( 1 << (val)) )
#define UNSET_FLAG(var, val) ( var &= ~( 1 << (val)) ) #define UNSET_FLAG(var, val) ( (var) &= ~( 1 << (val)) )
#define CHECK_FLAG(var, val) ( (var) & ( 1 << (val)) ) #define CHECK_FLAG(var, val) ( (var) & ( 1 << (val)) )
/* /*
@ -44,8 +44,7 @@ enum cc_mode {
CCMODE_TEXT, CCMODE_TEXT,
}; };
enum cc_color_code enum cc_color_code {
{
CCCOL_WHITE, CCCOL_WHITE,
CCCOL_GREEN, CCCOL_GREEN,
CCCOL_BLUE, CCCOL_BLUE,
@ -58,8 +57,7 @@ enum cc_color_code
CCCOL_TRANSPARENT, CCCOL_TRANSPARENT,
}; };
enum cc_font enum cc_font {
{
CCFONT_REGULAR, CCFONT_REGULAR,
CCFONT_ITALICS, CCFONT_ITALICS,
CCFONT_UNDERLINED, CCFONT_UNDERLINED,
@ -102,6 +100,7 @@ static const unsigned char pac2_attribs[][3] = // Color, font, ident
{ CCCOL_WHITE, CCFONT_UNDERLINED, 28 } // 0x5f || 0x7f { CCCOL_WHITE, CCFONT_UNDERLINED, 28 } // 0x5f || 0x7f
/* total 32 entries */ /* total 32 entries */
}; };
/* 0-255 needs 256 spaces */ /* 0-255 needs 256 spaces */
static const uint8_t parity_table[256] = { 0, 1, 1, 0, 1, 0, 0, 1, static const uint8_t parity_table[256] = { 0, 1, 1, 0, 1, 0, 0, 1,
1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0,
@ -135,6 +134,7 @@ static const uint8_t parity_table[256] = { 0, 1, 1, 0, 1, 0, 0, 1,
0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1,
0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1,
1, 0, 0, 1, 0, 1, 1, 0 }; 1, 0, 0, 1, 0, 1, 1, 0 };
struct Screen { struct Screen {
/* +1 is used to compensate null character of string */ /* +1 is used to compensate null character of string */
uint8_t characters[SCREEN_ROWS][SCREEN_COLUMNS+1]; uint8_t characters[SCREEN_ROWS][SCREEN_COLUMNS+1];
@ -197,6 +197,7 @@ static av_cold int close_decoder(AVCodecContext *avctx)
av_buffer_unref(&ctx->pktbuf); av_buffer_unref(&ctx->pktbuf);
return 0; return 0;
} }
/** /**
* @param ctx closed caption context just to print log * @param ctx closed caption context just to print log
*/ */
@ -216,6 +217,7 @@ static int write_char (CCaptionSubContext *ctx, char *row,uint8_t col, char ch)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
} }
/** /**
* This function after validating parity bit, also remove it from data pair. * This function after validating parity bit, also remove it from data pair.
* The first byte doesn't pass parity, we replace it with a solid blank * The first byte doesn't pass parity, we replace it with a solid blank
@ -295,6 +297,7 @@ static void handle_textattr( CCaptionSubContext *ctx, uint8_t hi, uint8_t lo )
if(ret == 0) if(ret == 0)
ctx->cursor_column++; ctx->cursor_column++;
} }
static void handle_pac( CCaptionSubContext *ctx, uint8_t hi, uint8_t lo ) static void handle_pac( CCaptionSubContext *ctx, uint8_t hi, uint8_t lo )
{ {
static const int8_t row_map[] = { static const int8_t row_map[] = {
@ -357,6 +360,7 @@ static int handle_edm(CCaptionSubContext *ctx,int64_t pts)
ctx->end_time = pts; ctx->end_time = pts;
return ret; return ret;
} }
static int handle_eoc(CCaptionSubContext *ctx, int64_t pts) static int handle_eoc(CCaptionSubContext *ctx, int64_t pts)
{ {
int ret; int ret;
@ -365,6 +369,7 @@ static int handle_eoc(CCaptionSubContext *ctx, int64_t pts)
ctx->cursor_column = 0; ctx->cursor_column = 0;
return ret; return ret;
} }
static void handle_delete_end_of_row( CCaptionSubContext *ctx, char hi, char lo) static void handle_delete_end_of_row( CCaptionSubContext *ctx, char hi, char lo)
{ {
struct Screen *screen = get_writing_screen(ctx); struct Screen *screen = get_writing_screen(ctx);
@ -372,6 +377,7 @@ static void handle_delete_end_of_row( CCaptionSubContext *ctx, char hi, char lo)
write_char(ctx, row, ctx->cursor_column, 0); write_char(ctx, row, ctx->cursor_column, 0);
} }
static void handle_char(CCaptionSubContext *ctx, char hi, char lo, int64_t pts) static void handle_char(CCaptionSubContext *ctx, char hi, char lo, int64_t pts)
{ {
struct Screen *screen = get_writing_screen(ctx); struct Screen *screen = get_writing_screen(ctx);
@ -398,6 +404,7 @@ static void handle_char(CCaptionSubContext *ctx, char hi, char lo, int64_t pts)
av_log(ctx, AV_LOG_DEBUG,"(%c,%c)\n",hi,lo); av_log(ctx, AV_LOG_DEBUG,"(%c,%c)\n",hi,lo);
#endif #endif
} }
static int process_cc608(CCaptionSubContext *ctx, int64_t pts, uint8_t hi, uint8_t lo) static int process_cc608(CCaptionSubContext *ctx, int64_t pts, uint8_t hi, uint8_t lo)
{ {
int ret = 0; int ret = 0;
@ -457,6 +464,7 @@ static int process_cc608(CCaptionSubContext *ctx, int64_t pts, uint8_t hi, uint8
return ret; return ret;
} }
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt) static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
{ {
CCaptionSubContext *ctx = avctx->priv_data; CCaptionSubContext *ctx = avctx->priv_data;
@ -506,9 +514,11 @@ static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avp
*got_sub = sub->num_rects > 0; *got_sub = sub->num_rects > 0;
return ret; return ret;
} }
static const AVOption options[] = { static const AVOption options[] = {
{NULL} {NULL}
}; };
static const AVClass ccaption_dec_class = { static const AVClass ccaption_dec_class = {
.class_name = "Closed caption Decoder", .class_name = "Closed caption Decoder",
.item_name = av_default_item_name, .item_name = av_default_item_name,