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_filmgrain_surf_init_g12.h
24 //! \brief    Defines the common interface for decode input bitstream
25 //! \details  Defines the interface to handle the decode input bitstream in
26 //!           both single execution call mode and multiple excution call mode.
27 //!
28 
29 #ifndef __DECODE_FILMGRAIN_SURF_INIT_H__
30 #define __DECODE_FILMGRAIN_SURF_INIT_H__
31 
32 #include "decode_av1_pipeline_g12.h"
33 #include "decode_av1_filmgrain_feature_g12.h"
34 #include "decode_huc_copy_packet_g12.h"
35 
36 
37 namespace decode {
38 
39 class FilmGrainSurfaceInit : public DecodeSubPipeline
40 {
41 public:
42     //!
43     //! \brief  AV1 Decode Film Grain constructor
44     //!
45     FilmGrainSurfaceInit(DecodePipeline *pipeline, MediaTask *task, uint8_t numVdbox, CodechalHwInterface* hwInterface);
46 
47     //!
48     //! \brief  AV1 Decode Film Grain destructor
49     //!
50     virtual ~FilmGrainSurfaceInit();
51 
52     //!
53     //! \brief  Initialize the bitstream context
54     //!
55     //! \param  [in] settings
56     //!         Reference to the Codechal settings
57     //! \return MOS_STATUS
58     //!         MOS_STATUS_SUCCESS if success, else fail reason
59     //!
60     virtual MOS_STATUS Init(CodechalSetting &settings) override;
61 
62     //!
63     //! \brief  Prepare interal parameters
64     //! \param  [in] params
65     //!         Reference to decode pipeline parameters
66     //! \return MOS_STATUS
67     //!         MOS_STATUS_SUCCESS if success, else fail reason
68     //!
69     virtual MOS_STATUS Prepare(DecodePipelineParams &params) override;
70 
71     //!
72     //! \brief  Get media function for context switch
73     //! \return MediaFunction
74     //!         Return the media function
75     //!
76     MediaFunction GetMediaFunction() override;
77 
78 protected:
79     //!
80     //! \brief  Reset the bitstream context for each frame
81     //! \return MOS_STATUS
82     //!         MOS_STATUS_SUCCESS if success, else fail reason
83     //!
84     MOS_STATUS Begin();
85 
86     //!
87     //! \brief  Film Grain Surface Init
88     //! \return MOS_STATUS
89     //!         MOS_STATUS_SUCCESS if success, else fail reason
90     //!
91     MOS_STATUS InitCoordinateSurface();
92 
93     //!
94     //! \brief  Initialize scalability parameters
95     //!
96     virtual void InitScalabilityPars(PMOS_INTERFACE osInterface) override;
97 
98 private:
99     Av1DecodeFilmGrainG12 * m_filmGrainFeature   = nullptr;        //!< Film Grain feature
100     DecodeAllocator *       m_allocator            = nullptr;        //!< Resource allocator
101     HucCopyPktG12 *         m_surfInitPkt          = nullptr;        //!< Surface init packet
102     PMOS_BUFFER             m_tmpInitBuf           = nullptr;        //!< Init buffer filled with 0
103     CodechalHwInterface    *m_hwInterface          = nullptr;
104     MEDIA_CLASS_DEFINE_END(decode__FilmGrainSurfaceInit)
105 };
106 }  // namespace decode
107 #endif
108