From patchwork Tue Oct 18 12:36:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 38781 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4a86:b0:9d:28a3:170e with SMTP id fn6csp2082803pzb; Tue, 18 Oct 2022 05:38:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6MHcSdPcJorf11sIZlt7NHQ4Wsb3i17vlUQtLOXW6d+CRHYPoMU+wi3X1Xpgl5tUrw7eXH X-Received: by 2002:a17:907:75f1:b0:78a:f935:647d with SMTP id jz17-20020a17090775f100b0078af935647dmr2225129ejc.587.1666096732845; Tue, 18 Oct 2022 05:38:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666096732; cv=none; d=google.com; s=arc-20160816; b=Iq9H6Yl2WQ3KovC0lejXKBxQaKTLcpC9mZ115UL009U/2AH8DRNL1Bsoio/SI/iWdl cwd91ShEtTTIzpcL/S+VZlhE3hum3B7nYIUvDa0exe2wUqRCUN3sbqs7HBasU5/chmMp VphY1xr76Kthf2KRHQWVmluhIDpaOHL60m7doWCxwOsJh6sSOc7/QstfwI4K+czCB45S ILhen4oU198fIKmQEbAgHawttC0OBWvVYqJDFcXQFUErM+MBldcPTE/h6y72DyDTOK83 euP0OH6pxuw5Ts/Ohp/znfdVwJlAXLuEM7KoH3w6ZrWMpDv0ecpbi6VATpuYOZnxKvf+ AIRA== 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=6lBHztwWASQuMkAa3jR9uD0LePo62RtWU5SOZRgjBUc=; b=eAf7/2P/L+bztF/pvvQsOrKvebihibNX02DqDg6XlgERKNyVLD8mFbKI5qMwyNlMTr D0ARDmZAo0Xenm0SPrKgbKtmjxc20vkkv4Ory3i1KWhzEDyuRvt8KYN+WDSHT4cvnjvg rKGAY8V5ypZh/fAf7mj67coIraCeGMFvy5HfyaDE2AZQ83nuLYrcVKw7gYhdjDqJRi1i sK9C6abyqokEpazWG7Xg1Nkk2GEt08TSmakYuXzrXBINYnDAghb6BROJvzvAu/ZEr0k/ rgvN6BQi2MEr13ObhwEQ7+XRK8XZwsfb6THmtagacLc9FAYEVE0sdcmG3rY37mzcId3j /K5Q== 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 c6-20020a05640227c600b0045d4492a8a5si2944619ede.337.2022.10.18.05.38.52; Tue, 18 Oct 2022 05:38:52 -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 96FB368BD69; Tue, 18 Oct 2022 15:38:25 +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 9627368BCF7 for ; Tue, 18 Oct 2022 15:38:20 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id DD87B2406C7 for ; Tue, 18 Oct 2022 14:38:17 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id cZ9psUygAl3y for ; Tue, 18 Oct 2022 14:38:16 +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 A64A32405EC for ; Tue, 18 Oct 2022 14:38:13 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id A877F3A168C for ; Tue, 18 Oct 2022 14:38:13 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 18 Oct 2022 14:36:46 +0200 Message-Id: <20221018123701.25002-5-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221018123701.25002-1-anton@khirnov.net> References: <20221018123701.25002-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/20] fftools/ffmpeg: drop free_input_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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: qCHutNPlVqhu Stop demuxer threads in ifile_close() instead. Simplifies the demuxer API. --- fftools/ffmpeg.c | 4 ---- fftools/ffmpeg.h | 1 - fftools/ffmpeg_demux.c | 17 ++++++----------- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index d29d2e4e88..3ad3fff5cd 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -555,7 +555,6 @@ static void ffmpeg_cleanup(int ret) for (i = 0; i < nb_output_files; i++) of_close(&output_files[i]); - free_input_threads(); for (i = 0; i < nb_input_files; i++) ifile_close(&input_files[i]); @@ -3932,7 +3931,6 @@ static int transcode(void) /* dump report by using the output first video and audio streams */ print_report(0, timer_start, cur_time); } - free_input_threads(); /* at the end of stream, we must flush the decoder buffers */ for (i = 0; i < nb_input_streams; i++) { @@ -3985,8 +3983,6 @@ static int transcode(void) ret = 0; fail: - free_input_threads(); - return ret; } diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 547660d5ef..823347f670 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -760,7 +760,6 @@ void ifile_close(InputFile **f); * - a negative error code on failure */ int ifile_get_packet(InputFile *f, AVPacket **pkt); -void free_input_threads(void); #define SPECIFIER_OPT_FMT_str "%s" #define SPECIFIER_OPT_FMT_i "%i" diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index d2db0663ab..5c75dd5b23 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -306,12 +306,12 @@ finish: return NULL; } -static void free_input_thread(int i) +static void thread_stop(Demuxer *d) { - InputFile *f = input_files[i]; + InputFile *f = &d->f; DemuxMsg msg; - if (!f || !f->in_thread_queue) + if (!f->in_thread_queue) return; av_thread_message_queue_set_err_send(f->in_thread_queue, AVERROR_EOF); while (av_thread_message_queue_recv(f->in_thread_queue, &msg, 0) >= 0) @@ -322,14 +322,6 @@ static void free_input_thread(int i) av_thread_message_queue_free(&f->audio_duration_queue); } -void free_input_threads(void) -{ - int i; - - for (i = 0; i < nb_input_files; i++) - free_input_thread(i); -} - static int thread_start(Demuxer *d) { int ret; @@ -426,10 +418,13 @@ int ifile_get_packet(InputFile *f, AVPacket **pkt) void ifile_close(InputFile **pf) { InputFile *f = *pf; + Demuxer *d = demuxer_from_ifile(f); if (!f) return; + thread_stop(d); + avformat_close_input(&f->ctx); av_freep(pf);