1 /*
2 * Copyright (c) 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_hevc_packet_back_end.cpp
24 //! \brief    Defines the interface for hevc back end decode packet
25 //!
26 #include "decode_hevc_packet_back_end.h"
27 #include "decode_status_report_defs.h"
28 #include "decode_predication_packet.h"
29 #include "decode_marker_packet.h"
30 
31 namespace decode {
32 
~HevcDecodeBackEndPkt()33 HevcDecodeBackEndPkt::~HevcDecodeBackEndPkt()
34 {
35 }
36 
Init()37 MOS_STATUS HevcDecodeBackEndPkt::Init()
38 {
39     DECODE_FUNC_CALL();
40     DECODE_CHK_STATUS(HevcDecodePkt::Init());
41 
42     DECODE_CHK_STATUS(m_statusReport->RegistObserver(this));
43 
44     DecodeSubPacket* subPacket = m_hevcPipeline->GetSubPacket(DecodePacketId(m_hevcPipeline, hevcPictureSubPacketId));
45     m_picturePkt = dynamic_cast<HevcDecodePicPkt*>(subPacket);
46     DECODE_CHK_NULL(m_picturePkt);
47 
48     return MOS_STATUS_SUCCESS;
49 }
50 
Destroy()51 MOS_STATUS HevcDecodeBackEndPkt::Destroy()
52 {
53     m_statusReport->UnregistObserver(this);
54     return MOS_STATUS_SUCCESS;
55 }
56 
IsPrologRequired()57 bool HevcDecodeBackEndPkt::IsPrologRequired()
58 {
59     return true;
60 }
61 
CalculateCommandSize(uint32_t & commandBufferSize,uint32_t & requestedPatchListSize)62 MOS_STATUS HevcDecodeBackEndPkt::CalculateCommandSize(uint32_t &commandBufferSize, uint32_t &requestedPatchListSize)
63 {
64     DECODE_CHK_STATUS(CalculateCommandBufferSize(commandBufferSize));
65     DECODE_CHK_STATUS(CalculatePatchListSize(requestedPatchListSize));
66     return MOS_STATUS_SUCCESS;
67 }
68 
CalculateCommandBufferSize(uint32_t & commandBufferSize)69 MOS_STATUS HevcDecodeBackEndPkt::CalculateCommandBufferSize(uint32_t &commandBufferSize)
70 {
71     // Just need consider picture level cmds for first level command buffer size,
72     // since the slice level cmds are located 2nd lvl batch buffer which is
73     // allocated by pipeline.
74     DECODE_CHK_STATUS(m_picturePkt->CalculateCommandSize(m_pictureStatesSize, m_picturePatchListSize));
75     commandBufferSize = m_pictureStatesSize + COMMAND_BUFFER_RESERVED_SPACE;
76     return MOS_STATUS_SUCCESS;
77 }
78 
CalculatePatchListSize(uint32_t & requestedPatchListSize)79 MOS_STATUS HevcDecodeBackEndPkt::CalculatePatchListSize(uint32_t &requestedPatchListSize)
80 {
81     if (!m_osInterface->bUsesPatchList)
82     {
83         requestedPatchListSize = 0;
84     }
85     else
86     {
87         requestedPatchListSize = m_picturePatchListSize;
88     }
89     return MOS_STATUS_SUCCESS;
90 }
91 
92 }
93