From patchwork Thu Jun 16 19:55:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 36290 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1a22:b0:84:42e0:ad30 with SMTP id cj34csp1130308pzb; Thu, 16 Jun 2022 13:09:54 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vS3NsohK2V7BsTte1csppcAYMu2OTZPn9FHysAIoXVQcMNMEJG8/SeNZPd+Iyq00mEisSN X-Received: by 2002:a17:906:58cf:b0:711:7acb:821f with SMTP id e15-20020a17090658cf00b007117acb821fmr5970236ejs.588.1655410194274; Thu, 16 Jun 2022 13:09:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655410194; cv=none; d=google.com; s=arc-20160816; b=DuugxD77NITXsRPWLo9MU31WnLFuYIZDEcTqFQdvmOMDJ1T/BVvysP95IxKSfqOWon 1E+JJuN4rQzejJyLLjBiXRbqZePNkZhiux8OOH/CGfIlRZpRxmRqrjfP+wbORya3FyxC X7lSiuPucWhDY3h/KiRI6EJqUAFa0rrbRH4j2rC/e/6J9qKSCwg6t7qWT7mSXIFq4ePM JQAyDTTsH4HfFt3ONWm1moIp6QVOJhPk84z72MmWT0jU7/WylphiH/WjGY5sHSrnaf75 smEOt9vKVu8p1661sKNpy+mJebYGctBBGS+Zb3r9bgNvKaiFpv5hPatrAtN0fWBV+E5n CdAg== 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=9bNbL0ClOLHPYiyg4D7i0wwreP8hcyRBwND0deSW368=; b=pP6rMgV2V7h4hUtCtMWGG5ahERh/vCVS15v2YVK3sE5bjwM53oVXfepRa77CkbeADD AcIC0H7a9RLwsqUxRmsmXHgk7DVXQVSfkLa6QVK1WRWE01p1Zt5tTyG+2u9XC85K51bU y0uo9mOf1oi/5f36TLsaCdVhZhU/17fR7KG2AEaj8DeCvvxKSB2J0qm36IVTK1SH8aQ/ Z4YR4mh6YLZs9FSijxvRbAheab7QD75Ql+516PEDSXP5yq/BlH1x7+3HYi7Ekutm3mL0 mRAToFSuTuy1i45wlayjOnTXHKyDtIpTZVltUp7ujzhTkOODznQ6EAYO9VqiGN5/nrjy a/gA== 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 h14-20020aa7cdce000000b0042e17781f86si3052998edw.268.2022.06.16.13.09.53; Thu, 16 Jun 2022 13:09:54 -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 5D3BB68B8DA; Thu, 16 Jun 2022 23:09:43 +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 7F30968B834 for ; Thu, 16 Jun 2022 23:09:36 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 20F72240175 for ; Thu, 16 Jun 2022 22:09:36 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id KC3h4zrmI5kr for ; Thu, 16 Jun 2022 22:09:35 +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 7B2B32400F5 for ; Thu, 16 Jun 2022 22:09:35 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 1961E3A2216; Thu, 16 Jun 2022 22:03:31 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 16 Jun 2022 21:55:32 +0200 Message-Id: <20220616195534.5278-33-anton@khirnov.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220616195534.5278-1-anton@khirnov.net> References: <20220616195534.5278-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 33/35] fftools/ffmpeg: depend on 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: RQ1CIcteSe/o ffmpeg will be switched to a fully threaded architecture, starting with muxers. --- configure | 2 +- fftools/ffmpeg.c | 20 -------------------- fftools/ffmpeg.h | 2 -- fftools/ffmpeg_opt.c | 2 -- 4 files changed, 1 insertion(+), 25 deletions(-) diff --git a/configure b/configure index 3dca1c4bd3..1c80c54baf 100755 --- a/configure +++ b/configure @@ -3808,7 +3808,7 @@ avfilter_extralibs="pthreads_extralibs" avutil_extralibs="d3d11va_extralibs nanosleep_extralibs pthreads_extralibs vaapi_drm_extralibs vaapi_x11_extralibs vdpau_x11_extralibs" # programs -ffmpeg_deps="avcodec avfilter avformat" +ffmpeg_deps="avcodec avfilter avformat threads" ffmpeg_select="aformat_filter anull_filter atrim_filter format_filter hflip_filter null_filter transpose_filter trim_filter vflip_filter" diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index f57028b9b7..aea7335c8f 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -161,9 +161,7 @@ static struct termios oldtty; static int restore_tty; #endif -#if HAVE_THREADS static void free_input_threads(void); -#endif /* sub2video hack: Convert subtitles to video with alpha to insert them in filter graphs. @@ -593,9 +591,7 @@ static void ffmpeg_cleanup(int ret) av_freep(&output_streams[i]); } -#if HAVE_THREADS free_input_threads(); -#endif for (i = 0; i < nb_input_files; i++) { avformat_close_input(&input_files[i]->ctx); av_packet_free(&input_files[i]->pkt); @@ -3660,7 +3656,6 @@ static int check_keyboard_interaction(int64_t cur_time) return 0; } -#if HAVE_THREADS static void *input_thread(void *arg) { InputFile *f = arg; @@ -3778,7 +3773,6 @@ static int get_input_packet_mt(InputFile *f, AVPacket **pkt) f->non_blocking ? AV_THREAD_MESSAGE_NONBLOCK : 0); } -#endif static int get_input_packet(InputFile *f, AVPacket **pkt) { @@ -3801,10 +3795,8 @@ static int get_input_packet(InputFile *f, AVPacket **pkt) } } -#if HAVE_THREADS if (f->thread_queue_size) return get_input_packet_mt(f, pkt); -#endif *pkt = f->pkt; return av_read_frame(f->ctx, *pkt); } @@ -3944,15 +3936,11 @@ static int process_input(int file_index) avcodec_flush_buffers(avctx); } } -#if HAVE_THREADS free_input_thread(file_index); -#endif ret = seek_to_start(ifile, is); -#if HAVE_THREADS thread_ret = init_input_thread(file_index); if (thread_ret < 0) return thread_ret; -#endif if (ret < 0) av_log(NULL, AV_LOG_WARNING, "Seek to start failed.\n"); else @@ -4194,11 +4182,9 @@ static int process_input(int file_index) process_input_packet(ist, pkt, 0); discard_packet: -#if HAVE_THREADS if (ifile->thread_queue_size) av_packet_free(&pkt); else -#endif av_packet_unref(pkt); return 0; @@ -4365,10 +4351,8 @@ static int transcode(void) timer_start = av_gettime_relative(); -#if HAVE_THREADS if ((ret = init_input_threads()) < 0) goto fail; -#endif while (!received_sigterm) { int64_t cur_time= av_gettime_relative(); @@ -4393,9 +4377,7 @@ static int transcode(void) /* dump report by using the output first video and audio streams */ print_report(0, timer_start, cur_time); } -#if HAVE_THREADS free_input_threads(); -#endif /* at the end of stream, we must flush the decoder buffers */ for (i = 0; i < nb_input_streams; i++) { @@ -4449,9 +4431,7 @@ static int transcode(void) ret = 0; fail: -#if HAVE_THREADS free_input_threads(); -#endif if (output_streams) { for (i = 0; i < nb_output_streams; i++) { diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 91f5b4024b..9baa701c67 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -426,13 +426,11 @@ typedef struct InputFile { AVPacket *pkt; -#if HAVE_THREADS AVThreadMessageQueue *in_thread_queue; pthread_t thread; /* thread reading from this file */ int non_blocking; /* reading packets from the thread should not block */ int joined; /* the thread has been joined */ int thread_queue_size; /* maximum number of queued packets */ -#endif } InputFile; enum forced_keyframes_const { diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 5ef4115cdb..7f46238534 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1328,9 +1328,7 @@ static int open_input_file(OptionsContext *o, const char *filename) f->pkt = av_packet_alloc(); if (!f->pkt) exit_program(1); -#if HAVE_THREADS f->thread_queue_size = o->thread_queue_size; -#endif /* check if all codec options have been used */ unused_opts = strip_specifiers(o->g->codec_opts);