1 /*****************************************************************************
2 * avcodec.h: decoder and encoder using libavcodec
3 *****************************************************************************
4 * Copyright (C) 2001-2008 VLC authors and VideoLAN
7 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
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 /* VLC <-> avcodec tables */
28 int GetFfmpegCodec( vlc_fourcc_t i_fourcc, int *pi_cat,
29 unsigned *pi_ffmpeg_codec, const char **ppsz_name );
30 int GetVlcFourcc( unsigned i_ffmpeg_codec, int *pi_cat,
31 vlc_fourcc_t *pi_fourcc, const char **ppsz_name );
32 vlc_fourcc_t GetVlcAudioFormat( int i_sample_fmt );
34 /* Video encoder module */
35 int OpenEncoder ( vlc_object_t * );
36 void CloseEncoder( vlc_object_t * );
38 /* Audio encoder module */
39 int OpenAudioEncoder ( vlc_object_t * );
40 void CloseAudioEncoder( vlc_object_t * );
42 /* Deinterlace video filter module */
43 int OpenDeinterlace( vlc_object_t * );
44 void CloseDeinterlace( vlc_object_t * );
47 int InitVideoDec( decoder_t *, AVCodecContext *, const AVCodec * );
48 void EndVideoDec( decoder_t *p_dec );
51 int InitAudioDec( decoder_t *, AVCodecContext *, const AVCodec * );
53 /* Subtitle Decoder */
54 int InitSubtitleDec( decoder_t *, AVCodecContext *, const AVCodec * );
56 /* Initialize decoder */
57 int ffmpeg_OpenCodec( decoder_t *p_dec );
58 void ffmpeg_CloseCodec( decoder_t *p_dec );
60 /*****************************************************************************
61 * Module descriptor help strings
62 *****************************************************************************/
63 #define DR_TEXT N_("Direct rendering")
64 /* FIXME Does somebody who knows what it does, explain */
66 #define ERROR_TEXT N_("Error resilience")
67 #define ERROR_LONGTEXT N_( \
68 "libavcodec can do error resilience.\n" \
69 "However, with a buggy encoder (such as the ISO MPEG-4 encoder from M$) " \
70 "this can produce a lot of errors.\n" \
71 "Valid values range from 0 to 4 (0 disables all errors resilience).")
73 #define BUGS_TEXT N_("Workaround bugs")
74 #define BUGS_LONGTEXT N_( \
75 "Try to fix some bugs:\n" \
78 "4 xvid interlaced\n" \
83 "This must be the sum of the values. For example, to fix \"ac vlc\" and " \
84 "\"ump4\", enter 40.")
86 #define HURRYUP_TEXT N_("Hurry up")
87 #define HURRYUP_LONGTEXT N_( \
88 "The decoder can partially decode or skip frame(s) " \
89 "when there is not enough time. It's useful with low CPU power " \
90 "but it can produce distorted pictures.")
92 #define FAST_TEXT N_("Allow speed tricks")
93 #define FAST_LONGTEXT N_( \
94 "Allow non specification compliant speedup tricks. Faster but error-prone.")
96 #define SKIP_FRAME_TEXT N_("Skip frame (default=0)")
97 #define SKIP_FRAME_LONGTEXT N_( \
98 "Force skipping of frames to speed up decoding " \
99 "(-1=None, 0=Default, 1=B-frames, 2=P-frames, 3=B+P frames, 4=all frames)." )
101 #define SKIP_IDCT_TEXT N_("Skip idct (default=0)")
102 #define SKIP_IDCT_LONGTEXT N_( \
103 "Force skipping of idct to speed up decoding for frame types " \
104 "(-1=None, 0=Default, 1=B-frames, 2=P-frames, 3=B+P frames, 4=all frames)." )
106 #define DEBUG_TEXT N_( "Debug mask" )
107 #define DEBUG_LONGTEXT N_( "Set FFmpeg debug mask" )
109 #define CODEC_TEXT N_( "Codec name" )
110 #define CODEC_LONGTEXT N_( "Internal libavcodec codec name" )
112 #define SKIPLOOPF_TEXT N_( "Skip the loop filter for H.264 decoding" )
113 #define SKIPLOOPF_LONGTEXT N_( "Skipping the loop filter (aka deblocking) " \
114 "usually has a detrimental effect on quality. However it provides a big " \
115 "speedup for high definition streams." )
117 #define HW_TEXT N_("Hardware decoding")
118 #define HW_LONGTEXT N_("This allows hardware decoding when available.")
120 #define VDA_PIX_FMT_TEXT N_("VDA output pixel format")
121 #define VDA_PIX_FMT_LONGTEXT N_("The pixel format for output image buffers.")
123 #define THREADS_TEXT N_( "Threads" )
124 #define THREADS_LONGTEXT N_( "Number of threads used for decoding, 0 meaning auto" )
129 #define ENC_CFG_PREFIX "sout-avcodec-"
131 #define ENC_KEYINT_TEXT N_( "Ratio of key frames" )
132 #define ENC_KEYINT_LONGTEXT N_( "Number of frames " \
133 "that will be coded for one key frame." )
135 #define ENC_BFRAMES_TEXT N_( "Ratio of B frames" )
136 #define ENC_BFRAMES_LONGTEXT N_( "Number of " \
137 "B frames that will be coded between two reference frames." )
139 #define ENC_VT_TEXT N_( "Video bitrate tolerance" )
140 #define ENC_VT_LONGTEXT N_( "Video bitrate tolerance in kbit/s." )
142 #define ENC_INTERLACE_TEXT N_( "Interlaced encoding" )
143 #define ENC_INTERLACE_LONGTEXT N_( "Enable dedicated " \
144 "algorithms for interlaced frames." )
146 #define ENC_INTERLACE_ME_TEXT N_( "Interlaced motion estimation" )
147 #define ENC_INTERLACE_ME_LONGTEXT N_( "Enable interlaced " \
148 "motion estimation algorithms. This requires more CPU." )
150 #define ENC_PRE_ME_TEXT N_( "Pre-motion estimation" )
151 #define ENC_PRE_ME_LONGTEXT N_( "Enable the pre-motion " \
152 "estimation algorithm.")
154 #define ENC_RC_BUF_TEXT N_( "Rate control buffer size" )
155 #define ENC_RC_BUF_LONGTEXT N_( "Rate control " \
156 "buffer size (in kbytes). A bigger buffer will allow for better rate " \
157 "control, but will cause a delay in the stream." )
159 #define ENC_RC_BUF_AGGR_TEXT N_( "Rate control buffer aggressiveness" )
160 #define ENC_RC_BUF_AGGR_LONGTEXT N_( "Rate control "\
161 "buffer aggressiveness." )
163 #define ENC_IQUANT_FACTOR_TEXT N_( "I quantization factor" )
164 #define ENC_IQUANT_FACTOR_LONGTEXT N_( \
165 "Quantization factor of I frames, compared with P frames (for instance " \
166 "1.0 => same qscale for I and P frames)." )
168 #define ENC_NOISE_RED_TEXT N_( "Noise reduction" )
169 #define ENC_NOISE_RED_LONGTEXT N_( "Enable a simple noise " \
170 "reduction algorithm to lower the encoding length and bitrate, at the " \
171 "expense of lower quality frames." )
173 #define ENC_MPEG4_MATRIX_TEXT N_( "MPEG4 quantization matrix" )
174 #define ENC_MPEG4_MATRIX_LONGTEXT N_( "Use the MPEG4 " \
175 "quantization matrix for MPEG2 encoding. This generally yields a " \
176 "better looking picture, while still retaining the compatibility with " \
177 "standard MPEG2 decoders.")
179 #define ENC_HQ_TEXT N_( "Quality level" )
180 #define ENC_HQ_LONGTEXT N_( "Quality level " \
181 "for the encoding of motions vectors (this can slow down the encoding " \
184 #define ENC_HURRYUP_TEXT N_( "Hurry up" )
185 #define ENC_HURRYUP_LONGTEXT N_( "The encoder " \
186 "can make on-the-fly quality tradeoffs if your CPU can't keep up with " \
187 "the encoding rate. It will disable trellis quantization, then the rate " \
188 "distortion of motion vectors (hq), and raise the noise reduction " \
189 "threshold to ease the encoder's task." )
191 #define ENC_QMIN_TEXT N_( "Minimum video quantizer scale" )
192 #define ENC_QMIN_LONGTEXT N_( "Minimum video " \
195 #define ENC_QMAX_TEXT N_( "Maximum video quantizer scale" )
196 #define ENC_QMAX_LONGTEXT N_( "Maximum video " \
199 #define ENC_TRELLIS_TEXT N_( "Trellis quantization" )
200 #define ENC_TRELLIS_LONGTEXT N_( "Enable trellis " \
201 "quantization (rate distortion for block coefficients)." )
203 #define ENC_QSCALE_TEXT N_( "Fixed quantizer scale" )
204 #define ENC_QSCALE_LONGTEXT N_( "A fixed video " \
205 "quantizer scale for VBR encoding (accepted values: 0.01 to 255.0)." )
207 #define ENC_STRICT_TEXT N_( "Strict standard compliance" )
208 #define ENC_STRICT_LONGTEXT N_( "Force a strict standard " \
209 "compliance when encoding (accepted values: -2 to 2)." )
211 #define ENC_LUMI_MASKING_TEXT N_( "Luminance masking" )
212 #define ENC_LUMI_MASKING_LONGTEXT N_( "Raise the quantizer for " \
213 "very bright macroblocks (default: 0.0)." )
215 #define ENC_DARK_MASKING_TEXT N_( "Darkness masking" )
216 #define ENC_DARK_MASKING_LONGTEXT N_( "Raise the quantizer for " \
217 "very dark macroblocks (default: 0.0)." )
219 #define ENC_P_MASKING_TEXT N_( "Motion masking" )
220 #define ENC_P_MASKING_LONGTEXT N_( "Raise the quantizer for " \
221 "macroblocks with a high temporal complexity (default: 0.0)." )
223 #define ENC_BORDER_MASKING_TEXT N_( "Border masking" )
224 #define ENC_BORDER_MASKING_LONGTEXT N_( "Raise the quantizer " \
225 "for macroblocks at the border of the frame (default: 0.0)." )
227 #define ENC_LUMA_ELIM_TEXT N_( "Luminance elimination" )
228 #define ENC_LUMA_ELIM_LONGTEXT N_( "Eliminates luminance blocks when " \
229 "the PSNR isn't much changed (default: 0.0). The H264 specification " \
232 #define ENC_CHROMA_ELIM_TEXT N_( "Chrominance elimination" )
233 #define ENC_CHROMA_ELIM_LONGTEXT N_( "Eliminates chrominance blocks when " \
234 "the PSNR isn't much changed (default: 0.0). The H264 specification " \
237 #define ENC_PROFILE_TEXT N_( "Specify AAC audio profile to use" )
238 #define ENC_PROFILE_LONGTEXT N_( "Specify the AAC audio profile to use " \
239 "for encoding the audio bitstream. It takes the following options: " \
240 "main, low, ssr (not supported),ltp, hev1, hev2 (default: low). " \
241 "hev1 and hev2 are currently supported only with libfdk-aac enabled libavcodec" )
243 #define AVCODEC_COMMON_MEMBERS \
244 AVCodecContext *p_context; \
245 const AVCodec *p_codec; \
248 #ifndef AV_VERSION_INT
249 # define AV_VERSION_INT(a, b, c) ((a)<<16 | (b)<<8 | (c))
252 #if defined(FF_THREAD_FRAME)
253 # define HAVE_AVCODEC_MT