From patchwork Fri May 5 09:07:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41490 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dca6:b0:f3:34fa:f187 with SMTP id ky38csp330168pzb; Fri, 5 May 2023 02:09:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6MuFpyyP34AkjI0+4iqVSuitxXEI/x4rtzLFlOlwTLqwAZlgDJ8pFon/rlg/LshZSzNxiK X-Received: by 2002:aa7:c7da:0:b0:50b:c693:70af with SMTP id o26-20020aa7c7da000000b0050bc69370afmr768714eds.2.1683277748840; Fri, 05 May 2023 02:09:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683277748; cv=none; d=google.com; s=arc-20160816; b=UfDmDr1mP4FpK4PjNxY2Nmnt1HC2bmorT1sAAjKFNr/BIiCK21aZmnxKnqorHNJjBF LgpdyCCezJzYFjFVpTXE5TlPuhLGV5bd/IEM4css8S8qQ545S7lsYeQj92YWi359c7z1 kaxg5l6E9g+w2yhuLZB3BH4nZk/8JwEo9K9RmthhUjeLNJKry5is6K0mtDySUTQ1m66/ /YQrJ4lYufq0nYN0yytAlr/8vqG2dDurNeByWizzH3/eTMIN3Dd+6hLWiVW/cfe/ouGQ OAjYAmy5NJclc5WPbwHHhibPGz8DA9m/+1IemZyM+svn1CSRUAKC22gKP4Pui+0mEbVT ApKg== 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=v0kKMzZh6tjhVKX2mPFOjaEfk9NrYnJf5RIoh+RyDkM=; b=dpOBndFVBYq22S62E2umTwZQwtEgjDBWwyDuFU1pkme3Iz8mB20OxfpYcgYL2A3W4D Fg+m+hGgob8c0UibNnkVTstLPoLKbUzYcVWOvaaI7+ZukvgI2FWAumZf5jT0QoRlrqKc GDfZcc5Vg3o1rzFeQmzzPjzvZopP/apvlkBS/AJrL8O4nf1IQy++jNHfZHHtZzCO6awT kARiueueXWC9j24CxSrr/OYVXytTK8s23BTTkR5AT7vuyBfxhTwFUBEd6lXWmfMuNjFT TbAMNEJLnU15gyccTbP0kd+CDvCObrCcz3Y5/2US73qbv31pfsCLEUVMr6099BE8A7Ki CTNg== 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 w8-20020aa7cb48000000b00508aa5d0efbsi4102661edt.62.2023.05.05.02.09.08; Fri, 05 May 2023 02:09:08 -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 EE12868C174; Fri, 5 May 2023 12:07:47 +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 09A1D68C12A for ; Fri, 5 May 2023 12:07:37 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 51A052405F9 for ; Fri, 5 May 2023 11:07:34 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id yWOeULAn5T-R for ; Fri, 5 May 2023 11:07:33 +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 3223D2406CB for ; Fri, 5 May 2023 11:07:30 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 224FD3A031B for ; Fri, 5 May 2023 11:07:30 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 May 2023 11:07:23 +0200 Message-Id: <20230505090723.24872-11-anton@khirnov.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230505090723.24872-1-anton@khirnov.net> References: <20230505090723.24872-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 11/11] fftools/ffmpeg: discard packets for unused streams in demuxing 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: 0J0Uhk+B7wKe Avoids the pointless overhead of transferring them to the main thread. --- fftools/ffmpeg.c | 4 ---- fftools/ffmpeg_demux.c | 3 ++- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 1ae9445b5d..0edcd3466e 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1961,9 +1961,6 @@ static int process_input(int file_index) ist->data_size += pkt->size; ist->nb_packets++; - if (ist->discard) - goto discard_packet; - /* add the stream-global side data to the first packet */ if (ist->nb_packets == 1) { for (i = 0; i < ist->st->nb_side_data; i++) { @@ -2002,7 +1999,6 @@ static int process_input(int file_index) process_input_packet(ist, pkt, 0); -discard_packet: av_packet_free(&pkt); return 0; diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index ad283356ba..6ba9aaca33 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -318,7 +318,8 @@ static void *input_thread(void *arg) /* the following test is needed in case new streams appear dynamically in stream : we ignore them */ - if (pkt->stream_index >= f->nb_streams) { + if (pkt->stream_index >= f->nb_streams || + f->streams[pkt->stream_index]->discard) { report_new_stream(d, pkt); av_packet_unref(pkt); continue;