xref: /aosp_15_r20/external/intel-media-driver/media_softlet/agnostic/common/vp/hal/features/vp_filter.h (revision ba62d9d3abf0e404f2022b4cd7a85e107f48596f)
1 /*
2 * Copyright (c) 2018-2024, 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     vp_filter.h
24 //! \brief    Defines the common interface for vp filters
25 //!           this file is for the base interface which is shared by all features.
26 //!
27 #ifndef __VP_FILTER_H__
28 #define __VP_FILTER_H__
29 
30 #include <map>
31 #include "mos_defs.h"
32 #include "vp_pipeline_common.h"
33 #include "vp_sfc_common.h"
34 #include "vp_render_common.h"
35 #include "vp_utils.h"
36 #include "sw_filter.h"
37 #include "vp_feature_caps.h"
38 #include "vp_render_fc_types.h"
39 
40 namespace vp {
41 
42 #define ESR_LAYER_NUM       10
43 #define VPHAL_MAX_HDR_INPUT_LAYER 8
44 #define VPHAL_HDR_EOTF_1DLUT_POINT_NUMBER 256
45 #define VPHAL_HDR_OETF_1DLUT_POINT_NUMBER 256
46 #define VPHAL_HDR_OETF_1DLUT_WIDTH 16
47 #define VPHAL_HDR_OETF_1DLUT_HEIGHT 16
48 
49 class VpCmdPacket;
50 
51 class VpFilter
52 {
53 public:
54     VpFilter(
55         PVP_MHWINTERFACE vpMhwInterface);
56 
~VpFilter()57     virtual ~VpFilter() {};
58 
59     //!
60     //! \brief  Initialize the media filter, allocate required resources
61     //! \return MOS_STATUS
62     //!         MOS_STATUS_SUCCESS if success, else fail reason
63     //!
64     virtual MOS_STATUS Init() = 0;
65 
66     //!
67     //! \brief  Prepare the parameters for filter generation
68     //! \return MOS_STATUS
69     //!         MOS_STATUS_SUCCESS if success, else fail reason
70     //!
71     virtual MOS_STATUS Prepare() = 0;
72 
73     //!
74     //! \brief  Destroy the media Filter and release the resources
75     //! \return MOS_STATUS
76     //!         MOS_STATUS_SUCCESS if success, else fail reason
77     //!
78     virtual MOS_STATUS Destroy() = 0;
79 
80     //!
81     //! \brief  Get execute caps for this filter
82     //! \return VP_EXECUTE_CAPS
83     //!         return the caps of filters
84     //!
GetExecuteCaps()85     VP_EXECUTE_CAPS GetExecuteCaps()
86     {
87         return m_executeCaps;
88     }
89 
90     //!
91     //! \brief  Get current associated media Packet
92     //! \return MediaTask*
93     //!         return the media task pointer
94     //!
GetActivePacket()95     VpCmdPacket * GetActivePacket()
96     {
97         return m_packet;
98     }
99 
100     //!
101     //! \brief  Set current associated media Packet
102     //! \return MediaTask*
103     //!         return the media task pointer
104     //!
SetPacket(VpCmdPacket * packet)105     void SetPacket(VpCmdPacket* packet)
106     {
107         m_packet = packet;
108     }
109 
110     //!
111     //! \brief  Get current associated media Packet
112     //! \return MediaTask*
113     //!         return the media task pointer
114     //!
GetMhwInterface()115     PVP_MHWINTERFACE GetMhwInterface()
116     {
117         return m_pvpMhwInterface;
118     }
119 
120 protected:
121 
122     PVP_MHWINTERFACE      m_pvpMhwInterface = nullptr;   // vp HW interfaces
123     VP_EXECUTE_CAPS       m_executeCaps = {};        // Filter executed caps
124     PVPHAL_SURFACE        m_tempSurface = nullptr;   // Inter-Media surface for Filter temp output
125 
126     VpCmdPacket         * m_packet = nullptr;
127 
128 MEDIA_CLASS_DEFINE_END(vp__VpFilter)
129 };
130 
131 struct _SFC_SCALING_PARAMS
132 {
133     // Scaling parameters
134     uint32_t                        dwOutputFrameHeight;                        // Output Frame Height
135     uint32_t                        dwOutputFrameWidth;                         // Output Frame Width
136     uint32_t                        dwInputFrameHeight;                         // Input Frame Height
137     uint32_t                        dwInputFrameWidth;                          // Input Frame Width
138     MOS_FORMAT                      inputFrameFormat;                           // Input Frame Format
139 
140     bool                            bBilinearScaling;                           // true if bilinear scaling, otherwise avs scaling.
141     uint32_t                        dwSourceRegionHeight;                       // Source/Crop region height
142     uint32_t                        dwSourceRegionWidth;                        // Source/Crop region width
143     uint32_t                        dwSourceRegionVerticalOffset;               // Source/Crop region vertical offset
144     uint32_t                        dwSourceRegionHorizontalOffset;             // Source/Crop region horizontal offset
145     uint32_t                        dwScaledRegionHeight;                       // Scaled region height
146     uint32_t                        dwScaledRegionWidth;                        // Scaled region width
147     uint32_t                        dwScaledRegionVerticalOffset;               // Scaled region vertical offset
148     uint32_t                        dwScaledRegionHorizontalOffset;             // Scaled region horizontal offset
149     uint32_t                        dwTargetRectangleStartHorizontalOffset;     // Target rectangle start horizontal offset
150     uint32_t                        dwTargetRectangleEndHorizontalOffset;       // Target rectangle end horizontal offset
151     uint32_t                        dwTargetRectangleStartVerticalOffset;       // Target rectangle start vertical offset
152     uint32_t                        dwTargetRectangleEndVerticalOffset;         // Target rectangle end vertical offset
153     bool                            bRectangleEnabled;                          // Target rectangle enabled
154     float                           fAVSXScalingRatio;                          // X Scaling Ratio
155     float                           fAVSYScalingRatio;                          // Y Scaling Ratio
156 
157     SFC_COLORFILL_PARAMS            sfcColorfillParams;                         // Colorfill Params
158 
159     VPHAL_SCALING_MODE              sfcScalingMode;                             // Bilinear, Nearest, AVS and future extension (configured by AVS coefficients)
160     //Interlaced scaling parameters
161     uint32_t                        interlacedScalingType;
162     VPHAL_SAMPLE_TYPE               srcSampleType;
163     VPHAL_SAMPLE_TYPE               dstSampleType;
164     bool                            isDemosaicNeeded;                           // 0: demosaic is not needed; 1: demosaic is needed
165     bool                            b1stPassOfSfc2PassScaling;                  // 1st Pass of Sfc 2Pass Scaling
166 };
167 
168 struct _SFC_CSC_PARAMS
169 {
170     bool                            bCSCEnabled;                                 // CSC Enabled
171     bool                            isInputColorSpaceRGB;                        // 0: YUV color space, 1:RGB color space
172     bool                            bIEFEnable;                                  // IEF Enabled
173     bool                            bChromaUpSamplingEnable;                     // ChromaUpSampling
174     bool                            b8tapChromafiltering;                        // Enables 8 tap filtering for Chroma Channels
175     bool                            isDitheringNeeded;                           // 0: dithering is not needed; 1: dithering is needed
176     VPHAL_CSPACE                    inputColorSpace;                             // Input Color Space
177     MOS_FORMAT                      inputFormat;                                 // SFC Input Format
178     MOS_FORMAT                      outputFormat;                                // SFC Output Format
179     PVPHAL_IEF_PARAMS               iefParams;                                   // Vphal Params
180     uint32_t                        sfcSrcChromaSiting;                          // SFC Source Chroma Siting location
181     uint32_t                        chromaDownSamplingVerticalCoef;              // Chroma DownSampling Vertical Coeff
182     uint32_t                        chromaDownSamplingHorizontalCoef;            // Chroma DownSampling Horizontal Coeff
183     bool                            isFullRgbG10P709;                            // Whether output colorspace is DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709
184     bool                            isDemosaicNeeded;                            // 0: demosaic is not needed; 1: demosaic is needed
185 };
186 
187 struct _SFC_ROT_MIR_PARAMS
188 {
189     VPHAL_ROTATION                  rotationMode;                               // Rotation mode -- 0, 90, 180 or 270
190     uint32_t                        mirrorType;                               // Mirror Type -- vert/horiz
191     bool                            bMirrorEnable;                              // Mirror mode -- enable/disable
192 };
193 
194 struct _VEBOX_DN_PARAMS
195 {
196     bool                            bDnEnabled;
197     bool                            bChromaDenoise;                             // bEnableChroma && bEnableLuma
198     bool                            bAutoDetect;
199     float                           fDenoiseFactor;
200     VPHAL_NOISELEVEL                NoiseLevel;
201     bool                            bEnableHVSDenoise;
202     VPHAL_HVSDENOISE_PARAMS         HVSDenoise;
203     bool                            bProgressive;
204 };
205 
206 struct _VEBOX_STE_PARAMS
207 {
208     bool                            bEnableSTE;                                 // STE Enabled
209     uint32_t                        dwSTEFactor;
210 
211     bool                            bEnableSTD;                                 // STD alone Enabled
212     VPHAL_STD_PARAMS                STDParam;
213 };
214 
215 struct _VEBOX_DI_PARAMS
216 {
217     bool                            bDiEnabled;                                 // DI Enabled
218     VPHAL_SAMPLE_TYPE               sampleTypeInput;
219     bool                            b60fpsDi;
220     VPHAL_DI_MODE                   diMode;                                     //!< DeInterlacing mode
221     bool                            enableFMD;                                  //!< FMD
222     bool                            bSCDEnabled;                                //!< Scene change detection
223     bool                            bHDContent;
224     bool                            bEnableQueryVariance;                       //!< Query variance enable
225 };
226 
227 struct _VEBOX_ACE_PARAMS
228 {
229     bool                            bEnableACE;                                 // ACE Enabled
230     bool                            bAceLevelChanged;
231     uint32_t                        dwAceLevel;
232     uint32_t                        dwAceStrength;
233     bool                            bAceHistogramEnabled;
234     bool                            bEnableLACE;
235 };
236 
237 struct _VEBOX_TCC_PARAMS
238 {
239     bool                            bEnableTCC;                                 // TCC Enabled
240     uint8_t                         Red;
241     uint8_t                         Green;
242     uint8_t                         Blue;
243     uint8_t                         Cyan;
244     uint8_t                         Magenta;
245     uint8_t                         Yellow;
246 };
247 
248 struct _VEBOX_CGC_PARAMS
249 {
250     bool                                bEnableCGC;                                 // CGC Enabled
251     bool                                bBt2020ToRGB;                               // Bt2020 convert to sRGB
252     VPHAL_CSPACE                        inputColorSpace;
253     VPHAL_CSPACE                        outputColorSpace;
254     MOS_FORMAT                          inputFormat;
255     MOS_FORMAT                          outputFormat;
256     bool                                bExtendedSrcGamut;
257     bool                                bExtendedDstGamut;
258     VPHAL_GAMUT_MODE                    GCompMode;
259     uint32_t                            dwAttenuation;
260     float                               displayRGBW_x[4];
261     float                               displayRGBW_y[4];
262 };
263 
264 struct _VEBOX_PROCAMP_PARAMS
265 {
266     bool                            bEnableProcamp;                            // Procamp Enabled
267     float                           fBrightness;
268     float                           fContrast;
269     float                           fHue;
270     float                           fSaturation;
271 };
272 
273 struct _VEBOX_CSC_PARAMS
274 {
275     bool                            bCSCEnabled;                                 // CSC Enabled
276     VPHAL_CSPACE                    inputColorSpace;                             // Input Color Space
277     VPHAL_CSPACE                    outputColorSpace;                            // Input Color Space
278     MOS_FORMAT                      inputFormat;                                 // Input Format
279     MOS_FORMAT                      outputFormat;                                // Output Format
280     PVPHAL_ALPHA_PARAMS             alphaParams;                                 // Output Alpha Params
281     bool                            bypassCUS;                                   // Bypass Chroma up sampling
282     bool                            bypassCDS;                                   // Bypass Chroma down sampling
283     uint32_t                        chromaUpSamplingVerticalCoef;                // Chroma UpSampling Vertical Coeff
284     uint32_t                        chromaUpSamplingHorizontalCoef;              // Chroma UpSampling Horizontal Coeff
285     uint32_t                        chromaDownSamplingVerticalCoef;              // Chroma DownSampling Vertical Coeff
286     uint32_t                        chromaDownSamplingHorizontalCoef;            // Chroma DownSampling Horizontal Coeff
287 };
288 
289 struct _RENDER_CSC_PARAMS
290 {
291     uint32_t                        layer;
292     bool                            bCSCEnabled;                                 // CSC Enabled
293     VPHAL_CSPACE                    inputColorSpcase;                            // Input Color Space
294     VPHAL_CSPACE                    outputColorSpcase;                           // Input Color Space
295     MOS_FORMAT                      inputFormat;                                 // Input Format
296     MOS_FORMAT                      outputFormat;                                // Output Format
297     PVPHAL_ALPHA_PARAMS             alphaParams;                                 // Output Alpha Params
298     uint32_t                        inputChromaSetting;                          // Chroma setting
299 };
300 
301 struct _VEBOX_HDR_PARAMS
302 {
303     uint32_t                        uiMaxDisplayLum;       //!< Maximum Display Luminance
304     uint32_t                        uiMaxContentLevelLum;  //!< Maximum Content Level Luminance
305     VPHAL_HDR_MODE                  hdrMode;
306     VPHAL_CSPACE                    srcColorSpace;
307     VPHAL_CSPACE                    dstColorSpace;
308     MOS_FORMAT                      dstFormat;
309     HDR_STAGE                       stage;
310     uint32_t                        lutSize;
311     bool                            isFp16Enable;
312     PVPHAL_3DLUT_PARAMS             external3DLutParams;
313 };
314 
315 using SFC_SCALING_PARAMS    = _SFC_SCALING_PARAMS;
316 using PSFC_SCALING_PARAMS   = SFC_SCALING_PARAMS * ;
317 using SFC_CSC_PARAMS        = _SFC_CSC_PARAMS;
318 using PSFC_CSC_PARAMS       = SFC_CSC_PARAMS * ;
319 using SFC_ROT_MIR_PARAMS    = _SFC_ROT_MIR_PARAMS;
320 using PSFC_ROT_MIR_PARAMS   = SFC_ROT_MIR_PARAMS * ;
321 using VEBOX_DN_PARAMS       = _VEBOX_DN_PARAMS;
322 using PVEBOX_DN_PARAMS      = VEBOX_DN_PARAMS *;
323 using VEBOX_STE_PARAMS      = _VEBOX_STE_PARAMS;
324 using PVEBOX_STE_PARAMS     = VEBOX_STE_PARAMS *;
325 using VEBOX_DI_PARAMS       = _VEBOX_DI_PARAMS;
326 using PVEBOX_DI_PARAMS      = VEBOX_DI_PARAMS *;
327 using VEBOX_ACE_PARAMS      = _VEBOX_ACE_PARAMS;
328 using PVEBOX_ACE_PARAMS     = VEBOX_ACE_PARAMS *;
329 using VEBOX_TCC_PARAMS      = _VEBOX_TCC_PARAMS;
330 using PVEBOX_TCC_PARAMS     = VEBOX_TCC_PARAMS *;
331 using VEBOX_CGC_PARAMS      = _VEBOX_CGC_PARAMS;
332 using PVEBOX_CGC_PARAMS     = VEBOX_CGC_PARAMS *;
333 using VEBOX_PROCAMP_PARAMS  = _VEBOX_PROCAMP_PARAMS;
334 using PVEBOX_PROCAMP_PARAMS = VEBOX_PROCAMP_PARAMS *;
335 using VEBOX_CSC_PARAMS      = _VEBOX_CSC_PARAMS;
336 using PVEBOX_CSC_PARAMS     = VEBOX_CSC_PARAMS *;
337 
338 using KERNEL_ARGS = std::vector<KRN_ARG>;
339 using KERNEL_BTIS = std::map<uint32_t,uint32_t>;
340 using KERNEL_INDEX_ARG_MAP              = std::map<uint32_t,KRN_ARG>;
341 using MULTI_LAYERS_KERNEL_INDEX_ARG_MAP = std::map<uint32_t,KERNEL_INDEX_ARG_MAP>;
342 
343 struct _VEBOX_UPDATE_PARAMS
344 {
345     VEBOX_DN_PARAMS                 denoiseParams;
346     VP_EXECUTE_CAPS                 veboxExecuteCaps;
347     VpKernelID                      kernelId;
348 };
349 
350 using VEBOX_UPDATE_PARAMS                 = _VEBOX_UPDATE_PARAMS;
351 using PVEBOX_UPDATE_PARAMS                = VEBOX_UPDATE_PARAMS *;
352 using VEBOX_HDR_PARAMS                    = _VEBOX_HDR_PARAMS;
353 using PVEBOX_HDR_PARAMS                   = VEBOX_HDR_PARAMS *;
354 
355 struct _RENDER_HDR_3DLUT_CAL_PARAMS
356 {
357     uint32_t                        maxDisplayLum;       //!< Maximum Display Luminance
358     uint32_t                        maxContentLevelLum;  //!< Maximum Content Level Luminance
359     VPHAL_HDR_MODE                  hdrMode;
360     VpKernelID                      kernelId;
361     uint32_t                        threadWidth;
362     uint32_t                        threadHeight;
363     uint32_t                        localWidth;
364     uint32_t                        localHeight;
365     KERNEL_ARGS                     kernelArgs;
366     void                            Init();
367 };
368 
369 using RENDER_HDR_3DLUT_CAL_PARAMS  = _RENDER_HDR_3DLUT_CAL_PARAMS;
370 using PRENDER_HDR_3DLUT_CAL_PARAMS = RENDER_HDR_3DLUT_CAL_PARAMS *;
371 
372 struct _RENDER_DN_HVS_CAL_PARAMS
373 {
374     uint32_t                        qp;
375     uint32_t                        strength;
376     VPHAL_HVSDN_MODE                hvsMode;
377     VpKernelID                      kernelId;
378     uint32_t                        threadWidth;
379     uint32_t                        threadHeight;
380     KERNEL_ARGS                     kernelArgs;
381 };
382 
383 using RENDER_DN_HVS_CAL_PARAMS  = _RENDER_DN_HVS_CAL_PARAMS;
384 using PRENDER_DN_HVS_CAL_PARAMS = RENDER_DN_HVS_CAL_PARAMS *;
385 
386 struct _STATE_COPY_PARAMS
387 {
388     bool needed;
389     VpKernelID                      kernelId;
390 };
391 
392 using STATE_COPY_PARAMS = _STATE_COPY_PARAMS;
393 using PSTATE_COPY_PARAMS = STATE_COPY_PARAMS*;
394 
395 struct SR_LAYER_PARAMS
396 {
397     uint32_t                                          uLayerID;
398     KERNEL_ARGS                                       kernelArgs;
399     SurfaceIndex                                      outputSurface;
400     uint32_t                                          uWidth;
401     uint32_t                                          uHeight;
402     MOS_FORMAT                                        format;
403     std::string                                       sKernelName;
404     VpKernelID                                        kernelId;
405     SurfaceIndex                                      weightBuffer;
406     uint32_t                                          uWeightBufferSize;
407     uint32_t                                          uOutChannels;
408     uint32_t                                          uInChannels;
409     uint32_t                                          uWeightsPerChannel;
410 
411     SurfaceIndex                                      biasBuffer;
412     uint32_t                                          uBiasBufferSize;
413     SurfaceIndex                                      reluBuffer;
414     uint32_t                                          uReluBufferSize;
415 
416     uint32_t                                          uThreadWidth;
417     uint32_t                                          uThreadHeight;
418 
419     uint16_t                                          imgDim[2];
420     uint16_t                                          channelDim[2];
421 
422     float                                             reluValue;
423     uint16_t                                          relu;
424     uint16_t                                          addToOutput;
425 };
426 
427 struct CHROMA_LAYER_PARAMS
428 {
429     uint32_t                                          uLayerID;
430     KERNEL_ARGS                                       kernelArgs;
431     SurfaceIndex                                      inputSRYSurface;
432     SurfaceIndex                                      inputUSurface;
433     SurfaceIndex                                      inputVSurface;
434     SurfaceIndex                                      outputSurface;
435     uint16_t                                          kernelFormat;
436     float                                             fDeltaU;
437     float                                             fDeltaV;
438     float                                             fShiftU;
439     float                                             fShiftV;
440     float                                             fScaleX;
441     float                                             fScaleY;
442     float                                             fChromaScaleX;
443     float                                             fChromaScaleY;
444     float                                             original_x;
445     float                                             original_y;
446     float                                             fScaleRatioX;
447     float                                             fScaleRatioY;
448 
449     std::string                                       sKernelName;
450     VpKernelID                                        kernelId;
451 
452     uint32_t                                          uThreadWidth;
453     uint32_t                                          uThreadHeight;
454 };
455 
456 struct _RENDER_FC_PARAMS
457 {
458     VpKernelID              kernelId;
459     VP_COMPOSITE_PARAMS     compParams;
460 };
461 using RENDER_FC_PARAMS  = _RENDER_FC_PARAMS;
462 using PRENDER_FC_PARAMS = RENDER_FC_PARAMS *;
463 
464 
465 struct L0_FC_KERNEL_CONFIG
466 {
467     VPHAL_PERFTAG perfTag = VPHAL_NONE;
468 };
469 
470 struct L0_FC_KERNEL_PARAM
471 {
472     KERNEL_ARGS                  kernelArgs;
473     std::string                  kernelName;
474     VpKernelID                   kernelId;
475     uint32_t                     threadWidth;
476     uint32_t                     threadHeight;
477     uint32_t                     localWidth;
478     uint32_t                     localHeight;
479     KERNEL_ARG_INDEX_SURFACE_MAP kernelStatefulSurfaces;
480     L0_FC_KERNEL_CONFIG          kernelConfig;
481     void                         Init();
482 };
483 
484 using L0_FC_KERNEL_PARAMS = std::vector<L0_FC_KERNEL_PARAM>;
485 struct _RENDER_L0_FC_PARAMS
486 {
487     L0_FC_KERNEL_PARAMS fc_kernelParams = {};
488     void                Init();
489 };
490 using RENDER_L0_FC_PARAMS  = _RENDER_L0_FC_PARAMS;
491 using PRENDER_L0_FC_PARAMS = RENDER_L0_FC_PARAMS *;
492 
493 struct _RENDER_HDR_PARAMS
494 {
495     VpKernelID              kernelId;
496     VP_COMPOSITE_PARAMS     compParams;
497     uint32_t                uiMaxDisplayLum;       //!< Maximum Display Luminance
498     uint32_t                uiMaxContentLevelLum;  //!< Maximum Content Level Luminance
499     VPHAL_HDR_MODE          hdrMode;
500     VPHAL_CSPACE            srcColorSpace;
501     VPHAL_CSPACE            dstColorSpace;
502     uint32_t                threadWidth;
503     uint32_t                threadHeight;
504 
505 
506     VPHAL_HDR_CACHE_CNTL            SurfMemObjCtl;                  //!< Cache attributes
507     uint32_t                        uiSplitFramePortions = 1;       //!< Split Frame flag
508     bool                            bForceSplitFrame     = false;
509 
510     uint32_t                        uSourceCount;                                               //!< Number of sources
511     uint32_t                        uTargetCount;                                               //!< Number of targets
512     uint32_t                        uSourceBindingTableIndex[8];        //!< Binding Table Index
513     uint32_t                        uTargetBindingTableIndex[8];       //!< Binding Table Index
514     uint32_t                        dwSurfaceWidth;                                             //!< Record the input surface width of last HDR render
515     uint32_t                        dwSurfaceHeight;                                            //!< Record the input surface height of last HDR render
516     PVPHAL_COLORFILL_PARAMS         pColorFillParams;                                           //!< ColorFill - BG only
517 
518     VPHAL_HDR_LUT_MODE              LUTMode[VPHAL_MAX_HDR_INPUT_LAYER];         //!< LUT Mode
519     VPHAL_HDR_LUT_MODE              GlobalLutMode;                              //!< Global LUT mode control for debugging purpose
520 
521     uint32_t                        dwOetfSurfaceWidth;             //!< Gamma 1D LUT surface
522     uint32_t                        dwOetfSurfaceHeight;            //!< Gamma 1D LUT surface
523     uint32_t                        dwUpdateMask;                   //!< Coefficients Update Mask
524     uint32_t                        Cri3DLUTSize;                   //!< CRI 3D LUT surface
525 
526     VPHAL_SURFACE                   OETF1DLUTSurface[VPHAL_MAX_HDR_INPUT_LAYER];        //!< OETF 1D LUT surface
527     VPHAL_SURFACE                   CoeffSurface;                                       //!< CSC CCM Coeff surface
528 
529     uint16_t                        OetfSmpteSt2084[VPHAL_HDR_OETF_1DLUT_POINT_NUMBER];      //!< EOTF 1D LUT SMPTE ST2084
530 
531     uint8_t*                        pInput3DLUT;                                             //!< Input 3DLUT address for GPU generate 3DLUT
532 
533     const uint16_t                  *pHDRStageConfigTable = nullptr;
534 
535     HDRStageEnables                 StageEnableFlags[VPHAL_MAX_HDR_INPUT_LAYER];
536 
537     VPHAL_GAMMA_TYPE                EOTFGamma[VPHAL_MAX_HDR_INPUT_LAYER]; //!< EOTF
538     VPHAL_GAMMA_TYPE                OETFGamma[VPHAL_MAX_HDR_INPUT_LAYER]; //!< OETF
539     VPHAL_HDR_MODE                  HdrMode[VPHAL_MAX_HDR_INPUT_LAYER];   //!< Hdr Mode
540     VPHAL_HDR_CCM_TYPE              CCM[VPHAL_MAX_HDR_INPUT_LAYER];       //!< CCM Mode
541     VPHAL_HDR_CCM_TYPE              CCMExt1[VPHAL_MAX_HDR_INPUT_LAYER];   //!< CCM Ext1 Mode
542     VPHAL_HDR_CCM_TYPE              CCMExt2[VPHAL_MAX_HDR_INPUT_LAYER];   //!< CCM Ext2 Mode
543     VPHAL_HDR_CSC_TYPE              PriorCSC[VPHAL_MAX_HDR_INPUT_LAYER];  //!< Prior CSC Mode
544     VPHAL_HDR_CSC_TYPE              PostCSC[VPHAL_MAX_HDR_INPUT_LAYER];   //!< Post CSC Mode
545 
546     HDR_PARAMS                      HDRFrameTargetParams;
547     HDR_PARAMS                      HDRLastFrameSourceParams[VPHAL_MAX_HDR_INPUT_LAYER];
548     HDR_PARAMS                      HDRLastFrameTargetParams;
549 
550     STATUS_TABLE_UPDATE_PARAMS      StatusTableUpdateParams;                   //!< Status table, Video Pre-Processing Only
551 
552     bool                            bNeed3DSampler;                       //!< indicate whether 3D should neede by force considering AVS removal etc.
553 
554    VPHAL_ROTATION                   Rotation   = VPHAL_ROTATION_IDENTITY;  //!<  0: 0 degree, 1: 90 degree, 2: 180 degree, 3: 270 degreee
555    VPHAL_SCALING_MODE               ScalingMode = VPHAL_SCALING_NEAREST;    //!<  Scaling Mode
556    PVPHAL_IEF_PARAMS                pIEFParams;
557    HDR_PARAMS                       srcHDRParams[VPHAL_MAX_HDR_INPUT_LAYER];
558    HDR_PARAMS                       targetHDRParams[VPHAL_MAX_HDR_OUTPUT_LAYER];
559    bool                             bUsingAutoModePipe;  //!< Hdr Auto Mode pipe flag
560    uint16_t                         InputSrc[VPHAL_MAX_HDR_INPUT_LAYER] = {};  // Input Surface
561    uint16_t                         Target[VPHAL_MAX_HDR_OUTPUT_LAYER]  = {};  // Target Surface
562    bool                             bGpuGenerate3DLUT;                         //!< Flag for per frame GPU generation of 3DLUT
563    float                            f3DLUTNormalizationFactor;                 //!< Normalization factor for 3DLUT
564    bool                             bDisableAutoMode;                          //!< Force to disable Hdr auto mode tone mapping for debugging purpose
565    bool                             coeffAllocated     = false;
566    bool                             OETF1DLUTAllocated = false;
567    bool                             Cri3DLUTAllocated  = false;
568    PVPHAL_BLENDING_PARAMS           pBlendingParams    = nullptr;              //!< Blending parameters
569 };
570 using RENDER_HDR_PARAMS  = _RENDER_HDR_PARAMS;
571 using PRENDER_HDR_PARAMS = RENDER_HDR_PARAMS *;
572 
573 class SwFilterPipe;
574 class HwFilter;
575 class PacketParamFactoryBase;
576 
577 /////////////////////////////HwFilter Parameters///////////////////////////////////
578 class HwFilterParameter
579 {
580 public:
581     HwFilterParameter(FeatureType featureType);
582     virtual ~HwFilterParameter();
583     virtual MOS_STATUS ConfigParams(HwFilter &hwFilter) = 0;
584 
GetFeatureType()585     FeatureType GetFeatureType()
586     {
587         return m_FeatureType;
588     }
589 
590 private:
591     FeatureType m_FeatureType = FeatureTypeInvalid;
592 
593 MEDIA_CLASS_DEFINE_END(vp__HwFilterParameter)
594 };
595 
596 /////////////////////////////Packet Parameters///////////////////////////////////
597 
598 class VpPacketParameter
599 {
600 public:
601     VpPacketParameter(PacketParamFactoryBase *packetParamFactory);
602     virtual ~VpPacketParameter();
603 
604     static void Destory(VpPacketParameter *&p);
605 
606     virtual bool SetPacketParam(VpCmdPacket *pPacket) = 0;
607 
608 private:
609     PacketParamFactoryBase *m_packetParamFactory = nullptr;
610 
611 MEDIA_CLASS_DEFINE_END(vp__VpPacketParameter)
612 };
613 
614 /////////////////////////////Policy Feature Handler//////////////////////////////
615 
616 class PolicyFeatureHandler
617 {
618 public:
619     PolicyFeatureHandler(VP_HW_CAPS &hwCaps);
620     virtual ~PolicyFeatureHandler();
621     virtual bool IsFeatureEnabled(SwFilterPipe &swFilterPipe);
622     virtual HwFilterParameter *CreateHwFilterParam(VP_EXECUTE_CAPS vpExecuteCaps, SwFilterPipe &swFilterPipe, PVP_MHWINTERFACE pHwInterface);
623     virtual bool IsFeatureEnabled(VP_EXECUTE_CAPS vpExecuteCaps);
624     virtual MOS_STATUS UpdateFeaturePipe(VP_EXECUTE_CAPS caps, SwFilter &feature, SwFilterPipe &featurePipe, SwFilterPipe &executePipe, bool isInputPipe, int index);
625     virtual MOS_STATUS UpdateUnusedFeature(VP_EXECUTE_CAPS caps, SwFilter &feature, SwFilterPipe &featurePipe, SwFilterPipe &executePipe, bool isInputPipe, int index);
626     FeatureType GetType();
627     HwFilterParameter *GetHwFeatureParameterFromPool();
628     virtual MOS_STATUS ReleaseHwFeatureParameter(HwFilterParameter *&pParam);
629 protected:
630     FeatureType m_Type = FeatureTypeInvalid;
631     std::vector<HwFilterParameter *> m_Pool;
632     VP_HW_CAPS  &m_hwCaps;
633 
634 MEDIA_CLASS_DEFINE_END(vp__PolicyFeatureHandler)
635 };
636 
637 class PacketParamFactoryBase
638 {
639 public:
640     PacketParamFactoryBase();
641     virtual ~PacketParamFactoryBase();
642     virtual VpPacketParameter *GetPacketParameter(PVP_MHWINTERFACE pHwInterface) = 0;
643     void ReturnPacketParameter(VpPacketParameter *&p);
644 protected:
645     std::vector<VpPacketParameter *> m_Pool;
646 
647 MEDIA_CLASS_DEFINE_END(vp__PacketParamFactoryBase)
648 };
649 
650 template<class T>
651 class PacketParamFactory : public PacketParamFactoryBase
652 {
653 public:
PacketParamFactory()654     PacketParamFactory()
655     {
656     }
~PacketParamFactory()657     virtual ~PacketParamFactory()
658     {
659     }
GetPacketParameter(PVP_MHWINTERFACE pHwInterface)660     virtual VpPacketParameter *GetPacketParameter(PVP_MHWINTERFACE pHwInterface)
661     {
662         if (nullptr == pHwInterface)
663         {
664             return nullptr;
665         }
666         if (m_Pool.empty())
667         {
668             T *p = MOS_New(T, pHwInterface, this);
669             if (nullptr == p)
670             {
671                 return nullptr;
672             }
673 
674             VpPacketParameter *pBase = dynamic_cast<VpPacketParameter *>(p);
675 
676             if (nullptr == pBase)
677             {
678                 MOS_Delete(p);
679             }
680             return pBase;
681         }
682         else
683         {
684             VpPacketParameter *p = m_Pool.back();
685             m_Pool.pop_back();
686             return p;
687         }
688     }
689 
690 MEDIA_CLASS_DEFINE_END(vp__PacketParamFactory)
691 };
692 
693 struct HW_FILTER_PARAM
694 {
695     FeatureType             type;
696     PVP_MHWINTERFACE        pHwInterface;
697     VP_EXECUTE_CAPS         vpExecuteCaps;
698     PacketParamFactoryBase *pPacketParamFactory                     = nullptr;
699     VpPacketParameter*    (*pfnCreatePacketParam)(HW_FILTER_PARAM&) = nullptr;
700 };
701 }
702 
703 #endif // !__VP_FILTER_H__
704