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_mpeg2_pipeline_adapter_m12.cpp
24 //! \brief    Defines the interface to adapt to mpeg2 decode pipeline
25 //!
26 
27 #include "decode_mpeg2_pipeline_adapter_m12.h"
28 #include "decode_utils.h"
29 
DecodeMpeg2PipelineAdapterM12(CodechalHwInterface * hwInterface,CodechalDebugInterface * debugInterface)30 DecodeMpeg2PipelineAdapterM12::DecodeMpeg2PipelineAdapterM12(
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 DecodeMpeg2PipelineAdapterM12::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 DecodeMpeg2PipelineAdapterM12::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 DecodeMpeg2PipelineAdapterM12::Allocate(CodechalSetting *codecHalSettings)
62 {
63     DECODE_FUNC_CALL();
64 
65     m_decoder = std::make_shared<decode::Mpeg2PipelineM12>(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 DecodeMpeg2PipelineAdapterM12::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 DecodeMpeg2PipelineAdapterM12::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 DecodeMpeg2PipelineAdapterM12::IsIncompletePicture()
92 {
93      return (!m_decoder->IsCompleteBitstream());
94 }
95 
GetDummyReference()96 MOS_SURFACE *DecodeMpeg2PipelineAdapterM12::GetDummyReference()
97 {
98     DECODE_FUNC_CALL();
99     return m_decoder->GetDummyReference();
100 }
101 
GetDummyReferenceStatus()102 CODECHAL_DUMMY_REFERENCE_STATUS DecodeMpeg2PipelineAdapterM12::GetDummyReferenceStatus()
103 {
104     DECODE_FUNC_CALL();
105     return m_decoder->GetDummyReferenceStatus();
106 }
107 
SetDummyReferenceStatus(CODECHAL_DUMMY_REFERENCE_STATUS status)108 void DecodeMpeg2PipelineAdapterM12::SetDummyReferenceStatus(CODECHAL_DUMMY_REFERENCE_STATUS status)
109 {
110     DECODE_FUNC_CALL();
111     m_decoder->SetDummyReferenceStatus(status);
112 }
113 
GetCompletedReport()114 uint32_t DecodeMpeg2PipelineAdapterM12::GetCompletedReport()
115 {
116     return m_decoder->GetCompletedReport();
117 }
118 
Destroy()119 void DecodeMpeg2PipelineAdapterM12::Destroy()
120 {
121     DECODE_FUNC_CALL();
122 
123     m_decoder->Destroy();
124 }
125 
GetDecodeContext()126 MOS_GPU_CONTEXT DecodeMpeg2PipelineAdapterM12::GetDecodeContext()
127 {
128     DECODE_FUNC_CALL();
129 
130     return m_decoder->GetDecodeContext();
131 }
132 
GetDecodeContextHandle()133 GPU_CONTEXT_HANDLE DecodeMpeg2PipelineAdapterM12::GetDecodeContextHandle()
134 {
135     DECODE_FUNC_CALL();
136 
137     return m_decoder->GetDecodeContextHandle();
138 }
139 
140 #ifdef _DECODE_PROCESSING_SUPPORTED
IsDownSamplingSupported()141 bool DecodeMpeg2PipelineAdapterM12::IsDownSamplingSupported()
142 {
143     return false;
144 }
145 #endif
146 
147