1 /*
2 * Copyright (c) 2019-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 //!
24 //! \file     vp_scalability_singlepipe.cpp
25 //! \brief    Defines the common interface for media vpp scalability singlepipe mode.
26 //! \details  The media scalability singlepipe interface is further sub-divided by component,
27 //!           this file is for the base interface which is shared by all components.
28 //!
29 #include "vp_scalability_singlepipe.h"
30 #include "vp_platform_interface.h"
31 
32 namespace vp
33 {
VpScalabilitySinglePipe(void * hwInterface,MediaContext * mediaContext,uint8_t componentType)34 VpScalabilitySinglePipe::VpScalabilitySinglePipe(void* hwInterface, MediaContext* mediaContext, uint8_t componentType) :
35     MediaScalabilitySinglePipe(hwInterface, mediaContext, componentType)
36 {
37     if (hwInterface == nullptr)
38     {
39         return;
40     }
41 
42     m_hwInterface = (PVP_MHWINTERFACE)hwInterface;
43     m_osInterface = m_hwInterface->m_osInterface;
44     m_miInterface = m_hwInterface->m_mhwMiInterface;
45     m_miItf       = m_hwInterface->m_vpPlatformInterface->GetMhwMiItf();
46 }
47 
~VpScalabilitySinglePipe()48 VpScalabilitySinglePipe::~VpScalabilitySinglePipe()
49 {
50     if (m_scalabilityOption)
51     {
52         MOS_Delete(m_scalabilityOption);
53         m_scalabilityOption = nullptr;
54     }
55 }
56 
Initialize(const MediaScalabilityOption & option)57 MOS_STATUS VpScalabilitySinglePipe::Initialize(const MediaScalabilityOption &option)
58 {
59     SCALABILITY_CHK_NULL_RETURN(m_osInterface);
60 
61     m_scalabilityOption = MOS_New(VpScalabilityOption, (const VpScalabilityOption &)option);
62     SCALABILITY_CHK_NULL_RETURN(m_scalabilityOption);
63     if (m_osInterface->osStreamState)
64     {
65         m_osInterface->osStreamState->component = COMPONENT_VPCommon;
66     }
67 
68     return MediaScalabilitySinglePipe::Initialize(option);
69 }
70 
CreateSinglePipe(void * hwInterface,MediaContext * mediaContext,uint8_t componentType)71 MOS_STATUS VpScalabilitySinglePipe::CreateSinglePipe(void *hwInterface, MediaContext *mediaContext, uint8_t componentType)
72 {
73     SCALABILITY_CHK_NULL_RETURN(hwInterface);
74     SCALABILITY_CHK_NULL_RETURN(mediaContext);
75 
76     ((PVP_MHWINTERFACE)hwInterface)->m_singlePipeScalability = MOS_New(VpScalabilitySinglePipe, hwInterface, mediaContext, scalabilityVp);
77     SCALABILITY_CHK_NULL_RETURN(((PVP_MHWINTERFACE)hwInterface)->m_singlePipeScalability);
78     return MOS_STATUS_SUCCESS;
79 }
80 }