Index: libmpcodecs/vd.c
===================================================================
--- libmpcodecs/vd.c	(revision 25594)
+++ libmpcodecs/vd.c	(working copy)
@@ -127,7 +127,6 @@
 int vo_gamma_saturation = 1000;
 int vo_gamma_hue = 1000;
 
-extern vd_functions_t* mpvdec; // FIXME!
 
 int mpcodecs_config_vo(sh_video_t *sh, int w, int h, unsigned int preferred_outfmt){
     int i,j;
@@ -135,6 +134,7 @@
     int screen_size_x=0;//SCREEN_SIZE_X;
     int screen_size_y=0;//SCREEN_SIZE_Y;
     vf_instance_t* vf=sh->vfilter,*sc=NULL;
+    vd_functions_t* mpvdec=sh->mpvdec;
     int palette=0;
     int vocfg_flags=0;
 
Index: libmpcodecs/dec_video.c
===================================================================
--- libmpcodecs/dec_video.c	(revision 25594)
+++ libmpcodecs/dec_video.c	(working copy)
@@ -43,10 +43,10 @@
 
 int divx_quality=0;
 
-vd_functions_t* mpvdec=NULL;
 
 int get_video_quality_max(sh_video_t *sh_video){
   vf_instance_t* vf=sh_video->vfilter;
+  vd_functions_t* mpvdec=sh_video->mpvdec;
   if(vf){
     int ret=vf->control(vf,VFCTRL_QUERY_MAX_PP_LEVEL,NULL);
     if(ret>0){
@@ -67,6 +67,7 @@
 
 void set_video_quality(sh_video_t *sh_video,int quality){
   vf_instance_t* vf=sh_video->vfilter;
+  vd_functions_t* mpvdec=sh_video->mpvdec;
   if(vf){
     int ret=vf->control(vf,VFCTRL_SET_PP_LEVEL, (void*)(&quality));
     if(ret==CONTROL_TRUE) return; // success
@@ -78,6 +79,7 @@
 int set_video_colors(sh_video_t *sh_video,const char *item,int value)
 {
     vf_instance_t* vf=sh_video->vfilter;
+    vd_functions_t* mpvdec=sh_video->mpvdec;
     vf_equalizer_t data;
 
     data.item = item;
@@ -101,6 +103,7 @@
 int get_video_colors(sh_video_t *sh_video,const char *item,int *value)
 {
     vf_instance_t* vf=sh_video->vfilter;
+    vd_functions_t* mpvdec=sh_video->mpvdec;
     vf_equalizer_t data;
 
     data.item = item;
@@ -136,11 +139,13 @@
 
 void resync_video_stream(sh_video_t *sh_video)
 {
+    vd_functions_t* mpvdec=sh_video->mpvdec;
     if(mpvdec) mpvdec->control(sh_video, VDCTRL_RESYNC_STREAM, NULL);
 }
 
 int get_current_video_decoder_lag(sh_video_t *sh_video)
 {
+    vd_functions_t* mpvdec=sh_video->mpvdec;
     int ret;
 
     if (!mpvdec)
@@ -152,6 +157,7 @@
 }
 
 void uninit_video(sh_video_t *sh_video){
+    vd_functions_t* mpvdec=sh_video->mpvdec;
     if(!sh_video->inited) return;
     mp_msg(MSGT_DECVIDEO,MSGL_V,MSGTR_UninitVideoStr,sh_video->codec->drv);
     mpvdec->uninit(sh_video);
@@ -180,6 +186,7 @@
     unsigned int orig_fourcc=sh_video->bih?sh_video->bih->biCompression:0;
     sh_video->codec=NULL;
     sh_video->vf_inited=0;
+    vd_functions_t* mpvdec=sh_video->mpvdec;
     if (codecname && codecname[0] == '+') {
       codecname = &codecname[1];
       force = 1;
@@ -203,7 +210,7 @@
 	for (i=0; mpcodecs_vd_drivers[i] != NULL; i++)
 //	    if(mpcodecs_vd_drivers[i]->info->id==sh_video->codec->driver) break;
 	    if(!strcmp(mpcodecs_vd_drivers[i]->info->short_name,sh_video->codec->drv)) break;
-	mpvdec=mpcodecs_vd_drivers[i];
+	sh_video->mpvdec=mpvdec=mpcodecs_vd_drivers[i];
 #ifdef DYNAMIC_PLUGINS
 	if (!mpvdec)
 	{
@@ -328,6 +335,7 @@
 void *decode_video(sh_video_t *sh_video, unsigned char *start, int in_size,
 		   int drop_frame, double pts)
 {
+    vd_functions_t* mpvdec=sh_video->mpvdec;
     mp_image_t *mpi = NULL;
     unsigned int t = GetTimer();
     unsigned int t2;
Index: libmpdemux/stheader.h
===================================================================
--- libmpdemux/stheader.h	(revision 25594)
+++ libmpdemux/stheader.h	(working copy)
@@ -89,6 +89,7 @@
   void* ImageDesc; // for quicktime codecs
   // codec-specific:
   void* context;   // codec-specific stuff (usually HANDLE or struct pointer)
+  void* mpvdec;    // vd_functions_t* pointer
 } sh_video_t;
 
 typedef struct {
