Use weightb=0 for turbo 1st pass x264 options. This prevents frame count discrepancie...
[HandBrake.git] / libhb / internal.h
blobe4d5bee49c403bd036392217ffc4b2728f4be684
1 /* $Id: internal.h,v 1.41 2005/11/25 15:05:25 titer Exp $
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. */
7 /***********************************************************************
8 * common.c
9 **********************************************************************/
10 void hb_log( char * log, ... );
11 void hb_error( char * fmt, ...);
13 int hb_list_bytes( hb_list_t * );
14 void hb_list_seebytes( hb_list_t * l, uint8_t * dst, int size );
15 void hb_list_getbytes( hb_list_t * l, uint8_t * dst, int size,
16 uint64_t * pts, uint64_t * pos );
17 void hb_list_empty( hb_list_t ** );
19 hb_title_t * hb_title_init( char * dvd, int index );
20 void hb_title_close( hb_title_t ** );
22 /***********************************************************************
23 * hb.c
24 **********************************************************************/
25 int hb_get_pid( hb_handle_t * );
26 void hb_set_state( hb_handle_t *, hb_state_t * );
28 /***********************************************************************
29 * fifo.c
30 **********************************************************************/
31 struct hb_buffer_s
33 int size;
34 int alloc;
35 uint8_t * data;
36 int cur;
38 int64_t sequence;
40 int id;
41 int64_t start;
42 int64_t stop;
43 int new_chap;
45 #define HB_FRAME_IDR 0x01
46 #define HB_FRAME_I 0x02
47 #define HB_FRAME_AUDIO 0x04
48 #define HB_FRAME_P 0x10
49 #define HB_FRAME_B 0x20
50 #define HB_FRAME_BREF 0x40
51 #define HB_FRAME_KEY 0x0F
52 #define HB_FRAME_REF 0xF0
53 uint8_t frametype;
54 uint16_t flags;
56 /* Holds the output PTS from x264, for use by b-frame offsets in muxmp4.c */
57 int64_t renderOffset;
59 int x;
60 int y;
61 int width;
62 int height;
64 hb_buffer_t * sub;
66 hb_buffer_t * next;
69 void hb_buffer_pool_init( void );
70 void hb_buffer_pool_free( void );
72 hb_buffer_t * hb_buffer_init( int size );
73 void hb_buffer_realloc( hb_buffer_t *, int size );
74 void hb_buffer_close( hb_buffer_t ** );
75 void hb_buffer_copy_settings( hb_buffer_t * dst,
76 const hb_buffer_t * src );
78 hb_fifo_t * hb_fifo_init();
79 int hb_fifo_size( hb_fifo_t * );
80 int hb_fifo_is_full( hb_fifo_t * );
81 float hb_fifo_percent_full( hb_fifo_t * f );
82 hb_buffer_t * hb_fifo_get( hb_fifo_t * );
83 hb_buffer_t * hb_fifo_see( hb_fifo_t * );
84 hb_buffer_t * hb_fifo_see2( hb_fifo_t * );
85 void hb_fifo_push( hb_fifo_t *, hb_buffer_t * );
86 void hb_fifo_close( hb_fifo_t ** );
88 /***********************************************************************
89 * Threads: update.c, scan.c, work.c, reader.c, muxcommon.c
90 **********************************************************************/
91 hb_thread_t * hb_update_init( int * build, char * version );
92 hb_thread_t * hb_scan_init( hb_handle_t *, const char * path,
93 int title_index, hb_list_t * list_title );
94 hb_thread_t * hb_work_init( hb_list_t * jobs, int cpu_count,
95 volatile int * die, int * error, hb_job_t ** job );
96 hb_thread_t * hb_reader_init( hb_job_t * );
97 hb_thread_t * hb_muxer_init( hb_job_t * );
99 /***********************************************************************
100 * libmpeg2 wrapper
101 ***********************************************************************
102 * It is exported here because it is used at several places
103 **********************************************************************/
104 typedef struct hb_libmpeg2_s hb_libmpeg2_t;
106 hb_libmpeg2_t * hb_libmpeg2_init();
107 int hb_libmpeg2_decode( hb_libmpeg2_t *,
108 hb_buffer_t * es_buf,
109 hb_list_t * raw_list );
110 void hb_libmpeg2_info( hb_libmpeg2_t * m, int * width,
111 int * height, int * rate, int * aspect_ratio );
112 void hb_libmpeg2_close( hb_libmpeg2_t ** );
114 /***********************************************************************
115 * mpegdemux.c
116 **********************************************************************/
117 int hb_demux_ps( hb_buffer_t * ps_buf, hb_list_t * es_list );
119 /***********************************************************************
120 * dvd.c
121 **********************************************************************/
122 typedef struct hb_dvd_s hb_dvd_t;
123 typedef struct hb_stream_s hb_stream_t;
125 hb_dvd_t * hb_dvd_init( char * path );
126 int hb_dvd_title_count( hb_dvd_t * );
127 hb_title_t * hb_dvd_title_scan( hb_dvd_t *, int title );
128 int hb_dvd_start( hb_dvd_t *, int title, int chapter );
129 void hb_dvd_stop( hb_dvd_t * );
130 int hb_dvd_seek( hb_dvd_t *, float );
131 int hb_dvd_read( hb_dvd_t *, hb_buffer_t * );
132 int hb_dvd_chapter( hb_dvd_t * );
133 int hb_dvd_is_break( hb_dvd_t * d );
134 void hb_dvd_close( hb_dvd_t ** );
136 hb_stream_t * hb_stream_open( char * path );
137 void hb_stream_close( hb_stream_t ** );
138 hb_title_t * hb_stream_title_scan( hb_stream_t *);
139 int hb_stream_read( hb_stream_t *, hb_buffer_t *);
140 int hb_stream_seek( hb_stream_t *, float );
141 void hb_stream_update_audio( hb_stream_t *, hb_audio_t *);
143 /***********************************************************************
144 * Work objects
145 **********************************************************************/
146 #define HB_CONFIG_MAX_SIZE 8192
147 union hb_esconfig_u
150 struct
152 uint8_t bytes[HB_CONFIG_MAX_SIZE];
153 int length;
154 } mpeg4;
156 struct
158 uint8_t sps[HB_CONFIG_MAX_SIZE];
159 int sps_length;
160 uint8_t pps[HB_CONFIG_MAX_SIZE];
161 int pps_length;
162 } h264;
164 struct
166 uint8_t bytes[HB_CONFIG_MAX_SIZE];
167 int length;
168 } aac;
170 struct
172 uint8_t headers[3][HB_CONFIG_MAX_SIZE];
173 char *language;
174 } vorbis;
176 struct
178 /* ac3flags stores the flags from the AC3 source, as found in scan.c */
179 int ac3flags;
180 } a52;
182 struct
184 /* dcaflags stores the flags from the DCA source, as found in scan.c */
185 int dcaflags;
186 } dca;
190 enum
192 WORK_SYNC = 1,
193 WORK_DECMPEG2,
194 WORK_DECSUB,
195 WORK_RENDER,
196 WORK_ENCAVCODEC,
197 WORK_ENCXVID,
198 WORK_ENCX264,
199 WORK_DECA52,
200 WORK_DECDCA,
201 WORK_DECAVCODEC,
202 WORK_DECLPCM,
203 WORK_ENCFAAC,
204 WORK_ENCLAME,
205 WORK_ENCVORBIS
208 enum
210 FILTER_DEINTERLACE = 1,
211 FILTER_DEBLOCK,
212 FILTER_DENOISE,
213 FILTER_DETELECINE
216 extern hb_work_object_t * hb_objects;
218 #define HB_WORK_IDLE 0
219 #define HB_WORK_OK 1
220 #define HB_WORK_ERROR 2
221 #define HB_WORK_DONE 3
223 /***********************************************************************
224 * Muxers
225 **********************************************************************/
226 typedef struct hb_mux_object_s hb_mux_object_t;
227 typedef struct hb_mux_data_s hb_mux_data_t;
229 #define HB_MUX_COMMON \
230 int (*init) ( hb_mux_object_t * ); \
231 int (*mux) ( hb_mux_object_t *, hb_mux_data_t *, \
232 hb_buffer_t * ); \
233 int (*end) ( hb_mux_object_t * );
235 #define DECLARE_MUX( a ) \
236 hb_mux_object_t * hb_mux_##a##_init( hb_job_t * );
238 DECLARE_MUX( mp4 );
239 DECLARE_MUX( avi );
240 DECLARE_MUX( ogm );
241 DECLARE_MUX( mkv );