OSDN Git Service

Structural changes, in order to eventually be able to compile HB
[handbrake-jp/handbrake-jp-git.git] / libhb / internal.h
1 /* $Id: internal.h,v 1.41 2005/11/25 15:05:25 titer Exp $
2
3    This file is part of the HandBrake source code.
4    Homepage: <http://handbrake.m0k.org/>.
5    It may be used under the terms of the GNU General Public License. */
6
7 /***********************************************************************
8  * common.c
9  **********************************************************************/
10 void hb_log( char * log, ... );
11
12 int  hb_list_bytes( hb_list_t * );
13 void hb_list_seebytes( hb_list_t * l, uint8_t * dst, int size );
14 void hb_list_getbytes( hb_list_t * l, uint8_t * dst, int size,
15                        uint64_t * pts, int * pos );
16 void hb_list_empty( hb_list_t ** );
17
18 hb_title_t * hb_title_init( char * dvd, int index );
19 void         hb_title_close( hb_title_t ** );
20
21 /***********************************************************************
22  * hb.c
23  **********************************************************************/
24 int  hb_get_pid( hb_handle_t * );
25 void hb_set_state( hb_handle_t *, hb_state_t * );
26
27 /***********************************************************************
28  * fifo.c
29  **********************************************************************/
30 typedef struct hb_buffer_s hb_buffer_t;
31 struct hb_buffer_s
32 {
33     int           size;
34     int           alloc;
35     uint8_t *     data;
36     int           cur;
37
38     int           id;
39     int64_t       start;
40     int64_t       stop;
41     int           key;
42
43     int           x;
44     int           y;
45     int           width;
46     int           height;
47
48     hb_buffer_t * sub;
49
50     hb_buffer_t * next;
51 };
52
53 hb_buffer_t * hb_buffer_init( int size );
54 void          hb_buffer_realloc( hb_buffer_t *, int size );
55 void          hb_buffer_close( hb_buffer_t ** );
56
57 typedef struct hb_fifo_s hb_fifo_t;
58
59 hb_fifo_t   * hb_fifo_init();
60 int           hb_fifo_size( hb_fifo_t * );
61 int           hb_fifo_is_full( hb_fifo_t * );
62 hb_buffer_t * hb_fifo_get( hb_fifo_t * );
63 hb_buffer_t * hb_fifo_see( hb_fifo_t * );
64 hb_buffer_t * hb_fifo_see2( hb_fifo_t * );
65 void          hb_fifo_push( hb_fifo_t *, hb_buffer_t * );
66 void          hb_fifo_close( hb_fifo_t ** );
67
68 /***********************************************************************
69  * Threads: update.c, scan.c, work.c, reader.c, muxcommon.c
70  **********************************************************************/
71 hb_thread_t * hb_update_init( int * build, char * version );
72 hb_thread_t * hb_scan_init( hb_handle_t *, const char * path,
73                             int title_index, hb_list_t * list_title );
74 hb_thread_t * hb_work_init( hb_list_t * jobs, int cpu_count,
75                             volatile int * die, int * error );
76 hb_thread_t  * hb_reader_init( hb_job_t * );
77 hb_thread_t  * hb_muxer_init( hb_job_t * );
78
79 /***********************************************************************
80  * libmpeg2 wrapper
81  ***********************************************************************
82  * It is exported here because it is used at several places
83  **********************************************************************/
84 typedef struct   hb_libmpeg2_s hb_libmpeg2_t;
85
86 hb_libmpeg2_t  * hb_libmpeg2_init();
87 int              hb_libmpeg2_decode( hb_libmpeg2_t *,
88                                       hb_buffer_t * es_buf,
89                                       hb_list_t * raw_list );
90 void             hb_libmpeg2_info( hb_libmpeg2_t * m, int * width,
91                                     int * height, int * rate );
92 void             hb_libmpeg2_close( hb_libmpeg2_t ** );
93
94 /***********************************************************************
95  * mpegdemux.c
96  **********************************************************************/
97 int hb_demux_ps( hb_buffer_t * ps_buf, hb_list_t * es_list );
98
99 /***********************************************************************
100  * dvd.c
101  **********************************************************************/
102 typedef struct hb_dvd_s hb_dvd_t;
103
104 hb_dvd_t *   hb_dvd_init( char * path );
105 int          hb_dvd_title_count( hb_dvd_t * );
106 hb_title_t * hb_dvd_title_scan( hb_dvd_t *, int title );
107 int          hb_dvd_start( hb_dvd_t *, int title, int chapter );
108 void         hb_dvd_stop( hb_dvd_t * );
109 int          hb_dvd_seek( hb_dvd_t *, float );
110 int          hb_dvd_read( hb_dvd_t *, hb_buffer_t * );
111 int          hb_dvd_chapter( hb_dvd_t * );
112 void         hb_dvd_close( hb_dvd_t ** );
113
114 /***********************************************************************
115  * Work objects
116  **********************************************************************/
117 #define HB_CONFIG_MAX_SIZE 8192
118 typedef union hb_esconfig_u
119 {
120     struct
121     {
122         uint8_t bytes[HB_CONFIG_MAX_SIZE];
123         int     length;
124     } mpeg4;
125
126     struct
127     {
128         uint8_t sps[HB_CONFIG_MAX_SIZE];
129         int     sps_length;
130         uint8_t pps[HB_CONFIG_MAX_SIZE];
131         int     pps_length;
132     } h264;
133
134     struct
135     {
136         uint8_t bytes[HB_CONFIG_MAX_SIZE];
137         int     length;
138     } aac;
139
140     struct
141     {
142         uint8_t headers[3][HB_CONFIG_MAX_SIZE];
143     } vorbis;
144 } hb_esconfig_t;
145
146 typedef struct hb_work_private_s hb_work_private_t;
147 typedef struct hb_work_object_s  hb_work_object_t;
148 struct hb_work_object_s
149 {
150     int                 id;
151     char              * name;
152
153     int              (* init)  ( hb_work_object_t *, hb_job_t * );
154     int              (* work)  ( hb_work_object_t *, hb_buffer_t **,
155                                  hb_buffer_t ** );
156     void             (* close) ( hb_work_object_t * );
157
158     hb_fifo_t         * fifo_in;
159     hb_fifo_t         * fifo_out;
160     hb_esconfig_t     * config;
161
162     hb_work_private_t * private_data;
163
164     hb_lock_t         * lock;
165     int                 used;
166     uint64_t            time;
167 };
168
169 enum
170 {
171     WORK_SYNC = 1,
172     WORK_DECMPEG2,
173     WORK_DECSUB,
174     WORK_RENDER,
175     WORK_ENCAVCODEC,
176     WORK_ENCXVID,
177     WORK_ENCX264,
178     WORK_DECA52,
179     WORK_DECAVCODEC,
180     WORK_DECLPCM,
181     WORK_ENCFAAC,
182     WORK_ENCLAME,
183     WORK_ENCVORBIS
184 };
185
186 extern hb_work_object_t hb_sync;
187 extern hb_work_object_t hb_decmpeg2;
188 extern hb_work_object_t hb_decsub;
189 extern hb_work_object_t hb_render;
190 extern hb_work_object_t hb_encavcodec;
191 extern hb_work_object_t hb_encxvid;
192 extern hb_work_object_t hb_encx264;
193 extern hb_work_object_t hb_deca52;
194 extern hb_work_object_t hb_decavcodec;
195 extern hb_work_object_t hb_declpcm;
196 extern hb_work_object_t hb_encfaac;
197 extern hb_work_object_t hb_enclame;
198 extern hb_work_object_t hb_encvorbis;
199
200 #define HB_WORK_IDLE     0
201 #define HB_WORK_OK       1
202 #define HB_WORK_ERROR    2
203 #define HB_WORK_DONE     3
204
205 /***********************************************************************
206  * Muxers
207  **********************************************************************/
208 typedef struct hb_mux_object_s hb_mux_object_t;
209 typedef struct hb_mux_data_s   hb_mux_data_t;
210
211 #define HB_MUX_COMMON \
212     int (*init)      ( hb_mux_object_t * ); \
213     int (*mux)       ( hb_mux_object_t *, hb_mux_data_t *, \
214                        hb_buffer_t * ); \
215     int (*end)       ( hb_mux_object_t * );
216
217 #define DECLARE_MUX( a ) \
218     hb_mux_object_t  * hb_mux_##a##_init( hb_job_t * );
219
220 DECLARE_MUX( mp4 );
221 DECLARE_MUX( avi );
222 DECLARE_MUX( ogm );
223