summaryrefslogtreecommitdiffstats
path: root/recipes-multimedia/libva/files/0010-Fix-failed-4k-video-wall-test-case-and-color-corrupt.patch
blob: 0100df770d2bb53fef7009428965ea0df732f4c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
From 7291ab5206c5e172c6c94dcfbe4f1bc258f3b7a5 Mon Sep 17 00:00:00 2001
From: WenshengZhang <wensheng.zhang@intel.com>
Date: Wed, 10 Jan 2024 14:08:37 +0800
Subject: [PATCH 10/12] Fix failed 4k video wall test case and color corruption
 of video composition

Fix failed 4k video wall test case from 16CH video only show 1CH output and
corruption observed on certain number of video composition when doing
sample_multi_transcode.

Upstream-Status: Backport [https://github.com/intel/media-driver/commit/38e14b1b97170b51586d00d1fa607e496b0c5825]
Signed-off-by: Lim, Siew Hoon <siew.hoon.lim@intel.com>
---
 .../common/vp/kdll/hal_kerneldll_next.h       |  1 +
 .../vp/hal/packet/vp_render_fc_kernel.cpp     |  7 ++
 .../common/vp/kdll/hal_kerneldll_next.c       | 70 +++++++++++--------
 .../linux/common/vp/ddi/ddi_vp_functions.cpp  | 20 ++----
 4 files changed, 55 insertions(+), 43 deletions(-)

diff --git a/media_common/agnostic/common/vp/kdll/hal_kerneldll_next.h b/media_common/agnostic/common/vp/kdll/hal_kerneldll_next.h
index 6447999b7..8e2ab371e 100644
--- a/media_common/agnostic/common/vp/kdll/hal_kerneldll_next.h
+++ b/media_common/agnostic/common/vp/kdll/hal_kerneldll_next.h
@@ -588,6 +588,7 @@ typedef struct tagKdll_FilterEntry
     Kdll_Scalingratio      ScalingRatio;
     Kdll_RenderMethod      RenderMethod;
     Kdll_SetCSCCoeffMethod SetCSCCoeffMode;
+    bool                   forceToTargetColorSpace;
 } Kdll_FilterEntry, *PKdll_FilterEntry;
 
 // Structure that defines a compositing filter
diff --git a/media_softlet/agnostic/common/vp/hal/packet/vp_render_fc_kernel.cpp b/media_softlet/agnostic/common/vp/hal/packet/vp_render_fc_kernel.cpp
index 8e982f67e..f8308fed1 100644
--- a/media_softlet/agnostic/common/vp/hal/packet/vp_render_fc_kernel.cpp
+++ b/media_softlet/agnostic/common/vp/hal/packet/vp_render_fc_kernel.cpp
@@ -775,6 +775,13 @@ MOS_STATUS VpRenderFcKernel::BuildFilter(
 
     for (i = 0; (i < (int)compParams->sourceCount) && (iMaxFilterSize > 0); i++)
     {
+        if (i > 0)
+        {
+            if (!RECT1_CONTAINS_RECT2(compParams->source[0].surf->rcDst, compParams->source[i].surf->rcDst))
+            {
+                pFilter->forceToTargetColorSpace = true;
+            }
+        }
         src = &compParams->source[i];
 
         //--------------------------------
diff --git a/media_softlet/agnostic/common/vp/kdll/hal_kerneldll_next.c b/media_softlet/agnostic/common/vp/kdll/hal_kerneldll_next.c
index d8f7d429a..151f3b039 100644
--- a/media_softlet/agnostic/common/vp/kdll/hal_kerneldll_next.c
+++ b/media_softlet/agnostic/common/vp/kdll/hal_kerneldll_next.c
@@ -2378,6 +2378,7 @@ bool KernelDll_SetupCSC(
     Kdll_CSC_Matrix  curr_matrix;
     Kdll_CSC_Matrix *matrix   = pCSC->Matrix;    // Color Space conversion matrix
     uint8_t *        matrixID = pCSC->MatrixID;  // CSC coefficient allocation table
+    bool forceToTargetColorSpace = false;
 
     // Clear all CSC matrices
     MOS_ZeroMemory(matrix, sizeof(pCSC->Matrix));
@@ -2395,6 +2396,10 @@ bool KernelDll_SetupCSC(
     //---------------------------------------------------------------//
     for (i = iFilterSize, pFilter = pSearchState->Filter; i > 0; i--, pFilter++)
     {
+        if (pFilter->forceToTargetColorSpace)
+        {
+            forceToTargetColorSpace = true;
+        }
         // Disable Procamp for all layers except Main Video
         // Disable Procamp if source is RGB
         if (pFilter->layer != Layer_MainVideo ||
@@ -2456,44 +2461,51 @@ bool KernelDll_SetupCSC(
     //---------------------------------------------------------------//
     if (sel_cspace == CSpace_Any)
     {
-        int cs;
-        for (cs = (CSpace_Any + 1); cs < CSpace_Count; cs++)
+        if (forceToTargetColorSpace)
         {
-            // Skip color spaces not in use
-            cspace = (VPHAL_CSPACE)cs;
-            if (!cspace_in_use[cspace])
-            {
-                continue;
-            }
-
-            // xvYCC and BT are treated as same for CSC considerations (BT.x to xvYCC.x matrix is I)
-            cspace = KernelDll_TranslateCspace(cspace);
-
-            // Count # of CS conversions and matrices
-            csc_count = 0;
-            for (i = iFilterSize, pFilter = pSearchState->Filter; i > 0; i--, pFilter++)
+            sel_cspace = out_cspace;
+        }
+        else
+        {
+            int cs;
+            for (cs = (CSpace_Any + 1); cs < CSpace_Count; cs++)
             {
-                // Ignore layers where the Color Space may be set in software (colorfill, palletized)
-                if (pFilter->cspace == CSpace_Any)
+                // Skip color spaces not in use
+                cspace = (VPHAL_CSPACE)cs;
+                if (!cspace_in_use[cspace])
                 {
                     continue;
                 }
 
-                // Check if CSC/PA is required
-                if (KernelDll_TranslateCspace(pFilter->cspace) != cspace ||
-                    pFilter->procamp != DL_PROCAMP_DISABLED)
+                // xvYCC and BT are treated as same for CSC considerations (BT.x to xvYCC.x matrix is I)
+                cspace = KernelDll_TranslateCspace(cspace);
+
+                // Count # of CS conversions and matrices
+                csc_count = 0;
+                for (i = iFilterSize, pFilter = pSearchState->Filter; i > 0; i--, pFilter++)
                 {
-                    csc_count++;
+                    // Ignore layers where the Color Space may be set in software (colorfill, palletized)
+                    if (pFilter->cspace == CSpace_Any)
+                    {
+                        continue;
+                    }
+
+                    // Check if CSC/PA is required
+                    if (KernelDll_TranslateCspace(pFilter->cspace) != cspace ||
+                        pFilter->procamp != DL_PROCAMP_DISABLED)
+                    {
+                        csc_count++;
+                    }
                 }
-            }
 
-            // Save best choice as requiring minimum number of CSC operations
-            if ((sel_csc_count < 0) ||                              // Initial value
-                (csc_count < sel_csc_count) ||                      // Minimum number of CSC operations
-                (csc_count == sel_csc_count && cs == main_cspace))  // Use main cspace as default if same CSC count
-            {
-                sel_cspace    = cspace;
-                sel_csc_count = csc_count;
+                // Save best choice as requiring minimum number of CSC operations
+                if ((sel_csc_count < 0) ||                              // Initial value
+                    (csc_count < sel_csc_count) ||                      // Minimum number of CSC operations
+                    (csc_count == sel_csc_count && cs == main_cspace))  // Use main cspace as default if same CSC count
+                {
+                    sel_cspace    = cspace;
+                    sel_csc_count = csc_count;
+                }
             }
         }
     }
diff --git a/media_softlet/linux/common/vp/ddi/ddi_vp_functions.cpp b/media_softlet/linux/common/vp/ddi/ddi_vp_functions.cpp
index 40d0b3fad..e60a6c69c 100644
--- a/media_softlet/linux/common/vp/ddi/ddi_vp_functions.cpp
+++ b/media_softlet/linux/common/vp/ddi/ddi_vp_functions.cpp
@@ -2115,9 +2115,8 @@ VAStatus DdiVpFunctions::SetBackgroundColorfill(
 {
     DDI_VP_FUNC_ENTER;
     DDI_VP_CHK_NULL(vpHalRenderParams, "nullptr vpHalRenderParams.", VA_STATUS_ERROR_INVALID_PARAMETER);
-    DDI_VP_CHK_NULL(vpHalRenderParams->pTarget[0],"nullptr pTarget[0].", VA_STATUS_ERROR_INVALID_PARAMETER);
 
-    if ((outBackGroundcolor >> 24) != 0 || vpHalRenderParams->pTarget[0]->ColorSpace == CSpace_sRGB)
+    if ((outBackGroundcolor >> 24) != 0)
     {
         if (vpHalRenderParams->pColorFillParams == nullptr)
         {
@@ -2126,18 +2125,11 @@ VAStatus DdiVpFunctions::SetBackgroundColorfill(
 
         DDI_VP_CHK_NULL(vpHalRenderParams->pColorFillParams, "nullptr pColorFillParams.", VA_STATUS_ERROR_UNKNOWN);
 
-        if (vpHalRenderParams->pTarget[0]->ColorSpace == CSpace_sRGB && (outBackGroundcolor >> 24) == 0)
-        {
-            // set color space for sRGB output
-            vpHalRenderParams->pColorFillParams->CSpace  = CSpace_sRGB;
-        }
-        else
-        {
-            // set background colorfill option
-            vpHalRenderParams->pColorFillParams->Color   = outBackGroundcolor;
-            vpHalRenderParams->pColorFillParams->bYCbCr  = false;
-            vpHalRenderParams->pColorFillParams->CSpace  = CSpace_sRGB;
-        }
+        // set background colorfill option
+        vpHalRenderParams->pColorFillParams->Color   = outBackGroundcolor;
+        vpHalRenderParams->pColorFillParams->bYCbCr  = false;
+        vpHalRenderParams->pColorFillParams->CSpace  = CSpace_sRGB;
+
     }
     else
     {
-- 
2.40.1