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-2010 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 00121 typedef enum 00122 { 00123 LQT_LOG_ERROR = (1<<0), 00124 LQT_LOG_WARNING = (1<<1), 00125 LQT_LOG_INFO = (1<<2), 00126 LQT_LOG_DEBUG = (1<<3), 00127 } lqt_log_level_t; 00128 00137 typedef void (*lqt_log_callback_t)(lqt_log_level_t level, 00138 const char * domain, 00139 const char * message, 00140 void * data); 00141 00142 00149 typedef enum 00150 { 00151 LQT_FILE_NONE = 0, 00152 LQT_FILE_QT_OLD = (1<<0), 00153 LQT_FILE_QT = (1<<1), 00154 LQT_FILE_AVI = (1<<2), 00155 LQT_FILE_AVI_ODML = (1<<3), 00156 LQT_FILE_MP4 = (1<<4), 00157 LQT_FILE_M4A = (1<<5), 00158 LQT_FILE_3GP = (1<<6), 00159 } lqt_file_type_t; 00160 00161 00172 typedef enum 00173 { 00174 LQT_CHANNEL_UNKNOWN, 00175 LQT_CHANNEL_FRONT_LEFT, 00176 LQT_CHANNEL_FRONT_RIGHT, 00177 LQT_CHANNEL_FRONT_CENTER, 00178 LQT_CHANNEL_FRONT_CENTER_LEFT, 00179 LQT_CHANNEL_FRONT_CENTER_RIGHT, 00180 LQT_CHANNEL_BACK_CENTER, 00181 LQT_CHANNEL_BACK_LEFT, 00182 LQT_CHANNEL_BACK_RIGHT, 00183 LQT_CHANNEL_SIDE_LEFT, 00184 LQT_CHANNEL_SIDE_RIGHT, 00185 LQT_CHANNEL_LFE, 00186 } lqt_channel_t; 00187 00188 00252 typedef enum 00253 { 00254 LQT_INTERLACE_NONE = 0, 00255 LQT_INTERLACE_TOP_FIRST, 00256 LQT_INTERLACE_BOTTOM_FIRST 00257 } lqt_interlace_mode_t; 00258 00268 typedef enum 00269 { 00270 LQT_CHROMA_PLACEMENT_DEFAULT = 0, 00271 LQT_CHROMA_PLACEMENT_MPEG2, 00272 LQT_CHROMA_PLACEMENT_DVPAL, 00273 } lqt_chroma_placement_t; 00274 00284 typedef enum 00285 { 00286 LQT_SAMPLE_UNDEFINED = 0, 00287 LQT_SAMPLE_INT8, 00288 LQT_SAMPLE_UINT8, 00289 LQT_SAMPLE_INT16, 00290 LQT_SAMPLE_INT32, 00291 LQT_SAMPLE_FLOAT, 00292 LQT_SAMPLE_DOUBLE 00293 } lqt_sample_format_t; 00294 00303 typedef struct quicktime_s quicktime_t; 00304 00305 /* This is the reference for all your library entry points. */ 00306 00307 /* ===== compression formats for which codecs exist ====== */ 00308 00328 #define QUICKTIME_DIVX "DIVX" 00329 00336 #define QUICKTIME_DIV3 "DIV3" 00337 00344 #define QUICKTIME_DV "dvc " 00345 /* AVID DV codec can be processed with libdv as well */ 00346 00353 #define QUICKTIME_DV_AVID "AVdv" 00354 00361 #define QUICKTIME_DV_AVID_A "dvcp" 00362 00370 /* RGB uncompressed. Allows alpha */ 00371 #define QUICKTIME_RAW "raw " 00372 00379 /* Jpeg Photo */ 00380 #define QUICKTIME_JPEG "jpeg" 00381 00382 /* Concatenated png images. Allows alpha */ 00383 00391 #define QUICKTIME_PNG "png " 00392 00400 #define QUICKTIME_MJPA "mjpa" 00401 00408 #define QUICKTIME_YUV2 "yuv2" 00409 00416 #define QUICKTIME_YUV4 "yuv4" 00417 00425 #define QUICKTIME_YUV420 "yv12" 00426 00433 #define QUICKTIME_2VUY "2vuy" 00434 00441 #define QUICKTIME_V308 "v308" 00442 00449 #define QUICKTIME_V408 "v408" 00450 00457 #define QUICKTIME_V210 "v210" 00458 00465 #define QUICKTIME_V410 "v410" 00466 00467 /* =================== Audio formats ======================= */ 00468 00488 #define QUICKTIME_RAWAUDIO "raw " 00489 00496 #define QUICKTIME_IMA4 "ima4" 00497 00504 #define QUICKTIME_TWOS "twos" 00505 00512 #define QUICKTIME_ULAW "ulaw" 00513 00522 #define QUICKTIME_VORBIS "OggS" 00523 00531 #define QUICKTIME_MP3 ".mp3" 00532 00533 /* =========================== public interface ========================= // */ 00534 00543 /* Get version information */ 00544 int quicktime_major(); 00545 00553 int quicktime_minor(); 00554 00563 int quicktime_release(); 00564 00576 int quicktime_check_sig(char *path); 00577 00588 quicktime_t* quicktime_open(const char *filename, int rd, int wr); 00589 00602 int quicktime_make_streamable(char *in_path, char *out_path); 00603 00617 void quicktime_set_copyright(quicktime_t *file, char *string); 00618 00625 void quicktime_set_name(quicktime_t *file, char *string); 00626 00633 void quicktime_set_info(quicktime_t *file, char *string); 00634 00642 char* quicktime_get_copyright(quicktime_t *file); 00643 00651 char* quicktime_get_name(quicktime_t *file); 00652 00659 char* quicktime_get_info(quicktime_t *file); 00660 00661 00677 int quicktime_set_audio(quicktime_t *file, 00678 int channels, 00679 long sample_rate, 00680 int bits, 00681 char *compressor); 00682 00693 void quicktime_set_framerate(quicktime_t *file, double framerate); 00694 00710 int quicktime_set_video(quicktime_t *file, 00711 int tracks, 00712 int frame_w, 00713 int frame_h, 00714 double frame_rate, 00715 char *compressor); 00716 00730 void quicktime_set_jpeg(quicktime_t *file, int quality, int use_float); 00731 00746 void quicktime_set_parameter(quicktime_t *file, char *key, void *value); 00747 00758 void quicktime_set_depth(quicktime_t *file, 00759 int depth, 00760 int track); 00761 00771 void quicktime_set_cmodel(quicktime_t *file, int colormodel); 00772 00783 void quicktime_set_row_span(quicktime_t *file, int row_span); 00784 00790 int quicktime_close(quicktime_t *file); 00791 00792 /* get length information */ 00793 /* channel numbers start on 1 for audio and video */ 00794 00803 long quicktime_audio_length(quicktime_t *file, int track); 00804 00816 long quicktime_video_length(quicktime_t *file, int track); 00817 00825 /* get position information */ 00826 long quicktime_audio_position(quicktime_t *file, int track); 00827 00837 long quicktime_video_position(quicktime_t *file, int track); 00838 00845 /* get file information */ 00846 int quicktime_video_tracks(quicktime_t *file); 00847 00854 int quicktime_audio_tracks(quicktime_t *file); 00855 00862 int quicktime_has_audio(quicktime_t *file); 00863 00871 long quicktime_sample_rate(quicktime_t *file, int track); 00872 00887 int quicktime_audio_bits(quicktime_t *file, int track); 00888 00896 int quicktime_track_channels(quicktime_t *file, int track); 00897 00910 char* quicktime_audio_compressor(quicktime_t *file, int track); 00911 00918 int quicktime_has_video(quicktime_t *file); 00919 00927 int quicktime_video_width(quicktime_t *file, int track); 00928 00936 int quicktime_video_height(quicktime_t *file, int track); 00937 00952 int quicktime_video_depth(quicktime_t *file, int track); 00953 00968 double quicktime_frame_rate(quicktime_t *file, int track); 00969 00980 char* quicktime_video_compressor(quicktime_t *file, int track); 00981 00982 /* number of bytes of raw data in this frame */ 00983 00995 long quicktime_frame_size(quicktime_t *file, long frame, int track); 00996 01006 int quicktime_channel_location(quicktime_t *file, int *quicktime_track, int *quicktime_channel, int channel); 01007 01008 /* file positioning */ 01009 /* Remove these and see what happens :) */ 01010 01011 // int quicktime_seek_end(quicktime_t *file); 01012 01021 int quicktime_seek_start(quicktime_t *file); 01022 01023 /* set position of file descriptor relative to a track */ 01024 01033 int quicktime_set_audio_position(quicktime_t *file, int64_t sample, int track); 01034 01045 int quicktime_set_video_position(quicktime_t *file, int64_t frame, int track); 01046 01047 /* set window data */ 01048 void quicktime_set_window(quicktime_t *file, int in_x, int in_y, int in_w, int in_h, int out_w, int out_h); 01049 01050 /* ========================== Access to raw data follows. */ 01051 /* write data for one quicktime track */ 01052 /* the user must handle conversion to the channels in this track */ 01053 int quicktime_write_audio(quicktime_t *file, uint8_t *audio_buffer, long samples, int track); 01054 01069 int quicktime_write_frame(quicktime_t *file, uint8_t *video_buffer, int64_t bytes, int track); 01070 01083 long quicktime_read_frame(quicktime_t *file, unsigned char *video_buffer, int track); 01084 01085 /* for reading frame using a library that needs a file descriptor */ 01086 /* Frame caching doesn't work here. */ 01087 int quicktime_read_frame_init(quicktime_t *file, int track); 01088 int quicktime_read_frame_end(quicktime_t *file, int track); 01089 01090 /* One keyframe table for each track */ 01091 long quicktime_get_keyframe_before(quicktime_t *file, long frame, int track); 01092 void quicktime_insert_keyframe(quicktime_t *file, long frame, int track); 01093 /* Track has keyframes */ 01094 int quicktime_has_keyframes(quicktime_t *file, int track); 01095 01096 /* ===================== Access to built in codecs follows. */ 01097 01098 /* If the codec for this track is supported in the library return 1. */ 01099 01107 int quicktime_supported_video(quicktime_t *file, int track); 01108 01116 int quicktime_supported_audio(quicktime_t *file, int track); 01117 01129 int quicktime_reads_cmodel(quicktime_t *file, 01130 int colormodel, 01131 int track); 01132 01144 int quicktime_writes_cmodel(quicktime_t *file, 01145 int colormodel, 01146 int track); 01147 01148 01149 /* Hacks for temporal codec */ 01150 int quicktime_divx_is_key(unsigned char *data, long size); 01151 int quicktime_divx_write_vol(unsigned char *data_start, 01152 int vol_width, 01153 int vol_height, 01154 int time_increment_resolution, 01155 double frame_rate); 01156 int quicktime_divx_has_vol(unsigned char *data); 01157 01158 int quicktime_div3_is_key(unsigned char *data, long size); 01159 01170 int quicktime_encode_video(quicktime_t *file, 01171 unsigned char **row_pointers, 01172 int track); 01173 01184 int quicktime_decode_video(quicktime_t *file, 01185 unsigned char **row_pointers, 01186 int track); 01187 01208 long quicktime_decode_scaled(quicktime_t *file, 01209 int in_x, /* Location of input frame to take picture */ 01210 int in_y, 01211 int in_w, 01212 int in_h, 01213 int out_w, /* Dimensions of output frame */ 01214 int out_h, 01215 int color_model, /* One of the color models defined above */ 01216 unsigned char **row_pointers, 01217 int track); 01218 01219 /* Decode or encode audio for a single channel into the buffer. */ 01220 /* Pass a buffer for the _i or the _f argument if you want int16 or float data. */ 01221 /* Notice that encoding requires an array of pointers to each channel. */ 01222 01240 int quicktime_decode_audio(quicktime_t *file, int16_t *output_i, float *output_f, long samples, int channel); 01241 01254 int quicktime_encode_audio(quicktime_t *file, int16_t **input_i, float **input_f, long samples); 01255 01263 int quicktime_dump(quicktime_t *file); 01264 01265 /* Specify the number of cpus to utilize. */ 01266 01277 int quicktime_set_cpus(quicktime_t *file, int cpus); 01278 01279 /* Specify whether to read contiguously or not. */ 01280 /* preload is the number of bytes to read ahead. */ 01281 /* This is no longer functional to the end user but is used to accelerate */ 01282 /* reading the header internally. */ 01283 void quicktime_set_preload(quicktime_t *file, int64_t preload); 01284 01285 int64_t quicktime_byte_position(quicktime_t *file); 01286 01295 void quicktime_set_avi(quicktime_t *file, int value); 01296 01297 #pragma GCC visibility pop 01298 01299 01300 #ifdef __cplusplus 01301 } 01302 #endif 01303 01304 #endif