libquicktime

lqt_codecinfo.h

00001 /*******************************************************************************
00002  lqt_codecinfo.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 /*
00026  *   Codec info structure for libquicktime
00027  *   (first approximation)
00028  */
00029 
00030 /* Type of a codec parameter */
00031 
00032 #ifndef _LQT_CODEC_INFO_H_
00033 #define _LQT_CODEC_INFO_H_
00034 
00035 #ifdef __GNUC__
00036 #pragma GCC visibility push(default)
00037 #endif
00038 
00039 #include <inttypes.h>
00040 
00041 
00042 
00043 #ifdef __cplusplus
00044 extern "C" {
00045 #endif /* __cplusplus */
00046 
00080 typedef enum
00081   {
00082     LQT_PARAMETER_INT,     
00083     LQT_PARAMETER_FLOAT,   
00084     LQT_PARAMETER_STRING,  
00085     LQT_PARAMETER_STRINGLIST, 
00086     /* This dummy type is used to separate sections (real_name will be on tab-label) */
00087     LQT_PARAMETER_SECTION, 
00088   } lqt_parameter_type_t;
00089 
00096 typedef union
00097   {
00098   int val_int; 
00099   char * val_string; 
00100   float val_float; 
00101   } lqt_parameter_value_t;
00102 
00110 typedef struct
00111   {
00112   char * name;   
00114   char * real_name; 
00116   lqt_parameter_type_t type; 
00118   lqt_parameter_value_t val_default; 
00120   /*
00121    *   Minimum and maximum values:
00122    *   These are only valid for numeric types and if val_min < val_max
00123    */
00124   
00125   lqt_parameter_value_t val_min; 
00126   lqt_parameter_value_t val_max; 
00128   int num_digits; 
00130   /*
00131    *  Possible options (only valid for LQT_STRINGLIST)
00132    */
00133   
00134   int num_stringlist_options; 
00135   char ** stringlist_options; 
00136   char ** stringlist_labels;  
00138   char * help_string; 
00140   } lqt_parameter_info_t;
00141 
00146 typedef enum
00147   {
00148     LQT_CODEC_AUDIO,
00149     LQT_CODEC_VIDEO
00150   } lqt_codec_type;
00151 
00156 typedef enum
00157   {
00158     LQT_DIRECTION_ENCODE,
00159     LQT_DIRECTION_DECODE,
00160     LQT_DIRECTION_BOTH
00161   } lqt_codec_direction;
00162 
00172 typedef struct
00173   {
00174   int width;
00175   int height;
00176   } lqt_image_size_t;
00177 
00178   
00183 #define LQT_CODEC_OBSOLETE (1<<24)
00184   
00189 struct lqt_codec_info_s
00190   {
00191   int compatibility_flags; 
00193   /* These are set by the plugins */
00194   
00195   char * name;               
00196   char * long_name;          
00197   char * description;        
00199   lqt_codec_type type;           
00200   lqt_codec_direction direction; 
00202   int num_fourccs;      
00203   char ** fourccs;      
00205   int num_wav_ids; 
00206   int * wav_ids;   
00209   int num_encoding_parameters; 
00210   lqt_parameter_info_t * encoding_parameters; 
00212   int num_decoding_parameters; 
00213   lqt_parameter_info_t * decoding_parameters; 
00215   /* The following members are set by libquicktime      */
00216   
00217   char * module_filename;    
00218   int module_index;          
00220   uint32_t file_time;        
00222   char * gettext_domain;     
00223   char * gettext_directory;  
00225   int num_encoding_colormodels; 
00226   int * encoding_colormodels;  
00228   int num_image_sizes; 
00230   lqt_image_size_t * image_sizes; 
00232   lqt_compression_id_t compression_id; 
00234   struct lqt_codec_info_s * next;   
00235   };
00236 
00237 
00238 /* Global Entry points */
00239 
00247 void lqt_registry_init();
00248 
00257 void lqt_registry_destroy();
00258 
00259 /* \ingroup codec_registry
00260  *
00261  * Save the registry file $HOME/.libquicktime_codecs.
00262  * Under normal circumstances, you never need to call this function
00263  */
00264 
00265 void lqt_registry_write();
00266 
00267 
00268 /******************************************************
00269  *  Non thread save functions for querying the
00270  *  codec registry. Suitable for single threaded
00271  *  applications (might become obsolete)
00272  ******************************************************/
00273 
00281 int lqt_get_num_audio_codecs();
00282 
00290 int lqt_get_num_video_codecs();
00291 
00300 const lqt_codec_info_t * lqt_get_audio_codec_info(int index);
00301 
00310 const lqt_codec_info_t * lqt_get_video_codec_info(int index);
00311 
00312 /********************************************************************
00313  *  Thread save function for getting codec parameters
00314  *  All these functions return a NULL terminated array of local
00315  *  copies of the codec data which must be freed using 
00316  *  lqt_destroy_codec_info(lqt_codec_info_t ** info) declared below
00317  ********************************************************************/
00318 
00331 lqt_codec_info_t ** lqt_query_registry(int audio, int video,
00332                                        int encode, int decode);
00333 
00344 lqt_codec_info_t ** lqt_find_audio_codec(char * fourcc, int encode);
00345 
00356 lqt_codec_info_t ** lqt_find_audio_codec_by_wav_id(int wav_id, int encode);
00357   
00368 lqt_codec_info_t ** lqt_find_video_codec(char * fourcc, int encode);
00369 
00370 
00371 
00372   
00373 
00374   
00384 lqt_codec_info_t ** lqt_find_audio_codec_by_name(const char * name);
00385 
00395 lqt_codec_info_t ** lqt_find_video_codec_by_name(const char * name);
00396 
00407 lqt_codec_info_t ** lqt_audio_codec_from_file(quicktime_t * file, int track);
00408 
00419 lqt_codec_info_t ** lqt_video_codec_from_file(quicktime_t * file, int track);
00420   
00429 void lqt_destroy_codec_info(lqt_codec_info_t ** info);
00430 
00442 void lqt_reorder_audio_codecs(lqt_codec_info_t ** codec_info);
00443 
00455 void lqt_reorder_video_codecs(lqt_codec_info_t ** codec_info);
00456 
00470 void lqt_set_default_parameter(lqt_codec_type type, int encode,
00471                                const char * codec_name,
00472                                const char * parameter_name,
00473                                lqt_parameter_value_t * val);
00474 
00485 void lqt_restore_default_parameters(lqt_codec_info_t * codec_info,
00486                                     int encode, int decode);
00487     
00488                                       
00497 void lqt_dump_codec_info(const lqt_codec_info_t * info);
00498 
00499 #ifdef __cplusplus
00500 }
00501 #endif /* __cplusplus */
00502 
00503 #ifdef __GNUC__
00504 #pragma GCC visibility pop
00505 #endif
00506 
00507 #endif /* _LQT_CODEC_INFO_H_ */