1 /* 2 * Copyright (c) 2020-2023, 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_avc_basic_feature.h 24 //! \brief Defines the common interface for decode avc basic feature 25 //! 26 #ifndef __DECODE_AVC_BASIC_FEATURE_H__ 27 #define __DECODE_AVC_BASIC_FEATURE_H__ 28 29 #include "decode_basic_feature.h" 30 #include "codec_def_decode_avc.h" 31 #include "codec_def_cenc_decode.h" 32 #include "decode_avc_reference_frames.h" 33 #include "decode_avc_mv_buffers.h" 34 35 namespace decode { 36 37 //! 38 //! \def DECODE_AVC_MONOPIC_CHROMA_DEFAULT 39 //! default chroma value for mono picture 40 //! 41 #define DECODE_AVC_MONOPIC_CHROMA_DEFAULT 0x80 42 43 class AvcBasicFeature : public DecodeBasicFeature 44 { 45 public: 46 //! 47 //! \brief AvcBasicFeature constructor 48 //! AvcBasicFeature(DecodeAllocator * allocator,void * hwInterface,PMOS_INTERFACE osInterface)49 AvcBasicFeature(DecodeAllocator *allocator, void *hwInterface, PMOS_INTERFACE osInterface) : 50 DecodeBasicFeature(allocator, hwInterface, osInterface) 51 { 52 if (osInterface != nullptr) 53 { 54 m_osInterface = osInterface; 55 } 56 }; 57 58 //! 59 //! \brief AvcBasicFeature deconstructor 60 //! 61 virtual ~AvcBasicFeature(); 62 63 //! 64 //! \brief Initialize avc basic feature CodechalSetting 65 //! \return MOS_STATUS 66 //! MOS_STATUS_SUCCESS if success, else fail reason 67 //! 68 virtual MOS_STATUS Init(void *setting) override; 69 70 //! 71 //! \brief Update avc decodeParams 72 //! \return MOS_STATUS 73 //! MOS_STATUS_SUCCESS if success, else fail reason 74 //! 75 virtual MOS_STATUS Update(void *params) override; 76 77 //! 78 //! \brief Get os interface 79 //! \return PMOS_INTERFACE 80 //! GetOsInterface()81 PMOS_INTERFACE GetOsInterface() 82 { 83 return m_osInterface; 84 } 85 86 //! 87 //! \brief Detect conformance conflict and do error concealment 88 //! \return MOS_STATUS 89 //! MOS_STATUS_SUCCESS if success, else show assert message 90 //! 91 MOS_STATUS ErrorDetectAndConceal(); 92 93 struct SliceRecord 94 { 95 uint32_t skip; 96 uint32_t offset; 97 uint32_t length; 98 uint32_t totalBytesConsumed; 99 }; 100 enum AvcSliceType 101 { 102 avcSliceP = 0, 103 avcSliceB = 1, 104 avcSliceI = 2 105 }; 106 const AvcSliceType AvcBsdSliceType[10] = 107 { 108 AvcSliceType::avcSliceP, 109 AvcSliceType::avcSliceB, 110 AvcSliceType::avcSliceI, 111 AvcSliceType::avcSliceP, 112 AvcSliceType::avcSliceI, 113 AvcSliceType::avcSliceP, 114 AvcSliceType::avcSliceB, 115 AvcSliceType::avcSliceI, 116 AvcSliceType::avcSliceP, 117 AvcSliceType::avcSliceI 118 }; 119 IsAvcPSlice(uint8_t sliceType)120 bool IsAvcPSlice(uint8_t sliceType) 121 { 122 return (sliceType < MHW_ARRAY_SIZE(AvcBsdSliceType)) ? (AvcBsdSliceType[sliceType] == avcSliceP) : false; 123 } IsAvcBSlice(uint8_t sliceType)124 bool IsAvcBSlice(uint8_t sliceType) 125 { 126 return (sliceType < MHW_ARRAY_SIZE(AvcBsdSliceType)) ? (AvcBsdSliceType[sliceType] == avcSliceB) : false; 127 } IsAvcISlice(uint8_t sliceType)128 bool IsAvcISlice(uint8_t sliceType) 129 { 130 return (sliceType < MHW_ARRAY_SIZE(AvcBsdSliceType)) ? (AvcBsdSliceType[sliceType] == avcSliceI) : false; 131 } 132 133 enum AvcQmTypes 134 { 135 avcQmIntra4x4 = 0, 136 avcQmInter4x4 = 1, 137 avcQmIntra8x8 = 2, 138 avcQmInter8x8 = 3 139 }; 140 141 142 PCODEC_AVC_PIC_PARAMS m_avcPicParams = nullptr; //!< Pointer to AVC picture parameter 143 PCODEC_MVC_EXT_PIC_PARAMS m_mvcExtPicParams = nullptr; //!< Pointer to MVC ext picture parameter 144 PCODEC_AVC_SLICE_PARAMS m_avcSliceParams = nullptr; //!< Pointer to AVC slice parameter 145 PCODEC_AVC_IQ_MATRIX_PARAMS m_avcIqMatrixParams = nullptr; //!< Pointer to AVC IQ matrix parameter 146 147 bool m_picIdRemappingInUse = false; //!< Indicate PicId Remapping are in use 148 uint32_t m_fullFeildsReceived = 0; //!< Indicate if fields are completed 149 bool m_fullFrameData = false; //!< Indicate it is a full frame 150 PMOS_BUFFER m_resMonoPicChromaBuffer = nullptr; //!< Handle of MonoPicture's default Chroma data surface 151 152 bool m_shortFormatInUse = false; //!< Indicate it is Short Format 153 bool m_deblockingEnabled = false; //!< Indicate Deblocking is enabled 154 bool m_streamOutEnabled = false; //!< Indicates if stream out enabled 155 bool m_isSecondField = false; //!< Indicate it is second field 156 PMOS_RESOURCE m_externalStreamOutBuffer = nullptr; //!< Stream out buffer from HW 157 uint32_t m_fixedFrameIdx = 0xff; //!< This is used for interlace case which second field reference to first field 158 //!< with the same frame index, need to save this frame index into refFrameList. 159 uint32_t m_lastValidSlice = 0; 160 uint32_t m_slcLength = 0; 161 uint32_t m_slcOffset = 0; 162 bool m_usingVeRing = false; 163 // CencDecode buffer 164 CencDecodeShareBuf *m_cencBuf = nullptr; 165 166 std::vector<SliceRecord> m_sliceRecord; //!< Record slice info 167 AvcReferenceFrames m_refFrames; //!< Reference frames 168 std::vector<uint32_t> m_refFrameIndexList; //!< Reference frame index list 169 RefrenceAssociatedBuffer<MOS_BUFFER, AvcMvBufferOpInf, AvcBasicFeature> m_mvBuffers; //!< Reference associated buffers 170 171 protected: 172 virtual MOS_STATUS SetRequiredBitstreamSize(uint32_t requiredSize) override; 173 MOS_STATUS SetPictureStructs(); 174 MOS_STATUS SetSliceStructs(); 175 virtual MOS_STATUS CheckBitDepthAndChromaSampling(); 176 177 PMOS_INTERFACE m_osInterface = nullptr; 178 179 MEDIA_CLASS_DEFINE_END(decode__AvcBasicFeature) 180 }; 181 182 }//decode 183 184 #endif // !__DECODE_AVC_BASIC_FEATURE_H__ 185