1 /*
2 * Copyright (c) 2018, 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     encode_huc_brc_init_packet.h
24 //! \brief    Defines the implementation of huc init packet
25 //!
26 
27 #ifndef __CODECHAL_HUC_BRC_INIT_PACKET_H__
28 #define __CODECHAL_HUC_BRC_INIT_PACKET_H__
29 
30 #include "media_cmd_packet.h"
31 #include "encode_huc.h"
32 #include "media_pipeline.h"
33 #include "codec_hw_next.h"
34 #include "encode_utils.h"
35 #include "encode_hevc_vdenc_pipeline.h"
36 #include "encode_hevc_basic_feature.h"
37 
38 namespace encode
39 {
40     class HucBrcInitPkt : public EncodeHucPkt
41     {
42     public:
HucBrcInitPkt(MediaPipeline * pipeline,MediaTask * task,CodechalHwInterfaceNext * hwInterface)43         HucBrcInitPkt(MediaPipeline *pipeline, MediaTask *task, CodechalHwInterfaceNext *hwInterface) :
44             EncodeHucPkt(pipeline, task, hwInterface)
45         {
46         }
47 
~HucBrcInitPkt()48         virtual ~HucBrcInitPkt() {}
49 
50         virtual MOS_STATUS Init() override;
51 
52         MOS_STATUS Submit(MOS_COMMAND_BUFFER *commandBuffer, uint8_t packetPhase = otherPacket) override;
53 
54         //!
55         //! \brief  Calculate Command Size
56         //!
57         //! \param  [in, out] commandBufferSize
58         //!         requested size
59         //! \param  [in, out] requestedPatchListSize
60         //!         requested size
61         //! \return MOS_STATUS
62         //!         status
63         //!
64         virtual MOS_STATUS CalculateCommandSize(
65             uint32_t &commandBufferSize,
66             uint32_t &requestedPatchListSize) override;
67 
68         //!
69         //! \brief  Get Packet Name
70         //! \return std::string
71         //!
GetPacketName()72         virtual std::string GetPacketName() override
73         {
74             return "BRCINIT";
75         }
76 
77     protected:
78         MHW_SETPAR_DECL_HDR(HUC_IMEM_STATE);
79         MHW_SETPAR_DECL_HDR(HUC_DMEM_STATE);
80         MHW_SETPAR_DECL_HDR(HUC_VIRTUAL_ADDR_STATE);
81         virtual MOS_STATUS AllocateResources() override;
82 
83         virtual MOS_STATUS SetDmemBuffer() const;
84 
85 #if USE_CODECHAL_DEBUG_TOOL
86         virtual MOS_STATUS DumpHucBrcInit();
87 #endif
88         static constexpr uint32_t               m_vdboxHucHevcBrcInitKernelDescriptor = 8;//!< Huc HEVC Brc init kernel descriptor
89 
90         uint32_t m_vdencBrcInitDmemBufferSize = sizeof(VdencHevcHucBrcInitDmem);
91         MOS_RESOURCE m_vdencBrcInitDmemBuffer[CODECHAL_ENCODE_RECYCLED_BUFFER_NUM] = {}; //!< VDEnc BrcInit DMEM buffer
92 
93         HevcBasicFeature    *m_basicFeature = nullptr;  //!< Hevc Basic Feature used in each frame
94 
95     MEDIA_CLASS_DEFINE_END(encode__HucBrcInitPkt)
96     };
97 
98 }  // namespace encode
99 #endif
100