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_sfc_histogram_postsubpipeline.cpp
25 //! \brief Defines the postSubpipeline for decode SFC histogram
26 //! \details Defines the postSubpipline for decode SFC histogram
27 //!
28
29 #include "decode_pipeline.h"
30 #include "decode_common_feature_defs.h"
31 #include "decode_sfc_histogram_postsubpipeline.h"
32 #include "decode_huc_packet_creator_base.h"
33
34 #ifdef _DECODE_PROCESSING_SUPPORTED
35
36 namespace decode {
37
DecodeSfcHistogramSubPipeline(DecodePipeline * pipeline,MediaTask * task,uint8_t numVdbox)38 DecodeSfcHistogramSubPipeline::DecodeSfcHistogramSubPipeline(DecodePipeline *pipeline,
39 MediaTask *task,
40 uint8_t numVdbox):
41 DecodeSubPipeline(pipeline, task, numVdbox)
42 {}
43
Init(CodechalSetting & settings)44 MOS_STATUS DecodeSfcHistogramSubPipeline::Init(CodechalSetting &settings)
45 {
46 DECODE_FUNC_CALL();
47 DECODE_CHK_NULL(m_pipeline);
48
49 CodechalHwInterfaceNext *hwInterface = m_pipeline->GetHwInterface();
50 DECODE_CHK_NULL(hwInterface);
51 m_osInterface = hwInterface->GetOsInterface();
52 DECODE_CHK_NULL(m_osInterface);
53 InitScalabilityPars(m_osInterface);
54
55 m_allocator = m_pipeline->GetDecodeAllocator();
56 DECODE_CHK_NULL(m_allocator);
57
58 auto featureManger = m_pipeline->GetFeatureManager();
59 DECODE_CHK_NULL(featureManger);
60 m_basicFeature = dynamic_cast<DecodeBasicFeature*>(featureManger->GetFeature(FeatureIDs::basicFeature));
61 DECODE_CHK_NULL(m_basicFeature);
62
63 m_downsampFeature = dynamic_cast<DecodeDownSamplingFeature*>(featureManger->GetFeature(
64 DecodeFeatureIDs::decodeDownSampling));
65
66 //Create Packets
67 HucPacketCreatorBase *hucPktCreator = dynamic_cast<HucPacketCreatorBase *>(m_pipeline);
68 DECODE_CHK_NULL(hucPktCreator);
69 m_copyPkt = hucPktCreator->CreateHucCopyPkt(m_pipeline, m_task, hwInterface);
70 DECODE_CHK_NULL(m_copyPkt);
71 MediaPacket *packet = dynamic_cast<MediaPacket *>(m_copyPkt);
72 DECODE_CHK_NULL(packet);
73 DECODE_CHK_STATUS(RegisterPacket(DecodePacketId(m_pipeline, hucCopyPacketId), *packet));
74 DECODE_CHK_STATUS(packet->Init());
75
76 return MOS_STATUS_SUCCESS;
77 }
78
Prepare(DecodePipelineParams & params)79 MOS_STATUS DecodeSfcHistogramSubPipeline::Prepare(DecodePipelineParams ¶ms)
80 {
81 DECODE_FUNC_CALL();
82 if (params.m_pipeMode == decodePipeModeBegin)
83 {
84 DECODE_CHK_STATUS(Begin());
85 }
86 else if (params.m_pipeMode == decodePipeModeProcess &&
87 m_downsampFeature != nullptr && m_downsampFeature->m_histogramBuffer != nullptr) //m_downsampFeature could be null if downsampling is not enabled
88 {
89 DECODE_CHK_NULL(params.m_params);
90 DECODE_CHK_NULL(m_basicFeature);
91 DECODE_CHK_NULL(m_downsampFeature->m_histogramBuffer);
92
93 CodechalDecodeParams* decodeParams = params.m_params;
94 PMOS_RESOURCE src = &m_downsampFeature->m_histogramBuffer->OsResource;
95 PMOS_RESOURCE dest = &decodeParams->m_histogramSurface.OsResource;
96 uint32_t destOffset = decodeParams->m_histogramSurface.dwOffset;
97 if (!m_allocator->ResourceIsNull(src) &&
98 !m_allocator->ResourceIsNull(dest))
99 {
100 DECODE_CHK_STATUS(CopyHistogramToDestBuf(src, dest, destOffset));
101 }
102 }
103
104 return MOS_STATUS_SUCCESS;
105 }
106
Begin()107 MOS_STATUS DecodeSfcHistogramSubPipeline::Begin()
108 {
109 DECODE_FUNC_CALL();
110 DECODE_CHK_STATUS(DecodeSubPipeline::Reset());
111
112 return MOS_STATUS_SUCCESS;
113 }
114
GetMediaFunction()115 MediaFunction DecodeSfcHistogramSubPipeline::GetMediaFunction()
116 {
117 DECODE_FUNC_CALL();
118 return VdboxDecodeWaFunc;
119 }
120
InitScalabilityPars(PMOS_INTERFACE osInterface)121 void DecodeSfcHistogramSubPipeline::InitScalabilityPars(PMOS_INTERFACE osInterface)
122 {
123 DECODE_FUNC_CALL();
124 m_decodeScalabilityPars.disableScalability = true;
125 m_decodeScalabilityPars.disableRealTile = true;
126 m_decodeScalabilityPars.enableVE = MOS_VE_SUPPORTED(osInterface);
127 m_decodeScalabilityPars.numVdbox = m_numVdbox;
128 }
129
CopyHistogramToDestBuf(MOS_RESOURCE * src,MOS_RESOURCE * dest,uint32_t destOffset)130 MOS_STATUS DecodeSfcHistogramSubPipeline::CopyHistogramToDestBuf(MOS_RESOURCE* src,
131 MOS_RESOURCE* dest,
132 uint32_t destOffset)
133 {
134 DECODE_FUNC_CALL();
135 DECODE_CHK_NULL(src);
136 DECODE_CHK_NULL(dest);
137
138 DECODE_CHK_STATUS(ActivatePacket(DecodePacketId(m_pipeline, hucCopyPacketId), true, 0, 0));
139
140 HucCopyPktItf::HucCopyParams copyParams;
141 copyParams.srcBuffer = src;
142 copyParams.srcOffset = 0;
143 copyParams.destBuffer = dest;
144 copyParams.destOffset = destOffset;
145 copyParams.copyLength = HISTOGRAM_BINCOUNT * m_downsampFeature->m_histogramBinWidth;
146 DECODE_CHK_STATUS(m_copyPkt->PushCopyParams(copyParams));
147
148 return MOS_STATUS_SUCCESS;
149 }
150
151
152 }
153
154 #endif
155