11 /* This is the reference for all your library entry points. */
18 /* ===== compression formats for which codecs exist ====== */
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_DNXHD "AVdn"
27 #define QUICKTIME_MP4V "mp4v"
29 #define QUICKTIME_H264 "avc1"
32 /* Basterdization of MPEG-4 which encodes alternating fields in series */
34 #define QUICKTIME_HV60 "HV60"
35 /* Basterdization of H264 which encodes alternating fields in series */
37 #define QUICKTIME_HV64 "HV64"
39 /* McRoesoft MPEG-4 */
40 #define QUICKTIME_DIV3 "DIV3"
41 #define QUICKTIME_DIV3_LOWER "div3"
44 #define QUICKTIME_SVQ1 "SVQ1"
45 #define QUICKTIME_SVQ3 "SVQ3"
46 #define QUICKTIME_H263 "h263"
49 #define QUICKTIME_DV "dvc "
50 #define QUICKTIME_DV25 "dv25"
51 #define QUICKTIME_DVSD "dvsd"
52 #define QUICKTIME_DVCP "dvcp" // PAL video inside Quicktime
54 /* RGB uncompressed. Allows alpha */
55 #define QUICKTIME_RAW "raw "
56 #define QUICKTIME_RLE "rle "
59 #define QUICKTIME_JPEG "jpeg"
60 #define QUICKTIME_MJPG "MJPG"
62 /* Concatenated png images. Allows alpha */
63 #define QUICKTIME_PNG "png "
66 #define QUICKTIME_MJPA "mjpa"
69 #define QUICKTIME_YUV2 "yuv2"
71 /* 8 bit Packed YUV (video range) 4:2:2 */
72 #define QUICKTIME_2VUY "2vuy"
74 /* Crazy YUV 4:2:0 configuration for early tests. NOT STANDARD. */
75 #define QUICKTIME_YUV4 "yuv4"
77 /* The following don't seem to work in Win but are documented. Only use
78 for intermediate storage since the documentation may be wrong. */
79 /* 8 bit Planar YUV 4:2:0 */
80 #define QUICKTIME_YUV420 "yv12"
82 /* 8 bit Planar YUV 4:1:1 */
83 #define QUICKTIME_YUV411 "y411"
85 /* 8 bit Packed YUV 4:2:2 */
86 #define QUICKTIME_YUV422 "yuv2"
88 /* 8 bit Planar YUV 4:4:4 */
89 #define QUICKTIME_YUV444 "v308"
91 /* 8 bit Planar YUVA 4:4:4:4 */
92 #define QUICKTIME_YUVA4444 "v408"
94 /* 10 bit Planar YUV 4:4:4 */
95 #define QUICKTIME_YUV444_10bit "v410"
97 /* ======== compression for which no codec exists ========== */
98 /* These are traditionally converted in hardware or not at all */
99 /* ======== Studies in different algorithms =============== */
101 /* YUV9. Too horrible to look at. */
102 #define QUICKTIME_YUV9 "YVU9"
104 /* RTjpeg, proprietary but fast? */
105 /* This is theoretically what nipple video uses. May get integrated later. */
106 #define QUICKTIME_RTJ0 "RTJ0"
108 /* =================== Audio formats ======================= */
110 /* Unsigned 8 bit but it uses the same fourcc as RGB uncompressed */
111 #ifndef QUICKTIME_RAW
112 #define QUICKTIME_RAW "raw "
116 #define QUICKTIME_IMA4 "ima4"
118 /* Twos compliment 8, 16, 24 */
119 #define QUICKTIME_TWOS "twos"
120 #define QUICKTIME_SOWT "sowt"
123 #define QUICKTIME_ULAW "ulaw"
125 /* OGG Vorbis. NOT STANDARD */
126 #define QUICKTIME_VORBIS "OggS"
128 /* MP3 Doesn't play in Win for some reason */
129 #define QUICKTIME_MP3 ".mp3"
131 #define QUICKTIME_MP4A "mp4a"
132 #define QUICKTIME_QDM2 "QDM2"
135 /* AVI decode only */
136 #define QUICKTIME_WMA "WMA "
138 /* Some crazy derivative on ima4. NOT STANDARD */
139 #define QUICKTIME_WMX2 "wmx2"
141 /* =========================== public interface ========================= */
143 /* Get version information */
144 int quicktime_major(void);
145 int quicktime_minor(void);
146 int quicktime_release(void);
148 /* return 1 if the file is a quicktime file */
149 int quicktime_check_sig(char *path);
151 /* call this first to open the file and create all the objects */
152 quicktime_t* quicktime_open(char *filename, int rd, int wr);
154 /* After quicktime_open and quicktime_set for the audio and video call this */
155 /* to generate a Microsoft AVI file. */
156 /* The allmighty requires the codec information in the beginning of the file */
157 /* while the index can either be in the beginning or the end. Thus */
158 /* You need to set the audio and video first. */
159 void quicktime_set_avi(quicktime_t *file, int value);
160 int quicktime_is_avi(quicktime_t *file);
162 /* Another Microsoft file format */
163 void quicktime_set_asf(quicktime_t *file, int value);
166 /* make the quicktime file streamable */
167 int quicktime_make_streamable(char *in_path, char *out_path);
169 /* Set various options in the file. */
170 void quicktime_set_copyright(quicktime_t *file, const char *string);
171 void quicktime_set_name(quicktime_t *file, const char *string);
172 void quicktime_set_info(quicktime_t *file, const char *string);
173 char* quicktime_get_copyright(quicktime_t *file);
174 char* quicktime_get_name(quicktime_t *file);
175 char* quicktime_get_info(quicktime_t *file);
177 /* Read all the information about the file. */
178 /* Requires a MOOV atom be present in the file. */
179 /* If no MOOV atom exists return 1 else return 0. */
180 int quicktime_read_info(quicktime_t *file);
182 /* set up tracks in a new file after opening and before writing */
183 /* returns the number of quicktime tracks allocated */
184 /* audio is stored two channels per quicktime track */
185 int quicktime_set_audio(quicktime_t *file,
190 /* Samplerate can be set after file is created */
191 void quicktime_set_framerate(quicktime_t *file, double framerate);
193 /* Set aspect ratio. Only a few codecs support it. */
194 void quicktime_set_aspect(quicktime_t *file, double aspect);
196 /* video is stored one layer per quicktime track */
197 int quicktime_set_video(quicktime_t *file,
204 /* routines for setting various video parameters */
205 /* should be called after set_video */
206 void quicktime_set_jpeg(quicktime_t *file, int quality, int use_float);
208 /* Configure codec parameters with this */
209 /* It iterates through every track and sets the key in that codec to */
210 /* the value. The value can be any data type and the key must be a */
211 /* string which the codec understands. */
212 void quicktime_set_parameter(quicktime_t *file, const char *key, void *value);
214 /* Get the english title of a codec based on its fourcc. */
215 /* Used by info boxed. */
216 char* quicktime_acodec_title(char *fourcc);
217 char* quicktime_vcodec_title(char *fourcc);
220 /* Set the depth of the track. */
221 void quicktime_set_depth(quicktime_t *file,
226 /* close the file and delete all the objects */
227 int quicktime_close(quicktime_t *file);
229 /* get length information */
230 long quicktime_audio_length(quicktime_t *file, int track);
231 long quicktime_video_length(quicktime_t *file, int track);
233 /* get position information */
234 long quicktime_audio_position(quicktime_t *file, int track);
235 long quicktime_video_position(quicktime_t *file, int track);
237 /* get file information */
238 int quicktime_video_tracks(quicktime_t *file);
239 int quicktime_audio_tracks(quicktime_t *file);
241 int quicktime_has_audio(quicktime_t *file);
243 /* Get the samples per second */
244 long quicktime_sample_rate(quicktime_t *file, int track);
246 /* Get the number of bits for the twos codec */
247 int quicktime_audio_bits(quicktime_t *file, int track);
249 /* Get the number of audio channels in an audio track */
250 int quicktime_track_channels(quicktime_t *file, int track);
251 char* quicktime_audio_compressor(quicktime_t *file, int track);
253 int quicktime_has_video(quicktime_t *file);
254 int quicktime_video_width(quicktime_t *file, int track);
255 int quicktime_video_height(quicktime_t *file, int track);
257 /* Number of bytes per pixel for the raw codec */
258 int quicktime_video_depth(quicktime_t *file, int track);
260 /* Frames per second */
261 double quicktime_frame_rate(quicktime_t *file, int track);
262 /* Frames per second as numerator over denominator*/
263 int quicktime_frame_rate_n(quicktime_t *file, int track);
264 int quicktime_frame_rate_d(quicktime_t *file, int track);
266 /* FourCC of the video compressor */
267 char* quicktime_video_compressor(quicktime_t *file, int track);
269 /* number of bytes of raw data in this frame */
270 long quicktime_frame_size(quicktime_t *file, long frame, int track);
272 /* get the quicktime track and channel that the audio channel belongs to */
273 /* channels and tracks start on 0 */
274 int quicktime_channel_location(quicktime_t *file, int *quicktime_track, int *quicktime_channel, int channel);
276 /* file positioning */
277 int quicktime_seek_end(quicktime_t *file);
278 int quicktime_seek_start(quicktime_t *file);
280 /* set position of file descriptor relative to a track */
281 int quicktime_set_audio_position(quicktime_t *file, int64_t sample, int track);
282 int quicktime_set_video_position(quicktime_t *file, int64_t frame, int track);
284 /* ========================== Access to raw data follows. */
285 /* write data for one quicktime track */
286 /* the user must handle conversion to the channels in this track */
287 int quicktime_write_audio(quicktime_t *file, char *audio_buffer, long samples,int track);
288 int quicktime_write_frame(quicktime_t *file, unsigned char *video_buffer, int64_t bytes, int track);
290 /* Read an entire chunk. */
291 /* read the number of bytes starting at the byte_start in the specified chunk */
292 /* You must provide enough space to store the chunk. */
293 int quicktime_read_chunk(quicktime_t *file, char *output, int track, int64_t chunk, int64_t byte_start, int64_t byte_len);
296 long quicktime_read_audio(quicktime_t *file, char *audio_buffer, long samples, int track);
297 long quicktime_read_frame(quicktime_t *file, unsigned char *video_buffer, int track);
299 /* for reading frame using a library that needs a file descriptor */
300 /* Frame caching doesn't work here. */
301 int quicktime_read_frame_init(quicktime_t *file, int track);
302 int quicktime_read_frame_end(quicktime_t *file, int track);
304 /* One keyframe table for each track */
305 /* Returns -1 if no keyframe exists. In AVI this always returns -1 */
306 /* if the frame offset is over 1 Gig. McRowsoft you know. */
307 int64_t quicktime_get_keyframe_before(quicktime_t *file, int64_t frame, int track);
308 int64_t quicktime_get_keyframe_after(quicktime_t *file, int64_t frame, int track);
309 void quicktime_insert_keyframe(quicktime_t *file, int64_t frame, int track);
311 /* Track has keyframes */
312 int quicktime_has_keyframes(quicktime_t *file, int track);
314 /* ===================== Access to built in codecs follows. */
316 /* If the codec for this track is supported in the library return 1. */
317 int quicktime_supported_video(quicktime_t *file, int track);
318 int quicktime_supported_audio(quicktime_t *file, int track);
322 /* The codecs can all support RGB in and out. */
323 /* To find out if other color models are supported, use these functions. */
324 /* Returns 1 if the codec can generate the color model with no conversion */
325 int quicktime_reads_cmodel(quicktime_t *file,
329 /* Returns 1 if the codec can write the color model with no conversion */
330 int quicktime_writes_cmodel(quicktime_t *file,
335 /* Utilities for direct copy of MPEG-4 */
336 int quicktime_mpeg4_is_key(unsigned char *data, long size, char *codec_id);
337 int quicktime_mpeg4_write_vol(unsigned char *data_start,
340 int time_increment_resolution,
342 int quicktime_mpeg4_has_vol(unsigned char *data);
344 /* Direct copy of H264 */
345 int quicktime_h264_is_key(unsigned char *data, long size, char *codec_id);
354 /* These should be called right before a decode or encode function */
355 /* Set the colormodel for the encoder and decoder interface */
356 void quicktime_set_cmodel(quicktime_t *file, int colormodel);
358 /* Set row span in bytes for the encoder and decoder interface */
359 void quicktime_set_row_span(quicktime_t *file, int row_span);
361 /* Set the decoding window for the decoder interface. If the dimensions are */
362 /* all -1, no scaling is used. The default is no scaling. */
363 void quicktime_set_window(quicktime_t *file,
364 int in_x, /* Location of input frame to take picture */
368 int out_w, /* Dimensions of output frame */
371 /* Encode the frame into a frame buffer. */
372 int quicktime_encode_video(quicktime_t *file,
373 unsigned char **row_pointers,
377 long quicktime_decode_video(quicktime_t *file,
378 unsigned char **row_pointers,
381 /* Get memory used by video decoders. Only counts frame caches. */
382 int64_t quicktime_memory_usage(quicktime_t *file);
383 void quicktime_set_cache_max(quicktime_t *file, int bytes);
385 /* Decode or encode audio for a single channel into the buffer. */
386 /* Pass a buffer for the _i or the _f argument if you want int16 or float data. */
387 /* Notice that encoding requires an array of pointers to each channel. */
388 int quicktime_decode_audio(quicktime_t *file,
393 int quicktime_encode_audio(quicktime_t *file,
404 /* Dump the file structures for the currently opened file. */
405 int quicktime_dump(quicktime_t *file);
407 /* Specify the number of cpus to utilize. */
408 int quicktime_set_cpus(quicktime_t *file, int cpus);
410 /* Specify whether to read contiguously or not. */
411 /* preload is the number of bytes to read ahead. */
412 /* This is no longer functional to the end user but is used to accelerate */
413 /* reading the header internally. */
414 void quicktime_set_preload(quicktime_t *file, int64_t preload);
416 int64_t quicktime_byte_position(quicktime_t *file);
418 /* Set frame offset for programme timecode */
419 void quicktime_set_frame_start(quicktime_t *file, int64_t value);
422 quicktime_trak_t *quicktime_add_track(quicktime_t *file);
423 int quicktime_init(quicktime_t *file);
424 int quicktime_init_audio_map(quicktime_audio_map_t *atrack, quicktime_trak_t *trak);
425 int quicktime_delete_audio_map(quicktime_audio_map_t *atrack);
426 int quicktime_init_video_map(quicktime_video_map_t *vtrack, quicktime_trak_t *trak);
427 int quicktime_delete_video_map(quicktime_video_map_t *vtrack);
428 int quicktime_delete(quicktime_t *file);
429 int quicktime_get_timescale(double frame_rate);
430 int quicktime_update_positions(quicktime_t *file);
432 int quicktime_codec_to_id(char *codec);
433 quicktime_codec_t *quicktime_new_codec(void);
434 void quicktime_del_codec(quicktime_codec_t *codec);
435 int new_vcodec(quicktime_video_map_t *vtrack);
436 int new_acodec(quicktime_audio_map_t *atrack);
437 int quicktime_init_vcodec(quicktime_video_map_t *vtrack);
438 int quicktime_init_acodec(quicktime_audio_map_t *atrack);
439 int quicktime_delete_vcodec(quicktime_video_map_t *vtrack);
440 int quicktime_delete_acodec(quicktime_audio_map_t *atrack);
441 int quicktime_flush_acodec(quicktime_t *file,int track);
442 void quicktime_flush_vcodec(quicktime_t *file,int track);
443 int64_t quicktime_samples_to_bytes(quicktime_trak_t *track,long samples);
444 int quicktime_codecs_flush(quicktime_t *file);