00001 /***************************************************************************** 00002 * vlc_codec.h: Definition of the decoder and encoder structures 00003 ***************************************************************************** 00004 * Copyright (C) 1999-2003 the VideoLAN team 00005 * $Id: aa36bbb331b0997bbe4b70f8e8c3a4edecc66eb7 $ 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 *, const subpicture_updater_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 bool b_error; 00131 }; 00132 00133 /** 00134 * @} 00135 */ 00136 00137 /** 00138 * \defgroup encoder Encoder 00139 * 00140 * The structure describing a Encoder 00141 * 00142 * @{ 00143 */ 00144 00145 struct encoder_t 00146 { 00147 VLC_COMMON_MEMBERS 00148 00149 /* Module properties */ 00150 module_t * p_module; 00151 encoder_sys_t * p_sys; 00152 00153 /* Properties of the input data fed to the encoder */ 00154 es_format_t fmt_in; 00155 00156 /* Properties of the output of the encoder */ 00157 es_format_t fmt_out; 00158 00159 block_t * ( * pf_encode_video )( encoder_t *, picture_t * ); 00160 block_t * ( * pf_encode_audio )( encoder_t *, aout_buffer_t * ); 00161 block_t * ( * pf_encode_sub )( encoder_t *, subpicture_t * ); 00162 00163 /* Common encoder options */ 00164 int i_threads; /* Number of threads to use during encoding */ 00165 int i_iframes; /* One I frame per i_iframes */ 00166 int i_bframes; /* One B frame per i_bframes */ 00167 int i_tolerance; /* Bitrate tolerance */ 00168 00169 /* Encoder config */ 00170 config_chain_t *p_cfg; 00171 }; 00172 00173 /** 00174 * @} 00175 */ 00176 00177 00178 /** 00179 * This function will return a new picture usable by a decoder as an output 00180 * buffer. You have to release it using decoder_DeletePicture or by returning 00181 * it to the caller as a pf_decode_video return value. 00182 */ 00183 VLC_EXPORT( picture_t *, decoder_NewPicture, ( decoder_t * ) LIBVLC_USED ); 00184 00185 /** 00186 * This function will release a picture create by decoder_NewPicture. 00187 */ 00188 VLC_EXPORT( void, decoder_DeletePicture, ( decoder_t *, picture_t *p_picture ) ); 00189 00190 /** 00191 * This function will increase the picture reference count. 00192 * (picture_Hold is not usable.) 00193 */ 00194 VLC_EXPORT( void, decoder_LinkPicture, ( decoder_t *, picture_t * ) ); 00195 00196 /** 00197 * This function will decrease the picture reference count. 00198 * (picture_Release is not usable.) 00199 */ 00200 VLC_EXPORT( void, decoder_UnlinkPicture, ( decoder_t *, picture_t * ) ); 00201 00202 /** 00203 * This function will return a new audio buffer usable by a decoder as an 00204 * output buffer. You have to release it using decoder_DeleteAudioBuffer 00205 * or by returning it to the caller as a pf_decode_audio return value. 00206 */ 00207 VLC_EXPORT( aout_buffer_t *, decoder_NewAudioBuffer, ( decoder_t *, int i_size ) LIBVLC_USED ); 00208 00209 /** 00210 * This function will release a audio buffer created by decoder_NewAudioBuffer. 00211 */ 00212 VLC_EXPORT( void, decoder_DeleteAudioBuffer, ( decoder_t *, aout_buffer_t *p_buffer ) ); 00213 00214 /** 00215 * This function will return a new subpicture usable by a decoder as an output 00216 * buffer. You have to release it using decoder_DeleteSubpicture or by returning 00217 * it to the caller as a pf_decode_sub return value. 00218 */ 00219 VLC_EXPORT( subpicture_t *, decoder_NewSubpicture, ( decoder_t *, const subpicture_updater_t * ) LIBVLC_USED ); 00220 00221 /** 00222 * This function will release a subpicture created by decoder_NewSubicture. 00223 */ 00224 VLC_EXPORT( void, decoder_DeleteSubpicture, ( decoder_t *, subpicture_t *p_subpicture ) ); 00225 00226 /** 00227 * This function gives all input attachments at once. 00228 * 00229 * You MUST release the returned values 00230 */ 00231 VLC_EXPORT( int, decoder_GetInputAttachments, ( decoder_t *, input_attachment_t ***ppp_attachment, int *pi_attachment ) ); 00232 00233 /** 00234 * This function converts a decoder timestamp into a display date comparable 00235 * to mdate(). 00236 * You MUST use it *only* for gathering statistics about speed. 00237 */ 00238 VLC_EXPORT( mtime_t, decoder_GetDisplayDate, ( decoder_t *, mtime_t ) LIBVLC_USED ); 00239 00240 /** 00241 * This function returns the current input rate. 00242 * You MUST use it *only* for gathering statistics about speed. 00243 */ 00244 VLC_EXPORT( int, decoder_GetDisplayRate, ( decoder_t * ) LIBVLC_USED ); 00245 00246 #endif /* _VLC_CODEC_H */
1.5.6