1 /*****************************************************************************
2 * ffmpeg.h: decoder using the ffmpeg library
3 *****************************************************************************
4 * Copyright (C) 2001 the VideoLAN team
7 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
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 #include "codecs.h" /* BITMAPINFOHEADER */
26 #if LIBAVCODEC_BUILD >= 4663
27 # define LIBAVCODEC_PP
34 struct AVCodecContext;
37 void E_(InitLibavcodec)( vlc_object_t * );
38 int E_(GetFfmpegCodec) ( vlc_fourcc_t, int *, int *, char ** );
39 int E_(GetVlcFourcc) ( int, int *, vlc_fourcc_t *, char ** );
40 int E_(GetFfmpegChroma)( vlc_fourcc_t );
41 vlc_fourcc_t E_(GetVlcChroma)( int );
43 /* Video decoder module */
44 int E_( InitVideoDec )( decoder_t *, AVCodecContext *, AVCodec *,
46 void E_( EndVideoDec ) ( decoder_t * );
47 picture_t *E_( DecodeVideo ) ( decoder_t *, block_t ** );
49 /* Audio decoder module */
50 int E_( InitAudioDec )( decoder_t *, AVCodecContext *, AVCodec *,
52 void E_( EndAudioDec ) ( decoder_t * );
53 aout_buffer_t *E_( DecodeAudio ) ( decoder_t *, block_t ** );
55 /* Chroma conversion module */
56 int E_(OpenChroma)( vlc_object_t * );
57 void E_(CloseChroma)( vlc_object_t * );
59 /* Video encoder module */
60 int E_(OpenEncoder) ( vlc_object_t * );
61 void E_(CloseEncoder)( vlc_object_t * );
63 /* Audio encoder module */
64 int E_(OpenAudioEncoder) ( vlc_object_t * );
65 void E_(CloseAudioEncoder)( vlc_object_t * );
68 int E_(OpenDemux) ( vlc_object_t * );
69 void E_(CloseDemux)( vlc_object_t * );
71 /* Video filter module */
72 int E_(OpenFilter)( vlc_object_t * );
73 int E_(OpenCropPadd)( vlc_object_t * );
74 void E_(CloseFilter)( vlc_object_t * );
75 int E_(OpenDeinterlace)( vlc_object_t * );
76 void E_(CloseDeinterlace)( vlc_object_t * );
78 /* Postprocessing module */
79 void *E_(OpenPostproc)( decoder_t *, vlc_bool_t * );
80 int E_(InitPostproc)( decoder_t *, void *, int, int, int );
81 int E_(PostprocPict)( decoder_t *, void *, picture_t *, AVFrame * );
82 void E_(ClosePostproc)( decoder_t *, void * );
84 /*****************************************************************************
85 * Module descriptor help strings
86 *****************************************************************************/
87 #define DR_TEXT N_("Direct rendering")
88 /* FIXME Does somebody who knows what it does, explain */
89 #define DR_LONGTEXT N_("Direct rendering")
91 #define ERROR_TEXT N_("Error resilience")
92 #define ERROR_LONGTEXT N_( \
93 "Ffmpeg can do error resilience.\n" \
94 "However, with a buggy encoder (such as the ISO MPEG-4 encoder from M$) " \
95 "this can produce a lot of errors.\n" \
96 "Valid values range from 0 to 4 (0 disables all errors resilience).")
98 #define BUGS_TEXT N_("Workaround bugs")
99 #define BUGS_LONGTEXT N_( \
100 "Try to fix some bugs:\n" \
103 "4 xvid interlaced\n" \
107 "64 Qpel chroma.\n" \
108 "This must be the sum of the values. For example, to fix \"ac vlc\" and " \
109 "\"ump4\", enter 40.")
111 #define HURRYUP_TEXT N_("Hurry up")
112 #define HURRYUP_LONGTEXT N_( \
113 "The decoder can partially decode or skip frame(s) " \
114 "when there is not enough time. It's useful with low CPU power " \
115 "but it can produce distorted pictures.")
117 #define PP_Q_TEXT N_("Post processing quality")
118 #define PP_Q_LONGTEXT N_( \
119 "Quality of post processing. Valid range is 0 to 6\n" \
120 "Higher levels require considerable more CPU power, but produce " \
121 "better looking pictures." )
123 #define DEBUG_TEXT N_( "Debug mask" )
124 #define DEBUG_LONGTEXT N_( "Set ffmpeg debug mask" )
126 /* TODO: Use a predefined list, with 0,1,2,4,7 */
127 #define VISMV_TEXT N_( "Visualize motion vectors" )
128 #define VISMV_LONGTEXT N_( \
129 "You can overlay the motion vectors (arrows showing how the images move) "\
130 "on the image. This value is a mask, based on these values:\n"\
131 "1 - visualize forward predicted MVs of P frames\n" \
132 "2 - visualize forward predicted MVs of B frames\n" \
133 "4 - visualize backward predicted MVs of B frames\n" \
134 "To visualize all vectors, the value should be 7." )
136 #define LOWRES_TEXT N_( "Low resolution decoding" )
137 #define LOWRES_LONGTEXT N_( "Only decode a low resolution version of " \
138 "the video. This requires less processing power" )
140 #define SKIPLOOPF_TEXT N_( "Skip the loop filter for H.264 decoding" )
141 #define SKIPLOOPF_LONGTEXT N_( "Skipping the loop filter (aka deblocking) " \
142 "usually has a detrimental effect on quality. However it provides a big " \
143 "speedup for high definition streams." )
145 #define LIBAVCODEC_PP_TEXT N_("FFmpeg post processing filter chains")
146 /* FIXME (cut/past from ffmpeg */
147 #define LIBAVCODEC_PP_LONGTEXT \
148 "<filterName>[:<option>[:<option>...]][[,|/][-]<filterName>[:<option>...]]...\n" \
149 "long form example:\n" \
150 "vdeblock:autoq/hdeblock:autoq/linblenddeint default,-vdeblock\n" \
151 "short form example:\n" \
152 "vb:a/hb:a/lb de,-vb\n" \
155 "Filters Options\n" \
156 "short long name short long option Description\n" \
157 "* * a autoq cpu power dependant enabler\n" \
158 " c chrom chrominance filtring enabled\n" \
159 " y nochrom chrominance filtring disabled\n" \
160 "hb hdeblock (2 Threshold) horizontal deblocking filter\n" \
161 " 1. difference factor: default=64, higher -> more deblocking\n" \
162 " 2. flatness threshold: default=40, lower -> more deblocking\n" \
163 " the h & v deblocking filters share these\n" \
164 " so u cant set different thresholds for h / v\n" \
165 "vb vdeblock (2 Threshold) vertical deblocking filter\n" \
166 "h1 x1hdeblock Experimental h deblock filter 1\n" \
167 "v1 x1vdeblock Experimental v deblock filter 1\n" \
168 "dr dering Deringing filter\n" \
169 "al autolevels automatic brightness / contrast\n" \
170 " f fullyrange stretch luminance to (0..255)\n" \
171 "lb linblenddeint linear blend deinterlacer\n" \
172 "li linipoldeint linear interpolating deinterlace\n" \
173 "ci cubicipoldeint cubic interpolating deinterlacer\n" \
174 "md mediandeint median deinterlacer\n" \
175 "fd ffmpegdeint ffmpeg deinterlacer\n" \
176 "de default hb:a,vb:a,dr:a,al\n" \
177 "fa fast h1:a,v1:a,dr:a,al\n" \
178 "tn tmpnoise (3 Thresholds) Temporal Noise Reducer\n" \
179 " 1. <= 2. <= 3. larger -> stronger filtering\n" \
180 "fq forceQuant <quantizer> Force quantizer\n"
185 #define ENC_CFG_PREFIX "sout-ffmpeg-"
187 #define ENC_KEYINT_TEXT N_( "Ratio of key frames" )
188 #define ENC_KEYINT_LONGTEXT N_( "Number of frames " \
189 "that will be coded for one key frame." )
191 #define ENC_BFRAMES_TEXT N_( "Ratio of B frames" )
192 #define ENC_BFRAMES_LONGTEXT N_( "Number of " \
193 "B frames that will be coded between two reference frames." )
195 #define ENC_VT_TEXT N_( "Video bitrate tolerance" )
196 #define ENC_VT_LONGTEXT N_( "Video bitrate tolerance in kbit/s." )
198 #define ENC_INTERLACE_TEXT N_( "Interlaced encoding" )
199 #define ENC_INTERLACE_LONGTEXT N_( "Enable dedicated " \
200 "algorithms for interlaced frames." )
202 #define ENC_INTERLACE_ME_TEXT N_( "Interlaced motion estimation" )
203 #define ENC_INTERLACE_ME_LONGTEXT N_( "Enable interlaced " \
204 "motion estimation algorithms. This requires more CPU." )
206 #define ENC_PRE_ME_TEXT N_( "Pre-motion estimation" )
207 #define ENC_PRE_ME_LONGTEXT N_( "Enable the pre-motion " \
208 "estimation algorithm.")
210 #define ENC_RC_STRICT_TEXT N_( "Strict rate control" )
211 #define ENC_RC_STRICT_LONGTEXT N_( "Enable the strict rate " \
212 "control algorithm." )
214 #define ENC_RC_BUF_TEXT N_( "Rate control buffer size" )
215 #define ENC_RC_BUF_LONGTEXT N_( "Rate control " \
216 "buffer size (in kbytes). A bigger buffer will allow for better rate " \
217 "control, but will cause a delay in the stream." )
219 #define ENC_RC_BUF_AGGR_TEXT N_( "Rate control buffer aggressiveness" )
220 #define ENC_RC_BUF_AGGR_LONGTEXT N_( "Rate control "\
221 "buffer aggressiveness." )
223 #define ENC_IQUANT_FACTOR_TEXT N_( "I quantization factor" )
224 #define ENC_IQUANT_FACTOR_LONGTEXT N_( \
225 "Quantization factor of I frames, compared with P frames (for instance " \
226 "1.0 => same qscale for I and P frames)." )
228 #define ENC_NOISE_RED_TEXT N_( "Noise reduction" )
229 #define ENC_NOISE_RED_LONGTEXT N_( "Enable a simple noise " \
230 "reduction algorithm to lower the encoding length and bitrate, at the " \
231 "expense of lower quality frames." )
233 #define ENC_MPEG4_MATRIX_TEXT N_( "MPEG4 quantization matrix" )
234 #define ENC_MPEG4_MATRIX_LONGTEXT N_( "Use the MPEG4 " \
235 "quantization matrix for MPEG2 encoding. This generally yields a " \
236 "better looking picture, while still retaining the compatibility with " \
237 "standard MPEG2 decoders.")
239 #define ENC_HQ_TEXT N_( "Quality level" )
240 #define ENC_HQ_LONGTEXT N_( "Quality level " \
241 "for the encoding of motions vectors (this can slow down the encoding " \
244 #define ENC_HURRYUP_TEXT N_( "Hurry up" )
245 #define ENC_HURRYUP_LONGTEXT N_( "The encoder " \
246 "can make on-the-fly quality tradeoffs if your CPU can't keep up with " \
247 "the encoding rate. It will disable trellis quantization, then the rate " \
248 "distortion of motion vectors (hq), and raise the noise reduction " \
249 "threshold to ease the encoder's task." )
251 #define ENC_QMIN_TEXT N_( "Minimum video quantizer scale" )
252 #define ENC_QMIN_LONGTEXT N_( "Minimum video " \
255 #define ENC_QMAX_TEXT N_( "Maximum video quantizer scale" )
256 #define ENC_QMAX_LONGTEXT N_( "Maximum video " \
259 #define ENC_TRELLIS_TEXT N_( "Trellis quantization" )
260 #define ENC_TRELLIS_LONGTEXT N_( "Enable trellis " \
261 "quantization (rate distortion for block coefficients)." )
263 #define ENC_QSCALE_TEXT N_( "Fixed quantizer scale" )
264 #define ENC_QSCALE_LONGTEXT N_( "A fixed video " \
265 "quantizer scale for VBR encoding (accepted values: 0.01 to 255.0)." )
267 #define ENC_STRICT_TEXT N_( "Strict standard compliance" )
268 #define ENC_STRICT_LONGTEXT N_( "Force a strict standard " \
269 "compliance when encoding (accepted values: -1, 0, 1)." )
271 #define ENC_LUMI_MASKING_TEXT N_( "Luminance masking" )
272 #define ENC_LUMI_MASKING_LONGTEXT N_( "Raise the quantizer for " \
273 "very bright macroblocks (default: 0.0)." )
275 #define ENC_DARK_MASKING_TEXT N_( "Darkness masking" )
276 #define ENC_DARK_MASKING_LONGTEXT N_( "Raise the quantizer for " \
277 "very dark macroblocks (default: 0.0)." )
279 #define ENC_P_MASKING_TEXT N_( "Motion masking" )
280 #define ENC_P_MASKING_LONGTEXT N_( "Raise the quantizer for " \
281 "macroblocks with a high temporal complexity (default: 0.0)." )
283 #define ENC_BORDER_MASKING_TEXT N_( "Border masking" )
284 #define ENC_BORDER_MASKING_LONGTEXT N_( "Raise the quantizer " \
285 "for macroblocks at the border of the frame (default: 0.0)." )
287 #define ENC_LUMA_ELIM_TEXT N_( "Luminance elimination" )
288 #define ENC_LUMA_ELIM_LONGTEXT N_( "Eliminates luminance blocks when " \
289 "the PSNR isn't much changed (default: 0.0). The H264 specification " \
292 #define ENC_CHROMA_ELIM_TEXT N_( "Chrominance elimination" )
293 #define ENC_CHROMA_ELIM_LONGTEXT N_( "Eliminates chrominance blocks when " \
294 "the PSNR isn't much changed (default: 0.0). The H264 specification " \