1 /*
2 * Copyright (c) 2017-2018, 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     mhw_vdbox_vdenc_interface.cpp
24 //! \brief    MHW interface for constructing Vdenc commands for the Vdbox engine
25 //! \details  Defines the interfaces for constructing MHW Vdbox Vdenc commands across all platforms
26 //!
27 
28 #include "mhw_vdbox_vdenc_interface.h"
29 
30 const bool MhwVdboxVdencInterface::m_vdencFTQEnabled[NUM_VDENC_TARGET_USAGE_MODES] = {
31     0, 1, 1, 1, 1, 1, 1, 0
32 };
33 
34 const bool MhwVdboxVdencInterface::m_vdencBlockBasedSkipEnabled[NUM_VDENC_TARGET_USAGE_MODES] = {
35     0, 1, 1, 1, 1, 1, 0, 0
36 };
37 
MhwVdboxVdencInterface(PMOS_INTERFACE osInterface)38 MhwVdboxVdencInterface::MhwVdboxVdencInterface(PMOS_INTERFACE osInterface)
39 {
40     MHW_FUNCTION_ENTER;
41 
42     m_osInterface = osInterface;
43 
44     MHW_ASSERT(m_osInterface);
45 
46     if (m_osInterface->bUsesGfxAddress)
47     {
48         AddResourceToCmd = Mhw_AddResourceToCmd_GfxAddress;
49     }
50     else // bUsesPatchList
51     {
52         AddResourceToCmd = Mhw_AddResourceToCmd_PatchList;
53     }
54 }
55 
MosToMediaStateFormat(MOS_FORMAT format)56 uint32_t MhwVdboxVdencInterface::MosToMediaStateFormat(MOS_FORMAT format)
57 {
58     switch (format)
59     {
60     case Format_A8R8G8B8:
61     case Format_X8R8G8B8:
62     case Format_A8B8G8R8:
63         return MHW_MEDIASTATE_SURFACEFORMAT_R8G8B8A8_UNORM;
64     case Format_422H:
65     case Format_422V:
66         return MHW_MEDIASTATE_SURFACEFORMAT_PLANAR_422_8;
67     case Format_AYUV:
68     case Format_AUYV:
69         return MHW_MEDIASTATE_SURFACEFORMAT_A8Y8U8V8_UNORM;
70     case Format_NV12:
71     case Format_NV11:
72     case Format_P208:
73     case Format_IMC1:
74     case Format_IMC3:
75         return MHW_MEDIASTATE_SURFACEFORMAT_PLANAR_420_8;
76     case Format_400P:
77     case Format_P8:
78         return MHW_MEDIASTATE_SURFACEFORMAT_Y8_UNORM;
79     case Format_411P:
80     case Format_411R:
81         return MHW_MEDIASTATE_SURFACEFORMAT_PLANAR_411_8;
82     case Format_UYVY:
83         return MHW_MEDIASTATE_SURFACEFORMAT_YCRCB_SWAPY;
84     case Format_YVYU:
85         return MHW_MEDIASTATE_SURFACEFORMAT_YCRCB_SWAPUV;
86     case Format_VYUY:
87         return MHW_MEDIASTATE_SURFACEFORMAT_YCRCB_SWAPUVY;
88     case Format_YUY2:
89     case Format_YUYV:
90     case Format_444P:
91     case Format_IMC2:
92     case Format_IMC4:
93     default:
94         return MHW_MEDIASTATE_SURFACEFORMAT_YCRCB_NORMAL;
95     }
96 
97     return MHW_MEDIASTATE_SURFACEFORMAT_YCRCB_NORMAL;
98 }
99