From patchwork Wed Aug 3 13:58:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 37108 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp458494pzb; Wed, 3 Aug 2022 07:00:52 -0700 (PDT) X-Google-Smtp-Source: AA6agR6iV/s2IClwQMkdOzVK1/t7OQfZSDG0wHPnX0JHVarQ8HGMs+0Whxfgnj/HAdudLtHYA1gw X-Received: by 2002:a05:6402:5211:b0:43e:1ac4:4b39 with SMTP id s17-20020a056402521100b0043e1ac44b39mr5628071edd.345.1659535251888; Wed, 03 Aug 2022 07:00:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659535251; cv=none; d=google.com; s=arc-20160816; b=EqT1foZfvcmkl3NxT9mdGueMmfGW5cHLi2SQX8E25TghGFJWnJI9Bbmh1uR4pbVbV2 IrQ0KvnzOdzBrF4nn5OBJ/a0MVUBm8pZpxSta8jcOWSX7NPpmkfa6Oym8vykyKqL4/tr zlpncT+e8wj9SeXg6cBGiLfb5GoJHg34QFV3a4fI9HfBAGYRkcsBmT+VCpACw/61+SnD V7BVHvyC6upYVVKPPFrJRMQXfTQ5qAPP71R8fEgmB3uwdZfjgWEiPpQxUFsBnp4pOHWS leiKW5/ndPnY5tCNgkVzA5HoaxiWKVmLqB/SKHKK+ouwp2mzwDvOcut1siFwiQElxovS vmFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=dizNKIPw7zvLxxLTOsVR1rB3leDirQYMwQngwAsSme4=; b=REtBu7qT5nWh2zNOa/FQBwAm/l8Jyh/FU+3g5r54zIpj31wGV6G66ohxDaDDV7lVe2 APW4vDVsMNsZT+hzZg3rwUWp7yld9cVDom6VdH6fRnmpop+b3dPGpMqIugR2mUGQnVSU gYBUd2dV6oCkr3bVD6KFAVrNMUiIN3ubPW5iO/346tA3GzA2ErkfbDgSyhOytPBhisL3 8nTvaiIKaNUd5rB50RPw0dsgyuIUUbB+2SmxVCgq0iBceowEG7bPqDPL7d6uQd7f/Fig PCXpNXWyCoK72+rdc4nfXgjeMfU0k1bN2/D4+S/QE8Pnr2K4db+0wscRYsRc4qilTFd2 3OcA== 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 gb4-20020a170907960400b006f3916bcfc8si4527982ejc.142.2022.08.03.07.00.51; Wed, 03 Aug 2022 07:00:51 -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 8DEF768B93E; Wed, 3 Aug 2022 16:59:13 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9B6AF68B878 for ; Wed, 3 Aug 2022 16:59:06 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id B67E924056A for ; Wed, 3 Aug 2022 15:59:04 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id ZPYZopWkJ7du for ; Wed, 3 Aug 2022 15:59:04 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 1B974240685 for ; Wed, 3 Aug 2022 15:58:55 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 23C133A04C6; Wed, 3 Aug 2022 15:58:52 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 3 Aug 2022 15:58:33 +0200 Message-Id: <20220803135844.16662-14-anton@khirnov.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220803135844.16662-1-anton@khirnov.net> References: <20220803135844.16662-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 14/25] fftools/ffmpeg: always read input in a thread 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: VzyJmmDJGFqu This will be required by the following architecture changes. --- fftools/ffmpeg.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index f12364fe0a..7ba1f2a8cf 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -3713,10 +3713,8 @@ static int init_input_thread(int i) int ret; InputFile *f = input_files[i]; - if (f->thread_queue_size < 0) - f->thread_queue_size = (nb_input_files > 1 ? 8 : 0); - if (!f->thread_queue_size) - return 0; + if (f->thread_queue_size <= 0) + f->thread_queue_size = (nb_input_files > 1 ? 8 : 1); if (f->ctx->pb ? !f->ctx->pb->seekable : strcmp(f->ctx->iformat->name, "lavfi")) @@ -3747,13 +3745,6 @@ static int init_input_threads(void) return 0; } -static int get_input_packet_mt(InputFile *f, AVPacket **pkt) -{ - return av_thread_message_queue_recv(f->in_thread_queue, pkt, - f->non_blocking ? - AV_THREAD_MESSAGE_NONBLOCK : 0); -} - static int get_input_packet(InputFile *f, AVPacket **pkt) { if (f->readrate || f->rate_emu) { @@ -3775,10 +3766,9 @@ static int get_input_packet(InputFile *f, AVPacket **pkt) } } - if (f->thread_queue_size) - return get_input_packet_mt(f, pkt); - *pkt = f->pkt; - return av_read_frame(f->ctx, *pkt); + return av_thread_message_queue_recv(f->in_thread_queue, pkt, + f->non_blocking ? + AV_THREAD_MESSAGE_NONBLOCK : 0); } static int got_eagain(void) @@ -4162,10 +4152,7 @@ static int process_input(int file_index) process_input_packet(ist, pkt, 0); discard_packet: - if (ifile->thread_queue_size) - av_packet_free(&pkt); - else - av_packet_unref(pkt); + av_packet_free(&pkt); return 0; }