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_V308 "v308" 00445 00452 #define QUICKTIME_V408 "v408" 00453 00460 #define QUICKTIME_V210 "v210" 00461 00468 #define QUICKTIME_V410 "v410" 00469 00470 /* =================== Audio formats ======================= */ 00471 00491 #define QUICKTIME_RAWAUDIO "raw " 00492 00499 #define QUICKTIME_IMA4 "ima4" 00500 00507 #define QUICKTIME_TWOS "twos" 00508 00515 #define QUICKTIME_ULAW "ulaw" 00516 00525 #define QUICKTIME_VORBIS "OggS" 00526 00534 #define QUICKTIME_MP3 ".mp3" 00535 00536 /* =========================== public interface ========================= // */ 00537 00546 /* Get version information */ 00547 int quicktime_major(); 00548 00556 int quicktime_minor(); 00557 00566 int quicktime_release(); 00567 00579 int quicktime_check_sig(char *path); 00580 00591 quicktime_t* quicktime_open(const char *filename, int rd, int wr); 00592 00605 int quicktime_make_streamable(char *in_path, char *out_path); 00606 00620 void quicktime_set_copyright(quicktime_t *file, char *string); 00621 00628 void quicktime_set_name(quicktime_t *file, char *string); 00629 00636 void quicktime_set_info(quicktime_t *file, char *string); 00637 00645 char* quicktime_get_copyright(quicktime_t *file); 00646 00654 char* quicktime_get_name(quicktime_t *file); 00655 00662 char* quicktime_get_info(quicktime_t *file); 00663 00664 00680 int quicktime_set_audio(quicktime_t *file, 00681 int channels, 00682 long sample_rate, 00683 int bits, 00684 char *compressor); 00685 00696 void quicktime_set_framerate(quicktime_t *file, double framerate); 00697 00713 int quicktime_set_video(quicktime_t *file, 00714 int tracks, 00715 int frame_w, 00716 int frame_h, 00717 double frame_rate, 00718 char *compressor); 00719 00733 void quicktime_set_jpeg(quicktime_t *file, int quality, int use_float); 00734 00749 void quicktime_set_parameter(quicktime_t *file, char *key, void *value); 00750 00761 void quicktime_set_depth(quicktime_t *file, 00762 int depth, 00763 int track); 00764 00774 void quicktime_set_cmodel(quicktime_t *file, int colormodel); 00775 00786 void quicktime_set_row_span(quicktime_t *file, int row_span); 00787 00793 int quicktime_close(quicktime_t *file); 00794 00795 /* get length information */ 00796 /* channel numbers start on 1 for audio and video */ 00797 00806 long quicktime_audio_length(quicktime_t *file, int track); 00807 00819 long quicktime_video_length(quicktime_t *file, int track); 00820 00828 /* get position information */ 00829 long quicktime_audio_position(quicktime_t *file, int track); 00830 00840 long quicktime_video_position(quicktime_t *file, int track); 00841 00848 /* get file information */ 00849 int quicktime_video_tracks(quicktime_t *file); 00850 00857 int quicktime_audio_tracks(quicktime_t *file); 00858 00865 int quicktime_has_audio(quicktime_t *file); 00866 00874 long quicktime_sample_rate(quicktime_t *file, int track); 00875 00890 int quicktime_audio_bits(quicktime_t *file, int track); 00891 00899 int quicktime_track_channels(quicktime_t *file, int track); 00900 00913 char* quicktime_audio_compressor(quicktime_t *file, int track); 00914 00921 int quicktime_has_video(quicktime_t *file); 00922 00930 int quicktime_video_width(quicktime_t *file, int track); 00931 00939 int quicktime_video_height(quicktime_t *file, int track); 00940 00955 int quicktime_video_depth(quicktime_t *file, int track); 00956 00971 double quicktime_frame_rate(quicktime_t *file, int track); 00972 00983 char* quicktime_video_compressor(quicktime_t *file, int track); 00984 00985 /* number of bytes of raw data in this frame */ 00986 00998 long quicktime_frame_size(quicktime_t *file, long frame, int track); 00999 01009 int quicktime_channel_location(quicktime_t *file, int *quicktime_track, int *quicktime_channel, int channel); 01010 01011 /* file positioning */ 01012 /* Remove these and see what happens :) */ 01013 01014 // int quicktime_seek_end(quicktime_t *file); 01015 01024 int quicktime_seek_start(quicktime_t *file); 01025 01026 /* set position of file descriptor relative to a track */ 01027 01036 int quicktime_set_audio_position(quicktime_t *file, int64_t sample, int track); 01037 01048 int quicktime_set_video_position(quicktime_t *file, int64_t frame, int track); 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