00001 /***************************************************************************** 00002 * vlc_codec.h: Definition of the decoder and encoder structures 00003 ***************************************************************************** 00004 * Copyright (C) 1999-2003 the VideoLAN team 00005 * $Id: 512dcf3ae652faa9f9564a1e6ab1e67bddaa2e85 $ 00006 * 00007 * Authors: Gildas Bazin <gbazin@netcourrier.com> 00008 * 00009 * This program is free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * This program is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with this program; if not, write to the Free Software 00021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 00022 *****************************************************************************/ 00023 00024 #ifndef VLC_CODEC_H 00025 #define VLC_CODEC_H 1 00026 00027 #include <vlc_block.h> 00028 #include <vlc_es.h> 00029 #include <vlc_picture.h> 00030 #include <vlc_subpicture.h> 00031 00032 /** 00033 * \file 00034 * This file defines the structure and types used by decoders and encoders 00035 */ 00036 00037 typedef struct decoder_owner_sys_t decoder_owner_sys_t; 00038 00039 /** 00040 * \defgroup decoder Decoder 00041 * 00042 * The structure describing a decoder 00043 * 00044 * @{ 00045 */ 00046 00047 /* 00048 * BIG FAT WARNING : the code relies in the first 4 members of filter_t 00049 * and decoder_t to be the same, so if you have anything to add, do it 00050 * at the end of the structure. 00051 */ 00052 struct decoder_t 00053 { 00054 VLC_COMMON_MEMBERS 00055 00056 /* Module properties */ 00057 module_t * p_module; 00058 decoder_sys_t * p_sys; 00059 00060 /* Input format ie from demuxer (XXX: a lot of field could be invalid) */ 00061 es_format_t fmt_in; 00062 00063 /* Output format of decoder/packetizer */ 00064 es_format_t fmt_out; 00065 00066 /* Some decoders only accept packetized data (ie. not truncated) */ 00067 bool b_need_packetized; 00068 00069 /* Tell the decoder if it is allowed to drop frames */ 00070 bool b_pace_control; 00071 00072 /* */ 00073 picture_t * ( * pf_decode_video )( decoder_t *, block_t ** ); 00074 aout_buffer_t * ( * pf_decode_audio )( decoder_t *, block_t ** ); 00075 subpicture_t * ( * pf_decode_sub) ( decoder_t *, block_t ** ); 00076 block_t * ( * pf_packetize ) ( decoder_t *, block_t ** ); 00077 00078 /* Closed Caption (CEA 608/708) extraction. 00079 * If set, it *may* be called after pf_decode_video/pf_packetize 00080 * returned data. It should return CC for the pictures returned by the 00081 * last pf_packetize/pf_decode_video call only, 00082 * pb_present will be used to known which cc channel are present (but 00083 * globaly, not necessary for the current packet */ 00084 block_t * ( * pf_get_cc ) ( decoder_t *, bool pb_present[4] ); 00085 00086 /* Meta data at codec level 00087 * The decoder owner set it back to NULL once it has retreived what it needs. 00088 * The decoder owner is responsible of its release except when you overwrite it. 00089 */ 00090 vlc_meta_t *p_description; 00091 00092 /* 00093 * Owner fields 00094 * XXX You MUST not use them directly. 00095 */ 00096 00097 /* Video output callbacks 00098 * XXX use decoder_NewPicture/decoder_DeletePicture 00099 * and decoder_LinkPicture/decoder_UnlinkPicture */ 00100 picture_t *(*pf_vout_buffer_new)( decoder_t * ); 00101 void (*pf_vout_buffer_del)( decoder_t *, picture_t * ); 00102 void (*pf_picture_link) ( decoder_t *, picture_t * ); 00103 void (*pf_picture_unlink) ( decoder_t *, picture_t * ); 00104 00105 /* Audio output callbacks 00106 * XXX use decoder_NewAudioBuffer/decoder_DeleteAudioBuffer */ 00107 aout_buffer_t *(*pf_aout_buffer_new)( decoder_t *, int ); 00108 void (*pf_aout_buffer_del)( decoder_t *, aout_buffer_t * ); 00109 00110 /* SPU output callbacks 00111 * XXX use decoder_NewSubpicture and decoder_DeleteSubpicture */ 00112 subpicture_t *(*pf_spu_buffer_new)( decoder_t * ); 00113 void (*pf_spu_buffer_del)( decoder_t *, subpicture_t * ); 00114 00115 /* Input attachments 00116 * XXX use decoder_GetInputAttachments */ 00117 int (*pf_get_attachments)( decoder_t *p_dec, input_attachment_t ***ppp_attachment, int *pi_attachment ); 00118 00119 /* Display date 00120 * XXX use decoder_GetDisplayDate */ 00121 mtime_t (*pf_get_display_date)( decoder_t *, mtime_t ); 00122 00123 /* Display rate 00124 * XXX use decoder_GetDisplayRate */ 00125 int (*pf_get_display_rate)( decoder_t * ); 00126 00127 /* Private structure for the owner of the decoder */ 00128 decoder_owner_sys_t *p_owner; 00129 }; 00130 00131 /** 00132 * @} 00133 */ 00134 00135 /** 00136 * \defgroup decoder Encoder 00137 * 00138 * The structure describing a Encoder 00139 * 00140 * @{ 00141 */ 00142 00143 struct encoder_t 00144 { 00145 VLC_COMMON_MEMBERS 00146 00147 /* Module properties */ 00148 module_t * p_module; 00149 encoder_sys_t * p_sys; 00150 00151 /* Properties of the input data fed to the encoder */ 00152 es_format_t fmt_in; 00153 00154 /* Properties of the output of the encoder */ 00155 es_format_t fmt_out; 00156 00157 block_t * ( * pf_encode_video )( encoder_t *, picture_t * ); 00158 block_t * ( * pf_encode_audio )( encoder_t *, aout_buffer_t * ); 00159 block_t * ( * pf_encode_sub )( encoder_t *, subpicture_t * ); 00160 00161 /* Common encoder options */ 00162 int i_threads; /* Number of threads to use during encoding */ 00163 int i_iframes; /* One I frame per i_iframes */ 00164 int i_bframes; /* One B frame per i_bframes */ 00165 int i_tolerance; /* Bitrate tolerance */ 00166 00167 /* Encoder config */ 00168 config_chain_t *p_cfg; 00169 }; 00170 00171 /** 00172 * @} 00173 */ 00174 00175 00176 /** 00177 * This function will return a new picture usable by a decoder as an output 00178 * buffer. You have to release it using decoder_DeletePicture or by returning 00179 * it to the caller as a pf_decode_video return value. 00180 */ 00181 VLC_EXPORT( picture_t *, decoder_NewPicture, ( decoder_t * ) ); 00182 00183 /** 00184 * This function will release a picture create by decoder_NewPicture. 00185 */ 00186 VLC_EXPORT( void, decoder_DeletePicture, ( decoder_t *, picture_t *p_picture ) ); 00187 00188 /** 00189 * This function will increase the picture reference count. 00190 * (picture_Hold is not usable.) 00191 */ 00192 VLC_EXPORT( void, decoder_LinkPicture, ( decoder_t *, picture_t * ) ); 00193 00194 /** 00195 * This function will decrease the picture reference count. 00196 * (picture_Release is not usable.) 00197 */ 00198 VLC_EXPORT( void, decoder_UnlinkPicture, ( decoder_t *, picture_t * ) ); 00199 00200 /** 00201 * This function will return a new audio buffer usable by a decoder as an 00202 * output buffer. You have to release it using decoder_DeleteAudioBuffer 00203 * or by returning it to the caller as a pf_decode_audio return value. 00204 */ 00205 VLC_EXPORT( aout_buffer_t *, decoder_NewAudioBuffer, ( decoder_t *, int i_size ) ); 00206 00207 /** 00208 * This function will release a audio buffer created by decoder_NewAudioBuffer. 00209 */ 00210 VLC_EXPORT( void, decoder_DeleteAudioBuffer, ( decoder_t *, aout_buffer_t *p_buffer ) ); 00211 00212 /** 00213 * This function will return a new subpicture usable by a decoder as an output 00214 * buffer. You have to release it using decoder_DeleteSubpicture or by returning 00215 * it to the caller as a pf_decode_sub return value. 00216 */ 00217 VLC_EXPORT( subpicture_t *, decoder_NewSubpicture, ( decoder_t * ) ); 00218 00219 /** 00220 * This function will release a subpicture created by decoder_NewSubicture. 00221 */ 00222 VLC_EXPORT( void, decoder_DeleteSubpicture, ( decoder_t *, subpicture_t *p_subpicture ) ); 00223 00224 /** 00225 * This function gives all input attachments at once. 00226 * 00227 * You MUST release the returned values 00228 */ 00229 VLC_EXPORT( int, decoder_GetInputAttachments, ( decoder_t *, input_attachment_t ***ppp_attachment, int *pi_attachment ) ); 00230 00231 /** 00232 * This function converts a decoder timestamp into a display date comparable 00233 * to mdate(). 00234 * You MUST use it *only* for gathering statistics about speed. 00235 */ 00236 VLC_EXPORT( mtime_t, decoder_GetDisplayDate, ( decoder_t *, mtime_t ) LIBVLC_USED ); 00237 00238 /** 00239 * This function returns the current input rate. 00240 * You MUST use it *only* for gathering statistics about speed. 00241 */ 00242 VLC_EXPORT( int, decoder_GetDisplayRate, ( decoder_t * ) ); 00243 00244 #endif /* _VLC_CODEC_H */
1.5.6