~ubuntu-branches/ubuntu/natty/vlc/natty

« back to all changes in this revision

Viewing changes to modules/codec/avcodec/avcodec.c

  • Committer: Bazaar Package Importer
  • Author(s): Benjamin Drung
  • Date: 2010-06-25 01:09:16 UTC
  • mfrom: (1.1.30 upstream)
  • Revision ID: james.westby@ubuntu.com-20100625010916-asxhep2mutg6g6pd
Tags: 1.1.0-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - build and install the libx264 plugin
  - add Xb-Npp header to vlc package
  - Add apport hook to include more vlc dependencies in bug reports
* Drop xulrunner patches.
* Drop 502_xulrunner_191.diff.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * avcodec.c: video and audio decoder and encoder using libavcodec
3
3
 *****************************************************************************
4
4
 * Copyright (C) 1999-2008 the VideoLAN team
5
 
 * $Id: 0d4026e275fb4cc9ae49a0dae44f61818d4cbce0 $
 
5
 * $Id: 7313a9b503291939af63bb02bd9eb16b2560841b $
6
6
 *
7
7
 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8
8
 *          Gildas Bazin <gbazin@videolan.org>
33
33
#include <vlc_plugin.h>
34
34
#include <vlc_codec.h>
35
35
#include <vlc_avcodec.h>
 
36
#include <vlc_cpu.h>
36
37
 
37
38
/* ffmpeg header */
38
39
#define HAVE_MMX 1
44
45
#   include <avcodec.h>
45
46
#endif
46
47
 
47
 
#if LIBAVCODEC_BUILD < 5000
48
 
#   error You must have a libavcodec >= 5000 (get svn)
49
 
#endif
50
 
 
51
48
#include "avcodec.h"
52
49
#include "avutil.h"
53
50
 
 
51
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 51, 48, 0 )
 
52
#   error You must update libavcodec to a version >= 51.48.0
 
53
#elif LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 52, 25, 0 )
 
54
#   warning You should update libavcodec to get subtitle support
 
55
#endif
 
56
 
54
57
/*****************************************************************************
55
58
 * decoder_sys_t: decoder descriptor
56
59
 *****************************************************************************/
76
79
    N_("rd"), N_("bits"), N_("simple") };
77
80
#endif
78
81
 
 
82
#ifdef MERGE_FFMPEG
 
83
# include "../../demux/avformat/avformat.h"
 
84
# include "../../access/avio.h"
 
85
#endif
 
86
 
79
87
/*****************************************************************************
80
88
 * Module descriptor
81
89
 *****************************************************************************/
82
 
#define MODULE_DESCRIPTION N_( "Various audio and video decoders/encoders" \
 
90
#define MODULE_DESCRIPTION N_( "Various audio and video decoders/encoders " \
83
91
        "delivered by the FFmpeg library. This includes (MS)MPEG4, DivX, SV1,"\
84
92
        "H261, H263, H264, WMV, WMA, AAC, AMR, DV, MJPEG and other codecs")
85
93
 
87
95
    set_shortname( "FFmpeg")
88
96
    add_shortcut( "ffmpeg" )
89
97
    set_category( CAT_INPUT )
90
 
    set_subcategory( SUBCAT_INPUT_SCODEC )
 
98
    set_subcategory( SUBCAT_INPUT_VCODEC )
91
99
    /* decoder main module */
92
100
#if defined(MODULE_NAME_is_ffmpegaltivec) \
93
101
     || (defined(CAN_COMPILE_ALTIVEC) && !defined(NO_ALTIVEC_IN_FFMPEG))
103
111
    set_callbacks( OpenDecoder, CloseDecoder )
104
112
 
105
113
 
106
 
    add_bool( "ffmpeg-dr", 1, NULL, DR_TEXT, DR_TEXT, true )
 
114
    add_bool( "ffmpeg-dr", true, NULL, DR_TEXT, DR_TEXT, true )
107
115
    add_integer ( "ffmpeg-error-resilience", 1, NULL, ERROR_TEXT,
108
116
        ERROR_LONGTEXT, true )
109
117
    add_integer ( "ffmpeg-workaround-bugs", 1, NULL, BUGS_TEXT, BUGS_LONGTEXT,
110
118
        false )
111
 
    add_bool( "ffmpeg-hurry-up", 1, NULL, HURRYUP_TEXT, HURRYUP_LONGTEXT,
 
119
    add_bool( "ffmpeg-hurry-up", true, NULL, HURRYUP_TEXT, HURRYUP_LONGTEXT,
112
120
        false )
113
121
    add_integer( "ffmpeg-skip-frame", 0, NULL, SKIP_FRAME_TEXT,
114
122
        SKIP_FRAME_LONGTEXT, true )
121
129
    add_integer ( "ffmpeg-lowres", 0, NULL, LOWRES_TEXT, LOWRES_LONGTEXT,
122
130
        true )
123
131
        change_integer_range( 0, 2 )
124
 
    add_bool( "ffmpeg-fast", 0, NULL, FAST_TEXT, FAST_LONGTEXT, true )
 
132
    add_bool( "ffmpeg-fast", false, NULL, FAST_TEXT, FAST_LONGTEXT, true )
125
133
    add_integer ( "ffmpeg-skiploopfilter", 0, NULL, SKIPLOOPF_TEXT,
126
134
                  SKIPLOOPF_LONGTEXT, true )
127
135
        change_safe ()
129
137
 
130
138
    add_integer( "ffmpeg-debug", 0, NULL, DEBUG_TEXT, DEBUG_LONGTEXT,
131
139
                 true )
 
140
#if defined(HAVE_AVCODEC_VAAPI) || defined(HAVE_AVCODEC_DXVA2)
 
141
    add_bool( "ffmpeg-hw", false, NULL, HW_TEXT, HW_LONGTEXT, true )
 
142
#endif
132
143
 
133
144
#ifdef ENABLE_SOUT
134
145
    /* encoder submodule */
146
157
                 ENC_KEYINT_LONGTEXT, false )
147
158
    add_integer( ENC_CFG_PREFIX "bframes", 0, NULL, ENC_BFRAMES_TEXT,
148
159
                 ENC_BFRAMES_LONGTEXT, false )
149
 
    add_bool( ENC_CFG_PREFIX "hurry-up", 0, NULL, ENC_HURRYUP_TEXT,
 
160
    add_bool( ENC_CFG_PREFIX "hurry-up", false, NULL, ENC_HURRYUP_TEXT,
150
161
              ENC_HURRYUP_LONGTEXT, false )
151
 
    add_bool( ENC_CFG_PREFIX "interlace", 0, NULL, ENC_INTERLACE_TEXT,
 
162
    add_bool( ENC_CFG_PREFIX "interlace", false, NULL, ENC_INTERLACE_TEXT,
152
163
              ENC_INTERLACE_LONGTEXT, true )
153
 
    add_bool( ENC_CFG_PREFIX "interlace-me", 1, NULL, ENC_INTERLACE_ME_TEXT,
 
164
    add_bool( ENC_CFG_PREFIX "interlace-me", true, NULL, ENC_INTERLACE_ME_TEXT,
154
165
              ENC_INTERLACE_ME_LONGTEXT, true )
155
166
    add_integer( ENC_CFG_PREFIX "vt", 0, NULL, ENC_VT_TEXT,
156
167
                 ENC_VT_LONGTEXT, true )
157
 
    add_bool( ENC_CFG_PREFIX "pre-me", 0, NULL, ENC_PRE_ME_TEXT,
 
168
    add_bool( ENC_CFG_PREFIX "pre-me", false, NULL, ENC_PRE_ME_TEXT,
158
169
              ENC_PRE_ME_LONGTEXT, true )
159
170
    add_integer( ENC_CFG_PREFIX "rc-buffer-size", 224*1024*8, NULL,
160
171
                 ENC_RC_BUF_TEXT, ENC_RC_BUF_LONGTEXT, true )
164
175
               ENC_IQUANT_FACTOR_TEXT, ENC_IQUANT_FACTOR_LONGTEXT, true )
165
176
    add_integer( ENC_CFG_PREFIX "noise-reduction", 0, NULL,
166
177
                 ENC_NOISE_RED_TEXT, ENC_NOISE_RED_LONGTEXT, true )
167
 
    add_bool( ENC_CFG_PREFIX "mpeg4-matrix", 0, NULL,
 
178
    add_bool( ENC_CFG_PREFIX "mpeg4-matrix", false, NULL,
168
179
              ENC_MPEG4_MATRIX_TEXT, ENC_MPEG4_MATRIX_LONGTEXT, true )
169
180
    add_integer( ENC_CFG_PREFIX "qmin", 0, NULL,
170
181
                 ENC_QMIN_TEXT, ENC_QMIN_LONGTEXT, true )
171
182
    add_integer( ENC_CFG_PREFIX "qmax", 0, NULL,
172
183
                 ENC_QMAX_TEXT, ENC_QMAX_LONGTEXT, true )
173
 
    add_bool( ENC_CFG_PREFIX "trellis", 0, NULL,
 
184
    add_bool( ENC_CFG_PREFIX "trellis", false, NULL,
174
185
              ENC_TRELLIS_TEXT, ENC_TRELLIS_LONGTEXT, true )
175
186
    add_float( ENC_CFG_PREFIX "qscale", 0, NULL,
176
187
               ENC_QSCALE_TEXT, ENC_QSCALE_LONGTEXT, true )
189
200
    add_integer( ENC_CFG_PREFIX "chroma-elim-threshold", 0, NULL,
190
201
                 ENC_CHROMA_ELIM_TEXT, ENC_CHROMA_ELIM_LONGTEXT, true )
191
202
 
192
 
#if LIBAVCODEC_VERSION_INT >= ((51<<16)+(40<<8)+4)
193
203
    /* Audio AAC encoder profile */
194
204
    add_string( ENC_CFG_PREFIX "aac-profile", "low", NULL,
195
205
                ENC_PROFILE_TEXT, ENC_PROFILE_LONGTEXT, true )
196
 
#endif
197
206
#endif /* ENABLE_SOUT */
198
207
 
199
208
    /* video filter submodule */
203
212
    set_description( N_("FFmpeg deinterlace video filter") )
204
213
    add_shortcut( "ffmpeg-deinterlace" )
205
214
 
 
215
#ifdef MERGE_FFMPEG
 
216
    add_submodule ()
 
217
#   include "../../demux/avformat/avformat.c"
 
218
    add_submodule ()
 
219
        AVIO_MODULE
 
220
#endif
206
221
vlc_module_end ()
207
222
 
208
223
/*****************************************************************************
239
254
    p_context = avcodec_alloc_context();
240
255
    if( !p_context )
241
256
        return VLC_ENOMEM;
242
 
    p_context->debug = config_GetInt( p_dec, "ffmpeg-debug" );
 
257
    p_context->debug = var_InheritInteger( p_dec, "ffmpeg-debug" );
243
258
    p_context->opaque = (void *)p_this;
244
259
 
245
260
    /* Set CPU capabilities */
265
280
    {
266
281
        p_context->dsp_mask |= FF_MM_SSE2;
267
282
    }
 
283
#ifdef FF_MM_SSE3
 
284
    if( !(i_cpu & CPU_CAPABILITY_SSE3) )
 
285
        p_context->dsp_mask |= FF_MM_SSE3;
 
286
#endif
 
287
#ifdef FF_MM_SSSE3
 
288
    if( !(i_cpu & CPU_CAPABILITY_SSSE3) )
 
289
        p_context->dsp_mask |= FF_MM_SSSE3;
 
290
#endif
 
291
#ifdef FF_MM_SSE4
 
292
    if( !(i_cpu & CPU_CAPABILITY_SSE4_1) )
 
293
        p_context->dsp_mask |= FF_MM_SSE4;
 
294
#endif
 
295
#ifdef FF_MM_SSE42
 
296
    if( !(i_cpu & CPU_CAPABILITY_SSE4_2) )
 
297
        p_context->dsp_mask |= FF_MM_SSE42;
 
298
#endif
268
299
 
269
300
    p_dec->b_need_packetized = true;
270
301
    switch( i_cat )
279
310
        i_result =  InitAudioDec ( p_dec, p_context, p_codec,
280
311
                                       i_codec_id, psz_namecodec );
281
312
        break;
 
313
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 52, 25, 0 )
 
314
    case SPU_ES:
 
315
        p_dec->pf_decode_sub = DecodeSubtitle;
 
316
        i_result =  InitSubtitleDec( p_dec, p_context, p_codec,
 
317
                                     i_codec_id, psz_namecodec );
 
318
        break;
 
319
#endif
282
320
    default:
283
321
        i_result = VLC_EGENERIC;
284
322
    }
285
323
 
286
 
    if( i_result == VLC_SUCCESS ) p_dec->p_sys->i_cat = i_cat;
 
324
    if( i_result == VLC_SUCCESS )
 
325
    {
 
326
        p_dec->p_sys->i_cat = i_cat;
 
327
        if( p_context->profile != FF_PROFILE_UNKNOWN)
 
328
            p_dec->fmt_in.i_profile = p_context->profile;
 
329
        if( p_context->level != FF_LEVEL_UNKNOWN)
 
330
            p_dec->fmt_in.i_level = p_context->level;
 
331
    }
287
332
 
288
333
    return i_result;
289
334
}
304
349
    case VIDEO_ES:
305
350
         EndVideoDec ( p_dec );
306
351
        break;
 
352
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 52, 25, 0 )
 
353
    case SPU_ES:
 
354
         EndSubtitleDec( p_dec );
 
355
        break;
 
356
#endif
307
357
    }
308
358
 
309
359
    if( p_sys->p_context )