vlc_codec.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * vlc_codec.h: Definition of the decoder and encoder structures
00003  *****************************************************************************
00004  * Copyright (C) 1999-2003 VLC authors and VideoLAN
00005  * $Id: beac8fd83d01576098e0fde46deb093ef75ba63d $
00006  *
00007  * Authors: Gildas Bazin <gbazin@netcourrier.com>
00008  *
00009  * This program is free software; you can redistribute it and/or modify it
00010  * under the terms of the GNU Lesser General Public License as published by
00011  * the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU Lesser General Public License
00020  * along with this program; if not, write to the Free Software Foundation,
00021  * 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     /**
00106      * Number of extra (ie in addition to the DPB) picture buffers
00107      * needed for decoding.
00108      */
00109     int             i_extra_picture_buffers;
00110 
00111     /* Audio output callbacks
00112      * XXX use decoder_NewAudioBuffer/decoder_DeleteAudioBuffer */
00113     aout_buffer_t  *(*pf_aout_buffer_new)( decoder_t *, int );
00114 
00115     /* SPU output callbacks
00116      * XXX use decoder_NewSubpicture and decoder_DeleteSubpicture */
00117     subpicture_t   *(*pf_spu_buffer_new)( decoder_t *, const subpicture_updater_t * );
00118     void            (*pf_spu_buffer_del)( decoder_t *, subpicture_t * );
00119 
00120     /* Input attachments
00121      * XXX use decoder_GetInputAttachments */
00122     int             (*pf_get_attachments)( decoder_t *p_dec, input_attachment_t ***ppp_attachment, int *pi_attachment );
00123 
00124     /* Display date
00125      * XXX use decoder_GetDisplayDate */
00126     mtime_t         (*pf_get_display_date)( decoder_t *, mtime_t );
00127 
00128     /* Display rate
00129      * XXX use decoder_GetDisplayRate */
00130     int             (*pf_get_display_rate)( decoder_t * );
00131 
00132     /* Private structure for the owner of the decoder */
00133     decoder_owner_sys_t *p_owner;
00134 
00135     bool                b_error;
00136 };
00137 
00138 /**
00139  * @}
00140  */
00141 
00142 /**
00143  * \defgroup encoder Encoder
00144  *
00145  * The structure describing a Encoder
00146  *
00147  * @{
00148  */
00149 
00150 struct encoder_t
00151 {
00152     VLC_COMMON_MEMBERS
00153 
00154     /* Module properties */
00155     module_t *          p_module;
00156     encoder_sys_t *     p_sys;
00157 
00158     /* Properties of the input data fed to the encoder */
00159     es_format_t         fmt_in;
00160 
00161     /* Properties of the output of the encoder */
00162     es_format_t         fmt_out;
00163 
00164     block_t *           ( * pf_encode_video )( encoder_t *, picture_t * );
00165     block_t *           ( * pf_encode_audio )( encoder_t *, aout_buffer_t * );
00166     block_t *           ( * pf_encode_sub )( encoder_t *, subpicture_t * );
00167 
00168     /* Common encoder options */
00169     int i_threads;               /* Number of threads to use during encoding */
00170     int i_iframes;               /* One I frame per i_iframes */
00171     int i_bframes;               /* One B frame per i_bframes */
00172     int i_tolerance;             /* Bitrate tolerance */
00173 
00174     /* Encoder config */
00175     config_chain_t *p_cfg;
00176 };
00177 
00178 /**
00179  * @}
00180  */
00181 
00182 
00183 /**
00184  * This function will return a new picture usable by a decoder as an output
00185  * buffer. You have to release it using decoder_DeletePicture or by returning
00186  * it to the caller as a pf_decode_video return value.
00187  */
00188 VLC_API picture_t * decoder_NewPicture( decoder_t * ) VLC_USED;
00189 
00190 /**
00191  * This function will release a picture create by decoder_NewPicture.
00192  */
00193 VLC_API void decoder_DeletePicture( decoder_t *, picture_t *p_picture );
00194 
00195 /**
00196  * This function will increase the picture reference count.
00197  * (picture_Hold is not usable.)
00198  */
00199 VLC_API void decoder_LinkPicture( decoder_t *, picture_t * );
00200 
00201 /**
00202  * This function will decrease the picture reference count.
00203  * (picture_Release is not usable.)
00204  */
00205 VLC_API void decoder_UnlinkPicture( decoder_t *, picture_t * );
00206 
00207 /**
00208  * This function will return a new audio buffer usable by a decoder as an
00209  * output buffer. You have to release it using decoder_DeleteAudioBuffer
00210  * or by returning it to the caller as a pf_decode_audio return value.
00211  */
00212 VLC_API aout_buffer_t * decoder_NewAudioBuffer( decoder_t *, int i_size ) VLC_USED;
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_API subpicture_t * decoder_NewSubpicture( decoder_t *, const subpicture_updater_t * ) VLC_USED;
00220 
00221 /**
00222  * This function will release a subpicture created by decoder_NewSubicture.
00223  */
00224 VLC_API 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_API 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_API mtime_t decoder_GetDisplayDate( decoder_t *, mtime_t ) VLC_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_API int decoder_GetDisplayRate( decoder_t * ) VLC_USED;
00245 
00246 #endif /* _VLC_CODEC_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines