allow ffmpeg video to resample curr_pos, add bluray format
[goodguy/history.git] / cinelerra-5.0 / quicktime / quicktime.h
1 #ifndef QUICKTIME_H
2 #define QUICKTIME_H
3
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7
8
9 #include "qtprivate.h"
10
11 /* This is the reference for all your library entry points. */
12
13
14
15
16
17
18 /* ===== compression formats for which codecs exist ====== */
19
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_DNXHD "AVdn"
27 #define QUICKTIME_MP4V "mp4v"
28
29 #define QUICKTIME_H264 "avc1"
30
31
32 /* Basterdization of MPEG-4 which encodes alternating fields in series */
33 /* NOT STANDARD */
34 #define QUICKTIME_HV60 "HV60"
35 /* Basterdization of H264 which encodes alternating fields in series */
36 /* NOT STANDARD */
37 #define QUICKTIME_HV64 "HV64"
38
39 /* McRoesoft MPEG-4 */
40 #define QUICKTIME_DIV3 "DIV3"
41 #define QUICKTIME_DIV3_LOWER "div3"
42
43 /* Mormon MPEG-4 */
44 #define QUICKTIME_SVQ1 "SVQ1"
45 #define QUICKTIME_SVQ3 "SVQ3"
46 #define QUICKTIME_H263 "h263"
47
48 /* Dee Vee */
49 #define QUICKTIME_DV "dvc "
50 #define QUICKTIME_DV25 "dv25"
51 #define QUICKTIME_DVSD "dvsd"
52 #define QUICKTIME_DVCP "dvcp"          // PAL video inside Quicktime
53
54 /* RGB uncompressed.  Allows alpha */
55 #define QUICKTIME_RAW  "raw "
56 #define QUICKTIME_RLE "rle "
57
58 /* Jpeg Photo */
59 #define QUICKTIME_JPEG "jpeg"
60 #define QUICKTIME_MJPG "MJPG"
61
62 /* Concatenated png images.  Allows alpha */
63 #define QUICKTIME_PNG "png "
64
65 /* Motion JPEG-A. */
66 #define QUICKTIME_MJPA "mjpa"
67
68 /* YUV 4:2:2 */
69 #define QUICKTIME_YUV2 "yuv2"
70
71 /* 8 bit Packed YUV (video range) 4:2:2 */
72 #define QUICKTIME_2VUY "2vuy"
73
74 /* Crazy YUV 4:2:0 configuration for early tests.  NOT STANDARD. */
75 #define QUICKTIME_YUV4 "yuv4"
76
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"
81
82 /* 8 bit Planar YUV 4:1:1 */
83 #define QUICKTIME_YUV411  "y411"
84
85 /* 8 bit Packed YUV 4:2:2 */
86 #define QUICKTIME_YUV422 "yuv2"
87
88 /* 8 bit Planar YUV 4:4:4 */
89 #define QUICKTIME_YUV444  "v308"
90
91 /* 8 bit Planar YUVA 4:4:4:4 */
92 #define QUICKTIME_YUVA4444 "v408"
93
94 /* 10 bit Planar YUV 4:4:4 */
95 #define QUICKTIME_YUV444_10bit  "v410"
96
97 /* ======== compression for which no codec exists ========== */
98 /* These are traditionally converted in hardware or not at all */
99 /* ======== Studies in different algorithms =============== */
100
101 /* YUV9.  Too horrible to look at. */
102 #define QUICKTIME_YUV9 "YVU9"
103
104 /* RTjpeg, proprietary but fast? */
105 /* This is theoretically what nipple video uses.  May get integrated later. */
106 #define QUICKTIME_RTJ0 "RTJ0"
107
108 /* =================== Audio formats ======================= */
109
110 /* Unsigned 8 bit but it uses the same fourcc as RGB uncompressed */
111 #ifndef QUICKTIME_RAW
112 #define QUICKTIME_RAW "raw "
113 #endif
114
115 /* IMA4 */
116 #define QUICKTIME_IMA4 "ima4"
117
118 /* Twos compliment 8, 16, 24 */
119 #define QUICKTIME_TWOS "twos"
120 #define QUICKTIME_SOWT "sowt"
121
122 /* ulaw */
123 #define QUICKTIME_ULAW "ulaw"
124
125 /* OGG Vorbis.  NOT STANDARD */
126 #define QUICKTIME_VORBIS "OggS"
127
128 /* MP3 Doesn't play in Win for some reason */
129 #define QUICKTIME_MP3 ".mp3"
130
131 #define QUICKTIME_MP4A "mp4a"
132 #define QUICKTIME_QDM2 "QDM2"
133
134 /* Mike Row Soft */
135 /* AVI decode only */
136 #define QUICKTIME_WMA "WMA "
137
138 /* Some crazy derivative on ima4.  NOT STANDARD */
139 #define QUICKTIME_WMX2 "wmx2"
140
141 /* =========================== public interface ========================= */
142
143 /* Get version information */
144 int quicktime_major(void);
145 int quicktime_minor(void);
146 int quicktime_release(void);
147
148 /* return 1 if the file is a quicktime file */
149 int quicktime_check_sig(char *path);
150
151 /* call this first to open the file and create all the objects */
152 quicktime_t* quicktime_open(char *filename, int rd, int wr);
153
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);
161
162 /* Another Microsoft file format */
163 void quicktime_set_asf(quicktime_t *file, int value);
164
165
166 /* make the quicktime file streamable */
167 int quicktime_make_streamable(char *in_path, char *out_path);
168
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);
176
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);
181
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,
186         int channels,
187         long sample_rate,
188         int bits,
189         char *compressor);
190 /* Samplerate can be set after file is created */
191 void quicktime_set_framerate(quicktime_t *file, double framerate);
192
193 /* Set aspect ratio.  Only a few codecs support it. */
194 void quicktime_set_aspect(quicktime_t *file, double aspect);
195
196 /* video is stored one layer per quicktime track */
197 int quicktime_set_video(quicktime_t *file,
198         int tracks,
199         int frame_w,
200         int frame_h,
201         double frame_rate,
202         char *compressor);
203
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);
207
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);
213
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);
218
219
220 /* Set the depth of the track. */
221 void quicktime_set_depth(quicktime_t *file,
222         int depth,
223         int track);
224
225
226 /* close the file and delete all the objects */
227 int quicktime_close(quicktime_t *file);
228
229 /* get length information */
230 long quicktime_audio_length(quicktime_t *file, int track);
231 long quicktime_video_length(quicktime_t *file, int track);
232
233 /* get position information */
234 long quicktime_audio_position(quicktime_t *file, int track);
235 long quicktime_video_position(quicktime_t *file, int track);
236
237 /* get file information */
238 int quicktime_video_tracks(quicktime_t *file);
239 int quicktime_audio_tracks(quicktime_t *file);
240
241 int quicktime_has_audio(quicktime_t *file);
242
243 /* Get the samples per second */
244 long quicktime_sample_rate(quicktime_t *file, int track);
245
246 /* Get the number of bits for the twos codec */
247 int quicktime_audio_bits(quicktime_t *file, int track);
248
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);
252
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);
256
257 /* Number of bytes per pixel for the raw codec */
258 int quicktime_video_depth(quicktime_t *file, int track);
259
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);
265
266 /* FourCC of the video compressor */
267 char* quicktime_video_compressor(quicktime_t *file, int track);
268
269 /* number of bytes of raw data in this frame */
270 long quicktime_frame_size(quicktime_t *file, long frame, int track);
271
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);
275
276 /* file positioning */
277 int quicktime_seek_end(quicktime_t *file);
278 int quicktime_seek_start(quicktime_t *file);
279
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);
283
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);
289
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);
294
295 /* read raw data */
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);
298
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);
303
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);
310
311 /* Track has keyframes */
312 int quicktime_has_keyframes(quicktime_t *file, int track);
313
314 /* ===================== Access to built in codecs follows. */
315
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);
319
320
321
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,
326                 int colormodel,
327                 int track);
328
329 /* Returns 1 if the codec can write the color model with no conversion */
330 int quicktime_writes_cmodel(quicktime_t *file,
331                 int colormodel,
332                 int track);
333
334
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,
338         int vol_width,
339         int vol_height,
340         int time_increment_resolution,
341         double frame_rate);
342 int quicktime_mpeg4_has_vol(unsigned char *data);
343
344 /* Direct copy of H264 */
345 int quicktime_h264_is_key(unsigned char *data, long size, char *codec_id);
346
347
348
349
350
351
352
353
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);
357
358 /* Set row span in bytes for the encoder and decoder interface */
359 void quicktime_set_row_span(quicktime_t *file, int row_span);
360
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 */
365         int in_y,
366         int in_w,
367         int in_h,
368         int out_w,                   /* Dimensions of output frame */
369         int out_h);
370
371 /* Encode the frame into a frame buffer. */
372 int quicktime_encode_video(quicktime_t *file,
373         unsigned char **row_pointers,
374         int track);
375
376 /* Decode a frame */
377 long quicktime_decode_video(quicktime_t *file,
378         unsigned char **row_pointers,
379         int track);
380
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);
384
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,
389         int16_t *output_i,
390         float *output_f,
391         long samples,
392         int channel);
393 int quicktime_encode_audio(quicktime_t *file,
394         int16_t **input_i,
395         float **input_f,
396         long samples);
397
398
399
400
401
402
403
404 /* Dump the file structures for the currently opened file. */
405 int quicktime_dump(quicktime_t *file);
406
407 /* Specify the number of cpus to utilize. */
408 int quicktime_set_cpus(quicktime_t *file, int cpus);
409
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);
415
416 int64_t quicktime_byte_position(quicktime_t *file);
417
418 /* Set frame offset for programme timecode */
419 void quicktime_set_frame_start(quicktime_t *file, int64_t value);
420
421
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);
431
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);
445
446 #ifdef __cplusplus
447 }
448 #endif
449
450 #endif