Nikolay Sivov : dxva2: Handle specified background color in VideoProcessBlt().

Alexandre Julliard julliard at winehq.org
Fri Nov 5 17:15:53 CDT 2021


Module: wine
Branch: master
Commit: d9957dd22792731cd249171c1ca236b7cbaace7b
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=d9957dd22792731cd249171c1ca236b7cbaace7b

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Fri Nov  5 13:21:14 2021 +0300

dxva2: Handle specified background color in VideoProcessBlt().

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/dxva2/main.c | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/dlls/dxva2/main.c b/dlls/dxva2/main.c
index 46f5a7af485..401b5cc976b 100644
--- a/dlls/dxva2/main.c
+++ b/dlls/dxva2/main.c
@@ -258,6 +258,26 @@ static BOOL intersect_rect(RECT *dest, const RECT *src1, const RECT *src2)
     return TRUE;
 }
 
+static D3DCOLOR video_processor_get_background_color(const DXVA2_AYUVSample16 *ayuv)
+{
+    float y, cb, cr;
+    BYTE r, g, b;
+
+    y = (ayuv->Y >> 8) - 16;
+    cb = (ayuv->Cb >> 8) - 128;
+    cr = (ayuv->Cr >> 8) - 128;
+
+    y = 255.0f * y / 219.0f;
+    cb = 255.0f * cb / 224.0f;
+    cr = 255.0f * cr / 224.0f;
+
+    r = y + 1.402 * cr;
+    g = y - 0.344 * cb - 0.714 * cr;
+    b = y + 1.772 * cb;
+
+    return D3DCOLOR_XRGB(r, g, b);
+}
+
 static HRESULT WINAPI video_processor_VideoProcessBlt(IDirectXVideoProcessor *iface, IDirect3DSurface9 *rt,
         const DXVA2_VideoProcessBltParams *params, const DXVA2_VideoSample *samples, UINT sample_count,
         HANDLE *complete_handle)
@@ -269,14 +289,19 @@ static HRESULT WINAPI video_processor_VideoProcessBlt(IDirectXVideoProcessor *if
 
     TRACE("%p, %p, %p, %p, %u, %p.\n", iface, rt, params, samples, sample_count, complete_handle);
 
+    if (params->BackgroundColor.Alpha != 0xffff)
+    {
+        WARN("Unexpected background alpha %#x.\n", params->BackgroundColor.Alpha);
+        return E_INVALIDARG;
+    }
+
     if (FAILED(hr = IDirect3DSurface9_GetDevice(rt, &device)))
     {
         WARN("Failed to get surface device, hr %#x.\n", hr);
         return hr;
     }
 
-    /* FIXME: use specified color */
-    IDirect3DDevice9_ColorFill(device, rt, NULL, 0);
+    IDirect3DDevice9_ColorFill(device, rt, &params->TargetRect, video_processor_get_background_color(&params->BackgroundColor));
 
     for (i = 0; i < sample_count; ++i)
     {




More information about the wine-cvs mailing list