1 /*
2 * Copyright (c) 2020-2022, 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_vp8_pipeline.h
24 //! \brief    Defines the interface for vp8 decode pipeline
25 //!
26 #ifndef __DECODE_VP8_PIPELINE_H__
27 #define __DECODE_VP8_PIPELINE_H__
28 
29 #include "decode_pipeline.h"
30 #include "decode_vp8_basic_feature.h"
31 #include "decode_phase.h"
32 
33 namespace decode {
34 
35 class Vp8Pipeline : public DecodePipeline
36 {
37 public:
38     enum Vp8DecodeMode
39     {
40         baseDecodeMode,         //!< Legacy decode mode with single pipe
41     };
42 
43     //!
44     //! \brief  Vp8Pipeline constructor
45     //! \param  [in] hwInterface
46     //!         Pointer to CodechalHwInterface
47     //! \param  [in] debugInterface
48     //!         Pointer to CodechalDebugInterface
49     //!
50     Vp8Pipeline(
51         CodechalHwInterfaceNext *   hwInterface,
52         CodechalDebugInterface *debugInterface);
53 
~Vp8Pipeline()54     virtual ~Vp8Pipeline() {};
55     Vp8DecodeMode GetDecodeMode();
56     //!
57     //! \brief  Declare Regkeys in the scope of vp9 decode
58     //! \return MOS_STATUS
59     //!         MOS_STATUS_SUCCESS if success, else fail reason
60     MOS_STATUS InitUserSetting(MediaUserSettingSharedPtr userSettingPtr) override;
61 
62     DeclareDecodePacketId(vp8PictureSubPacketId);
63     DeclareDecodePacketId(vp8SliceSubPacketId);
64     DeclareDecodePacketId(vp8DecodePacketId);
65 
66     Vp8BasicFeature *m_basicFeature     = nullptr;
67     Vp8DecodeMode    m_decodeMode       = baseDecodeMode;   //!< Decode mode
68 
69     std::vector<DecodePhase *> m_phaseList;                //!< Phase list
70 
71 protected:
72     //!
73     //! \brief  Initialize the decode pipeline
74     //! \param  [in] settings
75     //!         Pointer to the initialize settings
76     //! \return MOS_STATUS
77     //!         MOS_STATUS_SUCCESS if success, else fail reason
78     //!
79     virtual MOS_STATUS Initialize(void *settings) override;
80 
81     //!
82     //! \brief  Uninitialize the decode pipeline
83     //! \return MOS_STATUS
84     //!         MOS_STATUS_SUCCESS if success, else fail reason
85     //!
86     virtual MOS_STATUS Uninitialize() override;
87 
88     //!
89     //! \brief  Prepare interal parameters, should be invoked for each frame
90     //! \param  [in] params
91     //!         Pointer to the input parameters
92     //! \return MOS_STATUS
93     //!         MOS_STATUS_SUCCESS if success, else fail reason
94     //!
95     virtual MOS_STATUS Prepare(void *params) override;
96 
97     //!
98     //! \brief  User Feature Key Report
99     //! \return MOS_STATUS
100     //!         MOS_STATUS_SUCCESS if success, else fail reason
101     //!
102     virtual MOS_STATUS UserFeatureReport() override;
103 
104     //!
105     //! \brief  Finish the execution for each frame
106     //! \return MOS_STATUS
107     //!         MOS_STATUS_SUCCESS if success, else fail reason
108     //!
109     virtual MOS_STATUS Execute() override;
110 
111     //!
112     //! \brief  create media feature manager
113     //! \return MOS_STATUS
114     //!         MOS_STATUS_SUCCESS if success, else fail reason
115     //!
116     virtual MOS_STATUS CreateFeatureManager() override;
117 
118     //!
119     //! \brief  Create sub packets
120     //! \param  [in] codecSettings
121     //!         Point to codechal settings
122     //! \return MOS_STATUS
123     //!         MOS_STATUS_SUCCESS if success, else fail reason
124     //!
125     virtual MOS_STATUS CreateSubPackets(DecodeSubPacketManager& subPacketManager, CodechalSetting &codecSettings) override;
126 
127 
128 #if USE_CODECHAL_DEBUG_TOOL
129     //! \brief    Dump the picture parameters into file
130     //!
131     //! \param    [in] picParams
132     //!           Pointer to PCODEC_VP8_PIC_PARAMS
133     //!
134     //! \return   MOS_STATUS
135     //!           MOS_STATUS_SUCCESS if success, else fail reason
136     //!
137     MOS_STATUS DumpPicParams(PCODEC_VP8_PIC_PARAMS picParams);
138 
139     //! \brief    Dump the slice parameters into file
140     //!
141     //! \param    [in] sliceParams
142     //!           Pointer to CODEC_VP8_SLICE_PARAMS
143     //!
144     //! \return   MOS_STATUS
145     //!           MOS_STATUS_SUCCESS if success, else fail reason
146     //!
147     MOS_STATUS DumpSliceParams(CODEC_VP8_SLICE_PARAMS *sliceParams);
148 
149     //! \brief    Dump Inverse Quantization Matrix Buffer into file
150     //!
151     //! \param    [in] matrixData
152     //!           Pointer to CODEC_VP8_IQ_MATRIX_PARAMS
153     //!
154     //! \return   MOS_STATUS
155     //!           MOS_STATUS_SUCCESS if success, else fail reason
156     //!
157     MOS_STATUS DumpIQParams(CODEC_VP8_IQ_MATRIX_PARAMS *matrixData);
158 
159     //! \brief    Dump CoefProbBuffer into file
160     //!
161     //! \param    [in] m_resCoefProbBuffer
162     //!           Pointer to m_resCoefProbBuffer
163     //!
164     //! \return   MOS_STATUS
165     //!           MOS_STATUS_SUCCESS if success, else fail reason
166     //!
167     MOS_STATUS DumpCoefProbBuffer(PMOS_RESOURCE m_resCoefProbBuffer);
168 #endif
169 
170 MEDIA_CLASS_DEFINE_END(decode__Vp8Pipeline)
171 };
172 
173 }
174 #endif // !__DECODE_VP8_PIPELINE_H__
175