xine-lib  1.2.10
cc_decoder.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2000-2009 the xine project
3  *
4  * Copyright (C) Christian Vogler
5  * cvogler@gradient.cis.upenn.edu - December 2001
6  *
7  * This file is part of xine, a free video player.
8  *
9  * xine is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * xine is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
22  *
23  * stuff needed to provide closed captioning decoding and display
24  *
25  * Some small bits and pieces of the EIA-608 captioning decoder were
26  * adapted from CCDecoder 0.9.1 by Mike Baker. The latest version is
27  * available at http://sourceforge.net/projects/ccdecoder/.
28  */
29 
30 typedef struct cc_decoder_s cc_decoder_t;
32 
33 #define NUM_CC_PALETTES 2
34 #define CC_FONT_MAX 256
35 
36 typedef struct cc_config_s {
37  int cc_enabled; /* true if closed captions are enabled */
38  char font[CC_FONT_MAX]; /* standard captioning font & size */
39  int font_size;
40  char italic_font[CC_FONT_MAX]; /* italic captioning font & size */
41  int center; /* true if captions should be centered */
42  /* according to text width */
43  int cc_scheme; /* which captioning scheme to use */
44 
45  int config_version; /* the decoder should be updated when this is increased */
46 } cc_config_t;
47 
48 typedef struct spucc_class_s {
52 
53 typedef struct cc_state_s {
55  /* the following variables are not controlled by configuration files; they */
56  /* are intrinsic to the properties of the configuration options and the */
57  /* currently played video */
58  int can_cc; /* true if captions can be displayed */
59  /* (e.g., font fits on screen) */
60  cc_renderer_t *renderer; /* closed captioning renderer */
61 } cc_state_t;
62 
64 void cc_decoder_close(cc_decoder_t *this_obj);
65 
66 void decode_cc(cc_decoder_t *this, uint8_t *buffer, uint32_t buf_len,
67  int64_t pts);
68 
69 /* Instantiates a new closed captioning renderer. */
71  metronom_t *metronom, cc_state_t *cc_state,
72  int video_width, int video_height);
73 
74 /* Destroys a closed captioning renderer. */
75 void cc_renderer_close(cc_renderer_t *this_obj);
76 
77 /* Updates the renderer configuration variables */
78 void cc_renderer_update_cfg(cc_renderer_t *this_obj, int video_width,
79  int video_height);
80 
parity_table
static const int parity_table[256]
Parity table for packets.
Definition: cc_decoder.c:313
cc_decoder_open
cc_decoder_t * cc_decoder_open(cc_state_t *cc_state)
Definition: cc_decoder.c:1488
cc_renderer_s::cap_display
osd_object_t * cap_display
Definition: cc_decoder.c:347
colorinfo_s::bordercol
clut_t bordercol
Definition: cc_decoder.c:91
cc_renderer_s
Definition: cc_decoder.c:335
cc_decoder_s::active
cc_memory_t ** active
Definition: cc_decoder.c:424
GREEN
@ GREEN
Definition: cc_decoder.c:68
colorinfo_s::textcol
clut_t textcol
Definition: cc_decoder.c:92
cc_attribute_t
struct cc_attribute_s cc_attribute_t
cc_text_trans
static const colorinfo_t cc_text_trans[7]
Definition: cc_decoder.c:96
cc_hide_displayed
static void cc_hide_displayed(cc_decoder_t *this)
Definition: cc_decoder.c:1085
NTSC_FRAME_DURATION
#define NTSC_FRAME_DURATION
Definition: cc_decoder.c:54
OSD_TEXT2
#define OSD_TEXT2
Definition: osd.h:282
spucc_class_s::spu_class
spu_decoder_class_t spu_class
Definition: cc_decoder.h:49
xineutils.h
text_colormap
static const int text_colormap[7]
Definition: cc_decoder.c:77
cc_decoder_s
Definition: cc_decoder.c:417
ccrow_find_next_attr_change
static int ccrow_find_next_attr_change(cc_row_t *this, int pos, int lastpos)
Definition: cc_decoder.c:554
OSD_TEXT7
#define OSD_TEXT7
Definition: osd.h:287
clut_s::cb
uint8_t cb
Definition: alphablend.h:45
cc_renderer_adjust_osd_object
static void cc_renderer_adjust_osd_object(cc_renderer_t *this)
Definition: cc_decoder.c:940
OSD_TEXT1
#define OSD_TEXT1
Definition: osd.h:281
ccbuf_add_char
static void ccbuf_add_char(cc_buffer_t *this, uint8_t c)
Definition: cc_decoder.c:712
cc_memory_t
struct cc_memory_s cc_memory_t
cc_row_s::pac_attr_chg
int pac_attr_chg
Definition: cc_decoder.c:400
cc_renderer_s::metronom
metronom_t * metronom
Definition: cc_decoder.c:372
CLUT_Y_CR_CB_INIT
#define CLUT_Y_CR_CB_INIT(_y, _cr, _cb)
Definition: video_overlay.h:31
cc_renderer_free_osd_object
static void cc_renderer_free_osd_object(cc_renderer_t *this)
Definition: cc_decoder.c:929
cc_show_displayed
static void cc_show_displayed(cc_decoder_t *this)
Definition: cc_decoder.c:1102
cc_state_t
struct cc_state_s cc_state_t
cc_decoder_open
cc_decoder_t * cc_decoder_open(cc_state_t *cc_state)
Definition: cc_decoder.c:1488
cc_renderer_on_display
static int cc_renderer_on_display(cc_renderer_t *this)
Definition: cc_decoder.c:888
cc_renderer_s::cc_state
cc_state_t * cc_state
Definition: cc_decoder.c:374
cc_renderer_hide_caption
static void cc_renderer_hide_caption(cc_renderer_t *this, int64_t vpts)
Definition: cc_decoder.c:894
osd_renderer_s::free_object
void(* free_object)(osd_object_t *osd_to_close)
Definition: osd.h:99
OSD_TEXT6
#define OSD_TEXT6
Definition: osd.h:286
interpolate_color
static clut_t interpolate_color(clut_t src, clut_t dest, int steps, int current_step)
Definition: cc_decoder.c:488
rowdata
static const int rowdata[]
Definition: cc_decoder.c:223
cc_row_s::pac_attr
cc_attribute_t pac_attr
Definition: cc_decoder.c:401
cc_renderer_s::cc_palette
uint32_t cc_palette[OVL_PALETTE_SIZE]
Definition: cc_decoder.c:369
BLACK
@ BLACK
Definition: cc_decoder.c:68
cc_decode_ext_attribute
static void cc_decode_ext_attribute(cc_decoder_t *this, int channel, uint8_t c1, uint8_t c2)
Definition: cc_decoder.c:1187
cc_decode_PAC
static void cc_decode_PAC(cc_decoder_t *this, int channel, uint8_t c1, uint8_t c2)
Definition: cc_decoder.c:1151
metronom_s::got_spu_packet
int64_t(* got_spu_packet)(metronom_t *self, int64_t pts)
Definition: metronom.h:121
cc_decoder_s::pts
int64_t pts
Definition: cc_decoder.c:435
osd.h
cc_renderer_update_cfg
void cc_renderer_update_cfg(cc_renderer_t *this_obj, int video_width, int video_height)
Definition: cc_decoder.c:991
ccbuf_has_displayable
static int ccbuf_has_displayable(cc_buffer_t *this)
Definition: cc_decoder.c:701
get_font_metrics
static void get_font_metrics(osd_renderer_t *renderer, const char *fontname, int font_size, int *maxw, int *maxh)
Definition: cc_decoder.c:453
cc_config_s::config_version
int config_version
Definition: cc_decoder.h:45
cc_state_s::can_cc
int can_cc
Definition: cc_decoder.h:58
cc_text_trans_alpha
static const uint8_t cc_text_trans_alpha[TEXT_PALETTE_SIZE]
Definition: cc_decoder.c:199
ccbuf_tab
static void ccbuf_tab(cc_buffer_t *this, int tabsize)
Definition: cc_decoder.c:787
cc_char_cell_s::attributes
cc_attribute_t attributes
Definition: cc_decoder.c:389
cc_config_s::cc_enabled
int cc_enabled
Definition: cc_decoder.h:37
ccrow_set_attributes
static void ccrow_set_attributes(cc_renderer_t *renderer, cc_row_t *this, int pos)
Definition: cc_decoder.c:563
CAP_BG_COL
#define CAP_BG_COL
Definition: cc_decoder.c:61
cc_decoder_s::buffer
cc_memory_t buffer[2]
Definition: cc_decoder.c:419
cc_decode_special_char
static void cc_decode_special_char(cc_decoder_t *this, int channel, uint8_t c1, uint8_t c2)
Definition: cc_decoder.c:1196
cc_row_s::attr_chg
int attr_chg
Definition: cc_decoder.c:399
osd_object_s
Definition: osd.h:37
cc_renderer_open
cc_renderer_t * cc_renderer_open(osd_renderer_t *osd_renderer, metronom_t *metronom, cc_state_t *cc_state, int video_width, int video_height)
Definition: cc_decoder.c:959
cc_char_cell_s::midrow_attr
int midrow_attr
Definition: cc_decoder.c:391
cc_state_s
Definition: cc_decoder.h:53
CYAN
@ CYAN
Definition: cc_decoder.c:68
cc_renderer_close
void cc_renderer_close(cc_renderer_t *this_obj)
Definition: cc_decoder.c:980
cc_buffer_s::rowpos
int rowpos
Definition: cc_decoder.c:407
cc_renderer_s::y
int y
Definition: cc_decoder.c:340
cc_config_s
Definition: cc_decoder.h:36
colorinfo_t
struct colorinfo_s colorinfo_t
cc_state_s::renderer
cc_renderer_t * renderer
Definition: cc_decoder.h:60
cc_decoder_s::cc_state
cc_state_t * cc_state
Definition: cc_decoder.c:445
video_out.h
OVL_PALETTE_SIZE
#define OVL_PALETTE_SIZE
Definition: video_out.h:280
ccbuf_set_cursor
static void ccbuf_set_cursor(cc_buffer_t *this, int row, int column, int underline, int italics, int color)
Definition: cc_decoder.c:755
clut_s::y
uint8_t y
Definition: alphablend.h:47
cc_renderer_s::max_char_height
int max_char_height
Definition: cc_decoder.c:343
cc_config_s::font
char font[256]
Definition: cc_decoder.h:38
cc_buffer_s::rows
cc_row_t rows[15]
Definition: cc_decoder.c:406
cc_state_s::cc_cfg
cc_config_t * cc_cfg
Definition: cc_decoder.h:54
NULL
NULL
Definition: xine_plugin.c:78
cc_decoder_s::off_buf
cc_memory_t * off_buf
Definition: cc_decoder.c:422
clut_s::foo
uint8_t foo
Definition: alphablend.h:48
decode_cc
void decode_cc(cc_decoder_t *this, uint8_t *buffer, uint32_t buf_len, int64_t pts)
Definition: cc_decoder.c:1375
ccmem_exit
static void ccmem_exit(cc_memory_t *this)
Definition: cc_decoder.c:834
ccmem_init
static void ccmem_init(cc_memory_t *this)
Definition: cc_decoder.c:828
osd_renderer_s::set_encoding
int(* set_encoding)(osd_object_t *osd, const char *encoding)
Definition: osd.h:174
NUM_CC_PALETTES
#define NUM_CC_PALETTES
Definition: cc_decoder.h:33
cc_renderer_open
cc_renderer_t * cc_renderer_open(osd_renderer_t *osd_renderer, metronom_t *metronom, cc_state_t *cc_state, int video_width, int video_height)
Definition: cc_decoder.c:959
WHITE
@ WHITE
Definition: cc_decoder.c:68
cc_renderer_s::width
int width
Definition: cc_decoder.c:341
spucc_class_s::cc_cfg
cc_config_t cc_cfg
Definition: cc_decoder.h:50
cc_row_s::cells
cc_char_cell_t cells[32]
Definition: cc_decoder.c:396
cc_char_cell_s::c
uint8_t c
Definition: cc_decoder.c:388
cc_row_s::pos
int pos
Definition: cc_decoder.c:397
cc_renderer_s::x
int x
Definition: cc_decoder.c:339
cc_row_s
Definition: cc_decoder.c:395
cc_config_s::cc_scheme
int cc_scheme
Definition: cc_decoder.h:43
cc_config_s::center
int center
Definition: cc_decoder.h:41
width
unsigned int width
Definition: gfontrle.c:4
OSD_TEXT5
#define OSD_TEXT5
Definition: osd.h:285
MAGENTA
@ MAGENTA
Definition: cc_decoder.c:68
cc_renderer_s::displayed
int displayed
Definition: cc_decoder.c:348
osd_renderer_s::render_text
int(* render_text)(osd_object_t *osd, int x1, int y1, const char *text, int color_base)
Definition: osd.h:185
BLUE
@ BLUE
Definition: cc_decoder.c:68
cc_decoder_close
void cc_decoder_close(cc_decoder_t *this_obj)
Definition: cc_decoder.c:1517
cc_attribute_s::italic
uint8_t italic
Definition: cc_decoder.c:380
cc_config_t
struct cc_config_s cc_config_t
cc_decoder_s::f_offset
uint32_t f_offset
Definition: cc_decoder.c:437
TEXT_PALETTE_SIZE
#define TEXT_PALETTE_SIZE
Definition: osd.h:274
cc_decoder_s::displayed
int displayed
Definition: cc_decoder.c:442
cc_config_s::italic_font
char italic_font[256]
Definition: cc_decoder.h:40
ccmem_clear
static void ccmem_clear(cc_memory_t *this)
Definition: cc_decoder.c:819
osd_renderer_s::set_font
int(* set_font)(osd_object_t *osd, const char *fontname, int size)
Definition: osd.h:166
cc_row_s::num_chars
int num_chars
Definition: cc_decoder.c:398
CC_COLUMNS
#define CC_COLUMNS
Definition: cc_decoder.c:57
cc_renderer_close
void cc_renderer_close(cc_renderer_t *this_obj)
Definition: cc_decoder.c:980
MAX
#define MAX(a, b)
Definition: demux_ts.c:323
cc_memory_s::channel_no
int channel_no
Definition: cc_decoder.c:413
TRANSP_SPACE
#define TRANSP_SPACE
Definition: cc_decoder.c:220
spu_decoder_class_s
Definition: spu_decoder.h:42
cc_decoder_s::metronom
metronom_t * metronom
Definition: cc_decoder.c:447
cc_set_channel
static void cc_set_channel(cc_decoder_t *this, int channel)
Definition: cc_decoder.c:1063
osd_renderer_s
Definition: osd.h:82
cc_renderer_s::video_width
int video_width
Definition: cc_decoder.c:336
cc_config_s::font_size
int font_size
Definition: cc_decoder.h:39
cc_char_cell_s
Definition: cc_decoder.c:387
osd_renderer_s::get_text_size
int(* get_text_size)(osd_object_t *osd, const char *text, int *width, int *height)
Definition: osd.h:191
spucc_class_s
Definition: cc_decoder.h:48
ccrow_find_end_of_text_part
static int ccrow_find_end_of_text_part(cc_row_t *this, int pos)
Definition: cc_decoder.c:538
cc_memory_s::channel
cc_buffer_t channel[2]
Definition: cc_decoder.c:412
cc_renderer_calc_vpts
static int64_t cc_renderer_calc_vpts(cc_renderer_t *this, int64_t pts, uint32_t ntsc_frame_offset)
Definition: cc_decoder.c:878
cc_swap_buffers
static void cc_swap_buffers(cc_decoder_t *this)
Definition: cc_decoder.c:1122
cc_renderer_show_caption
static void cc_renderer_show_caption(cc_renderer_t *this, cc_buffer_t *buf, int64_t vpts)
Definition: cc_decoder.c:904
osd_renderer_s::filled_rect
void(* filled_rect)(osd_object_t *osd, int x1, int y1, int x2, int y2, int color)
Definition: osd.h:128
cc_attribute_s::background
uint8_t background
Definition: cc_decoder.c:383
decode_cc
void decode_cc(cc_decoder_t *this, uint8_t *buffer, uint32_t buf_len, int64_t pts)
Definition: cc_decoder.c:1375
cc_attribute_s::foreground
uint8_t foreground
Definition: cc_decoder.c:382
cc_renderer_s::height
int height
Definition: cc_decoder.c:342
good_parity
static int good_parity(uint16_t data)
Definition: cc_decoder.c:477
NUM_FG_COL
#define NUM_FG_COL
Definition: cc_decoder.c:64
active_ccbuffer
static cc_buffer_t * active_ccbuffer(cc_decoder_t *this)
Definition: cc_decoder.c:1072
height
unsigned int height
Definition: gfontrle.c:5
spucc_class_t
struct spucc_class_s spucc_class_t
cc_renderer_build_palette
static void cc_renderer_build_palette(cc_renderer_t *this)
Definition: cc_decoder.c:843
cc_attribute_s
Definition: cc_decoder.c:379
chartbl
static const int chartbl[128]
Character translation table.
Definition: cc_decoder.c:261
OSD_TEXT4
#define OSD_TEXT4
Definition: osd.h:284
ccrow_render
static void ccrow_render(cc_renderer_t *renderer, cc_row_t *this, int rownum)
Definition: cc_decoder.c:579
cc_decode_midrow_attr
static void cc_decode_midrow_attr(cc_decoder_t *this, int channel, uint8_t c1, uint8_t c2)
Definition: cc_decoder.c:1211
cc_renderer_s::display_vpts
int64_t display_vpts
Definition: cc_decoder.c:356
cc_decoder_close
void cc_decoder_close(cc_decoder_t *this)
Definition: cc_decoder.c:1517
metronom_s
Definition: metronom.h:71
ccrow_find_current_attr
static int ccrow_find_current_attr(cc_row_t *this, int pos)
Definition: cc_decoder.c:546
ccrow_fill_transp
static void ccrow_fill_transp(cc_row_t *rowbuf)
Definition: cc_decoder.c:516
cc_renderer_s::cc_trans
uint8_t cc_trans[OVL_PALETTE_SIZE]
Definition: cc_decoder.c:370
cc_decoder_s::on_buf
cc_memory_t * on_buf
Definition: cc_decoder.c:421
YELLOW
@ YELLOW
Definition: cc_decoder.c:68
OSD_TEXT3
#define OSD_TEXT3
Definition: osd.h:283
cc_memory_s
Definition: cc_decoder.c:411
cc_text_solid_alpha
static const uint8_t cc_text_solid_alpha[TEXT_PALETTE_SIZE]
Definition: cc_decoder.c:203
xine_internal.h
CC_CHANNELS
#define CC_CHANNELS
Definition: cc_decoder.c:58
cc_renderer_s::video_height
int video_height
Definition: cc_decoder.c:337
cc_renderer_update_cfg
void cc_renderer_update_cfg(cc_renderer_t *this_obj, int video_width, int video_height)
Definition: cc_decoder.c:991
cc_renderer_s::max_char_width
int max_char_width
Definition: cc_decoder.c:344
cc_onscreen_displayable
static int cc_onscreen_displayable(cc_decoder_t *this)
Definition: cc_decoder.c:1079
cc_decoder_s::renderer
osd_renderer_t * renderer
Definition: cc_decoder.c:440
config.h
cc_text_solid
static const colorinfo_t cc_text_solid[7]
Definition: cc_decoder.c:147
cc_buffer_t
struct cc_buffer_s cc_buffer_t
ccbuf_render
static void ccbuf_render(cc_renderer_t *renderer, cc_buffer_t *this)
Definition: cc_decoder.c:802
TRANSPARENT
@ TRANSPARENT
Definition: cc_decoder.c:68
cc_renderer_s::last_hide_vpts
int64_t last_hide_vpts
Definition: cc_decoder.c:366
colorinfo_s::bgcol
clut_t bgcol
Definition: cc_decoder.c:90
clut_s
Definition: alphablend.h:44
cc_renderer_s::osd_renderer
osd_renderer_t * osd_renderer
Definition: cc_decoder.c:346
osd_renderer_s::new_object
osd_object_t *(* new_object)(osd_renderer_t *this_gen, int width, int height)
Definition: osd.h:94
cc_decoder_s::capid
uint32_t capid
Definition: cc_decoder.c:428
ccrow_find_next_text_part
static int ccrow_find_next_text_part(cc_row_t *this, int pos)
Definition: cc_decoder.c:530
cc_decode_tab
static void cc_decode_tab(cc_decoder_t *this, int channel, uint8_t c1, uint8_t c2)
Definition: cc_decoder.c:1304
CC_ROWS
#define CC_ROWS
Definition: cc_decoder.c:56
cc_decoder.h
cc_alpha_palettes
static const uint8_t *const cc_alpha_palettes[2]
Definition: cc_decoder.c:213
cc_row_t
struct cc_row_s cc_row_t
RED
@ RED
Definition: cc_decoder.c:68
cc_decode_standard_char
static void cc_decode_standard_char(cc_decoder_t *this, uint8_t c1, uint8_t c2)
Definition: cc_decoder.c:1140
colorinfo_s
Definition: cc_decoder.c:89
specialchar
static const uint8_t specialchar[]
Definition: cc_decoder.c:227
CC_FONT_MAX
#define CC_FONT_MAX
Definition: cc_decoder.h:34
cc_decode_misc_control_code
static void cc_decode_misc_control_code(cc_decoder_t *this, int channel, uint8_t c1, uint8_t c2)
Definition: cc_decoder.c:1240
cc_buffer_s
Definition: cc_decoder.c:405
ccbuf_apply_attribute
static void ccbuf_apply_attribute(cc_buffer_t *this, cc_attribute_t *attr)
Definition: cc_decoder.c:775
cc_text_palettes
static const colorinfo_t *const cc_text_palettes[2]
Definition: cc_decoder.c:208
cc_char_cell_t
struct cc_char_cell_s cc_char_cell_t
cc_attribute_s::underline
uint8_t underline
Definition: cc_decoder.c:381
clut_s::cr
uint8_t cr
Definition: alphablend.h:46
cc_decode_EIA608
static void cc_decode_EIA608(cc_decoder_t *this, uint16_t data)
Definition: cc_decoder.c:1316
cc_decoder_s::lastcode
uint32_t lastcode
Definition: cc_decoder.c:432