Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Niklas Haas <ffmpeg@haasn.xyz>
To: ffmpeg-devel@ffmpeg.org
Cc: Niklas Haas <git@haasn.dev>
Subject: [FFmpeg-devel] [PATCH 4/5] avfilter/libplacebo: move hwctx init to init()
Date: Fri,  9 Feb 2024 15:53:48 +0100
Message-ID: <20240209145349.104511-4-ffmpeg@haasn.xyz> (raw)
In-Reply-To: <20240209145349.104511-1-ffmpeg@haasn.xyz>

From: Niklas Haas <git@haasn.dev>

---
 libavfilter/vf_libplacebo.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
index a9a3d884ce..f41d8be0c0 100644
--- a/libavfilter/vf_libplacebo.c
+++ b/libavfilter/vf_libplacebo.c
@@ -544,6 +544,7 @@ static int parse_shader(AVFilterContext *avctx, const void *shader, size_t len)
 
 static void libplacebo_uninit(AVFilterContext *avctx);
 static int libplacebo_config_input(AVFilterLink *inlink);
+static int init_vulkan(AVFilterContext *avctx);
 
 static int libplacebo_init(AVFilterContext *avctx)
 {
@@ -610,8 +611,7 @@ static int libplacebo_init(AVFilterContext *avctx)
     if (strcmp(s->fps_string, "none") != 0)
         RET(av_parse_video_rate(&s->fps, s->fps_string));
 
-    /* Note: s->vulkan etc. are initialized later, when hwctx is available */
-    return 0;
+    return init_vulkan(avctx);
 
 fail:
     return err;
@@ -656,13 +656,20 @@ static void input_uninit(LibplaceboInput *input)
     av_fifo_freep2(&input->out_pts);
 }
 
-static int init_vulkan(AVFilterContext *avctx, const AVVulkanDeviceContext *hwctx)
+static int init_vulkan(AVFilterContext *avctx)
 {
     int err = 0;
     LibplaceboContext *s = avctx->priv;
+    const AVVulkanDeviceContext *hwctx = NULL;
     uint8_t *buf = NULL;
     size_t buf_len;
 
+    if (avctx->hw_device_ctx) {
+        const AVHWDeviceContext *avhwctx = (void *) avctx->hw_device_ctx->data;
+        if (avhwctx->type == AV_HWDEVICE_TYPE_VULKAN)
+            hwctx = s->vkctx.hwctx = avhwctx->hwctx;
+    }
+
     if (hwctx) {
 #if PL_API_VER >= 278
         /* Import libavfilter vulkan context into libplacebo */
@@ -1127,18 +1134,9 @@ static int libplacebo_query_format(AVFilterContext *ctx)
 {
     int err;
     LibplaceboContext *s = ctx->priv;
-    const AVVulkanDeviceContext *vkhwctx = NULL;
     const AVPixFmtDescriptor *desc = NULL;
     AVFilterFormats *infmts = NULL, *outfmts = NULL;
 
-    if (ctx->hw_device_ctx) {
-        const AVHWDeviceContext *avhwctx = (void *) ctx->hw_device_ctx->data;
-        if (avhwctx->type == AV_HWDEVICE_TYPE_VULKAN)
-            vkhwctx = avhwctx->hwctx;
-    }
-
-    RET(init_vulkan(ctx, vkhwctx));
-
     while ((desc = av_pix_fmt_desc_next(desc))) {
         enum AVPixelFormat pixfmt = av_pix_fmt_desc_get_id(desc);
 
@@ -1150,7 +1148,7 @@ static int libplacebo_query_format(AVFilterContext *ctx)
 #endif
 
         if (pixfmt == AV_PIX_FMT_VULKAN) {
-            if (!vkhwctx || vkhwctx->act_dev != s->vulkan->device)
+            if (!s->vkctx.hwctx || s->vkctx.hwctx->act_dev != s->vulkan->device)
                 continue;
         }
 
-- 
2.43.0

_______________________________________________
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".

  parent reply	other threads:[~2024-02-09 14:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-09 14:53 [FFmpeg-devel] [PATCH 1/5] avfilter: tighten semantics on hw_device_ctx Niklas Haas
2024-02-09 14:53 ` [FFmpeg-devel] [PATCH 2/5] fftools/ffmpeg_filter: provide hwctx when probing graph Niklas Haas
2024-02-09 17:12   ` Anton Khirnov
2024-02-09 14:53 ` [FFmpeg-devel] [PATCH 3/5] avfilter/hwupload: move hwctx init to init() Niklas Haas
2024-02-09 17:17   ` Anton Khirnov
2024-02-09 14:53 ` Niklas Haas [this message]
2024-02-09 14:53 ` [FFmpeg-devel] [PATCH 5/5] avfilter/vsrc_ddagrab: " Niklas Haas
2024-02-09 16:53 ` [FFmpeg-devel] [PATCH 1/5] avfilter: tighten semantics on hw_device_ctx Anton Khirnov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240209145349.104511-4-ffmpeg@haasn.xyz \
    --to=ffmpeg@haasn.xyz \
    --cc=ffmpeg-devel@ffmpeg.org \
    --cc=git@haasn.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git