[FFmpeg-devel] [PATCH 3/3] lavu/hwcontext_[vaapi|vulkan]: support mapping VUYA, P012, and Y412
Philip Langdale
philipl at overt.org
Tue Aug 16 07:36:41 EEST 2022
These two of the Microsoft formats used by Intel VAAPI are sufficiently
conventional that we can add simple mappings for them in the hwcontexts
to enable back and forth mapping so that Vulkan filters can be used
with vaapi decoding/encoding of these formats.
Note that as with P010, we have to map to full 16bit Vulkan formats and
so technically lose some information with P012 and Y412. The most
significant consequence of this is that when mapping form Vulkan back
to VAAPI, the underlying DRM format will actually be Y416 and so we
need a mapping entry for it, even though we haven't added that as a
pixel format.
Signed-off-by: Philip Langdale <philipl at overt.org>
---
libavutil/hwcontext_vaapi.c | 21 +++++++++++++++------
libavutil/hwcontext_vulkan.c | 10 ++++++++++
2 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
index c3e79907fd..15fea62a34 100644
--- a/libavutil/hwcontext_vaapi.c
+++ b/libavutil/hwcontext_vaapi.c
@@ -122,8 +122,8 @@ static const VAAPIFormatDescriptor vaapi_format_map[] = {
#ifdef VA_FOURCC_Y210
MAP(Y210, YUV422_10, Y210, 0),
#endif
-#ifdef VA_FOURCC_Y216
- MAP(Y216, YUV422_12, Y216, 0),
+#ifdef VA_FOURCC_Y212
+ MAP(Y212, YUV422_12, Y212, 0),
#endif
MAP(411P, YUV411, YUV411P, 0),
MAP(422V, YUV422, YUV440P, 0),
@@ -133,8 +133,8 @@ static const VAAPIFormatDescriptor vaapi_format_map[] = {
#ifdef VA_FOURCC_P010
MAP(P010, YUV420_10BPP, P010, 0),
#endif
-#ifdef VA_FOURCC_P016
- MAP(P016, YUV420_12, P016, 0),
+#ifdef VA_FOURCC_P012
+ MAP(P012, YUV420_12, P012, 0),
#endif
MAP(BGRA, RGB32, BGRA, 0),
MAP(BGRX, RGB32, BGR0, 0),
@@ -152,8 +152,8 @@ static const VAAPIFormatDescriptor vaapi_format_map[] = {
#ifdef VA_FOURCC_Y410
MAP(Y410, YUV444_10, Y410, 0),
#endif
-#ifdef VA_FOURCC_Y416
- MAP(Y416, YUV444_12, Y416, 0),
+#ifdef VA_FOURCC_Y412
+ MAP(Y412, YUV444_12, Y412, 0),
#endif
};
#undef MAP
@@ -1010,6 +1010,9 @@ static const struct {
DRM_MAP(NV12, 1, DRM_FORMAT_NV12),
#if defined(VA_FOURCC_P010) && defined(DRM_FORMAT_R16)
DRM_MAP(P010, 2, DRM_FORMAT_R16, DRM_FORMAT_RG1616),
+#endif
+#if defined(VA_FOURCC_P012) && defined(DRM_FORMAT_R16)
+ DRM_MAP(P012, 2, DRM_FORMAT_R16, DRM_FORMAT_RG1616),
#endif
DRM_MAP(BGRA, 1, DRM_FORMAT_ARGB8888),
DRM_MAP(BGRX, 1, DRM_FORMAT_XRGB8888),
@@ -1021,6 +1024,12 @@ static const struct {
#endif
DRM_MAP(ARGB, 1, DRM_FORMAT_BGRA8888),
DRM_MAP(XRGB, 1, DRM_FORMAT_BGRX8888),
+#ifdef VA_FOURCC_AYUV
+ DRM_MAP(AYUV, 1, DRM_FORMAT_AYUV),
+#endif
+#ifdef VA_FOURCC_Y412
+ DRM_MAP(Y412, 1, DRM_FORMAT_Y412),
+#endif
};
#undef DRM_MAP
diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 237caa4bc0..62db2633fa 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -173,6 +173,7 @@ static const struct {
{ AV_PIX_FMT_NV12, { VK_FORMAT_R8_UNORM, VK_FORMAT_R8G8_UNORM } },
{ AV_PIX_FMT_NV21, { VK_FORMAT_R8_UNORM, VK_FORMAT_R8G8_UNORM } },
{ AV_PIX_FMT_P010, { VK_FORMAT_R16_UNORM, VK_FORMAT_R16G16_UNORM } },
+ { AV_PIX_FMT_P012, { VK_FORMAT_R16_UNORM, VK_FORMAT_R16G16_UNORM } },
{ AV_PIX_FMT_P016, { VK_FORMAT_R16_UNORM, VK_FORMAT_R16G16_UNORM } },
{ AV_PIX_FMT_NV16, { VK_FORMAT_R8_UNORM, VK_FORMAT_R8G8_UNORM } },
@@ -210,6 +211,9 @@ static const struct {
{ AV_PIX_FMT_YUVA444P12, { VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM } },
{ AV_PIX_FMT_YUVA444P16, { VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM } },
+ { AV_PIX_FMT_VUYA, { VK_FORMAT_R8G8B8A8_UNORM } },
+ { AV_PIX_FMT_Y412, { VK_FORMAT_R16G16B16A16_UNORM } },
+
{ AV_PIX_FMT_BGRA, { VK_FORMAT_B8G8R8A8_UNORM } },
{ AV_PIX_FMT_RGBA, { VK_FORMAT_R8G8B8A8_UNORM } },
{ AV_PIX_FMT_RGB24, { VK_FORMAT_R8G8B8_UNORM } },
@@ -2629,6 +2633,12 @@ static const struct {
{ DRM_FORMAT_XRGB8888, VK_FORMAT_B8G8R8A8_UNORM },
{ DRM_FORMAT_ABGR8888, VK_FORMAT_R8G8B8A8_UNORM },
{ DRM_FORMAT_XBGR8888, VK_FORMAT_R8G8B8A8_UNORM },
+
+ { DRM_FORMAT_AYUV, VK_FORMAT_R8G8B8A8_UNORM },
+ { DRM_FORMAT_Y412, VK_FORMAT_R16G16B16A16_UNORM },
+ // As we had to map Y412 to a 16bit Vulkan format, reverse mapping will
+ // end up yielding Y416 as the DRM format, so we need to recognise it.
+ { DRM_FORMAT_Y416, VK_FORMAT_R16G16B16A16_UNORM },
};
static inline VkFormat drm_to_vulkan_fmt(uint32_t drm_fourcc)
--
2.34.1
More information about the ffmpeg-devel
mailing list