[MPlayer-dev-eng] Patch: Pre-alpha support for virtualdub filters

Fredrik Kuivinen freku045 at student.liu.se
Sun Dec 23 16:43:07 CET 2001


Hi

Here is a patch to enable mplayer to load and use virtualdub filters. Due to
use of C++ in virtualdub filters it is quite hard to load the filters directly
from mplayer. I have therefore created a dll called glue.dll which is currently
compiled with visual c++. This dll is then used from mplayer. It is possible to
use visual c++ with wine and the makefiles currently do this. However I have
attached glue.dll and sylia.dll (Sylia is the scripting language used in
virtualdub.). As stated in the subject this is pre-alpha code. I have only
tested it with a few simple filters and it works. However a lot of filters
probably don't work.

Current limitations:
* Filters that resize the image do not work.
* Virtualdub filters only accept RGB32 and this patch only converts from RGB24
  so all yuv things do not work.
* Only one filter at a time. No filter chain or anything like that.
* Probably a lot more...

To test this:
Download some virtualdub filters. A few can be found at 
http://sauron.mordor.net/dgraft/.
Copy glue.dll and sylia.dll to somewhere where the win32 loader can find it.
Run mplayer -filter path-to-filter -filterconfig sylia-script-to-execute ...

Where sylia-script-to-execute looks something like 
"filters.instance[0].Config(...);"
(Example: "filters.instance[0].Config(100,0,0);" when using the RGB filter from
http://sauron.mordor.net/dgraft/rgb.html makes the picture more red.)

About the patch: It has some small changes to mplayer.c, dec_video.c, 
loader/win32.c, cfg-mplayer.h and some Makefiles. Most of the files in the new
directory loader/virtualdub is copied with small modifications from the
virtualdub source code. The code is quite ugly now but it is just a hack, I
wanted to test the idea (which was discussed in this ml some time ago.) and it
worked. virtualdub.tar.gz should be extracted in loader/.

Well... Is this something that is useful in mplayer/mencoder?

/ Fredrik Kuivinen

-------------- next part --------------
? main/loader/virtualdub
Index: main/Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/Makefile,v
retrieving revision 1.125
diff -u -3 -p -r1.125 Makefile
--- main/Makefile	21 Dec 2001 16:39:54 -0000	1.125
+++ main/Makefile	23 Dec 2001 15:21:50 -0000
@@ -163,7 +163,7 @@ GUI_LIBS = -LGui -lgui
 endif
 
 $(PRG):	$(MPLAYER_DEP)
-	$(CC) $(CFLAGS) -o $(PRG) $(OBJS_MPLAYER) $(CODEC_LIBS) -Llibmpdemux -lmpdemux $(VO_LIBS) $(AO_LIBS) $(LIB_LOADER) $(GUI_LIBS) $(COMMON_LIBS) $(EXTRA_LIB) $(A_LIBS) $(V_LIBS) $(LIRC_LIB) $(CSS_LIB) $(ARCH_LIB) $(DECORE_LIB) $(TERMCAP_LIB) $(STATIC_LIB) $(GTK_LIBS) $(PNG_LIB) $(Z_LIB) -lm
+	$(CC) $(CFLAGS) -o $(PRG) $(OBJS_MPLAYER) $(CODEC_LIBS) -Llibmpdemux -lmpdemux $(VO_LIBS) $(AO_LIBS) $(LIB_LOADER) $(GUI_LIBS) $(COMMON_LIBS) $(EXTRA_LIB) $(A_LIBS) $(V_LIBS) $(LIRC_LIB) $(CSS_LIB) $(ARCH_LIB) $(DECORE_LIB) $(TERMCAP_LIB) $(STATIC_LIB) $(GTK_LIBS) $(PNG_LIB) $(Z_LIB) -lm loader/virtualdub/mpvd.o
 
 $(PRG_FIBMAP): fibmap_mplayer.o
 	$(CC) -o $(PRG_FIBMAP) fibmap_mplayer.o
Index: main/cfg-mplayer.h
===================================================================
RCS file: /cvsroot/mplayer/main/cfg-mplayer.h,v
retrieving revision 1.115
diff -u -3 -p -r1.115 cfg-mplayer.h
--- main/cfg-mplayer.h	23 Dec 2001 01:34:10 -0000	1.115
+++ main/cfg-mplayer.h	23 Dec 2001 15:21:50 -0000
@@ -90,6 +90,9 @@ struct config ao_plugin_conf[]={
 
 extern int sws_flags;
 
+extern char* filter_path;
+extern char* filter_config;
+
 /*
  * CONF_TYPE_FUNC_FULL :
  * allows own implemtations for passing the params
@@ -108,6 +111,9 @@ struct config conf[]={
 	{"include", cfg_include, CONF_TYPE_FUNC_PARAM, 0, 0, 0}, /* this must be the first!!! */
 
 //---------------------- libao/libvo/mplayer options ------------------------
+    {"filter", &filter_path, CONF_TYPE_STRING, 0, 0, 0},
+    {"filterconfig", &filter_config, CONF_TYPE_STRING, 0, 0, 0},
+    
 	{"o", "Option -o has been renamed to -vo (video-out), use -vo !\n",
             CONF_TYPE_PRINT, CONF_NOCFG, 0, 0},
 	{"vo", &video_driver, CONF_TYPE_STRING, 0, 0, 0},
Index: main/dec_video.c
===================================================================
RCS file: /cvsroot/mplayer/main/dec_video.c,v
retrieving revision 1.77
diff -u -3 -p -r1.77 dec_video.c
--- main/dec_video.c	21 Dec 2001 17:49:22 -0000	1.77
+++ main/dec_video.c	23 Dec 2001 15:21:50 -0000
@@ -91,6 +91,8 @@ extern int tv_param_on;
 extern tvi_handle_t *tv_handler;
 #endif
 
+#include "loader/virtualdub/mpvd.h"
+
 void AVI_Decode_RLE8(char *image,char *delta,int tdsize,
     unsigned int *map,int imagex,int imagey,unsigned char x11_bytes_pixel);
 
@@ -856,9 +858,12 @@ case 2:
     else
         vo2_draw_frame(video_out,planes[0],sh_video->disp_w,sh_video->disp_w,sh_video->disp_h);
 #else
+    if(haveFilter())
+        runFilter(planes, sh_video, planar, stride);
+    
     if(planar)
         video_out->draw_slice(planes,stride,sh_video->disp_w,sh_video->disp_h,0,0);
-    else
+    else 
         video_out->draw_frame(planes);
 #endif
     t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f;
Index: main/mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.347
diff -u -3 -p -r1.347 mplayer.c
--- main/mplayer.c	23 Dec 2001 11:58:57 -0000	1.347
+++ main/mplayer.c	23 Dec 2001 15:21:50 -0000
@@ -117,6 +117,8 @@ static int max_framesize=0;
 #include "dec_audio.h"
 #include "dec_video.h"
 
+#include "loader/virtualdub/mpvd.h"
+
 #if 0
 extern picture_t *picture;	// exported from libmpeg2/decode.c
 
@@ -1201,8 +1203,10 @@ current_module="init_libvo";
    }
    inited_flags|=INITED_VO;
    mp_msg(MSGT_CPLAYER,MSGL_V,"INFO: Video OUT driver init OK!\n");
-
    fflush(stdout);
+
+   if(haveFilter())
+       initFilters(sh_video->disp_w, sh_video->disp_h, out_fmt);
    
 //================== MAIN: ==========================
 {
Index: main/loader/Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/loader/Makefile,v
retrieving revision 1.5
diff -u -3 -p -r1.5 Makefile
--- main/loader/Makefile	11 Dec 2001 22:58:13 -0000	1.5
+++ main/loader/Makefile	23 Dec 2001 15:21:50 -0000
@@ -19,6 +19,7 @@ CFLAGS=-I. -I.. $(OPTFLAGS) $(EXTRA_INC)
 #CFLAGS=-I. -I.. -O $(WARN_FLAGS) -g #-fno-omit-frame-pointer
 
 all: libloader.a
+	make -C virtualdub
 
 clean:
 	-rm -f *.o libloader.a
Index: main/loader/win32.c
===================================================================
RCS file: /cvsroot/mplayer/main/loader/win32.c,v
retrieving revision 1.42
diff -u -3 -p -r1.42 win32.c
--- main/loader/win32.c	17 Dec 2001 00:57:50 -0000	1.42
+++ main/loader/win32.c	23 Dec 2001 15:21:50 -0000
@@ -522,7 +522,7 @@ static HMODULE WINAPI expGetModuleHandle
     }
     if(!result)
     {
-	if(strcasecmp(name, "kernel32")==0)
+	if(name && strcasecmp(name, "kernel32")==0)
 	    result=MODULE_HANDLE_kernel32;
     }
     dbgprintf("GetModuleHandleA('%s') => 0x%x\n", name, result);
@@ -3300,6 +3300,24 @@ static int expisalnum(int c)
     dbgprintf("isalnum(0x%x='%c' => %d\n", c, c, result);
     return result;
 }
+static int expisspace(int c)
+{
+    int result= (int) isspace(c);
+    dbgprintf("isspace(0x%x='%c' => %d\n", c, c, result);
+    return result;
+}
+static int expisalpha(int c)
+{
+    int result= (int) isalpha(c);
+    dbgprintf("isalpha(0x%x='%c' => %d\n", c, c, result);
+    return result;
+}
+static int expisdigit(int c)
+{
+    int result= (int) isdigit(c);
+    dbgprintf("isdigit(0x%x='%c' => %d\n", c, c, result);
+    return result;
+}
 static void* expmemmove(void* dest, void* src, int n)
 {
     void* result = memmove(dest, src, n);
@@ -3318,6 +3336,12 @@ static void* expmemcpy(void* dest, void*
     dbgprintf("memcpy(0x%x, 0x%x, %d) => %p\n", dest, src, n, result);
     return result;
 }
+static void* expmemset(void* dest, int c, size_t n)
+{
+    void *result = memset(dest, c, n);
+    dbgprintf("memset(0x%x, %d, %d) => %p\n", dest, c, n, result);
+    return result;
+}
 static time_t exptime(time_t* t)
 {
     time_t result = time(t);
@@ -3624,8 +3648,13 @@ struct exports exp_msvcrt[]={
     FF(_strdup,-1)
     FF(_setjmp3,-1)
     FF(isalnum, -1)
+    FF(isspace, -1)
+    FF(isalpha, -1)
+    FF(isdigit, -1)
     FF(memmove, -1)
     FF(memcmp, -1)
+    FF(memset, -1)
+    FF(memcpy, -1)
     FF(time, -1)
     FF(rand, -1)
     FF(srand, -1)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: glue.dll
Type: application/x-msdos-program
Size: 53314 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20011223/a67e3d3e/attachment.dll>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sylia.dll
Type: application/x-msdos-program
Size: 49227 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20011223/a67e3d3e/attachment-0001.dll>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: virtualdub.tar.gz
Type: application/octet-stream
Size: 63510 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20011223/a67e3d3e/attachment.obj>


More information about the MPlayer-dev-eng mailing list