From patchwork Mon Apr 4 11:30:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 35196 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c05:b0:7a:e998:b410 with SMTP id bw5csp1915740pzb; Mon, 4 Apr 2022 04:40:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbV4f3mWSBHbhcWgugHmCapey/Hrlu9ygRiy0kE1JWTTcaKdpf5XWmSqMZ5wrwQXd86H5C X-Received: by 2002:a17:906:3adb:b0:6b7:876c:d11b with SMTP id z27-20020a1709063adb00b006b7876cd11bmr10371481ejd.250.1649072436675; Mon, 04 Apr 2022 04:40:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649072436; cv=none; d=google.com; s=arc-20160816; b=BOMkrdEe3UJSmERqiAOv6r7yy3axURjon4VRFkS2SVqu04UlhM93mffctoK+S+/VIr D6z1HMFetSFaAIl7UD7jDh91io1idhuC1o9Zpc07axJnkTFnq4nuzGUI4qVuLPUoU8zv +aXbCutq+cOXLUl0lbjusCXrSDJrFEYSgHELCdSU2AJv3ZPqlpqqozZetP30eFzOwXux IrX28tZBqNCmn6gQp9K9P50q0FyKZeKW8RH+6LV4xJhk8a1QVMHN2UKkZPoRH8J6deIi ZunaH/Epbf/ZkGJ+OXd2AE5LDzCGw2AxXm3Uasg8FysJXTEMC0N/q7nYV7noyFrOj5iR W6MA== 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=vd1VDqoI/89M+0RV4q8KkIj924wJksZx3oNNkPbZt50=; b=O2D3UDyts50gnsIMOaCbme9HviPSU8EWPmKX35B7SC7Pp2ILJsi4EhP3gs3Bz34s6R ZqYZKT3y3SosEQ+NusfovottHgu5gxwFEHcClEFXWj1wsO98aA1O7AeiXal7VL0CJMrM Va8vClRZfZckOVKBut4wezRiKdco9Ns+Ieh2uGadE/N1N2RQ9ybf51pIaAcYcjhe6XPR nsiPVyE6WigJpTjWo1HiYEUlqyEI9jXWAsmhNixaj0FD4XXp2Vi4JjTBnpZG9a/P7vDD r+qnh4kJRlcM4AZh1kgwtwVWo/YO7Vt92qfl9bbEqnlbqT0FCAZwbQDjV/kCK4FxhD7F Qfxg== 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 dv24-20020a170906b81800b006e6f9db2c58si3490038ejb.544.2022.04.04.04.40.35; Mon, 04 Apr 2022 04:40:36 -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 09DC968B389; Mon, 4 Apr 2022 14:37:59 +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 44A7668B350 for ; Mon, 4 Apr 2022 14:37:51 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id AB821240555 for ; Mon, 4 Apr 2022 13:37:48 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id ROjdUVlEwywM for ; Mon, 4 Apr 2022 13:37:48 +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 179592400F5 for ; Mon, 4 Apr 2022 13:37:42 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 4F5973A0E83; Mon, 4 Apr 2022 13:32:12 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Apr 2022 13:30:35 +0200 Message-Id: <20220404113037.13070-48-anton@khirnov.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220404113037.13070-1-anton@khirnov.net> References: <20220404113037.13070-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 47/49] 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: sFdpaKUHCNpE 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 e4d36aa639..4888b136a4 100755 --- a/configure +++ b/configure @@ -3796,7 +3796,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 2dff41e57f..9dfbc4216a 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -162,9 +162,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. @@ -592,9 +590,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); @@ -3601,7 +3597,6 @@ static int check_keyboard_interaction(int64_t cur_time) return 0; } -#if HAVE_THREADS static void *input_thread(void *arg) { InputFile *f = arg; @@ -3719,7 +3714,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) { @@ -3742,10 +3736,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); } @@ -3885,15 +3877,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 @@ -4133,11 +4121,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; @@ -4324,10 +4310,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(); @@ -4352,9 +4336,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++) { @@ -4412,9 +4394,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 14b98909d0..407342462f 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -423,13 +423,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 a86255e409..9bf22f6932 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1305,9 +1305,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);