r665: Merged the official release 2.0.
[cinelerra_cv.git] / quicktime / quicktime.h
blob33f1af40b0fd72261b3f4d69c1d02e08ba88b7c6
1 #ifndef QUICKTIME_H
2 #define QUICKTIME_H
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
9 #include "qtprivate.h"
11 /* This is the reference for all your library entry points. */
18 /* ===== compression formats for which codecs exist ====== */
20 /* Straight MPEG-4 */
21 #define QUICKTIME_DX50 "DX50"
22 #define QUICKTIME_MPG4 "MPG4"
23 #define QUICKTIME_MP42 "MP42"
24 #define QUICKTIME_DIVX "DIVX"
25 #define QUICKTIME_XVID "XVID"
26 #define QUICKTIME_MP4V "mp4v"
28 #define QUICKTIME_H264 "avc1"
31 /* Basterdization of MPEG-4 which encodes alternating fields in series */
32 /* NOT STANDARD */
33 #define QUICKTIME_HV60 "HV60"
34 /* Basterdization of H264 which encodes alternating fields in series */
35 /* NOT STANDARD */
36 #define QUICKTIME_HV64 "HV64"
38 /* McRoesoft MPEG-4 */
39 #define QUICKTIME_DIV3 "DIV3"
40 #define QUICKTIME_DIV3_LOWER "div3"
42 /* Mormon MPEG-4 */
43 #define QUICKTIME_SVQ1 "SVQ1"
44 #define QUICKTIME_SVQ3 "SVQ3"
45 #define QUICKTIME_H263 "h263"
47 /* Dee Vee */
48 #define QUICKTIME_DV "dvc "
49 #define QUICKTIME_DV25 "dv25"
50 #define QUICKTIME_DVSD "dvsd"
52 /* RGB uncompressed. Allows alpha */
53 #define QUICKTIME_RAW "raw "
55 /* Jpeg Photo */
56 #define QUICKTIME_JPEG "jpeg"
58 /* Concatenated png images. Allows alpha */
59 #define QUICKTIME_PNG "png "
61 /* Motion JPEG-A. */
62 #define QUICKTIME_MJPA "mjpa"
64 /* YUV 4:2:2 */
65 #define QUICKTIME_YUV2 "yuv2"
67 /* Crazy YUV 4:2:0 configuration for early tests. NOT STANDARD. */
68 #define QUICKTIME_YUV4 "yuv4"
70 /* The following don't seem to work in Win but are documented. Only use
71 for intermediate storage since the documentation may be wrong. */
72 /* 8 bit Planar YUV 4:2:0 */
73 #define QUICKTIME_YUV420 "yv12"
75 /* 8 bit Planar YUV 4:1:1 */
76 #define QUICKTIME_YUV411 "y411"
78 /* 8 bit Packed YUV 4:2:2 */
79 #define QUICKTIME_YUV422 "yuv2"
81 /* 8 bit Planar YUV 4:4:4 */
82 #define QUICKTIME_YUV444 "v308"
84 /* 8 bit Planar YUVA 4:4:4:4 */
85 #define QUICKTIME_YUVA4444 "v408"
87 /* 10 bit Planar YUV 4:4:4 */
88 #define QUICKTIME_YUV444_10bit "v410"
90 /* ======== compression for which no codec exists ========== */
91 /* These are traditionally converted in hardware or not at all */
92 /* ======== Studies in different algorithms =============== */
94 /* YUV9. Too horrible to look at. */
95 #define QUICKTIME_YUV9 "YVU9"
97 /* RTjpeg, proprietary but fast? */
98 /* This is theoretically what nipple video uses. May get integrated later. */
99 #define QUICKTIME_RTJ0 "RTJ0"
101 /* =================== Audio formats ======================= */
103 /* Unsigned 8 bit but it uses the same fourcc as RGB uncompressed */
104 #ifndef QUICKTIME_RAW
105 #define QUICKTIME_RAW "raw "
106 #endif
108 /* IMA4 */
109 #define QUICKTIME_IMA4 "ima4"
111 /* Twos compliment 8, 16, 24 */
112 #define QUICKTIME_TWOS "twos"
114 /* ulaw */
115 #define QUICKTIME_ULAW "ulaw"
117 /* OGG Vorbis. NOT STANDARD */
118 #define QUICKTIME_VORBIS "OggS"
120 /* MP3 Doesn't play in Win for some reason */
121 #define QUICKTIME_MP3 ".mp3"
123 #define QUICKTIME_MP4A "mp4a"
125 /* Mike Row Soft */
126 /* AVI decode only */
127 #define QUICKTIME_WMA "WMA "
129 /* Some crazy derivative on ima4. NOT STANDARD */
130 #define QUICKTIME_WMX2 "wmx2"
132 /* =========================== public interface ========================= */
134 /* Get version information */
135 int quicktime_major(void);
136 int quicktime_minor(void);
137 int quicktime_release(void);
139 /* return 1 if the file is a quicktime file */
140 int quicktime_check_sig(char *path);
142 /* call this first to open the file and create all the objects */
143 quicktime_t* quicktime_open(char *filename, int rd, int wr);
145 /* After quicktime_open and quicktime_set for the audio and video call this */
146 /* to generate a Microsoft AVI file. */
147 /* The allmighty requires the codec information in the beginning of the file */
148 /* while the index can either be in the beginning or the end. Thus */
149 /* You need to set the audio and video first. */
150 void quicktime_set_avi(quicktime_t *file, int value);
151 int quicktime_is_avi(quicktime_t *file);
153 /* Another Microsoft file format */
154 void quicktime_set_asf(quicktime_t *file, int value);
157 /* make the quicktime file streamable */
158 int quicktime_make_streamable(char *in_path, char *out_path);
160 /* Set various options in the file. */
161 void quicktime_set_copyright(quicktime_t *file, char *string);
162 void quicktime_set_name(quicktime_t *file, char *string);
163 void quicktime_set_info(quicktime_t *file, char *string);
164 char* quicktime_get_copyright(quicktime_t *file);
165 char* quicktime_get_name(quicktime_t *file);
166 char* quicktime_get_info(quicktime_t *file);
168 /* Read all the information about the file. */
169 /* Requires a MOOV atom be present in the file. */
170 /* If no MOOV atom exists return 1 else return 0. */
171 int quicktime_read_info(quicktime_t *file);
173 /* set up tracks in a new file after opening and before writing */
174 /* returns the number of quicktime tracks allocated */
175 /* audio is stored two channels per quicktime track */
176 int quicktime_set_audio(quicktime_t *file,
177 int channels,
178 long sample_rate,
179 int bits,
180 char *compressor);
181 /* Samplerate can be set after file is created */
182 void quicktime_set_framerate(quicktime_t *file, double framerate);
184 /* Set aspect ratio. Only a few codecs support it. */
185 void quicktime_set_aspect(quicktime_t *file, double aspect);
187 /* video is stored one layer per quicktime track */
188 int quicktime_set_video(quicktime_t *file,
189 int tracks,
190 int frame_w,
191 int frame_h,
192 double frame_rate,
193 char *compressor);
195 /* routines for setting various video parameters */
196 /* should be called after set_video */
197 void quicktime_set_jpeg(quicktime_t *file, int quality, int use_float);
199 /* Configure codec parameters with this */
200 /* It iterates through every track and sets the key in that codec to */
201 /* the value. The value can be any data type and the key must be a */
202 /* string which the codec understands. */
203 void quicktime_set_parameter(quicktime_t *file, char *key, void *value);
205 /* Get the english title of a codec based on its fourcc. */
206 /* Used by info boxed. */
207 char* quicktime_acodec_title(char *fourcc);
208 char* quicktime_vcodec_title(char *fourcc);
211 /* Set the depth of the track. */
212 void quicktime_set_depth(quicktime_t *file,
213 int depth,
214 int track);
217 /* close the file and delete all the objects */
218 int quicktime_close(quicktime_t *file);
220 /* get length information */
221 long quicktime_audio_length(quicktime_t *file, int track);
222 long quicktime_video_length(quicktime_t *file, int track);
224 /* get position information */
225 long quicktime_audio_position(quicktime_t *file, int track);
226 long quicktime_video_position(quicktime_t *file, int track);
228 /* get file information */
229 int quicktime_video_tracks(quicktime_t *file);
230 int quicktime_audio_tracks(quicktime_t *file);
232 int quicktime_has_audio(quicktime_t *file);
234 /* Get the samples per second */
235 long quicktime_sample_rate(quicktime_t *file, int track);
237 /* Get the number of bits for the twos codec */
238 int quicktime_audio_bits(quicktime_t *file, int track);
240 /* Get the number of audio channels in an audio track */
241 int quicktime_track_channels(quicktime_t *file, int track);
242 char* quicktime_audio_compressor(quicktime_t *file, int track);
244 int quicktime_has_video(quicktime_t *file);
245 int quicktime_video_width(quicktime_t *file, int track);
246 int quicktime_video_height(quicktime_t *file, int track);
248 /* Number of bytes per pixel for the raw codec */
249 int quicktime_video_depth(quicktime_t *file, int track);
251 /* The interlace mode */
252 int quicktime_video_interlacemode(quicktime_t *file, int track);
254 /* Frames per second */
255 double quicktime_frame_rate(quicktime_t *file, int track);
256 /* Frames per second as numerator over denominator*/
257 int quicktime_frame_rate_n(quicktime_t *file, int track);
258 int quicktime_frame_rate_d(quicktime_t *file, int track);
260 /* FourCC of the video compressor */
261 char* quicktime_video_compressor(quicktime_t *file, int track);
263 /* number of bytes of raw data in this frame */
264 long quicktime_frame_size(quicktime_t *file, long frame, int track);
266 /* get the quicktime track and channel that the audio channel belongs to */
267 /* channels and tracks start on 0 */
268 int quicktime_channel_location(quicktime_t *file, int *quicktime_track, int *quicktime_channel, int channel);
270 /* file positioning */
271 int quicktime_seek_end(quicktime_t *file);
272 int quicktime_seek_start(quicktime_t *file);
274 /* set position of file descriptor relative to a track */
275 int quicktime_set_audio_position(quicktime_t *file, int64_t sample, int track);
276 int quicktime_set_video_position(quicktime_t *file, int64_t frame, int track);
278 /* ========================== Access to raw data follows. */
279 /* write data for one quicktime track */
280 /* the user must handle conversion to the channels in this track */
282 * int quicktime_write_audio(quicktime_t *file,
283 * char *audio_buffer,
284 * long samples,
285 * int track);
287 int quicktime_write_frame(quicktime_t *file,
288 unsigned char *video_buffer,
289 int64_t bytes,
290 int track);
292 /* Read an entire chunk. */
293 /* read the number of bytes starting at the byte_start in the specified chunk */
294 /* You must provide enough space to store the chunk. */
295 int quicktime_read_chunk(quicktime_t *file, char *output, int track, int64_t chunk, int64_t byte_start, int64_t byte_len);
297 /* read raw data */
298 long quicktime_read_audio(quicktime_t *file, char *audio_buffer, long samples, int track);
299 long quicktime_read_frame(quicktime_t *file, unsigned char *video_buffer, int track);
301 /* for reading frame using a library that needs a file descriptor */
302 /* Frame caching doesn't work here. */
303 int quicktime_read_frame_init(quicktime_t *file, int track);
304 int quicktime_read_frame_end(quicktime_t *file, int track);
306 /* One keyframe table for each track */
307 /* Returns -1 if no keyframe exists. In AVI this always returns -1 */
308 /* if the frame offset is over 1 Gig. McRowsoft you know. */
309 int64_t quicktime_get_keyframe_before(quicktime_t *file, int64_t frame, int track);
310 int64_t quicktime_get_keyframe_after(quicktime_t *file, int64_t frame, int track);
311 void quicktime_insert_keyframe(quicktime_t *file, int64_t frame, int track);
313 /* Track has keyframes */
314 int quicktime_has_keyframes(quicktime_t *file, int track);
316 /* ===================== Access to built in codecs follows. */
318 /* If the codec for this track is supported in the library return 1. */
319 int quicktime_supported_video(quicktime_t *file, int track);
320 int quicktime_supported_audio(quicktime_t *file, int track);
324 /* The codecs can all support RGB in and out. */
325 /* To find out if other color models are supported, use these functions. */
326 /* Returns 1 if the codec can generate the color model with no conversion */
327 int quicktime_reads_cmodel(quicktime_t *file,
328 int colormodel,
329 int track);
331 /* Returns 1 if the codec can write the color model with no conversion */
332 int quicktime_writes_cmodel(quicktime_t *file,
333 int colormodel,
334 int track);
337 /* Utilities for direct copy of MPEG-4 */
338 int quicktime_mpeg4_is_key(unsigned char *data, long size, char *codec_id);
339 int quicktime_mpeg4_write_vol(unsigned char *data_start,
340 int vol_width,
341 int vol_height,
342 int time_increment_resolution,
343 double frame_rate);
344 int quicktime_mpeg4_has_vol(unsigned char *data);
346 /* Direct copy of H264 */
347 int quicktime_h264_is_key(unsigned char *data, long size, char *codec_id);
356 /* These should be called right before a decode or encode function */
357 /* Set the colormodel for the encoder and decoder interface */
358 void quicktime_set_cmodel(quicktime_t *file, int colormodel);
360 /* Set row span in bytes for the encoder and decoder interface */
361 void quicktime_set_row_span(quicktime_t *file, int row_span);
363 /* Set the decoding window for the decoder interface. If the dimensions are */
364 /* all -1, no scaling is used. The default is no scaling. */
365 void quicktime_set_window(quicktime_t *file,
366 int in_x, /* Location of input frame to take picture */
367 int in_y,
368 int in_w,
369 int in_h,
370 int out_w, /* Dimensions of output frame */
371 int out_h);
373 /* Encode the frame into a frame buffer. */
374 int quicktime_encode_video(quicktime_t *file,
375 unsigned char **row_pointers,
376 int track);
378 /* Decode a frame */
379 long quicktime_decode_video(quicktime_t *file,
380 unsigned char **row_pointers,
381 int track);
383 /* Decode or encode audio for a single channel into the buffer. */
384 /* Pass a buffer for the _i or the _f argument if you want int16 or float data. */
385 /* Notice that encoding requires an array of pointers to each channel. */
386 int quicktime_decode_audio(quicktime_t *file,
387 int16_t *output_i,
388 float *output_f,
389 long samples,
390 int channel);
391 int quicktime_encode_audio(quicktime_t *file,
392 int16_t **input_i,
393 float **input_f,
394 long samples);
402 /* Dump the file structures for the currently opened file. */
403 int quicktime_dump(quicktime_t *file);
405 /* Specify the number of cpus to utilize. */
406 int quicktime_set_cpus(quicktime_t *file, int cpus);
408 /* Specify whether to read contiguously or not. */
409 /* preload is the number of bytes to read ahead. */
410 /* This is no longer functional to the end user but is used to accelerate */
411 /* reading the header internally. */
412 void quicktime_set_preload(quicktime_t *file, int64_t preload);
414 int64_t quicktime_byte_position(quicktime_t *file);
416 /* Set frame offset for programme timecode */
417 void quicktime_set_frame_start(quicktime_t *file, int64_t value);
421 #ifdef __cplusplus
423 #endif
425 #endif