OSDN Git Service

merge 0.9.4 to jp
[handbrake-jp/handbrake-jp.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_buffer_t *hb_buffer;
94     hb_buffer_t *hb_last_buffer;
95     uint64_t last_pts;
96     unsigned char *enc_buffer; // Generic general purpose buffer
97     unsigned enc_buffer_used;
98     unsigned enc_buffer_capacity;
99 };
100
101 enum command_code
102 {
103     COM_UNKNOWN = 0,
104     COM_ERASEDISPLAYEDMEMORY = 1,
105     COM_RESUMECAPTIONLOADING = 2,
106     COM_ENDOFCAPTION = 3,
107     COM_TABOFFSET1 = 4,
108     COM_TABOFFSET2 = 5,
109     COM_TABOFFSET3 = 6,
110     COM_ROLLUP2 = 7,
111     COM_ROLLUP3 = 8,
112     COM_ROLLUP4 = 9,
113     COM_CARRIAGERETURN = 10,
114     COM_ERASENONDISPLAYEDMEMORY = 11,
115     COM_BACKSPACE = 12,
116         COM_RESUMETEXTDISPLAY = 13
117 };
118
119 enum encoding_type
120 {
121     ENC_UNICODE = 0,
122     ENC_LATIN_1 = 1,
123     ENC_UTF_8 = 2
124 };
125
126 enum output_format
127 {
128     OF_RAW      = 0,
129     OF_SRT      = 1,
130     OF_SAMI = 2,
131     OF_TRANSCRIPT = 3,
132     OF_RCWT = 4
133 };
134
135 #endif