From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id D4BF84D8B6 for ; Mon, 2 Jun 2025 11:54:39 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 334F868DE15; Mon, 2 Jun 2025 14:54:37 +0300 (EEST) Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id A3BF168DA2E for ; Mon, 2 Jun 2025 14:54:29 +0300 (EEST) Received: from haasn.dev (unknown [10.30.1.1]) by haasn.dev (Postfix) with UTF8SMTP id 3B87440C81; Mon, 2 Jun 2025 13:54:29 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Mon, 2 Jun 2025 13:54:27 +0200 Message-ID: <20250602115427.47647-1-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.49.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avfilter/vf_blackdetect_vulkan: fix black region reporting 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: From: Niklas Haas The old logic failed to take into account files that ended on ablack region. The new logic matches the vf_blackdetect behavior. --- libavfilter/vf_blackdetect_vulkan.c | 30 +++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/libavfilter/vf_blackdetect_vulkan.c b/libavfilter/vf_blackdetect_vulkan.c index 4e977abe3d..fdebfd955a 100644 --- a/libavfilter/vf_blackdetect_vulkan.c +++ b/libavfilter/vf_blackdetect_vulkan.c @@ -42,7 +42,6 @@ typedef struct BlackDetectVulkanContext { int alpha; int64_t black_start; - int64_t black_end; } BlackDetectVulkanContext; typedef struct BlackDetectPushData { @@ -145,6 +144,7 @@ static av_cold int init_filter(AVFilterContext *ctx) RET(ff_vk_shader_register_exec(vkctx, &s->e, &s->shd)); + s->black_start = AV_NOPTS_VALUE; s->initialized = 1; fail: @@ -156,6 +156,22 @@ fail: return err; } +static void report_black_region(AVFilterContext *ctx, int64_t black_end) +{ + BlackDetectVulkanContext *s = ctx->priv; + const AVFilterLink *inlink = ctx->inputs[0]; + if (s->black_start == AV_NOPTS_VALUE) + return; + + if ((black_end - s->black_start) >= s->black_min_duration_time / av_q2d(inlink->time_base)) { + av_log(s, AV_LOG_INFO, + "black_start:%s black_end:%s black_duration:%s\n", + av_ts2timestr(s->black_start, &inlink->time_base), + av_ts2timestr(black_end, &inlink->time_base), + av_ts2timestr(black_end - s->black_start, &inlink->time_base)); + } +} + static void evaluate(AVFilterLink *link, AVFrame *in, const BlackDetectBuf *sum) { @@ -183,15 +199,9 @@ static void evaluate(AVFilterLink *link, AVFrame *in, av_ts2timestr(in->pts, &in->time_base), 0); } } else if (s->black_start != AV_NOPTS_VALUE) { + report_black_region(ctx, in->pts); av_dict_set(&in->metadata, "lavfi.black_end", av_ts2timestr(in->pts, &in->time_base), 0); - if ((in->pts - s->black_start) >= s->black_min_duration_time / av_q2d(in->time_base)) { - av_log(s, AV_LOG_INFO, - "black_start:%s black_end:%s black_duration:%s\n", - av_ts2timestr(s->black_start, &in->time_base), - av_ts2timestr(in->pts, &in->time_base), - av_ts2timestr(in->pts - s->black_start, &in->time_base)); - } s->black_start = AV_NOPTS_VALUE; } } @@ -349,8 +359,12 @@ fail: static void blackdetect_vulkan_uninit(AVFilterContext *avctx) { BlackDetectVulkanContext *s = avctx->priv; + AVFilterLink *inlink = avctx->inputs[0]; + FilterLink *inl = ff_filter_link(inlink); FFVulkanContext *vkctx = &s->vkctx; + report_black_region(avctx, inl->current_pts); + ff_vk_exec_pool_free(vkctx, &s->e); ff_vk_shader_free(vkctx, &s->shd); -- 2.49.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".