ffmpeg.c 38.3 KB
Newer Older
1
2
3
/*****************************************************************************
 * ffmpeg.c: video decoder using ffmpeg library
 *****************************************************************************
4
 * Copyright (C) 1999-2001 the VideoLAN team
5
 * $Id$
6
7
 *
 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8
 *          Gildas Bazin <gbazin@videolan.org>
9
10
11
12
13
 *
 * 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.
14
 *
15
16
17
18
19
20
21
 * 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
dionoea's avatar
dionoea committed
22
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23
24
25
26
27
28
29
30
 *****************************************************************************/

/*****************************************************************************
 * Preamble
 *****************************************************************************/
#include <vlc/vlc.h>
#include <vlc/decoder.h>

gbazin's avatar
   
gbazin committed
31
/* ffmpeg header */
32
#define HAVE_MMX 1
gbazin's avatar
   
gbazin committed
33
34
35
36
37
#ifdef HAVE_FFMPEG_AVCODEC_H
#   include <ffmpeg/avcodec.h>
#else
#   include <avcodec.h>
#endif
38

39
40
#if LIBAVCODEC_BUILD < 4680
#   error You must have a libavcodec >= 4680 (get CVS)
41
#endif
42

43
#include "ffmpeg.h"
44
45

#ifdef LIBAVCODEC_PP
gbazin's avatar
   
gbazin committed
46
#   ifdef HAVE_POSTPROC_POSTPROCESS_H
gbazin's avatar
   
gbazin committed
47
48
49
50
#       include <postproc/postprocess.h>
#   else
#       include <libpostproc/postprocess.h>
#   endif
51
52
#endif

gbazin's avatar
   
gbazin committed
53
54
55
56
57
58
59
60
61
/*****************************************************************************
 * decoder_sys_t: decoder descriptor
 *****************************************************************************/
struct decoder_sys_t
{
    /* Common part between video and audio decoder */
    int i_cat;
    int i_codec_id;
    char *psz_namecodec;
62

gbazin's avatar
   
gbazin committed
63
64
65
    AVCodecContext *p_context;
    AVCodec        *p_codec;
};
66

gbazin's avatar
   
gbazin committed
67
68
69
70
/****************************************************************************
 * Local prototypes
 ****************************************************************************/
static int OpenDecoder( vlc_object_t * );
gbazin's avatar
   
gbazin committed
71
static void CloseDecoder( vlc_object_t * );
72

73
74
75
76
static int  nloopf_list[] = { 0, 1, 2, 3, 4 };
static char *nloopf_list_text[] =
  { N_("None"), N_("Non-ref"), N_("Bidir"), N_("Non-key"), N_("All") };

77
78
static char *enc_hq_list[] = { "rd", "bits", "simple" };
static char *enc_hq_list_text[] = { N_("rd"), N_("bits"), N_("simple") };
79
80
81
82
/*****************************************************************************
 * Module descriptor
 *****************************************************************************/
vlc_module_begin();
83
    set_shortname( "FFmpeg");
zorglub's avatar
zorglub committed
84
85
    set_category( CAT_INPUT );
    set_subcategory( SUBCAT_INPUT_SCODEC );
gbazin's avatar
   
gbazin committed
86
    /* decoder main module */
87
88
#if defined(MODULE_NAME_is_ffmpegaltivec) \
     || (defined(CAN_COMPILE_ALTIVEC) && !defined(NO_ALTIVEC_IN_FFMPEG))
89
    set_description( _("AltiVec FFmpeg audio/video decoder/encoder ((MS)MPEG4,SVQ1,H263,WMV,WMA)") );
Sam Hocevar's avatar
Sam Hocevar committed
90
    /*add_requirement( ALTIVEC );*/
91
92
    set_capability( "decoder", 71 );
#else
93
    set_description( _("FFmpeg audio/video decoder/encoder ((MS)MPEG4,SVQ1,H263,WMV,WMA)") );
gbazin's avatar
   
gbazin committed
94
    set_capability( "decoder", 70 );
95
#endif
zorglub's avatar
zorglub committed
96
    set_section( N_("Decoding") , NULL );
gbazin's avatar
   
gbazin committed
97
    set_callbacks( OpenDecoder, CloseDecoder );
gbazin's avatar
   
gbazin committed
98

gbazin's avatar
   
gbazin committed
99
    add_bool( "ffmpeg-dr", 1, NULL, DR_TEXT, DR_TEXT, VLC_TRUE );
gbazin's avatar
gbazin committed
100
    add_integer ( "ffmpeg-error-resilience", 1, NULL, ERROR_TEXT,
gbazin's avatar
   
gbazin committed
101
102
103
104
105
        ERROR_LONGTEXT, VLC_TRUE );
    add_integer ( "ffmpeg-workaround-bugs", 1, NULL, BUGS_TEXT, BUGS_LONGTEXT,
        VLC_FALSE );
    add_bool( "ffmpeg-hurry-up", 0, NULL, HURRYUP_TEXT, HURRYUP_LONGTEXT,
        VLC_FALSE );
gbazin's avatar
gbazin committed
106
107
    add_integer ( "ffmpeg-vismv", 0, NULL, VISMV_TEXT, VISMV_LONGTEXT,
        VLC_TRUE );
108
109
110
    add_integer ( "ffmpeg-lowres", 0, NULL, LOWRES_TEXT, LOWRES_LONGTEXT,
        VLC_TRUE );
        change_integer_range( 0, 2 );
111
112
113
    add_integer ( "ffmpeg-skiploopfilter", 0, NULL, SKIPLOOPF_TEXT,
                  SKIPLOOPF_LONGTEXT, VLC_TRUE );
        change_integer_list( nloopf_list, nloopf_list_text, 0 );
gbazin's avatar
   
gbazin committed
114

115
#ifdef LIBAVCODEC_PP
gbazin's avatar
   
gbazin committed
116
117
118
    add_integer( "ffmpeg-pp-q", 0, NULL, PP_Q_TEXT, PP_Q_LONGTEXT, VLC_FALSE );
    add_string( "ffmpeg-pp-name", "default", NULL, LIBAVCODEC_PP_TEXT,
        LIBAVCODEC_PP_LONGTEXT, VLC_TRUE );
119
#endif
120
121
    add_integer( "ffmpeg-debug", 0, NULL, DEBUG_TEXT, DEBUG_LONGTEXT,
                 VLC_TRUE );
gbazin's avatar
   
gbazin committed
122
123
124
125

    /* chroma conversion submodule */
    add_submodule();
    set_capability( "chroma", 50 );
gbazin's avatar
   
gbazin committed
126
    set_callbacks( E_(OpenChroma), E_(CloseChroma) );
127
    set_description( _("FFmpeg chroma conversion") );
gbazin's avatar
   
gbazin committed
128

gbazin's avatar
   
gbazin committed
129
130
    /* encoder submodule */
    add_submodule();
zorglub's avatar
zorglub committed
131
    set_section( N_("Encoding") , NULL );
132
    set_description( _("FFmpeg audio/video encoder") );
gbazin's avatar
   
gbazin committed
133
134
135
    set_capability( "encoder", 100 );
    set_callbacks( E_(OpenEncoder), E_(CloseEncoder) );

136
137
138
139
140
141
142
    add_string( ENC_CFG_PREFIX "hq", "simple", NULL, ENC_HQ_TEXT,
                ENC_HQ_LONGTEXT, VLC_FALSE );
        change_string_list( enc_hq_list, enc_hq_list_text, 0 );
    add_integer( ENC_CFG_PREFIX "keyint", 0, NULL, ENC_KEYINT_TEXT,
                 ENC_KEYINT_LONGTEXT, VLC_FALSE );
    add_integer( ENC_CFG_PREFIX "bframes", 0, NULL, ENC_BFRAMES_TEXT,
                 ENC_BFRAMES_LONGTEXT, VLC_FALSE );
143
    add_bool( ENC_CFG_PREFIX "hurry-up", 0, NULL, ENC_HURRYUP_TEXT,
144
145
146
              ENC_HURRYUP_LONGTEXT, VLC_FALSE );
    add_bool( ENC_CFG_PREFIX "interlace", 0, NULL, ENC_INTERLACE_TEXT,
              ENC_INTERLACE_LONGTEXT, VLC_TRUE );
147
148
    add_bool( ENC_CFG_PREFIX "interlace-me", 1, NULL, ENC_INTERLACE_ME_TEXT,
              ENC_INTERLACE_ME_LONGTEXT, VLC_TRUE );
149
150
    add_integer( ENC_CFG_PREFIX "vt", 0, NULL, ENC_VT_TEXT,
                 ENC_VT_LONGTEXT, VLC_TRUE );
151
    add_bool( ENC_CFG_PREFIX "pre-me", 0, NULL, ENC_PRE_ME_TEXT,
152
              ENC_PRE_ME_LONGTEXT, VLC_TRUE );
153
    add_bool( ENC_CFG_PREFIX "strict-rc", 0, NULL, ENC_RC_STRICT_TEXT,
154
              ENC_RC_STRICT_LONGTEXT, VLC_TRUE );
155
    add_integer( ENC_CFG_PREFIX "rc-buffer-size", 224*1024*8, NULL,
156
                 ENC_RC_BUF_TEXT, ENC_RC_BUF_LONGTEXT, VLC_TRUE );
157
    add_float( ENC_CFG_PREFIX "rc-buffer-aggressivity", 1.0, NULL,
158
               ENC_RC_BUF_AGGR_TEXT, ENC_RC_BUF_AGGR_LONGTEXT, VLC_TRUE );
159
    add_float( ENC_CFG_PREFIX "i-quant-factor", 0, NULL,
160
               ENC_IQUANT_FACTOR_TEXT, ENC_IQUANT_FACTOR_LONGTEXT, VLC_TRUE );
161
    add_integer( ENC_CFG_PREFIX "noise-reduction", 0, NULL,
162
                 ENC_NOISE_RED_TEXT, ENC_NOISE_RED_LONGTEXT, VLC_TRUE );
163
    add_bool( ENC_CFG_PREFIX "mpeg4-matrix", 0, NULL,
164
165
166
167
168
169
170
              ENC_MPEG4_MATRIX_TEXT, ENC_MPEG4_MATRIX_LONGTEXT, VLC_TRUE );
    add_integer( ENC_CFG_PREFIX "qmin", 0, NULL,
                 ENC_QMIN_TEXT, ENC_QMIN_LONGTEXT, VLC_TRUE );
    add_integer( ENC_CFG_PREFIX "qmax", 0, NULL,
                 ENC_QMAX_TEXT, ENC_QMAX_LONGTEXT, VLC_TRUE );
    add_bool( ENC_CFG_PREFIX "trellis", 0, NULL,
              ENC_TRELLIS_TEXT, ENC_TRELLIS_LONGTEXT, VLC_TRUE );
gbazin's avatar
gbazin committed
171
172
173
174
    add_float( ENC_CFG_PREFIX "qscale", 0, NULL,
               ENC_QSCALE_TEXT, ENC_QSCALE_LONGTEXT, VLC_TRUE );
    add_integer( ENC_CFG_PREFIX "strict", 0, NULL,
                 ENC_STRICT_TEXT, ENC_STRICT_LONGTEXT, VLC_TRUE );
175
176
177
178
179
180
181
182
183
184
185
186
    add_float( ENC_CFG_PREFIX "lumi-masking", 0.0, NULL,
               ENC_LUMI_MASKING_TEXT, ENC_LUMI_MASKING_LONGTEXT, VLC_TRUE );
    add_float( ENC_CFG_PREFIX "dark-masking", 0.0, NULL,
               ENC_DARK_MASKING_TEXT, ENC_DARK_MASKING_LONGTEXT, VLC_TRUE );
    add_float( ENC_CFG_PREFIX "p-masking", 0.0, NULL,
               ENC_P_MASKING_TEXT, ENC_P_MASKING_LONGTEXT, VLC_TRUE );
    add_float( ENC_CFG_PREFIX "border-masking", 0.0, NULL,
               ENC_BORDER_MASKING_TEXT, ENC_BORDER_MASKING_LONGTEXT, VLC_TRUE );
    add_integer( ENC_CFG_PREFIX "luma-elim-threshold", 0, NULL,
                 ENC_LUMA_ELIM_TEXT, ENC_LUMA_ELIM_LONGTEXT, VLC_TRUE );
    add_integer( ENC_CFG_PREFIX "chroma-elim-threshold", 0, NULL,
                 ENC_CHROMA_ELIM_TEXT, ENC_CHROMA_ELIM_LONGTEXT, VLC_TRUE );
187

gbazin's avatar
   
gbazin committed
188
    /* demux submodule */
gbazin's avatar
   
gbazin committed
189
    add_submodule();
190
    set_description( _("FFmpeg demuxer" ) );
191
    set_capability( "demux2", 2 );
gbazin's avatar
   
gbazin committed
192
193
    set_callbacks( E_(OpenDemux), E_(CloseDemux) );

194
195
196
197
198
199
    /* mux submodule */
    add_submodule();
    set_description( _("FFmpeg muxer" ) );
    set_capability( "sout mux", 2 );
    set_callbacks( E_(OpenMux), E_(CloseMux) );

200
201
202
203
    /* video filter submodule */
    add_submodule();
    set_capability( "video filter2", 50 );
    set_callbacks( E_(OpenFilter), E_(CloseFilter) );
204
    set_description( _("FFmpeg video filter") );
205

206
207
208
209
    /* crop/padd submodule */
    add_submodule();
    set_capability( "crop padd", 10 );
    set_callbacks( E_(OpenCropPadd), E_(CloseFilter) );
210
    set_description( _("FFmpeg crop padd filter") );
211

212
213
214
215
    /* video filter submodule */
    add_submodule();
    set_capability( "video filter2", 0 );
    set_callbacks( E_(OpenDeinterlace), E_(CloseDeinterlace) );
216
    set_description( _("FFmpeg deinterlace video filter") );
217
    add_shortcut( "ffmpeg-deinterlace" );
218

219
    var_Create( p_module->p_libvlc, "avcodec", VLC_VAR_MUTEX );
220
221
222
223
224
225
226
vlc_module_end();

/*****************************************************************************
 * OpenDecoder: probe the decoder and return score
 *****************************************************************************/
static int OpenDecoder( vlc_object_t *p_this )
{
gbazin's avatar
   
gbazin committed
227
    decoder_t *p_dec = (decoder_t*) p_this;
gbazin's avatar
   
gbazin committed
228
    int i_cat, i_codec_id, i_result;
gbazin's avatar
   
gbazin committed
229
230
    char *psz_namecodec;

Jean-Paul Saman's avatar
Jean-Paul Saman committed
231
232
    AVCodecContext *p_context = NULL;
    AVCodec        *p_codec = NULL;
gbazin's avatar
   
gbazin committed
233
234
235

    /* *** determine codec type *** */
    if( !E_(GetFfmpegCodec)( p_dec->fmt_in.i_codec, &i_cat, &i_codec_id,
gbazin's avatar
   
gbazin committed
236
237
238
239
                             &psz_namecodec ) )
    {
        return VLC_EGENERIC;
    }
240

gbazin's avatar
   
gbazin committed
241
242
243
244
245
246
247
248
    /* Bail out if buggy decoder */
    if( i_codec_id == CODEC_ID_AAC )
    {
        msg_Dbg( p_dec, "refusing to use ffmpeg's (%s) decoder which is buggy",
                 psz_namecodec );
        return VLC_EGENERIC;
    }

gbazin's avatar
   
gbazin committed
249
250
251
    /* Initialization must be done before avcodec_find_decoder() */
    E_(InitLibavcodec)(p_this);

252
    /* *** ask ffmpeg for a decoder *** */
Jean-Paul Saman's avatar
Jean-Paul Saman committed
253
254
    p_codec = avcodec_find_decoder( i_codec_id );
    if( !p_codec )
255
    {
gbazin's avatar
   
gbazin committed
256
        msg_Dbg( p_dec, "codec not found (%s)", psz_namecodec );
gbazin's avatar
   
gbazin committed
257
        return VLC_EGENERIC;
258
259
    }

gbazin's avatar
   
gbazin committed
260
261
    /* *** get a p_context *** */
    p_context = avcodec_alloc_context();
Jean-Paul Saman's avatar
Jean-Paul Saman committed
262
    if( !p_context )
Jean-Paul Saman's avatar
Jean-Paul Saman committed
263
        return VLC_ENOMEM;
264
    p_context->debug = config_GetInt( p_dec, "ffmpeg-debug" );
265
    p_context->opaque = (void *)p_this;
266

gbazin's avatar
   
gbazin committed
267
268
    /* Set CPU capabilities */
    p_context->dsp_mask = 0;
gbazin's avatar
   
gbazin committed
269
    if( !(p_dec->p_libvlc->i_cpu & CPU_CAPABILITY_MMX) )
gbazin's avatar
   
gbazin committed
270
    {
gbazin's avatar
   
gbazin committed
271
        p_context->dsp_mask |= FF_MM_MMX;
gbazin's avatar
   
gbazin committed
272
    }
gbazin's avatar
   
gbazin committed
273
    if( !(p_dec->p_libvlc->i_cpu & CPU_CAPABILITY_MMXEXT) )
gbazin's avatar
   
gbazin committed
274
    {
gbazin's avatar
   
gbazin committed
275
        p_context->dsp_mask |= FF_MM_MMXEXT;
gbazin's avatar
   
gbazin committed
276
    }
gbazin's avatar
   
gbazin committed
277
    if( !(p_dec->p_libvlc->i_cpu & CPU_CAPABILITY_3DNOW) )
gbazin's avatar
   
gbazin committed
278
    {
gbazin's avatar
   
gbazin committed
279
        p_context->dsp_mask |= FF_MM_3DNOW;
gbazin's avatar
   
gbazin committed
280
    }
gbazin's avatar
   
gbazin committed
281
    if( !(p_dec->p_libvlc->i_cpu & CPU_CAPABILITY_SSE) )
gbazin's avatar
   
gbazin committed
282
    {
gbazin's avatar
   
gbazin committed
283
        p_context->dsp_mask |= FF_MM_SSE;
284
285
286
    }
    if( !(p_dec->p_libvlc->i_cpu & CPU_CAPABILITY_SSE2) )
    {
gbazin's avatar
   
gbazin committed
287
        p_context->dsp_mask |= FF_MM_SSE2;
gbazin's avatar
   
gbazin committed
288
289
    }

gbazin's avatar
   
gbazin committed
290
    switch( i_cat )
291
    {
gbazin's avatar
   
gbazin committed
292
    case VIDEO_ES:
293
        p_dec->b_need_packetized = VLC_TRUE;
gbazin's avatar
   
gbazin committed
294
        p_dec->pf_decode_video = E_(DecodeVideo);
gbazin's avatar
   
gbazin committed
295
296
297
298
        i_result = E_( InitVideoDec )( p_dec, p_context, p_codec,
                                       i_codec_id, psz_namecodec );
        break;
    case AUDIO_ES:
gbazin's avatar
   
gbazin committed
299
        p_dec->pf_decode_audio = E_(DecodeAudio);
gbazin's avatar
   
gbazin committed
300
301
302
303
304
        i_result = E_( InitAudioDec )( p_dec, p_context, p_codec,
                                       i_codec_id, psz_namecodec );
        break;
    default:
        i_result = VLC_EGENERIC;
305
    }
306

307
    if( i_result == VLC_SUCCESS ) p_dec->p_sys->i_cat = i_cat;
308

gbazin's avatar
   
gbazin committed
309
    return i_result;
310
}
gbazin's avatar
   
gbazin committed
311

312
/*****************************************************************************
gbazin's avatar
   
gbazin committed
313
 * CloseDecoder: decoder destruction
314
 *****************************************************************************/
gbazin's avatar
   
gbazin committed
315
static void CloseDecoder( vlc_object_t *p_this )
316
{
gbazin's avatar
   
gbazin committed
317
    decoder_t *p_dec = (decoder_t *)p_this;
gbazin's avatar
   
gbazin committed
318
    decoder_sys_t *p_sys = p_dec->p_sys;
319
320
321
    vlc_value_t lockval;

    var_Get( p_dec->p_libvlc, "avcodec", &lockval );
322

gbazin's avatar
   
gbazin committed
323
    switch( p_sys->i_cat )
324
    {
gbazin's avatar
   
gbazin committed
325
326
327
328
329
330
    case AUDIO_ES:
        E_( EndAudioDec )( p_dec );
        break;
    case VIDEO_ES:
        E_( EndVideoDec )( p_dec );
        break;
331
    }
332

333
334
335
336
    if( p_sys->p_context )
    {
        if( p_sys->p_context->extradata )
            free( p_sys->p_context->extradata );
Jean-Paul Saman's avatar
Jean-Paul Saman committed
337
        p_sys->p_context->extradata = NULL;
338
        vlc_mutex_lock( lockval.p_address );
339
        avcodec_close( p_sys->p_context );
340
        vlc_mutex_unlock( lockval.p_address );
341
342
343
344
        msg_Dbg( p_dec, "ffmpeg codec (%s) stopped", p_sys->psz_namecodec );
        av_free( p_sys->p_context );
    }

gbazin's avatar
   
gbazin committed
345
    free( p_sys );
346
}
347

348
/*****************************************************************************
gbazin's avatar
   
gbazin committed
349
 * local Functions
350
 *****************************************************************************/
351
352
353
354
355
356
357
358
359
360
static void LibavcodecCallback( void *p_opaque, int i_level,
                                const char *psz_format, va_list va )
{
    int i_vlc_level;
    AVCodecContext *p_avctx = (AVCodecContext *)p_opaque;
    AVClass *p_avc;
    vlc_object_t *p_this;
    char *psz_new_format;
    const char *psz_item_name;

361
362
    p_avc = p_avctx ? p_avctx->av_class : 0;

363
#define cln p_avc->class_name
364
    /* Make sure we can get p_this back */
365
366
367
    if( !p_avctx || !p_avc || !cln ||
        cln[0]!='A' || cln[1]!='V' || cln[2]!='C' || cln[3]!='o' ||
        cln[4]!='d' || cln[5]!='e' || cln[6]!='c' )
368
369
    {
        if( i_level == AV_LOG_ERROR ) vfprintf( stderr, psz_format, va );
370
        return;
371
    }
372
#undef cln
373

374
375
376
377
378
379
380
381
382
383
384
385
386
387
    p_this = (vlc_object_t *)p_avctx->opaque;

    switch( i_level )
    {
    case AV_LOG_QUIET:
        i_vlc_level = VLC_MSG_ERR;
        break;
    case AV_LOG_ERROR:
        i_vlc_level = VLC_MSG_WARN;
        break;
    case AV_LOG_INFO:
        i_vlc_level = VLC_MSG_DBG;
        break;
    case AV_LOG_DEBUG:
388
389
390
        /* Print debug messages if they were requested */
        if( p_avctx->debug ) vfprintf( stderr, psz_format, va );
        return;
391
392
393
394
395
396
    default:
        return;
    }

    psz_item_name = p_avc->item_name(p_opaque);
    psz_new_format = malloc( strlen(psz_format) + strlen(psz_item_name)
397
                              + 18 + 5 );
398
399
    snprintf( psz_new_format, strlen(psz_format) + strlen(psz_item_name)
              + 18 + 5, "%s (%s@%p)", psz_format, p_avc->item_name(p_opaque), p_opaque );
zorglub's avatar
zorglub committed
400
401
    msg_GenericVa( p_this, MSG_QUEUE_NORMAL,i_vlc_level,
                    MODULE_STRING, psz_new_format, va );
402
403
404
    free( psz_new_format );
}

gbazin's avatar
   
gbazin committed
405
406
407
408
409
410
411
412
413
414
415
416
417
void E_(InitLibavcodec)( vlc_object_t *p_object )
{
    static int b_ffmpeginit = 0;
    vlc_value_t lockval;

    var_Get( p_object->p_libvlc, "avcodec", &lockval );
    vlc_mutex_lock( lockval.p_address );

    /* *** init ffmpeg library (libavcodec) *** */
    if( !b_ffmpeginit )
    {
        avcodec_init();
        avcodec_register_all();
418
        av_log_set_callback( LibavcodecCallback );
gbazin's avatar
   
gbazin committed
419
        b_ffmpeginit = 1;
420

gbazin's avatar
   
gbazin committed
421
422
423
424
        msg_Dbg( p_object, "libavcodec initialized (interface %d )",
                 LIBAVCODEC_BUILD );
    }
    else
425
    {
gbazin's avatar
   
gbazin committed
426
427
        msg_Dbg( p_object, "libavcodec already initialized" );
    }
428

gbazin's avatar
   
gbazin committed
429
430
431
    vlc_mutex_unlock( lockval.p_address );
}

432
433
434
435
436
437
438
439
440
441
442
/*****************************************************************************
 * Chroma fourcc -> ffmpeg_id mapping
 *****************************************************************************/
static struct
{
    vlc_fourcc_t  i_chroma;
    int  i_chroma_id;

} chroma_table[] =
{
    /* Planar YUV formats */
443
    { VLC_FOURCC('Y','U','V','A'), PIX_FMT_YUV444P }, /* Hack */
444
    { VLC_FOURCC('I','4','4','4'), PIX_FMT_YUV444P },
445
    { VLC_FOURCC('J','4','4','4'), PIX_FMT_YUVJ444P },
446
    { VLC_FOURCC('I','4','2','2'), PIX_FMT_YUV422P },
447
    { VLC_FOURCC('J','4','2','2'), PIX_FMT_YUVJ422P },
448
449
450
    { VLC_FOURCC('I','4','2','0'), PIX_FMT_YUV420P },
    { VLC_FOURCC('Y','V','1','2'), PIX_FMT_YUV420P },
    { VLC_FOURCC('I','Y','U','V'), PIX_FMT_YUV420P },
451
    { VLC_FOURCC('J','4','2','0'), PIX_FMT_YUVJ420P },
452
453
454
455
456
457
    { VLC_FOURCC('I','4','1','1'), PIX_FMT_YUV411P },
    { VLC_FOURCC('I','4','1','0'), PIX_FMT_YUV410P },
    { VLC_FOURCC('Y','V','U','9'), PIX_FMT_YUV410P },

    /* Packed YUV formats */
    { VLC_FOURCC('Y','U','Y','2'), PIX_FMT_YUV422 },
458
459
460
#if LIBAVCODEC_BUILD >= 4720
    { VLC_FOURCC('U','Y','V','Y'), PIX_FMT_UYVY422 },
#endif
461
462
463
464
465
466
467
468
469
470

    /* Packed RGB formats */
    { VLC_FOURCC('R','V','1','5'), PIX_FMT_RGB555 },
    { VLC_FOURCC('R','V','1','6'), PIX_FMT_RGB565 },
    { VLC_FOURCC('R','V','2','4'), PIX_FMT_RGB24 },
    { VLC_FOURCC('R','V','3','2'), PIX_FMT_RGBA32 },
    { VLC_FOURCC('G','R','E','Y'), PIX_FMT_GRAY8 },

    {0}
};
gbazin's avatar
   
gbazin committed
471

472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
int E_(GetFfmpegChroma)( vlc_fourcc_t i_chroma )
{
    int i;

    for( i = 0; chroma_table[i].i_chroma != 0; i++ )
    {
        if( chroma_table[i].i_chroma == i_chroma )
            return chroma_table[i].i_chroma_id;
    }
    return -1;
}

vlc_fourcc_t E_(GetVlcChroma)( int i_ffmpeg_chroma )
{
    int i;

    for( i = 0; chroma_table[i].i_chroma != 0; i++ )
    {
        if( chroma_table[i].i_chroma_id == i_ffmpeg_chroma )
            return chroma_table[i].i_chroma;
    }
    return 0;
}

/*****************************************************************************
 * Codec fourcc -> ffmpeg_id mapping
 *****************************************************************************/
gbazin's avatar
   
gbazin committed
499
500
501
502
503
504
static struct
{
    vlc_fourcc_t  i_fourcc;
    int  i_codec;
    int  i_cat;
    char *psz_name;
gbazin's avatar
   
gbazin committed
505

gbazin's avatar
   
gbazin committed
506
507
} codecs_table[] =
{
gbazin's avatar
   
gbazin committed
508
    /* MPEG-1 Video */
gbazin's avatar
   
gbazin committed
509
510
    { VLC_FOURCC('m','p','1','v'), CODEC_ID_MPEG1VIDEO,
      VIDEO_ES, "MPEG-1 Video" },
gbazin's avatar
   
gbazin committed
511
512

    /* MPEG-2 Video */
gbazin's avatar
   
gbazin committed
513
514
515
516
    { VLC_FOURCC('m','p','2','v'), CODEC_ID_MPEG2VIDEO,
      VIDEO_ES, "MPEG-2 Video" },
    { VLC_FOURCC('m','p','g','v'), CODEC_ID_MPEG2VIDEO,
      VIDEO_ES, "MPEG-2 Video" },
gbazin's avatar
   
gbazin committed
517
518

    /* MPEG-4 Video */
gbazin's avatar
   
gbazin committed
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
    { VLC_FOURCC('D','I','V','X'), CODEC_ID_MPEG4,
      VIDEO_ES, "MPEG-4 Video" },
    { VLC_FOURCC('d','i','v','x'), CODEC_ID_MPEG4,
      VIDEO_ES, "MPEG-4 Video" },
    { VLC_FOURCC('M','P','4','S'), CODEC_ID_MPEG4,
      VIDEO_ES, "MPEG-4 Video" },
    { VLC_FOURCC('m','p','4','s'), CODEC_ID_MPEG4,
      VIDEO_ES, "MPEG-4 Video" },
    { VLC_FOURCC('M','4','S','2'), CODEC_ID_MPEG4,
      VIDEO_ES, "MPEG-4 Video" },
    { VLC_FOURCC('m','4','s','2'), CODEC_ID_MPEG4,
      VIDEO_ES, "MPEG-4 Video" },
    { VLC_FOURCC('x','v','i','d'), CODEC_ID_MPEG4,
      VIDEO_ES, "MPEG-4 Video" },
    { VLC_FOURCC('X','V','I','D'), CODEC_ID_MPEG4,
      VIDEO_ES, "MPEG-4 Video" },
    { VLC_FOURCC('X','v','i','D'), CODEC_ID_MPEG4,
      VIDEO_ES, "MPEG-4 Video" },
537
538
539
540
    { VLC_FOURCC('X','V','I','X'), CODEC_ID_MPEG4,
      VIDEO_ES, "MPEG-4 Video" },
    { VLC_FOURCC('x','v','i','x'), CODEC_ID_MPEG4,
      VIDEO_ES, "MPEG-4 Video" },
gbazin's avatar
   
gbazin committed
541
542
543
544
545
546
    { VLC_FOURCC('D','X','5','0'), CODEC_ID_MPEG4,
      VIDEO_ES, "MPEG-4 Video" },
    { VLC_FOURCC('d','x','5','0'), CODEC_ID_MPEG4,
      VIDEO_ES, "MPEG-4 Video" },
    { VLC_FOURCC('m','p','4','v'), CODEC_ID_MPEG4,
      VIDEO_ES, "MPEG-4 Video" },
547
548
    { VLC_FOURCC('M','P','4','V'), CODEC_ID_MPEG4,
      VIDEO_ES, "MPEG-4 Video" },
gbazin's avatar
   
gbazin committed
549
550
551
552
553
554
    { VLC_FOURCC( 4,  0,  0,  0 ), CODEC_ID_MPEG4,
      VIDEO_ES, "MPEG-4 Video" },
    { VLC_FOURCC('m','4','c','c'), CODEC_ID_MPEG4,
      VIDEO_ES, "MPEG-4 Video" },
    { VLC_FOURCC('M','4','C','C'), CODEC_ID_MPEG4,
      VIDEO_ES, "MPEG-4 Video" },
555
556
    { VLC_FOURCC('F','M','P','4'), CODEC_ID_MPEG4,
      VIDEO_ES, "MPEG-4 Video" },
gbazin's avatar
   
gbazin committed
557
558
    /* 3ivx delta 3.5 Unsupported
     * putting it here gives extreme distorted images
gbazin's avatar
   
gbazin committed
559
560
561
562
    { VLC_FOURCC('3','I','V','1'), CODEC_ID_MPEG4,
      VIDEO_ES, "MPEG-4 Video" },
    { VLC_FOURCC('3','i','v','1'), CODEC_ID_MPEG4,
      VIDEO_ES, "MPEG-4 Video" }, */
gbazin's avatar
   
gbazin committed
563
    /* 3ivx delta 4 */
gbazin's avatar
   
gbazin committed
564
565
566
567
    { VLC_FOURCC('3','I','V','2'), CODEC_ID_MPEG4,
      VIDEO_ES, "MPEG-4 Video" },
    { VLC_FOURCC('3','i','v','2'), CODEC_ID_MPEG4,
      VIDEO_ES, "MPEG-4 Video" },
gbazin's avatar
   
gbazin committed
568
569

    /* MSMPEG4 v1 */
gbazin's avatar
   
gbazin committed
570
571
572
573
574
575
576
577
    { VLC_FOURCC('D','I','V','1'), CODEC_ID_MSMPEG4V1,
      VIDEO_ES, "MS MPEG-4 Video v1" },
    { VLC_FOURCC('d','i','v','1'), CODEC_ID_MSMPEG4V1,
      VIDEO_ES, "MS MPEG-4 Video v1" },
    { VLC_FOURCC('M','P','G','4'), CODEC_ID_MSMPEG4V1,
      VIDEO_ES, "MS MPEG-4 Video v1" },
    { VLC_FOURCC('m','p','g','4'), CODEC_ID_MSMPEG4V1,
      VIDEO_ES, "MS MPEG-4 Video v1" },
gbazin's avatar
   
gbazin committed
578
579

    /* MSMPEG4 v2 */
gbazin's avatar
   
gbazin committed
580
581
582
583
584
585
586
587
    { VLC_FOURCC('D','I','V','2'), CODEC_ID_MSMPEG4V2,
      VIDEO_ES, "MS MPEG-4 Video v2" },
    { VLC_FOURCC('d','i','v','2'), CODEC_ID_MSMPEG4V2,
      VIDEO_ES, "MS MPEG-4 Video v2" },
    { VLC_FOURCC('M','P','4','2'), CODEC_ID_MSMPEG4V2,
      VIDEO_ES, "MS MPEG-4 Video v2" },
    { VLC_FOURCC('m','p','4','2'), CODEC_ID_MSMPEG4V2,
      VIDEO_ES, "MS MPEG-4 Video v2" },
gbazin's avatar
   
gbazin committed
588
589

    /* MSMPEG4 v3 / M$ mpeg4 v3 */
gbazin's avatar
   
gbazin committed
590
591
592
593
594
595
596
597
598
599
    { VLC_FOURCC('M','P','G','3'), CODEC_ID_MSMPEG4V3,
      VIDEO_ES, "MS MPEG-4 Video v3" },
    { VLC_FOURCC('m','p','g','3'), CODEC_ID_MSMPEG4V3,
      VIDEO_ES, "MS MPEG-4 Video v3" },
    { VLC_FOURCC('d','i','v','3'), CODEC_ID_MSMPEG4V3,
      VIDEO_ES, "MS MPEG-4 Video v3" },
    { VLC_FOURCC('M','P','4','3'), CODEC_ID_MSMPEG4V3,
      VIDEO_ES, "MS MPEG-4 Video v3" },
    { VLC_FOURCC('m','p','4','3'), CODEC_ID_MSMPEG4V3,
      VIDEO_ES, "MS MPEG-4 Video v3" },
gbazin's avatar
   
gbazin committed
600
    /* DivX 3.20 */
gbazin's avatar
   
gbazin committed
601
602
603
604
605
606
607
608
609
610
611
612
613
614
    { VLC_FOURCC('D','I','V','3'), CODEC_ID_MSMPEG4V3,
      VIDEO_ES, "MS MPEG-4 Video v3" },
    { VLC_FOURCC('D','I','V','4'), CODEC_ID_MSMPEG4V3,
      VIDEO_ES, "MS MPEG-4 Video v3" },
    { VLC_FOURCC('d','i','v','4'), CODEC_ID_MSMPEG4V3,
      VIDEO_ES, "MS MPEG-4 Video v3" },
    { VLC_FOURCC('D','I','V','5'), CODEC_ID_MSMPEG4V3,
      VIDEO_ES, "MS MPEG-4 Video v3" },
    { VLC_FOURCC('d','i','v','5'), CODEC_ID_MSMPEG4V3,
      VIDEO_ES, "MS MPEG-4 Video v3" },
    { VLC_FOURCC('D','I','V','6'), CODEC_ID_MSMPEG4V3,
      VIDEO_ES, "MS MPEG-4 Video v3" },
    { VLC_FOURCC('d','i','v','6'), CODEC_ID_MSMPEG4V3,
      VIDEO_ES, "MS MPEG-4 Video v3" },
gbazin's avatar
   
gbazin committed
615
    /* AngelPotion stuff */
gbazin's avatar
   
gbazin committed
616
617
    { VLC_FOURCC('A','P','4','1'), CODEC_ID_MSMPEG4V3,
      VIDEO_ES, "MS MPEG-4 Video v3" },
gbazin's avatar
   
gbazin committed
618
    /* 3ivx doctered divx files */
gbazin's avatar
   
gbazin committed
619
620
621
622
    { VLC_FOURCC('3','I','V','D'), CODEC_ID_MSMPEG4V3,
      VIDEO_ES, "MS MPEG-4 Video v3" },
    { VLC_FOURCC('3','i','v','d'), CODEC_ID_MSMPEG4V3,
      VIDEO_ES, "MS MPEG-4 Video v3" },
gbazin's avatar
   
gbazin committed
623
    /* who knows? */
gbazin's avatar
   
gbazin committed
624
625
626
627
    { VLC_FOURCC('3','V','I','D'), CODEC_ID_MSMPEG4V3,
      VIDEO_ES, "MS MPEG-4 Video v3" },
    { VLC_FOURCC('3','v','i','d'), CODEC_ID_MSMPEG4V3,
      VIDEO_ES, "MS MPEG-4 Video v3" },
gbazin's avatar
   
gbazin committed
628
629

    /* Sorenson v1 */
gbazin's avatar
   
gbazin committed
630
631
    { VLC_FOURCC('S','V','Q','1'), CODEC_ID_SVQ1,
      VIDEO_ES, "SVQ-1 (Sorenson Video v1)" },
gbazin's avatar
   
gbazin committed
632
633

    /* Sorenson v3 */
gbazin's avatar
   
gbazin committed
634
635
    { VLC_FOURCC('S','V','Q','3'), CODEC_ID_SVQ3,
      VIDEO_ES, "SVQ-3 (Sorenson Video v3)" },
gbazin's avatar
   
gbazin committed
636

Laurent Aimar's avatar
Laurent Aimar committed
637
    /* h264 */
gbazin's avatar
   
gbazin committed
638
639
640
641
    { VLC_FOURCC('h','2','6','4'), CODEC_ID_H264,
      VIDEO_ES, "h264" },
    { VLC_FOURCC('H','2','6','4'), CODEC_ID_H264,
      VIDEO_ES, "h264" },
642
643
    { VLC_FOURCC('x','2','6','4'), CODEC_ID_H264,
      VIDEO_ES, "h264" },
644
645
646
    /* avc1: special case h264 */
    { VLC_FOURCC('a','v','c','1'), CODEC_ID_H264,
      VIDEO_ES, "h264" },
Laurent Aimar's avatar
Laurent Aimar committed
647
648
649
650
    { VLC_FOURCC('V','S','S','H'), CODEC_ID_H264,
      VIDEO_ES, "h264" },
    { VLC_FOURCC('v','s','s','h'), CODEC_ID_H264,
      VIDEO_ES, "h264" },
Laurent Aimar's avatar
Laurent Aimar committed
651

gbazin's avatar
   
gbazin committed
652
653
/* H263 and H263i */
/* H263(+) is also known as Real Video 1.0 */
hartman's avatar
hartman committed
654

655
/* FIXME FOURCC_H263P exist but what fourcc ? */
hartman's avatar
hartman committed
656

gbazin's avatar
   
gbazin committed
657
    /* H263 */
gbazin's avatar
   
gbazin committed
658
659
660
661
662
663
    { VLC_FOURCC('H','2','6','3'), CODEC_ID_H263,
      VIDEO_ES, "H263" },
    { VLC_FOURCC('h','2','6','3'), CODEC_ID_H263,
      VIDEO_ES, "H263" },
    { VLC_FOURCC('U','2','6','3'), CODEC_ID_H263,
      VIDEO_ES, "H263" },
664
665
    { VLC_FOURCC('M','2','6','3'), CODEC_ID_H263,
      VIDEO_ES, "H263" },
gbazin's avatar
   
gbazin committed
666
667

    /* H263i */
gbazin's avatar
   
gbazin committed
668
669
670
671
    { VLC_FOURCC('I','2','6','3'), CODEC_ID_H263I,
      VIDEO_ES, "I263.I" },
    { VLC_FOURCC('i','2','6','3'), CODEC_ID_H263I,
      VIDEO_ES, "I263.I" },
gbazin's avatar
   
gbazin committed
672
673

    /* Flash (H263) variant */
gbazin's avatar
   
gbazin committed
674
675
    { VLC_FOURCC('F','L','V','1'), CODEC_ID_FLV1,
      VIDEO_ES, "Flash Video" },
676

hartman's avatar
hartman committed
677
#if LIBAVCODEC_BUILD > 4716
678
679
    { VLC_FOURCC('H','2','6','1'), CODEC_ID_H261,
      VIDEO_ES, "H.261" },
hartman's avatar
hartman committed
680
#endif
681

sigmunau's avatar
sigmunau committed
682
#if LIBAVCODEC_BUILD > 4680
gbazin's avatar
   
gbazin committed
683
684
    { VLC_FOURCC('F','L','I','C'), CODEC_ID_FLIC,
      VIDEO_ES, "Flic Video" },
hartman's avatar
hartman committed
685
#endif
686

gbazin's avatar
   
gbazin committed
687
    /* MJPEG */
gbazin's avatar
   
gbazin committed
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
    { VLC_FOURCC( 'M', 'J', 'P', 'G' ), CODEC_ID_MJPEG,
      VIDEO_ES, "Motion JPEG Video" },
    { VLC_FOURCC( 'm', 'j', 'p', 'g' ), CODEC_ID_MJPEG,
      VIDEO_ES, "Motion JPEG Video" },
    { VLC_FOURCC( 'm', 'j', 'p', 'a' ), CODEC_ID_MJPEG, /* for mov file */
      VIDEO_ES, "Motion JPEG Video" },
    { VLC_FOURCC( 'j', 'p', 'e', 'g' ), CODEC_ID_MJPEG,
      VIDEO_ES, "Motion JPEG Video" },
    { VLC_FOURCC( 'J', 'P', 'E', 'G' ), CODEC_ID_MJPEG,
      VIDEO_ES, "Motion JPEG Video" },
    { VLC_FOURCC( 'J', 'F', 'I', 'F' ), CODEC_ID_MJPEG,
      VIDEO_ES, "Motion JPEG Video" },
    { VLC_FOURCC( 'J', 'P', 'G', 'L' ), CODEC_ID_MJPEG,
      VIDEO_ES, "Motion JPEG Video" },

    { VLC_FOURCC( 'm', 'j', 'p', 'b' ), CODEC_ID_MJPEGB, /* for mov file */
      VIDEO_ES, "Motion JPEG B Video" },
gbazin's avatar
   
gbazin committed
705

706
#if LIBAVCODEC_BUILD > 4680
gbazin's avatar
   
gbazin committed
707
708
    { VLC_FOURCC( 'S', 'P', '5', 'X' ), CODEC_ID_SP5X,
      VIDEO_ES, "Sunplus Motion JPEG Video" },
709
#endif
gbazin's avatar
   
gbazin committed
710

gbazin's avatar
   
gbazin committed
711
    /* DV */
gbazin's avatar
   
gbazin committed
712
713
714
715
716
717
718
719
720
721
    { VLC_FOURCC('d','v','s','l'), CODEC_ID_DVVIDEO,
      VIDEO_ES, "DV Video" },
    { VLC_FOURCC('d','v','s','d'), CODEC_ID_DVVIDEO,
      VIDEO_ES, "DV Video" },
    { VLC_FOURCC('D','V','S','D'), CODEC_ID_DVVIDEO,
      VIDEO_ES, "DV Video" },
    { VLC_FOURCC('d','v','h','d'), CODEC_ID_DVVIDEO,
      VIDEO_ES, "DV Video" },
    { VLC_FOURCC('d','v','c',' '), CODEC_ID_DVVIDEO,
      VIDEO_ES, "DV Video" },
722
723
    { VLC_FOURCC('d','v','c','p'), CODEC_ID_DVVIDEO,
      VIDEO_ES, "DV Video PAL" },
gbazin's avatar
   
gbazin committed
724
    { VLC_FOURCC('d','v','p',' '), CODEC_ID_DVVIDEO,
725
726
727
      VIDEO_ES, "DV Video Pro" },
    { VLC_FOURCC('d','v','p','p'), CODEC_ID_DVVIDEO,
      VIDEO_ES, "DV Video Pro PAL" },
gbazin's avatar
   
gbazin committed
728
729
    { VLC_FOURCC('C','D','V','C'), CODEC_ID_DVVIDEO,
      VIDEO_ES, "DV Video" },
gbazin's avatar
   
gbazin committed
730
731

    /* Windows Media Video */
gbazin's avatar
   
gbazin committed
732
733
734
735
    { VLC_FOURCC('W','M','V','1'), CODEC_ID_WMV1,
      VIDEO_ES, "Windows Media Video 1" },
    { VLC_FOURCC('W','M','V','2'), CODEC_ID_WMV2,
      VIDEO_ES, "Windows Media Video 2" },
736
#if LIBAVCODEC_BUILD >= ((51<<16)+(10<<8)+1)
737
738
    { VLC_FOURCC('W','M','V','3'), CODEC_ID_WMV3,
      VIDEO_ES, "Windows Media Video 3" },
739
740
    { VLC_FOURCC('W','V','C','1'), CODEC_ID_VC1,
      VIDEO_ES, "Windows Media Video VC1" },
741
#endif
742
743
744
745
746
#if 0
    /* WMVA is the VC-1 codec before the standardization proces,
       it is not bitstream compatible and deprecated  */
    { VLC_FOURCC('W','M','V','A'), CODEC_ID_VC1,
      VIDEO_ES, "Windows Media Video Advanced Profile" },
747
#endif
gbazin's avatar
   
gbazin committed
748
749
750

#if LIBAVCODEC_BUILD >= 4683
    /* Microsoft Video 1 */
gbazin's avatar
   
gbazin committed
751
752
753
754
755
756
757
758
759
760
761
762
    { VLC_FOURCC('M','S','V','C'), CODEC_ID_MSVIDEO1,
      VIDEO_ES, "Microsoft Video 1" },
    { VLC_FOURCC('m','s','v','c'), CODEC_ID_MSVIDEO1,
      VIDEO_ES, "Microsoft Video 1" },
    { VLC_FOURCC('C','R','A','M'), CODEC_ID_MSVIDEO1,
      VIDEO_ES, "Microsoft Video 1" },
    { VLC_FOURCC('c','r','a','m'), CODEC_ID_MSVIDEO1,
      VIDEO_ES, "Microsoft Video 1" },
    { VLC_FOURCC('W','H','A','M'), CODEC_ID_MSVIDEO1,
      VIDEO_ES, "Microsoft Video 1" },
    { VLC_FOURCC('w','h','a','m'), CODEC_ID_MSVIDEO1,
      VIDEO_ES, "Microsoft Video 1" },
gbazin's avatar
   
gbazin committed
763
764

    /* Microsoft RLE */
gbazin's avatar
   
gbazin committed
765
766
767
768
    { VLC_FOURCC('m','r','l','e'), CODEC_ID_MSRLE,
      VIDEO_ES, "Microsoft RLE Video" },
    { VLC_FOURCC(0x1,0x0,0x0,0x0), CODEC_ID_MSRLE,
      VIDEO_ES, "Microsoft RLE Video" },
gbazin's avatar
   
gbazin committed
769
#endif
hartman's avatar
hartman committed
770

gbazin's avatar
   
gbazin committed
771
    /* Indeo Video Codecs (Quality of this decoder on ppc is not good) */
gbazin's avatar
   
gbazin committed
772
773
774
775
776
777
778
779
    { VLC_FOURCC('I','V','3','1'), CODEC_ID_INDEO3,
      VIDEO_ES, "Indeo Video v3" },
    { VLC_FOURCC('i','v','3','1'), CODEC_ID_INDEO3,
      VIDEO_ES, "Indeo Video v3" },
    { VLC_FOURCC('I','V','3','2'), CODEC_ID_INDEO3,
      VIDEO_ES, "Indeo Video v3" },
    { VLC_FOURCC('i','v','3','2'), CODEC_ID_INDEO3,
      VIDEO_ES, "Indeo Video v3" },
780

781
782
783
784
785
#if LIBAVCODEC_BUILD >= 4721
    { VLC_FOURCC('t','s','c','c'), CODEC_ID_TSCC,
      VIDEO_ES, "TechSmith Camtasia Screen Capture Video" },
#endif

gbazin's avatar
   
gbazin committed
786
    /* Huff YUV */
gbazin's avatar
   
gbazin committed
787
788
    { VLC_FOURCC('H','F','Y','U'), CODEC_ID_HUFFYUV,
      VIDEO_ES, "Huff YUV Video" },
gbazin's avatar
   
gbazin committed
789
790

    /* Creative YUV */
gbazin's avatar
   
gbazin committed
791
792
    { VLC_FOURCC('C','Y','U','V'), CODEC_ID_CYUV,
      VIDEO_ES, "Creative YUV Video" },
gbazin's avatar
   
gbazin committed
793
794

    /* On2 VP3 Video Codecs */
795
796
797
798
    { VLC_FOURCC('V','P','3',' '), CODEC_ID_VP3,
      VIDEO_ES, "On2's VP3 Video" },
    { VLC_FOURCC('V','P','3','0'), CODEC_ID_VP3,
      VIDEO_ES, "On2's VP3 Video" },
gbazin's avatar
   
gbazin committed
799
800
801
802
    { VLC_FOURCC('V','P','3','1'), CODEC_ID_VP3,
      VIDEO_ES, "On2's VP3 Video" },
    { VLC_FOURCC('v','p','3','1'), CODEC_ID_VP3,
      VIDEO_ES, "On2's VP3 Video" },
803

804
805
806
807
808
809
810
811
812
813
814
#if LIBAVCODEC_BUILD >= ((51<<16)+(14<<8)+0)
    { VLC_FOURCC('V','P','5',' '), CODEC_ID_VP5,
      VIDEO_ES, "On2's VP5 Video" },
    { VLC_FOURCC('V','P','5','0'), CODEC_ID_VP5,
      VIDEO_ES, "On2's VP5 Video" },
    { VLC_FOURCC('V','P','6','2'), CODEC_ID_VP6,
      VIDEO_ES, "On2's VP6.2 Video" },
    { VLC_FOURCC('v','p','6','2'), CODEC_ID_VP6,
      VIDEO_ES, "On2's VP6.2 Video" },
#endif

815
816
#if LIBAVCODEC_BUILD >= 4685
    /* Xiph.org theora */
gbazin's avatar
   
gbazin committed
817
818
    { VLC_FOURCC('t','h','e','o'), CODEC_ID_THEORA,
      VIDEO_ES, "Xiph.org's Theora Video" },
819
820
#endif

hartman's avatar
hartman committed
821
#if ( !defined( WORDS_BIGENDIAN ) )
gbazin's avatar
   
gbazin committed
822
    /* Asus Video (Another thing that doesn't work on PPC) */
gbazin's avatar
   
gbazin committed
823
824
825
826
    { VLC_FOURCC('A','S','V','1'), CODEC_ID_ASV1,
      VIDEO_ES, "Asus V1 Video" },
    { VLC_FOURCC('A','S','V','2'), CODEC_ID_ASV2,
      VIDEO_ES, "Asus V2 Video" },
gbazin's avatar
   
gbazin committed
827
#endif
828

gbazin's avatar
   
gbazin committed
829
    /* FFMPEG Video 1 (lossless codec) */
gbazin's avatar
   
gbazin committed
830
831
    { VLC_FOURCC('F','F','V','1'), CODEC_ID_FFV1,
      VIDEO_ES, "FFMpeg Video 1" },
hartman's avatar
hartman committed
832

gbazin's avatar
   
gbazin committed
833
    /* ATI VCR1 */
gbazin's avatar
   
gbazin committed
834
835
    { VLC_FOURCC('V','C','R','1'), CODEC_ID_VCR1,
      VIDEO_ES, "ATI VCR1 Video" },
hartman's avatar
hartman committed
836

gbazin's avatar
   
gbazin committed
837
    /* Cirrus Logic AccuPak */
gbazin's avatar
   
gbazin committed
838
839
    { VLC_FOURCC('C','L','J','R'), CODEC_ID_CLJR,
      VIDEO_ES, "Creative Logic AccuPak" },
hartman's avatar
hartman committed
840

gbazin's avatar
   
gbazin committed
841
842
843
844
845
    /* Real Video */
    { VLC_FOURCC('R','V','1','0'), CODEC_ID_RV10,
      VIDEO_ES, "Real Video 10" },
    { VLC_FOURCC('R','V','1','3'), CODEC_ID_RV10,
      VIDEO_ES, "Real Video 13" },
846

gbazin's avatar
   
gbazin committed
847
#if LIBAVCODEC_BUILD >= 4684
gbazin's avatar
   
gbazin committed
848
    /* Apple Video */
gbazin's avatar
   
gbazin committed
849
850
    { VLC_FOURCC('r','p','z','a'), CODEC_ID_RPZA,
      VIDEO_ES, "Apple Video" },
gbazin's avatar
   
gbazin committed
851

sigmunau's avatar
sigmunau committed
852
853
    { VLC_FOURCC('s','m','c',' '), CODEC_ID_SMC,
      VIDEO_ES, "Apple graphics" },
hartman's avatar
hartman committed
854

gbazin's avatar
   
gbazin committed
855
    /* Cinepak */
gbazin's avatar
   
gbazin committed
856
857
    { VLC_FOURCC('c','v','i','d'), CODEC_ID_CINEPAK,
      VIDEO_ES, "Cinepak Video" },
gbazin's avatar
   
gbazin committed
858
859
860
861

    /* Id Quake II CIN */
    { VLC_FOURCC('I','D','C','I'), CODEC_ID_IDCIN,
      VIDEO_ES, "Id Quake II CIN Video" },
gbazin's avatar
   
gbazin committed
862
863
#endif

gbazin's avatar
   
gbazin committed
864
865
866
867
    /* 4X Technologies */
    { VLC_FOURCC('4','x','m','v'), CODEC_ID_4XM,
      VIDEO_ES, "4X Technologies Video" },

gbazin's avatar
   
gbazin committed
868
#if LIBAVCODEC_BUILD >= 4694
gbazin's avatar
   
gbazin committed
869
870
871
    /* Duck TrueMotion */
    { VLC_FOURCC('D','U','C','K'), CODEC_ID_TRUEMOTION1,
      VIDEO_ES, "Duck TrueMotion v1 Video" },
gbazin's avatar
   
gbazin committed
872
#endif
gbazin's avatar
   
gbazin committed
873

gbazin's avatar
   
gbazin committed
874
875
876
877
    /* Interplay MVE */
    { VLC_FOURCC('i','m','v','e'), CODEC_ID_INTERPLAY_VIDEO,
      VIDEO_ES, "Interplay MVE Video" },

gbazin's avatar
   
gbazin committed
878
879
880
881
882
883
884
885
886
887
888
889
890
891
    /* Id RoQ */
    { VLC_FOURCC('R','o','Q','v'), CODEC_ID_ROQ,
      VIDEO_ES, "Id RoQ Video" },

    /* Sony Playstation MDEC */
    { VLC_FOURCC('M','D','E','C'), CODEC_ID_MDEC,
      VIDEO_ES, "PSX MDEC Video" },

#if LIBAVCODEC_BUILD >= 4699
    /* Sierra VMD */
    { VLC_FOURCC('v','m','d','v'), CODEC_ID_VMDVIDEO,
      VIDEO_ES, "Sierra VMD Video" },
#endif

892
#if LIBAVCODEC_BUILD >= 4719
gbazin's avatar
gbazin committed
893
894
895
896
897
    /* FFMPEG's SNOW wavelet codec */
    { VLC_FOURCC('S','N','O','W'), CODEC_ID_SNOW,
      VIDEO_ES, "FFMpeg SNOW wavelet Video" },
#endif

898
#if LIBAVCODEC_BUILD >= 4752
899
900
901
    { VLC_FOURCC('r','l','e',' '), CODEC_ID_QTRLE,
      VIDEO_ES, "Apple QuickTime RLE Video" },

902
903
904
905
906
907
908
909
910
911
912
913
914
    { VLC_FOURCC('q','d','r','w'), CODEC_ID_QDRAW,
      VIDEO_ES, "Apple QuickDraw Video" },

    { VLC_FOURCC('Q','P','E','G'), CODEC_ID_QPEG,
      VIDEO_ES, "QPEG Video" },
    { VLC_FOURCC('Q','1','.','0'), CODEC_ID_QPEG,
      VIDEO_ES, "QPEG Video" },
    { VLC_FOURCC('Q','1','.','1'), CODEC_ID_QPEG,
      VIDEO_ES, "QPEG Video" },

    { VLC_FOURCC('U','L','T','I'), CODEC_ID_ULTI,
      VIDEO_ES, "IBM Ultimotion Video" },

915
916
917
    { VLC_FOURCC('V','I','X','L'), CODEC_ID_VIXL,
      VIDEO_ES, "Miro/Pinnacle VideoXL Video" },

918
919
920
921
922
923
924
925
    { VLC_FOURCC('L','O','C','O'), CODEC_ID_LOCO,
      VIDEO_ES, "LOCO Video" },

    { VLC_FOURCC('W','N','V','1'), CODEC_ID_WNV1,
      VIDEO_ES, "Winnov WNV1 Video" },

    { VLC_FOURCC('A','A','S','C'), CODEC_ID_AASC,
      VIDEO_ES, "Autodesc RLE Video" },
926
927
#endif
#if LIBAVCODEC_BUILD >= 4753
928
929
    { VLC_FOURCC('I','V','2','0'), CODEC_ID_INDEO2,
      VIDEO_ES, "Indeo Video v2" },
930
931
    { VLC_FOURCC('R','T','2','1'), CODEC_ID_INDEO2,
      VIDEO_ES, "Indeo Video v2" },
932
933
#endif

934
935
936
937
938
939
#if LIBAVCODEC_BUILD >= ((51<<16)+(13<<8)+0)
    { VLC_FOURCC('V','M','n','c'), CODEC_ID_VMNC,
      VIDEO_ES, "VMware Video" },
#endif


940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
    /*
     *  Image codecs
     */

#if LIBAVCODEC_BUILD >= 4731
    { VLC_FOURCC('p','n','g',' '), CODEC_ID_PNG,
      VIDEO_ES, "PNG Image" },
    { VLC_FOURCC('p','p','m',' '), CODEC_ID_PPM,
      VIDEO_ES, "PPM Image" },
    { VLC_FOURCC('p','g','m',' '), CODEC_ID_PGM,
      VIDEO_ES, "PGM Image" },
    { VLC_FOURCC('p','g','m','y'), CODEC_ID_PGMYUV,
      VIDEO_ES, "PGM YUV Image" },
    { VLC_FOURCC('p','a','m',' '), CODEC_ID_PAM,
      VIDEO_ES, "PAM Image" },
955
956
#endif

957
#if LIBAVCODEC_BUILD >= ((51<<16)+(0<<8)+0)
958
959
    { VLC_FOURCC('b','m','p',' '), CODEC_ID_BMP,
      VIDEO_ES, "BMP Image" },
960
961
#endif

gbazin's avatar
   
gbazin committed
962
963
964
965
966
    /*
     *  Audio Codecs
     */

    /* Windows Media Audio 1 */
gbazin's avatar
   
gbazin committed
967
968
969
970
    { VLC_FOURCC('W','M','A','1'), CODEC_ID_WMAV1,
      AUDIO_ES, "Windows Media Audio 1" },
    { VLC_FOURCC('w','m','a','1'), CODEC_ID_WMAV1,
      AUDIO_ES, "Windows Media Audio 1" },
gbazin's avatar
   
gbazin committed
971
972

    /* Windows Media Audio 2 */
gbazin's avatar
   
gbazin committed
973
974
975
976
    { VLC_FOURCC('W','M','A','2'), CODEC_ID_WMAV2,
      AUDIO_ES, "Windows Media Audio 2" },
    { VLC_FOURCC('w','m','a','2'), CODEC_ID_WMAV2,
      AUDIO_ES, "Windows Media Audio 2" },
gbazin's avatar
   
gbazin committed
977
978

    /* DV Audio */
gbazin's avatar
   
gbazin committed
979
980
    { VLC_FOURCC('d','v','a','u'), CODEC_ID_DVAUDIO,
      AUDIO_ES, "DV Audio" },
gbazin's avatar
   
gbazin committed
981
982

    /* MACE-3 Audio */
gbazin's avatar
   
gbazin committed
983
984
    { VLC_FOURCC('M','A','C','3'), CODEC_ID_MACE3,
      AUDIO_ES, "MACE-3 Audio" },
gbazin's avatar
   
gbazin committed
985
986

    /* MACE-6 Audio */
gbazin's avatar
   
gbazin committed
987
988
    { VLC_FOURCC('M','A','C','6'), CODEC_ID_MACE6,
      AUDIO_ES, "MACE-6 Audio" },
gbazin's avatar
   
gbazin committed
989
990

    /* RealAudio 1.0 */
gbazin's avatar
   
gbazin committed
991
992
    { VLC_FOURCC('1','4','_','4'), CODEC_ID_RA_144,
      AUDIO_ES, "RealAudio 1.0" },
gbazin's avatar
   
gbazin committed
993
994

    /* RealAudio 2.0 */
gbazin's avatar
   
gbazin committed
995
996
    { VLC_FOURCC('2','8','_','8'), CODEC_ID_RA_288,
      AUDIO_ES, "RealAudio 2.0" },
gbazin's avatar
   
gbazin committed
997
998

    /* MPEG Audio layer 1/2/3 */
gbazin's avatar
   
gbazin committed
999
1000
1001
1002
    { VLC_FOURCC('m','p','g','a'), CODEC_ID_MP2,
      AUDIO_ES, "MPEG Audio layer 1/2" },
    { VLC_FOURCC('m','p','3',' '), CODEC_ID_MP3,
      AUDIO_ES, "MPEG Audio layer 1/2/3" },
gbazin's avatar
   
gbazin committed
1003
1004

    /* A52 Audio (aka AC3) */
gbazin's avatar
   
gbazin committed
1005
1006
1007
1008
    { VLC_FOURCC('a','5','2',' '), CODEC_ID_AC3,
      AUDIO_ES, "A52 Audio (aka AC3)" },
    { VLC_FOURCC('a','5','2','b'), CODEC_ID_AC3, /* VLC specific hack */
      AUDIO_ES, "A52 Audio (aka AC3)" },
gbazin's avatar
   
gbazin committed
1009

1010
#if LIBAVCODEC_BUILD >= 4719
gbazin's avatar
gbazin committed
1011
1012
1013
1014
1015
    /* DTS Audio */
    { VLC_FOURCC('d','t','s',' '), CODEC_ID_DTS,
      AUDIO_ES, "DTS Audio" },
#endif

gbazin's avatar
   
gbazin committed
1016
    /* AAC audio */
gbazin's avatar
   
gbazin committed
1017
1018
1019
    { VLC_FOURCC('m','p','4','a'), CODEC_ID_AAC,
      AUDIO_ES, "MPEG AAC Audio" },

gbazin's avatar
   
gbazin committed
1020
1021
1022
1023
    /* 4X Technologies */
    { VLC_FOURCC('4','x','m','a'), CODEC_ID_ADPCM_4XM,
      AUDIO_ES, "4X Technologies Audio" },

gbazin's avatar
   
gbazin committed
1024
1025
1026
1027
    /* Interplay DPCM */
    { VLC_FOURCC('i','d','p','c'), CODEC_ID_INTERPLAY_DPCM,
      AUDIO_ES, "Interplay DPCM Audio" },

gbazin's avatar
   
gbazin committed
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
    /* Id RoQ */
    { VLC_FOURCC('R','o','Q','a'), CODEC_ID_ROQ_DPCM,
      AUDIO_ES, "Id RoQ DPCM Audio" },

#if LIBAVCODEC_BUILD >= 4685
    /* Sony Playstation XA ADPCM */
    { VLC_FOURCC('x','a',' ',' '), CODEC_ID_ADPCM_XA,
      AUDIO_ES, "PSX XA ADPCM Audio" },

    /* ADX ADPCM */
    { VLC_FOURCC('a','d','x',' '), CODEC_ID_ADPCM_ADX,
      AUDIO_ES, "ADX ADPCM Audio" },
#endif

#if LIBAVCODEC_BUILD >= 4699
    /* Sierra VMD */
    { VLC_FOURCC('v','m','d','a'), CODEC_ID_VMDAUDIO,
      AUDIO_ES, "Sierra VMD Audio" },
#endif

hartman's avatar
hartman committed
1048
1049
1050
1051
1052
1053
#if LIBAVCODEC_BUILD >= 4706
    /* G.726 ADPCM */
    { VLC_FOURCC('g','7','2','6'), CODEC_ID_ADPCM_G726,
      AUDIO_ES, "G.726 ADPCM Audio" },
#endif

1054
1055
1056
1057
1058
1059
1060
1061
#if LIBAVCODEC_BUILD >= 4683
    /* AMR */
    { VLC_FOURCC('s','a','m','r'), CODEC_ID_AMR_NB,
      AUDIO_ES, "AMR narrow band" },
    { VLC_FOURCC('s','a','w','b'), CODEC_ID_AMR_WB,
      AUDIO_ES, "AMR wide band" },
#endif

1062
1063
1064
1065
1066
1067
#if LIBAVCODEC_BUILD >= 4703
    /* FLAC */
    { VLC_FOURCC('f','l','a','c'), CODEC_ID_FLAC,
      AUDIO_ES, "FLAC (Free Lossless Audio Codec)" },
#endif

1068
1069
1070
1071
1072
1073
#if LIBAVCODEC_BUILD >= 4745
    /* ALAC */
    { VLC_FOURCC('a','l','a','c'), CODEC_ID_ALAC,
      AUDIO_ES, "Apple Lossless Audio Codec" },
#endif

1074
#if LIBAVCODEC_BUILD >= ((50<<16)+(0<<8)+1)
1075
1076
    /* QDM2 */
    { VLC_FOURCC('Q','D','M','2'), CODEC_ID_QDM2,
1077
      AUDIO_ES, "QDM2 Audio" },
1078
#endif
1079

1080
1081
1082
#if LIBAVCODEC_BUILD >= ((51<<16)+(0<<8)+0)
    /* COOK */
    { VLC_FOURCC('c','o','o','k'), CODEC_ID_COOK,
1083
      AUDIO_ES, "Cook Audio" },
1084
1085
#endif

1086
1087
1088
1089
1090
1091
#if LIBAVCODEC_BUILD >= ((51<<16)+(8<<8)+0)
    /* Shorten */
    { VLC_FOURCC(