libquicktime
|
00001 /******************************************************************************* 00002 quicktime.h 00003 00004 libquicktime - A library for reading and writing quicktime/avi/mp4 files. 00005 http://libquicktime.sourceforge.net 00006 00007 Copyright (C) 2002 Heroine Virtual Ltd. 00008 Copyright (C) 2002-2011 Members of the libquicktime project. 00009 00010 This library is free software; you can redistribute it and/or modify it under 00011 the terms of the GNU Lesser General Public License as published by the Free 00012 Software Foundation; either version 2.1 of the License, or (at your option) 00013 any later version. 00014 00015 This library is distributed in the hope that it will be useful, but WITHOUT 00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00018 details. 00019 00020 You should have received a copy of the GNU Lesser General Public License along 00021 with this library; if not, write to the Free Software Foundation, Inc., 51 00022 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00023 *******************************************************************************/ 00024 00025 #ifndef QUICKTIME_H 00026 #define QUICKTIME_H 00027 00028 #ifdef __cplusplus 00029 extern "C" { 00030 #endif 00031 00032 #include <inttypes.h> 00033 #include <stddef.h> 00034 00035 #pragma GCC visibility push(default) 00036 00037 /* Some public enums needed by most subsequent headers */ 00038 00039 typedef struct lqt_codec_info_s lqt_codec_info_t; 00040 00041 00124 typedef enum 00125 { 00126 LQT_LOG_ERROR = (1<<0), 00127 LQT_LOG_WARNING = (1<<1), 00128 LQT_LOG_INFO = (1<<2), 00129 LQT_LOG_DEBUG = (1<<3), 00130 } lqt_log_level_t; 00131 00140 typedef void (*lqt_log_callback_t)(lqt_log_level_t level, 00141 const char * domain, 00142 const char * message, 00143 void * data); 00144 00145 00152 typedef enum 00153 { 00154 LQT_FILE_NONE = 0, 00155 LQT_FILE_QT_OLD = (1<<0), 00156 LQT_FILE_QT = (1<<1), 00157 LQT_FILE_AVI = (1<<2), 00158 LQT_FILE_AVI_ODML = (1<<3), 00159 LQT_FILE_MP4 = (1<<4), 00160 LQT_FILE_M4A = (1<<5), 00161 LQT_FILE_3GP = (1<<6), 00162 } lqt_file_type_t; 00163 00164 00175 typedef enum 00176 { 00177 LQT_CHANNEL_UNKNOWN, 00178 LQT_CHANNEL_FRONT_LEFT, 00179 LQT_CHANNEL_FRONT_RIGHT, 00180 LQT_CHANNEL_FRONT_CENTER, 00181 LQT_CHANNEL_FRONT_CENTER_LEFT, 00182 LQT_CHANNEL_FRONT_CENTER_RIGHT, 00183 LQT_CHANNEL_BACK_CENTER, 00184 LQT_CHANNEL_BACK_LEFT, 00185 LQT_CHANNEL_BACK_RIGHT, 00186 LQT_CHANNEL_SIDE_LEFT, 00187 LQT_CHANNEL_SIDE_RIGHT, 00188 LQT_CHANNEL_LFE, 00189 } lqt_channel_t; 00190 00191 00255 typedef enum 00256 { 00257 LQT_INTERLACE_NONE = 0, 00258 LQT_INTERLACE_TOP_FIRST, 00259 LQT_INTERLACE_BOTTOM_FIRST 00260 } lqt_interlace_mode_t; 00261 00271 typedef enum 00272 { 00273 LQT_CHROMA_PLACEMENT_DEFAULT = 0, 00274 LQT_CHROMA_PLACEMENT_MPEG2, 00275 LQT_CHROMA_PLACEMENT_DVPAL, 00276 } lqt_chroma_placement_t; 00277 00287 typedef enum 00288 { 00289 LQT_SAMPLE_UNDEFINED = 0, 00290 LQT_SAMPLE_INT8, 00291 LQT_SAMPLE_UINT8, 00292 LQT_SAMPLE_INT16, 00293 LQT_SAMPLE_INT32, 00294 LQT_SAMPLE_FLOAT, 00295 LQT_SAMPLE_DOUBLE 00296 } lqt_sample_format_t; 00297 00306 typedef struct quicktime_s quicktime_t; 00307 00308 /* This is the reference for all your library entry points. */ 00309 00310 /* ===== compression formats for which codecs exist ====== */ 00311 00331 #define QUICKTIME_DIVX "DIVX" 00332 00339 #define QUICKTIME_DIV3 "DIV3" 00340 00347 #define QUICKTIME_DV "dvc " 00348 /* AVID DV codec can be processed with libdv as well */ 00349 00356 #define QUICKTIME_DV_AVID "AVdv" 00357 00364 #define QUICKTIME_DV_AVID_A "dvcp" 00365 00373 /* RGB uncompressed. Allows alpha */ 00374 #define QUICKTIME_RAW "raw " 00375 00382 /* Jpeg Photo */ 00383 #define QUICKTIME_JPEG "jpeg" 00384 00385 /* Concatenated png images. Allows alpha */ 00386 00394 #define QUICKTIME_PNG "png " 00395 00403 #define QUICKTIME_MJPA "mjpa" 00404 00411 #define QUICKTIME_YUV2 "yuv2" 00412 00419 #define QUICKTIME_YUV4 "yuv4" 00420 00428 #define QUICKTIME_YUV420 "yv12" 00429 00436 #define QUICKTIME_2VUY "2vuy" 00437 00444 #define QUICKTIME_YUVS "yuvs" 00445 00446 00453 #define QUICKTIME_V308 "v308" 00454 00461 #define QUICKTIME_V408 "v408" 00462 00469 #define QUICKTIME_V210 "v210" 00470 00477 #define QUICKTIME_V410 "v410" 00478 00479 /* =================== Audio formats ======================= */ 00480 00500 #define QUICKTIME_RAWAUDIO "raw " 00501 00508 #define QUICKTIME_IMA4 "ima4" 00509 00516 #define QUICKTIME_TWOS "twos" 00517 00524 #define QUICKTIME_ULAW "ulaw" 00525 00534 #define QUICKTIME_VORBIS "OggS" 00535 00543 #define QUICKTIME_MP3 ".mp3" 00544 00545 /* =========================== public interface ========================= // */ 00546 00555 /* Get version information */ 00556 int quicktime_major(); 00557 00565 int quicktime_minor(); 00566 00575 int quicktime_release(); 00576 00588 int quicktime_check_sig(char *path); 00589 00600 quicktime_t* quicktime_open(const char *filename, int rd, int wr); 00601 00614 int quicktime_make_streamable(char *in_path, char *out_path); 00615 00629 void quicktime_set_copyright(quicktime_t *file, char *string); 00630 00637 void quicktime_set_name(quicktime_t *file, char *string); 00638 00645 void quicktime_set_info(quicktime_t *file, char *string); 00646 00654 char* quicktime_get_copyright(quicktime_t *file); 00655 00663 char* quicktime_get_name(quicktime_t *file); 00664 00671 char* quicktime_get_info(quicktime_t *file); 00672 00673 00689 int quicktime_set_audio(quicktime_t *file, 00690 int channels, 00691 long sample_rate, 00692 int bits, 00693 char *compressor); 00694 00705 void quicktime_set_framerate(quicktime_t *file, double framerate); 00706 00722 int quicktime_set_video(quicktime_t *file, 00723 int tracks, 00724 int frame_w, 00725 int frame_h, 00726 double frame_rate, 00727 char *compressor); 00728 00742 void quicktime_set_jpeg(quicktime_t *file, int quality, int use_float); 00743 00758 void quicktime_set_parameter(quicktime_t *file, char *key, void *value); 00759 00770 void quicktime_set_depth(quicktime_t *file, 00771 int depth, 00772 int track); 00773 00783 void quicktime_set_cmodel(quicktime_t *file, int colormodel); 00784 00795 void quicktime_set_row_span(quicktime_t *file, int row_span); 00796 00802 int quicktime_close(quicktime_t *file); 00803 00804 /* get length information */ 00805 /* channel numbers start on 1 for audio and video */ 00806 00815 long quicktime_audio_length(quicktime_t *file, int track); 00816 00828 long quicktime_video_length(quicktime_t *file, int track); 00829 00837 /* get position information */ 00838 long quicktime_audio_position(quicktime_t *file, int track); 00839 00849 long quicktime_video_position(quicktime_t *file, int track); 00850 00857 /* get file information */ 00858 int quicktime_video_tracks(quicktime_t *file); 00859 00866 int quicktime_audio_tracks(quicktime_t *file); 00867 00874 int quicktime_has_audio(quicktime_t *file); 00875 00883 long quicktime_sample_rate(quicktime_t *file, int track); 00884 00899 int quicktime_audio_bits(quicktime_t *file, int track); 00900 00908 int quicktime_track_channels(quicktime_t *file, int track); 00909 00922 char* quicktime_audio_compressor(quicktime_t *file, int track); 00923 00930 int quicktime_has_video(quicktime_t *file); 00931 00939 int quicktime_video_width(quicktime_t *file, int track); 00940 00948 int quicktime_video_height(quicktime_t *file, int track); 00949 00964 int quicktime_video_depth(quicktime_t *file, int track); 00965 00980 double quicktime_frame_rate(quicktime_t *file, int track); 00981 00992 char* quicktime_video_compressor(quicktime_t *file, int track); 00993 00994 /* number of bytes of raw data in this frame */ 00995 01007 long quicktime_frame_size(quicktime_t *file, long frame, int track); 01008 01018 int quicktime_channel_location(quicktime_t *file, int *quicktime_track, int *quicktime_channel, int channel); 01019 01020 /* file positioning */ 01021 /* Remove these and see what happens :) */ 01022 01023 // int quicktime_seek_end(quicktime_t *file); 01024 01033 int quicktime_seek_start(quicktime_t *file); 01034 01035 /* set position of file descriptor relative to a track */ 01036 01045 int quicktime_set_audio_position(quicktime_t *file, int64_t sample, int track); 01046 01057 int quicktime_set_video_position(quicktime_t *file, int64_t frame, int track); 01058 01059 /* ========================== Access to raw data follows. */ 01060 /* write data for one quicktime track */ 01061 /* the user must handle conversion to the channels in this track */ 01062 int quicktime_write_audio(quicktime_t *file, uint8_t *audio_buffer, long samples, int track); 01063 01078 int quicktime_write_frame(quicktime_t *file, uint8_t *video_buffer, int64_t bytes, int track); 01079 01092 long quicktime_read_frame(quicktime_t *file, unsigned char *video_buffer, int track); 01093 01094 /* for reading frame using a library that needs a file descriptor */ 01095 /* Frame caching doesn't work here. */ 01096 int quicktime_read_frame_init(quicktime_t *file, int track); 01097 int quicktime_read_frame_end(quicktime_t *file, int track); 01098 01099 /* One keyframe table for each track */ 01100 long quicktime_get_keyframe_before(quicktime_t *file, long frame, int track); 01101 void quicktime_insert_keyframe(quicktime_t *file, long frame, int track); 01102 /* Track has keyframes */ 01103 int quicktime_has_keyframes(quicktime_t *file, int track); 01104 01105 /* ===================== Access to built in codecs follows. */ 01106 01107 /* If the codec for this track is supported in the library return 1. */ 01108 01116 int quicktime_supported_video(quicktime_t *file, int track); 01117 01125 int quicktime_supported_audio(quicktime_t *file, int track); 01126 01138 int quicktime_reads_cmodel(quicktime_t *file, 01139 int colormodel, 01140 int track); 01141 01153 int quicktime_writes_cmodel(quicktime_t *file, 01154 int colormodel, 01155 int track); 01156 01157 01158 /* Hacks for temporal codec */ 01159 int quicktime_divx_is_key(unsigned char *data, long size); 01160 int quicktime_divx_write_vol(unsigned char *data_start, 01161 int vol_width, 01162 int vol_height, 01163 int time_increment_resolution, 01164 double frame_rate); 01165 int quicktime_divx_has_vol(unsigned char *data); 01166 01167 int quicktime_div3_is_key(unsigned char *data, long size); 01168 01179 int quicktime_encode_video(quicktime_t *file, 01180 unsigned char **row_pointers, 01181 int track); 01182 01193 int quicktime_decode_video(quicktime_t *file, 01194 unsigned char **row_pointers, 01195 int track); 01196 01217 long quicktime_decode_scaled(quicktime_t *file, 01218 int in_x, /* Location of input frame to take picture */ 01219 int in_y, 01220 int in_w, 01221 int in_h, 01222 int out_w, /* Dimensions of output frame */ 01223 int out_h, 01224 int color_model, /* One of the color models defined above */ 01225 unsigned char **row_pointers, 01226 int track); 01227 01228 /* Decode or encode audio for a single channel into the buffer. */ 01229 /* Pass a buffer for the _i or the _f argument if you want int16 or float data. */ 01230 /* Notice that encoding requires an array of pointers to each channel. */ 01231 01249 int quicktime_decode_audio(quicktime_t *file, int16_t *output_i, float *output_f, long samples, int channel); 01250 01263 int quicktime_encode_audio(quicktime_t *file, int16_t **input_i, float **input_f, long samples); 01264 01272 int quicktime_dump(quicktime_t *file); 01273 01274 /* Specify the number of cpus to utilize. */ 01275 01286 int quicktime_set_cpus(quicktime_t *file, int cpus); 01287 01288 /* Specify whether to read contiguously or not. */ 01289 /* preload is the number of bytes to read ahead. */ 01290 /* This is no longer functional to the end user but is used to accelerate */ 01291 /* reading the header internally. */ 01292 void quicktime_set_preload(quicktime_t *file, int64_t preload); 01293 01294 int64_t quicktime_byte_position(quicktime_t *file); 01295 01304 void quicktime_set_avi(quicktime_t *file, int value); 01305 01306 #pragma GCC visibility pop 01307 01308 01309 #ifdef __cplusplus 01310 } 01311 #endif 01312 01313 #endif