From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id C1FBB4471C for ; Wed, 21 Sep 2022 18:25:16 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8C16968BAEF; Wed, 21 Sep 2022 21:25:13 +0300 (EEST) Received: from mail-oo1-f51.google.com (mail-oo1-f51.google.com [209.85.161.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AD78768B3FD for ; Wed, 21 Sep 2022 21:25:07 +0300 (EEST) Received: by mail-oo1-f51.google.com with SMTP id t4-20020a4aa3c4000000b00475624f2369so1026588ool.3 for ; Wed, 21 Sep 2022 11:25:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date; bh=wF4NhJkJxVNs7iqDwCNkgbAFkUpxIvgFgPVUCSw5UjU=; b=HsS7qyt86CUo31k23o8UUmE6Qulz9h9Uo16fz1iEhPXPv+urohWmkCIv5Hkcflly9u NpJa/Iqj31qpWf0MoVLi+yznInnHWD8yRyKO3HZabG9JANBJcXA/nIrCJXZcWW2fh7rk 10HJNjTCBDA9ZRQ2L88fdPVVfhWYIqwuA2mdiC/ujH4iLq0wmv5wQaKUYPJvqnSxvLHQ xIP2G47QW6xTpDuPP4BkYuNSpiPA9J0bxr52OuHAVabNHvXOdUSgZcLIo0RkY+m5nuU7 KHGWEsqcsT5qQ5JNMHllbsVdeOdgx9etqDI8Q7XY56dnP2fQCY5An7xRdPuCcECj5Yxy ANeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date; bh=wF4NhJkJxVNs7iqDwCNkgbAFkUpxIvgFgPVUCSw5UjU=; b=rNo0jzo4w9VQfI9NhgfLMWklZmSYW0N+FOZFxhCEepzhI6wOt+mgRVY68hiu3/b0Wl mH/kaIppYeTXOEadNWfa9N/Sc9momOG++2C6GWcIZphiQKuLTFDNVJghh/nhKzKip40p Pt4ybgTUF3N5MrDTshn14nU1VrSuMWdM1pbZW7LisICLTcaIGOCXzE5WNd3siyXTRDhC qAw0qRzgG29Qmwa8a6o496H8HQLUHtTbBRi6/d+Wl6ONfFMUxTmRUS1/4wSsuLEB5VR/ +1THQz0/ul/glIv8c5dP/eiDR95dZrGOHvhbPd+go/+nponktwDzGey0AingJIkehI6A G8Iw== X-Gm-Message-State: ACrzQf2f3LvXiOUr5x9lORXffwq1H7gGvQsGqW47U/5t6GPKvVoSdWEb wG078FdN3z449Zf0e8Q+a+oMYrTrM4c= X-Google-Smtp-Source: AMsMyM5FHpcqJuXw6Onc/SU9JUq0l15x/qA8fWGhHrjLyqyTFRf3Wm8SsiB1NJmJwDExiSCSIctxuA== X-Received: by 2002:a4a:9c92:0:b0:473:f49d:d855 with SMTP id z18-20020a4a9c92000000b00473f49dd855mr11085732ooj.93.1663784704872; Wed, 21 Sep 2022 11:25:04 -0700 (PDT) Received: from [192.168.0.13] ([191.97.187.183]) by smtp.gmail.com with ESMTPSA id e2-20020a056808148200b0034fddfc5922sm1563915oiw.36.2022.09.21.11.25.03 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 21 Sep 2022 11:25:04 -0700 (PDT) Message-ID: <18093382-08c9-d44f-0d0d-683e82bd27fb@gmail.com> Date: Wed, 21 Sep 2022 15:25:02 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20220920175021.60790-1-rcombs@rcombs.me> <20220920175021.60790-3-rcombs@rcombs.me> From: James Almer In-Reply-To: <20220920175021.60790-3-rcombs@rcombs.me> Subject: Re: [FFmpeg-devel] [PATCH 2/7] sws: add jobs option, distinct from threads 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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 9/20/2022 2:50 PM, rcombs wrote: > This allows for more efficient use of asymmetric-multiprocessing systems. > --- > libswscale/options.c | 2 ++ > libswscale/swscale_internal.h | 1 + > libswscale/utils.c | 9 ++++++--- > libswscale/version.h | 2 +- > 4 files changed, 10 insertions(+), 4 deletions(-) > > diff --git a/libswscale/options.c b/libswscale/options.c > index 4d41b835b1..5765daa100 100644 > --- a/libswscale/options.c > +++ b/libswscale/options.c > @@ -81,6 +81,8 @@ static const AVOption swscale_options[] = { > > { "threads", "number of threads", OFFSET(nb_threads), AV_OPT_TYPE_INT, {.i64 = 1 }, 0, INT_MAX, VE, "threads" }, > { "auto", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, .flags = VE, "threads" }, > + { "jobs", "number of jobs", OFFSET(nb_jobs), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, VE, "jobs" }, Default should probably be 1. > + { "auto", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, .flags = VE, "jobs" }, > > { NULL } > }; > diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h > index abeebbb002..602082e12c 100644 > --- a/libswscale/swscale_internal.h > +++ b/libswscale/swscale_internal.h > @@ -339,6 +339,7 @@ typedef struct SwsContext { > int vChrDrop; ///< Binary logarithm of extra vertical subsampling factor in source image chroma planes specified by user. > int sliceDir; ///< Direction that slices are fed to the scaler (1 = top-to-bottom, -1 = bottom-to-top). > int nb_threads; ///< Number of threads used for scaling > + int nb_jobs; ///< Number of slice jobs used for scaling > double param[2]; ///< Input parameters for scaling algorithms that need them. > > AVFrame *frame_src; > diff --git a/libswscale/utils.c b/libswscale/utils.c > index 45baa22b23..c9ff9db957 100644 > --- a/libswscale/utils.c > +++ b/libswscale/utils.c > @@ -1277,18 +1277,21 @@ static int context_init_threaded(SwsContext *c, > ff_sws_slice_worker, NULL, c->nb_threads); > if (ret == AVERROR(ENOSYS)) { > c->nb_threads = 1; > + c->nb_jobs = 1; > return 0; > } else if (ret < 0) > return ret; > > c->nb_threads = ret; > + if (c->nb_jobs < 1) Can c->nb_jobs even be -1? The AVOption range above is 0..INT_MAX > + c->nb_jobs = av_cpu_job_count(); > > - c->slice_ctx = av_calloc(c->nb_threads, sizeof(*c->slice_ctx)); > - c->slice_err = av_calloc(c->nb_threads, sizeof(*c->slice_err)); > + c->slice_ctx = av_calloc(c->nb_jobs, sizeof(*c->slice_ctx)); > + c->slice_err = av_calloc(c->nb_jobs, sizeof(*c->slice_err)); > if (!c->slice_ctx || !c->slice_err) > return AVERROR(ENOMEM); > > - for (int i = 0; i < c->nb_threads; i++) { > + for (int i = 0; i < c->nb_jobs; i++) { > c->slice_ctx[i] = sws_alloc_context(); > if (!c->slice_ctx[i]) > return AVERROR(ENOMEM); > diff --git a/libswscale/version.h b/libswscale/version.h > index 9bb3b171a7..4529a2d7d4 100644 > --- a/libswscale/version.h > +++ b/libswscale/version.h > @@ -29,7 +29,7 @@ > #include "version_major.h" > > #define LIBSWSCALE_VERSION_MINOR 8 > -#define LIBSWSCALE_VERSION_MICRO 112 > +#define LIBSWSCALE_VERSION_MICRO 113 > > #define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \ > LIBSWSCALE_VERSION_MINOR, \ _______________________________________________ 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".