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