| 1 | /* |
| 2 | * Copyright (c) 2020-2021, 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_vp9_pipeline.h |
| 24 | //! \brief Defines the interface for vp9 decode pipeline |
| 25 | //! |
| 26 | #ifndef __DECODE_VP9_PIPELINE_H__ |
| 27 | #define __DECODE_VP9_PIPELINE_H__ |
| 28 | |
| 29 | #include "decode_pipeline.h" |
| 30 | #include "decode_vp9_basic_feature.h" |
| 31 | #include "decode_scalability_option.h" |
| 32 | #include "decode_phase.h" |
| 33 | |
| 34 | namespace decode { |
| 35 | |
| 36 | class Vp9Pipeline : public DecodePipeline |
| 37 | { |
| 38 | public: |
| 39 | enum Vp9DecodeMode |
| 40 | { |
| 41 | baseDecodeMode, //!< Legacy decode mode with single pipe |
| 42 | virtualTileDecodeMode, //!< virtual tile decode mode |
| 43 | }; |
| 44 | |
| 45 | //! |
| 46 | //! \brief Vp9Pipeline constructor |
| 47 | //! \param [in] hwInterface |
| 48 | //! Pointer to CodechalHwInterface |
| 49 | //! \param [in] debugInterface |
| 50 | //! Pointer to CodechalDebugInterface |
| 51 | //! |
| 52 | Vp9Pipeline( |
| 53 | CodechalHwInterfaceNext *hwInterface, |
| 54 | CodechalDebugInterface *debugInterface); |
| 55 | |
| 56 | virtual ~Vp9Pipeline() {}; |
| 57 | |
| 58 | Vp9DecodeMode GetDecodeMode(); |
| 59 | //! |
| 60 | //! \brief Declare Regkeys in the scope of vp9 decode |
| 61 | //! \return MOS_STATUS |
| 62 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 63 | virtual MOS_STATUS InitUserSetting(MediaUserSettingSharedPtr userSettingPtr) override; |
| 64 | |
| 65 | DeclareDecodePacketId(vp9SinglePacketId); |
| 66 | DeclareDecodePacketId(vp9FrontEndPacketId); |
| 67 | DeclareDecodePacketId(vp9BackEndPacketId); |
| 68 | DeclareDecodePacketId(vp9PictureSubPacketId); |
| 69 | DeclareDecodePacketId(vp9SliceSubPacketId); |
| 70 | DeclareDecodePacketId(vp9TileSubPacketId); |
| 71 | DeclareDecodePacketId(vp9DebugSubPacketId); |
| 72 | |
| 73 | protected: |
| 74 | //! |
| 75 | //! \brief Initialize the decode pipeline |
| 76 | //! \param [in] settings |
| 77 | //! Pointer to the initialize settings |
| 78 | //! \return MOS_STATUS |
| 79 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 80 | //! |
| 81 | virtual MOS_STATUS Initialize(void *settings) override; |
| 82 | |
| 83 | //! |
| 84 | //! \brief Uninitialize the decode pipeline |
| 85 | //! \return MOS_STATUS |
| 86 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 87 | //! |
| 88 | virtual MOS_STATUS Uninitialize() override; |
| 89 | |
| 90 | //! |
| 91 | //! \brief Prepare interal parameters, should be invoked for each frame |
| 92 | //! \param [in] params |
| 93 | //! Pointer to the input parameters |
| 94 | //! \return MOS_STATUS |
| 95 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 96 | //! |
| 97 | virtual MOS_STATUS Prepare(void *params) override; |
| 98 | |
| 99 | //! |
| 100 | //! \brief User Feature Key Report |
| 101 | //! \return MOS_STATUS |
| 102 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 103 | //! |
| 104 | virtual MOS_STATUS UserFeatureReport() override; |
| 105 | |
| 106 | //! |
| 107 | //! \brief Finish the execution for each frame |
| 108 | //! \return MOS_STATUS |
| 109 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 110 | //! |
| 111 | virtual MOS_STATUS Execute() override; |
| 112 | |
| 113 | //! |
| 114 | //! \brief create media feature manager |
| 115 | //! \return MOS_STATUS |
| 116 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 117 | //! |
| 118 | virtual MOS_STATUS CreateFeatureManager() override; |
| 119 | |
| 120 | //! |
| 121 | //! \brief Create sub packets |
| 122 | //! \param [in] codecSettings |
| 123 | //! Point to codechal settings |
| 124 | //! \return MOS_STATUS |
| 125 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 126 | //! |
| 127 | virtual MOS_STATUS CreateSubPackets(DecodeSubPacketManager& subPacketManager, CodechalSetting &codecSettings) override; |
| 128 | |
| 129 | //! |
| 130 | //! \brief Initialize context option |
| 131 | //! \param [in] basicFeature |
| 132 | //! VP9 decode basic feature |
| 133 | //! \return MOS_STATUS |
| 134 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 135 | //! |
| 136 | virtual MOS_STATUS InitContexOption(Vp9BasicFeature &basicFeature); |
| 137 | |
| 138 | //! |
| 139 | //! \brief Initialize VP9 decode mode |
| 140 | //! \param [in] scalabMode |
| 141 | //! Decode scalability mode |
| 142 | //! \return MOS_STATUS |
| 143 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 144 | //! |
| 145 | MOS_STATUS InitDecodeMode(ScalabilityMode scalabMode); |
| 146 | |
| 147 | //! |
| 148 | //! \brief Add one phase with pass number and pipe number |
| 149 | //! \param [in] pass |
| 150 | //! Pass number for phase |
| 151 | //! \param [in] pipe |
| 152 | //! Pipe number for phase |
| 153 | //! \param [in] activePipeNum |
| 154 | //! Acutive pipe number for current pass |
| 155 | //! \return MOS_STATUS |
| 156 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 157 | //! |
| 158 | template<typename T> |
| 159 | MOS_STATUS CreatePhase(uint8_t pass = 0, uint8_t pipe = 0, uint8_t activePipeNum = 1); |
| 160 | |
| 161 | //! |
| 162 | //! \brief Create VP9 decode phase list for current frame |
| 163 | //! \param [in] scalabMode |
| 164 | //! Decode scalability mode |
| 165 | //! \param [in] numPipe |
| 166 | //! Number of pipe for currently scalability mode |
| 167 | //! \return MOS_STATUS |
| 168 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 169 | //! |
| 170 | MOS_STATUS CreatePhaseList(const ScalabilityMode scalabMode, const uint8_t numPipe); |
| 171 | |
| 172 | //! |
| 173 | //! \brief Destroy Vp9 decode phase list |
| 174 | //! \return MOS_STATUS |
| 175 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 176 | //! |
| 177 | MOS_STATUS DestoryPhaseList(); |
| 178 | |
| 179 | #if USE_CODECHAL_DEBUG_TOOL |
| 180 | //! \brief Dump the picture parameters |
| 181 | //! |
| 182 | //! \param [in] picParams |
| 183 | //! Pointer to CodecAv1PicParams |
| 184 | //! |
| 185 | //! \return MOS_STATUS |
| 186 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 187 | //! |
| 188 | MOS_STATUS DumpPicParams(CODEC_VP9_PIC_PARAMS *picParams); |
| 189 | |
| 190 | //! \brief Dump segment parameters into file |
| 191 | //! |
| 192 | //! \param [in] segmentParams |
| 193 | //! Pointer to PCODEC_VP9_SEGMENT_PARAMS |
| 194 | //! |
| 195 | //! \return MOS_STATUS |
| 196 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 197 | //! |
| 198 | MOS_STATUS DumpSegmentParams(CODEC_VP9_SEGMENT_PARAMS *segmentParams); |
| 199 | |
| 200 | //! \brief Dump slice parameters into file |
| 201 | //! |
| 202 | //! \param [in] slcParams |
| 203 | //! Pointer to PCODEC_VP9_SLICE_PARAMS |
| 204 | //! |
| 205 | //! \return MOS_STATUS |
| 206 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 207 | //! |
| 208 | MOS_STATUS DumpSliceParams(CODEC_VP9_SLICE_PARAMS *slcParams); |
| 209 | #endif |
| 210 | |
| 211 | protected: |
| 212 | Vp9BasicFeature *m_basicFeature = nullptr; |
| 213 | Vp9DecodeMode m_decodeMode = baseDecodeMode; //!< Decode mode |
| 214 | |
| 215 | DecodeScalabilityOption m_scalabOption; //!< VP9 decode scalability option |
| 216 | |
| 217 | std::vector<DecodePhase *> m_phaseList; //!< Phase list |
| 218 | |
| 219 | #if (_DEBUG || _RELEASE_INTERNAL) |
| 220 | uint32_t m_vtFrameCount = 0; //!< frame count for virtual tile decoding |
| 221 | #endif |
| 222 | |
| 223 | MEDIA_CLASS_DEFINE_END(decode__Vp9Pipeline) |
| 224 | }; |
| 225 | |
| 226 | } |
| 227 | #endif // !__DECODE_VP9_PIPELINE_H__ |