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_hevc_basic_feature.h
24 //! \brief    Defines the common interface for decode hevc basic feature
25 //!
26 #ifndef __DECODE_HEVC_BASIC_FEATURE_H__
27 #define __DECODE_HEVC_BASIC_FEATURE_H__
28 
29 #include "decode_basic_feature.h"
30 #include "codec_def_decode_hevc.h"
31 #include "codec_def_decode_hevc.h"
32 #include "decode_hevc_reference_frames.h"
33 #include "decode_hevc_mv_buffers.h"
34 #include "decode_hevc_tile_coding.h"
35 
36 namespace decode
37 {
38 class HevcBasicFeature :public DecodeBasicFeature
39 {
40 public:
HevcBasicFeature(DecodeAllocator * allocator,CodechalHwInterface * hwInterface)41     HevcBasicFeature(DecodeAllocator * allocator, CodechalHwInterface *hwInterface) :
42                      DecodeBasicFeature(allocator, hwInterface)
43     {
44         if (hwInterface != nullptr)
45         {
46             m_hcpInterface = hwInterface->GetHcpInterface();
47         }
48     };
49 
50     virtual ~HevcBasicFeature();
51 
52     virtual MOS_STATUS Init(void *setting) override;
53 
54     virtual MOS_STATUS Update(void *params) override;
55 
56     MOS_STATUS CreateReferenceBeforeLoopFilter();
57 
58     bool IsLastSlice(uint32_t sliceIdx);
59     bool IsIndependentSlice(uint32_t sliceIdx);
60 
61     // Parameters passed from application
62     PCODEC_HEVC_PIC_PARAMS          m_hevcPicParams = nullptr;      //!< Pointer to picture parameter
63     PCODEC_HEVC_SLICE_PARAMS        m_hevcSliceParams = nullptr;    //!< Pointer to slice parameter
64     PCODECHAL_HEVC_IQ_MATRIX_PARAMS m_hevcIqMatrixParams = nullptr; //!< Pointer to IQ matrix parameter
65     PCODEC_HEVC_EXT_PIC_PARAMS      m_hevcRextPicParams = nullptr;  //!< Extended pic params for Rext
66     PCODEC_HEVC_EXT_SLICE_PARAMS    m_hevcRextSliceParams = nullptr;//!< Extended slice params for Rext
67     PCODEC_HEVC_SCC_PIC_PARAMS      m_hevcSccPicParams = nullptr;   //!< Pic params for SCC
68     PCODEC_HEVC_SUBSET_PARAMS       m_hevcSubsetParams = nullptr;   //!< Hevc subset params for tile entrypoint offset
69 
70     bool                            m_isWPPMode    = false;         //!< Indicate current picture is WPP mode
71     bool                            m_isSCCIBCMode = false;         //!< Indicate current picture is SCC IBC mode
72     bool                            m_isSCCPLTMode = false;         //!< Indicate current picture is SCC PLT mode
73     bool                            m_isSCCACTMode = false;         //!< Indicate current picture is SCC ACT mode
74 
75     PMOS_SURFACE                    m_referenceBeforeLoopFilter = nullptr; //!< For SCC IBC
76     HevcReferenceFrames             m_refFrames;                    //!< Reference frames
77     std::vector<uint32_t>           m_refFrameIndexList;            //!< Reference frame index list
78     RefrenceAssociatedBuffer<MOS_BUFFER, HevcMvBufferOpInf, HevcBasicFeature>
79                                     m_mvBuffers;                    //!< MV buffers
80     HevcTileCoding                  m_tileCoding;                   //!< Tile coding
81 
82     uint32_t                        m_minCtbSize = 0;               //!< Min Luma Coding Block Size
83     uint32_t                        m_ctbSize = 0;                  //!< Max coding tree block size
84     uint32_t                        m_widthInCtb  = 0;              //!< Frame width in LCU
85     uint32_t                        m_heightInCtb  = 0;             //!< Frame height in LCU
86 
87     bool                            m_dummyReferenceSlot[CODECHAL_MAX_CUR_NUM_REF_FRAME_HEVC];
88 
89 protected:
90     virtual MOS_STATUS SetRequiredBitstreamSize(uint32_t requiredSize) override;
91 
92     MOS_STATUS SetPictureStructs();
93     MOS_STATUS SetSliceStructs();
94 
95     MhwVdboxHcpInterface * m_hcpInterface = nullptr;
96 
97 MEDIA_CLASS_DEFINE_END(HevcBasicFeature)
98 };
99 
100 }  // namespace encode
101 
102 #endif  // !__DECODE_HEVC_BASIC_FEATURE_H__
103