Debian Codegraph @

media_driver/agnostic/common/vp/hal/vphal_render_hdr_g11.h

raw
1 /*
2 * Copyright (c) 2019, 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 vphal_render_hdr_g11.h
24 //! \brief Common interface and structure used in HDR for GEN11
25 //! \details Common interface and structure used in HDR for GEN11 Fixed Function Vebox 3DLut
26 //!
27 #ifndef __VPHAL_RENDER_HDR_G11_H__
28 #define __VPHAL_RENDER_HDR_G11_H__
29
30 #if !EMUL
31 #include "vphal_common.h"
32 #include "vphal_mdf_wrapper.h"
33
34 //!
35 //! \brief Tone Mapping Source Type, Please don't change the Enmu Value.
36 //! \details These Enmu Values are passed to media kernel for further processing.
37 //!
38 typedef enum _TONE_MAPPING_SOURCE_TYPE
39 {
40 TONE_MAPPING_SOURCE_NONE = 0,
41 TONE_MAPPING_SOURCE_RGB = 1,
42 TONE_MAPPING_SOURCE_PSEUDO_Y_BT2020 = 2,
43 TONE_MAPPING_SOURCE_FULL_Y_BT2020 = 3,
44 TONE_MAPPING_SOURCE_FULL_Y_BT709 = 4,
45 TONE_MAPPING_SOURCE_PSEUDO_Y_BT709 = 5
46 } TONE_MAPPING_SOURCE_TYPE;
47
48 //!
49 //! \brief Tone Mapping Mode.
50 //! \details These Enmu Values are passed to media kernel for further processing.
51 //!
52 typedef enum _TONE_MAPPING_MODE
53 {
54 TONE_MAPPING_MODE_H2H = 0,
55 TONE_MAPPING_MODE_H2S = 1,
56 TONE_MAPPING_MODE_H2E = 2
57 } TONE_MAPPING_MODE;
58
59 //!
60 //! \brief OETF Type.
61 //! \details These Enmu Values are passed to media kernel for further processing.
62 //!
63 typedef enum _OETF_CURVE_TYPE
64 {
65 OETF_CURVE_SDR_709 = 0,
66 OETF_CURVE_HDR_2084 = 1,
67 OETF_SRGB = 2
68 } OETF_CURVE_TYPE;
69
70 class Hdr3DLutCmRender : public VPCmRenderer
71 {
72 public:
73 struct Hdr3DLutPayload
74 {
75 VpCmSurfaceHolder<CmSurface2D> *hdr3DLutSurface;
76 VpCmSurfaceHolder<CmSurface2D> *hdrCoefSurface;
77 uint16_t hdr3DLutSurfaceWidth;
78 uint16_t hdr3DLutSurfaceHeight;
79 };
80
81 Hdr3DLutCmRender(uint32_t *kernelBinary, uint32_t kernelSize, CmContext *cmContext);
82 Hdr3DLutCmRender(const Hdr3DLutCmRender&) = delete;
83 Hdr3DLutCmRender& operator=(const Hdr3DLutCmRender&) = delete;
84 virtual ~Hdr3DLutCmRender();
85
86 private:
87 virtual void AttachPayload(void *payload);
88 virtual CmKernel *GetKernelToRun(std::string &name);
89 virtual void GetThreadSpaceDimension(int &tsWidth, int &tsHeight, int &tsColor);
90 virtual void PrepareKernel(CmKernel *kernel);
91
92 CmProgram *m_cmProgram = nullptr;
93 CmKernel *m_cmKernel = nullptr;
94 Hdr3DLutPayload *m_cmPayload = nullptr;
95 };
96
97 class Hdr3DLutGenerator
98 {
99 public:
100 explicit Hdr3DLutGenerator(PRENDERHAL_INTERFACE vphalRenderer, uint32_t *kernelBinary, uint32_t kernelSize);
101 Hdr3DLutGenerator(const Hdr3DLutGenerator &) = delete;
102 Hdr3DLutGenerator &operator=(const Hdr3DLutGenerator &) = delete;
103 virtual ~Hdr3DLutGenerator();
104
105 void Render(const uint32_t maxDLL, const uint32_t maxCLL, const VPHAL_HDR_MODE hdrMode, const PVPHAL_SURFACE p3DLutSurface);
106
107 private:
108 void AllocateResources();
109 void FreeResources();
110
111 void InitCoefSurface(const uint32_t maxDLL, const uint32_t maxCLL, const VPHAL_HDR_MODE hdrMode);
112 void Init3DLutSurface();
113
114 EventManager *m_eventManager = nullptr;
115
116 PRENDERHAL_INTERFACE m_renderHal = nullptr;
117 VpCmSurfaceHolder<CmSurface2D> *m_hdr3DLutSurface = nullptr;
118 VpCmSurfaceHolder<CmSurface2D> *m_hdrCoefSurface = nullptr;
119 Hdr3DLutCmRender *m_hdr3DLutCmRender = nullptr;
120 float *m_hdrcoefBuffer = nullptr;
121 uint8_t *m_hdr3DLutSysBuffer = nullptr;
122 CmContext *m_cmContext = nullptr;
123
124 bool m_bHdr3DLutInit = false;
125 uint32_t m_savedMaxDLL = 1000;
126 uint32_t m_savedMaxCLL = 4000;
127 VPHAL_HDR_MODE m_savedHdrMode = VPHAL_HDR_MODE_NONE;
128
129 // Default to 65^3
130 const uint32_t m_segSize = 65;
131 const uint32_t m_mulSize = 128;
132 const uint32_t m_lutSizeInBytes = m_segSize * m_segSize * m_mulSize * 4 * 2;
133
134 uint32_t* m_kernelBinary = nullptr;
135 uint32_t m_kernelSize = 0;
136 };
137 #else
138 #include "vphal_render_hdr.h"
139 class Hdr3DLutGenerator
140 {
141 public:
142 explicit Hdr3DLutGenerator(PRENDERHAL_INTERFACE vphalRenderer, uint32_t* kernelBinary, uint32_t kernelSize)
143 {
144 MOS_UNUSED(vphalRenderer);
145 MOS_UNUSED(kernelBinary);
146 MOS_UNUSED(kernelSize);
147 };
148
149 Hdr3DLutGenerator(const Hdr3DLutGenerator &) = delete;
150 Hdr3DLutGenerator &operator=(const Hdr3DLutGenerator &) = delete;
151 virtual ~Hdr3DLutGenerator() {};
152
153 void Render(const uint32_t maxDLL, const uint32_t maxCLL, const VPHAL_HDR_MODE hdrMode, const PVPHAL_SURFACE p3DLutSurface)
154 {
155 return ;
156 };
157 };
158 #endif
159 #endif // __VPHAL_RENDER_HDR_G11_H__