From 94d3e6a710c40806f44c1d39aaa0388c05487b8f Mon Sep 17 00:00:00 2001 From: diego Date: Tue, 24 May 2011 19:47:07 +0000 Subject: cleanup: vo_direct3d: Mark a function static This fixes the warning: libvo/vo_direct3d.c:984:6: warning: no previous prototype for 'vo_draw_alpha_l8a8' git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33499 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_direct3d.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'libvo') diff --git a/libvo/vo_direct3d.c b/libvo/vo_direct3d.c index 65f5a6c2d1..2fb40d0398 100644 --- a/libvo/vo_direct3d.c +++ b/libvo/vo_direct3d.c @@ -979,8 +979,9 @@ static int draw_frame(uint8_t *src[]) * These values are then inverted again with the texture filter D3DBLEND_INVSRCALPHA */ -void vo_draw_alpha_l8a8(int w, int h, unsigned char* src, unsigned char *srca, - int srcstride, unsigned char* dstbase, int dststride) +static void vo_draw_alpha_l8a8(int w, int h, unsigned char* src, + unsigned char *srca, int srcstride, + unsigned char* dstbase, int dststride) { int y; for (y = 0; y < h; y++) { -- cgit v1.2.3 From 48fdd3d9268b55fe7e1743b43699b2650fb0db55 Mon Sep 17 00:00:00 2001 From: reimar Date: Tue, 24 May 2011 20:52:27 +0000 Subject: vo_gl: Support 9- and 10-bit YUV input for OpenGL VOs git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33502 b3059339-0415-0410-9bf9-f77b7e298cf2 Fix clear/border color of chroma texture for 9- and 10-bit formats. Avoids pink borders for those formats. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33504 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/csputils.c | 6 ++++++ libvo/csputils.h | 1 + libvo/gl_common.h | 14 ++++++++++++++ libvo/vo_gl.c | 21 +++++++++++++-------- libvo/vo_gl2.c | 19 ++++++++++++------- 5 files changed, 46 insertions(+), 15 deletions(-) (limited to 'libvo') diff --git a/libvo/csputils.c b/libvo/csputils.c index 2978279398..0a58aa5a0e 100644 --- a/libvo/csputils.c +++ b/libvo/csputils.c @@ -62,6 +62,9 @@ void mp_gen_gamma_map(uint8_t *map, int size, float gamma) { * not with e.g. MP_CSP_XYZ */ void mp_get_yuv2rgb_coeffs(struct mp_csp_params *params, float yuv2rgb[3][4]) { + float depth_multiplier = params->input_shift >= 0 ? + (1 << params->input_shift) : + (1.0 / (1 << -params->input_shift)); float uvcos = params->saturation * cos(params->hue); float uvsin = params->saturation * sin(params->hue); int format = params->format; @@ -128,6 +131,9 @@ void mp_get_yuv2rgb_coeffs(struct mp_csp_params *params, float yuv2rgb[3][4]) { // this "centers" contrast control so that e.g. a contrast of 0 // leads to a grey image, not a black one yuv2rgb[i][COL_C] += 0.5 - params->contrast / 2.0; + yuv2rgb[i][COL_Y] *= depth_multiplier; + yuv2rgb[i][COL_U] *= depth_multiplier; + yuv2rgb[i][COL_V] *= depth_multiplier; } } diff --git a/libvo/csputils.h b/libvo/csputils.h index acc8f59459..07d9932279 100644 --- a/libvo/csputils.h +++ b/libvo/csputils.h @@ -53,6 +53,7 @@ struct mp_csp_params { float rgamma; float ggamma; float bgamma; + int input_shift; }; void mp_gen_gamma_map(unsigned char *map, int size, float gamma); diff --git a/libvo/gl_common.h b/libvo/gl_common.h index fa0cffaf74..fca91d6f7d 100644 --- a/libvo/gl_common.h +++ b/libvo/gl_common.h @@ -353,6 +353,20 @@ int loadGPUProgram(GLenum target, char *prog); #define SET_YUV_CONVERSION(c) ((c) & YUV_CONVERSION_MASK) #define SET_YUV_LUM_SCALER(s) (((s) & YUV_SCALER_MASK) << YUV_LUM_SCALER_SHIFT) #define SET_YUV_CHROM_SCALER(s) (((s) & YUV_SCALER_MASK) << YUV_CHROM_SCALER_SHIFT) +//! returns whether the yuv conversion supports large brightness range etc. +static inline int glYUVLargeRange(int conv) +{ + switch (conv) + { + case YUV_CONVERSION_NONE: + case YUV_CONVERSION_COMBINERS: + case YUV_CONVERSION_COMBINERS_ATI: + case YUV_CONVERSION_FRAGMENT_LOOKUP3D: + case YUV_CONVERSION_TEXT_FRAGMENT: + return 0; + } + return 1; +} /** \} */ typedef struct { diff --git a/libvo/vo_gl.c b/libvo/vo_gl.c index bc50e245b3..f23d44ba64 100644 --- a/libvo/vo_gl.c +++ b/libvo/vo_gl.c @@ -247,7 +247,7 @@ static void texSize(int w, int h, int *texw, int *texh) { //! maximum size of custom fragment program #define MAX_CUSTOM_PROG_SIZE (1024 * 1024) static void update_yuvconv(void) { - int xs, ys; + int xs, ys, depth; float bri = eq_bri / 100.0; float cont = (eq_cont + 100) / 100.0; float hue = eq_hue / 100.0 * 3.1415927; @@ -256,11 +256,12 @@ static void update_yuvconv(void) { float ggamma = exp(log(8.0) * eq_ggamma / 100.0); float bgamma = exp(log(8.0) * eq_bgamma / 100.0); gl_conversion_params_t params = {gl_target, yuvconvtype, - {colorspace, levelconv, bri, cont, hue, sat, rgamma, ggamma, bgamma}, + {colorspace, levelconv, bri, cont, hue, sat, rgamma, ggamma, bgamma, 0}, texture_width, texture_height, 0, 0, filter_strength}; - mp_get_chroma_shift(image_format, &xs, &ys, NULL); + mp_get_chroma_shift(image_format, &xs, &ys, &depth); params.chrom_texw = params.texw >> xs; params.chrom_texh = params.texh >> ys; + params.csp_params.input_shift = -depth & 7; glSetupYUVConversion(¶ms); if (custom_prog) { FILE *f = fopen(custom_prog, "rb"); @@ -566,9 +567,11 @@ static int initGl(uint32_t d_width, uint32_t d_height) { if (is_yuv) { int i; - int xs, ys; + int xs, ys, depth; + int chroma_clear_val = 128; scale_type = get_scale_type(1); - mp_get_chroma_shift(image_format, &xs, &ys, NULL); + mp_get_chroma_shift(image_format, &xs, &ys, &depth); + chroma_clear_val >>= -depth & 7; mpglGenTextures(21, default_texs); default_texs[21] = 0; for (i = 0; i < 7; i++) { @@ -579,12 +582,14 @@ static int initGl(uint32_t d_width, uint32_t d_height) { } mpglActiveTexture(GL_TEXTURE1); glCreateClearTex(gl_target, gl_texfmt, gl_format, gl_type, scale_type, - texture_width >> xs, texture_height >> ys, 128); + texture_width >> xs, texture_height >> ys, + chroma_clear_val); if (mipmap_gen) mpglTexParameteri(gl_target, GL_GENERATE_MIPMAP, GL_TRUE); mpglActiveTexture(GL_TEXTURE2); glCreateClearTex(gl_target, gl_texfmt, gl_format, gl_type, scale_type, - texture_width >> xs, texture_height >> ys, 128); + texture_width >> xs, texture_height >> ys, + chroma_clear_val); if (mipmap_gen) mpglTexParameteri(gl_target, GL_GENERATE_MIPMAP, GL_TRUE); mpglActiveTexture(GL_TEXTURE0); @@ -1097,7 +1102,7 @@ query_format(uint32_t format) if (format == IMGFMT_RGB24 || format == IMGFMT_RGBA) return caps; if (use_yuv && mp_get_chroma_shift(format, NULL, NULL, &depth) && - (depth == 8 || depth == 16) && + (depth == 8 || depth == 16 || glYUVLargeRange(use_yuv)) && (IMGFMT_IS_YUVP16_NE(format) || !IMGFMT_IS_YUVP16(format))) return caps; // HACK, otherwise we get only b&w with some filters (e.g. -vf eq) diff --git a/libvo/vo_gl2.c b/libvo/vo_gl2.c index 21f779866c..ac1d957136 100644 --- a/libvo/vo_gl2.c +++ b/libvo/vo_gl2.c @@ -273,14 +273,18 @@ static int initTextures(void) glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); if (is_yuv) { - int xs, ys; - mp_get_chroma_shift(image_format, &xs, &ys, NULL); + int xs, ys, depth; + int chroma_clear_val = 128; + mp_get_chroma_shift(image_format, &xs, &ys, &depth); + chroma_clear_val >>= -depth & 7; mpglActiveTexture(GL_TEXTURE1); glCreateClearTex(GL_TEXTURE_2D, gl_internal_format, gl_bitmap_format, gl_bitmap_type, GL_LINEAR, - texture_width >> xs, texture_height >> ys, 128); + texture_width >> xs, texture_height >> ys, + chroma_clear_val); mpglActiveTexture(GL_TEXTURE2); glCreateClearTex(GL_TEXTURE_2D, gl_internal_format, gl_bitmap_format, gl_bitmap_type, GL_LINEAR, - texture_width >> xs, texture_height >> ys, 128); + texture_width >> xs, texture_height >> ys, + chroma_clear_val); mpglActiveTexture(GL_TEXTURE0); } @@ -559,7 +563,7 @@ static int initGl(uint32_t d_width, uint32_t d_height) glDisable(GL_CULL_FACE); glEnable (GL_TEXTURE_2D); if (is_yuv) { - int xs, ys; + int xs, ys, depth; gl_conversion_params_t params = {GL_TEXTURE_2D, use_yuv, {-1, -1, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0}, texture_width, texture_height, 0, 0, 0}; @@ -580,9 +584,10 @@ static int initGl(uint32_t d_width, uint32_t d_height) mpglBindProgram(GL_FRAGMENT_PROGRAM, fragprog); break; } - mp_get_chroma_shift(image_format, &xs, &ys, NULL); + mp_get_chroma_shift(image_format, &xs, &ys, &depth); params.chrom_texw = params.texw >> xs; params.chrom_texh = params.texh >> ys; + params.csp_params.input_shift = -depth & 7; glSetupYUVConversion(¶ms); } @@ -804,7 +809,7 @@ query_format(uint32_t format) { int depth; if (use_yuv && mp_get_chroma_shift(format, NULL, NULL, &depth) && - (depth == 8 || depth == 16) && + (depth == 8 || depth == 16 || glYUVLargeRange(use_yuv)) && (IMGFMT_IS_YUVP16_NE(format) || !IMGFMT_IS_YUVP16(format))) return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN | VFCAP_ACCEPT_STRIDE; -- cgit v1.2.3 From 15513a77fb375acfbda6de36b806c0070472d04d Mon Sep 17 00:00:00 2001 From: iive Date: Sun, 29 May 2011 22:46:52 +0000 Subject: vo_xv: avoid setting background color due to resize flicker Set background color only when using ck-method=background. In the other cases clearing of the non-video image area should be done manually. Not drawing on the video image area prevents flickering (visible when resizing). git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33522 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_xv.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'libvo') diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c index 6da354bd5a..cecbc68b7e 100644 --- a/libvo/vo_xv.c +++ b/libvo/vo_xv.c @@ -252,11 +252,12 @@ static int config(struct vo *vo, uint32_t width, uint32_t height, depth = 24; XMatchVisualInfo(x11->display, x11->screen, depth, TrueColor, &vinfo); - xswa.background_pixel = 0; - if (x11->xv_ck_info.method == CK_METHOD_BACKGROUND) - xswa.background_pixel = x11->xv_colorkey; xswa.border_pixel = 0; - xswamask = CWBackPixel | CWBorderPixel; + xswamask = CWBorderPixel; + if (x11->xv_ck_info.method == CK_METHOD_BACKGROUND) { + xswa.background_pixel = x11->xv_colorkey; + xswamask |= CWBackPixel; + } vo_x11_create_vo_window(vo, &vinfo, vo->dx, vo->dy, vo->dwidth, vo->dheight, flags, CopyFromParent, "xv", -- cgit v1.2.3 From ab1544b74d5d3f440dbcac801c3e3ebd676f9d7b Mon Sep 17 00:00:00 2001 From: iive Date: Sun, 29 May 2011 23:05:57 +0000 Subject: cleanup: x11_common: remove pointless GC operations Remove useless XSetBackground() call right before freeing the graphic context. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33524 b3059339-0415-0410-9bf9-f77b7e298cf2 Create empty vo_gc graphic context instead of one with undefined foreground color. The code that uses vo_gc already employs XSetForeground()/XSetBackground() to change the context accordingly. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33525 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/x11_common.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'libvo') diff --git a/libvo/x11_common.c b/libvo/x11_common.c index 12fc661dee..c576839ddb 100644 --- a/libvo/x11_common.c +++ b/libvo/x11_common.c @@ -732,7 +732,6 @@ void vo_x11_uninit(struct vo *vo) { if (x11->vo_gc != None) { - XSetBackground(vo->x11->display, x11->vo_gc, 0); XFreeGC(vo->x11->display, x11->vo_gc); x11->vo_gc = None; } @@ -1050,7 +1049,6 @@ void vo_x11_create_vo_window(struct vo *vo, XVisualInfo *vis, int x, int y, struct MPOpts *opts = vo->opts; struct vo_x11_state *x11 = vo->x11; Display *mDisplay = vo->x11->display; - XGCValues xgcv; if (WinID >= 0) { vo_fs = flags & VOFLAG_FULLSCREEN; x11->window = WinID ? (Window)WinID : x11->rootwin; @@ -1122,7 +1120,8 @@ void vo_x11_create_vo_window(struct vo *vo, XVisualInfo *vis, int x, int y, final: if (x11->vo_gc != None) XFreeGC(mDisplay, x11->vo_gc); - x11->vo_gc = XCreateGC(mDisplay, x11->window, GCForeground, &xgcv); + x11->vo_gc = XCreateGC(mDisplay, x11->window, 0, NULL); + XSync(mDisplay, False); x11->vo_mouse_autohide = 1; vo->event_fd = ConnectionNumber(x11->display); -- cgit v1.2.3 From d6e34fe91a5bf8a7a65e1e9ee7837612241f8ce8 Mon Sep 17 00:00:00 2001 From: diego Date: Tue, 14 Jun 2011 12:13:47 +0000 Subject: VO: support Pause/Break key in X11 input Allow Pause/Break key to be bound as MPlayer input key under X11. patch by Steaphan Greene, sgreene cs.binghamton edu git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33609 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/wskeys.h | 1 + libvo/x11_common.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'libvo') diff --git a/libvo/wskeys.h b/libvo/wskeys.h index ef372e5c7f..10d9b8b4e4 100644 --- a/libvo/wskeys.h +++ b/libvo/wskeys.h @@ -19,6 +19,7 @@ #ifndef MPLAYER_WSKEYS_H #define MPLAYER_WSKEYS_H +#define wsPause 0x13 + 256 #define wsUp 0x52 + 256 #define wsDown 0x54 + 256 #define wsLeft 0x51 + 256 diff --git a/libvo/x11_common.c b/libvo/x11_common.c index c576839ddb..0a193fb0d3 100644 --- a/libvo/x11_common.c +++ b/libvo/x11_common.c @@ -550,7 +550,8 @@ static void vo_x11_putkey_ext(struct vo *vo, int keysym, int modifiers) static const struct mp_keymap keymap[] = { // special keys - {wsEscape, KEY_ESC}, {wsBackSpace, KEY_BS}, {wsTab, KEY_TAB}, {wsEnter, KEY_ENTER}, + {wsPause, KEY_PAUSE}, {wsEscape, KEY_ESC}, {wsBackSpace, KEY_BS}, + {wsTab, KEY_TAB}, {wsEnter, KEY_ENTER}, // cursor keys {wsLeft, KEY_LEFT}, {wsRight, KEY_RIGHT}, {wsUp, KEY_UP}, {wsDown, KEY_DOWN}, -- cgit v1.2.3 From 1b6ae1ff582405652f5543bfc7193eec57d983fc Mon Sep 17 00:00:00 2001 From: reimar Date: Sun, 19 Jun 2011 10:36:15 +0000 Subject: VO: w32_common: also generate VO_EVENT_MOVE git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33650 b3059339-0415-0410-9bf9-f77b7e298cf2 Generate VO_EVENT_MOVE also with -wid. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33656 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/w32_common.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'libvo') diff --git a/libvo/w32_common.c b/libvo/w32_common.c index 0c512f3d2d..a8a59d02c9 100644 --- a/libvo/w32_common.c +++ b/libvo/w32_common.c @@ -101,6 +101,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l event_flags |= VO_EVENT_EXPOSE; break; case WM_MOVE: + event_flags |= VO_EVENT_MOVE; p.x = 0; p.y = 0; ClientToScreen(vo_window, &p); @@ -219,11 +220,18 @@ int vo_w32_check_events(void) { if (WinID >= 0) { BOOL res; RECT r; + POINT p; res = GetClientRect(vo_window, &r); if (res && (r.right != vo_dwidth || r.bottom != vo_dheight)) { vo_dwidth = r.right; vo_dheight = r.bottom; event_flags |= VO_EVENT_RESIZE; } + p.x = 0; p.y = 0; + ClientToScreen(vo_window, &p); + if (p.x != vo_dx || p.y != vo_dy) { + vo_dx = p.x; vo_dy = p.y; + event_flags |= VO_EVENT_MOVE; + } res = GetClientRect(WinID, &r); if (res && (r.right != vo_dwidth || r.bottom != vo_dheight)) MoveWindow(vo_window, 0, 0, r.right, r.bottom, FALSE); -- cgit v1.2.3 From 070491f1029ca3d74322146e646d653f9f5dc153 Mon Sep 17 00:00:00 2001 From: reimar Date: Sun, 19 Jun 2011 12:51:36 +0000 Subject: vo_directx: Change vo_directx to use w32_common.c While I tested it quite thoroughly, with and without -wid, -vm, -fs, ... it is _very_ likely to break something, please report any regressions! In the worst case it can still be reverted, however since it has very little relevance nowadays it will rot all the faster if not at least some code is shared. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33657 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_directx.c | 413 ++++++----------------------------------------------- 1 file changed, 43 insertions(+), 370 deletions(-) (limited to 'libvo') diff --git a/libvo/vo_directx.c b/libvo/vo_directx.c index 6df766cc4a..455752179e 100644 --- a/libvo/vo_directx.c +++ b/libvo/vo_directx.c @@ -37,6 +37,7 @@ #include "geometry.h" #include "mp_fifo.h" #include "sub/sub.h" +#include "w32_common.h" #ifndef WM_XBUTTONDOWN # define WM_XBUTTONDOWN 0x020B @@ -58,8 +59,6 @@ static DDSURFACEDESC2 ddsdsf; //surface descripiton needed for static HINSTANCE hddraw_dll; //handle to ddraw.dll static RECT rd; //rect of our stretched image static RECT rs; //rect of our source image -static HWND hWnd=NULL; //handle to the window -static HWND hWndFS=NULL; //fullscreen window static HBRUSH colorbrush = NULL; // Handle to colorkey brush static HBRUSH blackbrush = NULL; // Handle to black brush static HICON mplayericon = NULL; // Handle to mplayer icon @@ -348,19 +347,12 @@ static void uninit(void) if (g_lpddsPrimary != NULL) g_lpddsPrimary->lpVtbl->Release(g_lpddsPrimary); g_lpddsPrimary = NULL; mp_msg(MSGT_VO, MSGL_DBG3,"primary released\n"); - if(hWndFS)DestroyWindow(hWndFS); - hWndFS = NULL; - if((WinID == -1) && hWnd) DestroyWindow(hWnd); - hWnd = NULL; - mp_msg(MSGT_VO, MSGL_DBG3,"window destroyed\n"); UnregisterClass(WNDCLASSNAME_WINDOWED, GetModuleHandle(NULL)); UnregisterClass(WNDCLASSNAME_FULLSCREEN, GetModuleHandle(NULL)); if (mplayericon) DestroyIcon(mplayericon); mplayericon = NULL; if (mplayercursor) DestroyCursor(mplayercursor); mplayercursor = NULL; - if (blackbrush) DeleteObject(blackbrush); - blackbrush = NULL; if (colorbrush) DeleteObject(colorbrush); colorbrush = NULL; mp_msg(MSGT_VO, MSGL_DBG3,"GDI resources deleted\n"); @@ -373,6 +365,7 @@ static void uninit(void) hddraw_dll= NULL; mp_msg(MSGT_VO, MSGL_DBG3,"ddraw.dll freed\n"); mp_msg(MSGT_VO, MSGL_DBG3,"uninitialized\n"); + vo_w32_uninit(); } static BOOL WINAPI EnumCallbackEx(GUID FAR *lpGUID, LPSTR lpDriverDescription, LPSTR lpDriverName, LPVOID lpContext, HMONITOR hm) @@ -495,7 +488,7 @@ static uint32_t Directx_InitDirectDraw(void) else vm_bpp=ddsd.ddpfPixelFormat.dwRGBBitCount; if(vidmode){ - if (g_lpdd->lpVtbl->SetCooperativeLevel(g_lpdd, hWnd, DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN) != DD_OK) + if (g_lpdd->lpVtbl->SetCooperativeLevel(g_lpdd, vo_w32_window, DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN) != DD_OK) { mp_msg(MSGT_VO, MSGL_FATAL,"can't set cooperativelevel for exclusive mode\n"); return 1; @@ -509,7 +502,7 @@ static uint32_t Directx_InitDirectDraw(void) mp_msg(MSGT_VO, MSGL_V,"Initialized adapter %i for %i x %i @ %i \n",vo_adapter_num,vm_width,vm_height,vm_bpp); return 0; } - if (g_lpdd->lpVtbl->SetCooperativeLevel(g_lpdd, hWnd, DDSCL_NORMAL) != DD_OK) // or DDSCL_SETFOCUSWINDOW + if (g_lpdd->lpVtbl->SetCooperativeLevel(g_lpdd, vo_w32_window, DDSCL_NORMAL) != DD_OK) // or DDSCL_SETFOCUSWINDOW { mp_msg(MSGT_VO, MSGL_FATAL,"could not set cooperativelevel for hardwarecheck\n"); return 1; @@ -518,13 +511,19 @@ static uint32_t Directx_InitDirectDraw(void) return 0; } +static uint32_t Directx_ManageDisplay(void); + static void check_events(void) { - MSG msg; - while (PeekMessage(&msg, NULL, 0, 0,PM_REMOVE)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); + int evt = vo_w32_check_events(); + if (evt & (VO_EVENT_RESIZE | VO_EVENT_MOVE)) + Directx_ManageDisplay(); + if (evt & (VO_EVENT_RESIZE | VO_EVENT_MOVE | VO_EVENT_EXPOSE)) { + HDC dc = vo_w32_get_dc(vo_w32_window); + RECT r; + GetClientRect(vo_w32_window, &r); + FillRect(dc, &r, vo_fs || vidmode ? blackbrush : colorbrush); + vo_w32_release_dc(vo_w32_window, dc); } } @@ -536,66 +535,20 @@ static uint32_t Directx_ManageDisplay(void) DWORD dwUpdateFlags=0; int width,height; - if(!vidmode && !vo_fs && WinID!=-1) { - RECT current_rect = {0, 0, 0, 0}; - GetWindowRect(hWnd, ¤t_rect); - if ((current_rect.left == last_rect.left) - && (current_rect.top == last_rect.top) - && (current_rect.right == last_rect.right) - && (current_rect.bottom == last_rect.bottom)) - return 0; - last_rect = current_rect; - } + rd.left = vo_dx - xinerama_x; + rd.top = vo_dy - xinerama_y; + width = vo_dwidth; + height = vo_dheight; + + aspect(&width, &height, A_WINZOOM); + panscan_calc_windowed(); + width += vo_panscan_x; + height += vo_panscan_y; + width = FFMIN(width, vo_screenwidth); + height = FFMIN(height, vo_screenheight); + rd.left += (vo_dwidth - width ) / 2; + rd.top += (vo_dheight - height) / 2; - if(vo_fs || vidmode){ - aspect(&width,&height,A_ZOOM); - rd.left=(vo_screenwidth-width)/2; - rd.top=(vo_screenheight-height)/2; - if (WinID == -1) - if(ShowCursor(FALSE)>=0)while(ShowCursor(FALSE)>=0){} - } - else if (WinID != -1 && vo_geometry) { - POINT pt; - pt.x = vo_dx; - pt.y = vo_dy; - ClientToScreen(hWnd,&pt); - width=d_image_width; - height=d_image_height; - rd.left = pt.x; - rd.top = pt.y; - while(ShowCursor(TRUE)<=0){} - } - else { - POINT pt; - pt.x = 0; //overlayposition relative to the window - pt.y = 0; - ClientToScreen(hWnd,&pt); - GetClientRect(hWnd, &rd); - width=rd.right - rd.left; - height=rd.bottom - rd.top; - pt.x -= monitor_rect.left; /* move coordinates from global to local monitor space */ - pt.y -= monitor_rect.top; - rd.right -= monitor_rect.left; - rd.bottom -= monitor_rect.top; - rd.left = pt.x; - rd.top = pt.y; - if(!nooverlay && (!width || !height)){ - /*window is minimized*/ - ddrval = g_lpddsOverlay->lpVtbl->UpdateOverlay(g_lpddsOverlay,NULL, g_lpddsPrimary, NULL, DDOVER_HIDE, NULL); - return 0; - } - if(vo_keepaspect){ - int tmpheight=((float)width/window_aspect); - tmpheight+=tmpheight%2; - if(tmpheight > height){ - width=((float)height*window_aspect); - width+=width%2; - } - else height=tmpheight; - } - if (WinID == -1) - while(ShowCursor(TRUE)<=0){} - } rd.right=rd.left+width; rd.bottom=rd.top+height; @@ -680,23 +633,8 @@ static uint32_t Directx_ManageDisplay(void) } else { - g_lpddclipper->lpVtbl->SetHWnd(g_lpddclipper, 0,(vo_fs && !vidmode)?hWndFS: hWnd); - } - - if(!vidmode && !vo_fs){ - if(WinID == -1) { - RECT rdw=rd; - if (vo_border) - AdjustWindowRect(&rdw,WNDSTYLE,FALSE); -// printf("window: %i %i %ix%i\n",rdw.left,rdw.top,rdw.right - rdw.left,rdw.bottom - rdw.top); - rdw.left += monitor_rect.left; /* move to global coordinate space */ - rdw.top += monitor_rect.top; - rdw.right += monitor_rect.left; - rdw.bottom += monitor_rect.top; - SetWindowPos(hWnd,(vo_ontop)?HWND_TOPMOST:(vo_rootwin?HWND_BOTTOM:HWND_NOTOPMOST),rdw.left,rdw.top,rdw.right-rdw.left,rdw.bottom-rdw.top,SWP_NOOWNERZORDER); - } + g_lpddclipper->lpVtbl->SetHWnd(g_lpddclipper, 0, vo_w32_window); } - else SetWindowPos(vidmode?hWnd:hWndFS,vo_rootwin?HWND_BOTTOM:HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOOWNERZORDER|SWP_NOCOPYBITS); /*make sure the overlay is inside the screen*/ if(rd.left<0)rd.left=0; @@ -887,172 +825,10 @@ static uint32_t Directx_CheckPrimaryPixelformat(void) return 0; } -//function handles input -static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case WM_MOUSEACTIVATE: - return MA_ACTIVATEANDEAT; - case WM_NCACTIVATE: - { - if(vidmode && adapter_count > 2) //only disable if more than one adapter. - return 0; - break; - } - case WM_DESTROY: - { - PostQuitMessage(0); - return 0; - } - case WM_CLOSE: - { - mplayer_put_key(KEY_CLOSE_WIN); - return 0; - } - case WM_WINDOWPOSCHANGED: - { - //printf("Windowposchange\n"); - if(g_lpddsBack != NULL) //or it will crash with -vm - { - Directx_ManageDisplay(); - } - break; - } - case WM_SYSCOMMAND: - { - switch (wParam) - { //kill screensaver etc. - //note: works only when the window is active - //you can workaround this by disabling the allow screensaver option in - //the link to the app - case SC_SCREENSAVE: - case SC_MONITORPOWER: - mp_msg(MSGT_VO, MSGL_V ,"killing screensaver\n" ); - return 0; - case SC_MAXIMIZE: - if (!vo_fs) control(VOCTRL_FULLSCREEN, NULL); - return 0; - } - break; - } - case WM_KEYDOWN: - { - switch (wParam) - { - case VK_LEFT: - {mplayer_put_key(KEY_LEFT);break;} - case VK_UP: - {mplayer_put_key(KEY_UP);break;} - case VK_RIGHT: - {mplayer_put_key(KEY_RIGHT);break;} - case VK_DOWN: - {mplayer_put_key(KEY_DOWN);break;} - case VK_TAB: - {mplayer_put_key(KEY_TAB);break;} - case VK_BACK: - {mplayer_put_key(KEY_BS);break;} - case VK_DELETE: - {mplayer_put_key(KEY_DELETE);break;} - case VK_INSERT: - {mplayer_put_key(KEY_INSERT);break;} - case VK_HOME: - {mplayer_put_key(KEY_HOME);break;} - case VK_END: - {mplayer_put_key(KEY_END);break;} - case VK_PRIOR: - {mplayer_put_key(KEY_PAGE_UP);break;} - case VK_NEXT: - {mplayer_put_key(KEY_PAGE_DOWN);break;} - case VK_ESCAPE: - {mplayer_put_key(KEY_ESC);break;} - } - break; - } - case WM_CHAR: - { - mplayer_put_key(wParam); - break; - } - case WM_LBUTTONDOWN: - { - if (!vo_nomouse_input) - mplayer_put_key(MOUSE_BTN0); - break; - } - case WM_MBUTTONDOWN: - { - if (!vo_nomouse_input) - mplayer_put_key(MOUSE_BTN1); - break; - } - case WM_RBUTTONDOWN: - { - if (!vo_nomouse_input) - mplayer_put_key(MOUSE_BTN2); - break; - } - case WM_LBUTTONDBLCLK: - { - if(!vo_nomouse_input) - mplayer_put_key(MOUSE_BTN0_DBL); - break; - } - case WM_MBUTTONDBLCLK: - { - if(!vo_nomouse_input) - mplayer_put_key(MOUSE_BTN1_DBL); - break; - } - case WM_RBUTTONDBLCLK: - { - if(!vo_nomouse_input) - mplayer_put_key(MOUSE_BTN2_DBL); - break; - } - case WM_MOUSEWHEEL: - { - int x; - if (vo_nomouse_input) - break; - x = GET_WHEEL_DELTA_WPARAM(wParam); - if (x > 0) - mplayer_put_key(MOUSE_BTN3); - else - mplayer_put_key(MOUSE_BTN4); - break; - } - case WM_XBUTTONDOWN: - { - if (vo_nomouse_input) - break; - if (HIWORD(wParam) == 1) - mplayer_put_key(MOUSE_BTN5); - else - mplayer_put_key(MOUSE_BTN6); - break; - } - case WM_XBUTTONDBLCLK: - { - if (vo_nomouse_input) - break; - if (HIWORD(wParam) == 1) - mplayer_put_key(MOUSE_BTN5_DBL); - else - mplayer_put_key(MOUSE_BTN6_DBL); - break; - } - - } - return DefWindowProc(hWnd, message, wParam, lParam); -} - - static int preinit(const char *arg) { HINSTANCE hInstance = GetModuleHandle(NULL); char exedir[MAX_PATH]; - WNDCLASS wc; if(arg) { if(strstr(arg,"noaccel")) @@ -1074,31 +850,13 @@ static int preinit(const char *arg) windowcolor = vo_colorkey; colorbrush = CreateSolidBrush(windowcolor); blackbrush = (HBRUSH)GetStockObject(BLACK_BRUSH); - wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; - wc.lpfnWndProc = WndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = hInstance; - wc.hCursor = mplayercursor; - wc.hIcon = mplayericon; - wc.hbrBackground = vidmode ? blackbrush : colorbrush; - wc.lpszClassName = WNDCLASSNAME_WINDOWED; - wc.lpszMenuName = NULL; - RegisterClass(&wc); - if (WinID != -1) hWnd = WinID; - else - hWnd = CreateWindowEx(vidmode?WS_EX_TOPMOST:0, - WNDCLASSNAME_WINDOWED,"",(vidmode || !vo_border)?WS_POPUP:WNDSTYLE, - CW_USEDEFAULT, CW_USEDEFAULT, 100, 100,NULL,NULL,hInstance,NULL); - wc.hbrBackground = blackbrush; - wc.lpszClassName = WNDCLASSNAME_FULLSCREEN; - RegisterClass(&wc); + if (!vo_w32_init()) + return 1; + if (!vo_w32_config(100, 100, VOFLAG_HIDDEN)) + return 1; if (Directx_InitDirectDraw()!= 0)return 1; //init DirectDraw - if(!vidmode)hWndFS = CreateWindow(WNDCLASSNAME_FULLSCREEN,"MPlayer Fullscreen",WS_POPUP,monitor_rect.left,monitor_rect.top,monitor_rect.right-monitor_rect.left,monitor_rect.bottom-monitor_rect.top,hWnd,NULL,hInstance,NULL); - mp_msg(MSGT_VO, MSGL_DBG3 ,"initial mplayer windows created\n"); - if (Directx_CheckPrimaryPixelformat()!=0)return 1; if (!nooverlay && Directx_CheckOverlayPixelformats() == 0) //check for supported hardware { @@ -1239,8 +997,6 @@ static uint32_t put_image(mp_image_t *mpi){ uint32_t w = mpi->w; uint32_t h = mpi->h; - if (WinID != -1) Directx_ManageDisplay(); - if((mpi->flags&MP_IMGFLAG_DIRECT)||(mpi->flags&MP_IMGFLAG_DRAW_CALLBACK)) { mp_msg(MSGT_VO, MSGL_DBG3 ,"put_image: nothing to do: drawslices\n"); @@ -1278,8 +1034,6 @@ static uint32_t put_image(mp_image_t *mpi){ static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t options, char *title, uint32_t format) { - RECT rd; - vo_fs = options & 0x01; image_format = format; image_width = width; image_height = height; @@ -1302,32 +1056,11 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin g_lpddsPrimary = NULL; mp_msg(MSGT_VO, MSGL_DBG3,"overlay surfaces released\n"); - if(!vidmode){ - if(!vo_geometry){ - GetWindowRect(hWnd,&rd); - vo_dx=rd.left; - vo_dy=rd.top; - } - vo_dx += monitor_rect.left; /* move position to global window space */ - vo_dy += monitor_rect.top; - rd.left = vo_dx; - rd.top = vo_dy; - rd.right = rd.left + d_image_width; - rd.bottom = rd.top + d_image_height; - if (WinID == -1) { - if (vo_border) - AdjustWindowRect(&rd,WNDSTYLE,FALSE); - SetWindowPos(hWnd,NULL, vo_dx, vo_dy,rd.right-rd.left,rd.bottom-rd.top,SWP_SHOWWINDOW|SWP_NOOWNERZORDER); - } - } - else ShowWindow(hWnd,SW_SHOW); + if (!vo_w32_config(d_width, d_height, options)) + return 1; - if(vo_fs && !vidmode)ShowWindow(hWndFS,SW_SHOW); if (WinID == -1) - SetWindowText(hWnd,title); - - - if(vidmode)vo_fs=0; + SetWindowText(vo_w32_window,title); /*create the surfaces*/ @@ -1369,7 +1102,7 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin vo_doublebuffering = 0; /*create clipper for nonoverlay mode*/ if(g_lpdd->lpVtbl->CreateClipper(g_lpdd, 0, &g_lpddclipper,NULL)!= DD_OK){mp_msg(MSGT_VO, MSGL_FATAL,"can't create clipper\n");return 1;} - if(g_lpddclipper->lpVtbl->SetHWnd (g_lpddclipper, 0, hWnd)!= DD_OK){mp_msg(MSGT_VO, MSGL_FATAL,"can't associate clipper with window\n");return 1;} + if(g_lpddclipper->lpVtbl->SetHWnd (g_lpddclipper, 0, vo_w32_window)!= DD_OK){mp_msg(MSGT_VO, MSGL_FATAL,"can't associate clipper with window\n");return 1;} if(g_lpddsPrimary->lpVtbl->SetClipper (g_lpddsPrimary,g_lpddclipper)!=DD_OK){mp_msg(MSGT_VO, MSGL_FATAL,"can't associate primary surface with clipper\n");return 1;} mp_msg(MSGT_VO, MSGL_DBG3,"clipper succesfully created\n"); }else{ @@ -1475,43 +1208,11 @@ static int control(uint32_t request, void *data) case VOCTRL_DRAW_IMAGE: return put_image(data); case VOCTRL_BORDER: - if(WinID != -1) return VO_TRUE; - if(vidmode) - { - mp_msg(MSGT_VO, MSGL_ERR,"border has no meaning in exclusive mode\n"); - } - else - { - if(vo_border) { - vo_border = 0; - SetWindowLong(hWnd, GWL_STYLE, WS_POPUP); - } else { - vo_border = 1; - SetWindowLong(hWnd, GWL_STYLE, WNDSTYLE); - } - // needed AFAICT to force the window to - // redisplay with the new style. --Joey - if (!vo_fs) { - ShowWindow(hWnd,SW_HIDE); - ShowWindow(hWnd,SW_SHOW); - } - last_rect.left = 0xDEADC0DE; // reset window position cache - Directx_ManageDisplay(); - } + vo_w32_border(); + Directx_ManageDisplay(); return VO_TRUE; case VOCTRL_ONTOP: - if(WinID != -1) return VO_TRUE; - if(vidmode) - { - mp_msg(MSGT_VO, MSGL_ERR,"ontop has no meaning in exclusive mode\n"); - } - else - { - if(vo_ontop) vo_ontop = 0; - else vo_ontop = 1; - last_rect.left = 0xDEADC0DE; // reset window position cache - Directx_ManageDisplay(); - } + vo_w32_ontop(); return VO_TRUE; case VOCTRL_ROOTWIN: if(WinID != -1) return VO_TRUE; @@ -1529,29 +1230,8 @@ static int control(uint32_t request, void *data) return VO_TRUE; case VOCTRL_FULLSCREEN: { - if(vidmode) - { - mp_msg(MSGT_VO, MSGL_ERR,"currently we do not allow to switch from exclusive to windowed mode\n"); - } - else - { - if(!vo_fs) - { - vo_fs=1; - ShowWindow(hWndFS,SW_SHOW); - ShowWindow(hWnd,SW_HIDE); - SetForegroundWindow(hWndFS); - } - else - { - vo_fs=0; - ShowWindow(hWndFS,SW_HIDE); - ShowWindow(hWnd,SW_SHOW); - } - last_rect.left = 0xDEADC0DE; // reset window position cache - Directx_ManageDisplay(); - break; - } + vo_w32_fullscreen(); + Directx_ManageDisplay(); return VO_TRUE; } case VOCTRL_SET_EQUALIZER: { @@ -1563,14 +1243,7 @@ static int control(uint32_t request, void *data) return color_ctrl_get(args->name, args->valueptr); } case VOCTRL_UPDATE_SCREENINFO: - if (vidmode) { - vo_screenwidth = vm_width; - vo_screenheight = vm_height; - } else { - vo_screenwidth = monitor_rect.right - monitor_rect.left; - vo_screenheight = monitor_rect.bottom - monitor_rect.top; - } - aspect_save_screenres(vo_screenwidth, vo_screenheight); + w32_update_xinerama_info(); return VO_TRUE; case VOCTRL_RESET: last_rect.left = 0xDEADC0DE; // reset window position cache -- cgit v1.2.3 From 9d8913dbf42201f3028369b23797be594a03fb70 Mon Sep 17 00:00:00 2001 From: reimar Date: Sun, 19 Jun 2011 18:31:45 +0000 Subject: cleanup: vo_directx: remove redundant code Simplify code for printing display adapter list. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33672 b3059339-0415-0410-9bf9-f77b7e298cf2 Remove left-over code from icon/cursor handling that is now done by w32_common.c git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33673 b3059339-0415-0410-9bf9-f77b7e298cf2 Remove more code and variables that have no purpose anymore. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33674 b3059339-0415-0410-9bf9-f77b7e298cf2 Remove some #includes that are no longer needed. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33675 b3059339-0415-0410-9bf9-f77b7e298cf2 Remove more unnecessary code/defines. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33677 b3059339-0415-0410-9bf9-f77b7e298cf2 Move check_events function to avoid forward declaration. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33678 b3059339-0415-0410-9bf9-f77b7e298cf2 Remove more unused variables. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33679 b3059339-0415-0410-9bf9-f77b7e298cf2 Add const to avoid compiler warning. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33680 b3059339-0415-0410-9bf9-f77b7e298cf2 Use the proper type for the palette, fixes compiler warning. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33681 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_directx.c | 117 +++++++++++------------------------------------------ 1 file changed, 23 insertions(+), 94 deletions(-) (limited to 'libvo') diff --git a/libvo/vo_directx.c b/libvo/vo_directx.c index 455752179e..c9dfdde995 100644 --- a/libvo/vo_directx.c +++ b/libvo/vo_directx.c @@ -30,25 +30,11 @@ #include "video_out.h" #include "video_out_internal.h" #include "fastmemcpy.h" -#include "input/input.h" -#include "input/keycodes.h" #include "mp_msg.h" #include "aspect.h" -#include "geometry.h" -#include "mp_fifo.h" #include "sub/sub.h" #include "w32_common.h" -#ifndef WM_XBUTTONDOWN -# define WM_XBUTTONDOWN 0x020B -# define WM_XBUTTONUP 0x020C -# define WM_XBUTTONDBLCLK 0x020D -#endif - -#define WNDCLASSNAME_WINDOWED "MPlayer - The Movie Player" -#define WNDCLASSNAME_FULLSCREEN "MPlayer - Fullscreen" -#define WNDSTYLE WS_OVERLAPPEDWINDOW|WS_SIZEBOX - static LPDIRECTDRAWCOLORCONTROL g_cc = NULL; //color control interface static LPDIRECTDRAW7 g_lpdd = NULL; //DirectDraw Object static LPDIRECTDRAWSURFACE7 g_lpddsPrimary = NULL; //Primary Surface: viewport through the Desktop @@ -61,10 +47,7 @@ static RECT rd; //rect of our stretched imag static RECT rs; //rect of our source image static HBRUSH colorbrush = NULL; // Handle to colorkey brush static HBRUSH blackbrush = NULL; // Handle to black brush -static HICON mplayericon = NULL; // Handle to mplayer icon -static HCURSOR mplayercursor = NULL; // Handle to mplayer cursor static uint32_t image_width, image_height; //image width and height -static uint32_t d_image_width, d_image_height; //image width and height zoomed static uint8_t *image=NULL; //image data static void* tmp_image = NULL; static uint32_t image_format=0; //image format @@ -79,10 +62,6 @@ static COLORREF windowcolor = RGB(0,0,16); //windowcolor == colorkey static int adapter_count=0; static GUID selected_guid; static GUID *selected_guid_ptr = NULL; -static RECT monitor_rect; //monitor coordinates -static float window_aspect; -static BOOL (WINAPI* myGetMonitorInfo)(HMONITOR, LPMONITORINFO) = NULL; -static RECT last_rect = {0xDEADC0DE, 0xDEADC0DE, 0xDEADC0DE, 0xDEADC0DE}; /***************************************************************************** * DirectDraw GUIDs. @@ -347,12 +326,6 @@ static void uninit(void) if (g_lpddsPrimary != NULL) g_lpddsPrimary->lpVtbl->Release(g_lpddsPrimary); g_lpddsPrimary = NULL; mp_msg(MSGT_VO, MSGL_DBG3,"primary released\n"); - UnregisterClass(WNDCLASSNAME_WINDOWED, GetModuleHandle(NULL)); - UnregisterClass(WNDCLASSNAME_FULLSCREEN, GetModuleHandle(NULL)); - if (mplayericon) DestroyIcon(mplayericon); - mplayericon = NULL; - if (mplayercursor) DestroyCursor(mplayercursor); - mplayercursor = NULL; if (colorbrush) DeleteObject(colorbrush); colorbrush = NULL; mp_msg(MSGT_VO, MSGL_DBG3,"GDI resources deleted\n"); @@ -370,19 +343,11 @@ static void uninit(void) static BOOL WINAPI EnumCallbackEx(GUID FAR *lpGUID, LPSTR lpDriverDescription, LPSTR lpDriverName, LPVOID lpContext, HMONITOR hm) { - mp_msg(MSGT_VO, MSGL_INFO ," adapter %d: ", adapter_count); - if (!lpGUID) - { - mp_msg(MSGT_VO, MSGL_INFO ,"%s", "Primary Display Adapter"); - } - else - { - mp_msg(MSGT_VO, MSGL_INFO ,"%s", lpDriverDescription); - } + lpDriverDescription = "Primary Display Adapter"; + mp_msg(MSGT_VO, MSGL_INFO ," adapter %d: %s", adapter_count, lpDriverDescription); if(adapter_count == vo_adapter_num){ - MONITORINFO mi; if (!lpGUID) selected_guid_ptr = NULL; else @@ -390,11 +355,7 @@ static BOOL WINAPI EnumCallbackEx(GUID FAR *lpGUID, LPSTR lpDriverDescription, L selected_guid = *lpGUID; selected_guid_ptr = &selected_guid; } - mi.cbSize = sizeof(mi); - if (myGetMonitorInfo(hm, &mi)) { - monitor_rect = mi.rcMonitor; - } mp_msg(MSGT_VO, MSGL_INFO ,"\t\t<--"); } mp_msg(MSGT_VO, MSGL_INFO ,"\n"); @@ -409,16 +370,8 @@ static uint32_t Directx_InitDirectDraw(void) HRESULT (WINAPI *OurDirectDrawCreateEx)(GUID *,LPVOID *, REFIID,IUnknown FAR *); DDSURFACEDESC2 ddsd; LPDIRECTDRAWENUMERATEEX OurDirectDrawEnumerateEx; - HINSTANCE user32dll=LoadLibrary("user32.dll"); adapter_count = 0; - if(user32dll){ - myGetMonitorInfo=GetProcAddress(user32dll,"GetMonitorInfoA"); - if(!myGetMonitorInfo && vo_adapter_num){ - mp_msg(MSGT_VO, MSGL_ERR, " -adapter is not supported on Win95\n"); - vo_adapter_num = 0; - } - } mp_msg(MSGT_VO, MSGL_DBG3,"Initing DirectDraw\n" ); @@ -430,8 +383,6 @@ static uint32_t Directx_InitDirectDraw(void) return 1; } - last_rect.left = 0xDEADC0DE; // reset window position cache - if(vo_adapter_num){ //display other than default OurDirectDrawEnumerateEx = (LPDIRECTDRAWENUMERATEEX) GetProcAddress(hddraw_dll,"DirectDrawEnumerateExA"); if (!OurDirectDrawEnumerateEx){ @@ -448,7 +399,6 @@ static uint32_t Directx_InitDirectDraw(void) if(vo_adapter_num >= adapter_count) mp_msg(MSGT_VO, MSGL_ERR,"Selected adapter (%d) doesn't exist: Default Display Adapter selected\n",vo_adapter_num); } - FreeLibrary(user32dll); OurDirectDrawCreateEx = (void *)GetProcAddress(hddraw_dll, "DirectDrawCreateEx"); if ( OurDirectDrawCreateEx == NULL ) @@ -511,22 +461,6 @@ static uint32_t Directx_InitDirectDraw(void) return 0; } -static uint32_t Directx_ManageDisplay(void); - -static void check_events(void) -{ - int evt = vo_w32_check_events(); - if (evt & (VO_EVENT_RESIZE | VO_EVENT_MOVE)) - Directx_ManageDisplay(); - if (evt & (VO_EVENT_RESIZE | VO_EVENT_MOVE | VO_EVENT_EXPOSE)) { - HDC dc = vo_w32_get_dc(vo_w32_window); - RECT r; - GetClientRect(vo_w32_window, &r); - FillRect(dc, &r, vo_fs || vidmode ? blackbrush : colorbrush); - vo_w32_release_dc(vo_w32_window, dc); - } -} - static uint32_t Directx_ManageDisplay(void) { HRESULT ddrval; @@ -695,6 +629,20 @@ static uint32_t Directx_ManageDisplay(void) return 0; } +static void check_events(void) +{ + int evt = vo_w32_check_events(); + if (evt & (VO_EVENT_RESIZE | VO_EVENT_MOVE)) + Directx_ManageDisplay(); + if (evt & (VO_EVENT_RESIZE | VO_EVENT_MOVE | VO_EVENT_EXPOSE)) { + HDC dc = vo_w32_get_dc(vo_w32_window); + RECT r; + GetClientRect(vo_w32_window, &r); + FillRect(dc, &r, vo_fs || vidmode ? blackbrush : colorbrush); + vo_w32_release_dc(vo_w32_window, dc); + } +} + //find out supported overlay pixelformats static uint32_t Directx_CheckOverlayPixelformats(void) { @@ -827,8 +775,6 @@ static uint32_t Directx_CheckPrimaryPixelformat(void) static int preinit(const char *arg) { - HINSTANCE hInstance = GetModuleHandle(NULL); - char exedir[MAX_PATH]; if(arg) { if(strstr(arg,"noaccel")) @@ -837,15 +783,6 @@ static int preinit(const char *arg) nooverlay = 1; } } - /*load icon from the main app*/ - if(GetModuleFileName(NULL,exedir,MAX_PATH)) - { - mplayericon = ExtractIcon( hInstance, exedir, 0 ); - } - if(!mplayericon)mplayericon=LoadIcon(NULL,IDI_APPLICATION); - mplayercursor = LoadCursor(NULL, IDC_ARROW); - monitor_rect.right=GetSystemMetrics(SM_CXSCREEN); - monitor_rect.bottom=GetSystemMetrics(SM_CYSCREEN); windowcolor = vo_colorkey; colorbrush = CreateSolidBrush(windowcolor); @@ -1037,10 +974,7 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin image_format = format; image_width = width; image_height = height; - d_image_width = d_width; - d_image_height = d_height; if(format != primary_image_format)nooverlay = 0; - window_aspect= (float)d_image_width / (float)d_image_height; /*release all directx objects*/ if (g_cc != NULL)g_cc->lpVtbl->Release(g_cc); @@ -1069,13 +1003,13 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin //create palette for 256 color mode if(image_format==IMGFMT_BGR8){ LPDIRECTDRAWPALETTE ddpalette=NULL; - char* palette=malloc(4*256); + LPPALETTEENTRY palette=calloc(256, sizeof(*palette)); int i; for(i=0; i<256; i++){ - palette[4*i+0] = ((i >> 5) & 0x07) * 255 / 7; - palette[4*i+1] = ((i >> 2) & 0x07) * 255 / 7; - palette[4*i+2] = ((i >> 0) & 0x03) * 255 / 3; - palette[4*i+3] = PC_NOCOLLAPSE; + palette[i].peRed = ((i >> 5) & 0x07) * 255 / 7; + palette[i].peGreen = ((i >> 2) & 0x07) * 255 / 7; + palette[i].peBlue = ((i >> 0) & 0x03) * 255 / 3; + palette[i].peFlags = PC_NOCOLLAPSE; } g_lpdd->lpVtbl->CreatePalette(g_lpdd,DDPCAPS_8BIT|DDPCAPS_INITIALIZE,palette,&ddpalette,NULL); g_lpddsPrimary->lpVtbl->SetPalette(g_lpddsPrimary,ddpalette); @@ -1126,7 +1060,7 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin // contrast [0, 20000] // hue [-180, 180] // saturation [0, 20000] -static uint32_t color_ctrl_set(char *what, int value) +static uint32_t color_ctrl_set(const char *what, int value) { uint32_t r = VO_NOTIMPL; DDCOLORCONTROL dcc; @@ -1163,7 +1097,7 @@ static uint32_t color_ctrl_set(char *what, int value) } //analoguous to color_ctrl_set -static uint32_t color_ctrl_get(char *what, int *value) +static uint32_t color_ctrl_get(const char *what, int *value) { uint32_t r = VO_NOTIMPL; DDCOLORCONTROL dcc; @@ -1203,7 +1137,6 @@ static int control(uint32_t request, void *data) case VOCTRL_GET_IMAGE: return get_image(data); case VOCTRL_QUERY_FORMAT: - last_rect.left = 0xDEADC0DE; // reset window position cache return query_format(*((uint32_t*)data)); case VOCTRL_DRAW_IMAGE: return put_image(data); @@ -1224,7 +1157,6 @@ static int control(uint32_t request, void *data) { if(vo_rootwin) vo_rootwin = 0; else vo_rootwin = 1; - last_rect.left = 0xDEADC0DE; // reset window position cache Directx_ManageDisplay(); } return VO_TRUE; @@ -1245,9 +1177,6 @@ static int control(uint32_t request, void *data) case VOCTRL_UPDATE_SCREENINFO: w32_update_xinerama_info(); return VO_TRUE; - case VOCTRL_RESET: - last_rect.left = 0xDEADC0DE; // reset window position cache - // fall-through intended }; return VO_NOTIMPL; } -- cgit v1.2.3 From 950003b0c376a4e5444f0449f719a19125725296 Mon Sep 17 00:00:00 2001 From: reimar Date: Tue, 21 Jun 2011 19:44:24 +0000 Subject: vo_gl: fix YUY2/YVYU colorspace mixup Second GL_YCBCR_MESA format is YVYU, not YUY2. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33694 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/gl_common.c | 4 +++- libvo/vo_gl.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'libvo') diff --git a/libvo/gl_common.c b/libvo/gl_common.c index cee413d3b3..eb12d79a74 100644 --- a/libvo/gl_common.c +++ b/libvo/gl_common.c @@ -297,7 +297,9 @@ int glFindFormat(uint32_t fmt, int *bpp, GLint *gl_texfmt, *gl_type = GL_UNSIGNED_BYTE; break; case IMGFMT_UYVY: - case IMGFMT_YUY2: + // IMGFMT_YUY2 would be more logical for the _REV format, + // but gives clearly swapped colors. + case IMGFMT_YVYU: *gl_texfmt = GL_YCBCR_MESA; *bpp = 16; *gl_format = GL_YCBCR_MESA; diff --git a/libvo/vo_gl.c b/libvo/vo_gl.c index f23d44ba64..24a10a9d94 100644 --- a/libvo/vo_gl.c +++ b/libvo/vo_gl.c @@ -1109,7 +1109,7 @@ query_format(uint32_t format) // ideally MPlayer should be fixed instead not to use Y800 when it has the choice if (!use_yuv && (format == IMGFMT_Y8 || format == IMGFMT_Y800)) return 0; - if (!use_ycbcr && (format == IMGFMT_UYVY || format == IMGFMT_YUY2)) + if (!use_ycbcr && (format == IMGFMT_UYVY || format == IMGFMT_YVYU)) return 0; if (many_fmts && glFindFormat(format, NULL, NULL, NULL, NULL)) -- cgit v1.2.3 From 06d830687d5c57f7d5016ae4d0fccaa7b6780bad Mon Sep 17 00:00:00 2001 From: reimar Date: Sat, 2 Jul 2011 22:59:40 +0000 Subject: cleanup: silence some clang warnings Cosmetics: vo_mpegpes.c: Fix strange space placement Avoids clang warning that =- might have been intended as -=. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33797 b3059339-0415-0410-9bf9-f77b7e298cf2 vo_jpeg: Use "const char *" type for paths. Fixes a clang warning due to sign mismatch when calling open(). git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33799 b3059339-0415-0410-9bf9-f77b7e298cf2 mga_template.c: Remove pointless and in addition incorrect cast. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33800 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/mga_template.c | 2 +- libvo/vo_jpeg.c | 4 ++-- libvo/vo_mpegpes.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'libvo') diff --git a/libvo/mga_template.c b/libvo/mga_template.c index bd71694326..6886ecd8f7 100644 --- a/libvo/mga_template.c +++ b/libvo/mga_template.c @@ -438,7 +438,7 @@ static int mga_init(int width,int height,unsigned int format){ mp_msg(MSGT_VO,MSGL_V,"[MGA] Using %d buffers.\n",mga_vid_config.num_frames); - frames[0] = (char*)mmap(0,mga_vid_config.frame_size*mga_vid_config.num_frames,PROT_WRITE,MAP_SHARED,f,0); + frames[0] = mmap(0,mga_vid_config.frame_size*mga_vid_config.num_frames,PROT_WRITE,MAP_SHARED,f,0); frames[1] = frames[0] + 1*mga_vid_config.frame_size; frames[2] = frames[0] + 2*mga_vid_config.frame_size; frames[3] = frames[0] + 3*mga_vid_config.frame_size; diff --git a/libvo/vo_jpeg.c b/libvo/vo_jpeg.c index cafaf1f2d4..15f29a293a 100644 --- a/libvo/vo_jpeg.c +++ b/libvo/vo_jpeg.c @@ -104,7 +104,7 @@ static int framenum = 0; * returns, everything went well. */ -static void jpeg_mkdir(char *buf, int verbose) { +static void jpeg_mkdir(const char *buf, int verbose) { struct stat stat_p; #ifndef __MINGW32__ @@ -176,7 +176,7 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, /* ------------------------------------------------------------------------- */ -static uint32_t jpeg_write(uint8_t * name, uint8_t * buffer) +static uint32_t jpeg_write(const char * name, uint8_t * buffer) { FILE *outfile; struct jpeg_compress_struct cinfo; diff --git a/libvo/vo_mpegpes.c b/libvo/vo_mpegpes.c index dc63579519..cae6278e8f 100644 --- a/libvo/vo_mpegpes.c +++ b/libvo/vo_mpegpes.c @@ -232,7 +232,7 @@ static void uninit(void) { if(ao_mpegpes_fd >= 0 && ao_mpegpes_fd != vo_mpegpes_fd) close(ao_mpegpes_fd); - ao_mpegpes_fd =- 1; + ao_mpegpes_fd = -1; if(vo_mpegpes_fd>=0){ close(vo_mpegpes_fd);vo_mpegpes_fd=-1;} } -- cgit v1.2.3