[vlc-commits] avcodec: va: add a function to quickly check if the format might be decoded

Steve Lhomme git at videolan.org
Wed Jan 8 08:28:09 CET 2020


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Dec 18 09:33:54 2019 +0100| [8d94f8ecfc51cd655c9a0aa67678a2f4484381df] | committer: Steve Lhomme

avcodec: va: add a function to quickly check if the format might be decoded

Similar to vlc_va_GetChroma() but without forcing an output format.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8d94f8ecfc51cd655c9a0aa67678a2f4484381df
---

 modules/codec/avcodec/va.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++
 modules/codec/avcodec/va.h |  9 ++++++++
 2 files changed, 66 insertions(+)

diff --git a/modules/codec/avcodec/va.c b/modules/codec/avcodec/va.c
index fc3ef3fe8a..f045304efb 100644
--- a/modules/codec/avcodec/va.c
+++ b/modules/codec/avcodec/va.c
@@ -95,6 +95,63 @@ vlc_fourcc_t vlc_va_GetChroma(enum PixelFormat hwfmt, enum PixelFormat swfmt)
     }
 }
 
+bool vlc_va_MightDecode(enum PixelFormat hwfmt, enum PixelFormat swfmt)
+{
+    switch (hwfmt)
+    {
+        case AV_PIX_FMT_VAAPI_VLD:
+            switch (swfmt)
+            {
+                case AV_PIX_FMT_YUVJ420P:
+                case AV_PIX_FMT_YUV420P:
+                case AV_PIX_FMT_YUV420P10LE:
+                    return true;
+                default:
+                    return false;
+            }
+        case AV_PIX_FMT_DXVA2_VLD:
+            switch (swfmt)
+            {
+                case AV_PIX_FMT_YUV420P10LE:
+                case AV_PIX_FMT_YUVJ420P:
+                case AV_PIX_FMT_YUV420P:
+                    return true;
+                default:
+                    return false;
+            }
+            break;
+
+        case AV_PIX_FMT_D3D11VA_VLD:
+            switch (swfmt)
+            {
+                case AV_PIX_FMT_YUV420P10LE:
+                case AV_PIX_FMT_YUVJ420P:
+                case AV_PIX_FMT_YUV420P:
+                    return true;
+                default:
+                    return false;
+            }
+        break;
+
+        case AV_PIX_FMT_VDPAU:
+            switch (swfmt)
+            {
+                case AV_PIX_FMT_YUVJ444P:
+                case AV_PIX_FMT_YUV444P:
+                case AV_PIX_FMT_YUVJ422P:
+                case AV_PIX_FMT_YUV422P:
+                case AV_PIX_FMT_YUVJ420P:
+                case AV_PIX_FMT_YUV420P:
+                    return true;
+                default:
+                    return false;
+            }
+            break;
+        default:
+            return false;
+    }
+}
+
 static int vlc_va_Start(void *func, bool forced, va_list ap)
 {
     vlc_va_t *va = va_arg(ap, vlc_va_t *);
diff --git a/modules/codec/avcodec/va.h b/modules/codec/avcodec/va.h
index 95d1303f68..8ef429f4f9 100644
--- a/modules/codec/avcodec/va.h
+++ b/modules/codec/avcodec/va.h
@@ -64,6 +64,15 @@ typedef int (*vlc_va_open)(vlc_va_t *, AVCodecContext *, const AVPixFmtDescripto
  */
 vlc_fourcc_t vlc_va_GetChroma(enum PixelFormat hwfmt, enum PixelFormat swfmt);
 
+/**
+ * Determines whether the hardware acceleration PixelFormat can be used to
+ * decode pixels similar to the software PixelFormat.
+ * @param hwfmt the hardware acceleration pixel format
+ * @param swfmt the software pixel format
+ * @return true if the hardware acceleration should be supported
+ */
+bool vlc_va_MightDecode(enum PixelFormat hwfmt, enum PixelFormat swfmt);
+
 /**
  * Creates an accelerated video decoding back-end for libavcodec.
  * @param obj parent VLC object



More information about the vlc-commits mailing list