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_vp9_packet_single.cpp
24 //! \brief    Defines the interface for vp9 single decode packet
25 //!
26 #include "decode_vp9_packet_single.h"
27 #include "decode_status_report_defs.h"
28 #include "decode_predication_packet.h"
29 #include "decode_marker_packet.h"
30 
31 namespace decode {
Init()32 MOS_STATUS Vp9DecodeSinglePkt::Init()
33 {
34     DECODE_FUNC_CALL();
35     DECODE_CHK_STATUS(Vp9DecodePkt::Init());
36 
37     DECODE_CHK_STATUS(m_statusReport->RegistObserver(this));
38 
39     DecodeSubPacket* subPacket = m_vp9Pipeline->GetSubPacket(DecodePacketId(m_vp9Pipeline, vp9PictureSubPacketId));
40     m_picturePkt = dynamic_cast<Vp9DecodePicPkt*>(subPacket);
41     DECODE_CHK_NULL(m_picturePkt);
42 
43     subPacket  = m_vp9Pipeline->GetSubPacket(DecodePacketId(m_vp9Pipeline, vp9SliceSubPacketId));
44     m_slicePkt = dynamic_cast<Vp9DecodeSlcPkt *>(subPacket);
45     DECODE_CHK_NULL(m_slicePkt);
46 
47     return MOS_STATUS_SUCCESS;
48 }
49 
IsPrologRequired()50 bool Vp9DecodeSinglePkt::IsPrologRequired()
51 {
52     DECODE_FUNC_CALL();
53 
54     return true;
55 }
56 
CalculateCommandSize(uint32_t & commandBufferSize,uint32_t & requestedPatchListSize)57 MOS_STATUS Vp9DecodeSinglePkt::CalculateCommandSize(uint32_t &commandBufferSize, uint32_t &requestedPatchListSize)
58 {
59     DECODE_FUNC_CALL();
60 
61     DECODE_CHK_STATUS(CalculateCommandBufferSize(commandBufferSize));
62     DECODE_CHK_STATUS(CalculatePatchListSize(requestedPatchListSize));
63 
64     return MOS_STATUS_SUCCESS;
65 }
66 
CalculateCommandBufferSize(uint32_t & commandBufferSize)67 MOS_STATUS Vp9DecodeSinglePkt::CalculateCommandBufferSize(uint32_t &commandBufferSize)
68 {
69     DECODE_FUNC_CALL();
70 
71     DECODE_CHK_STATUS(m_picturePkt->CalculateCommandSize(m_pictureStatesSize, m_picturePatchListSize));
72     DECODE_CHK_STATUS(m_slicePkt->CalculateCommandSize(m_sliceStatesSize, m_slicePatchListSize));
73     // VP9 m_numSlices should be 1
74     commandBufferSize = m_pictureStatesSize + m_sliceStatesSize * (m_vp9BasicFeature->m_numSlices + 1) +
75                         COMMAND_BUFFER_RESERVED_SPACE;
76 
77     return MOS_STATUS_SUCCESS;
78 }
79 
CalculatePatchListSize(uint32_t & requestedPatchListSize)80 MOS_STATUS Vp9DecodeSinglePkt::CalculatePatchListSize(uint32_t &requestedPatchListSize)
81 {
82     DECODE_FUNC_CALL();
83 
84     if (!m_osInterface->bUsesPatchList)
85     {
86         requestedPatchListSize = 0;
87         return MOS_STATUS_SUCCESS;
88     }
89 
90     requestedPatchListSize = m_picturePatchListSize +
91                              (m_slicePatchListSize * (m_vp9BasicFeature->m_numSlices + 1));
92 
93     return MOS_STATUS_SUCCESS;
94 }
95 
96 }
97