avcodec.h 9.79 KB
Newer Older
1
/*****************************************************************************
2
 * avcodec.h: decoder and encoder using libavcodec
3
 *****************************************************************************
4
 * Copyright (C) 2001-2008 the VideoLAN team
Carlo Calabrò's avatar
Carlo Calabrò committed
5
 * $Id$
6 7
 *
 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
Sam Hocevar's avatar
Sam Hocevar committed
8
 *
9 10 11 12
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
Sam Hocevar's avatar
Sam Hocevar committed
13
 *
14 15 16 17 18 19 20
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
Antoine Cellerier's avatar
Antoine Cellerier committed
21
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 23
 *****************************************************************************/

24 25
picture_t * DecodeVideo    ( decoder_t *, block_t ** );
aout_buffer_t * DecodeAudio( decoder_t *, block_t ** );
26

Gildas Bazin's avatar
 
Gildas Bazin committed
27
/* Video encoder module */
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
28 29
int  OpenEncoder ( vlc_object_t * );
void CloseEncoder( vlc_object_t * );
30

Gildas Bazin's avatar
 
Gildas Bazin committed
31
/* Audio encoder module */
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
32 33
int  OpenAudioEncoder ( vlc_object_t * );
void CloseAudioEncoder( vlc_object_t * );
34

35
/* Deinterlace video filter module */
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
36 37
int  OpenDeinterlace( vlc_object_t * );
void CloseDeinterlace( vlc_object_t * );
Derk-Jan Hartman's avatar
Derk-Jan Hartman committed
38

Rafaël Carré's avatar
Rafaël Carré committed
39 40 41 42 43 44 45 46 47 48 49 50
void InitLibavcodec( vlc_object_t *p_object );

/* Video Decoder */
int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
                  AVCodec *p_codec, int i_codec_id, const char *psz_namecodec );
void EndVideoDec( decoder_t *p_dec );

/* Audio Decoder */
int InitAudioDec( decoder_t *p_dec, AVCodecContext *p_context,
                  AVCodec *p_codec, int i_codec_id, const char *psz_namecodec );
void EndAudioDec( decoder_t *p_dec );

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
51 52 53
/* Avcodec global lock */
extern vlc_mutex_t avcodec_lock;

Gildas Bazin's avatar
 
Gildas Bazin committed
54 55 56 57
/*****************************************************************************
 * Module descriptor help strings
 *****************************************************************************/
#define DR_TEXT N_("Direct rendering")
58 59
/* FIXME Does somebody who knows what it does, explain */
#define DR_LONGTEXT N_("Direct rendering")
Gildas Bazin's avatar
 
Gildas Bazin committed
60 61 62

#define ERROR_TEXT N_("Error resilience")
#define ERROR_LONGTEXT N_( \
63
    "Ffmpeg can do error resilience.\n" \
64 65
    "However, with a buggy encoder (such as the ISO MPEG-4 encoder from M$) " \
    "this can produce a lot of errors.\n" \
Gildas Bazin's avatar
Gildas Bazin committed
66
    "Valid values range from 0 to 4 (0 disables all errors resilience).")
Gildas Bazin's avatar
 
Gildas Bazin committed
67 68 69

#define BUGS_TEXT N_("Workaround bugs")
#define BUGS_LONGTEXT N_( \
70
    "Try to fix some bugs:\n" \
Gildas Bazin's avatar
 
Gildas Bazin committed
71 72 73 74 75 76
    "1  autodetect\n" \
    "2  old msmpeg4\n" \
    "4  xvid interlaced\n" \
    "8  ump4 \n" \
    "16 no padding\n" \
    "32 ac vlc\n" \
77 78 79
    "64 Qpel chroma.\n" \
    "This must be the sum of the values. For example, to fix \"ac vlc\" and " \
    "\"ump4\", enter 40.")
Gildas Bazin's avatar
 
Gildas Bazin committed
80 81 82

#define HURRYUP_TEXT N_("Hurry up")
#define HURRYUP_LONGTEXT N_( \
83
    "The decoder can partially decode or skip frame(s) " \
Gildas Bazin's avatar
 
Gildas Bazin committed
84 85 86
    "when there is not enough time. It's useful with low CPU power " \
    "but it can produce distorted pictures.")

87 88 89 90 91 92 93 94 95 96
#define SKIP_FRAME_TEXT N_("Skip frame (default=0)")
#define SKIP_FRAME_LONGTEXT N_( \
    "Force skipping of frames to speed up decoding " \
    "(-1=None, 0=Default, 1=B-frames, 2=P-frames, 3=B+P frames, 4=all frames)." )

#define SKIP_IDCT_TEXT N_("Skip idct (default=0)")
#define SKIP_IDCT_LONGTEXT N_( \
    "Force skipping of idct to speed up decoding for frame types" \
    "(-1=None, 0=Default, 1=B-frames, 2=P-frames, 3=B+P frames, 4=all frames)." )

97 98
#define DEBUG_TEXT N_( "Debug mask" )
#define DEBUG_LONGTEXT N_( "Set ffmpeg debug mask" )
99

100
/* TODO: Use a predefined list, with 0,1,2,4,7 */
Gildas Bazin's avatar
Gildas Bazin committed
101
#define VISMV_TEXT N_( "Visualize motion vectors" )
102 103 104
#define VISMV_LONGTEXT N_( \
    "You can overlay the motion vectors (arrows showing how the images move) "\
    "on the image. This value is a mask, based on these values:\n"\
Gildas Bazin's avatar
Gildas Bazin committed
105 106
    "1 - visualize forward predicted MVs of P frames\n" \
    "2 - visualize forward predicted MVs of B frames\n" \
107 108
    "4 - visualize backward predicted MVs of B frames\n" \
    "To visualize all vectors, the value should be 7." )
Gildas Bazin's avatar
Gildas Bazin committed
109

110
#define LOWRES_TEXT N_( "Low resolution decoding" )
111 112
#define LOWRES_LONGTEXT N_( "Only decode a low resolution version of " \
    "the video. This requires less processing power" )
113

114 115
#define SKIPLOOPF_TEXT N_( "Skip the loop filter for H.264 decoding" )
#define SKIPLOOPF_LONGTEXT N_( "Skipping the loop filter (aka deblocking) " \
116 117
    "usually has a detrimental effect on quality. However it provides a big " \
    "speedup for high definition streams." )
118

119 120 121 122 123 124
/*
 * Encoder options
 */
#define ENC_CFG_PREFIX "sout-ffmpeg-"

#define ENC_KEYINT_TEXT N_( "Ratio of key frames" )
125
#define ENC_KEYINT_LONGTEXT N_( "Number of frames " \
126 127 128
  "that will be coded for one key frame." )

#define ENC_BFRAMES_TEXT N_( "Ratio of B frames" )
129
#define ENC_BFRAMES_LONGTEXT N_( "Number of " \
130 131 132
  "B frames that will be coded between two reference frames." )

#define ENC_VT_TEXT N_( "Video bitrate tolerance" )
133
#define ENC_VT_LONGTEXT N_( "Video bitrate tolerance in kbit/s." )
134

135
#define ENC_INTERLACE_TEXT N_( "Interlaced encoding" )
136
#define ENC_INTERLACE_LONGTEXT N_( "Enable dedicated " \
137
  "algorithms for interlaced frames." )
138

139
#define ENC_INTERLACE_ME_TEXT N_( "Interlaced motion estimation" )
140
#define ENC_INTERLACE_ME_LONGTEXT N_( "Enable interlaced " \
141
  "motion estimation algorithms. This requires more CPU." )
142

143
#define ENC_PRE_ME_TEXT N_( "Pre-motion estimation" )
144 145
#define ENC_PRE_ME_LONGTEXT N_( "Enable the pre-motion " \
  "estimation algorithm.")
146 147

#define ENC_RC_BUF_TEXT N_( "Rate control buffer size" )
148
#define ENC_RC_BUF_LONGTEXT N_( "Rate control " \
149 150
  "buffer size (in kbytes). A bigger buffer will allow for better rate " \
  "control, but will cause a delay in the stream." )
151

152
#define ENC_RC_BUF_AGGR_TEXT N_( "Rate control buffer aggressiveness" )
153
#define ENC_RC_BUF_AGGR_LONGTEXT N_( "Rate control "\
154
  "buffer aggressiveness." )
155

156
#define ENC_IQUANT_FACTOR_TEXT N_( "I quantization factor" )
157 158
#define ENC_IQUANT_FACTOR_LONGTEXT N_(  \
  "Quantization factor of I frames, compared with P frames (for instance " \
159
  "1.0 => same qscale for I and P frames)." )
160 161

#define ENC_NOISE_RED_TEXT N_( "Noise reduction" )
162
#define ENC_NOISE_RED_LONGTEXT N_( "Enable a simple noise " \
163 164
  "reduction algorithm to lower the encoding length and bitrate, at the " \
  "expense of lower quality frames." )
165

166 167 168
#define ENC_MPEG4_MATRIX_TEXT N_( "MPEG4 quantization matrix" )
#define ENC_MPEG4_MATRIX_LONGTEXT N_( "Use the MPEG4 " \
  "quantization matrix for MPEG2 encoding. This generally yields a " \
169
  "better looking picture, while still retaining the compatibility with " \
170
  "standard MPEG2 decoders.")
171 172

#define ENC_HQ_TEXT N_( "Quality level" )
173
#define ENC_HQ_LONGTEXT N_( "Quality level " \
174 175
  "for the encoding of motions vectors (this can slow down the encoding " \
  "very much)." )
176 177

#define ENC_HURRYUP_TEXT N_( "Hurry up" )
178 179
#define ENC_HURRYUP_LONGTEXT N_( "The encoder " \
  "can make on-the-fly quality tradeoffs if your CPU can't keep up with " \
180
  "the encoding rate. It will disable trellis quantization, then the rate " \
181
  "distortion of motion vectors (hq), and raise the noise reduction " \
182
  "threshold to ease the encoder's task." )
183 184

#define ENC_QMIN_TEXT N_( "Minimum video quantizer scale" )
185
#define ENC_QMIN_LONGTEXT N_( "Minimum video " \
186 187 188
  "quantizer scale." )

#define ENC_QMAX_TEXT N_( "Maximum video quantizer scale" )
189
#define ENC_QMAX_LONGTEXT N_( "Maximum video " \
190 191
  "quantizer scale." )

192
#define ENC_TRELLIS_TEXT N_( "Trellis quantization" )
193
#define ENC_TRELLIS_LONGTEXT N_( "Enable trellis " \
194
  "quantization (rate distortion for block coefficients)." )
Gildas Bazin's avatar
Gildas Bazin committed
195

196
#define ENC_QSCALE_TEXT N_( "Fixed quantizer scale" )
197
#define ENC_QSCALE_LONGTEXT N_( "A fixed video " \
Gildas Bazin's avatar
Gildas Bazin committed
198 199 200
  "quantizer scale for VBR encoding (accepted values: 0.01 to 255.0)." )

#define ENC_STRICT_TEXT N_( "Strict standard compliance" )
201
#define ENC_STRICT_LONGTEXT N_( "Force a strict standard " \
Gildas Bazin's avatar
Gildas Bazin committed
202
  "compliance when encoding (accepted values: -1, 0, 1)." )
203 204

#define ENC_LUMI_MASKING_TEXT N_( "Luminance masking" )
205
#define ENC_LUMI_MASKING_LONGTEXT N_( "Raise the quantizer for " \
206 207 208
  "very bright macroblocks (default: 0.0)." )

#define ENC_DARK_MASKING_TEXT N_( "Darkness masking" )
209
#define ENC_DARK_MASKING_LONGTEXT N_( "Raise the quantizer for " \
210 211 212
  "very dark macroblocks (default: 0.0)." )

#define ENC_P_MASKING_TEXT N_( "Motion masking" )
213
#define ENC_P_MASKING_LONGTEXT N_( "Raise the quantizer for " \
214 215 216
  "macroblocks with a high temporal complexity (default: 0.0)." )

#define ENC_BORDER_MASKING_TEXT N_( "Border masking" )
217
#define ENC_BORDER_MASKING_LONGTEXT N_( "Raise the quantizer " \
218 219 220 221 222 223 224 225 226 227 228
  "for macroblocks at the border of the frame (default: 0.0)." )

#define ENC_LUMA_ELIM_TEXT N_( "Luminance elimination" )
#define ENC_LUMA_ELIM_LONGTEXT N_( "Eliminates luminance blocks when " \
  "the PSNR isn't much changed (default: 0.0). The H264 specification " \
  "recommends -4." )

#define ENC_CHROMA_ELIM_TEXT N_( "Chrominance elimination" )
#define ENC_CHROMA_ELIM_LONGTEXT N_( "Eliminates chrominance blocks when " \
  "the PSNR isn't much changed (default: 0.0). The H264 specification " \
  "recommends 7." )
229

230
#if LIBAVCODEC_VERSION_INT >= ((51<<16)+(40<<8)+4)
231 232 233 234
#define ENC_PROFILE_TEXT N_( "Specify AAC audio profile to use" )
#define ENC_PROFILE_LONGTEXT N_( "Specify the AAC audio profile to use " \
   "for encoding the audio bitstream. It takes the following options: " \
   "main, low, ssr (not supported) and ltp (default: main)" )
235
#endif
236

237 238 239
#define FFMPEG_COMMON_MEMBERS   \
    int i_cat;                  \
    int i_codec_id;             \
240
    const char *psz_namecodec;  \
241 242 243
    AVCodecContext *p_context;  \
    AVCodec        *p_codec;