+static int OpenVideoCodec( decoder_t *p_dec )
+{
+ decoder_sys_t *p_sys = p_dec->p_sys;
+
+ if( p_sys->p_context->extradata_size <= 0 )
+ {
+ if( p_sys->p_codec->id == AV_CODEC_ID_VC1 ||
+ p_sys->p_codec->id == AV_CODEC_ID_THEORA )
+ {
+ msg_Warn( p_dec, "waiting for extra data for codec %s",
+ p_sys->p_codec->name );
+ return 1;
+ }
+ }
+
+ p_sys->p_context->width = p_dec->fmt_in.video.i_visible_width;
+ p_sys->p_context->height = p_dec->fmt_in.video.i_visible_height;
+ if (p_sys->p_context->width == 0)
+ p_sys->p_context->width = p_dec->fmt_in.video.i_width;
+ else if (p_sys->p_context->width != p_dec->fmt_in.video.i_width)
+ p_sys->p_context->coded_width = p_dec->fmt_in.video.i_width;
+ if (p_sys->p_context->height == 0)
+ p_sys->p_context->height = p_dec->fmt_in.video.i_height;
+ else if (p_sys->p_context->height != p_dec->fmt_in.video.i_height)
+ p_sys->p_context->coded_height = p_dec->fmt_in.video.i_height;
+ p_sys->p_context->bits_per_coded_sample = p_dec->fmt_in.video.i_bits_per_pixel;
+
+ int ret = ffmpeg_OpenCodec( p_dec );
+ if( ret < 0 )
+ return ret;
+
+#ifdef HAVE_AVCODEC_MT
+ switch( p_sys->p_context->active_thread_type )
+ {
+ case FF_THREAD_FRAME:
+ msg_Dbg( p_dec, "using frame thread mode with %d threads",
+ p_sys->p_context->thread_count );
+ break;
+ case FF_THREAD_SLICE:
+ msg_Dbg( p_dec, "using slice thread mode with %d threads",
+ p_sys->p_context->thread_count );
+ break;
+ case 0:
+ if( p_sys->p_context->thread_count > 1 )
+ msg_Warn( p_dec, "failed to enable threaded decoding" );
+ break;
+ default:
+ msg_Warn( p_dec, "using unknown thread mode with %d threads",
+ p_sys->p_context->thread_count );
+ break;
+ }
+#endif
+ return VLC_SUCCESS;
+}
+