1 /*
2 * Copyright (c) 2018-2020, 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_avc_pipeline.h
24 //! \brief    Defines the interface for avc decode pipeline
25 //!
26 #ifndef __DECODE_AVC_PIPELINE_H__
27 #define __DECODE_AVC_PIPELINE_H__
28 
29 #include "decode_pipeline.h"
30 #include "decode_avc_basic_feature.h"
31 
32 namespace decode {
33 
34 class AvcPipeline : public DecodePipeline
35 {
36 public:
37     enum AvcDecodeMode
38     {
39         baseDecodeMode,         //!< Legacy decode mode with single pipe
40     };
41 
42     //!
43     //! \brief  AvcPipeline constructor
44     //! \param  [in] hwInterface
45     //!         Pointer to CodechalHwInterface
46     //! \param  [in] debugInterface
47     //!         Pointer to CodechalDebugInterface
48     //!
49     AvcPipeline(
50         CodechalHwInterfaceNext *hwInterface,
51         CodechalDebugInterface* debugInterface);
52 
53     //!
54     //! \brief  Return if short format decode in use
55     //! \return bool
56     //!         True if short format in use, else false
57     //!
58     bool IsShortFormat();
59 
60     bool m_intelEntrypointInUse = false; //!< Indicate it is Intel-specific Format
61 
~AvcPipeline()62     virtual ~AvcPipeline() {};
63 
64     AvcDecodeMode GetDecodeMode();
65     //!
66     //! \brief  Declare Regkeys in the scope of avc decode
67     //! \return MOS_STATUS
68     //!         MOS_STATUS_SUCCESS if success, else fail reason
69     virtual MOS_STATUS InitUserSetting(MediaUserSettingSharedPtr userSettingPtr) override;
70 
71     //!
72     //! \brief    Set decode short/long format during runtime.
73     //! \return   MOS_STATUS
74     //!           MOS_STATUS_SUCCESS if success, else fail reason
75     //!
76     virtual MOS_STATUS SetDecodeFormat(bool isShortFormat) override;
77 
78     DeclareDecodePacketId(avcDecodePacketId);
79     DeclareDecodePacketId(avcPictureSubPacketId);
80     DeclareDecodePacketId(avcSliceSubPacketId);
81     DeclareDecodePacketId(avcFormatMonoPicPktId);
82 
83 protected:
84     //!
85     //! \brief  Initialize the decode pipeline
86     //! \param  [in] settings
87     //!         Pointer to the initialize settings
88     //! \return MOS_STATUS
89     //!         MOS_STATUS_SUCCESS if success, else fail reason
90     //!
91     virtual MOS_STATUS Initialize(void *settings) override;
92 
93     //!
94     //! \brief  Prepare interal parameters, should be invoked for each frame
95     //! \param  [in] params
96     //!         Pointer to the input parameters
97     //! \return MOS_STATUS
98     //!         MOS_STATUS_SUCCESS if success, else fail reason
99     //!
100     virtual MOS_STATUS Prepare(void *params) override;
101 
102     //!
103     //! \brief  Uninitialize the decode pipeline
104     //! \return MOS_STATUS
105     //!         MOS_STATUS_SUCCESS if success, else fail reason
106     //!
107     virtual MOS_STATUS Uninitialize() override;
108 
109     //!
110     //! \brief  User Feature Key Report
111     //! \return MOS_STATUS
112     //!         MOS_STATUS_SUCCESS if success, else fail reason
113     //!
114     virtual MOS_STATUS UserFeatureReport() override;
115 
116     //!
117     //! \brief  Active decode packets
118     //! \return MOS_STATUS
119     //!         MOS_STATUS_SUCCESS if success, else fail reason
120     //!
121     virtual MOS_STATUS ActivateDecodePackets();
122 
123     //!
124     //! \brief  create media feature manager
125     //! \return MOS_STATUS
126     //!         MOS_STATUS_SUCCESS if success, else fail reason
127     //!
128     virtual MOS_STATUS CreateFeatureManager() override;
129 
130     //!
131     //! \brief  Create sub packets
132     //! \param  [in] codecSettings
133     //!         Point to codechal settings
134     //! \return MOS_STATUS
135     //!         MOS_STATUS_SUCCESS if success, else fail reason
136     //!
137     virtual MOS_STATUS CreateSubPackets(DecodeSubPacketManager& subPacketManager, CodechalSetting &codecSettings) override;
138 
139 #if USE_CODECHAL_DEBUG_TOOL
140     MOS_STATUS DumpPicParams(
141         PCODEC_AVC_PIC_PARAMS picParams);
142 
143     MOS_STATUS DumpSliceParams(
144         PCODEC_AVC_SLICE_PARAMS sliceParams,
145         uint32_t                numSlices,
146         bool                    shortFormatInUse);
147 
148     MOS_STATUS DumpIQParams(
149         PCODEC_AVC_IQ_MATRIX_PARAMS iqParams);
150 #endif
151 
152 protected:
153 
154     bool            m_shortFormatInUse  = false;             //!< Indicate it is Short Format
155     AvcDecodeMode   m_decodeMode        = baseDecodeMode;    //!< Decode mode
156     HucCopyPktItf   *m_formatMonoPicPkt  = nullptr;          //!< Format Avc Mono Chroma with HuC Copy
157     AvcBasicFeature *m_basicFeature     = nullptr;           //!< Avc Basic Feature
158     bool            m_allowVirtualNodeReassign = false;      //!< Whether allow virtual node reassign
159     MEDIA_CLASS_DEFINE_END(decode__AvcPipeline)
160 };
161 
162 }
163 #endif // !__DECODE_AVC_PIPELINE_H__
164