summaryrefslogtreecommitdiffstats
path: root/video/out/hwdec/hwdec_drmprime.c
diff options
context:
space:
mode:
Diffstat (limited to 'video/out/hwdec/hwdec_drmprime.c')
-rw-r--r--video/out/hwdec/hwdec_drmprime.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/video/out/hwdec/hwdec_drmprime.c b/video/out/hwdec/hwdec_drmprime.c
index f7c6250..bf60405 100644
--- a/video/out/hwdec/hwdec_drmprime.c
+++ b/video/out/hwdec/hwdec_drmprime.c
@@ -23,6 +23,7 @@
#include <libavutil/hwcontext.h>
#include <libavutil/hwcontext_drm.h>
+#include <libavutil/pixdesc.h>
#include <xf86drm.h>
#include "config.h"
@@ -51,7 +52,7 @@ static void uninit(struct ra_hwdec *hw)
av_buffer_unref(&p->hwctx.av_device_ref);
}
-const static dmabuf_interop_init interop_inits[] = {
+static const dmabuf_interop_init interop_inits[] = {
#if HAVE_DMABUF_INTEROP_GL
dmabuf_interop_gl_init,
#endif
@@ -64,6 +65,18 @@ const static dmabuf_interop_init interop_inits[] = {
NULL
};
+/**
+ * Due to the fact that Raspberry Pi support only exists in forked ffmpegs and
+ * also requires custom pixel formats, we need some way to work with those formats
+ * without introducing any build time dependencies. We do this by looking up the
+ * pixel formats by name. As rpi is an important target platform for this hwdec
+ * we don't really have the luxury of ignoring these forks.
+ */
+static const char *forked_pix_fmt_names[] = {
+ "rpi4_8",
+ "rpi4_10",
+};
+
static int init(struct ra_hwdec *hw)
{
struct priv_owner *p = hw->priv;
@@ -119,6 +132,18 @@ static int init(struct ra_hwdec *hw)
MP_TARRAY_APPEND(p, p->formats, num_formats, IMGFMT_NV12);
MP_TARRAY_APPEND(p, p->formats, num_formats, IMGFMT_420P);
MP_TARRAY_APPEND(p, p->formats, num_formats, pixfmt2imgfmt(AV_PIX_FMT_NV16));
+ MP_TARRAY_APPEND(p, p->formats, num_formats, IMGFMT_P010);
+#ifdef AV_PIX_FMT_P210
+ MP_TARRAY_APPEND(p, p->formats, num_formats, pixfmt2imgfmt(AV_PIX_FMT_P210));
+#endif
+
+ for (int i = 0; i < MP_ARRAY_SIZE(forked_pix_fmt_names); i++) {
+ enum AVPixelFormat fmt = av_get_pix_fmt(forked_pix_fmt_names[i]);
+ if (fmt != AV_PIX_FMT_NONE) {
+ MP_TARRAY_APPEND(p, p->formats, num_formats, pixfmt2imgfmt(fmt));
+ }
+ }
+
MP_TARRAY_APPEND(p, p->formats, num_formats, 0); // terminate it
p->hwctx.hw_imgfmt = IMGFMT_DRMPRIME;