1 /*
2 * Copyright (c) 2021, 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_av1_tile_packet.h
24 //! \brief    Defines the implementation of av1 decode tile packet
25 //!
26 
27 #ifndef __DECODE_AV1_TILE_PACKET_H__
28 #define __DECODE_AV1_TILE_PACKET_H__
29 
30 #include "media_cmd_packet.h"
31 #include "decode_av1_pipeline.h"
32 #include "decode_utils.h"
33 #include "decode_av1_basic_feature.h"
34 #include "decode_av1_tile_coding.h"
35 #include "mhw_vdbox_avp_itf.h"
36 
37 namespace decode
38 {
39 
40 class Av1DecodeTilePkt : public DecodeSubPacket , public mhw::vdbox::avp::Itf::ParSetting
41 {
42 public:
Av1DecodeTilePkt(Av1Pipeline * pipeline,CodechalHwInterfaceNext * hwInterface)43     Av1DecodeTilePkt(Av1Pipeline *pipeline, CodechalHwInterfaceNext*hwInterface)
44         : DecodeSubPacket(pipeline, hwInterface), m_av1Pipeline(pipeline)
45     {
46         if (m_hwInterface != nullptr)
47         {
48             m_avpItf = std::static_pointer_cast<mhw::vdbox::avp::Itf>(m_hwInterface->GetAvpInterfaceNext());
49             m_miItf  = std::static_pointer_cast<mhw::mi::Itf>(m_hwInterface->GetMiInterfaceNext());
50         }
51     }
~Av1DecodeTilePkt()52     virtual ~Av1DecodeTilePkt(){};
53 
54     //!
55     //! \brief  Initialize the media packet, allocate required resources
56     //! \return MOS_STATUS
57     //!         MOS_STATUS_SUCCESS if success, else fail reason
58     //!
59     virtual MOS_STATUS Init() override;
60 
61     //!
62     //! \brief  Prepare interal parameters, should be invoked for each frame
63     //! \return MOS_STATUS
64     //!         MOS_STATUS_SUCCESS if success, else fail reason
65     //!
66     virtual MOS_STATUS Prepare() override;
67 
68     //!
69     //! \brief  Execute av1 tile packet
70     //! \return MOS_STATUS
71     //!         MOS_STATUS_SUCCESS if success, else fail reason
72     //!
73     virtual MOS_STATUS Execute(MOS_COMMAND_BUFFER& cmdBuffer, int16_t tileIdx) = 0;
74 
75     //!
76     //! \brief  Calculate Command Size
77     //!
78     //! \param  [in, out] commandBufferSize
79     //!         requested size
80     //! \param  [in, out] requestedPatchListSize
81     //!         requested size
82     //! \return MOS_STATUS
83     //!         status
84     //!
85     MOS_STATUS CalculateCommandSize(
86         uint32_t &commandBufferSize,
87         uint32_t &requestedPatchListSize) override;
88 
89 protected:
90     MHW_SETPAR_DECL_HDR(AVP_INLOOP_FILTER_STATE);
91     MHW_SETPAR_DECL_HDR(AVP_FILM_GRAIN_STATE);
92     virtual MOS_STATUS AddCmd_AVP_TILE_CODING(MOS_COMMAND_BUFFER &cmdBuffer, int16_t tileIdx);
93     virtual MOS_STATUS AddCmd_AVP_BSD_OBJECT(MOS_COMMAND_BUFFER &cmdBuffer, int16_t tileIdx);
94     uint32_t GetFrameUncompressSize();
95 
96     //!
97     //! \brief  Calculate tile level command Buffer Size
98     //!
99     //! \return uint32_t
100     //!         Command buffer size calculated
101     //!
102     virtual MOS_STATUS CalculateTileStateCommandSize();
103 
104     Av1Pipeline *          m_av1Pipeline        = nullptr;
105     Av1BasicFeature *      m_av1BasicFeature    = nullptr;
106     DecodeAllocator *      m_allocator          = nullptr;
107     std::shared_ptr<mhw::vdbox::avp::Itf> m_avpItf = nullptr;
108 
109     // Parameters passed from application
110     CodecAv1PicParams      *m_av1PicParams      = nullptr;      //!< Pointer to AV1 picture parameter
111     CodecAv1SegmentsParams *m_segmentParams     = nullptr;      //!< Pointer to AV1 segments parameter
112     CodecAv1TileParams     *m_av1TileParams     = nullptr;      //!< Pointer to AV1 tiles parameter
113 
114     uint32_t m_tileStatesSize      = 0;  //!< Tile state command size
115     uint32_t m_tilePatchListSize   = 0;  //!< Tile patch list size
116 
117 MEDIA_CLASS_DEFINE_END(decode__Av1DecodeTilePkt)
118 };
119 
120 }  // namespace decode
121 #endif
122