1 /*
2 * Copyright (c) 2020-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 //!
24 //! \file decode_filmgrain_presubpipeline_g12.cpp
25 //! \brief Defines the preSubpipeline for film grain generate noise
26 //! \details Defines the preSubpipeline for film grain generate noise, including getRandomValues, regressPhase1, regressPhase2 kernels.
27 //!
28 #include "decode_filmgrain_presubpipeline_g12.h"
29 #include "decode_basic_feature.h"
30 #include "decode_pipeline.h"
31 #include "decode_av1_filmgrain_feature_g12.h"
32 #include "decode_av1_feature_defs_g12.h"
33
34 namespace decode {
35
FilmGrainPreSubPipeline(DecodePipeline * pipeline,MediaTask * task,uint8_t numVdbox,CodechalHwInterface * hwInterface)36 FilmGrainPreSubPipeline::FilmGrainPreSubPipeline(DecodePipeline *pipeline, MediaTask *task, uint8_t numVdbox, CodechalHwInterface* hwInterface)
37 : DecodeSubPipeline(pipeline, task, numVdbox)
38 {
39 m_hwInterface = hwInterface;
40 }
41
Init(CodechalSetting & settings)42 MOS_STATUS FilmGrainPreSubPipeline::Init(CodechalSetting &settings)
43 {
44 DECODE_CHK_NULL(m_pipeline);
45
46 CodechalHwInterface *hwInterface = m_hwInterface;
47 DECODE_CHK_NULL(hwInterface);
48 PMOS_INTERFACE osInterface = hwInterface->GetOsInterface();
49 DECODE_CHK_NULL(osInterface);
50 InitScalabilityPars(osInterface);
51
52 m_allocator = m_pipeline->GetDecodeAllocator();
53 DECODE_CHK_NULL(m_allocator);
54
55 MediaFeatureManager* featureManager = m_pipeline->GetFeatureManager();
56 DECODE_CHK_NULL(featureManager);
57 m_basicFeature = dynamic_cast<DecodeBasicFeature*>(featureManager->GetFeature(FeatureIDs::basicFeature));
58 DECODE_CHK_NULL(m_basicFeature);
59
60 m_filmGrainFeature = dynamic_cast<Av1DecodeFilmGrainG12 *>(featureManager->GetFeature(Av1FeatureIDs::av1SwFilmGrain));
61 DECODE_CHK_NULL(m_filmGrainFeature);
62
63 //Create Packets
64 m_filmGrainGrvPkt = MOS_New(FilmGrainGrvPacket, m_pipeline, m_task, hwInterface);
65 Av1PipelineG12 *pipeline = dynamic_cast<Av1PipelineG12 *>(m_pipeline);
66 DECODE_CHK_NULL(pipeline);
67 DECODE_CHK_STATUS(RegisterPacket(DecodePacketId(pipeline, av1FilmGrainGrvPacketId), *m_filmGrainGrvPkt));
68 DECODE_CHK_STATUS(m_filmGrainGrvPkt->Init());
69
70 m_filmGrainRp1Pkt = MOS_New(FilmGrainRp1Packet, m_pipeline, m_task, hwInterface);
71 DECODE_CHK_STATUS(RegisterPacket(DecodePacketId(pipeline, av1FilmGrainRp1PacketId), *m_filmGrainRp1Pkt));
72 DECODE_CHK_STATUS(m_filmGrainRp1Pkt->Init());
73
74 m_filmGrainRp2Pkt = MOS_New(FilmGrainRp2Packet, m_pipeline, m_task, hwInterface);
75 DECODE_CHK_STATUS(RegisterPacket(DecodePacketId(pipeline, av1FilmGrainRp2PacketId), *m_filmGrainRp2Pkt));
76 DECODE_CHK_STATUS(m_filmGrainRp2Pkt->Init());
77
78 return MOS_STATUS_SUCCESS;
79 }
80
Prepare(DecodePipelineParams & params)81 MOS_STATUS FilmGrainPreSubPipeline::Prepare(DecodePipelineParams ¶ms)
82 {
83 if (params.m_pipeMode == decodePipeModeBegin)
84 {
85 DECODE_CHK_STATUS(Begin());
86 }
87 else if (params.m_pipeMode == decodePipeModeProcess)
88 {
89 DECODE_CHK_NULL(params.m_params);
90 CodechalDecodeParams *decodeParams = params.m_params;
91 DECODE_CHK_STATUS(DoFilmGrainGenerateNoise(*decodeParams));
92 }
93
94 return MOS_STATUS_SUCCESS;
95 }
96
Begin()97 MOS_STATUS FilmGrainPreSubPipeline::Begin()
98 {
99 DECODE_CHK_STATUS(DecodeSubPipeline::Reset());
100
101 return MOS_STATUS_SUCCESS;
102 }
103
DoFilmGrainGenerateNoise(const CodechalDecodeParams & decodeParams)104 MOS_STATUS FilmGrainPreSubPipeline::DoFilmGrainGenerateNoise(const CodechalDecodeParams &decodeParams)
105 {
106 if (m_filmGrainFeature->m_filmGrainEnabled)
107 {
108 //Step1: Get Random Values
109 DECODE_CHK_STATUS(GetRandomValuesKernel(decodeParams));
110
111 //Step2: regressPhase1
112 DECODE_CHK_STATUS(RegressPhase1Kernel(decodeParams));
113
114 //Step3: regressPhase2
115 DECODE_CHK_STATUS(RegressPhase2Kernel(decodeParams));
116 }
117
118 return MOS_STATUS_SUCCESS;
119 }
120
GetRandomValuesKernel(const CodechalDecodeParams & decodeParams)121 MOS_STATUS FilmGrainPreSubPipeline::GetRandomValuesKernel(const CodechalDecodeParams &decodeParams)
122 {
123 Av1PipelineG12 *pipeline = dynamic_cast<Av1PipelineG12 *>(m_pipeline);
124 DECODE_CHK_NULL(pipeline);
125 DECODE_CHK_STATUS(ActivatePacket(DecodePacketId(pipeline, av1FilmGrainGrvPacketId), true, 0, 0));
126
127 return MOS_STATUS_SUCCESS;
128 }
129
RegressPhase1Kernel(const CodechalDecodeParams & decodeParams)130 MOS_STATUS FilmGrainPreSubPipeline::RegressPhase1Kernel(const CodechalDecodeParams &decodeParams)
131 {
132 Av1PipelineG12 *pipeline = dynamic_cast<Av1PipelineG12 *>(m_pipeline);
133 DECODE_CHK_NULL(pipeline);
134 DECODE_CHK_STATUS(ActivatePacket(DecodePacketId(pipeline, av1FilmGrainRp1PacketId), true, 0, 0));
135
136 return MOS_STATUS_SUCCESS;
137 }
138
RegressPhase2Kernel(const CodechalDecodeParams & decodeParams)139 MOS_STATUS FilmGrainPreSubPipeline::RegressPhase2Kernel(const CodechalDecodeParams &decodeParams)
140 {
141 Av1PipelineG12 *pipeline = dynamic_cast<Av1PipelineG12 *>(m_pipeline);
142 DECODE_CHK_NULL(pipeline);
143 DECODE_CHK_STATUS(ActivatePacket(DecodePacketId(pipeline, av1FilmGrainRp2PacketId), true, 0, 0));
144
145 return MOS_STATUS_SUCCESS;
146 }
147
GetMediaFunction()148 MediaFunction FilmGrainPreSubPipeline::GetMediaFunction()
149 {
150 if(!MEDIA_IS_SKU(m_pipeline->GetSkuTable(), FtrCCSNode))
151 {
152 return RenderGenericFunc;
153 }
154
155 return ComputeVppFunc;
156 }
157
InitScalabilityPars(PMOS_INTERFACE osInterface)158 void FilmGrainPreSubPipeline::InitScalabilityPars(PMOS_INTERFACE osInterface)
159 {
160 m_decodeScalabilityPars.disableScalability = true;
161 m_decodeScalabilityPars.disableRealTile = true;
162 m_decodeScalabilityPars.enableVE = MOS_VE_SUPPORTED(osInterface);
163 m_decodeScalabilityPars.numVdbox = m_numVdbox;
164 }
165
166 }
167