Debian Codegraph @

media_softlet/agnostic/common/codec/hal/dec/shared/features/decode_downsampling_feature.h

raw
1 /*
2 * Copyright (c) 2020-2025, 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 decode_downsampling_feature.h
24 //! \brief Defines the common interface for decode downsampling feature
25 //! \details The decode downsampling feature interface is further sub-divided by codec standard,
26 //! this file is for the base interface which is shared by all codecs.
27 //!
28 #ifndef __DECODE_DOWNSAMPLING_FEATURE_H__
29 #define __DECODE_DOWNSAMPLING_FEATURE_H__
30
31 #include "codec_def_decode.h"
32 #include "decode_allocator.h"
33 #include "media_feature.h"
34 #include "codec_hw_next.h"
35 #include "codechal_setting.h"
36 #include "decode_internal_target.h"
37
38 #ifdef _DECODE_PROCESSING_SUPPORTED
39
40 namespace decode
41 {
42 class DecodeDownSamplingFeature: public MediaFeature
43 {
44 enum HistogramBufferType
45 {
46 HistogramY = 0,
47 HistogramU,
48 HistogramV,
49 HistogramStatistics,
50 HistogramStreamIn,
51 HistogramStreamOut,
52 HistogramStreamMax
53 };
54
55 public:
56 using SurfaceWidthT = decltype(MOS_SURFACE::dwWidth);
57 using SurfaceHeightT = decltype(MOS_SURFACE::dwHeight);
58
59 DecodeDownSamplingFeature(MediaFeatureManager *featureManager, DecodeAllocator *allocator, PMOS_INTERFACE osInterface);
60 virtual ~DecodeDownSamplingFeature();
61
62 //!
63 //! \brief Init decode basic parameter
64 //! \param [in] setting
65 //! Pointer to CodechalSetting
66 //! \return MOS_STATUS
67 //! MOS_STATUS_SUCCESS if success, else fail reason
68 //!
69 virtual MOS_STATUS Init(void *setting);
70
71 //!
72 //! \brief Update decode basic feature
73 //! \param [in] params
74 //! Pointer to DecoderParams
75 //! \return MOS_STATUS
76 //! MOS_STATUS_SUCCESS if success, else fail reason
77 //!
78 virtual MOS_STATUS Update(void *params);
79
80 virtual MOS_STATUS DumpSfcOutputs(CodechalDebugInterface* debugInterface);
81
82 virtual bool IsVDAQMHistogramEnabled() const { return m_aqmHistogramEnable; }
83
84 // Downsampling input
85 PMOS_SURFACE m_inputSurface = nullptr;
86 CodecRectangle m_inputSurfaceRegion = {};
87 uint32_t m_chromaSitingType = 0;
88
89 // Downsampling output
90 MOS_SURFACE m_outputSurface;
91 CodecRectangle m_outputSurfaceRegion = {};
92
93 // Downsampling parameters
94 uint32_t m_rotationState = 0;
95 uint32_t m_blendState = 0;
96 uint32_t m_mirrorState = 0;
97 bool m_isInputSurfAllocated = false;
98 bool m_isReferenceOnlyPattern = false;
99
100 CODECHAL_SCALING_MODE m_scalingMode = CODECHAL_SCALING_NEAREST;
101
102 // Histogram
103 PMOS_BUFFER m_histogramBuffer = nullptr; // SFC histogram internal buffer for current frame
104 PMOS_SURFACE m_histogramDestSurf = nullptr; // SFC histogram dest surface
105 bool m_histogramDebug = false;
106 const uint32_t m_histogramBinWidth = 4;
107
108 bool m_aqmHistogramEnable = false; // VDAQM histogram enabled
109 PMOS_BUFFER m_histogramBufferU = nullptr; // VDAQM histogram internal buffer for current frame
110 PMOS_SURFACE m_histogramDestSurfU = nullptr; // VDAQM histogram dest surface U
111 PMOS_BUFFER m_histogramBufferV = nullptr; // VDAQM histogram internal buffer for current frame
112 PMOS_SURFACE m_histogramDestSurfV = nullptr; // VDAQM histogram dest surface V
113 PMOS_BUFFER m_histogramStatisticsSummary = nullptr; // VDAQM histogram Statistics summary output address
114 PMOS_BUFFER m_histogramMetaDataStreamOut = nullptr; // VDAQM histogram Metadata streamout output
115 PMOS_BUFFER m_histogramMetaDataStreamIn = nullptr; // VDAQM histogram Metadata streamout input
116
117 #if (_DEBUG || _RELEASE_INTERNAL)
118 MOS_SURFACE m_outputSurfaceList[DecodeBasicFeature::m_maxFrameIndex] = {}; //! \brief Downsampled surfaces
119 #endif
120
121 protected:
122 virtual MOS_STATUS UpdateInternalTargets(DecodeBasicFeature &basicFeature);
123
124 virtual MOS_STATUS GetRefFrameList(std::vector<uint32_t> &refFrameList) = 0;
125 virtual MOS_STATUS GetDecodeTargetSize(SurfaceWidthT &width, SurfaceHeightT &height) = 0;
126 virtual MOS_STATUS GetDecodeTargetFormat(MOS_FORMAT &format) = 0;
127 virtual MOS_STATUS UpdateDecodeTarget(MOS_SURFACE &surface) = 0;
128 PMOS_BUFFER AllocateHistogramBuffer(uint8_t frameIndex, HistogramBufferType bufferType);
129 void FreeHistogramBuffer();
130
131 PMOS_INTERFACE m_osInterface = nullptr;
132 DecodeAllocator *m_allocator = nullptr;
133 DecodeBasicFeature *m_basicFeature = nullptr;
134
135 InternalTargets m_internalTargets; //!< Internal targets for downsampling input if application dosen't prepare
136 PMOS_BUFFER m_histogramBufferList[DecodeBasicFeature::m_maxFrameIndex] = {}; //! \brief Internal histogram output buffer list
137 PMOS_BUFFER m_histogramBufferUList[DecodeBasicFeature::m_maxFrameIndex] = {}; //! \brief Internal histogram U plane output buffer list
138 PMOS_BUFFER m_histogramBufferVList[DecodeBasicFeature::m_maxFrameIndex] = {}; //! \brief Internal histogram V plane output buffer list
139 PMOS_BUFFER m_histogramBufferStatisticsSummaryList[DecodeBasicFeature::m_maxFrameIndex] = {}; //! \brief Internal histogram statistics summary buffer list
140 PMOS_BUFFER m_histogramBufferMetaDataStreamInList[DecodeBasicFeature::m_maxFrameIndex] = {}; //! \brief Internal histogram stream in buffer list
141 PMOS_BUFFER m_histogramBufferMetaDataStreamOutList[DecodeBasicFeature::m_maxFrameIndex] = {}; //! \brief Internal histogram stream out buffer list
142
143 MEDIA_CLASS_DEFINE_END(decode__DecodeDownSamplingFeature)
144 };
145 }//decode
146
147 #endif // !_DECODE_PROCESSING_SUPPORTED
148
149 #endif // !__DECODE_DOWNSAMPLING_FEATURE_H__