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