OSDN Git Service

HandBrake 0.6.0-test3
[handbrake-jp/handbrake-jp-git.git] / core / Utils.h
1 /* $Id: Utils.h,v 1.23 2004/03/08 11:32:48 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 #ifndef HB_UTILS_H
8 #define HB_UTILS_H
9
10 /* Standard headers */
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <string.h>
14 #include <unistd.h>
15 #include <inttypes.h>
16 typedef uint8_t byte_t;
17 #ifdef HB_BEOS
18 #  include <OS.h>
19 #endif
20
21 /* Handy macros */
22 #ifndef MIN
23 #define MIN( a, b ) ( ( (a) > (b) ) ? (b) : (a) )
24 #endif
25 #ifndef MAX
26 #define MAX( a, b ) ( ( (a) > (b) ) ? (a) : (b) )
27 #endif
28 #ifndef EVEN
29 #define EVEN( a ) ( ( (a) & 0x1 ) ? ( (a) + 1 ) : (a) )
30 #endif
31 #ifndef MULTIPLE_16
32 #define MULTIPLE_16( a ) ( 16 * ( ( (a) + 8 ) / 16 ) )
33 #endif
34 #ifndef VOUT_ASPECT_FACTOR
35 #define VOUT_ASPECT_FACTOR 432000
36 #endif
37
38 typedef struct HBHandle     HBHandle;
39
40 /* Utils */
41 typedef struct HBAudio      HBAudio;
42 typedef struct HBBuffer     HBBuffer;
43 typedef struct HBCond       HBCond;
44 typedef struct HBFifo       HBFifo;
45 typedef struct HBList       HBList;
46 typedef struct HBLock       HBLock;
47 typedef struct HBTitle      HBTitle;
48 typedef struct HBThread     HBThread;
49
50 /* (De)Muxers */
51 typedef struct HBAviMux     HBAviMux;
52 typedef struct HBOgmMux     HBOgmMux;
53 typedef struct HBDVDRead    HBDVDRead;
54 typedef struct HBMp4Mux     HBMp4Mux;
55 typedef struct HBScan       HBScan;
56
57 typedef struct HBWork       HBWork;
58 typedef struct HBWorkThread HBWorkThread;
59
60 /* AVI stuff */
61 typedef struct HBAviMainHeader   HBAviMainHeader;
62 typedef struct HBAviStreamHeader HBAviStreamHeader;
63 typedef struct HBBitmapInfo      HBBitmapInfo;
64 typedef struct HBWaveFormatEx    HBWaveFormatEx;
65
66 /* Misc functions which may be used from anywhere */
67 void     HBSnooze( int time );
68 void     HBLog( char * log, ... );
69 uint64_t HBGetDate();
70 int      HBPStoES( HBBuffer ** psBuffer, HBList * esBufferList );
71
72 /* HBList functions */
73 HBList * HBListInit();
74 int      HBListCount( HBList * );
75 void     HBListAdd( HBList *, void * item );
76 void     HBListRemove( HBList *, void * item );
77 void   * HBListItemAt( HBList *, int index );
78 void     HBListClose( HBList ** );
79
80 /* HBTitle function */
81 HBTitle * HBTitleInit();
82 void      HBTitleClose( HBTitle ** );
83
84 /* HBAudio functions */
85 HBAudio * HBAudioInit( int id, char * language );
86 void      HBAudioClose( HBAudio ** );
87
88 #define HB_SUCCESS          0x00
89 #define HB_CANCELED         0x01
90 #define HB_ERROR_A52_SYNC   0x02
91 #define HB_ERROR_AVI_WRITE  0x04
92 #define HB_ERROR_DVD_OPEN   0x08
93 #define HB_ERROR_DVD_READ   0x10
94 #define HB_ERROR_MP3_INIT   0x20
95 #define HB_ERROR_MP3_ENCODE 0x40
96 #define HB_ERROR_MPEG4_INIT 0x80
97
98 /* Possible codecs */
99 #define HB_CODEC_MPEG2  0x00
100 #define HB_CODEC_FFMPEG 0x01
101 #define HB_CODEC_XVID   0x02
102 #define HB_CODEC_AC3    0x04
103 #define HB_CODEC_LPCM   0x08
104 #define HB_CODEC_MP3    0x10
105 #define HB_CODEC_AAC    0x20
106 #define HB_CODEC_X264   0x40
107 #define HB_CODEC_VORBIS 0x80
108
109 /* Possible muxers */
110 #define HB_MUX_AVI 0x00
111 #define HB_MUX_MP4 0x01
112 #define HB_MUX_OGM 0x02
113
114 struct HBTitle
115 {
116     /* DVD info */
117     char * device;
118     int    index;
119     int    length;
120
121     /* Audio infos */
122     HBList * audioList;
123     HBList * ripAudioList;
124
125     /* See DVDRead.c */
126     int64_t start;
127
128     /* Video input */
129     int inWidth;
130     int inHeight;
131     int aspect;
132     int rate;
133     int rateBase;
134
135     /* Video output */
136     int outWidth;
137     int outHeight;
138     int outWidthMax;
139     int outHeightMax;
140     int topCrop;
141     int bottomCrop;
142     int leftCrop;
143     int rightCrop;
144     int deinterlace;
145     int autoTopCrop;
146     int autoBottomCrop;
147     int autoLeftCrop;
148     int autoRightCrop;
149
150     /* Encoder settings */
151     int codec;
152     int bitrate;
153     int twoPass;
154
155     /* Muxer settings */
156     char * file;
157     int    mux;
158
159     /* MP4 muxer specific */
160     int       track;
161     uint8_t * esConfig;
162     int       esConfigLength;
163
164     /* AVI muxer specific */
165     HBAviMainHeader   * aviMainHeader;
166     HBAviStreamHeader * aviVideoHeader;
167     HBBitmapInfo      * aviVideoFormat;
168
169     /* Fifos */
170     HBFifo  * inFifo;
171     HBFifo  * rawFifo;
172     HBFifo  * scaledFifo;
173     HBFifo  * outFifo;
174
175     /* Threads */
176     HBDVDRead    * dvdRead;
177     HBAviMux     * aviMux;
178     HBMp4Mux     * mp4Mux;
179     HBOgmMux     * ogmMux;
180     HBWorkThread * workThreads[8];
181
182     /* Work objects */
183     HBWork * decoder;
184     HBWork * scale;
185     HBWork * encoder;
186 };
187
188 struct HBAudio
189 {
190     /* Ident */
191     uint32_t    id;
192     char      * language;
193
194     /* Settings */
195     int         inCodec;
196     int         outCodec;
197     int         inSampleRate;
198     int         outSampleRate;
199     int         inBitrate;
200     int         outBitrate;
201
202     int         delay; /* in ms */
203
204     /* See DVDRead.c */
205     int64_t     start;
206
207     /* MPEG-4 config, used in the MP4 muxer */
208     uint8_t       * esConfig;
209     unsigned long   esConfigLength;
210
211     /* MP4 track id */
212     int         track;
213
214     /* AVI stuff */
215     uint32_t            aviFourCC;
216     HBAviStreamHeader * aviAudioHeader;
217     HBWaveFormatEx    * aviAudioFormat;
218
219     /* Fifos */
220     HBFifo    * inFifo;
221     HBFifo    * rawFifo;
222     HBFifo    * outFifo;
223
224     /* Work objects */
225     HBWork    * decoder;
226     HBWork    * encoder;;
227 };
228
229 #endif