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 >= 1028)
66 FOURCC_MFX_TO_VA (RGB565, RGB565),
68 FOURCC_MFX_TO_VA (AYUV, AYUV),
72 static const struct rt_map gst_msdk_rt_mfx_to_va[] = {
73 RT_MFX_TO_VA (YUV420, YUV420),
74 RT_MFX_TO_VA (YUV422, YUV422),
75 RT_MFX_TO_VA (YUV444, YUV444),
80 gst_msdk_get_mfx_status_from_va_status (VAStatus va_res)
82 mfxStatus mfxRes = MFX_ERR_NONE;
85 case VA_STATUS_SUCCESS:
86 mfxRes = MFX_ERR_NONE;
88 case VA_STATUS_ERROR_ALLOCATION_FAILED:
89 mfxRes = MFX_ERR_MEMORY_ALLOC;
91 case VA_STATUS_ERROR_ATTR_NOT_SUPPORTED:
92 case VA_STATUS_ERROR_UNSUPPORTED_PROFILE:
93 case VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT:
94 case VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT:
95 case VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE:
96 case VA_STATUS_ERROR_FLAG_NOT_SUPPORTED:
97 case VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED:
98 mfxRes = MFX_ERR_UNSUPPORTED;
100 case VA_STATUS_ERROR_INVALID_DISPLAY:
101 case VA_STATUS_ERROR_INVALID_CONFIG:
102 case VA_STATUS_ERROR_INVALID_CONTEXT:
103 case VA_STATUS_ERROR_INVALID_SURFACE:
104 case VA_STATUS_ERROR_INVALID_BUFFER:
105 case VA_STATUS_ERROR_INVALID_IMAGE:
106 case VA_STATUS_ERROR_INVALID_SUBPICTURE:
107 mfxRes = MFX_ERR_NOT_INITIALIZED;
109 case VA_STATUS_ERROR_INVALID_PARAMETER:
110 mfxRes = MFX_ERR_INVALID_VIDEO_PARAM;
113 mfxRes = MFX_ERR_UNKNOWN;
120 gst_msdk_get_va_fourcc_from_mfx_fourcc (mfxU32 fourcc)
122 const struct fourcc_map *m = gst_msdk_fourcc_mfx_to_va;
124 for (; m->mfx_fourcc != 0; m++) {
125 if (m->mfx_fourcc == fourcc)
133 gst_msdk_get_mfx_fourcc_from_va_fourcc (guint32 fourcc)
135 const struct fourcc_map *m = gst_msdk_fourcc_mfx_to_va;
137 for (; m->va_fourcc != 0; m++) {
138 if (m->va_fourcc == fourcc)
139 return m->mfx_fourcc;
146 gst_msdk_get_va_rt_format_from_mfx_rt_format (mfxU32 format)
148 const struct rt_map *m = gst_msdk_rt_mfx_to_va;
150 for (; m->mfx_rt_format != 0; m++) {
151 if (m->mfx_rt_format == format)
152 return m->va_rt_format;
159 gst_msdk_get_mfx_rt_format_from_va_rt_format (guint32 format)
161 const struct rt_map *m = gst_msdk_rt_mfx_to_va;
163 for (; m->va_rt_format != 0; m++) {
164 if (m->va_rt_format == format)
165 return m->mfx_rt_format;