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