]> git.sesse.net Git - vlc/blob - modules/codec/avcodec/avcodec.h
x264: make sure b-pyramid ain't set other than high-profile
[vlc] / modules / codec / avcodec / avcodec.h
1 /*****************************************************************************
2  * avcodec.h: decoder and encoder using libavcodec
3  *****************************************************************************
4  * Copyright (C) 2001-2008 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
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 /* VLC <-> avcodec tables */
25 int GetFfmpegCodec( vlc_fourcc_t i_fourcc, int *pi_cat,
26                     int *pi_ffmpeg_codec, const char **ppsz_name );
27 int GetVlcFourcc( int i_ffmpeg_codec, int *pi_cat,
28                   vlc_fourcc_t *pi_fourcc, const char **ppsz_name );
29 int TestFfmpegChroma( const int i_ffmpeg_id, const vlc_fourcc_t i_vlc_fourcc );
30 int GetFfmpegChroma( int *i_ffmpeg_chroma, const video_format_t fmt );
31 int GetVlcChroma( video_format_t *fmt, const int i_ffmpeg_chroma );
32 void GetVlcAudioFormat( vlc_fourcc_t *, unsigned *pi_bits, int i_sample_fmt );
33
34
35 picture_t * DecodeVideo    ( decoder_t *, block_t ** );
36 aout_buffer_t * DecodeAudio( decoder_t *, block_t ** );
37 subpicture_t *DecodeSubtitle( decoder_t *p_dec, block_t ** );
38
39 /* Video encoder module */
40 int  OpenEncoder ( vlc_object_t * );
41 void CloseEncoder( vlc_object_t * );
42
43 /* Audio encoder module */
44 int  OpenAudioEncoder ( vlc_object_t * );
45 void CloseAudioEncoder( vlc_object_t * );
46
47 /* Deinterlace video filter module */
48 int  OpenDeinterlace( vlc_object_t * );
49 void CloseDeinterlace( vlc_object_t * );
50
51 void InitLibavcodec( vlc_object_t *p_object );
52
53 /* Video Decoder */
54 int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
55                   AVCodec *p_codec, int i_codec_id, const char *psz_namecodec );
56 void EndVideoDec( decoder_t *p_dec );
57
58 /* Audio Decoder */
59 int InitAudioDec( decoder_t *p_dec, AVCodecContext *p_context,
60                   AVCodec *p_codec, int i_codec_id, const char *psz_namecodec );
61 void EndAudioDec( decoder_t *p_dec );
62
63 /* Subtitle Decoder */
64 int InitSubtitleDec( decoder_t *p_dec, AVCodecContext *p_context,
65                      AVCodec *p_codec, int i_codec_id, const char *psz_namecodec );
66 void EndSubtitleDec( decoder_t *p_dec );
67
68
69 /*****************************************************************************
70  * Module descriptor help strings
71  *****************************************************************************/
72 #define DR_TEXT N_("Direct rendering")
73 /* FIXME Does somebody who knows what it does, explain */
74 #define DR_LONGTEXT N_("Direct rendering")
75
76 #define ERROR_TEXT N_("Error resilience")
77 #define ERROR_LONGTEXT N_( \
78     "FFmpeg can do error resilience.\n" \
79     "However, with a buggy encoder (such as the ISO MPEG-4 encoder from M$) " \
80     "this can produce a lot of errors.\n" \
81     "Valid values range from 0 to 4 (0 disables all errors resilience).")
82
83 #define BUGS_TEXT N_("Workaround bugs")
84 #define BUGS_LONGTEXT N_( \
85     "Try to fix some bugs:\n" \
86     "1  autodetect\n" \
87     "2  old msmpeg4\n" \
88     "4  xvid interlaced\n" \
89     "8  ump4 \n" \
90     "16 no padding\n" \
91     "32 ac vlc\n" \
92     "64 Qpel chroma.\n" \
93     "This must be the sum of the values. For example, to fix \"ac vlc\" and " \
94     "\"ump4\", enter 40.")
95
96 #define HURRYUP_TEXT N_("Hurry up")
97 #define HURRYUP_LONGTEXT N_( \
98     "The decoder can partially decode or skip frame(s) " \
99     "when there is not enough time. It's useful with low CPU power " \
100     "but it can produce distorted pictures.")
101
102 #define FAST_TEXT N_("Allow speed tricks")
103 #define FAST_LONGTEXT N_( \
104     "Allow non specification compliant speedup tricks. Faster but error-prone.")
105
106 #define SKIP_FRAME_TEXT N_("Skip frame (default=0)")
107 #define SKIP_FRAME_LONGTEXT N_( \
108     "Force skipping of frames to speed up decoding " \
109     "(-1=None, 0=Default, 1=B-frames, 2=P-frames, 3=B+P frames, 4=all frames)." )
110
111 #define SKIP_IDCT_TEXT N_("Skip idct (default=0)")
112 #define SKIP_IDCT_LONGTEXT N_( \
113     "Force skipping of idct to speed up decoding for frame types" \
114     "(-1=None, 0=Default, 1=B-frames, 2=P-frames, 3=B+P frames, 4=all frames)." )
115
116 #define DEBUG_TEXT N_( "Debug mask" )
117 #define DEBUG_LONGTEXT N_( "Set FFmpeg debug mask" )
118
119 /* TODO: Use a predefined list, with 0,1,2,4,7 */
120 #define VISMV_TEXT N_( "Visualize motion vectors" )
121 #define VISMV_LONGTEXT N_( \
122     "You can overlay the motion vectors (arrows showing how the images move) "\
123     "on the image. This value is a mask, based on these values:\n"\
124     "1 - visualize forward predicted MVs of P frames\n" \
125     "2 - visualize forward predicted MVs of B frames\n" \
126     "4 - visualize backward predicted MVs of B frames\n" \
127     "To visualize all vectors, the value should be 7." )
128
129 #define LOWRES_TEXT N_( "Low resolution decoding" )
130 #define LOWRES_LONGTEXT N_( "Only decode a low resolution version of " \
131     "the video. This requires less processing power" )
132
133 #define SKIPLOOPF_TEXT N_( "Skip the loop filter for H.264 decoding" )
134 #define SKIPLOOPF_LONGTEXT N_( "Skipping the loop filter (aka deblocking) " \
135     "usually has a detrimental effect on quality. However it provides a big " \
136     "speedup for high definition streams." )
137
138 #define HW_TEXT N_("Hardware decoding")
139 #define HW_LONGTEXT N_("This allows hardware decoding when available.")
140
141 #define THREADS_TEXT N_( "Threads" )
142 #define THREADS_LONGTEXT N_( "Number of threads used for decoding, 0 meaning auto" )
143
144 /*
145  * Encoder options
146  */
147 #define ENC_CFG_PREFIX "sout-ffmpeg-"
148
149 #define ENC_KEYINT_TEXT N_( "Ratio of key frames" )
150 #define ENC_KEYINT_LONGTEXT N_( "Number of frames " \
151   "that will be coded for one key frame." )
152
153 #define ENC_BFRAMES_TEXT N_( "Ratio of B frames" )
154 #define ENC_BFRAMES_LONGTEXT N_( "Number of " \
155   "B frames that will be coded between two reference frames." )
156
157 #define ENC_VT_TEXT N_( "Video bitrate tolerance" )
158 #define ENC_VT_LONGTEXT N_( "Video bitrate tolerance in kbit/s." )
159
160 #define ENC_INTERLACE_TEXT N_( "Interlaced encoding" )
161 #define ENC_INTERLACE_LONGTEXT N_( "Enable dedicated " \
162   "algorithms for interlaced frames." )
163
164 #define ENC_INTERLACE_ME_TEXT N_( "Interlaced motion estimation" )
165 #define ENC_INTERLACE_ME_LONGTEXT N_( "Enable interlaced " \
166   "motion estimation algorithms. This requires more CPU." )
167
168 #define ENC_PRE_ME_TEXT N_( "Pre-motion estimation" )
169 #define ENC_PRE_ME_LONGTEXT N_( "Enable the pre-motion " \
170   "estimation algorithm.")
171
172 #define ENC_RC_BUF_TEXT N_( "Rate control buffer size" )
173 #define ENC_RC_BUF_LONGTEXT N_( "Rate control " \
174   "buffer size (in kbytes). A bigger buffer will allow for better rate " \
175   "control, but will cause a delay in the stream." )
176
177 #define ENC_RC_BUF_AGGR_TEXT N_( "Rate control buffer aggressiveness" )
178 #define ENC_RC_BUF_AGGR_LONGTEXT N_( "Rate control "\
179   "buffer aggressiveness." )
180
181 #define ENC_IQUANT_FACTOR_TEXT N_( "I quantization factor" )
182 #define ENC_IQUANT_FACTOR_LONGTEXT N_(  \
183   "Quantization factor of I frames, compared with P frames (for instance " \
184   "1.0 => same qscale for I and P frames)." )
185
186 #define ENC_NOISE_RED_TEXT N_( "Noise reduction" )
187 #define ENC_NOISE_RED_LONGTEXT N_( "Enable a simple noise " \
188   "reduction algorithm to lower the encoding length and bitrate, at the " \
189   "expense of lower quality frames." )
190
191 #define ENC_MPEG4_MATRIX_TEXT N_( "MPEG4 quantization matrix" )
192 #define ENC_MPEG4_MATRIX_LONGTEXT N_( "Use the MPEG4 " \
193   "quantization matrix for MPEG2 encoding. This generally yields a " \
194   "better looking picture, while still retaining the compatibility with " \
195   "standard MPEG2 decoders.")
196
197 #define ENC_HQ_TEXT N_( "Quality level" )
198 #define ENC_HQ_LONGTEXT N_( "Quality level " \
199   "for the encoding of motions vectors (this can slow down the encoding " \
200   "very much)." )
201
202 #define ENC_HURRYUP_TEXT N_( "Hurry up" )
203 #define ENC_HURRYUP_LONGTEXT N_( "The encoder " \
204   "can make on-the-fly quality tradeoffs if your CPU can't keep up with " \
205   "the encoding rate. It will disable trellis quantization, then the rate " \
206   "distortion of motion vectors (hq), and raise the noise reduction " \
207   "threshold to ease the encoder's task." )
208
209 #define ENC_QMIN_TEXT N_( "Minimum video quantizer scale" )
210 #define ENC_QMIN_LONGTEXT N_( "Minimum video " \
211   "quantizer scale." )
212
213 #define ENC_QMAX_TEXT N_( "Maximum video quantizer scale" )
214 #define ENC_QMAX_LONGTEXT N_( "Maximum video " \
215   "quantizer scale." )
216
217 #define ENC_TRELLIS_TEXT N_( "Trellis quantization" )
218 #define ENC_TRELLIS_LONGTEXT N_( "Enable trellis " \
219   "quantization (rate distortion for block coefficients)." )
220
221 #define ENC_QSCALE_TEXT N_( "Fixed quantizer scale" )
222 #define ENC_QSCALE_LONGTEXT N_( "A fixed video " \
223   "quantizer scale for VBR encoding (accepted values: 0.01 to 255.0)." )
224
225 #define ENC_STRICT_TEXT N_( "Strict standard compliance" )
226 #define ENC_STRICT_LONGTEXT N_( "Force a strict standard " \
227   "compliance when encoding (accepted values: -1, 0, 1)." )
228
229 #define ENC_LUMI_MASKING_TEXT N_( "Luminance masking" )
230 #define ENC_LUMI_MASKING_LONGTEXT N_( "Raise the quantizer for " \
231   "very bright macroblocks (default: 0.0)." )
232
233 #define ENC_DARK_MASKING_TEXT N_( "Darkness masking" )
234 #define ENC_DARK_MASKING_LONGTEXT N_( "Raise the quantizer for " \
235   "very dark macroblocks (default: 0.0)." )
236
237 #define ENC_P_MASKING_TEXT N_( "Motion masking" )
238 #define ENC_P_MASKING_LONGTEXT N_( "Raise the quantizer for " \
239   "macroblocks with a high temporal complexity (default: 0.0)." )
240
241 #define ENC_BORDER_MASKING_TEXT N_( "Border masking" )
242 #define ENC_BORDER_MASKING_LONGTEXT N_( "Raise the quantizer " \
243   "for macroblocks at the border of the frame (default: 0.0)." )
244
245 #define ENC_LUMA_ELIM_TEXT N_( "Luminance elimination" )
246 #define ENC_LUMA_ELIM_LONGTEXT N_( "Eliminates luminance blocks when " \
247   "the PSNR isn't much changed (default: 0.0). The H264 specification " \
248   "recommends -4." )
249
250 #define ENC_CHROMA_ELIM_TEXT N_( "Chrominance elimination" )
251 #define ENC_CHROMA_ELIM_LONGTEXT N_( "Eliminates chrominance blocks when " \
252   "the PSNR isn't much changed (default: 0.0). The H264 specification " \
253   "recommends 7." )
254
255 #define ENC_PROFILE_TEXT N_( "Specify AAC audio profile to use" )
256 #define ENC_PROFILE_LONGTEXT N_( "Specify the AAC audio profile to use " \
257    "for encoding the audio bitstream. It takes the following options: " \
258    "main, low, ssr (not supported) and ltp (default: main)" )
259
260 #define FFMPEG_COMMON_MEMBERS   \
261     int i_cat;                  \
262     int i_codec_id;             \
263     const char *psz_namecodec;  \
264     AVCodecContext *p_context;  \
265     AVCodec        *p_codec;    \
266     bool b_delayed_open;
267
268 #ifndef AV_VERSION_INT
269 #   define AV_VERSION_INT(a, b, c) ((a)<<16 | (b)<<8 | (c))
270 #endif
271
272 /* Uncomment it to enable compilation with vaapi/dxva2 (you also must change the build
273  * system) */
274 //#define HAVE_AVCODEC_VAAPI 1
275 //#define HAVE_AVCODEC_DXVA2 1