Message ID | ZrUQdcSai7XrJ0Ya@vicerveza.homeunix.net |
---|---|
State | New |
Headers | show |
Series | [FFmpeg-devel] PATCH: Force vaapi image formats to NV12-only | expand |
Context | Check | Description |
---|---|---|
yinshiyou/commit_msg_loongarch64 | warning | The first line of the commit message must start with a context terminated by a colon and a space, for example "lavu/opt: " or "doc: ". |
> vaapi drivers often lack proper image converesions and not all > situations allow vagetimage or vaputimage with the image formats > reported by the api. nv12 seems allowed in all circumstances. > > with this change now one can use the hwaccel directly without > explicit conversions to nv12 for frame downloading to work. > > gstreamer adopted a similar approach: > https://bugzilla.gnome.org/show_bug.cgi?id=752958 > --- > libavutil/hwcontext_vaapi.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c > index 12bc95119a..d678e58d07 100644 > --- a/libavutil/hwcontext_vaapi.c > +++ b/libavutil/hwcontext_vaapi.c > @@ -418,7 +418,12 @@ static int vaapi_device_init(avhwdevicecontext *hwdev) > for (i = 0; i < image_count; i++) { > fourcc = image_list[i].fourcc; > pix_fmt = vaapi_pix_fmt_from_fourcc(fourcc); > - if (pix_fmt == av_pix_fmt_none) { > + if (pix_fmt != av_pix_fmt_nv12) { > + av_log(hwdev, av_log_debug, "format %#x -> ignored.\n", > + fourcc); > + continue; > + } > + else if (pix_fmt == av_pix_fmt_none) { > av_log(hwdev, av_log_debug, "format %#x -> unknown.\n", > fourcc); > } else { > -- > 2.44.1 Isn’t it break all pixel formats with bit depth > 8? I think we already have hwcontext API to select sw_format, this isn’t a bug inside ffmpeg. > On Aug 9, 2024, at 02:37, Lluís Batlle i Rossell <viric@viric.name> wrote: > > attached > <0001-Force-vaapi-image-formats-to-NV12-only.patch>_______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
On Fri, Aug 09, 2024 at 11:49:54AM +0800, Zhao Zhili wrote: > > vaapi drivers often lack proper image converesions and not all > > situations allow vagetimage or vaputimage with the image formats > > reported by the api. nv12 seems allowed in all circumstances. > > > > with this change now one can use the hwaccel directly without > > explicit conversions to nv12 for frame downloading to work. > > > > gstreamer adopted a similar approach: > > https://bugzilla.gnome.org/show_bug.cgi?id=752958 > > Isn’t it break all pixel formats with bit depth > 8? > I think we already have hwcontext API to select sw_format, this isn’t a bug > inside ffmpeg. Correct... I didn't think of the need beyond NV12. What if I redo the patch so I keep all formats, but I simply move NV12 to the first place? That will make ffmpeg pick NV12 as default if NONE specified.
diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index 12bc95119a..d678e58d07 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -418,7 +418,12 @@ static int vaapi_device_init(AVHWDeviceContext *hwdev) for (i = 0; i < image_count; i++) { fourcc = image_list[i].fourcc; pix_fmt = vaapi_pix_fmt_from_fourcc(fourcc); - if (pix_fmt == AV_PIX_FMT_NONE) { + if (pix_fmt != AV_PIX_FMT_NV12) { + av_log(hwdev, AV_LOG_DEBUG, "Format %#x -> ignored.\n", + fourcc); + continue; + } + else if (pix_fmt == AV_PIX_FMT_NONE) { av_log(hwdev, AV_LOG_DEBUG, "Format %#x -> unknown.\n", fourcc); } else {
attached From c6439f3a74529db25777029596791a62eb3c77d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= <viric@viric.name> Date: Thu, 8 Aug 2024 20:32:03 +0200 Subject: [PATCH] Force vaapi image formats to NV12-only Vaapi drivers often lack proper image converesions and not all situations allow vaGetImage or vaPutImage with the image formats reported by the API. NV12 seems allowed in all circumstances. With this change now one can use the hwaccel directly without explicit conversions to nv12 for frame downloading to work. gstreamer adopted a similar approach: https://bugzilla.gnome.org/show_bug.cgi?id=752958 --- libavutil/hwcontext_vaapi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)