mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
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:
parent
ff5b9a1cbe
commit
012559f2bb
@ -27,9 +27,9 @@
|
||||
#define SCREEN_ROWS 15
|
||||
#define SCREEN_COLUMNS 32
|
||||
|
||||
#define SET_FLAG(var, val) ( var |= ( 1 << (val) ) )
|
||||
#define UNSET_FLAG(var, val) ( var &= ~( 1 << (val)) )
|
||||
#define CHECK_FLAG(var, val) ( (var) & (1 << (val) ) )
|
||||
#define SET_FLAG(var, val) ( (var) |= ( 1 << (val)) )
|
||||
#define UNSET_FLAG(var, val) ( (var) &= ~( 1 << (val)) )
|
||||
#define CHECK_FLAG(var, val) ( (var) & ( 1 << (val)) )
|
||||
|
||||
/*
|
||||
* TODO list
|
||||
@ -44,8 +44,7 @@ enum cc_mode {
|
||||
CCMODE_TEXT,
|
||||
};
|
||||
|
||||
enum cc_color_code
|
||||
{
|
||||
enum cc_color_code {
|
||||
CCCOL_WHITE,
|
||||
CCCOL_GREEN,
|
||||
CCCOL_BLUE,
|
||||
@ -58,8 +57,7 @@ enum cc_color_code
|
||||
CCCOL_TRANSPARENT,
|
||||
};
|
||||
|
||||
enum cc_font
|
||||
{
|
||||
enum cc_font {
|
||||
CCFONT_REGULAR,
|
||||
CCFONT_ITALICS,
|
||||
CCFONT_UNDERLINED,
|
||||
@ -102,6 +100,7 @@ static const unsigned char pac2_attribs[][3] = // Color, font, ident
|
||||
{ CCCOL_WHITE, CCFONT_UNDERLINED, 28 } // 0x5f || 0x7f
|
||||
/* total 32 entries */
|
||||
};
|
||||
|
||||
/* 0-255 needs 256 spaces */
|
||||
static const uint8_t parity_table[256] = { 0, 1, 1, 0, 1, 0, 0, 1,
|
||||
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,
|
||||
1, 0, 0, 1, 0, 1, 1, 0 };
|
||||
|
||||
struct Screen {
|
||||
/* +1 is used to compensate null character of string */
|
||||
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);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ -295,6 +297,7 @@ static void handle_textattr( CCaptionSubContext *ctx, uint8_t hi, uint8_t lo )
|
||||
if(ret == 0)
|
||||
ctx->cursor_column++;
|
||||
}
|
||||
|
||||
static void handle_pac( CCaptionSubContext *ctx, uint8_t hi, uint8_t lo )
|
||||
{
|
||||
static const int8_t row_map[] = {
|
||||
@ -357,6 +360,7 @@ static int handle_edm(CCaptionSubContext *ctx,int64_t pts)
|
||||
ctx->end_time = pts;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int handle_eoc(CCaptionSubContext *ctx, int64_t pts)
|
||||
{
|
||||
int ret;
|
||||
@ -365,6 +369,7 @@ static int handle_eoc(CCaptionSubContext *ctx, int64_t pts)
|
||||
ctx->cursor_column = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void handle_delete_end_of_row( CCaptionSubContext *ctx, char hi, char lo)
|
||||
{
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
static void handle_char(CCaptionSubContext *ctx, char hi, char lo, int64_t pts)
|
||||
{
|
||||
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);
|
||||
#endif
|
||||
}
|
||||
|
||||
static int process_cc608(CCaptionSubContext *ctx, int64_t pts, uint8_t hi, uint8_t lo)
|
||||
{
|
||||
int ret = 0;
|
||||
@ -457,6 +464,7 @@ static int process_cc608(CCaptionSubContext *ctx, int64_t pts, uint8_t hi, uint8
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
|
||||
{
|
||||
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;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const AVOption options[] = {
|
||||
{NULL}
|
||||
};
|
||||
|
||||
static const AVClass ccaption_dec_class = {
|
||||
.class_name = "Closed caption Decoder",
|
||||
.item_name = av_default_item_name,
|
||||
|
Loading…
Reference in New Issue
Block a user