xbmc
cc_decoder.h
1 /*
2  * Copyright (C) 2000-2008 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  * SPDX-License-Identifier: GPL-2.0-or-later
10  * See LICENSES/README.md for more information.
11  *
12  * stuff needed to provide closed captioning decoding and display
13  *
14  * Some small bits and pieces of the EIA-608 captioning decoder were
15  * adapted from CCDecoder 0.9.1 by Mike Baker. The latest version is
16  * available at http://sourceforge.net/projects/ccdecoder/.
17  */
18 
19 #pragma once
20 
21 #include <stdint.h>
22 
23 #define CC_ROWS 15
24 #define CC_COLUMNS 32
25 #define CC_CHANNELS 2
26 
27 /* colors specified by the EIA 608 standard */
28 enum cc_colors
29 {
30  WHITE,
31  GREEN,
32  BLUE,
33  CYAN,
34  RED,
35  YELLOW,
36  MAGENTA,
37  BLACK
38 };
39 
40 typedef struct cc_attribute_s {
41  uint8_t italic;
42  uint8_t underline;
43  uint8_t foreground;
44  uint8_t background;
46 
47 /* CC character cell */
48 typedef struct cc_char_cell_s
49 {
50  uint8_t c; /* character code, not the same as ASCII */
51  cc_attribute_t attributes; /* attributes of this character, if changed */
52  /* here */
53  uint8_t charset; /* charset type */
54  int midrow_attr; /* true if this cell changes an attribute */
56 
57 /* a single row in the closed captioning memory */
58 typedef struct cc_row_s
59 {
60  cc_char_cell_t cells[CC_COLUMNS];
61  int pos; /* position of the cursor */
62  int num_chars; /* how many characters in the row are data */
63  int attr_chg; /* true if midrow attr. change at cursor pos */
64  int pac_attr_chg; /* true if attribute has changed via PAC */
65  cc_attribute_t pac_attr; /* PAC attr. that hasn't been applied yet */
66 } cc_row_t;
67 
68 /* closed captioning memory for a single channel */
69 typedef struct cc_buffer_s
70 {
71  cc_row_t rows[CC_ROWS];
72  int rowpos; /* row cursor position */
73 } cc_buffer_t;
74 
75 /* captioning memory for all channels */
76 typedef struct cc_memory_s
77 {
78  cc_buffer_t channel[CC_CHANNELS];
79  int channel_no; /* currently active channel */
80 } cc_memory_t;
81 
82 enum cc_style
83 {
84  CC_NOTSET = 0,
85  CC_ROLLUP,
86  CC_PAINTON,
87  CC_POPON
88 };
89 
90 /* The closed captioning decoder data structure */
92 {
93  /* CC decoder buffer - one onscreen, one offscreen */
94  cc_memory_t buffer[2];
95  /* onscreen, offscreen buffer ptrs */
96  cc_memory_t *on_buf;
97  cc_memory_t *off_buf;
98  /* which buffer is active for receiving data */
99  cc_memory_t **active;
100 
101  /* the last captioning code seen (control codes are often sent twice
102  in a row, but should be processed only once) */
103  uint32_t lastcode;
104 
105  uint16_t rollup_rows;
106  enum cc_style style;
107 
108  void *userdata;
109  void(*callback)(int service, void *userdata);
110  char text[CC_ROWS*CC_COLUMNS + 1];
111  int textlen;
112  cc_attribute_t textattr;
113 };
114 
115 typedef struct cc_decoder_s cc_decoder_t;
116 
117 cc_decoder_t *cc_decoder_open();
118 void cc_decoder_close(cc_decoder_t *this_obj);
119 void cc_decoder_init(void);
120 
121 void decode_cc(cc_decoder_t *dec, const uint8_t *buffer, uint32_t buf_len);
Definition: cc_decoder.h:48
Definition: LibInputPointer.h:13
Definition: cc_decoder.h:76
Definition: cc_decoder.h:69
Definition: cc_decoder.h:58
Definition: cc_decoder.h:91
Definition: cc_decoder.h:40