Fix a memleak when using the --use-stream-immediate option.
[vlc.git] / include / vlc_codec.h
blobffc33e7b6caaaea06873838168c1b2c457dbb814
1 /*****************************************************************************
2 * vlc_codec.h: Definition of the decoder and encoder structures
3 *****************************************************************************
4 * Copyright (C) 1999-2003 the VideoLAN team
5 * $Id$
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 *****************************************************************************/
24 #ifndef _VLC_CODEC_H
25 #define _VLC_CODEC_H 1
27 #include <vlc_block.h>
28 #include <vlc_es.h>
30 /**
31 * \file
32 * This file defines the structure and types used by decoders and encoders
35 typedef struct decoder_owner_sys_t decoder_owner_sys_t;
37 /**
38 * \defgroup decoder Decoder
40 * The structure describing a decoder
42 * @{
46 * BIG FAT WARNING : the code relies in the first 4 members of filter_t
47 * and decoder_t to be the same, so if you have anything to add, do it
48 * at the end of the structure.
50 struct decoder_t
52 VLC_COMMON_MEMBERS
54 /* Module properties */
55 module_t * p_module;
56 decoder_sys_t * p_sys;
58 /* Input format ie from demuxer (XXX: a lot of field could be invalid) */
59 es_format_t fmt_in;
61 /* Output format of decoder/packetizer */
62 es_format_t fmt_out;
64 /* Some decoders only accept packetized data (ie. not truncated) */
65 bool b_need_packetized;
67 /* Tell the decoder if it is allowed to drop frames */
68 bool b_pace_control;
70 /* */
71 picture_t * ( * pf_decode_video )( decoder_t *, block_t ** );
72 aout_buffer_t * ( * pf_decode_audio )( decoder_t *, block_t ** );
73 subpicture_t * ( * pf_decode_sub) ( decoder_t *, block_t ** );
74 block_t * ( * pf_packetize ) ( decoder_t *, block_t ** );
76 /* Closed Caption (CEA 608/708) extraction.
77 * If set, it *may* be called after pf_decode_video/pf_packetize
78 * returned data. It should return CC for the pictures returned by the
79 * last pf_packetize/pf_decode_video call only,
80 * pb_present will be used to known which cc channel are present (but
81 * globaly, not necessary for the current packet */
82 block_t * ( * pf_get_cc ) ( decoder_t *, bool pb_present[4] );
85 * Buffers allocation
88 /* Audio output callbacks */
89 aout_buffer_t * ( * pf_aout_buffer_new) ( decoder_t *, int );
90 void ( * pf_aout_buffer_del) ( decoder_t *, aout_buffer_t * );
92 /* Video output callbacks */
93 picture_t * ( * pf_vout_buffer_new) ( decoder_t * );
94 void ( * pf_vout_buffer_del) ( decoder_t *, picture_t * );
95 void ( * pf_picture_link) ( decoder_t *, picture_t * );
96 void ( * pf_picture_unlink) ( decoder_t *, picture_t * );
98 /* SPU output callbacks */
99 subpicture_t * ( * pf_spu_buffer_new) ( decoder_t * );
100 void ( * pf_spu_buffer_del) ( decoder_t *, subpicture_t * );
102 /* Private structure for the owner of the decoder */
103 decoder_owner_sys_t *p_owner;
107 * @}
111 * \defgroup decoder Encoder
113 * The structure describing a Encoder
115 * @{
118 struct encoder_t
120 VLC_COMMON_MEMBERS
122 /* Module properties */
123 module_t * p_module;
124 encoder_sys_t * p_sys;
126 /* Properties of the input data fed to the encoder */
127 es_format_t fmt_in;
129 /* Properties of the output of the encoder */
130 es_format_t fmt_out;
132 block_t * ( * pf_encode_video )( encoder_t *, picture_t * );
133 block_t * ( * pf_encode_audio )( encoder_t *, aout_buffer_t * );
134 block_t * ( * pf_encode_sub )( encoder_t *, subpicture_t * );
136 /* Common encoder options */
137 int i_threads; /* Number of threads to use during encoding */
138 int i_iframes; /* One I frame per i_iframes */
139 int i_bframes; /* One B frame per i_bframes */
140 int i_tolerance; /* Bitrate tolerance */
142 /* Encoder config */
143 config_chain_t *p_cfg;
147 * @}
150 VLC_EXPORT( input_attachment_t *, decoder_GetInputAttachment, ( decoder_t *, const char *psz_name ) );
151 VLC_EXPORT( int, decoder_GetInputAttachments, ( decoder_t *p_dec, input_attachment_t ***ppp_attachment, int *pi_attachment ) );
152 VLC_EXPORT( mtime_t, decoder_GetDisplayDate, ( decoder_t *, mtime_t ) );
154 #endif /* _VLC_CODEC_H */