[vlc-devel] [PATCH 01/10] avcodec: va: add a function to quickly check if the format might be decoded
Steve Lhomme
robux4 at ycbcr.xyz
Wed Dec 18 15:53:04 CET 2019
Similar to vlc_va_GetChroma() but without forcing an output format.
---
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 fc3ef3fe8ab..f045304efb5 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 95d1303f683..8ef429f4f96 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
--
2.17.1
More information about the vlc-devel
mailing list