Nikolay Sivov : evr/mixer: Pass valid background color parameter to VideoProcessBlt().

Alexandre Julliard julliard at winehq.org
Thu Nov 4 17:04:21 CDT 2021


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

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Thu Nov  4 17:58:44 2021 +0300

evr/mixer: Pass valid background color parameter to VideoProcessBlt().

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

---

 dlls/evr/mixer.c | 35 +++++++++++++++++++++++++++++++----
 1 file changed, 31 insertions(+), 4 deletions(-)

diff --git a/dlls/evr/mixer.c b/dlls/evr/mixer.c
index 3a2b6830782..2e03535fda3 100644
--- a/dlls/evr/mixer.c
+++ b/dlls/evr/mixer.c
@@ -95,7 +95,11 @@ struct video_mixer
     IMFAttributes *internal_attributes;
     unsigned int mixing_flags;
     unsigned int is_streaming;
-    COLORREF bkgnd_color;
+    struct
+    {
+        COLORREF rgba;
+        DXVA2_AYUVSample16 ayuv;
+    } bkgnd_color;
     LONGLONG lower_bound;
     LONGLONG upper_bound;
     CRITICAL_SECTION cs;
@@ -1277,7 +1281,6 @@ static void video_mixer_render(struct video_mixer *mixer, IDirect3DSurface9 *rt)
         zoom_rect.right = zoom_rect.bottom = 1.0f;
     }
 
-    SetRect(&params.TargetRect, 0, 0, rt_desc.Width, rt_desc.Height);
     video_mixer_scale_rect(&dst, rt_desc.Width, rt_desc.Height, &zoom_rect);
 
     for (i = 0; i < mixer->input_count; ++i)
@@ -1329,6 +1332,9 @@ static void video_mixer_render(struct video_mixer *mixer, IDirect3DSurface9 *rt)
 
     if (SUCCEEDED(hr))
     {
+        SetRect(&params.TargetRect, 0, 0, rt_desc.Width, rt_desc.Height);
+        params.BackgroundColor = mixer->bkgnd_color.ayuv;
+
         if (FAILED(hr = IDirectXVideoProcessor_VideoProcessBlt(mixer->processor, rt, &params, samples,
                 sample_count, NULL)))
         {
@@ -1983,12 +1989,28 @@ static HRESULT WINAPI video_mixer_processor_GetBackgroundColor(IMFVideoProcessor
         return E_POINTER;
 
     EnterCriticalSection(&mixer->cs);
-    *color = mixer->bkgnd_color;
+    *color = mixer->bkgnd_color.rgba;
     LeaveCriticalSection(&mixer->cs);
 
     return S_OK;
 }
 
+static void video_mixer_rgb_to_ycbcr(COLORREF rgb, DXVA2_AYUVSample16 *ayuv)
+{
+    int y, cb, cr, r, g, b;
+
+    r = GetRValue(rgb); g = GetGValue(rgb); b = GetBValue(rgb);
+    /* Coefficients according to SDTV ITU-R BT.601 */
+    y  = (77 * r + 150 * g +  29 * b + 128) / 256 + 16;
+    cb = (-44 * r - 87 * g + 131 * b + 128) / 256 + 128;
+    cr = (131 * r - 110 * g - 21 * b + 128) / 256 + 128;
+
+    ayuv->Y  = y * 0x100;
+    ayuv->Cb = cb * 0x100;
+    ayuv->Cr = cr * 0x100;
+    ayuv->Alpha = 0xffff;
+}
+
 static HRESULT WINAPI video_mixer_processor_SetBackgroundColor(IMFVideoProcessor *iface, COLORREF color)
 {
     struct video_mixer *mixer = impl_from_IMFVideoProcessor(iface);
@@ -1996,7 +2018,11 @@ static HRESULT WINAPI video_mixer_processor_SetBackgroundColor(IMFVideoProcessor
     TRACE("%p, %#x.\n", iface, color);
 
     EnterCriticalSection(&mixer->cs);
-    mixer->bkgnd_color = color;
+    if (mixer->bkgnd_color.rgba != color)
+    {
+        video_mixer_rgb_to_ycbcr(color, &mixer->bkgnd_color.ayuv);
+        mixer->bkgnd_color.rgba = color;
+    }
     LeaveCriticalSection(&mixer->cs);
 
     return S_OK;
@@ -2528,6 +2554,7 @@ HRESULT evr_mixer_create(IUnknown *outer, void **out)
     object->upper_bound = MFT_OUTPUT_BOUND_UPPER_UNBOUNDED;
     video_mixer_init_input(&object->inputs[0]);
     video_mixer_update_zorder_map(object);
+    video_mixer_rgb_to_ycbcr(object->bkgnd_color.rgba, &object->bkgnd_color.ayuv);
     InitializeCriticalSection(&object->cs);
     if (FAILED(hr = MFCreateAttributes(&object->attributes, 0)))
     {




More information about the wine-cvs mailing list