summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Langdale <philipl@overt.org>2023-12-10 21:00:42 +0800
committerPhilip Langdale <github.philipl@overt.org>2023-12-15 14:17:19 -0800
commitef56c0c20a6f94bfc4b9f2d5880a16933835283b (patch)
tree6c7025ef7b25427e54ed347a7002315949d30faf
parent672829439a21d8290ffa866a1bbe48e659036451 (diff)
downloadmpv-ef56c0c20a6f94bfc4b9f2d5880a16933835283b.tar.bz2
mpv-ef56c0c20a6f94bfc4b9f2d5880a16933835283b.tar.xz
hwdec_drmprime: try and declare support for weird forked ffmpeg formats
As a result of the work I did the explicitly check for formats supported by the vo in the f_autoconvert logic, I introduced a regression in the handling of the rpi4_8 and rpi4_10 formats. These require special handling because they only exist in the rpi forks and not upstream ffmpeg, which means they don't have stable pix fmt values that we can use directly. Previously, we simply didn't declare them as supported, which was ok, as nothing was really enforcing the list of supported formats, but that has changed. As we still can't simply use the pix fmts, I had to do a slightly ridiculous dance to look them up by name, and if they exist, then register them as supported. Good times.
-rw-r--r--video/out/hwdec/hwdec_drmprime.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/video/out/hwdec/hwdec_drmprime.c b/video/out/hwdec/hwdec_drmprime.c
index f7c6250cb6..a5f9c664fb 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"
@@ -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.
+ */
+const static 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,14 @@ 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));
+
+ 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;