DirectX plugins

Gildas Bazin gbazin at netcourrier.com
Fri May 18 04:21:55 CEST 2001


Hi everybody,

You will find attached to this mail a patch to include DirectX video and
audio support.
When I started the Win32 port, I did not intend to program any directx
plugins because SDL support was already in. Unfortunately I haven't been
able to make the overlay work correctly with SDL under win32, so after long
hours spent on this issue I decided that I would be better off programming
a directx plugin (and this might also help me to solve the SDL problem).

Of course, this plugin is still a work in progress. Some features are not
yet implemented and some bugs are left. But I thinkg it's working nicely
enough to be integrated into the CVS.


Basically the video plugin is a DirectDraw plugin and for now it is only
working if you have a video card with YUV hardware overlay (which I beleive
most people have). And it's not yet optimized (no double buffering, and
we'll also have to had Shane Harper's optimizations for YUV overlay).
The audio plugin is also functionnal but sometime the sound doesn't start
at the same time as the video.
The VLC also crashes after one play when it tries to loop to the beginning
of the video.

Another thing: if you want these plugins to work you also have to include
my former patch (hack) for the video_output initialisation. ( on Windows
you have to create the video window in the same thread you will poll the
event otherwise you won't receive any of them ).

PS: I also included another patch which correct Win32 compilation problems
and which also includes the video_output initialisation patch.
PPS: I will also put a binary version of the VLC compiled with these
patches on the ftp site. (Because I know it's not an easy task to compile
it for Win32 (well it is but you need to have mingw32 install whith the
DirectX and SDL stuff)
PPPS: all the files (except the patch) where in directory named "windx"
under "plugins" on my machine.

I hope you'll enjoy (and give a lot of feedback on what's not working)

-- Attached file included as plaintext by Listar --

Index: Makefile.opts.in
===================================================================
RCS file: /var/cvs/videolan/vlc/Makefile.opts.in,v
retrieving revision 1.9
diff -u -r1.9 Makefile.opts.in
--- Makefile.opts.in	2001/05/06 04:32:02	1.9
+++ Makefile.opts.in	2001/05/18 01:50:33
@@ -73,6 +73,7 @@
 LIB_QT = @LIB_QT@
 LIB_TS = @LIB_TS@
 LIB_SDL = @LIB_SDL@
+LIB_WINDX = @LIB_WINDX@
 LIB_X11 = @LIB_X11@
 LIB_XVIDEO = @LIB_XVIDEO@
 LIB_YUV = @LIB_YUV@
Index: configure.in
===================================================================
RCS file: /var/cvs/videolan/vlc/configure.in,v
retrieving revision 1.99
diff -u -r1.99 configure.in
--- configure.in	2001/05/16 14:51:29	1.99
+++ configure.in	2001/05/18 01:50:46
@@ -401,6 +401,30 @@
     fi
 
 dnl
+dnl  Windows DirectX module
+dnl
+AC_ARG_WITH(windx,
+  [  --with-windx[=name]     Windows DirectX support (default enabled)],
+  [ if test "x$withval" != "xno";
+    then
+      PLUGINS="${PLUGINS} windx";
+      if test "x$withval" != "xyes";
+      then
+        LIB_WINDX="${LIB_WINDX} -L"$withval"/lib -lddraw -ldsound"
+        INCLUDE="${INCLUDE} -I"$withval"/include"
+      else
+        AC_CHECK_HEADERS(directx.h, , [echo "Cannot find DirectX headers !"; exit])
+        LIB_WINDX="${LIB_WINDX} -L/usr/lib -lddraw -ldsound"
+      fi
+    fi ])
+    if test "x$withval" = "x";
+    then
+      AC_CHECK_HEADERS(directx.h,
+      [PLUGINS="${PLUGINS} windx"
+       LIB_WINDX="${LIB_WINDX} -L/usr/lib -lddraw -ldsound"])
+    fi
+
+dnl
 dnl  Glide module
 dnl
 AC_ARG_WITH(glide,
@@ -567,6 +591,7 @@
 AC_SUBST(LIB_QT)
 AC_SUBST(LIB_TS)
 AC_SUBST(LIB_SDL)
+AC_SUBST(LIB_WINDX)
 AC_SUBST(LIB_X11)
 AC_SUBST(LIB_XVIDEO)
 AC_SUBST(LIB_YUV)
Index: plugins/gtk/gtk_menu.c
===================================================================
RCS file: /var/cvs/videolan/vlc/plugins/gtk/gtk_menu.c,v
retrieving revision 1.2
diff -u -r1.2 gtk_menu.c
--- plugins/gtk/gtk_menu.c	2001/05/15 14:49:48	1.2
+++ plugins/gtk/gtk_menu.c	2001/05/18 01:50:50
@@ -60,6 +60,10 @@
 
 #include "main.h"
 
+#ifdef WIN32
+#define snprintf _snprintf
+#endif
+
 /****************************************************************************
  * Gtk*Toggle: callbacks to toggle the value of a checkmenuitem
  ****************************************************************************
Index: plugins/gtk/gtk_playlist.c
===================================================================
RCS file: /var/cvs/videolan/vlc/plugins/gtk/gtk_playlist.c,v
retrieving revision 1.13
diff -u -r1.13 gtk_playlist.c
--- plugins/gtk/gtk_playlist.c	2001/05/15 14:49:48	1.13
+++ plugins/gtk/gtk_playlist.c	2001/05/18 01:50:51
@@ -32,14 +32,18 @@
 
 #include <stdlib.h>
 
-#include <gtk/gtk.h>
-
 #include <string.h>
 
 #include <sys/types.h>          /* for readdir  and stat stuff */
+
+#ifndef WIN32
 #include <dirent.h>
+#endif
+
 #include <sys/stat.h>
 #include <unistd.h>
+
+#include <gtk/gtk.h>    /* to be included after stat.h (win32) */
 
 #include "config.h"
 #include "common.h"
Index: plugins/gtk/gtk_playlist.h
===================================================================
RCS file: /var/cvs/videolan/vlc/plugins/gtk/gtk_playlist.h,v
retrieving revision 1.3
diff -u -r1.3 gtk_playlist.h
--- plugins/gtk/gtk_playlist.h	2001/05/15 14:49:48	1.3
+++ plugins/gtk/gtk_playlist.h	2001/05/18 01:50:52
@@ -39,7 +39,7 @@
 gboolean GtkPlaylistPrev      ( GtkWidget *, GdkEventButton *, gpointer );
 gboolean GtkPlaylistNext      ( GtkWidget *, GdkEventButton *, gpointer );
 gboolean GtkPlaylistDragMotion( GtkWidget *, GdkDragContext *,
-                                gint, gint, uint, gpointer );
+                                gint, gint, guint, gpointer );
 gboolean GtkPlaylistEvent     ( GtkWidget *, GdkEvent *, gpointer );
 void     GtkPlaylistDragData  ( GtkWidget *, GdkDragContext *,
                                 gint, gint, GtkSelectionData *,
Index: plugins/gtk/intf_gtk.c
===================================================================
RCS file: /var/cvs/videolan/vlc/plugins/gtk/intf_gtk.c,v
retrieving revision 1.19
diff -u -r1.19 intf_gtk.c
--- plugins/gtk/intf_gtk.c	2001/05/15 14:49:48	1.19
+++ plugins/gtk/intf_gtk.c	2001/05/18 01:50:53
@@ -35,6 +35,7 @@
 #include <string.h>                                            /* strerror() */
 #include <stdio.h>
 
+#include <glib/glib.h>
 #include <gtk/gtk.h>
 
 #include "config.h"
Index: plugins/imdct/ac3_imdct_3dn.c
===================================================================
RCS file: /var/cvs/videolan/vlc/plugins/imdct/ac3_imdct_3dn.c,v
retrieving revision 1.1
diff -u -r1.1 ac3_imdct_3dn.c
--- plugins/imdct/ac3_imdct_3dn.c	2001/05/16 14:51:29	1.1
+++ plugins/imdct/ac3_imdct_3dn.c	2001/05/18 01:50:55
@@ -41,6 +41,10 @@
 #include "ac3_imdct_common.h"
 #include "ac3_retables.h"
 
+#ifndef M_PI
+#   define M_PI 3.14159265358979323846
+#endif
+
 void _M( fft_64p )  ( complex_t *x );
 void _M( fft_128p ) ( complex_t *a );
 
Index: plugins/imdct/ac3_imdct_sse.c
===================================================================
RCS file: /var/cvs/videolan/vlc/plugins/imdct/ac3_imdct_sse.c,v
retrieving revision 1.2
diff -u -r1.2 ac3_imdct_sse.c
--- plugins/imdct/ac3_imdct_sse.c	2001/05/16 14:51:29	1.2
+++ plugins/imdct/ac3_imdct_sse.c	2001/05/18 01:50:57
@@ -42,6 +42,10 @@
 #include "ac3_imdct_common.h"
 #include "ac3_retables.h"
 
+#ifndef M_PI
+#   define M_PI 3.14159265358979323846
+#endif
+
 void _M( fft_64p )  ( complex_t *x );
 void _M( fft_128p ) ( complex_t *a );
 
Index: plugins/sdl/vout_sdl.c
===================================================================
RCS file: /var/cvs/videolan/vlc/plugins/sdl/vout_sdl.c,v
retrieving revision 1.51
diff -u -r1.51 vout_sdl.c
--- plugins/sdl/vout_sdl.c	2001/05/07 04:42:42	1.51
+++ plugins/sdl/vout_sdl.c	2001/05/18 01:51:01
@@ -256,7 +256,7 @@
 static void vout_End( vout_thread_t *p_vout )
 {
     SDLCloseDisplay( p_vout );
-    SDL_Quit();
+    SDL_QuitSubSystem( SDL_INIT_VIDEO );
 }
 
 /*****************************************************************************
Index: src/interface/intf_msg.c
===================================================================
RCS file: /var/cvs/videolan/vlc/src/interface/intf_msg.c,v
retrieving revision 1.34
diff -u -r1.34 intf_msg.c
--- src/interface/intf_msg.c	2001/05/07 03:14:09	1.34
+++ src/interface/intf_msg.c	2001/05/18 01:51:09
@@ -47,7 +47,9 @@
 #include "main.h"
 
 #ifdef WIN32
+#ifndef snprintf
 #define snprintf _snprintf         /* snprintf not defined in mingw32 (bug?) */
+#endif
 #endif
 
 /*****************************************************************************
Index: src/misc/mtime.c
===================================================================
RCS file: /var/cvs/videolan/vlc/src/misc/mtime.c,v
retrieving revision 1.18
diff -u -r1.18 mtime.c
--- src/misc/mtime.c	2001/05/07 04:42:42	1.18
+++ src/misc/mtime.c	2001/05/18 01:51:09
@@ -86,15 +87,14 @@
     if( !QueryPerformanceFrequency((LARGE_INTEGER *)&freq) )
     {
         /* Milisecond resolution */
-        FILETIME file_time;
-        GetSystemTimeAsFileTime((FILETIME *)&file_time);
-        usec_time *= 1000;
+        usec_time = 1000 * GetTickCount();
     }
     else
     {
         /* Microsecond resolution */
         QueryPerformanceCounter((LARGE_INTEGER *)&usec_time);
-        usec_time /= (freq/1000000);
+        usec_time *= 1000000;
+        usec_time /= freq;
     }
     return( usec_time );
 
@@ -139,7 +139,7 @@
         return;
     }
     /* Sleep only has milisecond resolution */
-    Sleep( (DWORD)(delay/1000) );
+    Sleep( (DWORD)((delay+500)/1000) );
 
 #else
 
@@ -186,9 +186,14 @@
     snooze( delay );
 
 #elif defined( WIN32 )
-    Sleep( delay/1000 );             /* Sleep only has milisecond resolution */
-  /* Maybe we could use the multimedia timer to reach the right resolution,  */
-  /* or the old Winsock select() function ?*/
+    Sleep( (delay+500)/1000 );       /* Sleep only has milisecond resolution */
+  /* There doesn't seem to be any nice solution to extend msleep resolution
+   * under Windows (except maybe on NT and 2000) and select() can't be used
+   * like in unix world. So we'll have to do with 10 miliseconds resolution
+   * (Windows task scheduler's resolution) */
+  /* The audio_output task doesn't seem to like the fact that msleep has no
+   * effect for delays < 1ms so we ensure that the delay will always be at
+   * least 1ms */
 
 #elif defined( HAVE_USLEEP )
     usleep( delay );
Index: src/video_output/video_output.c
===================================================================
RCS file: /var/cvs/videolan/vlc/src/video_output/video_output.c,v
retrieving revision 1.128
diff -u -r1.128 video_output.c
--- src/video_output/video_output.c	2001/05/08 20:38:25	1.128
+++ src/video_output/video_output.c	2001/05/18 01:51:17
@@ -224,50 +224,6 @@
 
     p_vout->i_pictures = 0;
 
-    /* Create and initialize system-dependant method - this function issues its
-     * own error messages */
-    if( p_vout->pf_create( p_vout ) )
-    {
-        module_Unneed( p_vout->p_module );
-        free( p_vout );
-        return( NULL );
-    }
-
-    intf_WarnMsg( 3, "actual configuration: %dx%d, %d/%d bpp (%d Bpl), "
-                  "masks: 0x%x/0x%x/0x%x",
-                  p_vout->i_width, p_vout->i_height, p_vout->i_screen_depth,
-                  p_vout->i_bytes_per_pixel * 8, p_vout->i_bytes_per_line,
-                  p_vout->i_red_mask, p_vout->i_green_mask,
-                  p_vout->i_blue_mask );
-
-    /* Calculate shifts from system-updated masks */
-    MaskToShift( &p_vout->i_red_lshift, &p_vout->i_red_rshift,
-                 p_vout->i_red_mask );
-    MaskToShift( &p_vout->i_green_lshift, &p_vout->i_green_rshift,
-                 p_vout->i_green_mask );
-    MaskToShift( &p_vout->i_blue_lshift, &p_vout->i_blue_rshift,
-                 p_vout->i_blue_mask );
-
-    /* Set some useful colors */
-    p_vout->i_white_pixel = RGB2PIXEL( p_vout, 255, 255, 255 );
-    p_vout->i_black_pixel = RGB2PIXEL( p_vout, 0, 0, 0 );
-    p_vout->i_gray_pixel  = RGB2PIXEL( p_vout, 128, 128, 128 );
-    p_vout->i_blue_pixel  = RGB2PIXEL( p_vout, 0, 0, 50 );
-
-    /* Load fonts - fonts must be initialized after the system method since
-     * they may be dependant on screen depth and other thread properties */
-    p_vout->p_default_font = vout_LoadFont( VOUT_DEFAULT_FONT );
-    if( p_vout->p_default_font == NULL )
-    {
-        intf_ErrMsg( "vout error: could not load default font" );
-    }
-
-    p_vout->p_large_font = vout_LoadFont( VOUT_LARGE_FONT );
-    if( p_vout->p_large_font == NULL )
-    {
-        intf_ErrMsg( "vout error: could not load large font" );
-    }
-
     /* Create thread and set locks */
     vlc_mutex_init( &p_vout->picture_lock );
     vlc_mutex_init( &p_vout->subpicture_lock );
@@ -946,6 +902,50 @@
 #ifdef STATS
     p_vout->c_loops = 0;
 #endif
+
+    /* Create and initialize system-dependant method - this function issues its
+     * own error messages */
+    if( p_vout->pf_create( p_vout ) )
+    {
+        module_Unneed( p_vout->p_module );
+        free( p_vout );
+        return( NULL );
+    }
+
+    intf_WarnMsg( 3, "actual configuration: %dx%d, %d/%d bpp (%d Bpl), "
+                  "masks: 0x%x/0x%x/0x%x",
+                  p_vout->i_width, p_vout->i_height, p_vout->i_screen_depth,
+                  p_vout->i_bytes_per_pixel * 8, p_vout->i_bytes_per_line,
+                  p_vout->i_red_mask, p_vout->i_green_mask,
+                  p_vout->i_blue_mask );
+
+    /* Calculate shifts from system-updated masks */
+    MaskToShift( &p_vout->i_red_lshift, &p_vout->i_red_rshift,
+                 p_vout->i_red_mask );
+    MaskToShift( &p_vout->i_green_lshift, &p_vout->i_green_rshift,
+                 p_vout->i_green_mask );
+    MaskToShift( &p_vout->i_blue_lshift, &p_vout->i_blue_rshift,
+                 p_vout->i_blue_mask );
+
+    /* Set some useful colors */
+    p_vout->i_white_pixel = RGB2PIXEL( p_vout, 255, 255, 255 );
+    p_vout->i_black_pixel = RGB2PIXEL( p_vout, 0, 0, 0 );
+    p_vout->i_gray_pixel  = RGB2PIXEL( p_vout, 128, 128, 128 );
+    p_vout->i_blue_pixel  = RGB2PIXEL( p_vout, 0, 0, 50 );
+
+    /* Load fonts - fonts must be initialized after the system method since
+     * they may be dependant on screen depth and other thread properties */
+    p_vout->p_default_font = vout_LoadFont( VOUT_DEFAULT_FONT );
+    if( p_vout->p_default_font == NULL )
+    {
+        intf_ErrMsg( "vout error: could not load default font" );
+    }
+
+    p_vout->p_large_font = vout_LoadFont( VOUT_LARGE_FONT );
+    if( p_vout->p_large_font == NULL )
+    {
+        intf_ErrMsg( "vout error: could not load large font" );
+    }
 
    /* Initialize output method - this function issues its own error messages */
     if( p_vout->pf_init( p_vout ) )









-- Binary/unsupported file stripped by Listar --
-- Type: text/x-c


-- Binary/unsupported file stripped by Listar --
-- Type: text/x-makefile


-- Binary/unsupported file stripped by Listar --
-- Type: text/x-c


-- Binary/unsupported file stripped by Listar --
-- Type: text/x-c





More information about the vlc-devel mailing list