1 /*
2 * Copyright (c) 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_mpeg2_reference_frames.h
24 //! \brief    Defines reference list related logic for mpeg2 decode
25 //!
26 #ifndef __DECODE_MPEG2_REFERENCE_FRAMES_H__
27 #define __DECODE_MPEG2_REFERENCE_FRAMES_H__
28 
29 #include "codec_def_decode_mpeg2.h"
30 #include "mhw_vdbox.h"
31 #include "decode_allocator.h"
32 
33 namespace decode
34 {
35 class Mpeg2BasicFeature;
36 
37 class Mpeg2ReferenceFrames
38 {
39 public:
40     //!
41     //! \brief  Mpeg2ReferenceFrames constructor
42     //!
43     Mpeg2ReferenceFrames();
44 
45     //!
46     //! \brief  Mpeg2ReferenceFrames deconstructor
47     //!
48     ~Mpeg2ReferenceFrames();
49 
50     //!
51     //! \brief  Init Mpeg2 reference frames
52     //! \param  [in] basicFeature
53     //!         Pointer to Mpeg2 basic feature
54     //! \return MOS_STATUS
55     //!         MOS_STATUS_SUCCESS if success, else fail reason
56     //!
57     MOS_STATUS Init(Mpeg2BasicFeature *basicFeature, DecodeAllocator& allocator);
58 
59     //!
60     //! \brief  Update reference frames for picture
61     //! \param  [in] picParams
62     //!         Picture parameters
63     //! \return MOS_STATUS
64     //!         MOS_STATUS_SUCCESS if success, else fail reason
65     //!
66     MOS_STATUS UpdatePicture(CodecDecodeMpeg2PicParams &picParams);
67 
68     //!
69     //! \brief  Update current resource for reference list
70     //! \param  [in] picParams
71     //!         Picture parameters
72     //! \return  MOS_STATUS
73     //!         MOS_STATUS_SUCCESS if success, else fail reason
74     //!
75     MOS_STATUS UpdateCurResource(const CodecDecodeMpeg2PicParams &picParams);
76 
77     PCODEC_REF_LIST     m_refList[CODECHAL_NUM_UNCOMPRESSED_SURFACE_MPEG2];     //!< Pointer to reference list
78 
79 protected:
80     //!
81     //! \brief  Update the current frame entry on m_refList
82     //! \param  [in] picParams
83     //!         Picture parameters
84     //! \return MOS_STATUS
85     //!         MOS_STATUS_SUCCESS if success, else fail reason
86     //!
87     MOS_STATUS UpdateCurFrame(const CodecDecodeMpeg2PicParams &picParams);
88 
89     //!
90     //! \brief  Update the reference list for current frame
91     //! \param  [in] picParams
92     //!         Picture parameters
93     //! \return MOS_STATUS
94     //!         MOS_STATUS_SUCCESS if success, else fail reason
95     //!
96     MOS_STATUS UpdateCurRefList(const CodecDecodeMpeg2PicParams &picParams);
97 
98     Mpeg2BasicFeature*       m_basicFeature = nullptr;                       //!< MPEG2 basic feature
99     DecodeAllocator*         m_allocator    = nullptr;                       //!< Decode allocator
100     std::vector<uint8_t>     m_activeReferenceList;                          //!< Active reference list of current picture
101 
102 MEDIA_CLASS_DEFINE_END(decode__Mpeg2ReferenceFrames)
103 };
104 
105 }  // namespace decode
106 
107 #endif  // !__DECODE_MPEG2_REFERENCE_FRAMES_H__
108