• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_reference_frames.h
24 //! \brief    Defines reference list related logic for hevc decode
25 //!
26 #ifndef __DECODE_HEVC_REFERENCE_FRAMES_H__
27 #define __DECODE_HEVC_REFERENCE_FRAMES_H__
28 
29 #include "codec_def_decode_hevc.h"
30 #include "mhw_vdbox.h"
31 #include "decode_allocator.h"
32 
33 namespace decode
34 {
35 class HevcBasicFeature;
36 
37 class HevcReferenceFrames
38 {
39 public:
40     //!
41     //! \brief  HevcReferenceFrames constructor
42     //!
43     HevcReferenceFrames();
44 
45     //!
46     //! \brief  HevcReferenceFrames deconstructor
47     //!
48     ~HevcReferenceFrames();
49 
50     //!
51     //! \brief  Init Hevc reference frames
52     //! \param  [in] basicFeature
53     //!         Pointer to Hevc basic feature
54     //! \return  MOS_STATUS
55     //!         MOS_STATUS_SUCCESS if success, else fail reason
56     //!
57     MOS_STATUS Init(HevcBasicFeature *basicFeature, DecodeAllocator& allocator);
58 
59     //!
60     //! \brief  Update reference frames for picture
61     //! \param  [in] picParams
62     //!         Picture parameters
63     //! \param  [in] isSCCIBCMode
64     //!         Flag to indicate SCC IBC mode
65     //! \return  MOS_STATUS
66     //!         MOS_STATUS_SUCCESS if success, else fail reason
67     //!
68     MOS_STATUS UpdatePicture(CODEC_HEVC_PIC_PARAMS & picParams, bool isSCCIBCMode);
69 
70     //!
71     //! \brief  Update current resource for reference list
72     //! \param  [in] picParams
73     //!         Picture parameters
74     //! \param  [in] isSCCIBCMode
75     //!         Flag to indicate SCC IBC mode
76     //! \return  MOS_STATUS
77     //!         MOS_STATUS_SUCCESS if success, else fail reason
78     //!
79     MOS_STATUS UpdateCurResource(const CODEC_HEVC_PIC_PARAMS & picParams, bool isSCCIBCMode);
80 
81     //!
82     //! \brief  Get active reference list for current frame
83     //! \param  [in] picParams
84     //!         Picture parameters
85     //! \return  std::vector<uint8_t> &
86     //!         Active reference list indices for current frame
87     //!
88     const std::vector<uint8_t> & GetActiveReferenceList(const CODEC_HEVC_PIC_PARAMS & picParams);
89 
90     //!
91     //! \brief  Get active reference list for current frame
92     //! \param  [in] frameIndex
93     //!         Frame index for reference
94     //! \return  PMOS_RESOURCE
95     //!         Active reference list for current frame
96     //!
97     PMOS_RESOURCE GetReferenceByFrameIndex(uint8_t frameIndex);
98 
99     //!
100     //! \brief  Get valid reference for error concealment.
101     //! \return  PMOS_RESOURCE
102     //!         Valid reference resource
103     //!
104     PMOS_RESOURCE GetValidReference();
105 
106     //!
107     //! \brief  Fix reference list for slice
108     //! \param  [in] picParams
109     //!         Picture parameters
110     //! \param  [in] slc
111     //!         Slice parameters
112     //! \return  MOS_STATUS
113     //!         MOS_STATUS_SUCCESS if success, else fail reason
114     //!
115     MOS_STATUS FixSliceRefList(const CODEC_HEVC_PIC_PARAMS & picParams, CODEC_HEVC_SLICE_PARAMS & slc);
116 
117     int8_t              m_refIdxMapping[CODEC_MAX_NUM_REF_FRAME_HEVC];      //!< Map table of indices of references
118     PCODEC_REF_LIST     m_refList[CODECHAL_NUM_UNCOMPRESSED_SURFACE_HEVC];  //!< Pointer to reference list
119     bool                m_curIsIntra = true;                                //!< Indicate current picture is intra
120     uint8_t             m_IBCRefIdx = 0;                                    //!< Reference ID for IBC mode
121 
122 protected:
123     //!
124     //! \brief  Update the current frame entry on m_refList
125     //! \param  [in] picParams
126     //!         Picture parameters
127     //! \param  [in] isSCCIBCMode
128     //!         Flag to indicate SCC IBC mode
129     //! \return  MOS_STATUS
130     //!         MOS_STATUS_SUCCESS if success, else fail reason
131     //!
132     MOS_STATUS UpdateCurFrame(const CODEC_HEVC_PIC_PARAMS & picParams, bool isSCCIBCMode);
133 
134     //!
135     //! \brief  Update the reference list for current frame
136     //! \param  [in] picParams
137     //!         Picture parameters
138     //! \param  [in] isSCCIBCMode
139     //!         Flag to indicate SCC IBC mode
140     //! \return  MOS_STATUS
141     //!         MOS_STATUS_SUCCESS if success, else fail reason
142     //!
143     MOS_STATUS UpdateCurRefList(const CODEC_HEVC_PIC_PARAMS & picParams, bool isSCCIBCMode);
144 
145     //!
146     //! \brief  Update the reference index mapping
147     //! \param  [in] picParams
148     //!         Picture parameters
149     //! \param  [in] isSCCIBCMode
150     //!         Flag to indicate SCC IBC mode
151     //! \return  MOS_STATUS
152     //!         MOS_STATUS_SUCCESS if success, else fail reason
153     //!
154     MOS_STATUS UpdateRefIdxMapping(const CODEC_HEVC_PIC_PARAMS & picParams, bool isSCCIBCMode);
155 
156     //!
157     //! \brief  Update the reference cache policy
158     //! \param  [in] picParams
159     //!         Picture parameters
160     //! \return MOS_STATUS
161     //!         MOS_STATUS_SUCCESS if success, else fail reason
162     //!
163     MOS_STATUS UpdateRefCachePolicy(const CODEC_HEVC_PIC_PARAMS &picParams);
164 
165     //!
166     //! \brief  Detect if current frame has refrence frame
167     //! \param  [in] picParams
168     //!         Picture parameters
169     //! \return  MOS_STATUS
170     //!         MOS_STATUS_SUCCESS if success, else fail reason
171     //!
172     bool IsCurFrameUseReference(const CODEC_HEVC_PIC_PARAMS & picParams);
173 
174     //!
175     //! \brief  Detect POC duplication and save status to m_duplicationPocMap
176     //! \param  [in] picParams
177     //!         Picture parameters
178     //! \param  [out] refFrameList
179     //!         Reference frame list
180     //! \return  MOS_STATUS
181     //!         MOS_STATUS_SUCCESS if success, else fail reason
182     //!
183     MOS_STATUS DetectPocDuplication(const int32_t (&picOrderCntValList)[CODEC_MAX_NUM_REF_FRAME_HEVC],
184                                     CODEC_PICTURE (&refFrameList)[CODEC_MAX_NUM_REF_FRAME_HEVC]);
185 
186     static constexpr int32_t m_invalidPocValue = 0XFFFFFFFF;
187 
188     HevcBasicFeature*    m_basicFeature = nullptr;                           //!< HEVC paramter
189     DecodeAllocator*     m_allocator    = nullptr;                           //!< Decode allocator
190 
191     bool                 m_frameUsedAsCurRef[CODEC_MAX_NUM_REF_FRAME_HEVC];  //!< Indicate frames used as reference of current picture
192     std::vector<uint8_t> m_activeReferenceList;                             //!< Active reference list of current picture
193 
194     std::vector<int8_t>  m_duplicationPocMap[CODEC_MAX_NUM_REF_FRAME_HEVC];  //!< duplication POC map
195     PMOS_INTERFACE       m_osInterface = nullptr;                            //!< Os interface
196 
197 MEDIA_CLASS_DEFINE_END(decode__HevcReferenceFrames)
198 };
199 
200 }  // namespace encode
201 
202 #endif  // !__DECODE_HEVC_REFERENCE_FRAMES_H__
203