1 // Copyright (c) 2007-2020 Intel Corporation
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in all
11 // copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 // SOFTWARE.
20 
21 #if defined (MFX_VA)
22 
23 #include "libmfx_core_hw.h"
24 #include "mfx_common_decode_int.h"
25 #include "mfx_enc_common.h"
26 #include "mfx_ext_buffers.h"
27 
28 #include "umc_va_base.h"
29 
30 using namespace UMC;
31 
ChooseProfile(mfxVideoParam const * param,eMFXHWType)32 mfxU32 ChooseProfile(mfxVideoParam const* param, eMFXHWType)
33 {
34     mfxU32 profile = UMC::VA_VLD;
35 
36     // video accelerator is needed for decoders only
37     switch (param->mfx.CodecId)
38     {
39     case MFX_CODEC_VC1:
40         profile |= VA_VC1;
41         break;
42 
43     case MFX_CODEC_MPEG2:
44         profile |= VA_MPEG2;
45         break;
46 
47     case MFX_CODEC_AVC:
48         profile |= VA_H264;
49         break;
50 
51     case MFX_CODEC_JPEG:
52         profile |= VA_JPEG;
53         break;
54 
55     case MFX_CODEC_VP8:
56         profile |= VA_VP8;
57         break;
58 
59     case MFX_CODEC_VP9:
60         profile |= VA_VP9;
61         switch (param->mfx.FrameInfo.FourCC)
62         {
63         case MFX_FOURCC_P010:
64             profile |= VA_PROFILE_10;
65             break;
66         case MFX_FOURCC_AYUV:
67             profile |= VA_PROFILE_444;
68             break;
69 #if (MFX_VERSION >= 1027)
70         case MFX_FOURCC_Y410:
71             profile |= VA_PROFILE_10 | VA_PROFILE_444;
72             break;
73 #endif
74 #if (MFX_VERSION >= 1031)
75         case MFX_FOURCC_P016:
76             profile |= VA_PROFILE_12;
77             break;
78         case MFX_FOURCC_Y416:
79             profile |= VA_PROFILE_12 | VA_PROFILE_444;
80             break;
81 #endif
82         }
83         break;
84 
85 #if defined(MFX_ENABLE_AV1_VIDEO_DECODE)
86     case MFX_CODEC_AV1:
87         profile |= VA_AV1;
88         switch (param->mfx.FrameInfo.FourCC)
89         {
90         case MFX_FOURCC_P010:
91             profile |= VA_PROFILE_10;
92             break;
93         }
94         break;
95 #endif
96 
97 
98     case MFX_CODEC_HEVC:
99         profile |= VA_H265;
100         switch (param->mfx.FrameInfo.FourCC)
101         {
102             case MFX_FOURCC_P010:
103                 profile |= VA_PROFILE_10;
104                 break;
105             case MFX_FOURCC_YUY2:
106                 profile |= VA_PROFILE_422;
107                 break;
108             case MFX_FOURCC_AYUV:
109                 profile |= VA_PROFILE_444;
110                 break;
111 #if (MFX_VERSION >= 1027)
112             case MFX_FOURCC_Y210:
113                 profile |= VA_PROFILE_10 | VA_PROFILE_422;
114                 break;
115             case MFX_FOURCC_Y410:
116                 profile |= VA_PROFILE_10 | VA_PROFILE_444;
117                 break;
118 #endif
119 #if (MFX_VERSION >= 1031)
120             case MFX_FOURCC_P016:
121                 profile |= VA_PROFILE_12;
122                 break;
123             case MFX_FOURCC_Y216:
124                 profile |= VA_PROFILE_12 | VA_PROFILE_422;
125                 break;
126             case MFX_FOURCC_Y416:
127                 profile |= VA_PROFILE_12 | VA_PROFILE_444;
128                 break;
129 #endif
130         }
131 
132         {
133             mfxU32 const profile_idc = ExtractProfile(param->mfx.CodecProfile);
134 #if (MFX_VERSION >= 1032)
135             if (profile_idc == MFX_PROFILE_HEVC_SCC)
136                 profile |= VA_PROFILE_SCC;
137 #endif
138 
139 #if (MFX_VERSION >= 1027)
140             if (profile_idc == MFX_PROFILE_HEVC_REXT)
141                 profile |= VA_PROFILE_REXT;
142 #endif
143         }
144 
145         break;
146 
147     default:
148         return UMC::UNKNOWN;
149     }
150 
151 
152     return profile;
153 }
154 
155 
156 #endif
157 /* EOF */
158