Merge pull request 'firefox-fourier 0003: proper V4L2REQUEST type acceptance patch (closes #60)' (#63) from firefox-0003-v4l2request-proper-2026-05-21 into main
build and publish packages / distcc-avahi-aarch64 (push) Successful in 4s
build and publish packages / mesa-panvk-bifrost-aarch64 (push) Successful in 4s
build and publish packages / lmcp-any (push) Successful in 3s
build and publish packages / lmcp-debian (push) Successful in 3s
build and publish packages / claude-his-any (push) Successful in 3s
build and publish packages / ffmpeg-v4l2-request-aarch64 (push) Successful in 4s
build and publish packages / claude-his-debian (push) Successful in 4s
build and publish packages / ffmpeg-v4l2-request-debian (push) Successful in 3s
build and publish packages / libva-v4l2-request-fourier-aarch64 (push) Successful in 3s
build and publish packages / daedalus-v4l2-debian (push) Successful in 3s
build and publish packages / mpv-fourier-aarch64 (push) Successful in 3s
build and publish packages / libva-v4l2-request-fourier-debian (push) Successful in 3s
build and publish packages / daedalus-v4l2-dkms-debian (push) Successful in 3s
build and publish packages / mpv-fourier-debian (push) Successful in 3s

Reviewed-on: #63
This commit was merged in pull request #63.
This commit is contained in:
2026-05-21 05:10:27 +00:00
@@ -18,27 +18,30 @@ This patch adds a sibling init path, `InitV4L2RequestDecoder`, that:
* looks up the codec via two complementary mechanisms libavcodec * looks up the codec via two complementary mechanisms libavcodec
uses for v4l2_request: uses for v4l2_request:
- **named codec** (`h264_v4l2request`, `vp8_v4l2request`, etc.): - **named codec** (`h264_v4l2request`, `vp8_v4l2request`, etc.):
the legacy AVCodec-per-hwaccel registration. ALARM, Debian, the legacy AVCodec-per-hwaccel registration.
and most distros building with --enable-v4l2-request expose - **generic codec + hw_configs walk**: the modern hwaccel
this (avcodec_find_decoder_by_name lookup). registration. Accepts EITHER AV_HWDEVICE_TYPE_DRM (legacy
- **generic codec + AV_HWDEVICE_TYPE_DRM** in `hw_configs`: ffmpeg-v4l2-request-fork output prior to FFmpeg 7.1) OR
the modern hwaccel registration on some upstream-only ffmpeg AV_HWDEVICE_TYPE_V4L2REQUEST (FFmpeg 7.1+ dedicated enum,
builds. value 13 on Kwiboo's no-AMF tree, 14 on upstream-AMF tree).
Mozilla's bundled libavutil headers may not have the V4L2REQUEST
enumerator, so the test is on the integer value via `(int)cast`.
Probes named-codec first (explicit, portable) and falls back to Probes named-codec first (explicit, portable) and falls back to
walking the generic codec's `hw_configs` for the DRM device type; walking the generic codec's `hw_configs` for either device type;
* creates an `AV_HWDEVICE_TYPE_DRM` hwdevice context bound to * creates an hwdevice context bound to `/dev/dri/renderD128`. Uses
`/dev/dri/renderD128` via the new `av_hwdevice_ctx_create` wrapper integer 13 (V4L2REQUEST as defined by Kwiboo's v4l2-request-n7.1.3
(patch 2/4) and attaches it to the codec context; tree, what our libavcodec61-fourier emits) cast to enum
AVHWDeviceType for the av_hwdevice_ctx_create call;
* reuses the existing `ChooseV4L2PixelFormat` get-format callback * reuses the existing `ChooseV4L2PixelFormat` get-format callback
(already returns `AV_PIX_FMT_DRM_PRIME`) and the existing (already returns `AV_PIX_FMT_DRM_PRIME`) and the existing
`apply_cropping = 0` constraint. `apply_cropping = 0` constraint.
`InitV4L2RequestDecoder` is invoked **before** `InitV4L2Decoder` in `InitV4L2RequestDecoder` is invoked **before** `InitV4L2Decoder` in
`InitHWDecoderIfAllowed`. On Rockchip mainline it succeeds via either `InitHWDecoderIfAllowed`. On Rockchip mainline it succeeds via either
mechanism (ALARM uses the named codec). On Pi4 / Mediatek / mechanism. On Pi4 / Mediatek / vendor-MPP-stateful boards neither
vendor-MPP-stateful boards neither mechanism is registered for the mechanism is registered for the codec, the function bails out, and the
codec, the function bails out, and the existing stateful existing stateful `InitV4L2Decoder` runs as before. No regression of
`InitV4L2Decoder` runs as before. No regression of stateful boards. stateful boards.
`mDRMDeviceContext` is unconditionally `av_buffer_unref`'d in `mDRMDeviceContext` is unconditionally `av_buffer_unref`'d in
`ProcessShutdown` (no-op when null). Gated behind `ProcessShutdown` (no-op when null). Gated behind
@@ -46,9 +49,8 @@ codec, the function bails out, and the existing stateful
Bug 1969297. Bug 1969297.
diff --git a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.h b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.h --- a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.h 2026-05-21 04:57:59.570946601 +0000
--- a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.h 2026-03-18 19:22:14.000000000 +0000 +++ b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.h 2026-05-21 04:57:59.876488776 +0000
+++ b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.h 2026-04-27 20:43:39.347992674 +0000
@@ -225,7 +225,12 @@ @@ -225,7 +225,12 @@
bool IsLinuxHDR() const; bool IsLinuxHDR() const;
MediaResult InitVAAPIDecoder(); MediaResult InitVAAPIDecoder();
@@ -73,9 +75,8 @@ diff --git a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.h b/dom/media/platfor
// If video overlay is used we want to upload SW decoded frames to // If video overlay is used we want to upload SW decoded frames to
// DMABuf and present it as a external texture to rendering pipeline. // DMABuf and present it as a external texture to rendering pipeline.
bool mUploadSWDecodeToDMABuf = false; bool mUploadSWDecodeToDMABuf = false;
diff --git a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp --- a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp 2026-05-21 04:57:59.566685221 +0000
--- a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp 2026-04-27 16:09:10.000000000 +0200 +++ b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp 2026-05-21 04:58:00.136004159 +0000
+++ b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp 2026-04-29 00:10:00.098884335 +0200
@@ -403,6 +403,129 @@ @@ -403,6 +403,129 @@
return NS_OK; return NS_OK;
} }
@@ -90,7 +91,7 @@ diff --git a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp b/dom/media/platf
+ } + }
+ const char* drmDevice = "/dev/dri/renderD128"; + const char* drmDevice = "/dev/dri/renderD128";
+ if (mLib->av_hwdevice_ctx_create(&mDRMDeviceContext, + if (mLib->av_hwdevice_ctx_create(&mDRMDeviceContext,
+ AV_HWDEVICE_TYPE_DRM, drmDevice, + (enum AVHWDeviceType)13, drmDevice,
+ nullptr, 0) < 0) { + nullptr, 0) < 0) {
+ FFMPEG_LOG(" av_hwdevice_ctx_create(DRM, %s) failed", drmDevice); + FFMPEG_LOG(" av_hwdevice_ctx_create(DRM, %s) failed", drmDevice);
+ return false; + return false;
@@ -143,7 +144,7 @@ diff --git a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp b/dom/media/platf
+ for (int i = 0;; i++) { + for (int i = 0;; i++) {
+ const AVCodecHWConfig* cfg = mLib->avcodec_get_hw_config(generic, i); + const AVCodecHWConfig* cfg = mLib->avcodec_get_hw_config(generic, i);
+ if (!cfg) break; + if (!cfg) break;
+ if (cfg->device_type == AV_HWDEVICE_TYPE_DRM) { + if (cfg->device_type == AV_HWDEVICE_TYPE_DRM || (int)cfg->device_type == 13 || (int)cfg->device_type == 14) {
+ codec = generic; + codec = generic;
+ FFMPEG_LOG(" using generic codec %s with DRM hwaccel", codec->name); + FFMPEG_LOG(" using generic codec %s with DRM hwaccel", codec->name);
+ break; + break;