This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 37083b3105acebcdfbd8b9e2046e971db5d108c2 Author: Niklas Haas <[email protected]> AuthorDate: Sun Jul 5 16:16:21 2026 +0300 Commit: Niklas Haas <[email protected]> CommitDate: Fri Aug 14 10:41:40 2026 +0200 swscale/utils: add ff_sws_thread_exec() helper Simplified API that wraps slicethread create/execute/free, with fallback for systems without threading support. Signed-off-by: Niklas Haas <[email protected]> --- libswscale/swscale_internal.h | 8 ++++++++ libswscale/utils.c | 23 +++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index 58d441822e..e7f7f6be53 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -1196,6 +1196,14 @@ int ff_swscale(SwsInternal *c, const uint8_t *const src[], const int srcStride[] int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[], int dstSliceY, int dstSliceH); +/** + * Helper for dispatching a single function across multiple threads. This is + * a wrapper around avpriv_slicethread_create2() + avpriv_slicethread_execute2(), + * falling back to direct invocation if threading is not available. + */ +int ff_sws_thread_exec(void *priv, + int (*func)(void *priv, int jobnr, int threadnr, int nb_jobs, int nb_threads), + int nb_threads, int nb_jobs); //number of extra lines to process #define MAX_LINES_AHEAD 4 diff --git a/libswscale/utils.c b/libswscale/utils.c index d96ece2ac1..98baa6e73b 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -2442,3 +2442,26 @@ int ff_range_add(RangeList *rl, unsigned int start, unsigned int len) return 0; } + +int ff_sws_thread_exec(void *priv, + int (*func)(void *priv, int jobnr, int threadnr, int nb_jobs, int nb_threads), + int nb_threads, int nb_jobs) +{ + AVSliceThread *slicethread; + int ret = avpriv_slicethread_create2(&slicethread, priv, func, NULL, nb_threads); + if (ret == AVERROR(ENOSYS)) { + /* Fallback for build configurations without threading */ + for (int i = 0; i < nb_jobs; i++) { + int ret = func(priv, i, 0, nb_jobs, 1); + if (ret) + return ret; + } + return 0; + } else if (ret < 0) { + return ret; + } + + ret = avpriv_slicethread_execute2(slicethread, nb_jobs, 0); + avpriv_slicethread_free(&slicethread); + return ret; +} _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
