xref: /aosp_15_r20/external/intel-media-driver/media_driver/agnostic/common/vp/kdll/hal_kerneldll.c (revision ba62d9d3abf0e404f2022b4cd7a85e107f48596f)
1 /*
2 * Copyright (c) 2008-2017, Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 */
22 //!
23 //! \file      hal_kerneldll.c
24 //! \brief         Kernel Dynamic Linking / Loading routines
25 //!
26 #ifndef VPHAL_LIB
27 
28 #if IMOLA
29 #include <stdlib.h>
30 #endif // IMOLA
31 #include <math.h> //for sin & cos
32 #endif  // VPHAL_LIB
33 
34 #if EMUL || VPHAL_LIB
35 #include <math.h>
36 #include "support.h"
37 #elif LINUX
38 #else  // !(EMUL | VPHAL_LIB) && !LINUX
39 
40 #endif // EMUL | VPHAL_LIB
41 
42 #include "hal_kerneldll.h"
43 #include "vphal.h"
44 
45 // Define _DEBUG symbol for KDLL Release build before loading the "vpkrnheader.h" file
46 // This is necessary for full kernels names in both Release/Debug versions of KDLL app
47 #if EMUL || VPHAL_LIB
48 #ifndef _DEBUG
49 #define _DEBUG 2
50 #endif // _DEBUG
51 #endif // EMUL || VPHAL_LIB
52 
53 // Kernel IDs and Kernel Names
54 #include "vpkrnheader.h" // IDR_VP_TOTAL_NUM_KERNELS
55 
56 // Undefine _DEBUG symbol for the remaining of the KDLL Release build
57 #if _DEBUG == 2
58 #undef _DEBUG
59 #endif // _DEBUG
60 
61 
62 #ifdef __cplusplus
63 extern "C" {
64 #endif // __cplusplus
65 
66 
67 
68 const float g_cCSC_GrayIdentity[12] =
69 {
70     1.0f,  0.0f, 0.0f, 0.000f,
71     0.0f,  0.0f, 0.0f, 128.0f,
72     0.0f,  0.0f, 0.0f, 128.0f
73 };
74 
75 const char  *g_cInit_ComponentNames[] =
76 {
77     IDR_VP_KERNEL_NAMES
78 };
79 
80 #if _DEBUG || EMUL || VPHAL_LIB
81 
82 #ifndef VPHAL_LIB
83 #pragma warning( push )
84 #pragma warning( disable : 4996 )
85 #endif // VPHAL_LIB
86 
KernelDll_GetLayerString(Kdll_Layer layer)87 const char    *KernelDll_GetLayerString(Kdll_Layer layer)
88 {
89     switch (layer)
90     {
91         case Layer_Invalid     : return _T("Invalid");
92         case Layer_None        : return _T("None");
93         case Layer_Background  : return _T("Background");
94         case Layer_MainVideo   : return _T("Main Video");
95         case Layer_SubVideo    : return _T("Sub-Video");
96         case Layer_SubPicture1 : return _T("Sub-Picture 1");
97         case Layer_SubPicture2 : return _T("Sub-Picture 2");
98         case Layer_SubPicture3 : return _T("Sub-Picture 3");
99         case Layer_SubPicture4 : return _T("Sub-Picture 4");
100         case Layer_Graphics    : return _T("Graphics");
101         case Layer_RenderTarget: return _T("Render Target");
102     }
103 
104     return nullptr;
105 }
106 
KernelDll_GetFormatString(MOS_FORMAT format)107 const char    *KernelDll_GetFormatString(MOS_FORMAT   format)
108 {
109     switch (format)
110     {
111         case Format_Invalid     : return _T("Invalid");
112         case Format_Source      : return _T("Current layer");
113         case Format_RGB         : return _T("RGB");
114         case Format_RGB32       : return _T("RGB32");
115         case Format_PA          : return _T("PA");
116         case Format_PL2         : return _T("PL2");
117         case Format_PL3         : return _T("PL3");
118         case Format_PL3_RGB     : return _T("PL3_RGB");
119         case Format_PAL         : return _T("PAL");
120         case Format_None        : return _T("None");
121         case Format_Any         : return _T("Any");
122         case Format_A8R8G8B8    : return _T("ARGB");
123         case Format_X8R8G8B8    : return _T("RGB");
124         case Format_A8B8G8R8    : return _T("ABGR");
125         case Format_X8B8G8R8    : return _T("BGR");
126         case Format_A16B16G16R16: return _T("A16B16G16R16");
127         case Format_A16R16G16B16: return _T("A16R16G16B16");
128         case Format_R5G6B5      : return _T("RGB16");
129         case Format_R8G8B8      : return _T("RGB24");
130         case Format_R32U        : return _T("R32U");
131         case Format_R32F        : return _T("R32F");
132         case Format_RGBP        : return _T("RGBP");
133         case Format_BGRP        : return _T("BGRP");
134         case Format_YUY2        : return _T("YUY2");
135         case Format_YUYV        : return _T("YUYV");
136         case Format_YVYU        : return _T("YVYU");
137         case Format_UYVY        : return _T("UYVY");
138         case Format_VYUY        : return _T("VYUY");
139         case Format_Y416        : return _T("Y416");
140         case Format_AYUV        : return _T("AYUV");
141         case Format_AUYV        : return _T("AUYV");
142         case Format_400P        : return _T("400P");
143         case Format_NV12        : return _T("NV12");
144         case Format_NV12_UnAligned: return _T("NV12_UnAligned");
145         case Format_NV21        : return _T("NV21");
146         case Format_NV11        : return _T("NV11");
147         case Format_NV11_UnAligned: return _T("NV11_UnAligned");
148         case Format_P208        : return _T("P208");
149         case Format_P208_UnAligned: return _T("P208_UnAligned");
150         case Format_IMC1        : return _T("IMC1");
151         case Format_IMC2        : return _T("IMC2");
152         case Format_IMC3        : return _T("IMC3");
153         case Format_IMC4        : return _T("IMC4");
154         case Format_422H        : return _T("422H");
155         case Format_422V        : return _T("422V");
156         case Format_444P        : return _T("444P");
157         case Format_411P        : return _T("411P");
158         case Format_411R        : return _T("411R");
159         case Format_I420        : return _T("I420");
160         case Format_IYUV        : return _T("IYUV");
161         case Format_YV12        : return _T("YV12");
162         case Format_YVU9        : return _T("YVU9");
163         case Format_AI44        : return _T("AI44");
164         case Format_IA44        : return _T("IA44");
165         case Format_P8          : return _T("P8");
166         case Format_A8P8        : return _T("A8P8");
167         case Format_A8          : return _T("A8");
168         case Format_L8          : return _T("L8");
169         case Format_A4L4        : return _T("A4L4");
170         case Format_A8L8        : return _T("A8L8");
171         case Format_IRW0        : return _T("IRW0");
172         case Format_IRW1        : return _T("IRW1");
173         case Format_IRW2        : return _T("IRW2");
174         case Format_IRW3        : return _T("IRW3");
175         case Format_IRW4        : return _T("IRW4");
176         case Format_IRW5        : return _T("IRW5");
177         case Format_IRW6        : return _T("IRW6");
178         case Format_IRW7        : return _T("IRW7");
179         case Format_STMM        : return _T("STMM");
180         case Format_Buffer      : return _T("Buffer");
181         case Format_Buffer_2D   : return _T("Buffer_2D");
182         case Format_V8U8        : return _T("V8U8");
183         case Format_R32S        : return _T("R32S");
184         case Format_R8U         : return _T("RU8");
185         case Format_R8G8UN      : return _T("R8G8UN");
186         case Format_R8G8SN      : return _T("R8S8UN");
187         case Format_G8R8_G8B8   : return _T("G8R8_G8B8");
188         case Format_R16U        : return _T("R16U");
189         case Format_R16S        : return _T("R16S");
190         case Format_R16UN       : return _T("R16UN");
191         case Format_RAW         : return _T("RAW");
192         case Format_Y8          : return _T("Y8");
193         case Format_Y1          : return _T("Y1");
194         case Format_Y16U        : return _T("Y16U");
195         case Format_Y16S        : return _T("Y16S");
196         case Format_L16         : return _T("L16");
197         case Format_D16         : return _T("D16");
198         case Format_R10G10B10A2 : return _T("R10G10B10A2");
199         case Format_B10G10R10A2 : return _T("B10G10R10A2");
200         case Format_P016        : return _T("P016");
201         case Format_P010        : return _T("P010");
202         case Format_YV12_Planar : return _T("YV12_Planar");
203         default                 : return _T("Invalid format");
204     }
205 
206     return nullptr;
207 }
208 
KernelDll_GetCSpaceString(VPHAL_CSPACE cspace)209 const char    *KernelDll_GetCSpaceString(VPHAL_CSPACE cspace)
210 {
211     switch (cspace)
212     {
213         case CSpace_None                : return _T("None");
214         case CSpace_Source              : return _T("Current layer");
215         case CSpace_RGB                 : return _T("RGB");
216         case CSpace_YUV                 : return _T("YUV");
217         case CSpace_Any                 : return _T("Any");
218         case CSpace_sRGB                : return _T("sRGB");
219         case CSpace_BT601               : return _T("BT.601");
220         case CSpace_BT601_FullRange     : return _T("BT.601_FullRange");
221         case CSpace_BT709               : return _T("BT.709");
222         case CSpace_BT709_FullRange     : return _T("BT.709_FullRange");
223         case CSpace_xvYCC601            : return _T("xvYCC.601");
224         case CSpace_xvYCC709            : return _T("xvYCC.709");
225         case CSpace_BT601Gray           : return _T("BT.601Gray");
226         case CSpace_BT601Gray_FullRange : return _T("BT.601Gray_FullRange");
227         default                         : return _T("Invalid cspace");
228     }
229 
230     return nullptr;
231 }
232 
KernelDll_GetSamplingString(Kdll_Sampling sampling)233 const char    *KernelDll_GetSamplingString(Kdll_Sampling sampling)
234 {
235     switch (sampling)
236     {
237         case Sample_None             : return _T("No Sampling");
238         case Sample_Source           : return _T("Current layer");
239         case Sample_Any              : return _T("Any Sampling");
240         case Sample_Scaling_Any      : return _T("Any Scale");
241         case Sample_Scaling          : return _T("Scale");
242         case Sample_Scaling_034x     : return _T("0.34x");
243         case Sample_Scaling_AVS      : return _T("AVS");
244         case Sample_iScaling         : return _T("iScale");
245         case Sample_iScaling_034x    : return _T("0.34x iScaling");
246         case Sample_iScaling_AVS     : return _T("iAVS");
247     }
248 
249     return nullptr;
250 }
251 
KernelDll_GetRotationString(VPHAL_ROTATION rotation)252 const char    *KernelDll_GetRotationString(VPHAL_ROTATION rotation)
253 {
254     switch (rotation)
255     {
256         case VPHAL_ROTATION_IDENTITY            : return _T("0");
257         case VPHAL_ROTATION_90                  : return _T("90");
258         case VPHAL_ROTATION_180                 : return _T("180");
259         case VPHAL_ROTATION_270                 : return _T("270");
260         case VPHAL_MIRROR_HORIZONTAL            : return _T("Horizontal");
261         case VPHAL_MIRROR_VERTICAL              : return _T("Vertical");
262         case VPHAL_ROTATE_90_MIRROR_VERTICAL    : return _T("90 Mirror Vertical");
263         case VPHAL_ROTATE_90_MIRROR_HORIZONTAL  : return _T("90 Mirror Horizontal");
264     }
265 
266     return nullptr;
267 }
268 
KernelDll_GetProcessString(Kdll_Processing process)269 const char    *KernelDll_GetProcessString(Kdll_Processing process)
270 {
271     switch (process)
272     {
273         case Process_None        : return _T("No processing");
274         case Process_Source      : return _T("Current layer");
275         case Process_Any         : return _T("Any processing");
276         case Process_Composite   : return _T("Composite");
277         case Process_XORComposite: return _T("XOR Mono Composite");
278         case Process_CBlend      : return _T("Const Blend");
279         case Process_SBlend      : return _T("Source Blend");
280         case Process_SBlend_4bits: return _T("Source Blend 4-bits");
281         case Process_PBlend      : return _T("Part Blend");
282         case Process_CSBlend     : return _T("ConstSource Blend");
283         case Process_CPBlend     : return _T("ConstPart Blend");
284         case Process_DI          : return _T("DI");
285         case Process_DN          : return _T("DN");
286         case Process_DNDI        : return _T("DNDI");
287     }
288 
289     return nullptr;
290 }
291 
292 
KernelDll_GetParserStateString(Kdll_ParserState state)293 const char    *KernelDll_GetParserStateString(Kdll_ParserState state)
294 {
295     switch (state)
296     {
297         case Parser_Invalid                 : return _T("Invalid");
298         case Parser_Begin                   : return _T("Begin");
299         case Parser_SetRenderMethod         : return _T("SetRenderMethod");
300         case Parser_SetupLayer0             : return _T("SetupLayer0");
301         case Parser_SetupLayer1             : return _T("SetupLayer1");
302         case Parser_SetParamsLayer0         : return _T("SetParamsLayer0");
303         case Parser_SetParamsLayer1         : return _T("SetParamsLayer1");
304         case Parser_SetParamsTarget         : return _T("SetParamsTarget");
305         case Parser_SampleLayer0            : return _T("SampleLayer0");
306         case Parser_SampleLayer0Mix         : return _T("SampleLayer0Mix");
307         case Parser_SampleLayer0ColorFill   : return _T("SampleLayer0ColorFill");
308         case Parser_RotateLayer0Check       : return _T("SampleRotateLayer0Check");
309         case Parser_RotateLayer0            : return _T("SampleRotateLayer0");
310         case Parser_SampleLayer0Done        : return _T("SampleLayer0Done");
311         case Parser_ShuffleLayer0           : return _T("ShuffleLayer0");
312         case Parser_SampleLayer1            : return _T("SampleLayer1");
313         case Parser_SampleLayer1Done        : return _T("SampleLayer1Done");
314         case Parser_ShuffleLayer1           : return _T("ShuffleLayer1");
315         case Parser_SampleLayer0SelectCSC   : return _T("SampleLayer0SelectCSC");
316         case Parser_SetupCSC0               : return _T("SetupCSC0");
317         case Parser_ExecuteCSC0             : return _T("ExecuteCSC0");
318         case Parser_ExecuteCSC0Done         : return _T("ExecuteCSC0Done");
319         case Parser_SetupCSC1               : return _T("SetupCSC1");
320         case Parser_ExecuteCSC1             : return _T("ExecuteCSC1");
321         case Parser_ExecuteCSC1Done         : return _T("ExecuteCSC1Done");
322         case Parser_Lumakey                 : return _T("LumaKey");
323         case Parser_ProcessLayer            : return _T("ProcessLayer");
324         case Parser_ProcessLayerDone        : return _T("ProcessLayerDone");
325         case Parser_DualOutput              : return _T("DualOutput");
326         case Parser_Rotation                : return _T("Rotation");
327         case Parser_DestSurfIndex           : return _T("DestSurfIndex");
328         case Parser_Colorfill               : return _T("Colorfill");
329         case Parser_WriteOutput             : return _T("WriteOutput");
330         case Parser_End                     : return _T("End");
331         default                             : return _T("Invalid parser state");
332     }
333 
334     return nullptr;
335 }
336 
KernelDll_GetRuleIDString(Kdll_RuleID RID)337 const char    *KernelDll_GetRuleIDString(Kdll_RuleID RID)
338 {
339     switch (RID)
340     {
341         case RID_Op_EOF             : return _T("EOF");
342         case RID_Op_NewEntry        : return _T("NewEntry");
343         case RID_IsTargetCspace     : return _T("IsTargetCspace");
344         case RID_IsLayerID          : return _T("IsLayerID");
345         case RID_IsLayerFormat      : return _T("IsLayerFormat");
346         case RID_IsParserState      : return _T("IsParserState");
347         case RID_IsRenderMethod     : return _T("IsRenderMethod");
348         case RID_IsShuffling        : return _T("IsShuffling");
349         case RID_IsLayerRotation    : return _T("IsLayerRotation");
350         case RID_IsSrc0Format       : return _T("IsSrc0Format");
351         case RID_IsSrc0Sampling     : return _T("IsSrc0Sampling");
352         case RID_IsSrc0ColorFill    : return _T("IsSrc0ColorFill");
353         case RID_IsSrc0LumaKey      : return _T("IsSrc0LumaKey");
354         case RID_IsSrc0Procamp      : return _T("IsSrc0Procamp");
355         case RID_IsSrc0Rotation     : return _T("IsSrc0Rotation");
356         case RID_IsSrc0Coeff        : return _T("IsSrc0Coeff");
357         case RID_IsSrc0Processing   : return _T("IsSrc0Processing");
358         case RID_IsSrc1Format       : return _T("IsSrc1Format");
359         case RID_IsSrc1Sampling     : return _T("IsSrc1Sampling");
360         case RID_IsSrc1LumaKey      : return _T("IsSrc1LumaKey");
361         case RID_IsSrc1SamplerLumaKey: return _T("IsSrc1SamplerLumaKey");
362         case RID_IsSrc1Coeff        : return _T("IsSrc1Coeff");
363         case RID_IsSrc1Processing   : return _T("IsSrc1Processing");
364         case RID_IsLayerNumber      : return _T("IsLayerNumber");
365         case RID_IsQuadrant         : return _T("IsQuadrant");
366         case RID_IsCSCBeforeMix     : return _T("IsCSCBeforeMix");
367         case RID_IsDualOutput       : return _T("IsDualOutput");
368         case RID_IsRTRotate         : return _T("IsRTRotate");
369         case RID_IsTargetFormat     : return _T("IsTargetFormat");
370         case RID_Is64BSaveEnabled   : return _T("Is64BSaveEnabled");
371         case RID_IsTargetTileType   : return _T("IsTargetTileType");
372         case RID_IsProcampEnabled   : return _T("IsProcampEnabled");
373         case RID_SetTargetCspace    : return _T("SetTargetCspace");
374         case RID_SetParserState     : return _T("SetParserState");
375         case RID_SetSrc0Format      : return _T("SetSrc0Format");
376         case RID_SetSrc0Sampling    : return _T("SetSrc0Sampling");
377         case RID_SetSrc0ColorFill   : return _T("SetSrc0ColorFill");
378         case RID_SetSrc0LumaKey     : return _T("SetSrc0LumaKey");
379         case RID_SetSrc0Rotation    : return _T("SetSrc0Rotation");
380         case RID_SetSrc0Coeff       : return _T("SetSrc0Coeff");
381         case RID_SetSrc0Processing  : return _T("SetSrc0Processing");
382         case RID_SetSrc1Format      : return _T("SetSrc1Format");
383         case RID_SetSrc1Sampling    : return _T("SetSrc1Sampling");
384         case RID_SetSrc1Rotation    : return _T("SetSrc1Rotation");
385         case RID_SetSrc1LumaKey     : return _T("SetSrc1LumaKey");
386         case RID_SetSrc1SamplerLumaKey: return _T("SetSrc1SamplerLumaKey");
387         case RID_SetSrc1Procamp     : return _T("SetSrc1Procamp");
388         case RID_SetSrc1Coeff       : return _T("SetSrc1Coeff");
389         case RID_SetSrc1Processing  : return _T("SetSrc1Processing");
390         case RID_SetKernel          : return _T("SetKernel");
391         case RID_SetNextLayer       : return _T("SetNextLayer");
392         case RID_SetPatchData       : return _T("SetPatchData");
393         case RID_SetQuadrant        : return _T("SetQuadrant");
394         case RID_SetCSCBeforeMix    : return _T("SetCSCBeforeMix");
395         case RID_SetPatch           : return _T("SetPatch");
396         case RID_IsSrc0Chromasiting : return _T("IsSrc0Chromasiting");
397         case RID_IsSrc1Procamp      : return _T("IsSrc1Procamp");
398         case RID_IsSrc1Chromasiting : return _T("IsSrc1Chromasiting");
399         case RID_IsSetCoeffMode     : return _T("IsSetCoeffMode");
400         case RID_IsConstOutAlpha    : return _T("IsConstOutAlpha");
401         case RID_IsDitherNeeded     : return _T("IsDitherNeeded");
402         case RID_IsScalingRatio     : return _T("IsScalingRatio");
403         case RID_SetSrc0Procamp     : return _T("SetSrc0Procamp");
404     }
405 
406     return nullptr;
407 }
408 
KernelDll_GetCoeffIDString(Kdll_CoeffID CID)409 const char    *KernelDll_GetCoeffIDString(Kdll_CoeffID CID)
410 {
411     switch (CID)
412     {
413         case CoeffID_Src0   : return _T("Src0 coeff");
414         case CoeffID_Src1   : return _T("Src1 coeff");
415         case CoeffID_Source : return _T("Current layer");
416         case CoeffID_Any    : return _T("Any coeff");
417         case CoeffID_None   : return _T("No coeff");
418         case CoeffID_0      : return _T("Coeff 0");
419         case CoeffID_1      : return _T("Coeff 1");
420         case CoeffID_2      : return _T("Coeff 2");
421         case CoeffID_3      : return _T("Coeff 3");
422         case CoeffID_4      : return _T("Coeff 4");
423         case CoeffID_5      : return _T("Coeff 5");
424     }
425 
426     return nullptr;
427 }
428 
KernelDll_GetShuffleString(Kdll_Shuffling shuffling)429 const char    *KernelDll_GetShuffleString(Kdll_Shuffling shuffling)
430 {
431     switch (shuffling)
432     {
433         case Shuffle_None          : return _T("None");
434         case Shuffle_Any           : return _T("Any");
435         case Shuffle_All_8x8_Layer : return _T("All 8x8 Layer");
436         case Shuffle_RenderTarget  : return _T("Render Target");
437     }
438 
439     return nullptr;
440 }
441 
KernelDll_PrintRule(char * szOut,int32_t iSize,const Kdll_RuleEntry * pEntry,Kdll_KernelCache * pCache)442 int32_t KernelDll_PrintRule(
443     char                    *szOut,
444     int32_t                 iSize,
445     const Kdll_RuleEntry    *pEntry,
446     Kdll_KernelCache        *pCache)
447 {
448     char    data[32];
449     int32_t increment   = 1;
450     const char *szRID   = KernelDll_GetRuleIDString(pEntry->id);
451     const char *szValue = nullptr;
452 
453     switch (pEntry->id)
454     {
455         case RID_IsParserState     :
456         case RID_SetParserState    :
457             szValue = KernelDll_GetParserStateString((Kdll_ParserState) pEntry->value);
458             break;
459 
460         case RID_IsLayerID         :
461             szValue = KernelDll_GetLayerString((Kdll_Layer) pEntry->value);
462             break;
463 
464         case RID_Op_NewEntry       :
465         case RID_Op_EOF            :
466         case RID_IsLayerNumber     :
467         case RID_IsQuadrant        :
468         case RID_SetQuadrant       :
469         case RID_SetPatchData      :
470             _stprintf(data, _T("%d"), pEntry->value);
471             szValue = data;
472             break;
473 
474         case RID_IsSrc0ColorFill   :
475         case RID_SetSrc0ColorFill  :
476             if (pEntry->value == ColorFill_Source)
477             {
478                 szValue = _T("Current Layer");
479             }
480             else if (pEntry->value)
481             {
482                 szValue = _T("TRUE");
483             }
484             else
485             {
486                 szValue = _T("FALSE");
487             }
488             break;
489 
490         case RID_IsSrc0LumaKey          :
491         case RID_IsSrc1LumaKey          :
492         case RID_SetSrc0LumaKey         :
493         case RID_SetSrc1LumaKey         :
494         case RID_IsSrc1SamplerLumaKey   :
495         case RID_SetSrc1SamplerLumaKey  :
496             if (pEntry->value == LumaKey_Source)
497             {
498                 szValue = _T("Current Layer");
499             }
500             else if (pEntry->value)
501             {
502                 szValue = _T("TRUE");
503             }
504             else
505             {
506                 szValue = _T("FALSE");
507             }
508             break;
509 
510         case RID_IsSrc0Procamp    :
511         case RID_IsSrc1Procamp    :
512         case RID_SetSrc0Procamp   :
513         case RID_SetSrc1Procamp   :
514             if (pEntry->value == Procamp_Source)
515             {
516                 szValue = _T("Current Layer");
517             }
518             else if (pEntry->value == DL_PROCAMP_DISABLED)
519             {
520                 szValue = _T("FALSE");
521             }
522             else
523             {
524                 szValue = _T("TRUE");
525             }
526             break;
527 
528         case RID_IsSrc0Chromasiting :
529         case RID_IsSrc1Chromasiting :
530             if (pEntry->value == DL_CHROMASITING_DISABLE)
531             {
532                 szValue = _T("FALSE");
533             }
534             else
535             {
536                 szValue = _T("TRUE");
537             }
538             break;
539 
540         case RID_SetKernel:
541             if (pCache && (pEntry->value < pCache->iCacheEntries))
542             {
543                 szValue = pCache->pCacheEntries[pEntry->value].szName;
544             }
545             else
546             {
547                 _stprintf(data, _T("%d"), pEntry->value);
548                 szValue = data;
549             }
550             break;
551 
552         case RID_SetNextLayer:
553             if (pEntry->value == 0)
554             {
555                 szValue = _T("Next Layer");
556             }
557             else if (pEntry->value == -1)
558             {
559                 szValue = _T("Previous Layer");
560             }
561             else if (pEntry->value == 2)
562             {
563                 szValue = _T("Target Layer");
564             }
565             else if (pEntry->value == -2)
566             {
567                 szValue = _T("Main Layer");
568             }
569             break;
570 
571         case RID_SetPatch          :
572             _stprintf(data, _T("%d patch entries"), pEntry->value);
573             increment += pEntry->value;
574             szValue = data;
575             break;
576 
577         case RID_IsLayerFormat     :
578         case RID_IsSrc0Format      :
579         case RID_IsSrc1Format      :
580         case RID_SetSrc0Format     :
581         case RID_SetSrc1Format     :
582         case RID_IsTargetFormat    :
583             szValue = KernelDll_GetFormatString((MOS_FORMAT  ) pEntry->value);
584             break;
585 
586         case RID_IsTargetCspace    :
587         case RID_SetTargetCspace   :
588             szValue = KernelDll_GetCSpaceString((VPHAL_CSPACE) pEntry->value);
589             break;
590 
591         case RID_IsSrc0Sampling    :
592         case RID_IsSrc1Sampling    :
593         case RID_SetSrc0Sampling   :
594         case RID_SetSrc1Sampling   :
595             szValue = KernelDll_GetSamplingString((Kdll_Sampling) pEntry->value);
596             break;
597 
598         case RID_IsSrc0Rotation   :
599             szValue = KernelDll_GetRotationString((VPHAL_ROTATION) pEntry->value);
600             break;
601 
602         case RID_IsShuffling       :
603             szValue = KernelDll_GetShuffleString((Kdll_Shuffling) pEntry->value);
604             break;
605 
606         case RID_IsSrc0Coeff       :
607         case RID_IsSrc1Coeff       :
608         case RID_SetSrc0Coeff      :
609         case RID_SetSrc1Coeff      :
610             szValue = KernelDll_GetCoeffIDString((Kdll_CoeffID) pEntry->value);
611             break;
612 
613         case RID_IsSrc1Processing  :
614         case RID_SetSrc1Processing :
615             szValue = KernelDll_GetProcessString((Kdll_Processing) pEntry->value);
616             break;
617 
618         case RID_IsCSCBeforeMix    :
619         case RID_SetCSCBeforeMix   :
620             if (pEntry->value)
621             {
622                 szValue = _T("TRUE");
623             }
624             else
625             {
626                 szValue = _T("FALSE");
627             }
628             break;
629 
630         case RID_Is64BSaveEnabled  :
631             if (pEntry->value)
632             {
633                 szValue = _T("TRUE");
634             }
635             else
636             {
637                 szValue = _T("FALSE");
638             }
639             break;
640 
641         default:
642             break;
643     }
644 
645     if (szRID && szValue)
646     {
647         _sntprintf(szOut, iSize, _T("%-22s %s"), szRID, szValue);
648     }
649     else if (szRID)
650     {
651         _sntprintf(szOut, iSize, _T("%-22s"), szRID);
652     }
653 
654     return increment;
655 }
656 
657 #ifndef VPHAL_LIB
658 #pragma warning( pop )
659 #endif // !VPHAL_LIB
660 
661 #endif // _DEBUG || EMUL || VPHAL_LIB
662 
663 /*----------------------------------------------------------------------------
664 | Name      : KernelDll_IsSameFormatType
665 | Purpose   : Check if 2 formats are similar
666 |
667 | Input     : Internal Format
668 |
669 | Return    : FourCC format
670 \---------------------------------------------------------------------------*/
KernelDll_IsSameFormatType(MOS_FORMAT format1,MOS_FORMAT format2)671 bool KernelDll_IsSameFormatType(MOS_FORMAT   format1, MOS_FORMAT   format2)
672 {
673     int32_t group1, group2;
674 
675     switch (format1)
676     {
677         CASE_PA_FORMAT:
678             group1 = 1;
679             break;
680 
681         CASE_PL2_FORMAT:
682             group1 = 2;
683             break;
684 
685         CASE_PL3_FORMAT:
686             group1 = 3;
687             break;
688 
689         CASE_RGB_FORMAT:
690             group1 = 4;
691             break;
692 
693         default:
694             group1 = 0;
695             break;
696     }
697 
698     switch (format2)
699     {
700         CASE_PA_FORMAT:
701             group2 = 1;
702             break;
703 
704         CASE_PL2_FORMAT:
705             group2 = 2;
706             break;
707 
708         CASE_PL3_FORMAT:
709             group2 = 3;
710             break;
711 
712         CASE_RGB_FORMAT:
713             group2 = 4;
714             break;
715 
716         default:
717             group2 = 0;
718             break;
719     }
720 
721     if (group1 == group2)
722     {
723         return true;
724     }
725     else
726     {
727         return false;
728     }
729 }
730 
731 //--------------------------------------------------------------
732 // Kerneldll_GetComponentKernel - Get component/static kernel
733 //                                entry from cache
734 //--------------------------------------------------------------
735 Kdll_CacheEntry *
KernelDll_GetComponentKernel(Kdll_State * pState,int32_t iKUID)736 KernelDll_GetComponentKernel(Kdll_State *pState,
737                              int32_t     iKUID)
738 {
739     Kdll_CacheEntry *pEntry = nullptr;
740 
741     if (iKUID < pState->ComponentKernelCache.iCacheMaxEntries)
742     {
743         pEntry = &(pState->ComponentKernelCache.pCacheEntries[iKUID]);
744         if (pEntry->iKUID != iKUID ||
745             pEntry->pBinary == nullptr ||
746             pEntry->iSize == 0)
747         {
748             pEntry = nullptr;
749         }
750     }
751 
752     return pEntry;
753 }
754 
755 #ifdef __cplusplus
756 }
757 #endif // __cplusplus