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 #ifdef __GNUC__ 00036 #pragma GCC visibility push(default) 00037 #endif 00038 00039 /* Some public enums needed by most subsequent headers */ 00040 00041 typedef struct lqt_codec_info_s lqt_codec_info_t; 00042 00043 00126 typedef enum 00127 { 00128 LQT_LOG_ERROR = (1<<0), 00129 LQT_LOG_WARNING = (1<<1), 00130 LQT_LOG_INFO = (1<<2), 00131 LQT_LOG_DEBUG = (1<<3), 00132 } lqt_log_level_t; 00133 00142 typedef void (*lqt_log_callback_t)(lqt_log_level_t level, 00143 const char * domain, 00144 const char * message, 00145 void * data); 00146 00147 00154 typedef enum 00155 { 00156 LQT_FILE_NONE = 0, 00157 LQT_FILE_QT_OLD = (1<<0), 00158 LQT_FILE_QT = (1<<1), 00159 LQT_FILE_AVI = (1<<2), 00160 LQT_FILE_AVI_ODML = (1<<3), 00161 LQT_FILE_MP4 = (1<<4), 00162 LQT_FILE_M4A = (1<<5), 00163 LQT_FILE_3GP = (1<<6), 00164 } lqt_file_type_t; 00165 00166 00177 typedef enum 00178 { 00179 LQT_CHANNEL_UNKNOWN, 00180 LQT_CHANNEL_FRONT_LEFT, 00181 LQT_CHANNEL_FRONT_RIGHT, 00182 LQT_CHANNEL_FRONT_CENTER, 00183 LQT_CHANNEL_FRONT_CENTER_LEFT, 00184 LQT_CHANNEL_FRONT_CENTER_RIGHT, 00185 LQT_CHANNEL_BACK_CENTER, 00186 LQT_CHANNEL_BACK_LEFT, 00187 LQT_CHANNEL_BACK_RIGHT, 00188 LQT_CHANNEL_SIDE_LEFT, 00189 LQT_CHANNEL_SIDE_RIGHT, 00190 LQT_CHANNEL_LFE, 00191 } lqt_channel_t; 00192 00193 00257 typedef enum 00258 { 00259 LQT_INTERLACE_NONE = 0, 00260 LQT_INTERLACE_TOP_FIRST, 00261 LQT_INTERLACE_BOTTOM_FIRST 00262 } lqt_interlace_mode_t; 00263 00273 typedef enum 00274 { 00275 LQT_CHROMA_PLACEMENT_DEFAULT = 0, 00276 LQT_CHROMA_PLACEMENT_MPEG2, 00277 LQT_CHROMA_PLACEMENT_DVPAL, 00278 } lqt_chroma_placement_t; 00279 00289 typedef enum 00290 { 00291 LQT_SAMPLE_UNDEFINED = 0, 00292 LQT_SAMPLE_INT8, 00293 LQT_SAMPLE_UINT8, 00294 LQT_SAMPLE_INT16, 00295 LQT_SAMPLE_INT32, 00296 LQT_SAMPLE_FLOAT, 00297 LQT_SAMPLE_DOUBLE, 00298 } lqt_sample_format_t; 00299 00308 typedef struct quicktime_s quicktime_t; 00309 00310 /* This is the reference for all your library entry points. */ 00311 00312 /* ===== compression formats for which codecs exist ====== */ 00313 00333 #define QUICKTIME_DIVX "DIVX" 00334 00341 #define QUICKTIME_DIV3 "DIV3" 00342 00349 #define QUICKTIME_DV "dvc " 00350 /* AVID DV codec can be processed with libdv as well */ 00351 00358 #define QUICKTIME_DV_AVID "AVdv" 00359 00366 #define QUICKTIME_DV_AVID_A "dvcp" 00367 00375 /* RGB uncompressed. Allows alpha */ 00376 #define QUICKTIME_RAW "raw " 00377 00384 /* Jpeg Photo */ 00385 #define QUICKTIME_JPEG "jpeg" 00386 00387 /* Concatenated png images. Allows alpha */ 00388 00396 #define QUICKTIME_PNG "png " 00397 00405 #define QUICKTIME_MJPA "mjpa" 00406 00413 #define QUICKTIME_YUV2 "yuv2" 00414 00421 #define QUICKTIME_YUV4 "yuv4" 00422 00430 #define QUICKTIME_YUV420 "yv12" 00431 00438 #define QUICKTIME_2VUY "2vuy" 00439 00446 #define QUICKTIME_YUVS "yuvs" 00447 00448 00455 #define QUICKTIME_V308 "v308" 00456 00463 #define QUICKTIME_V408 "v408" 00464 00471 #define QUICKTIME_V210 "v210" 00472 00479 #define QUICKTIME_V410 "v410" 00480 00481 /* =================== Audio formats ======================= */ 00482 00502 #define QUICKTIME_RAWAUDIO "raw " 00503 00510 #define QUICKTIME_IMA4 "ima4" 00511 00518 #define QUICKTIME_TWOS "twos" 00519 00526 #define QUICKTIME_ULAW "ulaw" 00527 00536 #define QUICKTIME_VORBIS "OggS" 00537 00545 #define QUICKTIME_MP3 ".mp3" 00546 00547 /* =========================== public interface ========================= // */ 00548 00557 /* Get version information */ 00558 int quicktime_major(); 00559 00567 int quicktime_minor(); 00568 00577 int quicktime_release(); 00578 00590 int quicktime_check_sig(char *path); 00591 00602 quicktime_t* quicktime_open(const char *filename, int rd, int wr); 00603 00616 int quicktime_make_streamable(char *in_path, char *out_path); 00617 00631 void quicktime_set_copyright(quicktime_t *file, char *string); 00632 00639 void quicktime_set_name(quicktime_t *file, char *string); 00640 00647 void quicktime_set_info(quicktime_t *file, char *string); 00648 00656 char* quicktime_get_copyright(quicktime_t *file); 00657 00665 char* quicktime_get_name(quicktime_t *file); 00666 00673 char* quicktime_get_info(quicktime_t *file); 00674 00675 00691 int quicktime_set_audio(quicktime_t *file, 00692 int channels, 00693 long sample_rate, 00694 int bits, 00695 char *compressor); 00696 00707 void quicktime_set_framerate(quicktime_t *file, double framerate); 00708 00724 int quicktime_set_video(quicktime_t *file, 00725 int tracks, 00726 int frame_w, 00727 int frame_h, 00728 double frame_rate, 00729 char *compressor); 00730 00744 void quicktime_set_jpeg(quicktime_t *file, int quality, int use_float); 00745 00760 void quicktime_set_parameter(quicktime_t *file, char *key, void *value); 00761 00772 void quicktime_set_depth(quicktime_t *file, 00773 int depth, 00774 int track); 00775 00785 void quicktime_set_cmodel(quicktime_t *file, int colormodel); 00786 00797 void quicktime_set_row_span(quicktime_t *file, int row_span); 00798 00804 int quicktime_close(quicktime_t *file); 00805 00806 /* get length information */ 00807 /* channel numbers start on 1 for audio and video */ 00808 00817 long quicktime_audio_length(quicktime_t *file, int track); 00818 00830 long quicktime_video_length(quicktime_t *file, int track); 00831 00839 /* get position information */ 00840 long quicktime_audio_position(quicktime_t *file, int track); 00841 00851 long quicktime_video_position(quicktime_t *file, int track); 00852 00859 /* get file information */ 00860 int quicktime_video_tracks(quicktime_t *file); 00861 00868 int quicktime_audio_tracks(quicktime_t *file); 00869 00876 int quicktime_has_audio(quicktime_t *file); 00877 00885 long quicktime_sample_rate(quicktime_t *file, int track); 00886 00901 int quicktime_audio_bits(quicktime_t *file, int track); 00902 00910 int quicktime_track_channels(quicktime_t *file, int track); 00911 00924 char* quicktime_audio_compressor(quicktime_t *file, int track); 00925 00932 int quicktime_has_video(quicktime_t *file); 00933 00941 int quicktime_video_width(quicktime_t *file, int track); 00942 00950 int quicktime_video_height(quicktime_t *file, int track); 00951 00966 int quicktime_video_depth(quicktime_t *file, int track); 00967 00982 double quicktime_frame_rate(quicktime_t *file, int track); 00983 00994 char* quicktime_video_compressor(quicktime_t *file, int track); 00995 00996 /* number of bytes of raw data in this frame */ 00997 01009 long quicktime_frame_size(quicktime_t *file, long frame, int track); 01010 01020 int quicktime_channel_location(quicktime_t *file, int *quicktime_track, int *quicktime_channel, int channel); 01021 01022 /* file positioning */ 01023 /* Remove these and see what happens :) */ 01024 01025 // int quicktime_seek_end(quicktime_t *file); 01026 01035 int quicktime_seek_start(quicktime_t *file); 01036 01037 /* set position of file descriptor relative to a track */ 01038 01047 int quicktime_set_audio_position(quicktime_t *file, int64_t sample, int track); 01048 01059 int quicktime_set_video_position(quicktime_t *file, int64_t frame, int track); 01060 01061 /* ========================== Access to raw data follows. */ 01062 /* write data for one quicktime track */ 01063 /* the user must handle conversion to the channels in this track */ 01064 int quicktime_write_audio(quicktime_t *file, uint8_t *audio_buffer, long samples, int track); 01065 01081 int quicktime_write_frame(quicktime_t *file, uint8_t *video_buffer, int64_t bytes, int track); 01082 01098 long quicktime_read_frame(quicktime_t *file, unsigned char *video_buffer, int track); 01099 01100 /* for reading frame using a library that needs a file descriptor */ 01101 /* Frame caching doesn't work here. */ 01102 int quicktime_read_frame_init(quicktime_t *file, int track); 01103 int quicktime_read_frame_end(quicktime_t *file, int track); 01104 01105 /* One keyframe table for each track */ 01106 long quicktime_get_keyframe_before(quicktime_t *file, long frame, int track); 01107 long quicktime_get_partial_keyframe_before(quicktime_t *file, long frame, int track); 01108 void quicktime_insert_keyframe(quicktime_t *file, long frame, int track); 01109 void quicktime_insert_partial_keyframe(quicktime_t *file, long frame, int track); 01110 /* Track has keyframes */ 01111 int quicktime_has_keyframes(quicktime_t *file, int track); 01112 01113 /* Sample dependencies for long-GOP formats. */ 01114 void quicktime_insert_sdtp_entry(quicktime_t *file, long frame, int track, uint8_t flags); 01115 01116 /* ===================== Access to built in codecs follows. */ 01117 01118 /* If the codec for this track is supported in the library return 1. */ 01119 01127 int quicktime_supported_video(quicktime_t *file, int track); 01128 01136 int quicktime_supported_audio(quicktime_t *file, int track); 01137 01149 int quicktime_reads_cmodel(quicktime_t *file, 01150 int colormodel, 01151 int track); 01152 01164 int quicktime_writes_cmodel(quicktime_t *file, 01165 int colormodel, 01166 int track); 01167 01168 01169 /* Hacks for temporal codec */ 01170 int quicktime_divx_is_key(unsigned char *data, long size); 01171 int quicktime_divx_write_vol(unsigned char *data_start, 01172 int vol_width, 01173 int vol_height, 01174 int time_increment_resolution, 01175 double frame_rate); 01176 int quicktime_divx_has_vol(unsigned char *data); 01177 01178 int quicktime_div3_is_key(unsigned char *data, long size); 01179 01190 int quicktime_encode_video(quicktime_t *file, 01191 unsigned char **row_pointers, 01192 int track); 01193 01204 int quicktime_decode_video(quicktime_t *file, 01205 unsigned char **row_pointers, 01206 int track); 01207 01228 long quicktime_decode_scaled(quicktime_t *file, 01229 int in_x, /* Location of input frame to take picture */ 01230 int in_y, 01231 int in_w, 01232 int in_h, 01233 int out_w, /* Dimensions of output frame */ 01234 int out_h, 01235 int color_model, /* One of the color models defined above */ 01236 unsigned char **row_pointers, 01237 int track); 01238 01239 /* Decode or encode audio for a single channel into the buffer. */ 01240 /* Pass a buffer for the _i or the _f argument if you want int16 or float data. */ 01241 /* Notice that encoding requires an array of pointers to each channel. */ 01242 01260 int quicktime_decode_audio(quicktime_t *file, int16_t *output_i, float *output_f, long samples, int channel); 01261 01274 int quicktime_encode_audio(quicktime_t *file, int16_t **input_i, float **input_f, long samples); 01275 01283 int quicktime_dump(quicktime_t *file); 01284 01285 /* Specify the number of cpus to utilize. */ 01286 01297 int quicktime_set_cpus(quicktime_t *file, int cpus); 01298 01299 /* Specify whether to read contiguously or not. */ 01300 /* preload is the number of bytes to read ahead. */ 01301 /* This is no longer functional to the end user but is used to accelerate */ 01302 /* reading the header internally. */ 01303 void quicktime_set_preload(quicktime_t *file, int64_t preload); 01304 01305 int64_t quicktime_byte_position(quicktime_t *file); 01306 01315 void quicktime_set_avi(quicktime_t *file, int value); 01316 01317 #ifdef __GNUC__ 01318 #pragma GCC visibility pop 01319 #endif 01320 01321 01322 #ifdef __cplusplus 01323 } 01324 #endif 01325 01326 #endif