OSDN Git Service

baba5627b9215ae181b21e0d9ac277096d2b5504
[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, uint64_t * 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 struct hb_buffer_s
31 {
32     int           size;
33     int           alloc;
34     uint8_t *     data;
35     int           cur;
36
37     int           id;
38     int64_t       start;
39     int64_t       stop;
40     int           key;
41
42     int           x;
43     int           y;
44     int           width;
45     int           height;
46
47     hb_buffer_t * sub;
48
49     hb_buffer_t * next;
50 };
51
52 hb_buffer_t * hb_buffer_init( int size );
53 void          hb_buffer_realloc( hb_buffer_t *, int size );
54 void          hb_buffer_close( hb_buffer_t ** );
55
56
57 hb_fifo_t   * hb_fifo_init();
58 int           hb_fifo_size( hb_fifo_t * );
59 int           hb_fifo_is_full( hb_fifo_t * );
60 float         hb_fifo_percent_full( hb_fifo_t * f );
61 hb_buffer_t * hb_fifo_get( hb_fifo_t * );
62 hb_buffer_t * hb_fifo_see( hb_fifo_t * );
63 hb_buffer_t * hb_fifo_see2( hb_fifo_t * );
64 void          hb_fifo_push( hb_fifo_t *, hb_buffer_t * );
65 void          hb_fifo_close( hb_fifo_t ** );
66
67 /***********************************************************************
68  * Threads: update.c, scan.c, work.c, reader.c, muxcommon.c
69  **********************************************************************/
70 hb_thread_t * hb_update_init( int * build, char * version );
71 hb_thread_t * hb_scan_init( hb_handle_t *, const char * path,
72                             int title_index, hb_list_t * list_title );
73 hb_thread_t * hb_work_init( hb_list_t * jobs, int cpu_count,
74                             volatile int * die, int * error );
75 hb_thread_t  * hb_reader_init( hb_job_t * );
76 hb_thread_t  * hb_muxer_init( hb_job_t * );
77
78 /***********************************************************************
79  * libmpeg2 wrapper
80  ***********************************************************************
81  * It is exported here because it is used at several places
82  **********************************************************************/
83 typedef struct   hb_libmpeg2_s hb_libmpeg2_t;
84
85 hb_libmpeg2_t  * hb_libmpeg2_init();
86 int              hb_libmpeg2_decode( hb_libmpeg2_t *,
87                                       hb_buffer_t * es_buf,
88                                       hb_list_t * raw_list );
89 void             hb_libmpeg2_info( hb_libmpeg2_t * m, int * width,
90                                     int * height, int * rate );
91 void             hb_libmpeg2_close( hb_libmpeg2_t ** );
92
93 /***********************************************************************
94  * mpegdemux.c
95  **********************************************************************/
96 int hb_demux_ps( hb_buffer_t * ps_buf, hb_list_t * es_list );
97
98 /***********************************************************************
99  * dvd.c
100  **********************************************************************/
101 typedef struct hb_dvd_s hb_dvd_t;
102
103 hb_dvd_t *   hb_dvd_init( char * path );
104 int          hb_dvd_title_count( hb_dvd_t * );
105 hb_title_t * hb_dvd_title_scan( hb_dvd_t *, int title );
106 int          hb_dvd_start( hb_dvd_t *, int title, int chapter );
107 void         hb_dvd_stop( hb_dvd_t * );
108 int          hb_dvd_seek( hb_dvd_t *, float );
109 int          hb_dvd_read( hb_dvd_t *, hb_buffer_t * );
110 int          hb_dvd_chapter( hb_dvd_t * );
111 void         hb_dvd_close( hb_dvd_t ** );
112
113 /***********************************************************************
114  * Work objects
115  **********************************************************************/
116 #define HB_CONFIG_MAX_SIZE 8192
117 union hb_esconfig_u
118 {
119     struct
120     {
121         uint8_t bytes[HB_CONFIG_MAX_SIZE];
122         int     length;
123     } mpeg4;
124
125         struct
126         {
127             uint8_t  sps[HB_CONFIG_MAX_SIZE];
128             int       sps_length;
129             uint8_t  pps[HB_CONFIG_MAX_SIZE];
130             int       pps_length;
131         } h264;
132
133     struct
134     {
135         uint8_t bytes[HB_CONFIG_MAX_SIZE];
136         int     length;
137         /* Total channels actually used for this audio track */
138         int channelsused;
139     } aac;
140
141     struct
142     {
143         uint8_t headers[3][HB_CONFIG_MAX_SIZE];
144     } vorbis;
145     
146     struct
147     {
148         /* indicates the number of normal channels the source audio has */
149         int  channels;
150         /* indicates the number of lfe channels the source audio has */
151         int  lfechannels;
152         /* ac3flags:       stores the flags from the AC3 source, as found in scan.c */
153         int  ac3flags;
154         /* Total channels actually used for this audio track */
155         int channelsused;
156     } a52;
157 };
158
159 enum
160 {
161     WORK_SYNC = 1,
162     WORK_DECMPEG2,
163     WORK_DECSUB,
164     WORK_RENDER,
165     WORK_ENCAVCODEC,
166     WORK_ENCXVID,
167     WORK_ENCX264,
168     WORK_DECA52,
169     WORK_DECAVCODEC,
170     WORK_DECLPCM,
171     WORK_ENCFAAC,
172     WORK_ENCLAME,
173     WORK_ENCVORBIS
174 };
175
176 extern hb_work_object_t * hb_objects;
177
178 #define HB_WORK_IDLE     0
179 #define HB_WORK_OK       1
180 #define HB_WORK_ERROR    2
181 #define HB_WORK_DONE     3
182
183 /***********************************************************************
184  * Muxers
185  **********************************************************************/
186 typedef struct hb_mux_object_s hb_mux_object_t;
187 typedef struct hb_mux_data_s   hb_mux_data_t;
188
189 #define HB_MUX_COMMON \
190     int (*init)      ( hb_mux_object_t * ); \
191     int (*mux)       ( hb_mux_object_t *, hb_mux_data_t *, \
192                        hb_buffer_t * ); \
193     int (*end)       ( hb_mux_object_t * );
194
195 #define DECLARE_MUX( a ) \
196     hb_mux_object_t  * hb_mux_##a##_init( hb_job_t * );
197
198 DECLARE_MUX( mp4 );
199 DECLARE_MUX( avi );
200 DECLARE_MUX( ogm );
201