libquicktime

lqt.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002  lqt.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 _LQT_H_
00026 #define _LQT_H_
00027 
00028 #include "quicktime.h"
00029 #include "lqt_atoms.h"
00030 #include "compression.h"
00031 #include "lqt_codecinfo.h"
00032 #include "lqt_qtvr.h"
00033 
00034 #ifdef __GNUC__
00035 #pragma GCC visibility push(default)
00036 #endif
00037 
00038 
00039 #ifdef __cplusplus
00040 extern "C" {
00041 #endif /* __cplusplus */
00042 
00048 void *lqt_bufalloc(size_t size);
00049 
00050 
00051   
00058 void lqt_set_log_callback(lqt_log_callback_t cb, void * data);
00059                            
00060   
00072 int lqt_fileno(quicktime_t *file);
00073 
00085 void lqt_set_audio_parameter(quicktime_t *file,int track, const char *key,const void *value);
00086 
00098 void lqt_set_video_parameter(quicktime_t *file,int track, const char *key,const void *value);
00099 
00110 int lqt_get_pixel_aspect(quicktime_t *file, int track, int * pixel_width,
00111                          int * pixel_height);
00112 
00123 int lqt_set_pixel_aspect(quicktime_t *file, int track, int pixel_width,
00124                          int pixel_height);
00125 
00138 lqt_interlace_mode_t lqt_get_interlace_mode(quicktime_t * file, int track);
00139 
00152 int lqt_set_interlace_mode(quicktime_t * file, int track,
00153                            lqt_interlace_mode_t mode);
00154 
00155   
00161 const char * lqt_interlace_mode_to_string(lqt_interlace_mode_t mode);
00162 
00173 lqt_chroma_placement_t lqt_get_chroma_placement(quicktime_t * file, int track);
00174 
00181 const char * lqt_chroma_placement_to_string(lqt_chroma_placement_t chroma_placement);
00182 
00193 int lqt_get_codec_api_version();
00194 
00201 const char * lqt_channel_to_string(lqt_channel_t ch);
00202 
00214 void lqt_set_channel_setup(quicktime_t * file, int track, lqt_channel_t * ch);
00215 
00226 const lqt_channel_t * lqt_get_channel_setup(quicktime_t * file, int track);
00227 
00228 
00261 int lqt_add_text_track(quicktime_t * file, int timescale);
00262 
00272 void lqt_set_text_language(quicktime_t * file, int track, const char * language);
00273 
00284 void lqt_set_chapter_track(quicktime_t * file, int track);
00285 
00295 void lqt_set_text_box(quicktime_t * file, int track,
00296                       uint16_t top, uint16_t left,
00297                       uint16_t bottom, uint16_t right);
00298 
00311 void lqt_set_text_fg_color(quicktime_t * file, int track,
00312                            uint16_t r, uint16_t g,
00313                            uint16_t b, uint16_t a);
00314 
00328 void lqt_set_text_bg_color(quicktime_t * file, int track,
00329                            uint16_t r, uint16_t g,
00330                            uint16_t b, uint16_t a);
00331 
00332   
00333   
00334   
00343 int lqt_write_text(quicktime_t * file, int track, const char * text, int64_t duration);
00344   
00362 int lqt_text_tracks(quicktime_t * file);
00363 
00374 int lqt_get_text_language(quicktime_t * file, int track, char * language);
00375 
00382 int lqt_text_time_scale(quicktime_t * file, int track);
00383 
00393 void lqt_get_text_box(quicktime_t * file, int track,
00394                       uint16_t * top, uint16_t * left,
00395                       uint16_t * bottom, uint16_t * right);
00396 
00397   
00412 int lqt_read_text(quicktime_t * file, int track, char ** text, int * text_alloc,
00413                   int64_t * timestamp, int64_t * duration);
00414 
00422 int lqt_is_chapter_track(quicktime_t * file, int track);
00423 
00430 int64_t lqt_text_samples(quicktime_t * file, int track);
00431 
00438 void lqt_set_text_position(quicktime_t * file, int track, int64_t position);
00439 
00450 void lqt_set_text_time(quicktime_t * file, int track, int64_t time);
00451 
00463 void lqt_get_text_fg_color(quicktime_t * file, int track,
00464                            uint16_t * r, uint16_t * g,
00465                            uint16_t * b, uint16_t * a);
00466 
00478 void lqt_get_text_bg_color(quicktime_t * file, int track,
00479                            uint16_t * r, uint16_t * g,
00480                            uint16_t * b, uint16_t * a);
00481 
00497 #define LQT_TIMECODE_DROP    0x0001 //!< Indicates whether the timecode is drop frame
00498 #define LQT_TIMECODE_24HMAX  0x0002 //!< Indicates whether the timecode wraps after 24 hours
00499 #define LQT_TIMECODE_NEG_OK  0x0004 //!< Indicates whether negative time values are allowed
00500 #define LQT_TIMECODE_COUNTER 0x0008 //!< Indicates whether the time value corresponds to a tape counter value
00501 
00514 void lqt_add_timecode_track(quicktime_t * file, int track,
00515                             uint32_t flags, int framerate);
00516 
00526 void lqt_write_timecode(quicktime_t * file, int track,
00527                         uint32_t timecode);
00528 
00539 int lqt_has_timecode_track(quicktime_t * file, int track,
00540                            uint32_t * flags, int * framerate);
00541 
00556 int lqt_read_timecode(quicktime_t * file, int track,
00557                       uint32_t * timecode);
00558 
00570 const char * lqt_get_timecode_tape_name(quicktime_t * file, int track);
00571 
00582 void lqt_set_timecode_tape_name(quicktime_t * file, int track,
00583                                 const char * tapename);
00584 
00593 int lqt_get_timecode_track_enabled(quicktime_t * file, int track);
00594 
00603 void lqt_set_timecode_track_enabled(quicktime_t * file, int track,
00604                                     int enabled);
00605 
00612 /***********************************************
00613  * Advanced colormodel handling.
00614  * (defined in lqt_color.c)
00615  ***********************************************/
00616 
00622 #define LQT_COLORMODEL_NONE -1
00623   
00624 /* Colormodel <-> string conversion (used by registry file routines) */
00625 
00632 const char * lqt_colormodel_to_string(int colormodel);
00633 
00640 int lqt_string_to_colormodel(const char * str);
00641 
00642 /* Query information about the colormodel */
00643 
00650 int lqt_colormodel_is_planar(int colormodel);
00651 
00658 int lqt_colormodel_has_alpha(int colormodel);
00659 
00666 int lqt_colormodel_is_rgb(int colormodel);
00667 
00674 int lqt_colormodel_is_yuv(int colormodel);
00675 
00684 void lqt_colormodel_get_chroma_sub(int colormodel, int * sub_h, int * sub_v);
00685 
00692 int lqt_colormodel_is_video_range(int colormodel);
00693 
00707 void lqt_get_default_rowspan(int colormodel, int width, int * rowspan, int * rowspan_uv);
00708 
00721 int lqt_colormodel_has_conversion(int in_cmodel, int out_cmodel);
00722   
00723 /* Query supported colormodels */
00724 
00730 int lqt_num_colormodels();
00731 
00737 const char * lqt_get_colormodel_string(int index);
00738 
00745 int lqt_get_colormodel(int index);
00746 
00757 int lqt_get_decoder_colormodel(quicktime_t * file, int track);
00758 
00770 int lqt_get_best_source_colormodel(int const* source_options, int target);
00771 
00783 int lqt_get_best_target_colormodel(int source, int const* target_options);
00784 
00801 int lqt_get_best_colormodel(quicktime_t * file, int track, int * supported);
00802 
00813 int lqt_get_cmodel(quicktime_t * file, int track);
00814   
00830 uint8_t ** lqt_rows_alloc(int width, int height, int colormodel, int * rowspan, int * rowspan_uv);
00831 
00845 void lqt_rows_copy(uint8_t **out_rows, uint8_t **in_rows, int width, int height, int in_rowspan, int in_rowspan_uv,
00846                    int out_rowspan, int out_rowspan_uv, int colormodel);
00847   
00867 void lqt_rows_copy_sub(uint8_t **out_rows, uint8_t **in_rows,
00868                        int width, int height, int in_rowspan,
00869                        int in_rowspan_uv, int out_rowspan,
00870                        int out_rowspan_uv, int colormodel, int src_x, int src_y, int dst_x, int dst_y);
00871   
00888 void lqt_rows_clear(uint8_t **rows,
00889                     int width, int height, int rowspan, int rowspan_uv, int colormodel);
00890 
00891   
00897 void lqt_rows_free(uint8_t ** rows);
00898   
00899 
00900 /**************************************
00901  * Set streams for encoding
00902  **************************************/
00903 
00917 int lqt_set_audio(quicktime_t *file, int channels,
00918                   long sample_rate,  int bits,
00919                   lqt_codec_info_t * codec_info);
00920 
00921   
00939 int lqt_set_video(quicktime_t *file, int tracks, 
00940                   int frame_w, int frame_h,
00941                   int frame_duration, int timescale,
00942                   lqt_codec_info_t * codec_info);
00943 
00944  
00961 int lqt_add_audio_track(quicktime_t *file,
00962                         int channels, long sample_rate, int bits,
00963                         lqt_codec_info_t * codec_info);
00964 
00972 int lqt_set_audio_codec(quicktime_t *file, int track,
00973                         lqt_codec_info_t * info);
00974 
00975   
00986 void lqt_set_audio_language(quicktime_t * file, int track, const char * language);
00987   
01006 int lqt_add_video_track(quicktime_t *file,
01007                         int frame_w, int frame_h,
01008                         int frame_duration, int timescale,
01009                         lqt_codec_info_t * codec_info);
01010 
01018 int lqt_set_video_codec(quicktime_t *file, int track,
01019                         lqt_codec_info_t * info);
01020 
01021   
01039 int lqt_set_video_pass(quicktime_t *file,
01040                        int pass, int total_passes, 
01041                        const char * stats_file, int track);
01042 
01050 int64_t lqt_get_frame_time(quicktime_t * file, int track, int frame);
01051 
01062 int64_t lqt_frame_time(quicktime_t * file, int track);
01063 
01077 int lqt_decode_video(quicktime_t *file,
01078                      unsigned char **row_pointers, int track);
01079 
01097 int lqt_read_video_frame(quicktime_t * file,
01098                          uint8_t ** buffer, int * buffer_alloc,
01099                          int64_t frame, int64_t * time, int track);
01100   
01116 int lqt_encode_video(quicktime_t *file, 
01117                      unsigned char **row_pointers, 
01118                      int track, int64_t time);
01119 
01137 int lqt_encode_video_d(quicktime_t *file, 
01138                        unsigned char **row_pointers, 
01139                        int track, int64_t time, int duration);
01140   
01149 int lqt_frame_duration(quicktime_t * file, int track, int *constant);
01150   
01158 int lqt_video_time_scale(quicktime_t * file, int track);
01159 
01169 int64_t lqt_video_duration(quicktime_t * file, int track);
01170 
01185 void lqt_set_cmodel(quicktime_t *file, int track, int colormodel);
01186 
01193 long lqt_video_edit_list_total_entries(quicktime_t * file, int track);
01194 
01202 long lqt_video_edit_duration(quicktime_t * file, int track, int entry_index);
01203 
01211 long lqt_video_edit_time(quicktime_t * file, int track, int entry_index);
01212 
01220 float lqt_video_edit_rate(quicktime_t * file, int track, int entry_index);
01221 
01232 void lqt_set_row_span(quicktime_t *file, int track, int row_span);
01233 
01244 void lqt_set_row_span_uv(quicktime_t *file, int track, int row_span_uv);
01245   
01270 int lqt_decode_audio(quicktime_t *file, 
01271                      int16_t **output_i, 
01272                      float **output_f, 
01273                      long samples);
01274   
01287 int64_t lqt_last_audio_position(quicktime_t * file, int track);
01288   
01302 int lqt_encode_audio_track(quicktime_t *file, 
01303                            int16_t **output_i, 
01304                            float **output_f, 
01305                            long samples,
01306                            int track);
01307   
01325 int lqt_decode_audio_track(quicktime_t *file, 
01326                            int16_t **output_i, 
01327                            float **output_f, 
01328                            long samples,
01329                            int track);
01330   
01331 /*
01332  *  Query the internal sample format. Works for decoding (call after quicktime_open)
01333  *  and encoding (call after lqt_add_audio_track, lqt_set_audio or quicktime_set_audio).
01334  */
01335 
01342 const char * lqt_sample_format_to_string(lqt_sample_format_t sampleformat);
01343 
01355 lqt_sample_format_t lqt_get_sample_format(quicktime_t * file, int track);
01356 
01357 /* The following return the actual number of en-/decoded frames */
01358   
01375 int lqt_decode_audio_raw(quicktime_t *file, 
01376                          void * output, 
01377                          long samples,
01378                          int track);
01379 
01391 int lqt_get_audio_language(quicktime_t * file, int track, char * language);
01392 
01393   
01407 int lqt_encode_audio_raw(quicktime_t *file, 
01408                          void * input, 
01409                          long samples,
01410                          int track);
01411 
01423 void lqt_seek_video(quicktime_t * file, int track,
01424                     int64_t time);
01425   
01432 long lqt_audio_edit_list_total_entries(quicktime_t * file, int track);
01433 
01441 long lqt_audio_edit_duration(quicktime_t * file, int track, int entry_index);
01442 
01450 long lqt_audio_edit_time(quicktime_t * file, int track, int entry_index);
01451 
01459 float lqt_audio_edit_rate(quicktime_t * file, int track, int entry_index);
01460 
01461 /*
01462  *  AVI Specific stuff
01463  */
01464 
01471 int lqt_is_avi(quicktime_t *file);
01472 
01483 int lqt_get_wav_id(quicktime_t *file, int track);
01484   
01495 int lqt_total_channels(quicktime_t *file);
01496 
01497 /* Extended metadata support */
01498 
01505 void lqt_set_album(quicktime_t *file, char *string);
01506 
01513 void lqt_set_artist(quicktime_t *file, char *string);
01514 
01521 void lqt_set_genre(quicktime_t *file, char *string);
01522 
01530 void lqt_set_track(quicktime_t *file, char *string);
01531 
01538 void lqt_set_comment(quicktime_t *file, char *string);
01539 
01546 void lqt_set_author(quicktime_t *file, char *string);
01547 
01554 void lqt_set_creation_time(quicktime_t *file, unsigned long time);
01555 
01556   
01563 char * lqt_get_album(quicktime_t * file);
01564   
01570 char * lqt_get_artist(quicktime_t * file);
01571 
01578 char * lqt_get_genre(quicktime_t * file);
01579 
01585 char * lqt_get_track(quicktime_t * file);
01586 
01593 char * lqt_get_comment(quicktime_t *file);
01594 
01600 char * lqt_get_author(quicktime_t *file);
01601 
01607 unsigned long lqt_get_creation_time(quicktime_t * file);
01608   
01609 /* get track number from track id */
01610 int lqt_track_from_id(quicktime_t *file, int track_id);
01611 
01618 const char * lqt_file_type_to_string(lqt_file_type_t type);
01619 
01626 lqt_file_type_t lqt_get_file_type(quicktime_t * file);
01627  
01628   
01636 quicktime_t * lqt_open_read(const char * filename);
01637 
01647   quicktime_t * lqt_open_read_with_log(const char * filename, lqt_log_callback_t cb, void * log_data);
01648   
01657 quicktime_t * lqt_open_write(const char * filename, lqt_file_type_t type);
01658 
01669 quicktime_t * lqt_open_write_with_log(const char * filename, lqt_file_type_t type,
01670                                       lqt_log_callback_t cb, void * log_data);
01671   
01683 void lqt_set_max_riff_size(quicktime_t * file, int size);
01684 
01685 
01693 void lqt_set_audio_pts_offset(quicktime_t * file, int track, int64_t offset);
01694   
01702 int64_t lqt_get_audio_pts_offset(quicktime_t * file, int track);
01703 
01711 void lqt_set_video_pts_offset(quicktime_t * file, int track, int64_t offset);
01712   
01720 int64_t lqt_get_video_pts_offset(quicktime_t * file, int track);
01721 
01729 void lqt_set_text_pts_offset(quicktime_t * file, int track, int64_t offset);
01730   
01738 int64_t lqt_get_text_pts_offset(quicktime_t * file, int track);
01739   
01740 #ifdef __cplusplus
01741 }
01742 #endif /* __cplusplus */
01743 
01744 #ifdef __GNUC__
01745 #pragma GCC visibility pop
01746 #endif
01747   
01748 #endif