1 /*
2 * Copyright (c) 2019-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_av1_pipeline_g12_base.h
24 //! \brief    Defines the interface for av1 decode pipeline
25 //!
26 #ifndef __DECODE_AV1_PIPELINE_G12_BASE_H__
27 #define __DECODE_AV1_PIPELINE_G12_BASE_H__
28 
29 #include "decode_pipeline.h"
30 #include "decode_av1_basic_feature_g12.h"
31 
32 namespace decode {
33 
34 class Av1PipelineG12_Base : public DecodePipeline
35 {
36 public:
37     enum Av1DecodeMode
38     {
39         baseDecodeMode,         //!< Legacy decode mode with single pipe
40         realTileDecodeMode,     //!< Real tile decode mode
41     };
42 
43     //!
44     //! \brief  Av1PipelineG12_Base constructor
45     //! \param  [in] hwInterface
46     //!         Pointer to CodechalHwInterface
47     //! \param  [in] debugInterface
48     //!         Pointer to CodechalDebugInterface
49     //!
50     Av1PipelineG12_Base(
51         CodechalHwInterface *   hwInterface,
52         CodechalDebugInterface *debugInterface);
53 
~Av1PipelineG12_Base()54     virtual ~Av1PipelineG12_Base() {};
55 
56     Av1DecodeMode GetDecodeMode();
57 
58     bool    FrameBasedDecodingInUse();
59 
TileBasedDecodingInuse()60     bool    TileBasedDecodingInuse() {return m_forceTileBasedDecoding;}
61 
62     DeclareDecodePacketId(av1DecodePacketId);
63     DeclareDecodePacketId(av1PictureSubPacketId);
64     DeclareDecodePacketId(av1TileSubPacketId);
65 
66 protected:
67     //!
68     //! \brief  Initialize the decode pipeline
69     //! \param  [in] settings
70     //!         Pointer to the initialize settings
71     //! \return MOS_STATUS
72     //!         MOS_STATUS_SUCCESS if success, else fail reason
73     //!
74     virtual MOS_STATUS Initialize(void *settings) override;
75 
76     //!
77     //! \brief  Uninitialize the decode pipeline
78     //! \return MOS_STATUS
79     //!         MOS_STATUS_SUCCESS if success, else fail reason
80     //!
81     virtual MOS_STATUS Uninitialize() override;
82 
83     //!
84     //! \brief  Prepare interal parameters, should be invoked for each frame
85     //! \param  [in] params
86     //!         Pointer to the input parameters
87     //! \return MOS_STATUS
88     //!         MOS_STATUS_SUCCESS if success, else fail reason
89     //!
90     virtual MOS_STATUS Prepare(void *params) override;
91 
92     //!
93     //! \brief  User Feature Key Report
94     //! \return MOS_STATUS
95     //!         MOS_STATUS_SUCCESS if success, else fail reason
96     //!
97     virtual MOS_STATUS UserFeatureReport() override;
98 
99     //!
100     //! \brief  Active decode packets
101     //! \return MOS_STATUS
102     //!         MOS_STATUS_SUCCESS if success, else fail reason
103     //!
104     virtual MOS_STATUS ActivateDecodePackets();
105 
106     //!
107     //! \brief  create media feature manager
108     //! \return MOS_STATUS
109     //!         MOS_STATUS_SUCCESS if success, else fail reason
110     //!
111     virtual MOS_STATUS CreateFeatureManager() override;
112 
113     //!
114     //! \brief  Create sub packets
115     //! \param  [in] codecSettings
116     //!         Point to codechal settings
117     //! \return MOS_STATUS
118     //!         MOS_STATUS_SUCCESS if success, else fail reason
119     //!
120     virtual MOS_STATUS CreateSubPackets(DecodeSubPacketManager &subPacketManager, CodechalSetting &codecSettings) override;
121 
122     //!
123     //! \brief  Create post sub packets
124     //! \param  [in] subPipelineManager
125     //! \return MOS_STATUS
126     //!         MOS_STATUS_SUCCESS if success, else fail reason
127     //!
128     virtual MOS_STATUS CreatePostSubPipeLines(DecodeSubPipelineManager &subPipelineManager) override;
129 
130     //!
131     //! \brief  Create pre sub packets
132     //! \param  [in] subPipelineManager
133     //! \return MOS_STATUS
134     //!         MOS_STATUS_SUCCESS if success, else fail reason
135     //!
136     virtual MOS_STATUS CreatePreSubPipeLines(DecodeSubPipelineManager &subPipelineManager) override;
137 
138 #if USE_CODECHAL_DEBUG_TOOL
139         //! \brief    Dump the parameters
140         //!
141         //! \return   MOS_STATUS
142         //!           MOS_STATUS_SUCCESS if success, else fail reason
143         //!
144         MOS_STATUS DumpParams(Av1BasicFeatureG12 &basicFeature);
145 
146         //! \brief    Dump the picture parameters
147         //!
148         //! \param    [in] picParams
149         //!           Pointer to CodecAv1PicParams
150         //!
151         //! \return   MOS_STATUS
152         //!           MOS_STATUS_SUCCESS if success, else fail reason
153         //!
154         MOS_STATUS DumpPicParams(CodecAv1PicParams *picParams);
155 
156         //! \brief    Dump Tile Group parameters into file
157         //!
158         //! \param    [in] tileParams
159         //!           Pointer to CodecAv1TileParams
160         //!
161         //! \param    [in] tileNum
162         //!           Number of tiles
163         //!
164         //! \return   MOS_STATUS
165         //!           MOS_STATUS_SUCCESS if success, else fail reason
166         //!
167         MOS_STATUS DumpTileParams(CodecAv1TileParams *tileParams, uint32_t tileNum);
168 #endif
169 
170 protected:
171     Av1DecodeMode  m_decodeMode       = baseDecodeMode;   //!< Decode mode
172     uint16_t       m_passNum          = 1;                //!< Decode pass number
173     bool           m_isFirstTileInFrm = true;             //!< First tile in the first frame
174     bool           m_forceTileBasedDecoding = false;      //!< Force tile based decoding
175     CodechalHwInterface *m_hwInterface            = nullptr;
176 MEDIA_CLASS_DEFINE_END(decode__Av1PipelineG12_Base)
177 };
178 
179 }
180 #endif // !__DECODE_AV1_PIPELINE_G12_BASE_H__
181