From patchwork Mon Sep 26 13:46:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Tomas_H=C3=A4rdin?= X-Patchwork-Id: 38336 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp2260900pzh; Mon, 26 Sep 2022 06:46:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM459xpPNN0nSTuiK9eRgwZgdy2MB0Q1i/L2MCCGlT5X+dqsdhVpKm8g8F7ImNbtgEj7Loix X-Received: by 2002:a17:907:724a:b0:782:405f:8115 with SMTP id ds10-20020a170907724a00b00782405f8115mr18069015ejc.147.1664200010259; Mon, 26 Sep 2022 06:46:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664200010; cv=none; d=google.com; s=arc-20160816; b=y5cv/8ex9wNoYaESeq2/RRQMhuBZgeuE0W9ZKs5r7S+GPrZdU9dq5wPmEUgkltuaYo bKZ5aM3hiQBHsx/E6Uc17cJLKI/Ql913GvymefFmyrkCVlvA+FaOPx2ITeNI30qvilS8 lPlDvGRH2XnatCMncNhGMlM2yx0BOEpYryWL635igLJ2gS+E0ajioJmo1Tqc3o0AWTB2 HO7bdtW2oJJYsK8L0jzwMBehMpX9FBR02dlJ7VIAVmM62vQ3IDAvuDDVWqeXeMlQE4Qd YjuB4ZJm0SmKyuoNHLPcRBoF3nTtH1BLxoAHu41iM5kIR/O1vHakQxHjDFiYV1BdofHe vv9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:user-agent:date:to:from:message-id:delivered-to; bh=iof/wXd7k7Lo9DDgfQst7abwHVzs6vK9CuRXdOInh6M=; b=McL/raqO+hTFJaiTpvv6tuwRLvjx6VToEgLmYCcTbRx6i6kEpyu6rp09A4yXKj7vZI doYXQuCExF5XEmkxwXl0PXkaVo969JFMHwNZL+Bt5PnJZauT1In65iNYqsMXnGRaLthz 3ew0ei2tncYLmwrYHuXp82EY6ofzfl0I2m/shhO1dGkkEcX2bbKY4Jx1O33gac1g4fvm W6ooov+nxnN8YTTbO6K/MGdcNlI2DAP7vK7nJ9qqwEg8viQ91CTsqd9ocO8K4ycSv+xO Q7jrv2rBMh5zzRI57rCfvbp8VYGTQzt7SvcUgvhy82X8PizdQt5GLWHFQsrCTV6fTxuH oK2g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id di4-20020a170906730400b0078238d39215si15634278ejc.483.2022.09.26.06.46.49; Mon, 26 Sep 2022 06:46:50 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7361268B9A4; Mon, 26 Sep 2022 16:46:45 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.frobbit.se (mail.frobbit.se [85.30.129.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E1BF768B0DC for ; Mon, 26 Sep 2022 16:46:38 +0300 (EEST) Received: from [10.10.150.19] (unknown [134.65.164.34]) by mail.frobbit.se (Postfix) with ESMTPSA id 9ED8E20101 for ; Mon, 26 Sep 2022 15:46:37 +0200 (CEST) Message-ID: <99afc63012bcb654bba64f2cadc2d1404316c027.camel@haerdin.se> From: Tomas =?iso-8859-1?q?H=E4rdin?= To: ffmpeg-devel Date: Mon, 26 Sep 2022 15:46:36 +0200 User-Agent: Evolution 3.38.3-1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3] Add avpriv_slicethread_create2() and avpriv_slicethread_execute2(), make execute() and execute2() return FFMIN() of thread return codes 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 2M+dwNVRSsrx Fixed the ABI break in the previous version of this patch, updated all internal uses of related APIs. Tested with both ./configure and ./configure --disable-pthreads Also using a new email for mailing list purposes. /Tomas From 265f1095fb85b1eba18ed1b89fe71531ee09fe9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= Date: Thu, 16 Jun 2022 12:16:44 +0200 Subject: [PATCH] Add avpriv_slicethread_create2() and avpriv_slicethread_execute2(), make execute() and execute2() return FFMIN() of thread return codes Updates all internal uses of related APIs. At the moment only fic.c actually checks return code of execute() hence the change to its FATE reference. --- doc/APIchanges | 4 ++ libavcodec/avcodec.c | 10 +++-- libavcodec/pthread_slice.c | 14 +++---- libavfilter/pthread.c | 8 ++-- libavutil/slicethread.c | 70 ++++++++++++++++++++++++++++++++--- libavutil/slicethread.h | 27 ++++++++++++++ libavutil/version.h | 2 +- libswscale/swscale.c | 20 ++-------- libswscale/swscale_internal.h | 6 +-- libswscale/utils.c | 8 ++-- tests/fate/screen.mak | 1 + tests/ref/fate/fic-avi | 30 +++++++-------- 12 files changed, 137 insertions(+), 63 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index b0a41c9e37..240e549a2f 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,10 @@ libavutil: 2021-04-27 API changes, most recent first: +2022-09-26 - xxxxxxxxxx - lavu 57.38.100 - slicethread.h + Deprecate avpriv_slicethread_create() and avpriv_slicethread_execute(). + Add avpriv_slicethread_create2() and avpriv_slicethread_execute2(). + 2022-09-26 - xxxxxxxxxx - lavc 59.48.100 - avcodec.h Deprecate avcodec_enum_to_chroma_pos() and avcodec_chroma_pos_to_enum(). Use av_chroma_location_enum_to_pos() or av_chroma_location_pos_to_enum() diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c index a85d3c2309..ee75b3abe7 100644 --- a/libavcodec/avcodec.c +++ b/libavcodec/avcodec.c @@ -44,28 +44,30 @@ int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2), void *arg, int *ret, int count, int size) { - int i; + int i, rr = 0; for (i = 0; i < count; i++) { int r = func(c, (char *)arg + i * size); + rr = FFMIN(rr, r); if (ret) ret[i] = r; } emms_c(); - return 0; + return rr; } int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int jobnr, int threadnr), void *arg, int *ret, int count) { - int i; + int i, rr = 0; for (i = 0; i < count; i++) { int r = func(c, arg, i, 0); + rr = FFMIN(rr, r); if (ret) ret[i] = r; } emms_c(); - return 0; + return rr; } static AVMutex codec_mutex = AV_MUTEX_INITIALIZER; diff --git a/libavcodec/pthread_slice.c b/libavcodec/pthread_slice.c index a4d31c6f4d..795d0c9c5a 100644 --- a/libavcodec/pthread_slice.c +++ b/libavcodec/pthread_slice.c @@ -61,13 +61,13 @@ typedef struct SliceThreadContext { Progress *progress; } SliceThreadContext; -static void main_function(void *priv) { +static int main_function(void *priv) { AVCodecContext *avctx = priv; SliceThreadContext *c = avctx->internal->thread_ctx; - c->mainfunc(avctx); + return c->mainfunc(avctx); } -static void worker_func(void *priv, int jobnr, int threadnr, int nb_jobs, int nb_threads) +static int worker_func(void *priv, int jobnr, int threadnr, int nb_jobs, int nb_threads) { AVCodecContext *avctx = priv; SliceThreadContext *c = avctx->internal->thread_ctx; @@ -77,6 +77,7 @@ static void worker_func(void *priv, int jobnr, int threadnr, int nb_jobs, int nb : c->func2(avctx, c->args, jobnr, threadnr); if (c->rets) c->rets[jobnr] = ret; + return ret; } void ff_slice_thread_free(AVCodecContext *avctx) @@ -112,8 +113,7 @@ static int thread_execute(AVCodecContext *avctx, action_func* func, void *arg, i c->func = func; c->rets = ret; - avpriv_slicethread_execute(c->thread, job_count, !!c->mainfunc ); - return 0; + return avpriv_slicethread_execute2(c->thread, job_count, !!c->mainfunc); } static int thread_execute2(AVCodecContext *avctx, action_func2* func2, void *arg, int *ret, int job_count) @@ -135,7 +135,7 @@ int ff_slice_thread_init(AVCodecContext *avctx) { SliceThreadContext *c; int thread_count = avctx->thread_count; - void (*mainfunc)(void *); + int (*mainfunc)(void *); // We cannot do this in the encoder init as the threads are created before if (av_codec_is_encoder(avctx->codec) && @@ -161,7 +161,7 @@ int ff_slice_thread_init(AVCodecContext *avctx) avctx->internal->thread_ctx = c = av_mallocz(sizeof(*c)); mainfunc = ffcodec(avctx->codec)->caps_internal & FF_CODEC_CAP_SLICE_THREAD_HAS_MF ? &main_function : NULL; - if (!c || (thread_count = avpriv_slicethread_create(&c->thread, avctx, worker_func, mainfunc, thread_count)) <= 1) { + if (!c || (thread_count = avpriv_slicethread_create2(&c->thread, avctx, worker_func, mainfunc, thread_count)) <= 1) { if (c) avpriv_slicethread_free(&c->thread); av_freep(&avctx->internal->thread_ctx); diff --git a/libavfilter/pthread.c b/libavfilter/pthread.c index 1a063d3cc0..855c842df9 100644 --- a/libavfilter/pthread.c +++ b/libavfilter/pthread.c @@ -43,12 +43,13 @@ typedef struct ThreadContext { int *rets; } ThreadContext; -static void worker_func(void *priv, int jobnr, int threadnr, int nb_jobs, int nb_threads) +static int worker_func(void *priv, int jobnr, int threadnr, int nb_jobs, int nb_threads) { ThreadContext *c = priv; int ret = c->func(c->ctx, c->arg, jobnr, nb_jobs); if (c->rets) c->rets[jobnr] = ret; + return ret; } static void slice_thread_uninit(ThreadContext *c) @@ -68,13 +69,12 @@ static int thread_execute(AVFilterContext *ctx, avfilter_action_func *func, c->func = func; c->rets = ret; - avpriv_slicethread_execute(c->thread, nb_jobs, 0); - return 0; + return avpriv_slicethread_execute2(c->thread, nb_jobs, 0); } static int thread_init_internal(ThreadContext *c, int nb_threads) { - nb_threads = avpriv_slicethread_create(&c->thread, c, worker_func, NULL, nb_threads); + nb_threads = avpriv_slicethread_create2(&c->thread, c, worker_func, NULL, nb_threads); if (nb_threads <= 1) avpriv_slicethread_free(&c->thread); return FFMAX(nb_threads, 1); diff --git a/libavutil/slicethread.c b/libavutil/slicethread.c index 115b099736..38c4ebdc4c 100644 --- a/libavutil/slicethread.c +++ b/libavutil/slicethread.c @@ -34,6 +34,7 @@ typedef struct WorkerContext { pthread_cond_t cond; pthread_t thread; int done; + int ret; } WorkerContext; struct AVSliceThread { @@ -50,11 +51,15 @@ struct AVSliceThread { int finished; void *priv; + // either worker_func and main_func are non-NULL or worker_func2 and main_func2 are + // all four are never non-NULL at the same time void (*worker_func)(void *priv, int jobnr, int threadnr, int nb_jobs, int nb_threads); void (*main_func)(void *priv); + int (*worker_func2)(void *priv, int jobnr, int threadnr, int nb_jobs, int nb_threads); + int (*main_func2)(void *priv); }; -static int run_jobs(AVSliceThread *ctx) +static int run_jobs(AVSliceThread *ctx, int *ret_out) { unsigned nb_jobs = ctx->nb_jobs; unsigned nb_active_threads = ctx->nb_active_threads; @@ -62,7 +67,12 @@ static int run_jobs(AVSliceThread *ctx) unsigned current_job = first_job; do { - ctx->worker_func(ctx->priv, current_job, first_job, nb_jobs, nb_active_threads); + if (ctx->worker_func2) { + int ret = ctx->worker_func2(ctx->priv, current_job, first_job, nb_jobs, nb_active_threads); + *ret_out = FFMIN(*ret_out, ret); + } else { + ctx->worker_func(ctx->priv, current_job, first_job, nb_jobs, nb_active_threads); + } } while ((current_job = atomic_fetch_add_explicit(&ctx->current_job, 1, memory_order_acq_rel)) < nb_jobs); return current_job == nb_jobs + nb_active_threads - 1; @@ -86,7 +96,7 @@ static void *attribute_align_arg thread_worker(void *v) return NULL; } - if (run_jobs(ctx)) { + if (run_jobs(ctx, &w->ret)) { pthread_mutex_lock(&ctx->done_mutex); ctx->done = 1; pthread_cond_signal(&ctx->done_cond); @@ -95,9 +105,11 @@ static void *attribute_align_arg thread_worker(void *v) } } -int avpriv_slicethread_create(AVSliceThread **pctx, void *priv, +static int slicethread_create(AVSliceThread **pctx, void *priv, void (*worker_func)(void *priv, int jobnr, int threadnr, int nb_jobs, int nb_threads), void (*main_func)(void *priv), + int (*worker_func2)(void *priv, int jobnr, int threadnr, int nb_jobs, int nb_threads), + int (*main_func2)(void *priv), int nb_threads) { AVSliceThread *ctx; @@ -128,6 +140,8 @@ int avpriv_slicethread_create(AVSliceThread **pctx, void *priv, ctx->priv = priv; ctx->worker_func = worker_func; ctx->main_func = main_func; + ctx->worker_func2= worker_func2; + ctx->main_func2 = main_func2; ctx->nb_threads = nb_threads; ctx->nb_active_threads = 0; ctx->nb_jobs = 0; @@ -165,9 +179,30 @@ int avpriv_slicethread_create(AVSliceThread **pctx, void *priv, return nb_threads; } +int avpriv_slicethread_create(AVSliceThread **pctx, void *priv, + void (*worker_func)(void *priv, int jobnr, int threadnr, int nb_jobs, int nb_threads), + void (*main_func)(void *priv), + int nb_threads) +{ + return slicethread_create(pctx, priv, worker_func, main_func, NULL, NULL, nb_threads); +} + +int avpriv_slicethread_create2(AVSliceThread **pctx, void *priv, + int (*worker_func)(void *priv, int jobnr, int threadnr, int nb_jobs, int nb_threads), + int (*main_func)(void *priv), + int nb_threads) +{ + return slicethread_create(pctx, priv, NULL, NULL, worker_func, main_func, nb_threads); +} + void avpriv_slicethread_execute(AVSliceThread *ctx, int nb_jobs, int execute_main) { - int nb_workers, i, is_last = 0; + (void)avpriv_slicethread_execute2(ctx, nb_jobs, execute_main); +} + +int avpriv_slicethread_execute2(AVSliceThread *ctx, int nb_jobs, int execute_main) +{ + int nb_workers, i, is_last = 0, ret = 0; av_assert0(nb_jobs > 0); ctx->nb_jobs = nb_jobs; @@ -182,14 +217,17 @@ void avpriv_slicethread_execute(AVSliceThread *ctx, int nb_jobs, int execute_mai WorkerContext *w = &ctx->workers[i]; pthread_mutex_lock(&w->mutex); w->done = 0; + w->ret = 0; pthread_cond_signal(&w->cond); pthread_mutex_unlock(&w->mutex); } if (ctx->main_func && execute_main) ctx->main_func(ctx->priv); + else if (ctx->main_func2 && execute_main) + ret = ctx->main_func2(ctx->priv); else - is_last = run_jobs(ctx); + is_last = run_jobs(ctx, &ret); if (!is_last) { pthread_mutex_lock(&ctx->done_mutex); @@ -198,6 +236,11 @@ void avpriv_slicethread_execute(AVSliceThread *ctx, int nb_jobs, int execute_mai ctx->done = 0; pthread_mutex_unlock(&ctx->done_mutex); } + + for (i = 0; i < nb_workers; i++) + ret = FFMIN(ret, ctx->workers[i].ret); + + return ret; } void avpriv_slicethread_free(AVSliceThread **pctx) @@ -246,11 +289,26 @@ int avpriv_slicethread_create(AVSliceThread **pctx, void *priv, return AVERROR(ENOSYS); } +int avpriv_slicethread_create2(AVSliceThread **pctx, void *priv, + int (*worker_func)(void *priv, int jobnr, int threadnr, int nb_jobs, int nb_threads), + int (*main_func)(void *priv), + int nb_threads) +{ + *pctx = NULL; + return AVERROR(ENOSYS); +} + void avpriv_slicethread_execute(AVSliceThread *ctx, int nb_jobs, int execute_main) { av_assert0(0); } +int avpriv_slicethread_execute2(AVSliceThread *ctx, int nb_jobs, int execute_main) +{ + av_assert0(0); + return AVERROR(ENOSYS); +} + void avpriv_slicethread_free(AVSliceThread **pctx) { av_assert0(!pctx || !*pctx); diff --git a/libavutil/slicethread.h b/libavutil/slicethread.h index f6f6f302c4..4deb287674 100644 --- a/libavutil/slicethread.h +++ b/libavutil/slicethread.h @@ -29,20 +29,47 @@ typedef struct AVSliceThread AVSliceThread; * @param main_func special callback function, called from main thread, may be NULL * @param nb_threads number of threads, 0 for automatic, must be >= 0 * @return return number of threads or negative AVERROR on failure + * @deprecated Use avpriv_slicethread_create2() instead. */ +attribute_deprecated int avpriv_slicethread_create(AVSliceThread **pctx, void *priv, void (*worker_func)(void *priv, int jobnr, int threadnr, int nb_jobs, int nb_threads), void (*main_func)(void *priv), int nb_threads); +/** + * Like avpriv_slicethread_create() except worker_func and main_func return int. + * @param pctx slice threading context returned here + * @param priv private pointer to be passed to callback function + * @param worker_func callback function to be executed + * @param main_func special callback function, called from main thread, may be NULL + * @param nb_threads number of threads, 0 for automatic, must be >= 0 + * @return return number of threads or negative AVERROR on failure + */ +int avpriv_slicethread_create2(AVSliceThread **pctx, void *priv, + int (*worker_func)(void *priv, int jobnr, int threadnr, int nb_jobs, int nb_threads), + int (*main_func)(void *priv), + int nb_threads); + /** * Execute slice threading. * @param ctx slice threading context * @param nb_jobs number of jobs, must be > 0 * @param execute_main also execute main_func + * @deprecated Use avpriv_slicethread_execute2() instead. */ +attribute_deprecated void avpriv_slicethread_execute(AVSliceThread *ctx, int nb_jobs, int execute_main); +/** + * Like avpriv_slicethread_execute() except returns FFMIN(0, main_func(), worker_func()). + * @param ctx slice threading context + * @param nb_jobs number of jobs, must be > 0 + * @param execute_main also execute main_func + * @return AVERROR on error. + */ +int avpriv_slicethread_execute2(AVSliceThread *ctx, int nb_jobs, int execute_main); + /** * Destroy slice threading context. * @param pctx pointer to context diff --git a/libavutil/version.h b/libavutil/version.h index 9c44cef6aa..5aca550f45 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 57 -#define LIBAVUTIL_VERSION_MINOR 37 +#define LIBAVUTIL_VERSION_MINOR 38 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 367d045a02..500b74c099 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -1150,23 +1150,11 @@ int sws_receive_slice(struct SwsContext *c, unsigned int slice_start, if (c->slicethread) { int nb_jobs = c->slice_ctx[0]->dither == SWS_DITHER_ED ? 1 : c->nb_slice_ctx; - int ret = 0; c->dst_slice_start = slice_start; c->dst_slice_height = slice_height; - avpriv_slicethread_execute(c->slicethread, nb_jobs, 0); - - for (int i = 0; i < c->nb_slice_ctx; i++) { - if (c->slice_err[i] < 0) { - ret = c->slice_err[i]; - break; - } - } - - memset(c->slice_err, 0, c->nb_slice_ctx * sizeof(*c->slice_err)); - - return ret; + return avpriv_slicethread_execute2(c->slicethread, nb_jobs, 0); } for (int i = 0; i < FF_ARRAY_ELEMS(dst); i++) { @@ -1213,8 +1201,8 @@ int attribute_align_arg sws_scale(struct SwsContext *c, dst, dstStride, 0, c->dstH); } -void ff_sws_slice_worker(void *priv, int jobnr, int threadnr, - int nb_jobs, int nb_threads) +int ff_sws_slice_worker(void *priv, int jobnr, int threadnr, + int nb_jobs, int nb_threads) { SwsContext *parent = priv; SwsContext *c = parent->slice_ctx[threadnr]; @@ -1242,5 +1230,5 @@ void ff_sws_slice_worker(void *priv, int jobnr, int threadnr, parent->dst_slice_start + slice_start, slice_end - slice_start); } - parent->slice_err[threadnr] = err; + return err; } diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index abeebbb002..50e73c86fa 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -306,7 +306,7 @@ typedef struct SwsContext { AVSliceThread *slicethread; struct SwsContext **slice_ctx; - int *slice_err; + attribute_deprecated int *slice_err; ///< @deprecated Not used any more. Removing it would require a bunch of asm to be rewritten. int nb_slice_ctx; // values passed to current sws_receive_slice() call @@ -1152,8 +1152,8 @@ void ff_init_vscale_pfn(SwsContext *c, yuv2planar1_fn yuv2plane1, yuv2planarX_fn yuv2interleavedX_fn yuv2nv12cX, yuv2packed1_fn yuv2packed1, yuv2packed2_fn yuv2packed2, yuv2packedX_fn yuv2packedX, yuv2anyX_fn yuv2anyX, int use_mmx); -void ff_sws_slice_worker(void *priv, int jobnr, int threadnr, - int nb_jobs, int nb_threads); +int ff_sws_slice_worker(void *priv, int jobnr, int threadnr, + int nb_jobs, int nb_threads); //number of extra lines to process #define MAX_LINES_AHEAD 4 diff --git a/libswscale/utils.c b/libswscale/utils.c index 45baa22b23..8bfd3a64ac 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -1273,8 +1273,8 @@ static int context_init_threaded(SwsContext *c, { int ret; - ret = avpriv_slicethread_create(&c->slicethread, (void*)c, - ff_sws_slice_worker, NULL, c->nb_threads); + ret = avpriv_slicethread_create2(&c->slicethread, (void*)c, + ff_sws_slice_worker, NULL, c->nb_threads); if (ret == AVERROR(ENOSYS)) { c->nb_threads = 1; return 0; @@ -1284,8 +1284,7 @@ static int context_init_threaded(SwsContext *c, c->nb_threads = ret; c->slice_ctx = av_calloc(c->nb_threads, sizeof(*c->slice_ctx)); - c->slice_err = av_calloc(c->nb_threads, sizeof(*c->slice_err)); - if (!c->slice_ctx || !c->slice_err) + if (!c->slice_ctx) return AVERROR(ENOMEM); for (int i = 0; i < c->nb_threads; i++) { @@ -2421,7 +2420,6 @@ void sws_freeContext(SwsContext *c) for (i = 0; i < c->nb_slice_ctx; i++) sws_freeContext(c->slice_ctx[i]); av_freep(&c->slice_ctx); - av_freep(&c->slice_err); avpriv_slicethread_free(&c->slicethread); diff --git a/tests/fate/screen.mak b/tests/fate/screen.mak index bd6d228544..b572f67b55 100644 --- a/tests/fate/screen.mak +++ b/tests/fate/screen.mak @@ -5,6 +5,7 @@ fate-cscd: CMD = framecrc -i $(TARGET_SAMPLES)/CSCD/sample_video.avi -an -pix_fm FATE_SCREEN-$(call FRAMECRC, AVI, DXTORY) += fate-dxtory fate-dxtory: CMD = framecrc -i $(TARGET_SAMPLES)/dxtory/dxtory_mic.avi -an +# fic sample is broken. some packets are truncated and one packet has length zero FATE_SCREEN-$(call FRAMECRC, AVI, FIC) += fate-fic-avi fate-fic-avi: CMD = framecrc -i $(TARGET_SAMPLES)/fic/fic-partial-2MB.avi -an diff --git a/tests/ref/fate/fic-avi b/tests/ref/fate/fic-avi index df55789d54..4546f230b1 100644 --- a/tests/ref/fate/fic-avi +++ b/tests/ref/fate/fic-avi @@ -76,19 +76,18 @@ 0, 70, 70, 1, 1566720, 0x40f7d39a 0, 71, 71, 1, 1566720, 0x40f7d39a 0, 72, 72, 1, 1566720, 0x40f7d39a -0, 73, 73, 1, 1566720, 0xa7d6e25f -0, 74, 74, 1, 1566720, 0xa7d6e25f -0, 75, 75, 1, 1566720, 0xa7d6e25f -0, 76, 76, 1, 1566720, 0xa7d6e25f -0, 77, 77, 1, 1566720, 0xa7d6e25f -0, 78, 78, 1, 1566720, 0xa7d6e25f -0, 79, 79, 1, 1566720, 0xa7d6e25f -0, 80, 80, 1, 1566720, 0xa7d6e25f -0, 81, 81, 1, 1566720, 0xa7d6e25f -0, 82, 82, 1, 1566720, 0xa7d6e25f -0, 83, 83, 1, 1566720, 0xa7d6e25f -0, 84, 84, 1, 1566720, 0xa7d6e25f -0, 85, 85, 1, 1566720, 0xa7d6e25f +0, 74, 74, 1, 1566720, 0x40f7d39a +0, 75, 75, 1, 1566720, 0x40f7d39a +0, 76, 76, 1, 1566720, 0x40f7d39a +0, 77, 77, 1, 1566720, 0x40f7d39a +0, 78, 78, 1, 1566720, 0x40f7d39a +0, 79, 79, 1, 1566720, 0x40f7d39a +0, 80, 80, 1, 1566720, 0x40f7d39a +0, 81, 81, 1, 1566720, 0x40f7d39a +0, 82, 82, 1, 1566720, 0x40f7d39a +0, 83, 83, 1, 1566720, 0x40f7d39a +0, 84, 84, 1, 1566720, 0x40f7d39a +0, 85, 85, 1, 1566720, 0x40f7d39a 0, 86, 86, 1, 1566720, 0xa7d6e25f 0, 87, 87, 1, 1566720, 0xa7d6e25f 0, 88, 88, 1, 1566720, 0xa7d6e25f @@ -104,7 +103,6 @@ 0, 98, 98, 1, 1566720, 0xa7d6e25f 0, 99, 99, 1, 1566720, 0xa7d6e25f 0, 100, 100, 1, 1566720, 0xeaf8d207 -0, 101, 101, 1, 1566720, 0x6724983e 0, 102, 102, 1, 1566720, 0x0e95d209 0, 103, 103, 1, 1566720, 0x0e95d209 0, 104, 104, 1, 1566720, 0x0e95d209 @@ -121,6 +119,4 @@ 0, 115, 115, 1, 1566720, 0xfe83b964 0, 116, 116, 1, 1566720, 0xfe83b964 0, 117, 117, 1, 1566720, 0xfe83b964 -0, 118, 118, 1, 1566720, 0x25dc30a6 -0, 119, 119, 1, 1566720, 0x25dc30a6 -0, 120, 120, 1, 1566720, 0x25dc30a6 +0, 119, 119, 1, 1566720, 0xfe83b964 -- 2.30.2