This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit 218b4771a32153c434f1e87e5c3063c01c51c432
Author:     Michael Niedermayer <[email protected]>
AuthorDate: Sun Jun 7 21:38:20 2026 +0200
Commit:     michaelni <[email protected]>
CommitDate: Sat Jun 13 21:41:05 2026 +0000

    avfilter: add ff_slice_pos() helper for slice boundaries
    
    Slice based filter workers compute their per-thread row/sample/channel
    boundaries as total * jobnr / nb_jobs. The total * jobnr product is
    evaluated in int and overflows signed int for large dimensions and many
    slice threads, before the division by nb_jobs brings it back in range.
---
 libavfilter/filters.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/libavfilter/filters.h b/libavfilter/filters.h
index a152be4d47..57540d7698 100644
--- a/libavfilter/filters.h
+++ b/libavfilter/filters.h
@@ -750,6 +750,21 @@ int ff_filter_process_command(AVFilterContext *ctx, const 
char *cmd,
  */
 int ff_filter_get_nb_threads(AVFilterContext *ctx) av_pure;
 
+/**
+ * Compute the boundary index for a slice when work of size total is split
+ * into nb_jobs slices. Returns the first index of slice jobnr, so the slice
+ * jobnr covers [ff_slice_pos(total, jobnr, nb_jobs),
+ * ff_slice_pos(total, jobnr + 1, nb_jobs)).
+ *
+ * The multiplication is performed in 64bit to avoid signed overflow of the
+ * total * jobnr intermediate that would occur for large dimensions and many
+ * slice threads.
+ */
+static inline int ff_slice_pos(int total, int jobnr, int nb_jobs)
+{
+    return (int)((int64_t)total * jobnr / nb_jobs);
+}
+
 /**
  * Send a frame of data to the next filter.
  *

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to