1 /*****************************************************************************
2 * vlc_codec.h: Definition of the decoder and encoder structures
3 *****************************************************************************
4 * Copyright (C) 1999-2003 VLC authors and VideoLAN
7 * Authors: Gildas Bazin <gbazin@netcourrier.com>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * 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>
33 * \defgroup codec Codec
34 * Decoders and encoders
37 * Decoder and encoder modules interface
39 * \defgroup decoder Decoder
40 * Audio, video and text decoders
44 typedef struct decoder_owner_sys_t decoder_owner_sys_t
;
47 * BIG FAT WARNING : the code relies in the first 4 members of filter_t
48 * and decoder_t to be the same, so if you have anything to add, do it
49 * at the end of the structure.
55 /* Module properties */
57 decoder_sys_t
* p_sys
;
59 /* Input format ie from demuxer (XXX: a lot of field could be invalid) */
62 /* Output format of decoder/packetizer */
65 /* Some decoders only accept packetized data (ie. not truncated) */
66 bool b_need_packetized
;
68 /* Tell the decoder if it is allowed to drop frames */
72 picture_t
* ( * pf_decode_video
)( decoder_t
*, block_t
** );
73 block_t
* ( * pf_decode_audio
)( decoder_t
*, block_t
** );
74 subpicture_t
* ( * pf_decode_sub
) ( decoder_t
*, block_t
** );
75 block_t
* ( * pf_packetize
) ( decoder_t
*, block_t
** );
77 /* Closed Caption (CEA 608/708) extraction.
78 * If set, it *may* be called after pf_decode_video/pf_packetize
79 * returned data. It should return CC for the pictures returned by the
80 * last pf_packetize/pf_decode_video call only,
81 * pb_present will be used to known which cc channel are present (but
82 * globaly, not necessary for the current packet */
83 block_t
* ( * pf_get_cc
) ( decoder_t
*, bool pb_present
[4] );
85 /* Meta data at codec level
86 * The decoder owner set it back to NULL once it has retreived what it needs.
87 * The decoder owner is responsible of its release except when you overwrite it.
89 vlc_meta_t
*p_description
;
93 * XXX You MUST not use them directly.
96 /* Video output callbacks
97 * XXX use decoder_NewPicture */
98 int (*pf_vout_format_update
)( decoder_t
* );
99 picture_t
*(*pf_vout_buffer_new
)( decoder_t
* );
102 * Number of extra (ie in addition to the DPB) picture buffers
103 * needed for decoding.
105 int i_extra_picture_buffers
;
107 /* Audio output callbacks */
108 int (*pf_aout_format_update
)( decoder_t
* );
110 /* SPU output callbacks
111 * XXX use decoder_NewSubpicture */
112 subpicture_t
*(*pf_spu_buffer_new
)( decoder_t
*, const subpicture_updater_t
* );
115 * XXX use decoder_GetInputAttachments */
116 int (*pf_get_attachments
)( decoder_t
*p_dec
, input_attachment_t
***ppp_attachment
, int *pi_attachment
);
119 * XXX use decoder_GetDisplayDate */
120 mtime_t (*pf_get_display_date
)( decoder_t
*, mtime_t
);
123 * XXX use decoder_GetDisplayRate */
124 int (*pf_get_display_rate
)( decoder_t
* );
126 /* Private structure for the owner of the decoder */
127 decoder_owner_sys_t
*p_owner
;
137 * \defgroup encoder Encoder
138 * Audio, video and text encoders
146 /* Module properties */
148 encoder_sys_t
* p_sys
;
150 /* Properties of the input data fed to the encoder */
153 /* Properties of the output of the encoder */
156 block_t
* ( * pf_encode_video
)( encoder_t
*, picture_t
* );
157 block_t
* ( * pf_encode_audio
)( encoder_t
*, block_t
* );
158 block_t
* ( * pf_encode_sub
)( encoder_t
*, subpicture_t
* );
160 /* Common encoder options */
161 int i_threads
; /* Number of threads to use during encoding */
162 int i_iframes
; /* One I frame per i_iframes */
163 int i_bframes
; /* One B frame per i_bframes */
164 int i_tolerance
; /* Bitrate tolerance */
167 config_chain_t
*p_cfg
;
178 * This function notifies the video output pipeline of a new video output
179 * format (fmt_out.video). If there is currently no video output or if the
180 * video output format has changed, a new video output will be set up.
181 * @return 0 if the video output is working, -1 if not. */
182 static inline int decoder_UpdateVideoFormat( decoder_t
*dec
)
184 if( dec
->pf_vout_format_update
!= NULL
)
185 return dec
->pf_vout_format_update( dec
);
191 * This function will return a new picture usable by a decoder as an output
192 * buffer. You have to release it using picture_Release() or by returning
193 * it to the caller as a pf_decode_video return value.
195 VLC_API picture_t
* decoder_NewPicture( decoder_t
* ) VLC_USED
;
198 * This function notifies the audio output pipeline of a new audio output
199 * format (fmt_out.audio). If there is currently no audio output or if the
200 * audio output format has changed, a new audio output will be set up.
201 * @return 0 if the audio output is working, -1 if not. */
202 static inline int decoder_UpdateAudioFormat( decoder_t
*dec
)
204 if( dec
->pf_aout_format_update
!= NULL
)
205 return dec
->pf_aout_format_update( dec
);
211 * This function will return a new audio buffer usable by a decoder as an
212 * output buffer. It must be released with block_Release() or returned it to
213 * the caller as a pf_decode_audio return value.
215 VLC_API block_t
* decoder_NewAudioBuffer( decoder_t
*, int i_size
) VLC_USED
;
218 * This function will return a new subpicture usable by a decoder as an output
219 * buffer. You have to release it using subpicture_Delete() or by returning
220 * it to the caller as a pf_decode_sub return value.
222 VLC_API subpicture_t
* decoder_NewSubpicture( decoder_t
*, const subpicture_updater_t
* ) VLC_USED
;
225 * This function gives all input attachments at once.
227 * You MUST release the returned values
229 VLC_API
int decoder_GetInputAttachments( decoder_t
*, input_attachment_t
***ppp_attachment
, int *pi_attachment
);
232 * This function converts a decoder timestamp into a display date comparable
234 * You MUST use it *only* for gathering statistics about speed.
236 VLC_API mtime_t
decoder_GetDisplayDate( decoder_t
*, mtime_t
) VLC_USED
;
239 * This function returns the current input rate.
240 * You MUST use it *only* for gathering statistics about speed.
242 VLC_API
int decoder_GetDisplayRate( decoder_t
* ) VLC_USED
;
246 #endif /* _VLC_CODEC_H */