1 /*
2 * Copyright (c) 2019-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_pipeline_g12.h
24 //! \brief    Defines the interface for av1 decode pipeline
25 //!
26 #ifndef __DECODE_AV1_PIPELINE_G12_H__
27 #define __DECODE_AV1_PIPELINE_G12_H__
28 
29 #include "decode_av1_pipeline_g12_base.h"
30 #include "codec_def_decode_av1.h"
31 #include "decode_filmgrain_surf_init_g12.h"
32 #include "decode_filmgrain_presubpipeline_g12.h"
33 #include "decode_filmgrain_postsubpipeline_g12.h"
34 #include "decode_huc_packet_creator_g12.h"
35 
36 namespace decode
37 {
38     class FilmGrainSurfaceInit;
39     class FilmGrainPreSubPipeline;
40     class FilmGrainPostSubPipeline;
41     class Av1DecodePktG12;
42     class Av1PipelineG12 : public Av1PipelineG12_Base, public HucPacketCreatorG12
43     {
44     public:
45         //!
46         //! \brief  DecodePipeline constructor
47         //! \param  [in] hwInterface
48         //!         Pointer to CodechalHwInterface
49         //! \param  [in] debugInterface
50         //!         Pointer to CodechalDebugInterface
51         //!
52         Av1PipelineG12(
53             CodechalHwInterface *   hwInterface,
54             CodechalDebugInterface *debugInterface);
55 
~Av1PipelineG12()56         virtual ~Av1PipelineG12() {};
57 
58         virtual MOS_STATUS Init(void *settings) override;
59 
60         //!
61         //! \brief  Prepare interal parameters, should be invoked for each frame
62         //! \param  [in] params
63         //!         Pointer to the input parameters
64         //! \return MOS_STATUS
65         //!         MOS_STATUS_SUCCESS if success, else fail reason
66         //!
67         virtual MOS_STATUS Prepare(void *params) final;
68 
69         //!
70         //! \brief  Finish the execution for each frame
71         //! \return MOS_STATUS
72         //!         MOS_STATUS_SUCCESS if success, else fail reason
73         //!
74         virtual MOS_STATUS Execute() final;
75 
76         virtual MOS_STATUS GetStatusReport(void *status, uint16_t numStatus) override;
77 
78         uint32_t GetCompletedReport();
79 
80         virtual MOS_STATUS Destroy() override;
81 
82         DeclareDecodePacketId(av1FilmGrainGrvPacketId);  //!< declare packet ID for film grain getRandomValues kernel
83         DeclareDecodePacketId(av1FilmGrainRp1PacketId);  //!< declare packet ID for film grain RegressPhase1 kernel
84         DeclareDecodePacketId(av1FilmGrainRp2PacketId);  //!< declare packet ID for film grain RegressPhase2 kernel
85         DeclareDecodePacketId(av1FilmGrainAppPacketId);  //!< declare packet ID for film grain ApplyNoise kernel
86 
87     protected:
88         virtual MOS_STATUS Initialize(void *settings) override;
89         virtual MOS_STATUS Uninitialize() override;
90 
91         //!
92         //! \brief  User Feature Key Report
93         //! \return MOS_STATUS
94         //!         MOS_STATUS_SUCCESS if success, else fail reason
95         //!
96         virtual MOS_STATUS UserFeatureReport() override;
97 
98         //!
99         //! \brief  Create sub packets
100         //! \param  [in] codecSettings
101         //!         Codechal settings
102         //! \return MOS_STATUS
103         //!         MOS_STATUS_SUCCESS if success, else fail reason
104         //!
105         virtual MOS_STATUS CreateSubPackets(DecodeSubPacketManager& subPacketManager, CodechalSetting &codecSettings) override;
106 
107         //!
108         //! \brief  Initialize media context for decode pipeline
109         //! \return MOS_STATUS
110         //!         MOS_STATUS_SUCCESS if success, else fail reason
111         //!
112         MOS_STATUS InitContext();
113 
114         //!
115         //! \brief    Initialize MMC state
116         //!
117         //! \return   MOS_STATUS
118         //!           MOS_STATUS_SUCCESS if success
119         //!
120         virtual MOS_STATUS InitMmcState();
121 
122 #if USE_CODECHAL_DEBUG_TOOL
123         //!
124         //! \brief  Dump render targets
125         //! \param  [in] reportData
126         //!         Decode report data
127         //! \return MOS_STATUS
128         //!         MOS_STATUS_SUCCESS if success, else fail reason
129         //!
130         virtual MOS_STATUS DumpOutput(const DecodeStatusReportData& reportData) override;
131 #endif
132 
133         //!
134         //! \brief  Create AV1 Decode feature manager for Gen12
135         //! \return MOS_STATUS
136         //!         MOS_STATUS_SUCCESS if success, else fail reason
137         //!
138         MOS_STATUS CreateFeatureManager() override;
139 
140         FilmGrainSurfaceInit        *m_fgCoordValSurfInitPipeline = nullptr;
141         FilmGrainPreSubPipeline     *m_fgGenNoiseSubPipeline = nullptr;    //!< Film Grain Generate Noise sub pipeline, used as pre-subpipeline before HW decoding
142         FilmGrainPostSubPipeline    *m_fgAppNoiseSubPipeline = nullptr;    //!< Film Grain Apply Noise sub pipeline, used as post-subpipeline after HW decoding
143         bool                         m_allowVirtualNodeReassign = false;   //!< Whether allow virtual node reassign
144 
145     private:
146         Av1DecodePktG12 *m_av1DecodePkt = nullptr;
147 
148     MEDIA_CLASS_DEFINE_END(decode__Av1PipelineG12)
149     };
150 }
151 #endif // !__DECODE_AV1_PIPELINE_G12_H__
152