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