1 /*****************************************************************************
2 * vlc_codec.h: Definition of the decoder and encoder structures
3 *****************************************************************************
4 * Copyright (C) 1999-2003 the VideoLAN team
7 * Authors: Gildas Bazin <gbazin@netcourrier.com>
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.
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.
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 *****************************************************************************/
27 #include <vlc_block.h>
29 #include <vlc_picture.h>
30 #include <vlc_subpicture.h>
34 * This file defines the structure and types used by decoders and encoders
37 typedef struct decoder_owner_sys_t decoder_owner_sys_t
;
40 * \defgroup decoder Decoder
42 * The structure describing a decoder
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.
56 /* Module properties */
58 decoder_sys_t
* p_sys
;
60 /* Input format ie from demuxer (XXX: a lot of field could be invalid) */
63 /* Output format of decoder/packetizer */
66 /* Some decoders only accept packetized data (ie. not truncated) */
67 bool b_need_packetized
;
69 /* Tell the decoder if it is allowed to drop frames */
73 picture_t
* ( * pf_decode_video
)( decoder_t
*, block_t
** );
74 aout_buffer_t
* ( * pf_decode_audio
)( decoder_t
*, block_t
** );
75 subpicture_t
* ( * pf_decode_sub
) ( decoder_t
*, block_t
** );
76 block_t
* ( * pf_packetize
) ( decoder_t
*, block_t
** );
78 /* Closed Caption (CEA 608/708) extraction.
79 * If set, it *may* be called after pf_decode_video/pf_packetize
80 * returned data. It should return CC for the pictures returned by the
81 * last pf_packetize/pf_decode_video call only,
82 * pb_present will be used to known which cc channel are present (but
83 * globaly, not necessary for the current packet */
84 block_t
* ( * pf_get_cc
) ( decoder_t
*, bool pb_present
[4] );
86 /* Meta data at codec level
87 * The decoder owner set it back to NULL once it has retreived what it needs.
88 * The decoder owner is responsible of its release except when you overwrite it.
90 vlc_meta_t
*p_description
;
94 * XXX You MUST not use them directly.
97 /* Video output callbacks
98 * XXX use decoder_NewPicture/decoder_DeletePicture
99 * and decoder_LinkPicture/decoder_UnlinkPicture */
100 picture_t
*(*pf_vout_buffer_new
)( decoder_t
* );
101 void (*pf_vout_buffer_del
)( decoder_t
*, picture_t
* );
102 void (*pf_picture_link
) ( decoder_t
*, picture_t
* );
103 void (*pf_picture_unlink
) ( decoder_t
*, picture_t
* );
105 /* Audio output callbacks
106 * XXX use decoder_NewAudioBuffer/decoder_DeleteAudioBuffer */
107 aout_buffer_t
*(*pf_aout_buffer_new
)( decoder_t
*, int );
108 void (*pf_aout_buffer_del
)( decoder_t
*, aout_buffer_t
* );
110 /* SPU output callbacks
111 * XXX use decoder_NewSubpicture and decoder_DeleteSubpicture */
112 subpicture_t
*(*pf_spu_buffer_new
)( decoder_t
*, const subpicture_updater_t
* );
113 void (*pf_spu_buffer_del
)( decoder_t
*, subpicture_t
* );
116 * XXX use decoder_GetInputAttachments */
117 int (*pf_get_attachments
)( decoder_t
*p_dec
, input_attachment_t
***ppp_attachment
, int *pi_attachment
);
120 * XXX use decoder_GetDisplayDate */
121 mtime_t (*pf_get_display_date
)( decoder_t
*, mtime_t
);
124 * XXX use decoder_GetDisplayRate */
125 int (*pf_get_display_rate
)( decoder_t
* );
127 /* Private structure for the owner of the decoder */
128 decoder_owner_sys_t
*p_owner
;
138 * \defgroup encoder Encoder
140 * The structure describing a Encoder
149 /* Module properties */
151 encoder_sys_t
* p_sys
;
153 /* Properties of the input data fed to the encoder */
156 /* Properties of the output of the encoder */
159 block_t
* ( * pf_encode_video
)( encoder_t
*, picture_t
* );
160 block_t
* ( * pf_encode_audio
)( encoder_t
*, aout_buffer_t
* );
161 block_t
* ( * pf_encode_sub
)( encoder_t
*, subpicture_t
* );
163 /* Common encoder options */
164 int i_threads
; /* Number of threads to use during encoding */
165 int i_iframes
; /* One I frame per i_iframes */
166 int i_bframes
; /* One B frame per i_bframes */
167 int i_tolerance
; /* Bitrate tolerance */
170 config_chain_t
*p_cfg
;
179 * This function will return a new picture usable by a decoder as an output
180 * buffer. You have to release it using decoder_DeletePicture or by returning
181 * it to the caller as a pf_decode_video return value.
183 VLC_EXPORT( picture_t
*, decoder_NewPicture
, ( decoder_t
* ) LIBVLC_USED
);
186 * This function will release a picture create by decoder_NewPicture.
188 VLC_EXPORT( void, decoder_DeletePicture
, ( decoder_t
*, picture_t
*p_picture
) );
191 * This function will increase the picture reference count.
192 * (picture_Hold is not usable.)
194 VLC_EXPORT( void, decoder_LinkPicture
, ( decoder_t
*, picture_t
* ) );
197 * This function will decrease the picture reference count.
198 * (picture_Release is not usable.)
200 VLC_EXPORT( void, decoder_UnlinkPicture
, ( decoder_t
*, picture_t
* ) );
203 * This function will return a new audio buffer usable by a decoder as an
204 * output buffer. You have to release it using decoder_DeleteAudioBuffer
205 * or by returning it to the caller as a pf_decode_audio return value.
207 VLC_EXPORT( aout_buffer_t
*, decoder_NewAudioBuffer
, ( decoder_t
*, int i_size
) LIBVLC_USED
);
210 * This function will release a audio buffer created by decoder_NewAudioBuffer.
212 VLC_EXPORT( void, decoder_DeleteAudioBuffer
, ( decoder_t
*, aout_buffer_t
*p_buffer
) );
215 * This function will return a new subpicture usable by a decoder as an output
216 * buffer. You have to release it using decoder_DeleteSubpicture or by returning
217 * it to the caller as a pf_decode_sub return value.
219 VLC_EXPORT( subpicture_t
*, decoder_NewSubpicture
, ( decoder_t
*, const subpicture_updater_t
* ) LIBVLC_USED
);
222 * This function will release a subpicture created by decoder_NewSubicture.
224 VLC_EXPORT( void, decoder_DeleteSubpicture
, ( decoder_t
*, subpicture_t
*p_subpicture
) );
227 * This function gives all input attachments at once.
229 * You MUST release the returned values
231 VLC_EXPORT( int, decoder_GetInputAttachments
, ( decoder_t
*, input_attachment_t
***ppp_attachment
, int *pi_attachment
) );
234 * This function converts a decoder timestamp into a display date comparable
236 * You MUST use it *only* for gathering statistics about speed.
238 VLC_EXPORT( mtime_t
, decoder_GetDisplayDate
, ( decoder_t
*, mtime_t
) LIBVLC_USED
);
241 * This function returns the current input rate.
242 * You MUST use it *only* for gathering statistics about speed.
244 VLC_EXPORT( int, decoder_GetDisplayRate
, ( decoder_t
* ) LIBVLC_USED
);
246 #endif /* _VLC_CODEC_H */