FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions | Variables
ccaption_dec.c File Reference
#include "avcodec.h"
#include "ass.h"
#include "libavutil/opt.h"

Go to the source code of this file.

Data Structures

struct  Screen
 
struct  CCaptionSubContext
 

Macros

#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 OFFSET(x)   offsetof(CCaptionSubContext, x)
 
#define SD   AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_DECODING_PARAM
 

Enumerations

enum  cc_mode { CCMODE_POPON, CCMODE_PAINTON, CCMODE_ROLLUP, CCMODE_TEXT }
 
enum  cc_color_code {
  CCCOL_WHITE, CCCOL_GREEN, CCCOL_BLUE, CCCOL_CYAN,
  CCCOL_RED, CCCOL_YELLOW, CCCOL_MAGENTA, CCCOL_USERDEFINED,
  CCCOL_BLACK, CCCOL_TRANSPARENT
}
 
enum  cc_font { CCFONT_REGULAR, CCFONT_ITALICS, CCFONT_UNDERLINED, CCFONT_UNDERLINED_ITALICS }
 

Functions

static av_cold int init_decoder (AVCodecContext *avctx)
 
static av_cold int close_decoder (AVCodecContext *avctx)
 
static void flush_decoder (AVCodecContext *avctx)
 
static int write_char (CCaptionSubContext *ctx, struct Screen *screen, char ch)
 
static int validate_cc_data_pair (uint8_t *cc_data_pair)
 This function after validating parity bit, also remove it from data pair. More...
 
static struct Screenget_writing_screen (CCaptionSubContext *ctx)
 
static void roll_up (CCaptionSubContext *ctx)
 
static int capture_screen (CCaptionSubContext *ctx)
 
static int reap_screen (CCaptionSubContext *ctx, int64_t pts)
 
static void handle_textattr (CCaptionSubContext *ctx, uint8_t hi, uint8_t lo)
 
static void handle_pac (CCaptionSubContext *ctx, uint8_t hi, uint8_t lo)
 
static void handle_edm (CCaptionSubContext *ctx, int64_t pts)
 
static void handle_eoc (CCaptionSubContext *ctx, int64_t pts)
 
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)
 
static void process_cc608 (CCaptionSubContext *ctx, int64_t pts, uint8_t hi, uint8_t lo)
 
static int decode (AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
 

Variables

static const AVRational ass_tb = {1, 100}
 
static const unsigned char pac2_attribs [32][3]
 
static const AVOption options []
 
static const AVClass ccaption_dec_class
 
AVCodec ff_ccaption_decoder
 

Macro Definition Documentation

#define SCREEN_ROWS   15

Definition at line 26 of file ccaption_dec.c.

Referenced by capture_screen(), and roll_up().

#define SCREEN_COLUMNS   32

Definition at line 27 of file ccaption_dec.c.

Referenced by capture_screen(), roll_up(), and write_char().

#define SET_FLAG (   var,
  val 
)    ( (var) |= ( 1 << (val)) )

Definition at line 29 of file ccaption_dec.c.

Referenced by handle_char(), handle_textattr(), and roll_up().

#define UNSET_FLAG (   var,
  val 
)    ( (var) &= ~( 1 << (val)) )

Definition at line 30 of file ccaption_dec.c.

Referenced by roll_up().

#define CHECK_FLAG (   var,
  val 
)    ( (var) & ( 1 << (val)) )

Definition at line 31 of file ccaption_dec.c.

Referenced by capture_screen(), and roll_up().

#define OFFSET (   x)    offsetof(CCaptionSubContext, x)

Definition at line 646 of file ccaption_dec.c.

Enumeration Type Documentation

enum cc_mode
Enumerator
CCMODE_POPON 
CCMODE_PAINTON 
CCMODE_ROLLUP 
CCMODE_TEXT 

Definition at line 39 of file ccaption_dec.c.

Enumerator
CCCOL_WHITE 
CCCOL_GREEN 
CCCOL_BLUE 
CCCOL_CYAN 
CCCOL_RED 
CCCOL_YELLOW 
CCCOL_MAGENTA 
CCCOL_USERDEFINED 
CCCOL_BLACK 
CCCOL_TRANSPARENT 

Definition at line 46 of file ccaption_dec.c.

enum cc_font
Enumerator
CCFONT_REGULAR 
CCFONT_ITALICS 
CCFONT_UNDERLINED 
CCFONT_UNDERLINED_ITALICS 

Definition at line 59 of file ccaption_dec.c.

Function Documentation

static av_cold int init_decoder ( AVCodecContext avctx)
static

Definition at line 142 of file ccaption_dec.c.

static av_cold int close_decoder ( AVCodecContext avctx)
static

Definition at line 171 of file ccaption_dec.c.

static void flush_decoder ( AVCodecContext avctx)
static

Definition at line 179 of file ccaption_dec.c.

static int write_char ( CCaptionSubContext ctx,
struct Screen screen,
char  ch 
)
static
Parameters
ctxclosed caption context just to print log

Definition at line 202 of file ccaption_dec.c.

Referenced by handle_char(), handle_delete_end_of_row(), handle_pac(), and handle_textattr().

static int validate_cc_data_pair ( uint8_t cc_data_pair)
static

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 and process the pair. If the second byte doesn't pass parity, it returns INVALIDDATA user can ignore the whole pair and pass the other pair.

Definition at line 232 of file ccaption_dec.c.

Referenced by decode().

static struct Screen* get_writing_screen ( CCaptionSubContext ctx)
static
static void roll_up ( CCaptionSubContext ctx)
static

Definition at line 282 of file ccaption_dec.c.

Referenced by process_cc608().

static int capture_screen ( CCaptionSubContext ctx)
static

Definition at line 316 of file ccaption_dec.c.

Referenced by avf_read_header(), decode(), and reap_screen().

static int reap_screen ( CCaptionSubContext ctx,
int64_t  pts 
)
static

Definition at line 380 of file ccaption_dec.c.

Referenced by handle_edm(), handle_eoc(), and process_cc608().

static void handle_textattr ( CCaptionSubContext ctx,
uint8_t  hi,
uint8_t  lo 
)
static

Definition at line 388 of file ccaption_dec.c.

Referenced by process_cc608().

static void handle_pac ( CCaptionSubContext ctx,
uint8_t  hi,
uint8_t  lo 
)
static

Definition at line 403 of file ccaption_dec.c.

Referenced by process_cc608().

static void handle_edm ( CCaptionSubContext ctx,
int64_t  pts 
)
static
Parameters
ptsit is required to set end time

Definition at line 432 of file ccaption_dec.c.

Referenced by handle_eoc(), and process_cc608().

static void handle_eoc ( CCaptionSubContext ctx,
int64_t  pts 
)
static

Definition at line 449 of file ccaption_dec.c.

Referenced by process_cc608().

static void handle_delete_end_of_row ( CCaptionSubContext ctx,
char  hi,
char  lo 
)
static

Definition at line 465 of file ccaption_dec.c.

Referenced by process_cc608().

static void handle_char ( CCaptionSubContext ctx,
char  hi,
char  lo,
int64_t  pts 
)
static

Definition at line 471 of file ccaption_dec.c.

Referenced by process_cc608().

static void process_cc608 ( CCaptionSubContext ctx,
int64_t  pts,
uint8_t  hi,
uint8_t  lo 
)
static

Definition at line 496 of file ccaption_dec.c.

Referenced by decode().

static int decode ( AVCodecContext avctx,
void data,
int *  got_sub,
AVPacket avpkt 
)
static
Examples:
qsvdec.c.

Definition at line 572 of file ccaption_dec.c.

Referenced by frame_alloc(), get_buffer(), get_format(), main(), and show_formats_devices().

Variable Documentation

const AVRational ass_tb = {1, 100}
static

Definition at line 33 of file ccaption_dec.c.

const unsigned char pac2_attribs[32][3]
static

Definition at line 66 of file ccaption_dec.c.

Referenced by handle_pac(), and handle_textattr().

const AVOption options[]
static
Initial value:
= {
{ "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 },
{NULL}
}
#define NULL
Definition: coverity.c:32
#define OFFSET(x)
Definition: ccaption_dec.c:646
#define SD
Definition: ccaption_dec.c:647

Definition at line 648 of file ccaption_dec.c.

const AVClass ccaption_dec_class
static
Initial value:
= {
.class_name = "Closed caption Decoder",
.item_name = av_default_item_name,
.option = options,
}
#define LIBAVUTIL_VERSION_INT
Definition: version.h:70
av_default_item_name
static const AVOption options[]
Definition: ccaption_dec.c:648

Definition at line 653 of file ccaption_dec.c.

AVCodec ff_ccaption_decoder
Initial value:
= {
.name = "cc_dec",
.long_name = NULL_IF_CONFIG_SMALL("Closed Caption (EIA-608 / CEA-708) Decoder"),
.priv_data_size = sizeof(CCaptionSubContext),
.close = close_decoder,
.priv_class = &ccaption_dec_class,
}
static void flush(AVCodecContext *avctx)
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:176
static av_cold int init_decoder(AVCodecContext *avctx)
Definition: ccaption_dec.c:142
static void flush_decoder(AVCodecContext *avctx)
Definition: ccaption_dec.c:179
static const AVClass ccaption_dec_class
Definition: ccaption_dec.c:653
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
Definition: ccaption_dec.c:572
static av_cold int close_decoder(AVCodecContext *avctx)
Definition: ccaption_dec.c:171

Definition at line 660 of file ccaption_dec.c.