/*****************************************************************************
* vout.c: Windows DirectX video output display method
*****************************************************************************
- * Copyright (C) 2001-2004 VideoLAN
+ * Copyright (C) 2001-2004 the VideoLAN team
* $Id$
*
* Authors: Gildas Bazin <gbazin@videolan.org>
static void End ( vout_thread_t * );
static int Manage ( vout_thread_t * );
static void Display ( vout_thread_t *, picture_t * );
+static void SetPalette( vout_thread_t *, uint16_t *, uint16_t *, uint16_t * );
static int NewPictureVec ( vout_thread_t *, picture_t *, int );
static void FreePictureVec ( vout_thread_t *, picture_t *, int );
static int DirectXLockSurface ( vout_thread_t *p_vout, picture_t *p_pic );
static int DirectXUnlockSurface ( vout_thread_t *p_vout, picture_t *p_pic );
-static DWORD DirectXFindColorkey( vout_thread_t *p_vout, uint32_t i_color );
+static DWORD DirectXFindColorkey( vout_thread_t *p_vout, uint32_t *i_color );
void SwitchWallpaperMode( vout_thread_t *, vlc_bool_t );
static char *ppsz_dev_text[] = { N_("Default") };
vlc_module_begin();
+ set_shortname( "DirectX" );
+ set_category( CAT_VIDEO );
+ set_subcategory( SUBCAT_VIDEO_VOUT );
add_bool( "directx-hw-yuv", 1, NULL, HW_YUV_TEXT, HW_YUV_LONGTEXT,
VLC_TRUE );
add_bool( "directx-use-sysmem", 0, NULL, SYSMEM_TEXT, SYSMEM_LONGTEXT,
p_vout->p_sys->GetMonitorInfo = NULL;
if( (huser32 = GetModuleHandle( _T("USER32") ) ) )
{
- p_vout->p_sys->MonitorFromWindow =
+ p_vout->p_sys->MonitorFromWindow = (HMONITOR (WINAPI *)( HWND, DWORD ))
GetProcAddress( huser32, _T("MonitorFromWindow") );
p_vout->p_sys->GetMonitorInfo =
#ifndef UNICODE
p_vout->output.i_width = p_vout->render.i_width;
p_vout->output.i_height = p_vout->render.i_height;
p_vout->output.i_aspect = p_vout->render.i_aspect;
+ p_vout->fmt_out = p_vout->fmt_in;
+ E_(DirectXUpdateRects)( p_vout, VLC_TRUE );
#define MAX_DIRECTBUFFERS 1
/* Right now we use only 1 directbuffer because we don't want the
/* Change the window title bar text */
PostMessage( p_vout->p_sys->hwnd, WM_VLC_CHANGE_TEXT, 0, 0 );
+ p_vout->fmt_out.i_chroma = p_vout->output.i_chroma;
return VLC_SUCCESS;
}
}
}
+ /* Check for cropping changes */
+ if( p_vout->fmt_out.i_x_offset != p_vout->fmt_in.i_x_offset ||
+ p_vout->fmt_out.i_y_offset != p_vout->fmt_in.i_y_offset ||
+ p_vout->fmt_out.i_visible_width != p_vout->fmt_in.i_visible_width ||
+ p_vout->fmt_out.i_visible_height != p_vout->fmt_in.i_visible_height )
+ {
+ p_vout->fmt_out.i_x_offset = p_vout->fmt_in.i_x_offset;
+ p_vout->fmt_out.i_y_offset = p_vout->fmt_in.i_y_offset;
+ p_vout->fmt_out.i_visible_width = p_vout->fmt_in.i_visible_width;
+ p_vout->fmt_out.i_visible_height = p_vout->fmt_in.i_visible_height;
+ E_(DirectXUpdateRects)( p_vout, VLC_TRUE );
+ }
+
/* We used to call the Win32 PeekMessage function here to read the window
* messages. But since window can stay blocked into this function for a
* long time (for example when you move your window on the screen), I
/* Make sure the colorkey will be painted */
p_vout->p_sys->i_colorkey = 1;
p_vout->p_sys->i_rgb_colorkey =
- DirectXFindColorkey( p_vout, p_vout->p_sys->i_colorkey );
+ DirectXFindColorkey( p_vout, &p_vout->p_sys->i_colorkey );
/* Create the actual brush */
SetClassLong( p_vout->p_sys->hvideownd, GCL_HBRBACKGROUND,
{
int i_x, i_y, i_width, i_height;
- rect_src.left = rect_src.top = 0;
- rect_src.right = p_vout->render.i_width;
- rect_src.bottom = p_vout->render.i_height;
+ rect_src.left = p_vout->fmt_out.i_x_offset;
+ rect_src.top = p_vout->fmt_out.i_y_offset;
+ rect_src.right = rect_src.left + p_vout->fmt_out.i_visible_width;
+ rect_src.bottom = rect_src.top + p_vout->fmt_out.i_visible_height;
rect_dest = p_vout->p_sys->rect_display;
vout_PlacePicture( p_vout, rect_dest.right, rect_dest.bottom,
{
switch( ddpfPixelFormat.dwRGBBitCount )
{
- case 8: /* FIXME: set the palette */
+ case 8:
p_vout->output.i_chroma = VLC_FOURCC('R','G','B','2');
+ p_vout->output.pf_setpalette = SetPalette;
break;
case 15:
p_vout->output.i_chroma = VLC_FOURCC('R','V','1','5');
/*****************************************************************************
* DirectXFindColorkey: Finds out the 32bits RGB pixel value of the colorkey
*****************************************************************************/
-static DWORD DirectXFindColorkey( vout_thread_t *p_vout, uint32_t i_color )
+static DWORD DirectXFindColorkey( vout_thread_t *p_vout, uint32_t *pi_color )
{
DDSURFACEDESC ddsd;
HRESULT dxresult;
switch( ddsd.ddpfPixelFormat.dwRGBBitCount )
{
case 4:
- *(uint8_t *)ddsd.lpSurface = 0x11;
+ *(uint8_t *)ddsd.lpSurface = *pi_color | (*pi_color << 4);
break;
case 8:
- *(uint8_t *)ddsd.lpSurface = 0x01;
+ *(uint8_t *)ddsd.lpSurface = *pi_color;
break;
+ case 15:
case 16:
- *(uint16_t *)ddsd.lpSurface = 0x01;
+ *(uint16_t *)ddsd.lpSurface = *pi_color;
break;
+ case 24:
+ /* Seems to be problematic so we'll just put black as the colorkey */
+ *pi_color = 0;
default:
- *(uint32_t *)ddsd.lpSurface = 0x01;
+ *(uint32_t *)ddsd.lpSurface = *pi_color;
break;
}
return VLC_SUCCESS;
}
+
+/*****************************************************************************
+ * SetPalette: sets an 8 bpp palette
+ *****************************************************************************/
+static void SetPalette( vout_thread_t *p_vout,
+ uint16_t *red, uint16_t *green, uint16_t *blue )
+{
+ msg_Err( p_vout, "FIXME: SetPalette unimplemented" );
+}