1 /*
2 * Copyright (c) 2018-2020, 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_hevc_pipeline_adapter_m12.cpp
24 //! \brief    Defines the interface to adapt to hevc decode pipeline
25 //!
26 
27 #include "decode_hevc_pipeline_adapter_m12.h"
28 #include "decode_utils.h"
29 
DecodeHevcPipelineAdapterM12(CodechalHwInterface * hwInterface,CodechalDebugInterface * debugInterface)30 DecodeHevcPipelineAdapterM12::DecodeHevcPipelineAdapterM12(
31     CodechalHwInterface *   hwInterface,
32     CodechalDebugInterface *debugInterface)
33     : DecodePipelineAdapter(hwInterface, debugInterface)
34 {
35     DECODE_ASSERT(m_osInterface != nullptr);
36     if (m_osInterface != nullptr)
37     {
38         Mos_CheckVirtualEngineSupported(m_osInterface, true, true);
39         Mos_SetVirtualEngineSupported(m_osInterface, true);
40     }
41 }
42 
BeginFrame()43 MOS_STATUS DecodeHevcPipelineAdapterM12::BeginFrame()
44 {
45     DECODE_FUNC_CALL();
46 
47     decode::DecodePipelineParams decodeParams;
48     decodeParams.m_pipeMode = decode::decodePipeModeBegin;
49     DECODE_CHK_STATUS(m_decoder->Prepare(&decodeParams));
50     return m_decoder->Execute();
51 }
52 
EndFrame()53 MOS_STATUS DecodeHevcPipelineAdapterM12::EndFrame()
54 {
55     DECODE_FUNC_CALL();
56 
57     decode::DecodePipelineParams decodeParams;
58     decodeParams.m_pipeMode = decode::decodePipeModeEnd;
59     DECODE_CHK_STATUS(m_decoder->Prepare(&decodeParams));
60     return m_decoder->Execute();
61 }
62 
Allocate(CodechalSetting * codecHalSettings)63 MOS_STATUS DecodeHevcPipelineAdapterM12::Allocate(CodechalSetting *codecHalSettings)
64 {
65     DECODE_FUNC_CALL();
66 
67     m_decoder = std::make_shared<decode::HevcPipelineM12>(m_hwInterface, m_debugInterface);
68     DECODE_CHK_NULL(m_decoder);
69 
70     return m_decoder->Init(codecHalSettings);
71 }
72 
Execute(void * params)73 MOS_STATUS DecodeHevcPipelineAdapterM12::Execute(void    *params)
74 {
75     DECODE_FUNC_CALL();
76 
77     decode::DecodePipelineParams decodeParams;
78     decodeParams.m_params = (CodechalDecodeParams*)params;
79     decodeParams.m_pipeMode = decode::decodePipeModeProcess;
80     DECODE_CHK_STATUS(m_decoder->Prepare(&decodeParams));
81     return m_decoder->Execute();
82 }
83 
GetStatusReport(void * status,uint16_t numStatus)84 MOS_STATUS DecodeHevcPipelineAdapterM12::GetStatusReport(
85     void                *status,
86     uint16_t            numStatus)
87 {
88     DECODE_FUNC_CALL();
89 
90     return m_decoder->GetStatusReport(status, numStatus);
91 }
92 
IsIncompletePicture()93 bool DecodeHevcPipelineAdapterM12::IsIncompletePicture()
94 {
95      return (!m_decoder->IsCompleteBitstream());
96 }
97 
98 #ifdef _DECODE_PROCESSING_SUPPORTED
IsDownSamplingSupported()99 bool DecodeHevcPipelineAdapterM12::IsDownSamplingSupported()
100 {
101     return m_decoder->IsDownSamplingSupported();
102 }
103 #endif
104 
GetDummyReference()105 MOS_SURFACE* DecodeHevcPipelineAdapterM12::GetDummyReference()
106 {
107     DECODE_FUNC_CALL();
108     return m_decoder->GetDummyReference();
109 }
110 
GetDummyReferenceStatus()111 CODECHAL_DUMMY_REFERENCE_STATUS DecodeHevcPipelineAdapterM12::GetDummyReferenceStatus()
112 {
113     DECODE_FUNC_CALL();
114     return m_decoder->GetDummyReferenceStatus();
115 }
116 
SetDummyReferenceStatus(CODECHAL_DUMMY_REFERENCE_STATUS status)117 void DecodeHevcPipelineAdapterM12::SetDummyReferenceStatus(CODECHAL_DUMMY_REFERENCE_STATUS status)
118 {
119     DECODE_FUNC_CALL();
120     m_decoder->SetDummyReferenceStatus(status);
121 }
122 
GetCompletedReport()123 uint32_t DecodeHevcPipelineAdapterM12::GetCompletedReport()
124 {
125     return m_decoder->GetCompletedReport();
126 }
127 
Destroy()128 void DecodeHevcPipelineAdapterM12::Destroy()
129 {
130     DECODE_FUNC_CALL();
131 
132     m_decoder->Destroy();
133 }
134 
GetDecodeContext()135 MOS_GPU_CONTEXT DecodeHevcPipelineAdapterM12::GetDecodeContext()
136 {
137     DECODE_FUNC_CALL();
138 
139     return m_decoder->GetDecodeContext();
140 }
141 
142 
143