xref: /aosp_15_r20/external/intel-media-driver/media_softlet/linux/common/os/mos_decompression_base.cpp (revision ba62d9d3abf0e404f2022b4cd7a85e107f48596f)
1 /*
2 * Copyright (c) 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     mos_decompression_base.cpp
24 //! \brief    MOS decompression functions
25 //! \details  MOS decompression functions
26 //!
27 
28 #include "mos_decompression.h"
29 #include "media_interfaces_mmd_next.h"
30 
MosDecompressionBase(PMOS_CONTEXT osDriverContext)31 MosDecompressionBase::MosDecompressionBase(PMOS_CONTEXT osDriverContext)
32 {
33 #ifdef _MMC_SUPPORTED
34     MOS_OS_CHK_NULL_NO_STATUS_RETURN(osDriverContext);
35 
36     m_mediaMemDecompState = static_cast<MediaMemDecompBaseState *>(MmdDeviceNext::CreateFactory(osDriverContext));
37 
38 #endif
39 }
40 
~MosDecompressionBase()41 MosDecompressionBase::~MosDecompressionBase()
42 {
43 #ifdef _MMC_SUPPORTED
44     MOS_Delete(m_mediaMemDecompState);
45 #endif
46 }
47 
MemoryDecompress(PMOS_RESOURCE osResource)48 MOS_STATUS MosDecompressionBase::MemoryDecompress(
49     PMOS_RESOURCE osResource)
50 {
51     MOS_OS_CHK_NULL_RETURN(m_mediaMemDecompState);
52     m_mediaMemDecompState->MemoryDecompress(osResource);
53     return MOS_STATUS_SUCCESS;
54 }
55 
MediaMemoryCopy(PMOS_RESOURCE inputResource,PMOS_RESOURCE outputResource,bool outputCompressed)56 MOS_STATUS MosDecompressionBase::MediaMemoryCopy(
57     PMOS_RESOURCE inputResource,
58     PMOS_RESOURCE outputResource,
59     bool          outputCompressed)
60 {
61     MOS_OS_CHK_NULL_RETURN(m_mediaMemDecompState);
62     m_mediaMemDecompState->MediaMemoryCopy(
63         inputResource,
64         outputResource,
65         outputCompressed);
66 
67     return MOS_STATUS_SUCCESS;
68 }
69 
MediaMemoryCopy2D(PMOS_RESOURCE inputResource,PMOS_RESOURCE outputResource,uint32_t copyWidth,uint32_t copyHeight,uint32_t copyInputOffset,uint32_t copyOutputOffset,uint32_t bpp,bool outputCompressed)70 MOS_STATUS MosDecompressionBase::MediaMemoryCopy2D(
71     PMOS_RESOURCE inputResource,
72     PMOS_RESOURCE outputResource,
73     uint32_t      copyWidth,
74     uint32_t      copyHeight,
75     uint32_t      copyInputOffset,
76     uint32_t      copyOutputOffset,
77     uint32_t      bpp,
78     bool          outputCompressed)
79 {
80     MOS_OS_CHK_NULL_RETURN(m_mediaMemDecompState);
81 
82     m_mediaMemDecompState->MediaMemoryCopy2D(
83         inputResource,
84         outputResource,
85         copyWidth,
86         copyHeight,
87         copyInputOffset,
88         copyOutputOffset,
89         bpp,
90         outputCompressed);
91 
92     return MOS_STATUS_SUCCESS;
93 }
94