quicktime.h

Go to the documentation of this file.
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-2007 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 /* Some public enums needed by most subsequent headers */
00036 
00119 typedef enum
00120   {
00121     LQT_LOG_ERROR   = (1<<0),
00122     LQT_LOG_WARNING = (1<<1),
00123     LQT_LOG_INFO    = (1<<2),
00124     LQT_LOG_DEBUG   = (1<<3),
00125   } lqt_log_level_t;
00126 
00135 typedef void (*lqt_log_callback_t)(lqt_log_level_t level,
00136                                    const char * domain,
00137                                    const char * message,
00138                                    void * data);
00139 
00140   
00147 typedef enum
00148   {
00149     LQT_FILE_NONE = 0,        
00150     LQT_FILE_QT_OLD   = (1<<0), 
00151     LQT_FILE_QT       = (1<<1), 
00152     LQT_FILE_AVI      = (1<<2), 
00153     LQT_FILE_AVI_ODML = (1<<3), 
00154     LQT_FILE_MP4      = (1<<4), 
00155     LQT_FILE_M4A      = (1<<5), 
00156     LQT_FILE_3GP      = (1<<6), 
00157   } lqt_file_type_t;
00158 
00159   
00170 typedef enum 
00171   {
00172     LQT_CHANNEL_UNKNOWN,
00173     LQT_CHANNEL_FRONT_LEFT,
00174     LQT_CHANNEL_FRONT_RIGHT,
00175     LQT_CHANNEL_FRONT_CENTER,
00176     LQT_CHANNEL_FRONT_CENTER_LEFT,
00177     LQT_CHANNEL_FRONT_CENTER_RIGHT,
00178     LQT_CHANNEL_BACK_CENTER,
00179     LQT_CHANNEL_BACK_LEFT,
00180     LQT_CHANNEL_BACK_RIGHT,
00181     LQT_CHANNEL_SIDE_LEFT,
00182     LQT_CHANNEL_SIDE_RIGHT,
00183     LQT_CHANNEL_LFE,
00184   } lqt_channel_t;
00185 
00186   
00250 typedef enum 
00251   {
00252     LQT_INTERLACE_NONE = 0, 
00253     LQT_INTERLACE_TOP_FIRST, 
00254     LQT_INTERLACE_BOTTOM_FIRST  
00255   } lqt_interlace_mode_t;
00256 
00266 typedef enum 
00267   {
00268     LQT_CHROMA_PLACEMENT_DEFAULT = 0, 
00269     LQT_CHROMA_PLACEMENT_MPEG2,       
00270     LQT_CHROMA_PLACEMENT_DVPAL,       
00271   } lqt_chroma_placement_t;
00272 
00282 typedef enum 
00283   {
00284     LQT_SAMPLE_UNDEFINED = 0, 
00285     LQT_SAMPLE_INT8,      
00286     LQT_SAMPLE_UINT8,     
00287     LQT_SAMPLE_INT16,     
00288     LQT_SAMPLE_INT32,     
00289     LQT_SAMPLE_FLOAT,     
00290     LQT_SAMPLE_DOUBLE     
00291   } lqt_sample_format_t;
00292   
00301 typedef struct quicktime_s quicktime_t;
00302   
00303 /* This is the reference for all your library entry points. */
00304 
00305 /* ===== compression formats for which codecs exist ====== */
00306 
00326 #define QUICKTIME_DIVX "DIVX"
00327 
00334 #define QUICKTIME_DIV3 "DIV3"
00335 
00342 #define QUICKTIME_DV "dvc "
00343 /* AVID DV codec can be processed with libdv as well */
00344 
00351 #define QUICKTIME_DV_AVID "AVdv"
00352 
00359 #define QUICKTIME_DV_AVID_A "dvcp"
00360 
00368 /* RGB uncompressed.  Allows alpha */
00369 #define QUICKTIME_RAW  "raw "
00370 
00377 /* Jpeg Photo */
00378 #define QUICKTIME_JPEG "jpeg"
00379 
00380 /* Concatenated png images.  Allows alpha */
00381 
00389 #define QUICKTIME_PNG "png "
00390 
00398 #define QUICKTIME_MJPA "mjpa"
00399 
00406 #define QUICKTIME_YUV2 "yuv2"
00407 
00414 #define QUICKTIME_YUV4 "yuv4"
00415 
00423 #define QUICKTIME_YUV420  "yv12"
00424 
00431 #define QUICKTIME_2VUY "2vuy"
00432 
00439 #define QUICKTIME_V308  "v308"
00440 
00447 #define QUICKTIME_V408 "v408"
00448 
00455 #define QUICKTIME_V210 "v210"
00456 
00463 #define QUICKTIME_V410 "v410"
00464 
00465 /* =================== Audio formats ======================= */
00466 
00486 #define QUICKTIME_RAWAUDIO "raw "
00487 
00494 #define QUICKTIME_IMA4 "ima4"
00495 
00502 #define QUICKTIME_TWOS "twos"
00503 
00510 #define QUICKTIME_ULAW "ulaw"
00511 
00520 #define QUICKTIME_VORBIS "OggS"
00521 
00529 #define QUICKTIME_MP3 ".mp3"
00530   
00531 /* =========================== public interface ========================= // */
00532 
00541   /* Get version information */
00542 int quicktime_major();
00543 
00551 int quicktime_minor();
00552 
00561 int quicktime_release();
00562 
00574 int quicktime_check_sig(char *path);
00575 
00586 quicktime_t* quicktime_open(const char *filename, int rd, int wr);
00587 
00600 int quicktime_make_streamable(char *in_path, char *out_path);
00601 
00615 void quicktime_set_copyright(quicktime_t *file, char *string);
00616 
00623 void quicktime_set_name(quicktime_t *file, char *string);
00624 
00631 void quicktime_set_info(quicktime_t *file, char *string);
00632 
00640 char* quicktime_get_copyright(quicktime_t *file);
00641 
00649 char* quicktime_get_name(quicktime_t *file);
00650 
00657 char* quicktime_get_info(quicktime_t *file);
00658 
00659 
00675 int quicktime_set_audio(quicktime_t *file, 
00676         int channels, 
00677         long sample_rate, 
00678         int bits, 
00679         char *compressor);
00680 
00691 void quicktime_set_framerate(quicktime_t *file, double framerate);
00692 
00708 int quicktime_set_video(quicktime_t *file, 
00709         int tracks, 
00710         int frame_w, 
00711         int frame_h, 
00712         double frame_rate, 
00713         char *compressor);
00714 
00728 void quicktime_set_jpeg(quicktime_t *file, int quality, int use_float);
00729 
00744 void quicktime_set_parameter(quicktime_t *file, char *key, void *value);
00745 
00756 void quicktime_set_depth(quicktime_t *file, 
00757         int depth, 
00758         int track);
00759 
00769 void quicktime_set_cmodel(quicktime_t *file, int colormodel);
00770 
00781 void quicktime_set_row_span(quicktime_t *file, int row_span);
00782 
00788 int quicktime_close(quicktime_t *file);
00789 
00790 /* get length information */
00791 /* channel numbers start on 1 for audio and video */
00792 
00801 long quicktime_audio_length(quicktime_t *file, int track);
00802 
00814 long quicktime_video_length(quicktime_t *file, int track);
00815 
00823   /* get position information */
00824 long quicktime_audio_position(quicktime_t *file, int track);
00825 
00835 long quicktime_video_position(quicktime_t *file, int track);
00836 
00843 /* get file information */
00844 int quicktime_video_tracks(quicktime_t *file);
00845 
00852 int quicktime_audio_tracks(quicktime_t *file);
00853 
00860 int quicktime_has_audio(quicktime_t *file);
00861 
00869 long quicktime_sample_rate(quicktime_t *file, int track);
00870 
00885 int quicktime_audio_bits(quicktime_t *file, int track);
00886 
00894 int quicktime_track_channels(quicktime_t *file, int track);
00895 
00908 char* quicktime_audio_compressor(quicktime_t *file, int track);
00909 
00916 int quicktime_has_video(quicktime_t *file);
00917 
00925 int quicktime_video_width(quicktime_t *file, int track);
00926 
00934 int quicktime_video_height(quicktime_t *file, int track);
00935 
00950 int quicktime_video_depth(quicktime_t *file, int track);
00951 
00966 double quicktime_frame_rate(quicktime_t *file, int track);
00967 
00978 char* quicktime_video_compressor(quicktime_t *file, int track);
00979 
00980 /* number of bytes of raw data in this frame */
00981 
00993 long quicktime_frame_size(quicktime_t *file, long frame, int track);
00994 
01004 int quicktime_channel_location(quicktime_t *file, int *quicktime_track, int *quicktime_channel, int channel);
01005 
01006 /* file positioning */
01007 /* Remove these and see what happens :) */
01008 
01009 // int quicktime_seek_end(quicktime_t *file);
01010 
01019 int quicktime_seek_start(quicktime_t *file);
01020 
01021 /* set position of file descriptor relative to a track */
01022 
01031 int quicktime_set_audio_position(quicktime_t *file, int64_t sample, int track);
01032 
01043 int quicktime_set_video_position(quicktime_t *file, int64_t frame, int track);
01044 
01045 /* set window data */
01046 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);
01047 
01048 /* ========================== Access to raw data follows. */
01049 /* write data for one quicktime track */
01050 /* the user must handle conversion to the channels in this track */
01051 int quicktime_write_audio(quicktime_t *file, uint8_t *audio_buffer, long samples, int track);
01052 
01067 int quicktime_write_frame(quicktime_t *file, uint8_t *video_buffer, int64_t bytes, int track);
01068 
01081 long quicktime_read_frame(quicktime_t *file, unsigned char *video_buffer, int track);
01082 
01083 /* for reading frame using a library that needs a file descriptor */
01084 /* Frame caching doesn't work here. */
01085 int quicktime_read_frame_init(quicktime_t *file, int track);
01086 int quicktime_read_frame_end(quicktime_t *file, int track);
01087 
01088 /* One keyframe table for each track */
01089 long quicktime_get_keyframe_before(quicktime_t *file, long frame, int track);
01090 void quicktime_insert_keyframe(quicktime_t *file, long frame, int track);
01091 /* Track has keyframes */
01092 int quicktime_has_keyframes(quicktime_t *file, int track);
01093 
01094 /* ===================== Access to built in codecs follows. */
01095 
01096 /* If the codec for this track is supported in the library return 1. */
01097 
01105 int quicktime_supported_video(quicktime_t *file, int track);
01106 
01114 int quicktime_supported_audio(quicktime_t *file, int track);
01115 
01127 int quicktime_reads_cmodel(quicktime_t *file, 
01128                 int colormodel, 
01129                 int track);
01130 
01142 int quicktime_writes_cmodel(quicktime_t *file, 
01143                 int colormodel, 
01144                 int track);
01145 
01146 
01147 /* Hacks for temporal codec */
01148 int quicktime_divx_is_key(unsigned char *data, long size);
01149 int quicktime_divx_write_vol(unsigned char *data_start,
01150         int vol_width, 
01151         int vol_height, 
01152         int time_increment_resolution, 
01153         double frame_rate);
01154 int quicktime_divx_has_vol(unsigned char *data);
01155 
01156 int quicktime_div3_is_key(unsigned char *data, long size);
01157 
01168 int quicktime_encode_video(quicktime_t *file, 
01169         unsigned char **row_pointers, 
01170         int track);
01171 
01182 int quicktime_decode_video(quicktime_t *file, 
01183         unsigned char **row_pointers, 
01184         int track);
01185 
01206 long quicktime_decode_scaled(quicktime_t *file, 
01207         int in_x,                    /* Location of input frame to take picture */
01208         int in_y,
01209         int in_w,
01210         int in_h,
01211         int out_w,                   /* Dimensions of output frame */
01212         int out_h,
01213         int color_model,             /* One of the color models defined above */
01214         unsigned char **row_pointers, 
01215         int track);
01216 
01217 /* Decode or encode audio for a single channel into the buffer. */
01218 /* Pass a buffer for the _i or the _f argument if you want int16 or float data. */
01219 /* Notice that encoding requires an array of pointers to each channel. */
01220 
01238 int quicktime_decode_audio(quicktime_t *file, int16_t *output_i, float *output_f, long samples, int channel);
01239 
01252 int quicktime_encode_audio(quicktime_t *file, int16_t **input_i, float **input_f, long samples);
01253 
01261 int quicktime_dump(quicktime_t *file);
01262 
01263 /* Specify the number of cpus to utilize. */
01264 
01275 int quicktime_set_cpus(quicktime_t *file, int cpus);
01276 
01277 /* Specify whether to read contiguously or not. */
01278 /* preload is the number of bytes to read ahead. */
01279 /* This is no longer functional to the end user but is used to accelerate */
01280 /* reading the header internally. */
01281 void quicktime_set_preload(quicktime_t *file, int64_t preload);
01282 
01283 int64_t quicktime_byte_position(quicktime_t *file);
01284 
01293 void quicktime_set_avi(quicktime_t *file, int value);
01294 
01295   
01296 
01297 #ifdef __cplusplus
01298 }
01299 #endif
01300 
01301 #endif

Generated on Sat Aug 9 12:01:55 2008 for libquicktime by  doxygen 1.5.6