1 /* GStreamer Intel MSDK plugin
2 * Copyright (c) 2016, Oblong Industries, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
15 * 3. Neither the name of the copyright holder nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
28 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #include <va/va_drm.h>
37 #include "msdk_libva.h"
51 #define FOURCC_MFX_TO_VA(MFX, VA) \
52 { MFX_FOURCC_##MFX, VA_FOURCC_##VA }
54 #define RT_MFX_TO_VA(MFX, VA) \
55 { MFX_CHROMAFORMAT_##MFX, VA_RT_FORMAT_##VA }
57 static const struct fourcc_map gst_msdk_fourcc_mfx_to_va[] = {
58 FOURCC_MFX_TO_VA (NV12, NV12),
59 FOURCC_MFX_TO_VA (YUY2, YUY2),
60 FOURCC_MFX_TO_VA (UYVY, UYVY),
61 FOURCC_MFX_TO_VA (YV12, YV12),
62 FOURCC_MFX_TO_VA (RGB4, ARGB),
63 FOURCC_MFX_TO_VA (P8, P208),
64 FOURCC_MFX_TO_VA (P010, P010),
65 #if (MFX_VERSION >= 1031)
66 FOURCC_MFX_TO_VA (P016, P016),
67 FOURCC_MFX_TO_VA (Y216, Y216),
68 FOURCC_MFX_TO_VA (Y416, Y416),
70 #if (MFX_VERSION >= 1028)
71 FOURCC_MFX_TO_VA (RGB565, RGB565),
73 FOURCC_MFX_TO_VA (AYUV, AYUV),
74 #if VA_CHECK_VERSION(1, 4, 1)
75 FOURCC_MFX_TO_VA (A2RGB10, A2R10G10B10),
77 #if ((MFX_VERSION >= 1027) && VA_CHECK_VERSION(1, 2, 0))
78 FOURCC_MFX_TO_VA (Y210, Y210),
79 FOURCC_MFX_TO_VA (Y410, Y410),
81 FOURCC_MFX_TO_VA (BGR4, ABGR),
83 #if (MFX_VERSION >= 2004)
84 FOURCC_MFX_TO_VA (RGBP, RGBP),
85 FOURCC_MFX_TO_VA (BGRP, BGRP),
91 static const struct rt_map gst_msdk_rt_mfx_to_va[] = {
92 RT_MFX_TO_VA (YUV420, YUV420),
93 RT_MFX_TO_VA (YUV422, YUV422),
94 RT_MFX_TO_VA (YUV444, YUV444),
99 gst_msdk_get_mfx_status_from_va_status (VAStatus va_res)
101 mfxStatus mfxRes = MFX_ERR_NONE;
104 case VA_STATUS_SUCCESS:
105 mfxRes = MFX_ERR_NONE;
107 case VA_STATUS_ERROR_ALLOCATION_FAILED:
108 mfxRes = MFX_ERR_MEMORY_ALLOC;
110 case VA_STATUS_ERROR_ATTR_NOT_SUPPORTED:
111 case VA_STATUS_ERROR_UNSUPPORTED_PROFILE:
112 case VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT:
113 case VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT:
114 case VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE:
115 case VA_STATUS_ERROR_FLAG_NOT_SUPPORTED:
116 case VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED:
117 mfxRes = MFX_ERR_UNSUPPORTED;
119 case VA_STATUS_ERROR_INVALID_DISPLAY:
120 case VA_STATUS_ERROR_INVALID_CONFIG:
121 case VA_STATUS_ERROR_INVALID_CONTEXT:
122 case VA_STATUS_ERROR_INVALID_SURFACE:
123 case VA_STATUS_ERROR_INVALID_BUFFER:
124 case VA_STATUS_ERROR_INVALID_IMAGE:
125 case VA_STATUS_ERROR_INVALID_SUBPICTURE:
126 mfxRes = MFX_ERR_NOT_INITIALIZED;
128 case VA_STATUS_ERROR_INVALID_PARAMETER:
129 mfxRes = MFX_ERR_INVALID_VIDEO_PARAM;
132 mfxRes = MFX_ERR_UNKNOWN;
139 gst_msdk_get_va_fourcc_from_mfx_fourcc (mfxU32 fourcc)
141 const struct fourcc_map *m = gst_msdk_fourcc_mfx_to_va;
143 for (; m->mfx_fourcc != 0; m++) {
144 if (m->mfx_fourcc == fourcc)
152 gst_msdk_get_mfx_fourcc_from_va_fourcc (guint32 fourcc)
154 const struct fourcc_map *m = gst_msdk_fourcc_mfx_to_va;
156 for (; m->va_fourcc != 0; m++) {
157 if (m->va_fourcc == fourcc)
158 return m->mfx_fourcc;
165 gst_msdk_get_va_rt_format_from_mfx_rt_format (mfxU32 format)
167 const struct rt_map *m = gst_msdk_rt_mfx_to_va;
169 for (; m->mfx_rt_format != 0; m++) {
170 if (m->mfx_rt_format == format)
171 return m->va_rt_format;
178 gst_msdk_get_mfx_rt_format_from_va_rt_format (guint32 format)
180 const struct rt_map *m = gst_msdk_rt_mfx_to_va;
182 for (; m->va_rt_format != 0; m++) {
183 if (m->va_rt_format == format)
184 return m->mfx_rt_format;