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 //!
24 //! \file     decode_sub_pipeline.cpp
25 //! \brief    Defines the common interface for decode sub pipeline
26 //! \details  The decode sub pipeline interface is further sub-divided by decode standard,
27 //!           this file is for the base interface which is shared by all decoders.
28 //!
29 #include "decode_sub_pipeline.h"
30 #include "decode_pipeline.h"
31 #include "decode_utils.h"
32 #include "media_packet.h"
33 
34 namespace decode {
35 
DecodeSubPipeline(DecodePipeline * pipeline,MediaTask * task,uint8_t numVdbox)36 DecodeSubPipeline::DecodeSubPipeline(DecodePipeline* pipeline, MediaTask* task, uint8_t numVdbox)
37     : m_pipeline(pipeline), m_task(task), m_numVdbox(numVdbox)
38 {
39     DECODE_ASSERT(m_pipeline != nullptr);
40     DECODE_ASSERT(m_task != nullptr);
41     MOS_ZeroMemory(&m_decodeScalabilityPars, sizeof(m_decodeScalabilityPars));
42 }
43 
~DecodeSubPipeline()44 DecodeSubPipeline::~DecodeSubPipeline()
45 {
46     for (auto iter : m_packetList)
47     {
48         MOS_Delete(iter.second);
49     }
50 
51     m_packetList.clear();
52     m_activePacketList.clear();
53 }
54 
GetPacketList()55 DecodeSubPipeline::PacketListType & DecodeSubPipeline::GetPacketList()
56 {
57     return m_packetList;
58 }
59 
GetActivePackets()60 DecodeSubPipeline::ActivePacketListType & DecodeSubPipeline::GetActivePackets()
61 {
62     return m_activePacketList;
63 }
64 
GetScalabilityPars()65 DecodeScalabilityPars& DecodeSubPipeline::GetScalabilityPars()
66 {
67     return m_decodeScalabilityPars;
68 }
69 
RegisterPacket(uint32_t packetId,MediaPacket & packet)70 MOS_STATUS DecodeSubPipeline::RegisterPacket(uint32_t packetId, MediaPacket& packet)
71 {
72     auto iter = m_packetList.find(packetId);
73     if (iter == m_packetList.end())
74     {
75         m_packetList.insert(std::make_pair(packetId, &packet));
76     }
77 
78     return MOS_STATUS_SUCCESS;
79 }
80 
ActivatePacket(uint32_t packetId,bool immediateSubmit,uint8_t pass,uint8_t pipe,uint8_t pipeNum)81 MOS_STATUS DecodeSubPipeline::ActivatePacket(uint32_t packetId, bool immediateSubmit,
82                                              uint8_t pass, uint8_t pipe, uint8_t pipeNum)
83 {
84     auto iter = m_packetList.find(packetId);
85     if (iter == m_packetList.end())
86     {
87         return MOS_STATUS_INVALID_PARAMETER;
88     }
89 
90     PacketProperty prop;
91     prop.packetId                         = iter->first;
92     prop.packet                           = iter->second;
93     prop.immediateSubmit                  = immediateSubmit;
94     prop.frameTrackingRequested           = false;
95 
96     prop.stateProperty.currentPass        = pass;
97     prop.stateProperty.currentPipe        = pipe;
98     prop.stateProperty.pipeIndexForSubmit = pipeNum;
99 
100     m_activePacketList.push_back(prop);
101 
102     return MOS_STATUS_SUCCESS;
103 }
104 
Reset()105 MOS_STATUS DecodeSubPipeline::Reset()
106 {
107     m_activePacketList.clear();
108 
109     return MOS_STATUS_SUCCESS;
110 }
111 
112 }
113