* [FFmpeg-devel] [PATCH] avfilter/vf_blackdetect_vulkan: fix black region reporting
@ 2025-06-02 11:54 Niklas Haas
2025-06-03 9:26 ` Niklas Haas
0 siblings, 1 reply; 2+ messages in thread
From: Niklas Haas @ 2025-06-02 11:54 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Niklas Haas
From: Niklas Haas <git@haasn.dev>
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".
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avfilter/vf_blackdetect_vulkan: fix black region reporting
2025-06-02 11:54 [FFmpeg-devel] [PATCH] avfilter/vf_blackdetect_vulkan: fix black region reporting Niklas Haas
@ 2025-06-03 9:26 ` Niklas Haas
0 siblings, 0 replies; 2+ messages in thread
From: Niklas Haas @ 2025-06-03 9:26 UTC (permalink / raw)
To: ffmpeg-devel
On Mon, 02 Jun 2025 13:54:27 +0200 Niklas Haas <ffmpeg@haasn.xyz> wrote:
> From: Niklas Haas <git@haasn.dev>
>
> The old logic failed to take into account files that ended on ablack
> region. The new logic matches the vf_blackdetect behavior.
Will push if there are no objections.
_______________________________________________
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".
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-06-03 9:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-02 11:54 [FFmpeg-devel] [PATCH] avfilter/vf_blackdetect_vulkan: fix black region reporting Niklas Haas
2025-06-03 9:26 ` Niklas Haas
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