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;
45 hb_list_t * hb_list_init();
46 int hb_list_count( hb_list_t * );
47 void hb_list_add( hb_list_t *, void * );
48 void hb_list_rem( hb_list_t *, void * );
49 void * hb_list_item( hb_list_t *, int );
50 void hb_list_close( hb_list_t ** );
52 #define HB_KEEP_WIDTH 0
53 #define HB_KEEP_HEIGHT 1
54 void hb_fix_aspect( hb_job_t * job, int keep );
56 int hb_calc_bitrate( hb_job_t *, int size );
64 #define HB_ASPECT_BASE 9
65 #define HB_VIDEO_RATE_BASE 27000000
67 extern hb_rate_t hb_video_rates[];
68 extern int hb_video_rates_count;
69 extern hb_rate_t hb_audio_rates[];
70 extern int hb_audio_rates_count;
71 extern int hb_audio_rates_default;
72 extern hb_rate_t hb_audio_bitrates[];
73 extern int hb_audio_bitrates_count;
74 extern int hb_audio_bitrates_default;
76 /******************************************************************************
77 * hb_job_t: settings to be filled by the UI
78 *****************************************************************************/
81 /* Pointer to the title to be ripped */
84 /* Chapter selection */
89 crop: must be multiples of 2 (top/bottom/left/right)
91 width: must be a multiple of 16
92 height: must be a multiple of 16
93 keep_ratio: used by UIs */
103 vquality: output quality (0.0..1.0)
104 if < 0.0 or > 1.0, bitrate is used instead
105 vbitrate: output bitrate (kbps)
107 vrate, vrate_base: output framerate is vrate / vrate_base */
108 #define HB_VCODEC_MASK 0x0000FF
109 #define HB_VCODEC_FFMPEG 0x000001
110 #define HB_VCODEC_XVID 0x000002
111 #define HB_VCODEC_X264 0x000004
121 Indexes in hb_title_t's audios list, starting from 0.
122 -1 indicates the end of the list */
127 abitrate: output bitrate (kbps)
128 arate: output samplerate (Hz)
129 HB_ACODEC_AC3 means pass-through, then abitrate and arate are
131 #define HB_ACODEC_MASK 0x00FF00
132 #define HB_ACODEC_FAAC 0x000100
133 #define HB_ACODEC_LAME 0x000200
134 #define HB_ACODEC_VORBIS 0x000400
135 #define HB_ACODEC_AC3 0x000800
136 #define HB_ACODEC_MPGA 0x001000
137 #define HB_ACODEC_LPCM 0x002000
142 /* Subtitle settings:
143 subtitle: index in hb_title_t's subtitles list, starting
144 from 0. -1 means no subtitle */
148 mux: output file format
150 #define HB_MUX_MASK 0xFF0000
151 #define HB_MUX_MP4 0x010000
152 #define HB_MUX_AVI 0x020000
153 #define HB_MUX_OGM 0x040000
164 hb_fifo_t * fifo_mpeg2; /* MPEG-2 video ES */
165 hb_fifo_t * fifo_raw; /* Raw pictures */
166 hb_fifo_t * fifo_sync; /* Raw pictures, framerate corrected */
167 hb_fifo_t * fifo_render; /* Raw pictures, scaled */
168 hb_fifo_t * fifo_mpeg4; /* MPEG-4 video ES */
170 hb_thread_t * reader;
173 hb_list_t * list_work;
195 int es_config_length;
197 hb_mux_data_t * mux_data;
212 hb_fifo_t * fifo_in; /* AC3/MPEG/LPCM ES */
213 hb_fifo_t * fifo_raw; /* Raw audio */
214 hb_fifo_t * fifo_sync; /* Resampled, synced raw audio */
215 hb_fifo_t * fifo_out; /* MP3/AAC/Vorbis ES */
227 uint8_t * headers[3];
233 hb_mux_data_t * mux_data;
246 /* Visual-friendly duration */
251 /* Exact duration (in 1/90000s) */
262 hb_fifo_t * fifo_in; /* SPU ES */
263 hb_fifo_t * fifo_raw; /* Decodec SPU */
279 /* Visual-friendly duration */
284 /* Exact duration (in 1/90000s) */
294 uint32_t palette[16];
296 hb_list_t * list_chapter;
297 hb_list_t * list_audio;
298 hb_list_t * list_subtitle;
300 /* Job template for this title */
307 #define HB_STATE_IDLE 1
308 #define HB_STATE_SCANNING 2
309 #define HB_STATE_SCANDONE 4
310 #define HB_STATE_WORKING 8
311 #define HB_STATE_PAUSED 16
312 #define HB_STATE_WORKDONE 32
319 /* HB_STATE_SCANNING */
326 /* HB_STATE_WORKING */
339 /* HB_STATE_WORKDONE */
340 #define HB_ERROR_NONE 0
341 #define HB_ERROR_CANCELED 1
342 #define HB_ERROR_UNKNOWN 2