+/*****************************************************************************
+ * ffmpeg_OpenCodec:
+ *****************************************************************************/
+static int ffmpeg_OpenCodec( decoder_t *p_dec )
+{
+ decoder_sys_t *p_sys = p_dec->p_sys;
+
+ if( p_sys->p_context->extradata_size <= 0 )
+ {
+ if( p_sys->i_codec_id == CODEC_ID_VC1 ||
+ p_sys->i_codec_id == CODEC_ID_VORBIS ||
+ p_sys->i_codec_id == CODEC_ID_THEORA )
+ {
+ msg_Warn( p_dec, "waiting for extra data for codec %s",
+ p_sys->psz_namecodec );
+ return 1;
+ }
+ }
+ p_sys->p_context->width = p_dec->fmt_in.video.i_width;
+ p_sys->p_context->height = p_dec->fmt_in.video.i_height;
+#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
+ p_sys->p_context->bits_per_sample = p_dec->fmt_in.video.i_bits_per_pixel;
+#else
+ p_sys->p_context->bits_per_coded_sample = p_dec->fmt_in.video.i_bits_per_pixel;
+#endif
+
+ int ret;
+ vlc_avcodec_lock();
+ ret = avcodec_open( p_sys->p_context, p_sys->p_codec );
+ vlc_avcodec_unlock();
+ if( ret < 0 )
+ return VLC_EGENERIC;
+ msg_Dbg( p_dec, "ffmpeg codec (%s) started", p_sys->psz_namecodec );
+
+ p_sys->b_delayed_open = false;
+
+ return VLC_SUCCESS;
+}