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_format_t;
00291   
00300 typedef struct quicktime_s quicktime_t;
00301   
00302 /* This is the reference for all your library entry points. */
00303 
00304 /* ===== compression formats for which codecs exist ====== */
00305 
00325 #define QUICKTIME_DIVX "DIVX"
00326 
00333 #define QUICKTIME_DIV3 "DIV3"
00334 
00341 #define QUICKTIME_DV "dvc "
00342 /* AVID DV codec can be processed with libdv as well */
00343 
00350 #define QUICKTIME_DV_AVID "AVdv"
00351 
00358 #define QUICKTIME_DV_AVID_A "dvcp"
00359 
00367 /* RGB uncompressed.  Allows alpha */
00368 #define QUICKTIME_RAW  "raw "
00369 
00376 /* Jpeg Photo */
00377 #define QUICKTIME_JPEG "jpeg"
00378 
00379 /* Concatenated png images.  Allows alpha */
00380 
00388 #define QUICKTIME_PNG "png "
00389 
00397 #define QUICKTIME_MJPA "mjpa"
00398 
00405 #define QUICKTIME_YUV2 "yuv2"
00406 
00413 #define QUICKTIME_YUV4 "yuv4"
00414 
00422 #define QUICKTIME_YUV420  "yv12"
00423 
00430 #define QUICKTIME_2VUY "2vuy"
00431 
00438 #define QUICKTIME_V308  "v308"
00439 
00446 #define QUICKTIME_V408 "v408"
00447 
00454 #define QUICKTIME_V210 "v210"
00455 
00462 #define QUICKTIME_V410 "v410"
00463 
00464 /* =================== Audio formats ======================= */
00465 
00485 #define QUICKTIME_RAWAUDIO "raw "
00486 
00493 #define QUICKTIME_IMA4 "ima4"
00494 
00501 #define QUICKTIME_TWOS "twos"
00502 
00509 #define QUICKTIME_ULAW "ulaw"
00510 
00519 #define QUICKTIME_VORBIS "OggS"
00520 
00528 #define QUICKTIME_MP3 ".mp3"
00529   
00530 /* =========================== public interface ========================= // */
00531 
00540   /* Get version information */
00541 int quicktime_major();
00542 
00550 int quicktime_minor();
00551 
00560 int quicktime_release();
00561 
00573 int quicktime_check_sig(char *path);
00574 
00585 quicktime_t* quicktime_open(const char *filename, int rd, int wr);
00586 
00599 int quicktime_make_streamable(char *in_path, char *out_path);
00600 
00614 void quicktime_set_copyright(quicktime_t *file, char *string);
00615 
00622 void quicktime_set_name(quicktime_t *file, char *string);
00623 
00630 void quicktime_set_info(quicktime_t *file, char *string);
00631 
00639 char* quicktime_get_copyright(quicktime_t *file);
00640 
00648 char* quicktime_get_name(quicktime_t *file);
00649 
00656 char* quicktime_get_info(quicktime_t *file);
00657 
00658 
00674 int quicktime_set_audio(quicktime_t *file, 
00675         int channels, 
00676         long sample_rate, 
00677         int bits, 
00678         char *compressor);
00679 
00690 void quicktime_set_framerate(quicktime_t *file, double framerate);
00691 
00707 int quicktime_set_video(quicktime_t *file, 
00708         int tracks, 
00709         int frame_w, 
00710         int frame_h, 
00711         double frame_rate, 
00712         char *compressor);
00713 
00727 void quicktime_set_jpeg(quicktime_t *file, int quality, int use_float);
00728 
00743 void quicktime_set_parameter(quicktime_t *file, char *key, void *value);
00744 
00755 void quicktime_set_depth(quicktime_t *file, 
00756         int depth, 
00757         int track);
00758 
00768 void quicktime_set_cmodel(quicktime_t *file, int colormodel);
00769 
00780 void quicktime_set_row_span(quicktime_t *file, int row_span);
00781 
00787 int quicktime_close(quicktime_t *file);
00788 
00789 /* get length information */
00790 /* channel numbers start on 1 for audio and video */
00791 
00800 long quicktime_audio_length(quicktime_t *file, int track);
00801 
00813 long quicktime_video_length(quicktime_t *file, int track);
00814 
00822   /* get position information */
00823 long quicktime_audio_position(quicktime_t *file, int track);
00824 
00834 long quicktime_video_position(quicktime_t *file, int track);
00835 
00842 /* get file information */
00843 int quicktime_video_tracks(quicktime_t *file);
00844 
00851 int quicktime_audio_tracks(quicktime_t *file);
00852 
00859 int quicktime_has_audio(quicktime_t *file);
00860 
00868 long quicktime_sample_rate(quicktime_t *file, int track);
00869 
00884 int quicktime_audio_bits(quicktime_t *file, int track);
00885 
00893 int quicktime_track_channels(quicktime_t *file, int track);
00894 
00907 char* quicktime_audio_compressor(quicktime_t *file, int track);
00908 
00915 int quicktime_has_video(quicktime_t *file);
00916 
00924 int quicktime_video_width(quicktime_t *file, int track);
00925 
00933 int quicktime_video_height(quicktime_t *file, int track);
00934 
00949 int quicktime_video_depth(quicktime_t *file, int track);
00950 
00965 double quicktime_frame_rate(quicktime_t *file, int track);
00966 
00977 char* quicktime_video_compressor(quicktime_t *file, int track);
00978 
00979 /* number of bytes of raw data in this frame */
00980 
00992 long quicktime_frame_size(quicktime_t *file, long frame, int track);
00993 
01003 int quicktime_channel_location(quicktime_t *file, int *quicktime_track, int *quicktime_channel, int channel);
01004 
01005 /* file positioning */
01006 /* Remove these and see what happens :) */
01007 
01008 // int quicktime_seek_end(quicktime_t *file);
01009 
01018 int quicktime_seek_start(quicktime_t *file);
01019 
01020 /* set position of file descriptor relative to a track */
01021 
01030 int quicktime_set_audio_position(quicktime_t *file, int64_t sample, int track);
01031 
01042 int quicktime_set_video_position(quicktime_t *file, int64_t frame, int track);
01043 
01044 /* ========================== Access to raw data follows. */
01045 /* write data for one quicktime track */
01046 /* the user must handle conversion to the channels in this track */
01047 int quicktime_write_audio(quicktime_t *file, uint8_t *audio_buffer, long samples, int track);
01048 
01063 int quicktime_write_frame(quicktime_t *file, uint8_t *video_buffer, int64_t bytes, int track);
01064 
01077 long quicktime_read_frame(quicktime_t *file, unsigned char *video_buffer, int track);
01078 
01079 /* for reading frame using a library that needs a file descriptor */
01080 /* Frame caching doesn't work here. */
01081 int quicktime_read_frame_init(quicktime_t *file, int track);
01082 int quicktime_read_frame_end(quicktime_t *file, int track);
01083 
01084 /* One keyframe table for each track */
01085 long quicktime_get_keyframe_before(quicktime_t *file, long frame, int track);
01086 void quicktime_insert_keyframe(quicktime_t *file, long frame, int track);
01087 /* Track has keyframes */
01088 int quicktime_has_keyframes(quicktime_t *file, int track);
01089 
01090 /* ===================== Access to built in codecs follows. */
01091 
01092 /* If the codec for this track is supported in the library return 1. */
01093 
01101 int quicktime_supported_video(quicktime_t *file, int track);
01102 
01110 int quicktime_supported_audio(quicktime_t *file, int track);
01111 
01123 int quicktime_reads_cmodel(quicktime_t *file, 
01124                 int colormodel, 
01125                 int track);
01126 
01138 int quicktime_writes_cmodel(quicktime_t *file, 
01139                 int colormodel, 
01140                 int track);
01141 
01142 
01143 /* Hacks for temporal codec */
01144 int quicktime_divx_is_key(unsigned char *data, long size);
01145 int quicktime_divx_write_vol(unsigned char *data_start,
01146         int vol_width, 
01147         int vol_height, 
01148         int time_increment_resolution, 
01149         double frame_rate);
01150 int quicktime_divx_has_vol(unsigned char *data);
01151 
01152 int quicktime_div3_is_key(unsigned char *data, long size);
01153 
01164 int quicktime_encode_video(quicktime_t *file, 
01165         unsigned char **row_pointers, 
01166         int track);
01167 
01178 int quicktime_decode_video(quicktime_t *file, 
01179         unsigned char **row_pointers, 
01180         int track);
01181 
01202 long quicktime_decode_scaled(quicktime_t *file, 
01203         int in_x,                    /* Location of input frame to take picture */
01204         int in_y,
01205         int in_w,
01206         int in_h,
01207         int out_w,                   /* Dimensions of output frame */
01208         int out_h,
01209         int color_model,             /* One of the color models defined above */
01210         unsigned char **row_pointers, 
01211         int track);
01212 
01213 /* Decode or encode audio for a single channel into the buffer. */
01214 /* Pass a buffer for the _i or the _f argument if you want int16 or float data. */
01215 /* Notice that encoding requires an array of pointers to each channel. */
01216 
01234 int quicktime_decode_audio(quicktime_t *file, int16_t *output_i, float *output_f, long samples, int channel);
01235 
01248 int quicktime_encode_audio(quicktime_t *file, int16_t **input_i, float **input_f, long samples);
01249 
01257 int quicktime_dump(quicktime_t *file);
01258 
01259 /* Specify the number of cpus to utilize. */
01260 
01271 int quicktime_set_cpus(quicktime_t *file, int cpus);
01272 
01273 /* Specify whether to read contiguously or not. */
01274 /* preload is the number of bytes to read ahead. */
01275 /* This is no longer functional to the end user but is used to accelerate */
01276 /* reading the header internally. */
01277 void quicktime_set_preload(quicktime_t *file, int64_t preload);
01278 
01279 int64_t quicktime_byte_position(quicktime_t *file);
01280 
01289 void quicktime_set_avi(quicktime_t *file, int value);
01290 
01291   
01292 
01293 #ifdef __cplusplus
01294 }
01295 #endif
01296 
01297 #endif

Generated on Tue Jan 8 23:01:07 2008 for libquicktime by  doxygen 1.5.3