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_real_tile.h
24 //! \brief    Defines the implementation of hevc real tile decode packet
25 //!
26 
27 #ifndef __DECODE_HEVC_PACKET_REAL_TILE_H__
28 #define __DECODE_HEVC_PACKET_REAL_TILE_H__
29 
30 #include "decode_hevc_packet.h"
31 
32 namespace decode
33 {
34 
35 class HevcDecodeRealTilePkt : public HevcDecodePkt
36 {
37 public:
HevcDecodeRealTilePkt(MediaPipeline * pipeline,MediaTask * task,CodechalHwInterfaceNext * hwInterface)38     HevcDecodeRealTilePkt(MediaPipeline *pipeline, MediaTask *task, CodechalHwInterfaceNext*hwInterface)
39         : HevcDecodePkt(pipeline, task, hwInterface)
40     {
41     }
42     virtual ~HevcDecodeRealTilePkt();
43 
44     //!
45     //! \brief  Initialize the media packet, allocate required resources
46     //! \return MOS_STATUS
47     //!         MOS_STATUS_SUCCESS if success, else fail reason
48     //!
49     virtual MOS_STATUS Init() override;
50 
51     //!
52     //! \brief  Destroy the media packet and release the resources
53     //! \return MOS_STATUS
54     //!         MOS_STATUS_SUCCESS if success, else fail reason
55     //!
56     virtual MOS_STATUS Destroy() override;
57 
58     //!
59     //! \brief  Calculate Command Size
60     //!
61     //! \param  [in, out] commandBufferSize
62     //!         requested size
63     //! \param  [in, out] requestedPatchListSize
64     //!         requested size
65     //! \return MOS_STATUS
66     //!         status
67     //!
68     MOS_STATUS CalculateCommandSize(uint32_t &commandBufferSize, uint32_t &requestedPatchListSize) override;
69 
70     //!
71     //! \brief  Get Packet Name
72     //! \return std::string
73     //!
GetPacketName()74     virtual std::string GetPacketName() override
75     {
76         return "HEVC_DECODE_REAL_TILE_PASS" + std::to_string(static_cast<uint32_t>(m_hevcPipeline->GetCurrentPass()));
77     }
78 
79 protected:
80     //!
81     //! \brief  Initialize the second level batch buffer which holds slice level cmds
82     //! \param  [in] batchBuffer
83     //!         Batch buffer for slice level commands
84     //! \param  [in] batchBufBase
85     //!         Point to slice level command buffer
86     //! \param  [in] tileColNum
87     //!         Tile column number
88     //! \return MOS_STATUS
89     //!         status
90     //!
91     MOS_STATUS InitSliceLevelCmdBuffer(MHW_BATCH_BUFFER &batchBuffer, uint8_t *batchBufBase, uint32_t tileColNum);
92 
93     //!
94     //! \brief  Calculate Command Buffer Size
95     //! \param  [out] commandBufferSize
96     //!         requested size
97     //! \return uint32_t
98     //!         Command buffer size calculated
99     //!
100     virtual MOS_STATUS CalculateCommandBufferSize(uint32_t &commandBufferSize);
101 
102     //!
103     //! \brief  Calculate Patch List Size
104     //! \param  [out] requestedPatchListSize
105     //!         requested size
106     //! \return uint32_t
107     //!         Patchlist size calculated
108     //!
109     virtual MOS_STATUS CalculatePatchListSize(uint32_t &requestedPatchListSize);
110 
111     //!
112     //! \brief  Check if prolog required
113     //!
114     //! \return bool
115     //!         True if prolog required
116     //!
117     bool IsPrologRequired();
118 
119     //!
120     //! \brief  Check if last tile column
121     //!
122     //! \return bool
123     //!         True if last tile column, else false
124     //!
125     bool IsLastTileCol();
126 
127     HevcDecodePicPkt *m_picturePkt = nullptr;
128     HevcDecodeSlcPkt *m_slicePkt   = nullptr;
129 
130     std::vector<MOS_COMMAND_BUFFER> m_sliceLevelCmdBuffer;
131 
132 MEDIA_CLASS_DEFINE_END(decode__HevcDecodeRealTilePkt)
133 };
134 
135 }  // namespace decode
136 #endif
137