Index: libvo/vo_directx.c =================================================================== RCS file: /cvsroot/mplayer/main/libvo/vo_directx.c,v retrieving revision 1.38 diff -u -r1.38 vo_directx.c --- libvo/vo_directx.c 22 Sep 2004 16:26:53 -0000 1.38 +++ libvo/vo_directx.c 22 Oct 2004 09:40:29 -0000 @@ -18,6 +18,11 @@ * *****************************************************************************/ +/***************************************************************************** + * Changes made by Vitos Laszlo + * 2004.10.22 - added code for overlay color controls + *****************************************************************************/ + #include #include #include @@ -41,6 +46,7 @@ # define WM_XBUTTONDBLCLK 0x020D #endif +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 static LPDIRECTDRAWSURFACE7 g_lpddsOverlay = NULL; //Overlay Surface @@ -88,6 +94,11 @@ 0x15e65ec0,0x3b9c,0x11d2,{0xb9,0x2f,0x00,0x60,0x97,0x97,0xea,0x5b} }; +static const GUID IID_IDirectDrawColorControl = +{ + 0x4b9f0ee0,0x0d7e,0x11d0,{0x9b,0x06,0x00,0xa0,0xc9,0x03,0xa3,0xb8} +}; + typedef struct directx_fourcc_caps { char* img_format_name; //human readable name @@ -239,6 +250,11 @@ mp_msg(MSGT_VO, MSGL_FATAL,"can't get attached surface\n"); return 1; } + //try to get a color control interface + ddrval = g_lpddsOverlay->lpVtbl->QueryInterface(g_lpddsOverlay, &IID_IDirectDrawColorControl, &g_cc); + if (ddrval != DD_OK) { + mp_msg(MSGT_VO, MSGL_ERR, "Could not get IID_IDirectDrawColorControl interface! Overlay controls won't work..."); + } return 0; } vo_doublebuffering=0; //disable tribblebuffering @@ -286,6 +302,11 @@ return 1; } g_lpddsBack = g_lpddsOverlay; + //try to get a color control interface + ddrval = g_lpddsOverlay->lpVtbl->QueryInterface(g_lpddsOverlay, &IID_IDirectDrawColorControl, &g_cc); + if (ddrval != DD_OK) { + mp_msg(MSGT_VO, MSGL_ERR, "Could not get IID_IDirectDrawColorControl interface! Overlay controls won't work..."); + } return 0; } @@ -318,6 +339,10 @@ if (g_lpddsBack != NULL) g_lpddsBack->lpVtbl->Release(g_lpddsBack); g_lpddsBack = NULL; mp_msg(MSGT_VO, MSGL_DBG3,"back surface released\n"); + //clean up color control + if (g_cc != NULL) { + g_cc->lpVtbl->Release(g_cc); + } if(vo_doublebuffering && !nooverlay) { if (g_lpddsOverlay != NULL)g_lpddsOverlay->lpVtbl->Release(g_lpddsOverlay); @@ -1254,6 +1279,81 @@ return 0; } +//function to set color controls +// brightness [0, 10000] +// contrast [0, 20000] +// hue [-180, 180] +// saturation [0, 20000] +static uint32_t color_ctrl_set(char *what, int value) +{ + uint32_t r = VO_NOTIMPL; + DDCOLORCONTROL dcc; + //printf("\n*** %s = %d\n", what, value); + if (!g_cc) { + //printf("\n *** could not get color control interface!!!\n"); + return VO_NOTIMPL; + } + ZeroMemory(&dcc, sizeof(dcc)); + dcc.dwSize = sizeof(dcc); + + if (!strcmp(what, "brightness")) { + dcc.dwFlags = DDCOLOR_BRIGHTNESS; + dcc.lBrightness = (value + 100) * 10000 / 200; + r = VO_TRUE; + } else if (!strcmp(what, "contrast")) { + dcc.dwFlags = DDCOLOR_CONTRAST; + dcc.lContrast = (value + 100) * 20000 / 200; + r = VO_TRUE; + } else if (!strcmp(what, "hue")) { + dcc.dwFlags = DDCOLOR_HUE; + dcc.lHue = value * 180 / 100; + r = VO_TRUE; + } else if (!strcmp(what, "saturation")) { + dcc.dwFlags = DDCOLOR_SATURATION; + dcc.lSaturation = (value + 100) * 20000 / 200; + r = VO_TRUE; + } + + if (r == VO_TRUE) { + g_cc->lpVtbl->SetColorControls(g_cc, &dcc); + } + return r; +} + +//analoguous to color_ctrl_set +static uint32_t color_ctrl_get(char *what, int *value) +{ + uint32_t r = VO_NOTIMPL; + DDCOLORCONTROL dcc; + if (!g_cc) { + //printf("\n *** could not get color control interface!!!\n"); + return VO_NOTIMPL; + } + ZeroMemory(&dcc, sizeof(dcc)); + dcc.dwSize = sizeof(dcc); + dcc.dwFlags = DDCOLOR_BRIGHTNESS | DDCOLOR_CONTRAST | DDCOLOR_HUE | DDCOLOR_SATURATION; + if (g_cc->lpVtbl->GetColorControls(g_cc, &dcc) != DD_OK) { + return r; + } + + if (!strcmp(what, "brightness") && (dcc.dwFlags & DDCOLOR_BRIGHTNESS)) { + *value = dcc.lBrightness * 200 / 10000 - 100; + r = VO_TRUE; + } else if (!strcmp(what, "contrast") && (dcc.dwFlags & DDCOLOR_CONTRAST)) { + *value = dcc.lContrast * 200 / 20000 - 100; + r = VO_TRUE; + } else if (!strcmp(what, "hue") && (dcc.dwFlags & DDCOLOR_HUE)) { + *value = dcc.lHue * 100 / 180; + r = VO_TRUE; + } else if (!strcmp(what, "saturation") && (dcc.dwFlags & DDCOLOR_SATURATION)) { + *value = dcc.lSaturation * 200 / 20000 - 100; + r = VO_TRUE; + } + printf("\n*** %s = %d\n", what, *value); + + return r; +} + static uint32_t control(uint32_t request, void *data, ...) { switch (request) { @@ -1313,6 +1413,25 @@ } return VO_TRUE; } - }; + case VOCTRL_SET_EQUALIZER: { + va_list ap; + int value; + + va_start(ap, data); + value = va_arg(ap, int); + va_end(ap); + return color_ctrl_set(data, value); + } + //had to disable this one, because at first call it always returns 0 for all settings... why?? +/* case VOCTRL_GET_EQUALIZER: { + va_list ap; + int *value; + + va_start(ap, data); + value = va_arg(ap, int*); + va_end(ap); + return color_ctrl_get(data, value); + }*/ + }; return VO_NOTIMPL; }