]> git.sesse.net Git - vlc/blob - include/vlc_codec.h
Stick b_error to object types that actually use it
[vlc] / include / vlc_codec.h
1 /*****************************************************************************
2  * vlc_codec.h: Definition of the decoder and encoder structures
3  *****************************************************************************
4  * Copyright (C) 1999-2003 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Gildas Bazin <gbazin@netcourrier.com>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #ifndef VLC_CODEC_H
25 #define VLC_CODEC_H 1
26
27 #include <vlc_block.h>
28 #include <vlc_es.h>
29 #include <vlc_picture.h>
30 #include <vlc_subpicture.h>
31
32 /**
33  * \file
34  * This file defines the structure and types used by decoders and encoders
35  */
36
37 typedef struct decoder_owner_sys_t decoder_owner_sys_t;
38
39 /**
40  * \defgroup decoder Decoder
41  *
42  * The structure describing a decoder
43  *
44  * @{
45  */
46
47 /*
48  * BIG FAT WARNING : the code relies in the first 4 members of filter_t
49  * and decoder_t to be the same, so if you have anything to add, do it
50  * at the end of the structure.
51  */
52 struct decoder_t
53 {
54     VLC_COMMON_MEMBERS
55
56     /* Module properties */
57     module_t *          p_module;
58     decoder_sys_t *     p_sys;
59     bool                b_error;
60
61     /* Input format ie from demuxer (XXX: a lot of field could be invalid) */
62     es_format_t         fmt_in;
63
64     /* Output format of decoder/packetizer */
65     es_format_t         fmt_out;
66
67     /* Some decoders only accept packetized data (ie. not truncated) */
68     bool                b_need_packetized;
69
70     /* Tell the decoder if it is allowed to drop frames */
71     bool                b_pace_control;
72
73     /* */
74     picture_t *         ( * pf_decode_video )( decoder_t *, block_t ** );
75     aout_buffer_t *     ( * pf_decode_audio )( decoder_t *, block_t ** );
76     subpicture_t *      ( * pf_decode_sub)   ( decoder_t *, block_t ** );
77     block_t *           ( * pf_packetize )   ( decoder_t *, block_t ** );
78
79     /* Closed Caption (CEA 608/708) extraction.
80      * If set, it *may* be called after pf_decode_video/pf_packetize
81      * returned data. It should return CC for the pictures returned by the
82      * last pf_packetize/pf_decode_video call only,
83      * pb_present will be used to known which cc channel are present (but
84      * globaly, not necessary for the current packet */
85     block_t *           ( * pf_get_cc )      ( decoder_t *, bool pb_present[4] );
86
87     /* Meta data at codec level
88      *  The decoder owner set it back to NULL once it has retreived what it needs.
89      *  The decoder owner is responsible of its release except when you overwrite it.
90      */
91     vlc_meta_t          *p_description;
92
93     /*
94      * Owner fields
95      * XXX You MUST not use them directly.
96      */
97
98     /* Video output callbacks
99      * XXX use decoder_NewPicture/decoder_DeletePicture
100      * and decoder_LinkPicture/decoder_UnlinkPicture */
101     picture_t      *(*pf_vout_buffer_new)( decoder_t * );
102     void            (*pf_vout_buffer_del)( decoder_t *, picture_t * );
103     void            (*pf_picture_link)   ( decoder_t *, picture_t * );
104     void            (*pf_picture_unlink) ( decoder_t *, picture_t * );
105
106     /* Audio output callbacks
107      * XXX use decoder_NewAudioBuffer/decoder_DeleteAudioBuffer */
108     aout_buffer_t  *(*pf_aout_buffer_new)( decoder_t *, int );
109     void            (*pf_aout_buffer_del)( decoder_t *, aout_buffer_t * );
110
111     /* SPU output callbacks
112      * XXX use decoder_NewSubpicture and decoder_DeleteSubpicture */
113     subpicture_t   *(*pf_spu_buffer_new)( decoder_t * );
114     void            (*pf_spu_buffer_del)( decoder_t *, subpicture_t * );
115
116     /* Input attachments
117      * XXX use decoder_GetInputAttachments */
118     int             (*pf_get_attachments)( decoder_t *p_dec, input_attachment_t ***ppp_attachment, int *pi_attachment );
119
120     /* Display date
121      * XXX use decoder_GetDisplayDate */
122     mtime_t         (*pf_get_display_date)( decoder_t *, mtime_t );
123
124     /* Display rate
125      * XXX use decoder_GetDisplayRate */
126     int             (*pf_get_display_rate)( decoder_t * );
127
128     /* Private structure for the owner of the decoder */
129     decoder_owner_sys_t *p_owner;
130 };
131
132 /**
133  * @}
134  */
135
136 /**
137  * \defgroup decoder Encoder
138  *
139  * The structure describing a Encoder
140  *
141  * @{
142  */
143
144 struct encoder_t
145 {
146     VLC_COMMON_MEMBERS
147
148     /* Module properties */
149     module_t *          p_module;
150     encoder_sys_t *     p_sys;
151
152     /* Properties of the input data fed to the encoder */
153     es_format_t         fmt_in;
154
155     /* Properties of the output of the encoder */
156     es_format_t         fmt_out;
157
158     block_t *           ( * pf_encode_video )( encoder_t *, picture_t * );
159     block_t *           ( * pf_encode_audio )( encoder_t *, aout_buffer_t * );
160     block_t *           ( * pf_encode_sub )( encoder_t *, subpicture_t * );
161
162     /* Common encoder options */
163     int i_threads;               /* Number of threads to use during encoding */
164     int i_iframes;               /* One I frame per i_iframes */
165     int i_bframes;               /* One B frame per i_bframes */
166     int i_tolerance;             /* Bitrate tolerance */
167
168     /* Encoder config */
169     config_chain_t *p_cfg;
170 };
171
172 /**
173  * @}
174  */
175
176
177 /**
178  * This function will return a new picture usable by a decoder as an output
179  * buffer. You have to release it using decoder_DeletePicture or by returning
180  * it to the caller as a pf_decode_video return value.
181  */
182 VLC_EXPORT( picture_t *, decoder_NewPicture, ( decoder_t * ) LIBVLC_USED );
183
184 /**
185  * This function will release a picture create by decoder_NewPicture.
186  */
187 VLC_EXPORT( void, decoder_DeletePicture, ( decoder_t *, picture_t *p_picture ) );
188
189 /**
190  * This function will increase the picture reference count.
191  * (picture_Hold is not usable.)
192  */
193 VLC_EXPORT( void, decoder_LinkPicture, ( decoder_t *, picture_t * ) );
194
195 /**
196  * This function will decrease the picture reference count.
197  * (picture_Release is not usable.)
198  */
199 VLC_EXPORT( void, decoder_UnlinkPicture, ( decoder_t *, picture_t * ) );
200
201 /**
202  * This function will return a new audio buffer usable by a decoder as an
203  * output buffer. You have to release it using decoder_DeleteAudioBuffer
204  * or by returning it to the caller as a pf_decode_audio return value.
205  */
206 VLC_EXPORT( aout_buffer_t *, decoder_NewAudioBuffer, ( decoder_t *, int i_size ) LIBVLC_USED );
207
208 /**
209  * This function will release a audio buffer created by decoder_NewAudioBuffer.
210  */
211 VLC_EXPORT( void, decoder_DeleteAudioBuffer, ( decoder_t *, aout_buffer_t *p_buffer ) );
212
213 /**
214  * This function will return a new subpicture usable by a decoder as an output
215  * buffer. You have to release it using decoder_DeleteSubpicture or by returning
216  * it to the caller as a pf_decode_sub return value.
217  */
218 VLC_EXPORT( subpicture_t *, decoder_NewSubpicture, ( decoder_t * ) LIBVLC_USED );
219
220 /**
221  * This function will release a subpicture created by decoder_NewSubicture.
222  */
223 VLC_EXPORT( void, decoder_DeleteSubpicture, ( decoder_t *, subpicture_t *p_subpicture ) );
224
225 /**
226  * This function gives all input attachments at once.
227  *
228  * You MUST release the returned values
229  */
230 VLC_EXPORT( int, decoder_GetInputAttachments, ( decoder_t *, input_attachment_t ***ppp_attachment, int *pi_attachment ) );
231
232 /**
233  * This function converts a decoder timestamp into a display date comparable
234  * to mdate().
235  * You MUST use it *only* for gathering statistics about speed.
236  */
237 VLC_EXPORT( mtime_t, decoder_GetDisplayDate, ( decoder_t *, mtime_t ) LIBVLC_USED );
238
239 /**
240  * This function returns the current input rate.
241  * You MUST use it *only* for gathering statistics about speed.
242  */
243 VLC_EXPORT( int, decoder_GetDisplayRate, ( decoder_t * ) LIBVLC_USED );
244
245 #endif /* _VLC_CODEC_H */