1 /*
2 * Copyright (c) 2021-2024, 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_huc_packet_creator.h
24 //!
25 
26 #ifndef __CODECHAL_HUC_PACKET_CREATOR_H__
27 #define __CODECHAL_HUC_PACKET_CREATOR_H__
28 
29 #include "decode_huc_packet_creator_base.h"
30 
31 #define DECALRE_HUC_KERNEL(hucName, platform)                                                                                    \
32     using hucName##platform##CreatorFunc = std::function<CmdPacket *(MediaPipeline *, MediaTask *, CodechalHwInterfaceNext *)>;  \
33                                                                                                                                  \
34 public:                                                                                                                          \
35     static bool Set##hucName##platform##CreatorFunc(hucName##platform##CreatorFunc creatorEntry, bool forceOverwrite)            \
36     {                                                                                                                            \
37         hucName##platform##CreatorFunc &entry = Get##hucName##platform##CreatorFunc();                                           \
38         if (forceOverwrite || !entry)                                                                                            \
39         {                                                                                                                        \
40             entry = creatorEntry;                                                                                                \
41         }                                                                                                                        \
42         return true;                                                                                                             \
43     }                                                                                                                            \
44                                                                                                                                  \
45     CmdPacket *Create##hucName##platform##Packet(MediaPipeline *pipeline, MediaTask *task, CodechalHwInterfaceNext *hwInterface) \
46     {                                                                                                                            \
47         auto createFunc = Get##hucName##platform##CreatorFunc();                                                                 \
48         return createFunc(pipeline, task, hwInterface);                                                                          \
49     }                                                                                                                            \
50                                                                                                                                  \
51 private:                                                                                                                         \
52     static hucName##platform##CreatorFunc &Get##hucName##platform##CreatorFunc()                                                 \
53     {                                                                                                                            \
54         static hucName##platform##CreatorFunc m_##hucName##platform##HucPktCreatorFunc;                                          \
55         return m_##hucName##platform##HucPktCreatorFunc;                                                                         \
56     }
57 
58 #define CREATE_HUC_PACKET(hucName, platform, pipeline, task, hwInterface) Create##hucName##platform##Packet(pipeline, task, hwInterface)
59 
60 #define REGISTER_HUC_PACKET(hucName, platform, hucPacket, forceOverWrite)                                                                  \
61     static CmdPacket *Create##hucName##platform##hucPacket(MediaPipeline *pipeline, MediaTask *task, CodechalHwInterfaceNext *hwInterface) \
62     {                                                                                                                                      \
63         CmdPacket *hucName##platform##Pkt = MOS_New(hucPacket, pipeline, task, hwInterface);                                               \
64         return hucName##platform##Pkt;                                                                                                     \
65     }                                                                                                                                      \
66     static bool volatile hucPacket##platform##packetCreatorFlag = HucPacketCreator::Set##hucName##platform##CreatorFunc(Create##hucName##platform##hucPacket, forceOverWrite);
67 
68 namespace decode
69 {
70 class HucPacketCreator : public HucPacketCreatorBase
71 {
72 public:
73 
HucPacketCreator()74     HucPacketCreator()
75     {
76     }
77 
~HucPacketCreator()78     virtual ~HucPacketCreator() {}
79 
80     virtual HucCopyPktItf *CreateHucCopyPkt(MediaPipeline *pipeline, MediaTask *task, CodechalHwInterfaceNext *hwInterface) override;
81     virtual CmdPacket *    CreateProbUpdatePkt(MediaPipeline *pipeline, MediaTask *task, CodechalHwInterfaceNext *hwInterface) override;
82 
83     virtual HucCopyPktItf *CreateStreamOutInterface(
84         MediaPipeline       *pipeline,
85         MediaTask           *task,
86         CodechalHwInterfaceNext *hwInterface) override;
87 
88     DECALRE_HUC_KERNEL(VvcS2L, Xe2Lpm)
89 
90 MEDIA_CLASS_DEFINE_END(decode__HucPacketCreator)
91 };
92 
93 }  // namespace decode
94 #endif
95