From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 096E344CED for ; Tue, 15 Nov 2022 15:50:46 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 85E4468BC1C; Tue, 15 Nov 2022 17:50:43 +0200 (EET) Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DAF9F68B375 for ; Tue, 15 Nov 2022 17:50:36 +0200 (EET) Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 8CAE34B424; Tue, 15 Nov 2022 16:50:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1668527436; bh=+gp2oj5k9slSdIAClbsR2iLOVmfOIxmc5zZHClDg2Yw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Gx8S49rv1X+ec8JovnY91xB4y7HSsKHa+Knarpj2QwEtyp4d5LmCmLPyV2mLN8qqI g+hPIQ7XbhmrH9W0kXT+6+ohZ7/OTgYXbLV2tXc2sxRtXeViT3syBAI3ROz1PDANZT oBtN7q/eFoOe12DMYmuJvuTAW9+WVN07w/MDkiuE= Date: Tue, 15 Nov 2022 16:50:36 +0100 Message-ID: <20221115165036.GB32931@haasn.xyz> From: Niklas Haas To: ffmpeg-devel@ffmpeg.org In-Reply-To: <20221115140950.GB42218@haasn.xyz> References: <20221108131230.39188-1-ffmpeg@haasn.xyz> <20221115140950.GB42218@haasn.xyz> MIME-Version: 1.0 Content-Disposition: inline Subject: Re: [FFmpeg-devel] [PATCH 1/2] avfilter/vf_libplacebo: init vulkan device in query_format X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Niklas Haas Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Merged as c0b93c4f8 after ACK via IRC. On Tue, 15 Nov 2022 14:09:50 +0100 Niklas Haas wrote: > Merging in 48 hours if no replies. > > On Tue, 08 Nov 2022 14:12:29 +0100 Niklas Haas wrote: > > From: Niklas Haas > > > > Instead of doing it ad-hoc in `filter_frame`. This is not a huge change > > on its own, but paves the way for adding support for more formats in the > > future, in particular formats other than AV_PIX_FMT_VULKAN. > > --- > > libavfilter/vf_libplacebo.c | 35 ++++++++++++++++++++++++++++------- > > 1 file changed, 28 insertions(+), 7 deletions(-) > > > > diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c > > index cfee1117e8..cb6b021816 100644 > > --- a/libavfilter/vf_libplacebo.c > > +++ b/libavfilter/vf_libplacebo.c > > @@ -56,7 +56,6 @@ static const struct pl_tone_map_function * const tonemapping_funcs[TONE_MAP_COUN > > typedef struct LibplaceboContext { > > /* lavfi vulkan*/ > > FFVulkanContext vkctx; > > - int initialized; > > > > /* libplacebo */ > > pl_log log; > > @@ -237,10 +236,17 @@ static int init_vulkan(AVFilterContext *avctx) > > { > > int err = 0; > > LibplaceboContext *s = avctx->priv; > > - const AVVulkanDeviceContext *hwctx = s->vkctx.hwctx; > > + const AVVulkanDeviceContext *hwctx; > > uint8_t *buf = NULL; > > size_t buf_len; > > > > + if (!avctx->hw_device_ctx) { > > + av_log(s, AV_LOG_ERROR, "Missing vulkan hwdevice for vf_libplacebo.\n"); > > + return AVERROR(EINVAL); > > + } > > + > > + hwctx = ((AVHWDeviceContext*) avctx->hw_device_ctx->data)->hwctx; > > + > > /* Import libavfilter vulkan context into libplacebo */ > > s->vulkan = pl_vulkan_import(s->log, pl_vulkan_import_params( > > .instance = hwctx->inst, > > @@ -289,7 +295,6 @@ static int init_vulkan(AVFilterContext *avctx) > > fail: > > if (buf) > > av_file_unmap(buf, buf_len); > > - s->initialized = 1; > > return err; > > } > > > > @@ -303,7 +308,6 @@ static void libplacebo_uninit(AVFilterContext *avctx) > > pl_vulkan_destroy(&s->vulkan); > > pl_log_destroy(&s->log); > > ff_vk_uninit(&s->vkctx); > > - s->initialized = 0; > > s->gpu = NULL; > > } > > > > @@ -452,8 +456,6 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) > > } > > > > pl_log_level_update(s->log, get_log_level()); > > - if (!s->initialized) > > - RET(init_vulkan(ctx)); > > > > RET(av_frame_copy_props(out, in)); > > out->width = outlink->w; > > @@ -505,6 +507,25 @@ fail: > > return err; > > } > > > > +static int libplacebo_query_format(AVFilterContext *ctx) > > +{ > > + int err = 0; > > + static const enum AVPixelFormat pix_fmts[] = { > > + AV_PIX_FMT_VULKAN, AV_PIX_FMT_NONE, > > + }; > > + > > + RET(init_vulkan(ctx)); > > + > > + RET(ff_formats_ref(ff_make_format_list(pix_fmts), > > + &ctx->inputs[0]->outcfg.formats)); > > + RET(ff_formats_ref(ff_make_format_list(pix_fmts), > > + &ctx->outputs[0]->incfg.formats)); > > + return 0; > > + > > +fail: > > + return err; > > +} > > + > > static int libplacebo_config_output(AVFilterLink *outlink) > > { > > int err; > > @@ -755,7 +776,7 @@ const AVFilter ff_vf_libplacebo = { > > .process_command = &ff_filter_process_command, > > FILTER_INPUTS(libplacebo_inputs), > > FILTER_OUTPUTS(libplacebo_outputs), > > - FILTER_SINGLE_PIXFMT(AV_PIX_FMT_VULKAN), > > + FILTER_QUERY_FUNC(libplacebo_query_format), > > .priv_class = &libplacebo_class, > > .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE, > > }; > > -- > > 2.38.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". _______________________________________________ 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".