From: Markus Fritsche Subject: [PATCH 2/4] dom/media/platforms/ffmpeg: wrap av_hwdevice_ctx_create Date: 2026-04-27 Background ---------- `FFmpegLibWrapper` already wraps `av_hwdevice_ctx_alloc` (no device path) and `av_hwdevice_ctx_init`, used by the VAAPI codepath which discovers the DRM device implicitly. The v4l2_request hwaccel needs the *path-aware* constructor `av_hwdevice_ctx_create`, which lets the caller pass `"/dev/dri/renderD128"` (or similar) directly when creating an `AV_HWDEVICE_TYPE_DRM` context. libavcodec then binds the v4l2_request hwaccel internally based on the codec's `hw_configs`. This patch adds the function pointer + the `AV_FUNC_OPTION_SILENT` registration. Same versioning as the other `av_hwdevice_ctx_*` wrappers (libavutil 58–62). No callers yet — patch 3/4 (FFmpegVideoDecoder routing) consumes it. Bug 1969297. diff --git a/dom/media/platforms/ffmpeg/FFmpegLibWrapper.h b/dom/media/platforms/ffmpeg/FFmpegLibWrapper.h --- a/dom/media/platforms/ffmpeg/FFmpegLibWrapper.h +++ b/dom/media/platforms/ffmpeg/FFmpegLibWrapper.h @@ -177,6 +177,11 @@ // libavutil >= 58 AVBufferRef* (*av_hwdevice_ctx_alloc)(int); int (*av_hwdevice_ctx_init)(AVBufferRef* ref); + // firefox-fourier: device-path-aware constructor needed to bind a + // DRM hwdevice (AV_HWDEVICE_TYPE_DRM) to /dev/dri/renderD* for the + // libavcodec v4l2_request hwaccel. + int (*av_hwdevice_ctx_create)(AVBufferRef** device_ctx, int type, + const char* device, void* opts, int flags); AVBufferRef* (*av_hwframe_ctx_alloc)(AVBufferRef* device_ctx); int (*av_hwframe_ctx_init)(AVBufferRef* ref); AVBufferRef* (*av_buffer_ref)(AVBufferRef* buf); diff --git a/dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp b/dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp --- a/dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp +++ b/dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp @@ -293,6 +293,11 @@ FFmpegLibWrapper::LinkResult FFmpegLibWrapper::Link() { AV_FUNC_AVUTIL_58 | AV_FUNC_AVUTIL_59 | AV_FUNC_AVUTIL_60 | AV_FUNC_AVUTIL_61 | AV_FUNC_AVUTIL_62) + // firefox-fourier: see comment in FFmpegLibWrapper.h + AV_FUNC_OPTION_SILENT(av_hwdevice_ctx_create, + AV_FUNC_AVUTIL_58 | AV_FUNC_AVUTIL_59 | + AV_FUNC_AVUTIL_60 | AV_FUNC_AVUTIL_61 | + AV_FUNC_AVUTIL_62) AV_FUNC_OPTION_SILENT( av_buffer_ref, AV_FUNC_AVUTIL_58 | AV_FUNC_AVUTIL_59 | AV_FUNC_AVUTIL_60 | AV_FUNC_AVUTIL_61 | AV_FUNC_AVUTIL_62)