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_sub_pipeline.h
24 //! \brief    Defines the common interface for decode sub pipeline
25 //! \details  The decode sub pipeline interface is further sub-divided by decode standard,
26 //!           this file is for the base interface which is shared by all decoders.
27 //!
28 #ifndef __DECODE_SUB_PIPELINE_H__
29 #define __DECODE_SUB_PIPELINE_H__
30 
31 #include "decode_scalability_defs.h"
32 #include "media_packet.h"
33 #include "media_task.h"
34 #include "media_context.h"
35 #include "codechal_setting.h"
36 
37 namespace decode {
38 
39 class DecodePipeline;
40 struct DecodePipelineParams;
41 
42 class DecodeSubPipeline
43 {
44 public:
45     using PacketListType       = std::map<uint32_t, MediaPacket *>;
46     using ActivePacketListType = std::vector<PacketProperty>;
47 
48     //!
49     //! \brief  Decode sub pipeline constructor
50     //!
51     DecodeSubPipeline(DecodePipeline* pipeline, MediaTask* task, uint8_t numVdbox);
52 
53     //!
54     //! \brief  Decode sub pipeline destructor
55     //!
56     virtual ~DecodeSubPipeline();
57 
58     //!
59     //! \brief  Initialize the sub pipeline
60     //! \param  [in] settings
61     //!         Reference to the Codechal settings
62     //! \return MOS_STATUS
63     //!         MOS_STATUS_SUCCESS if success, else fail reason
64     //!
65     virtual MOS_STATUS Init(CodechalSetting& settings) = 0;
66 
67     //!
68     //! \brief  Prepare interal parameters
69     //! \param  [in] params
70     //!         Reference to decode pipeline parameters
71     //! \return MOS_STATUS
72     //!         MOS_STATUS_SUCCESS if success, else fail reason
73     //!
74     virtual MOS_STATUS Prepare(DecodePipelineParams& params) = 0;
75 
76     //!
77     //! \brief  Get packet list
78     //! \return PacketListType
79     //!         Return the packet list
80     //!
81     PacketListType & GetPacketList();
82 
83     //!
84     //! \brief  Get active packets list
85     //! \return ActivePacketListType
86     //!         Return the active packets list
87     //!
88     ActivePacketListType & GetActivePackets();
89 
90     //!
91     //! \brief  Get media function for context switch
92     //! \return MediaFunction
93     //!         Return the media function
94     //!
95     virtual MediaFunction GetMediaFunction() = 0;
96 
97     //!
98     //! \brief  Get scalability parameters
99     //! \return DecodeScalabilityPars&
100     //!         Return the scalability parameters
101     //!
102     DecodeScalabilityPars& GetScalabilityPars();
103 
104 protected:
105     //!
106     //! \brief  Register one packet into packet list
107     //! \param  [in] packetId
108     //!         Packet Id
109     //! \param  [in] packet
110     //!         The packet corresponding to packetId
111     //! \return MOS_STATUS
112     //!         MOS_STATUS_SUCCESS if success, else fail reason
113     //!
114     MOS_STATUS RegisterPacket(uint32_t packetId, MediaPacket& packet);
115 
116     //!
117     //! \brief  Activate one packet and add it to active packet list
118     //! \param  [in] packetId
119     //!         Packet Id
120     //! \param  [in] immediateSubmit
121     //!         Indicate if this packet to activate is needed to submit immediately after been added to task
122     //! \param  [in] pass
123     //!         pass belongs to the Packet
124     //! \param  [in] pipe
125     //!         pipe belongs to the Packet
126     //! \param  [in] pipe numbers
127     //!         pipe numbers the Packet needs to use
128     //! \return MOS_STATUS
129     //!         MOS_STATUS_SUCCESS if success, else fail reason
130     //!
131     MOS_STATUS ActivatePacket(uint32_t packetId, bool immediateSubmit,
132                               uint8_t pass, uint8_t pipe, uint8_t pipeNum = 1);
133 
134     //!
135     //! \brief  Reset sub pipeline
136     //! \return MOS_STATUS
137     //!         MOS_STATUS_SUCCESS if success, else fail reason
138     //!
139     MOS_STATUS Reset();
140 
141     //!
142     //! \brief  Initialize scalability parameters
143     //!
144     virtual void InitScalabilityPars(PMOS_INTERFACE osInterface) = 0;
145 
146 protected:
147     DecodePipeline*         m_pipeline = nullptr;    //!< Decode pipeline
148     MediaTask*              m_task = nullptr;        //!< Decode task
149     uint8_t                 m_numVdbox = 1;          //!< Number of Vdbox
150 
151     PacketListType          m_packetList;            //!< Packets list
152     ActivePacketListType    m_activePacketList;      //!< Active packets property list
153 
154     DecodeScalabilityPars   m_decodeScalabilityPars; //!< Decode scalability parameters
155 
156 MEDIA_CLASS_DEFINE_END(DecodeSubPipeline)
157 };
158 
159 }//decode
160 
161 #endif // !__DECODE_PIPELINE_H__
162