OSDN Git Service

e6c1518a7b212b07bbd64ac7cda8ed19a6f56a33
[handbrake-jp/handbrake-jp-git.git] / libhb / deccc608sub.h
1 /*
2  * From ccextractor, leave this file as intact and close to the original as possible so that 
3  * it is easy to patch in fixes - even though this file contains code that we don't need.
4  *
5  * Note that the SRT sub generation from CC could be useful for mkv subs.
6  */
7 #ifndef __deccc608sub_H__
8 #define __deccc608sub_H__
9
10 #include "common.h"
11
12 struct s_write;
13
14 void handle_end_of_data (struct s_write *wb);
15 void process608 (const unsigned char *data, int length, struct s_write *wb);
16 void get_char_in_latin_1 (unsigned char *buffer, unsigned char c);
17 void get_char_in_unicode (unsigned char *buffer, unsigned char c);
18 int get_char_in_utf_8 (unsigned char *buffer, unsigned char c);
19 unsigned char cctolower (unsigned char c);
20 unsigned char cctoupper (unsigned char c);
21 int general_608_init (struct s_write *wb);
22 void general_608_close (struct s_write *wb);
23
24 #define CC608_SCREEN_WIDTH  32
25
26 enum cc_modes
27 {
28     MODE_POPUP = 0,
29     MODE_ROLLUP_2 = 1,
30     MODE_ROLLUP_3 = 2,
31     MODE_ROLLUP_4 = 3,
32         MODE_TEXT = 4
33 };
34
35 enum color_code
36 {
37     COL_WHITE = 0,
38     COL_GREEN = 1,
39     COL_BLUE = 2,
40     COL_CYAN = 3,
41     COL_RED = 4,
42     COL_YELLOW = 5,
43     COL_MAGENTA = 6,
44         COL_USERDEFINED = 7
45 };
46
47
48 enum font_bits
49 {
50     FONT_REGULAR = 0,
51     FONT_ITALICS = 1,
52     FONT_UNDERLINED = 2,
53     FONT_UNDERLINED_ITALICS = 3
54 };
55
56
57 struct eia608_screen // A CC buffer
58 {
59     unsigned char characters[15][33]; 
60     unsigned char colors[15][33];
61     unsigned char fonts[15][33]; // Extra char at the end for a 0
62     int row_used[15]; // Any data in row?
63     int empty; // Buffer completely empty?      
64 };
65
66 #define LLONG long long
67
68 struct eia608
69 {
70     struct eia608_screen buffer1;
71     struct eia608_screen buffer2;  
72     int cursor_row, cursor_column;
73     int visible_buffer;
74     int srt_counter; // Number of subs currently written
75     int screenfuls_counter; // Number of meaningful screenfuls written
76     LLONG current_visible_start_ms; // At what time did the current visible buffer became so?
77     // unsigned current_visible_start_cc; // At what time did the current visible buffer became so?
78     enum cc_modes mode;
79     unsigned char last_c1, last_c2;
80     int channel; // Currently selected channel
81     unsigned char color; // Color we are currently using to write
82     unsigned char font; // Font we are currently using to write
83     int rollup_base_row;
84 };
85
86 struct s_write {
87     struct eia608 *data608;
88     FILE *fh;
89     unsigned char *subline; 
90     int new_sentence;
91     int new_channel;
92     int in_xds_mode;
93     hb_subtitle_t * subtitle;
94     uint64_t last_pts;
95 };
96
97 enum command_code
98 {
99     COM_UNKNOWN = 0,
100     COM_ERASEDISPLAYEDMEMORY = 1,
101     COM_RESUMECAPTIONLOADING = 2,
102     COM_ENDOFCAPTION = 3,
103     COM_TABOFFSET1 = 4,
104     COM_TABOFFSET2 = 5,
105     COM_TABOFFSET3 = 6,
106     COM_ROLLUP2 = 7,
107     COM_ROLLUP3 = 8,
108     COM_ROLLUP4 = 9,
109     COM_CARRIAGERETURN = 10,
110     COM_ERASENONDISPLAYEDMEMORY = 11,
111     COM_BACKSPACE = 12,
112         COM_RESUMETEXTDISPLAY = 13
113 };
114
115 enum encoding_type
116 {
117     ENC_UNICODE = 0,
118     ENC_LATIN_1 = 1,
119     ENC_UTF_8 = 2
120 };
121
122 enum output_format
123 {
124     OF_RAW      = 0,
125     OF_SRT      = 1,
126     OF_SAMI = 2,
127     OF_TRANSCRIPT = 3,
128     OF_RCWT = 4
129 };
130
131 #endif