|
libclosedcaption 1.0.3
ISDB-Tb/SBTVD (Brazilian DTV) closed caption extraction from MPEG-TS
|
C0, C1 and CSI control commands of the caption text. More...
#include "caption-common.h"#include "caption-data.h"#include "caption-closed.h"#include "caption-management.h"

Go to the source code of this file.
Data Structures | |
| struct | CC_ControlCodes_CallbackData_t |
| struct | CaptionClosedControls_t |
| struct | csi_arg_Pn |
Macros | |
| #define | DEBUG_CAPTION_CLOSED_CONTROLCODE |
| #define | CAPTION_CTRL_SET(code, callback) { code, callback, #code } |
| #define | CTRL_C0_NULL 0x00 |
| #define | CTRL_C0_BELL 0x07 |
| #define | CTRL_CSI_FB 0x20 |
| #define | CTRL_CSI_IB 0x3b |
| #define | CTRL_CSI_MAX_Pn_ARGS 5 |
| #define | CTRL_CSI_MAX_Pn_FIELDS (5+1) |
Typedefs | |
| typedef uint8_t | CaptionClosed_CtrlCode_t |
C0, C1 and CSI control commands of the caption text.
The caption text mixes characters and control commands (ARIB STD-B24, Volume 1, 7.2; ABNT NBR 15606-1; ARIB TR-B14, 6.5):
CSI P1 ; P2 ; ... 0x20 F, where the parameters are decimal numbers in ASCII and the final byte F tells the command (SWF, SDF, SDP...).Each command has a callback_controls_* callback, called by caption_closed_controls_load(). It reads the parameters, updates the CaptionClosed_t and moves the read position past the parameters. When the callback returns TRUE, the controls hook is called (see caption-hooking.h).
Commands that should not be used in closed caption (only in superimpose) return FALSE, but still skip their parameters, so they are not handled as text.
Example of caption text (TV Globo):
* 00000000 0c 9b 37 20 53 9b 31 37 36 3b 39 39 20 5f 9b 36 |..7.S.176;99._.6| * 00000010 30 38 3b 33 39 30 20 56 9b 33 36 3b 33 36 20 57 |08;390.V.36;36.W| * 00000020 9b 32 20 58 9b 31 36 20 59 9b 38 20 6e 88 1c 4c |.2.X.16.Y.8.n..L| * 00000030 40 87 90 50 5b 4d 41 54 45 55 53 5d 20 4f 20 43 |@..P[MATEUS].O.C| * 00000040 41 4c 49 58 54 4f 20 56 41 49 0d 52 45 53 4f 4c |ALIXTO.VAI.RESOL| * 00000050 56 45 52 20 4f 20 50 52 4f 42 4c 45 4d 41 20 44 |VER.O.PROBLEMA.D| * 00000060 4f 20 43 41 52 52 4f 2c 0d 4f 20 4d 41 49 53 20 |O.CARRO,.O.MAIS.| * 00000070 52 c1 50 49 44 4f 20 50 4f 53 53 cd 56 45 4c 2e |R.PIDO.POSS.VEL.| * * 0c CS: clear screen * 9b 37 20 53 CSI SWF(7): 960x540 horizontal format * 9b ... 20 5f CSI SDP(176;99): position of the display area * 9b ... 20 56 CSI SDF(608;390): size of the display area * 9b ... 20 57 CSI SSM(36;36): character size * 9b 32 20 58 CSI SHS(2): horizontal spacing * 9b 31 36 20 59 CSI SVS(16): vertical spacing * 9b 38 20 6e CSI RCS(8): transparent raster color * 88 SSZ: small characters * 1c 4c 40 APS(12, 0): cursor at row 12, column 0 * 87 WHF: white text * 90 50 COL: black background * 0d APR: new line * c1, cd 'Á' and 'Í' in ISO-8859-15 *
Definition in file caption-closed-controls.h.
| #define DEBUG_CAPTION_CLOSED_CONTROLCODE |
Includes the CaptionClosedControls_t::code_name field in the command tables, used by caption_closed_controls_get_name() in the debug messages.
Definition at line 68 of file caption-closed-controls.h.
| #define CAPTION_CTRL_SET | ( | code, | |
| callback | |||
| ) | { code, callback, #code } |
Builds an entry of the command tables.
Definition at line 101 of file caption-closed-controls.h.
| #define CTRL_C0_NULL 0x00 |
NUL: ignored.
Definition at line 122 of file caption-closed-controls.h.
| #define CTRL_C0_BELL 0x07 |
BEL: ignored in closed caption.
Definition at line 123 of file caption-closed-controls.h.
| #define CTRL_CSI_FB 0x20 |
Intermediate byte (0x20) that comes before the final byte of the CSI.
Definition at line 315 of file caption-closed-controls.h.
| #define CTRL_CSI_IB 0x3b |
CSI parameter separator (';').
Definition at line 316 of file caption-closed-controls.h.
| #define CTRL_CSI_MAX_Pn_ARGS 5 |
Max number of parameters read from a CSI.
Definition at line 318 of file caption-closed-controls.h.
| #define CTRL_CSI_MAX_Pn_FIELDS (5+1) |
Max digits of a parameter, plus the '\0' (up to "65535").
Definition at line 319 of file caption-closed-controls.h.
| typedef uint8_t CaptionClosed_CtrlCode_t |
Code of a control command (C0, C1 or CSI).
Definition at line 71 of file caption-closed-controls.h.
C0 commands (ARIB TR-B14, Table 3.11; ARIB STD-B24, Table 7-14).
Unused values are filled with PAD, so the code minus 0x08 is the direct index into the callbacks table.
Definition at line 121 of file caption-closed-controls.h.
C1 commands (ARIB TR-B14, Table 3.11; ARIB STD-B24, Table 7-15).
Unused values are filled with PAD, so the code minus 0x80 is the direct index into the callbacks table.
| Enumerator | |
|---|---|
| CTRL_C1_BKF | Black Foreground: black text. |
| CTRL_C1_RDF | Red Foreground: red text. |
| CTRL_C1_GRF | Green Foreground: green text. |
| CTRL_C1_YLF | Yellow Foreground: yellow text. |
| CTRL_C1_BLF | Blue Foreground: blue text. |
| CTRL_C1_MGF | Magenta Foreground: magenta text. |
| CTRL_C1_CNF | Cyan Foreground: cyan text. |
| CTRL_C1_WHF | White Foreground: white text. |
| CTRL_C1_SSZ | Small Size: small characters. |
| CTRL_C1_MSZ | Middle Size: medium characters. |
| CTRL_C1_NSZ | Normal Size: normal characters. |
| CTRL_C1_SZX | Character Size Controls: size given by P1. |
| CTRL_C1_PAD_0x8c | Unused. |
| CTRL_C1_PAD_0x8d | Unused. |
| CTRL_C1_PAD_0x8e | Unused. |
| CTRL_C1_PAD_0x8f | Unused. |
| CTRL_C1_COL | Colour Controls: text/background color (P1, or 0x20 P2 for the palette). |
| CTRL_C1_FLC | Flashing Control: blinking. |
| CTRL_C1_CDC | Conceal Display Controls. |
| CTRL_C1_POL | Pattern Polarity Controls. |
| CTRL_C1_WMM | Writing Mode Modification. |
| CTRL_C1_MAC | Macro Command. |
| CTRL_C1_PAD_0x96 | Unused. |
| CTRL_C1_HLC | Highlighting Character Block: outline. |
| CTRL_C1_RPC | Repeat Character: repeats the next character. |
| CTRL_C1_SPL | Stop Lining: end of underline. |
| CTRL_C1_STL | Start Lining: start of underline. |
| CTRL_C1_CSI | Control Sequence Introducer: extended sequence, see CaptionClosed_CtrlCodes_C1_CSI. |
| CTRL_C1_PAD_0x9c | Unused. |
| CTRL_C1_TIM | Time Controls: wait/timing. |
| CTRL_C1_PAD_0x9e | Unused. |
| CTRL_C1_PAD_0x9f | Unused. |
Definition at line 184 of file caption-closed-controls.h.
CSI subcommands: the final byte F of the sequence CSI P1 ; P2 ; ... 0x20 F (ARIB STD-B24, Table 7-17).
Unused values are filled with PAD, so the code minus 0x53 is the direct index into the callbacks table.
Definition at line 262 of file caption-closed-controls.h.
Start of each command table: the code minus this value is the index in the callbacks table.
| Enumerator | |
|---|---|
| CC_CTRLCODE_SET_UNKNOWN | Not a command. |
| CC_CTRLCODE_SET_C0 | C0 table (0x08 to 0x1f). |
| CC_CTRLCODE_SET_C1 | C1 table (0x80 to 0x9f). |
Definition at line 346 of file caption-closed-controls.h.
| enum CC_Color_CMLA_t |
Colors of the CMLA palette (Colour Map Lower Address), used by the color commands (BKF ~ WHF and COL).
Definition at line 386 of file caption-closed-controls.h.
| const char * caption_closed_controls_get_name | ( | const uint8_t | code | ) |
Name of a command, for debug messages.
| code | C0, C1 or CSI subcommand code. |
| bool callback_controls_c0_APB | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
APB: not supported in closed caption.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c0_APF | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
APF: accepted, no effect on the state.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c0_APD | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
APD: not supported in closed caption.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c0_APU | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
APU: not supported in closed caption.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c0_CS | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
CS: sets CaptionClosed_t::need_clear.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c0_APR | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
APR: accepted; the controls hook gets the line break.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c0_LS1 | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
LS1: not supported in closed caption.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c0_LS0 | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
LS0: not supported in closed caption.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c0_PAPF | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
PAPF: not supported; skips 1 parameter.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c0_CAN | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
CAN: not supported in closed caption.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c0_SS2 | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
SS2: not supported; skips 1 parameter.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c0_ESC | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
ESC: not supported; skips the whole sequence.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c0_APS | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
APS: updates CaptionClosed_t::APS (2 parameters).
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c0_SS3 | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
SS3: hands the G3 character in UTF-8 to the text hook.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c0_RS | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
RS: not supported in closed caption.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c0_US | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
US: accepted, no effect on the state.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c1_BKF | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
BKF: black text.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c1_RDF | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
RDF: red text.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c1_GRF | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
GRF: green text.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c1_YLF | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
YLF: yellow text.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c1_BLF | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
BLF: blue text.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c1_MGF | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
MGF: magenta text.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c1_CNF | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
CNF: cyan text.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c1_WHF | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
WHF: white text.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c1_SSZ | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
SSZ: small characters.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c1_MSZ | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
MSZ: medium characters.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c1_NSZ | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
NSZ: normal characters.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c1_SZX | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
SZX: stores P1 in CaptionClosed_t::char_size_custom.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c1_COL | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
COL: text, background or half intensity color.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c1_FLC | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
FLC: not supported; skips 1 parameter.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c1_CDC | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
CDC: not supported; skips 1 or 2 parameters.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c1_POL | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
POL: not supported; skips 1 parameter.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c1_WMM | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
WMM: not supported; skips 1 parameter.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c1_MAC | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
MAC: not supported; skips 1 parameter.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c1_HLC | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
HLC: not supported; skips 1 parameter.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c1_RPC | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
RPC: not supported; skips 1 parameter.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c1_SPL | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
SPL: not supported in closed caption.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c1_STL | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
STL: not supported in closed caption.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c1_TIM | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
TIME: not supported; skips 2 parameters.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c1_CSI_load | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
CSI: reads the sequence and dispatches the subcommand.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c1_CSI_swf | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
SWF: format, characters per line and lines.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c1_CSI_ssm | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
SSM: character size (P1 x P2).
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c1_CSI_shs | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
SHS: horizontal spacing (P1).
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c1_CSI_svs | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
SVS: vertical spacing (P1).
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c1_CSI_orn | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
ORN: not implemented.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c1_CSI_cfs | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
CFS: not implemented.
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c1_CSI_rcs | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
RCS: raster color (P1, from 0 to 15).
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c1_CSI_sdf | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
SDF: size of the display area (P1 x P2).
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool callback_controls_c1_CSI_sdp | ( | const CC_ControlCodes_CallbackData_t * | d | ) |
SDP: position of the display area (P1, P2).
| d | Command data (see CC_ControlCodes_CallbackData_t). |
| bool csi_arg_Pn_load | ( | CC_ControlCodes_CallbackData_t * | d | ) |
Reads the decimal parameters of a CSI sequence, separated by ';'.
| d | d->argv points to the first parameter, d->argc is the number of parameter bytes and d->data points to the csi_arg_Pn struct that receives the values. |
| bool caption_closed_controls_is_table | ( | const uint8_t * | byte, |
| enum CC_ControlCodes_TableJump_e * | table | ||
| ) |
Checks if a byte is a C0 or C1 command.
| byte | Caption text byte. |
| table | Receives the command table, or CC_CTRLCODE_SET_UNKNOWN. |
| bool caption_closed_controls_load | ( | enum CC_ControlCodes_TableJump_e | table, |
| const uint8_t * | argv, | ||
| const uint16_t | argc, | ||
| uint16_t * | pos, | ||
| CaptionClosed_t * | caption | ||
| ) |
Runs the C0/C1 command at argv[*pos].
Calls the command callback, which moves pos past the parameters, and, if it returns TRUE, calls the controls hook.
| table | Command table, got from caption_closed_controls_is_table(). |
| argv | Caption text buffer. |
| argc | Number of bytes available from pos. |
| pos | Position of the command in argv; on return, it points to the last byte consumed by the command. |
| caption | Caption state. |