1 /* $Id: common.h,v 1.51 2005/11/04 13:09:40 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. */
16 #include <sys/types.h>
21 #define MIN( a, b ) ( (a) > (b) ? (b) : (a) )
24 #define MAX( a, b ) ( (a) > (b) ? (a) : (b) )
27 #define EVEN( a ) ( (a) + ( (a) & 1 ) )
28 #define MULTIPLE_16( a ) ( 16 * ( ( (a) + 8 ) / 16 ) )
30 typedef struct hb_handle_s hb_handle_t;
31 typedef struct hb_list_s hb_list_t;
32 typedef struct hb_rate_s hb_rate_t;
33 typedef struct hb_job_s hb_job_t;
34 typedef struct hb_title_s hb_title_t;
35 typedef struct hb_chapter_s hb_chapter_t;
36 typedef struct hb_audio_s hb_audio_t;
37 typedef struct hb_subtitle_s hb_subtitle_t;
38 typedef struct hb_state_s hb_state_t;
39 typedef union hb_esconfig_u hb_esconfig_t;
40 typedef struct hb_work_private_s hb_work_private_t;
41 typedef struct hb_work_object_s hb_work_object_t;
42 typedef struct hb_buffer_s hb_buffer_t;
43 typedef struct hb_fifo_s hb_fifo_t;
44 typedef struct hb_lock_s hb_lock_t;
51 hb_list_t * hb_list_init();
52 int hb_list_count( hb_list_t * );
53 void hb_list_add( hb_list_t *, void * );
54 void hb_list_rem( hb_list_t *, void * );
55 void * hb_list_item( hb_list_t *, int );
56 void hb_list_close( hb_list_t ** );
58 #define HB_KEEP_WIDTH 0
59 #define HB_KEEP_HEIGHT 1
60 void hb_fix_aspect( hb_job_t * job, int keep );
62 int hb_calc_bitrate( hb_job_t *, int size );
70 #define HB_ASPECT_BASE 9
71 #define HB_VIDEO_RATE_BASE 27000000
73 extern hb_rate_t hb_video_rates[];
74 extern int hb_video_rates_count;
75 extern hb_rate_t hb_audio_rates[];
76 extern int hb_audio_rates_count;
77 extern int hb_audio_rates_default;
78 extern hb_rate_t hb_audio_bitrates[];
79 extern int hb_audio_bitrates_count;
80 extern int hb_audio_bitrates_default;
82 /******************************************************************************
83 * hb_job_t: settings to be filled by the UI
84 *****************************************************************************/
87 /* Pointer to the title to be ripped */
90 /* Chapter selection */
95 crop: must be multiples of 2 (top/bottom/left/right)
97 width: must be a multiple of 16
98 height: must be a multiple of 16
99 keep_ratio: used by UIs */
109 vquality: output quality (0.0..1.0)
110 if < 0.0 or > 1.0, bitrate is used instead
111 vbitrate: output bitrate (kbps)
113 vrate, vrate_base: output framerate is vrate / vrate_base */
114 #define HB_VCODEC_MASK 0x0000FF
115 #define HB_VCODEC_FFMPEG 0x000001
116 #define HB_VCODEC_XVID 0x000002
117 #define HB_VCODEC_X264 0x000004
127 Indexes in hb_title_t's audios list, starting from 0.
128 -1 indicates the end of the list */
133 abitrate: output bitrate (kbps)
134 arate: output samplerate (Hz)
135 HB_ACODEC_AC3 means pass-through, then abitrate and arate are
137 #define HB_ACODEC_MASK 0x00FF00
138 #define HB_ACODEC_FAAC 0x000100
139 #define HB_ACODEC_LAME 0x000200
140 #define HB_ACODEC_VORBIS 0x000400
141 #define HB_ACODEC_AC3 0x000800
142 #define HB_ACODEC_MPGA 0x001000
143 #define HB_ACODEC_LPCM 0x002000
148 /* Subtitle settings:
149 subtitle: index in hb_title_t's subtitles list, starting
150 from 0. -1 means no subtitle */
154 mux: output file format
156 #define HB_MUX_MASK 0xFF0000
157 #define HB_MUX_MP4 0x010000
158 #define HB_MUX_AVI 0x020000
159 #define HB_MUX_OGM 0x040000
170 hb_fifo_t * fifo_mpeg2; /* MPEG-2 video ES */
171 hb_fifo_t * fifo_raw; /* Raw pictures */
172 hb_fifo_t * fifo_sync; /* Raw pictures, framerate corrected */
173 hb_fifo_t * fifo_render; /* Raw pictures, scaled */
174 hb_fifo_t * fifo_mpeg4; /* MPEG-4 video ES */
176 hb_thread_t * reader;
179 hb_list_t * list_work;
181 hb_esconfig_t config;
183 hb_mux_data_t * mux_data;
198 hb_fifo_t * fifo_in; /* AC3/MPEG/LPCM ES */
199 hb_fifo_t * fifo_raw; /* Raw audio */
200 hb_fifo_t * fifo_sync; /* Resampled, synced raw audio */
201 hb_fifo_t * fifo_out; /* MP3/AAC/Vorbis ES */
203 hb_esconfig_t config;
204 hb_mux_data_t * mux_data;
217 /* Visual-friendly duration */
222 /* Exact duration (in 1/90000s) */
233 hb_fifo_t * fifo_in; /* SPU ES */
234 hb_fifo_t * fifo_raw; /* Decodec SPU */
250 /* Visual-friendly duration */
255 /* Exact duration (in 1/90000s) */
265 uint32_t palette[16];
267 hb_list_t * list_chapter;
268 hb_list_t * list_audio;
269 hb_list_t * list_subtitle;
271 /* Job template for this title */
278 #define HB_STATE_IDLE 1
279 #define HB_STATE_SCANNING 2
280 #define HB_STATE_SCANDONE 4
281 #define HB_STATE_WORKING 8
282 #define HB_STATE_PAUSED 16
283 #define HB_STATE_WORKDONE 32
290 /* HB_STATE_SCANNING */
297 /* HB_STATE_WORKING */
310 /* HB_STATE_WORKDONE */
311 #define HB_ERROR_NONE 0
312 #define HB_ERROR_CANCELED 1
313 #define HB_ERROR_UNKNOWN 2
320 struct hb_work_object_s
326 int (* init) ( hb_work_object_t *, hb_job_t * );
327 int (* work) ( hb_work_object_t *, hb_buffer_t **,
329 void (* close) ( hb_work_object_t * );
332 hb_fifo_t * fifo_out;
333 hb_esconfig_t * config;
335 hb_work_private_t * private_data;
337 hb_thread_t * thread;
340 hb_work_object_t * next;
344 extern hb_work_object_t hb_sync;
345 extern hb_work_object_t hb_decmpeg2;
346 extern hb_work_object_t hb_decsub;
347 extern hb_work_object_t hb_render;
348 extern hb_work_object_t hb_encavcodec;
349 extern hb_work_object_t hb_encxvid;
350 extern hb_work_object_t hb_encx264;
351 extern hb_work_object_t hb_deca52;
352 extern hb_work_object_t hb_decavcodec;
353 extern hb_work_object_t hb_declpcm;
354 extern hb_work_object_t hb_encfaac;
355 extern hb_work_object_t hb_enclame;
356 extern hb_work_object_t hb_encvorbis;