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 decode_basic_feature.h 24 //! \brief Defines the common interface for decode badic feature 25 //! \details The decode basic 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_BASIC_FEATURE_H__ 29 #define __DECODE_BASIC_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 37 namespace decode { 38 39 class DecodeBasicFeature: public MediaFeature 40 { 41 public: 42 DecodeBasicFeature(DecodeAllocator *allocator, void *hwInterface, PMOS_INTERFACE osInterface); 43 virtual ~DecodeBasicFeature(); 44 45 //! 46 //! \brief Init decode basic parameter 47 //! \param [in] setting 48 //! Pointer to CodechalSetting 49 //! \return MOS_STATUS 50 //! MOS_STATUS_SUCCESS if success, else fail reason 51 //! 52 virtual MOS_STATUS Init(void *setting); 53 54 //! 55 //! \brief Update decode basic feature 56 //! \param [in] params 57 //! Pointer to DecoderParams 58 //! \return MOS_STATUS 59 //! MOS_STATUS_SUCCESS if success, else fail reason 60 //! 61 virtual MOS_STATUS Update(void *params); 62 63 //! 64 //! \brief Update decode dest surface 65 //! \param [in] destSurface 66 //! Decode render target from DDI 67 //! \return MOS_STATUS 68 //! MOS_STATUS_SUCCESS if success, else fail reason 69 //! 70 MOS_STATUS UpdateDestSurface(MOS_SURFACE &destSurface); 71 72 #ifdef _MMC_SUPPORTED 73 //! 74 //! \brief Set MMC state 75 //! \param [in] isMmcEnabled 76 //! Flag to indicate if the MMC is enabled 77 //! \return MOS_STATUS 78 //! MOS_STATUS_SUCCESS if success, else fail reason 79 //! SetMmcState(bool isMmcEnabled)80 MOS_STATUS SetMmcState(bool isMmcEnabled) 81 { 82 m_isMmcEnabled = isMmcEnabled; 83 return MOS_STATUS_SUCCESS; 84 } 85 #endif 86 87 //! 88 //! \brief Get MMC state 89 //! \return bool 90 //! Return true if MMC enabled 91 //! IsMmcEnabled()92 bool IsMmcEnabled() 93 { 94 #ifdef _MMC_SUPPORTED 95 return m_isMmcEnabled; 96 #else 97 return false; 98 #endif 99 } 100 101 uint32_t m_width = 0; //!< Frame width in luma samples 102 uint32_t m_height = 0; //!< Frame height in luma samples 103 uint16_t m_picWidthInMb = 0; //!< Picture Width in MB width count 104 uint16_t m_picHeightInMb = 0; //!< Picture Height in MB height count 105 106 uint32_t m_frameNum = 0; //!< Frame number, inc by each codec pipeline 107 bool m_secondField = false; //!< Indicates if current field is second field(bottom field) 108 uint16_t m_pictureCodingType = 0; //!< I, P, B or mixed frame 109 110 CODEC_PICTURE m_curRenderPic = {0}; //!< picture information of current render target 111 112 CODECHAL_STANDARD m_standard = CODECHAL_UNDEFINED; //!< Decode standard 113 CODECHAL_MODE m_mode = CODECHAL_UNSUPPORTED_MODE; //!< Decode mode 114 CODECHAL_FUNCTION m_codecFunction = CODECHAL_FUNCTION_INVALID; //!< Decode function 115 116 HCP_CHROMA_FORMAT_IDC m_chromaFormat = HCP_CHROMA_FORMAT_YUV420; //!< Chroma format(420, 422 etc) 117 uint8_t m_bitDepth = 8; //!< Bit depth 118 bool m_is10Bit = false; 119 120 uint32_t m_numSlices = 0; //!< [VLD mode] Number of slices to be decoded 121 122 MOS_SURFACE m_destSurface; //!< Decode render target 123 124 MOS_BUFFER m_resDataBuffer; //!< Decode input bitstream 125 uint32_t m_dataOffset = 0; 126 uint32_t m_dataSize = 0; //!< Size of the bitstream required on this picture 127 PMOS_SURFACE m_refFrameSurface = nullptr; //!< Handle of reference frame surface 128 uint32_t m_refSurfaceNum = 0; //!< Number of reference frame surface 129 130 bool m_reportFrameCrc = false; //!< Flag to indicate if report frame CRC 131 132 bool m_disableDecodeSyncLock = false; //!< Indicates if decode sync lock is disabled 133 134 bool m_setMarkerEnabled = false; //!< [SetMarker] Indicates whether or not SetMarker is enabled 135 PMOS_RESOURCE m_presSetMarker = nullptr; //!< [SetMarker] Resource for SetMarker 136 137 bool m_useDummyReference = false; //!< Indicates if use dummy reference 138 MOS_SURFACE m_dummyReference; //!< Dummy reference surface 139 CODECHAL_DUMMY_REFERENCE_STATUS m_dummyReferenceStatus = CODECHAL_DUMMY_REFERENCE_INVALID; //!< Indicate the status of dummy reference 140 constexpr static uint8_t m_invalidFrameIndex = 0xff; //!< Invalid frame index 141 constexpr static uint8_t m_maxFrameIndex = CODECHAL_NUM_UNCOMPRESSED_SURFACE_HEVC; //!< Max frame index 142 143 protected: 144 //! 145 //! \brief Set required bitstream size by each codec 146 //! \param [in] requiredSize 147 //! required size for current frame 148 //! \return MOS_STATUS 149 //! MOS_STATUS_SUCCESS if success, else fail reason 150 //! 151 virtual MOS_STATUS SetRequiredBitstreamSize(uint32_t requiredSize) = 0; 152 153 void * m_hwInterface = nullptr; 154 DecodeAllocator * m_allocator = nullptr; 155 PMOS_INTERFACE m_osInterface = nullptr; 156 157 #ifdef _MMC_SUPPORTED 158 bool m_isMmcEnabled = false; //!< Indicate MMC enabled for current picture 159 #endif 160 161 MEDIA_CLASS_DEFINE_END(decode__DecodeBasicFeature) 162 }; 163 164 }//decode 165 166 #endif // !__DECODE_BASIC_FEATURE_H__ 167