Commit 70630f32 authored by Gildas Bazin's avatar Gildas Bazin

* plugins/directx/vout_directx.*: the directx vout plugin now uses the
IID_IDirectDrawSurface2 interface, this shouldn't break anything and we should now
support WinNT4+DirectX3.
Added support for YUY2 overlays because a few graphics cards only support this.
Some code cleanup too.
* plugins/directx/vout_events.c: small bugfix.
parent 74b9c004
......@@ -2,7 +2,7 @@
* vout_directx.c: Windows DirectX video output display method
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: vout_directx.c,v 1.36 2002/05/30 08:17:04 gbazin Exp $
* $Id: vout_directx.c,v 1.36.2.1 2002/07/29 16:22:14 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -58,7 +58,7 @@
*****************************************************************************/
#include <initguid.h>
DEFINE_GUID( IID_IDirectDraw2, 0xB3A6F3E0,0x2B43,0x11CF,0xA2,0xDE,0x00,0xAA,0x00,0xB9,0x33,0x56 );
DEFINE_GUID( IID_IDirectDrawSurface3, 0xDA044E00,0x69B2,0x11D0,0xA1,0xD5,0x00,0xAA,0x00,0xB8,0xDF,0xBB );
DEFINE_GUID( IID_IDirectDrawSurface2, 0x57805885,0x6eec,0x11cf,0x94,0x41,0xa8,0x23,0x03,0xc1,0x0e,0x27 );
/*****************************************************************************
* Local prototypes.
......@@ -80,9 +80,9 @@ static void DirectXCloseDDraw ( vout_thread_t *p_vout );
static int DirectXCreateDisplay ( vout_thread_t *p_vout );
static void DirectXCloseDisplay ( vout_thread_t *p_vout );
static int DirectXCreateSurface ( vout_thread_t *p_vout,
LPDIRECTDRAWSURFACE3 *, int, int, int );
LPDIRECTDRAWSURFACE2 *, int, int, int );
static void DirectXCloseSurface ( vout_thread_t *p_vout,
LPDIRECTDRAWSURFACE3 );
LPDIRECTDRAWSURFACE2 );
static int DirectXCreateClipper ( vout_thread_t *p_vout );
static void DirectXGetDDrawCaps ( vout_thread_t *p_vout );
static int DirectXGetSurfaceDesc ( picture_t *p_pic );
......@@ -114,7 +114,7 @@ static int vout_Create( vout_thread_t *p_vout )
if( p_vout->p_sys == NULL )
{
intf_ErrMsg( "vout error: can't create p_sys (%s)", strerror(ENOMEM) );
return( 1 );
return 1;
}
/* Initialisations */
......@@ -158,8 +158,7 @@ static int vout_Create( vout_thread_t *p_vout )
{
intf_ErrMsg( "vout error: can't create DirectXEventThread" );
intf_ErrMsg("vout error: %s", strerror(ENOMEM));
free( p_vout->p_sys );
return( 1 );
goto error;
}
/* We need to wait for the actual creation of the thread and window */
......@@ -173,8 +172,7 @@ static int vout_Create( vout_thread_t *p_vout )
if( p_vout->p_sys->i_event_thread_status != THREAD_READY )
{
intf_ErrMsg( "vout error: DirectXEventThread failed" );
free( p_vout->p_sys );
return( 1 );
goto error;
}
intf_WarnMsg( 3, "vout: vout_Create DirectXEventThread running" );
......@@ -183,20 +181,21 @@ static int vout_Create( vout_thread_t *p_vout )
if( DirectXInitDDraw( p_vout ) )
{
intf_ErrMsg( "vout error: can't initialise DirectDraw" );
vout_Destroy( p_vout );
return ( 1 );
goto error;
}
/* Create the directx display */
if( DirectXCreateDisplay( p_vout ) )
{
intf_ErrMsg( "vout error: can't initialise DirectDraw" );
DirectXCloseDDraw( p_vout );
vout_Destroy( p_vout );
return ( 1 );
goto error;
}
return( 0 );
return 0;
error:
vout_Destroy( p_vout );
return 1;
}
/*****************************************************************************
......@@ -207,6 +206,7 @@ static int vout_Create( vout_thread_t *p_vout )
*****************************************************************************/
static int vout_Init( vout_thread_t *p_vout )
{
int i_chroma_backup;
/* Initialize the output structure.
* Since DirectDraw can do rescaling for us, stick to the default
......@@ -220,17 +220,62 @@ static int vout_Init( vout_thread_t *p_vout )
* video decoder to decode directly into direct buffers as they are
* created into video memory and video memory is _really_ slow */
/* Choose the chroma we will try first. */
switch( p_vout->render.i_chroma )
{
case FOURCC_YUY2:
case FOURCC_YUNV:
p_vout->output.i_chroma = FOURCC_YUY2;
break;
case FOURCC_UYVY:
case FOURCC_UYNV:
case FOURCC_Y422:
p_vout->output.i_chroma = FOURCC_UYVY;
break;
case FOURCC_YVYU:
p_vout->output.i_chroma = FOURCC_YVYU;
break;
default:
p_vout->output.i_chroma = FOURCC_YV12;
break;
}
NewPictureVec( p_vout, p_vout->p_picture, MAX_DIRECTBUFFERS );
i_chroma_backup = p_vout->output.i_chroma;
if( !I_OUTPUTPICTURES )
{
/* hmmm, it didn't work! Let's try commonly supported chromas */
p_vout->output.i_chroma = FOURCC_YV12;
NewPictureVec( p_vout, p_vout->p_picture, MAX_DIRECTBUFFERS );
if( !I_OUTPUTPICTURES )
{
/* hmmm, it didn't work! Let's try commonly supported chromas */
p_vout->output.i_chroma = FOURCC_YUY2;
NewPictureVec( p_vout, p_vout->p_picture, MAX_DIRECTBUFFERS );
}
}
if( !I_OUTPUTPICTURES )
{
/* If it still didn't work then don't try to use an overlay */
p_vout->output.i_chroma = i_chroma_backup;
p_vout->p_sys->b_using_overlay = 0;
NewPictureVec( p_vout, p_vout->p_picture, MAX_DIRECTBUFFERS );
}
/* Change the window title bar text */
if( p_vout->p_sys->b_using_overlay )
SetWindowText( p_vout->p_sys->hwnd,
"VLC DirectX (using hardware overlay)" );
VOUT_TITLE " (hardware YUV overlay DirectX output)" );
else if( p_vout->p_sys->b_hw_yuv )
SetWindowText( p_vout->p_sys->hwnd,
"VLC DirectX (using hardware YUV->RGB conversion)" );
VOUT_TITLE " (hardware YUV DirectX output)" );
else SetWindowText( p_vout->p_sys->hwnd,
VOUT_TITLE " (software RGB DirectX output)" );
return( 0 );
return 0;
}
/*****************************************************************************
......@@ -253,6 +298,7 @@ static void vout_End( vout_thread_t *p_vout )
static void vout_Destroy( vout_thread_t *p_vout )
{
intf_WarnMsg( 3, "vout: vout_Destroy" );
DirectXCloseDisplay( p_vout );
DirectXCloseDDraw( p_vout );
......@@ -260,13 +306,18 @@ static void vout_Destroy( vout_thread_t *p_vout )
vlc_mutex_lock( &p_vout->p_sys->event_thread_lock );
p_vout->p_sys->b_event_thread_die = 1;
/* we need to be sure DirectXEventThread won't stay stuck in GetMessage,
* so we send a fake message */
if( p_vout->p_sys->i_event_thread_status == THREAD_READY )
{
/* we need to be sure DirectXEventThread won't stay stuck in
* GetMessage, so we send a fake message */
if( p_vout->p_sys->hwnd )
PostMessage( p_vout->p_sys->hwnd, WM_NULL, 0, 0);
vlc_mutex_unlock( &p_vout->p_sys->event_thread_lock );
vlc_thread_join( p_vout->p_sys->event_thread_id );
}
else
vlc_mutex_unlock( &p_vout->p_sys->event_thread_lock );
if( p_vout->p_sys != NULL )
{
......@@ -369,7 +420,7 @@ static int vout_Manage( vout_thread_t *p_vout )
if( p_vout->p_sys->b_event_thread_die )
return 1; /* exit */
return( 0 );
return 0;
}
/*****************************************************************************
......@@ -406,7 +457,7 @@ static void vout_Display( vout_thread_t *p_vout, picture_t *p_pic )
ddbltfx.dwDDFX = DDBLTFX_NOTEARING;
/* Blit video surface to display */
dxresult = IDirectDrawSurface3_Blt(p_vout->p_sys->p_display,
dxresult = IDirectDrawSurface2_Blt(p_vout->p_sys->p_display,
&p_vout->p_sys->rect_dest_clipped,
p_pic->p_sys->p_surface,
&p_vout->p_sys->rect_src_clipped,
......@@ -415,10 +466,10 @@ static void vout_Display( vout_thread_t *p_vout, picture_t *p_pic )
{
/* Our surface can be lost so be sure
* to check this and restore it if needed */
IDirectDrawSurface3_Restore( p_vout->p_sys->p_display );
IDirectDrawSurface2_Restore( p_vout->p_sys->p_display );
/* Now that the surface has been restored try to display again */
dxresult = IDirectDrawSurface3_Blt(p_vout->p_sys->p_display,
dxresult = IDirectDrawSurface2_Blt(p_vout->p_sys->p_display,
&p_vout->p_sys->rect_dest_clipped,
p_pic->p_sys->p_surface,
&p_vout->p_sys->rect_src_clipped,
......@@ -439,17 +490,17 @@ static void vout_Display( vout_thread_t *p_vout, picture_t *p_pic )
if( p_pic->p_sys->p_front_surface == p_pic->p_sys->p_surface )
return;
dxresult = IDirectDrawSurface3_Flip( p_pic->p_sys->p_front_surface,
dxresult = IDirectDrawSurface2_Flip( p_pic->p_sys->p_front_surface,
NULL, DDFLIP_WAIT );
if ( dxresult == DDERR_SURFACELOST )
{
/* Our surface can be lost so be sure
* to check this and restore it if needed */
IDirectDrawSurface3_Restore( p_vout->p_sys->p_display );
IDirectDrawSurface3_Restore( p_pic->p_sys->p_front_surface );
IDirectDrawSurface2_Restore( p_vout->p_sys->p_display );
IDirectDrawSurface2_Restore( p_pic->p_sys->p_front_surface );
/* Now that the surface has been restored try to display again */
dxresult = IDirectDrawSurface3_Flip( p_pic->p_sys->p_front_surface,
dxresult = IDirectDrawSurface2_Flip( p_pic->p_sys->p_front_surface,
NULL, DDFLIP_WAIT );
DirectXUpdateOverlay( p_vout );
}
......@@ -499,7 +550,7 @@ static int DirectXInitDDraw( vout_thread_t *p_vout )
if( p_vout->p_sys->hddraw_dll == NULL )
{
intf_WarnMsg( 3, "vout: DirectXInitDDraw failed loading ddraw.dll" );
return( 1 );
goto error;
}
OurDirectDrawCreate =
......@@ -507,9 +558,7 @@ static int DirectXInitDDraw( vout_thread_t *p_vout )
if ( OurDirectDrawCreate == NULL )
{
intf_ErrMsg( "vout error: DirectXInitDDraw failed GetProcAddress" );
FreeLibrary( p_vout->p_sys->hddraw_dll );
p_vout->p_sys->hddraw_dll = NULL;
return( 1 );
goto error;
}
/* Initialize DirectDraw now */
......@@ -517,49 +566,44 @@ static int DirectXInitDDraw( vout_thread_t *p_vout )
if( dxresult != DD_OK )
{
intf_ErrMsg( "vout error: DirectXInitDDraw can't initialize DDraw" );
p_vout->p_sys->p_ddobject = NULL;
FreeLibrary( p_vout->p_sys->hddraw_dll );
p_vout->p_sys->hddraw_dll = NULL;
return( 1 );
}
/* Set DirectDraw Cooperative level, ie what control we want over Windows
* display */
dxresult = IDirectDraw_SetCooperativeLevel( p_ddobject,
p_vout->p_sys->hwnd, DDSCL_NORMAL );
if( dxresult != DD_OK )
{
intf_ErrMsg( "vout error: can't set direct draw cooperative level." );
IDirectDraw_Release( p_ddobject );
p_vout->p_sys->p_ddobject = NULL;
FreeLibrary( p_vout->p_sys->hddraw_dll );
p_vout->p_sys->hddraw_dll = NULL;
return( 1 );
goto error;
}
/* Get the IDirectDraw2 interface */
dxresult = IDirectDraw_QueryInterface( p_ddobject, &IID_IDirectDraw2,
(LPVOID *)&p_vout->p_sys->p_ddobject );
/* Release the unused interface */
IDirectDraw_Release( p_ddobject );
if( dxresult != DD_OK )
{
intf_ErrMsg( "vout error: can't get IDirectDraw2 interface." );
IDirectDraw_Release( p_ddobject );
p_vout->p_sys->p_ddobject = NULL;
FreeLibrary( p_vout->p_sys->hddraw_dll );
p_vout->p_sys->hddraw_dll = NULL;
return( 1 );
goto error;
}
else
/* Set DirectDraw Cooperative level, ie what control we want over Windows
* display */
dxresult = IDirectDraw2_SetCooperativeLevel( p_vout->p_sys->p_ddobject,
p_vout->p_sys->hwnd, DDSCL_NORMAL );
if( dxresult != DD_OK )
{
/* Release the unused interface */
IDirectDraw_Release( p_ddobject );
intf_ErrMsg( "vout error: can't set direct draw cooperative level." );
goto error;
}
/* Probe the capabilities of the hardware */
DirectXGetDDrawCaps( p_vout );
intf_WarnMsg( 3, "vout: End DirectXInitDDraw" );
return( 0 );
return 0;
error:
if( p_vout->p_sys->p_ddobject )
IDirectDraw2_Release( p_vout->p_sys->p_ddobject );
if( p_vout->p_sys->hddraw_dll )
FreeLibrary( p_vout->p_sys->hddraw_dll );
p_vout->p_sys->hddraw_dll = NULL;
p_vout->p_sys->p_ddobject = NULL;
return 1;
}
/*****************************************************************************
......@@ -590,27 +634,20 @@ static int DirectXCreateDisplay( vout_thread_t *p_vout )
if( dxresult != DD_OK )
{
intf_ErrMsg( "vout error: can't get direct draw primary surface." );
p_vout->p_sys->p_display = NULL;
return( 1 );
return 1;
}
dxresult = IDirectDrawSurface_QueryInterface( p_display,
&IID_IDirectDrawSurface3,
&IID_IDirectDrawSurface2,
(LPVOID *)&p_vout->p_sys->p_display );
if ( dxresult != DD_OK )
{
intf_ErrMsg( "vout error: can't get IDirectDrawSurface3 interface." );
IDirectDrawSurface_Release( p_display );
p_vout->p_sys->p_display = NULL;
return( 1 );
}
else
{
/* Release the old interface */
IDirectDrawSurface_Release( p_display );
if ( dxresult != DD_OK )
{
intf_ErrMsg( "vout error: can't get IDirectDrawSurface2 interface." );
return 1;
}
/* The clipper will be used only in non-overlay mode */
DirectXCreateClipper( p_vout );
......@@ -619,7 +656,7 @@ static int DirectXCreateDisplay( vout_thread_t *p_vout )
/* compute the colorkey pixel value from the RGB value we've got */
memset( &pixel_format, 0, sizeof( DDPIXELFORMAT ));
pixel_format.dwSize = sizeof( DDPIXELFORMAT );
dxresult = IDirectDrawSurface3_GetPixelFormat( p_vout->p_sys->p_display,
dxresult = IDirectDrawSurface2_GetPixelFormat( p_vout->p_sys->p_display,
&pixel_format );
if( dxresult != DD_OK )
intf_WarnMsg( 3, "vout: DirectXUpdateOverlay GetPixelFormat failed" );
......@@ -628,7 +665,7 @@ static int DirectXCreateDisplay( vout_thread_t *p_vout )
& pixel_format.dwRBitMask);
#endif
return( 0 );
return 0;
}
......@@ -652,8 +689,7 @@ static int DirectXCreateClipper( vout_thread_t *p_vout )
if( dxresult != DD_OK )
{
intf_WarnMsg( 3, "vout: DirectXCreateClipper can't create clipper." );
p_vout->p_sys->p_clipper = NULL;
return( 1 );
goto error;
}
/* associate the clipper to the window */
......@@ -663,9 +699,7 @@ static int DirectXCreateClipper( vout_thread_t *p_vout )
{
intf_WarnMsg( 3,
"vout: DirectXCreateClipper can't attach clipper to window." );
IDirectDrawSurface_Release( p_vout->p_sys->p_clipper );
p_vout->p_sys->p_clipper = NULL;
return( 1 );
goto error;
}
/* associate the clipper with the surface */
......@@ -675,12 +709,16 @@ static int DirectXCreateClipper( vout_thread_t *p_vout )
{
intf_WarnMsg( 3,
"vout: DirectXCreateClipper can't attach clipper to surface." );
IDirectDrawSurface_Release( p_vout->p_sys->p_clipper );
p_vout->p_sys->p_clipper = NULL;
return( 1 );
goto error;
}
return( 0 );
return 0;
error:
if( p_vout->p_sys->p_clipper )
IDirectDrawClipper_Release( p_vout->p_sys->p_clipper );
p_vout->p_sys->p_clipper = NULL;
return 1;
}
/*****************************************************************************
......@@ -694,7 +732,7 @@ static int DirectXCreateClipper( vout_thread_t *p_vout )
* need to do any blitting to the main display...)
*****************************************************************************/
static int DirectXCreateSurface( vout_thread_t *p_vout,
LPDIRECTDRAWSURFACE3 *pp_surface_final,
LPDIRECTDRAWSURFACE2 *pp_surface_final,
int i_chroma, int b_overlay,
int i_backbuffers )
{
......@@ -781,12 +819,12 @@ static int DirectXCreateSurface( vout_thread_t *p_vout,
/* Now that the surface is created, try to get a newer DirectX interface */
dxresult = IDirectDrawSurface_QueryInterface( p_surface,
&IID_IDirectDrawSurface3,
&IID_IDirectDrawSurface2,
(LPVOID *)pp_surface_final );
IDirectDrawSurface_Release( p_surface ); /* Release the old interface */
if ( dxresult != DD_OK )
{
intf_ErrMsg( "vout error: can't get IDirectDrawSurface3 interface." );
intf_ErrMsg( "vout error: can't get IDirectDrawSurface2 interface." );
*pp_surface_final = NULL;
return 0;
}
......@@ -824,7 +862,7 @@ void DirectXUpdateOverlay( vout_thread_t *p_vout )
if( !p_vout->p_sys->b_caps_overlay_clipping )
dwFlags |= DDOVER_KEYDESTOVERRIDE;
dxresult = IDirectDrawSurface3_UpdateOverlay(
dxresult = IDirectDrawSurface2_UpdateOverlay(
p_vout->p_sys->p_current_surface,
&p_vout->p_sys->rect_src_clipped,
p_vout->p_sys->p_display,
......@@ -872,14 +910,14 @@ static void DirectXCloseDisplay( vout_thread_t *p_vout )
if( p_vout->p_sys->p_clipper != NULL )
{
intf_WarnMsg( 3, "vout: DirectXCloseDisplay clipper" );
IDirectDraw2_Release( p_vout->p_sys->p_clipper );
IDirectDrawClipper_Release( p_vout->p_sys->p_clipper );
p_vout->p_sys->p_clipper = NULL;
}
if( p_vout->p_sys->p_display != NULL )
{
intf_WarnMsg( 3, "vout: DirectXCloseDisplay display" );
IDirectDraw2_Release( p_vout->p_sys->p_display );
IDirectDrawSurface2_Release( p_vout->p_sys->p_display );
p_vout->p_sys->p_display = NULL;
}
}
......@@ -890,12 +928,12 @@ static void DirectXCloseDisplay( vout_thread_t *p_vout )
* This function returns all resources allocated for the surface.
*****************************************************************************/
static void DirectXCloseSurface( vout_thread_t *p_vout,
LPDIRECTDRAWSURFACE3 p_surface )
LPDIRECTDRAWSURFACE2 p_surface )
{
intf_WarnMsg( 3, "vout: DirectXCloseSurface" );
if( p_surface != NULL )
{
IDirectDraw2_Release( p_surface );
IDirectDrawSurface2_Release( p_surface );
}
}
......@@ -909,32 +947,12 @@ static int NewPictureVec( vout_thread_t *p_vout, picture_t *p_pic,
{
int i;
boolean_t b_result_ok;
LPDIRECTDRAWSURFACE3 p_surface;
LPDIRECTDRAWSURFACE2 p_surface;
intf_WarnMsg( 3, "vout: NewPictureVec" );
I_OUTPUTPICTURES = 0;
/* Choose the chroma we will try first. */
switch( p_vout->render.i_chroma )
{
case FOURCC_YUY2:
case FOURCC_YUNV:
p_vout->output.i_chroma = FOURCC_YUY2;
break;
case FOURCC_UYVY:
case FOURCC_UYNV:
case FOURCC_Y422:
p_vout->output.i_chroma = FOURCC_UYVY;
break;
case FOURCC_YVYU:
p_vout->output.i_chroma = FOURCC_YVYU;
break;
default:
p_vout->output.i_chroma = FOURCC_YV12;
break;
}
/* First we try to use an YUV overlay surface.
* The overlay surface that we create won't be used to decode directly
* into it because accessing video memory directly is way to slow (remember
......@@ -980,7 +998,7 @@ static int NewPictureVec( vout_thread_t *p_vout, picture_t *p_pic,
/* Get the back buffer */
memset( &dds_caps, 0, sizeof( DDSCAPS ) );
dds_caps.dwCaps = DDSCAPS_BACKBUFFER;
if( DD_OK != IDirectDrawSurface3_GetAttachedSurface(
if( DD_OK != IDirectDrawSurface2_GetAttachedSurface(
p_surface, &dds_caps,
&p_pic[0].p_sys->p_surface ) )
{
......@@ -999,22 +1017,18 @@ static int NewPictureVec( vout_thread_t *p_vout, picture_t *p_pic,
UpdatePictureStruct( p_vout, &front_pic,
p_vout->output.i_chroma ) )
{
int j;
for( j = 0; j < front_pic.i_planes; j++ )
memset( front_pic.p[j].p_pixels, 127,
front_pic.p[j].i_lines * front_pic.p[j].i_pitch
* front_pic.p[j].i_pixel_bytes );
int i,j;
for( i = 0; i < front_pic.i_planes; i++ )
for( j = 0; j < front_pic.p[i].i_lines; j++)
memset( front_pic.p[i].p_pixels + j *
front_pic.p[i].i_pitch, 127,
front_pic.p[i].i_visible_bytes );
}
DirectXUpdateOverlay( p_vout );
I_OUTPUTPICTURES = 1;
intf_WarnMsg( 3,"vout: DirectX YUV overlay created successfully" );
}
else
{
intf_WarnMsg( 3, "vout: can't create an YUV overlay surface." );
p_vout->p_sys->b_using_overlay = 0;
}
}
/* As we can't have an overlay, we'll try to create a plain offscreen
......@@ -1038,7 +1052,7 @@ static int NewPictureVec( vout_thread_t *p_vout, picture_t *p_pic,
DDPIXELFORMAT ddpfPixelFormat;
ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
IDirectDrawSurface3_GetPixelFormat( p_vout->p_sys->p_display,
IDirectDrawSurface2_GetPixelFormat( p_vout->p_sys->p_display,
&ddpfPixelFormat );
if( ddpfPixelFormat.dwFlags & DDPF_RGB )
......@@ -1057,7 +1071,7 @@ static int NewPictureVec( vout_thread_t *p_vout, picture_t *p_pic,
p_vout->output.i_chroma = FOURCC_RV32; break;
default:
intf_ErrMsg( "vout error: unknown screen depth" );
return( 0 );
return 0;
}
p_vout->output.i_rmask = ddpfPixelFormat.dwRBitMask;
p_vout->output.i_gmask = ddpfPixelFormat.dwGBitMask;
......@@ -1089,8 +1103,6 @@ static int NewPictureVec( vout_thread_t *p_vout, picture_t *p_pic,
intf_WarnMsg( 3, "vout: DirectX plain surface created "
"successfully" );
}
else
intf_ErrMsg( "vout error: DirectX can't create plain surface." );
}
......@@ -1184,8 +1196,10 @@ static int UpdatePictureStruct( vout_thread_t *p_vout, picture_t *p_pic,
p_pic->p->i_pixel_bytes = 4;
break;
default:
return( -1 );
return -1;
}
p_pic->p->i_visible_bytes = p_vout->output.i_width *
p_pic->p->i_pixel_bytes;
break;
case FOURCC_YV12:
......@@ -1194,6 +1208,8 @@ static int UpdatePictureStruct( vout_thread_t *p_vout, picture_t *p_pic,
p_pic->p[Y_PLANE].i_lines = p_vout->output.i_height;
p_pic->p[Y_PLANE].i_pitch = p_pic->p_sys->ddsd.lPitch;
p_pic->p[Y_PLANE].i_pixel_bytes = 1;
p_pic->p[Y_PLANE].i_visible_bytes = p_vout->output.i_width *
p_pic->p[Y_PLANE].i_pixel_bytes;
p_pic->p[Y_PLANE].b_margin = 0;
p_pic->V_PIXELS = p_pic->Y_PIXELS
......@@ -1201,6 +1217,8 @@ static int UpdatePictureStruct( vout_thread_t *p_vout, picture_t *p_pic,
p_pic->p[V_PLANE].i_lines = p_vout->output.i_height / 2;
p_pic->p[V_PLANE].i_pitch = p_pic->p[Y_PLANE].i_pitch / 2;
p_pic->p[V_PLANE].i_pixel_bytes = 1;
p_pic->p[V_PLANE].i_visible_bytes = p_vout->output.i_width *
p_pic->p[V_PLANE].i_pixel_bytes;
p_pic->p[V_PLANE].b_margin = 0;
p_pic->U_PIXELS = p_pic->V_PIXELS
......@@ -1208,6 +1226,8 @@ static int UpdatePictureStruct( vout_thread_t *p_vout, picture_t *p_pic,
p_pic->p[U_PLANE].i_lines = p_vout->output.i_height / 2;
p_pic->p[U_PLANE].i_pitch = p_pic->p[Y_PLANE].i_pitch / 2;
p_pic->p[U_PLANE].i_pixel_bytes = 1;
p_pic->p[U_PLANE].i_visible_bytes = p_vout->output.i_width *
p_pic->p[U_PLANE].i_pixel_bytes;
p_pic->p[U_PLANE].b_margin = 0;
p_pic->i_planes = 3;
......@@ -1219,6 +1239,8 @@ static int UpdatePictureStruct( vout_thread_t *p_vout, picture_t *p_pic,
p_pic->p[Y_PLANE].i_lines = p_vout->output.i_height;
p_pic->p[Y_PLANE].i_pitch = p_pic->p_sys->ddsd.lPitch;
p_pic->p[Y_PLANE].i_pixel_bytes = 1;
p_pic->p[Y_PLANE].i_visible_bytes = p_vout->output.i_width *
p_pic->p[Y_PLANE].i_pixel_bytes;
p_pic->p[Y_PLANE].b_margin = 0;
p_pic->U_PIXELS = p_pic->Y_PIXELS
......@@ -1226,6 +1248,8 @@ static int UpdatePictureStruct( vout_thread_t *p_vout, picture_t *p_pic,
p_pic->p[U_PLANE].i_lines = p_vout->output.i_height / 2;
p_pic->p[U_PLANE].i_pitch = p_pic->p[Y_PLANE].i_pitch / 2;
p_pic->p[U_PLANE].i_pixel_bytes = 1;
p_pic->p[U_PLANE].i_visible_bytes = p_vout->output.i_width *
p_pic->p[U_PLANE].i_pixel_bytes;
p_pic->p[U_PLANE].b_margin = 0;
p_pic->V_PIXELS = p_pic->U_PIXELS
......@@ -1233,11 +1257,26 @@ static int UpdatePictureStruct( vout_thread_t *p_vout, picture_t *p_pic,
p_pic->p[V_PLANE].i_lines = p_vout->output.i_height / 2;
p_pic->p[V_PLANE].i_pitch = p_pic->p[Y_PLANE].i_pitch / 2;
p_pic->p[V_PLANE].i_pixel_bytes = 1;
p_pic->p[V_PLANE].i_visible_bytes = p_vout->output.i_width *
p_pic->p[V_PLANE].i_pixel_bytes;
p_pic->p[V_PLANE].b_margin = 0;
p_pic->i_planes = 3;
break;
case FOURCC_YUY2:
p_pic->p->p_pixels = p_pic->p_sys->ddsd.lpSurface;
p_pic->p->i_lines = p_vout->output.i_height;
p_pic->p->i_pitch = p_pic->p_sys->ddsd.lPitch;
p_pic->p->i_pixel_bytes = 2;
p_pic->p->i_visible_bytes = p_vout->output.i_width *
p_pic->p->i_pixel_bytes;
p_pic->p->b_margin = 1;
p_pic->i_planes = 1;
break;
default:
/* Not supported */
return 0;
......@@ -1314,7 +1353,7 @@ static int DirectXGetSurfaceDesc( picture_t *p_pic )
/* Lock the surface to get a valid pointer to the picture buffer */
memset( &p_pic->p_sys->ddsd, 0, sizeof( DDSURFACEDESC ));
p_pic->p_sys->ddsd.dwSize = sizeof(DDSURFACEDESC);
dxresult = IDirectDrawSurface3_Lock( p_pic->p_sys->p_surface,
dxresult = IDirectDrawSurface2_Lock( p_pic->p_sys->p_surface,
NULL, &p_pic->p_sys->ddsd,
DDLOCK_NOSYSLOCK | DDLOCK_WAIT,
NULL );
......@@ -1322,8 +1361,8 @@ static int DirectXGetSurfaceDesc( picture_t *p_pic )
{
/* Your surface can be lost so be sure
* to check this and restore it if needed */
dxresult = IDirectDrawSurface3_Restore( p_pic->p_sys->p_surface );
dxresult = IDirectDrawSurface3_Lock( p_pic->p_sys->p_surface, NULL,
dxresult = IDirectDrawSurface2_Restore( p_pic->p_sys->p_surface );
dxresult = IDirectDrawSurface2_Lock( p_pic->p_sys->p_surface, NULL,
&p_pic->p_sys->ddsd,
DDLOCK_NOSYSLOCK | DDLOCK_WAIT,
NULL);
......@@ -1335,7 +1374,7 @@ static int DirectXGetSurfaceDesc( picture_t *p_pic )
}
/* Unlock the Surface */
dxresult = IDirectDrawSurface3_Unlock( p_pic->p_sys->p_surface, NULL );
dxresult = IDirectDrawSurface2_Unlock( p_pic->p_sys->p_surface, NULL );
return 1;
}
......@@ -2,7 +2,7 @@
* vout_directx.h: Windows DirectX video output header file
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: vout_directx.h,v 1.6 2002/05/18 13:30:28 gbazin Exp $
* $Id: vout_directx.h,v 1.6.2.1 2002/07/29 16:22:14 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -31,8 +31,8 @@ typedef struct vout_sys_s
{
LPDIRECTDRAW2 p_ddobject; /* DirectDraw object */
LPDIRECTDRAWSURFACE3 p_display; /* Display device */
LPDIRECTDRAWSURFACE3 p_current_surface; /* surface currently displayed */
LPDIRECTDRAWSURFACE2 p_display; /* Display device */
LPDIRECTDRAWSURFACE2 p_current_surface; /* surface currently displayed */
LPDIRECTDRAWCLIPPER p_clipper; /* clipper used for blitting */
HINSTANCE hddraw_dll; /* handle of the opened ddraw dll */
HBRUSH hbrush; /* window backgound brush (color) */
......@@ -87,9 +87,9 @@ typedef struct vout_sys_s
*****************************************************************************/
typedef struct picture_sys_s
{
LPDIRECTDRAWSURFACE3 p_surface;
LPDIRECTDRAWSURFACE2 p_surface;
DDSURFACEDESC ddsd;
LPDIRECTDRAWSURFACE3 p_front_surface;
LPDIRECTDRAWSURFACE2 p_front_surface;
} picture_sys_t;
......
......@@ -2,7 +2,7 @@
* vout_events.c: Windows DirectX video output events handler
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: vout_events.c,v 1.18.2.2 2002/06/03 17:19:54 sam Exp $
* $Id: vout_events.c,v 1.18.2.3 2002/07/29 16:22:14 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -285,7 +285,7 @@ static int DirectXCreateWindow( vout_thread_t *p_vout )
p_vout->p_sys->rect_display.bottom,
p_vout->p_sys->i_display_depth );
ReleaseDC( p_vout->p_sys->hwnd, hdc );
ReleaseDC( NULL, hdc );
/* Get the Icon from the main app */
vlc_icon = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment