From patchwork Mon Nov 14 15:13:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 39275 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp2487937pzb; Mon, 14 Nov 2022 07:14:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf6sZbHFvoiXLArHRmPS5qWc773X64EgrWwbGmgwAwIa3TDiZ9s22LoUF293cQbe02GJa7Uw X-Received: by 2002:a17:906:793:b0:78c:ad86:d3 with SMTP id l19-20020a170906079300b0078cad8600d3mr10582890ejc.643.1668438896800; Mon, 14 Nov 2022 07:14:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668438896; cv=none; d=google.com; s=arc-20160816; b=Fi4PuleQ/SX7/mxUM4y4H65DDsruDuvE+NCxPXNZHpd4FanVB7vC5pz1gIIhJu/l1m w4uW+7cO6U6vXa+pG8Od0CP/tcqliqkiKAsfPgF8nE8zeVNauXkn9RBPS+j5tuAwXhRq QPNx/73r/fnIc/OnMGEBb6omBRx7es7YX57N6Vro+0igQT9RlpDFlGbsqIzYb8Hxmx2r ZdZ3i9NvqbYlEGvz0WY7ynuPejGAnPfZSJpNBOfvHln10Fef/yfJgeBJt9UcRxSSx3Yv EcpIMiMb3k8QMclmjCZa4L77Pw+RYHFe2IcvkCO+U5Ob6RpTkguhDaDGISJBDQB91Suy sjmw== 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=zxOT3HEV5wywTxHKRqQyHgr7mR3Pl3OYSIDIiN72ChQ=; b=HaOGpnY0vLokiMSCBFPCMHt9e1G8lPdAh3crZKfai+C3/Ee2bsazIoXmExfTqBuOtl Zfl3lbwTUPC+F/h4RlD3yRXBtt/tLQ57iZYOHWmuJ8QTIVY2saBVpwV6v6dz/+cRbp61 5SjEYi5pkhsprWwSBItgfpKPzgpJ55XZ5h9Np4VL1GBwprTjnf/Jp0neIFPwZa7vCfXe jpa09tbMrrW9qLHXbS1JPSl6nhWmeZyrsjXsElW55Kjav+FnC/zwBHKIN6TRUK5Esh7j goMY0AFHan67FjNTKrv7MknTAVWtT6WjhCFYQuyp6EugkYLH3UKMFAeuq/NM1mytLzEC AwSA== 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 c73-20020a509fcf000000b004617df75676si9480833edf.245.2022.11.14.07.14.56; Mon, 14 Nov 2022 07:14:56 -0800 (PST) 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 A268668BE2B; Mon, 14 Nov 2022 17:14:30 +0200 (EET) 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 AC16268BE15 for ; Mon, 14 Nov 2022 17:14:21 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 678D1240499 for ; Mon, 14 Nov 2022 16:14:21 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id oj5U87Nl7iXn for ; Mon, 14 Nov 2022 16:14:20 +0100 (CET) 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 1EBFA2405EC for ; Mon, 14 Nov 2022 16:14:19 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id A85433A0520 for ; Mon, 14 Nov 2022 16:14:18 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Nov 2022 16:13:45 +0100 Message-Id: <20221114151350.5134-3-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221114151350.5134-1-anton@khirnov.net> References: <20221114151350.5134-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/8] fftools/ffmpeg: stop handling max_frames in do_video_out() 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: TrTDn3tk0EOy Frame limiting is now handled using sync queues. This code prevents the sync queue from triggering EOF, resulting in unnecessarily many frames being decoded, filtered, and then discarded. Found-by: U. Artie Eoff --- fftools/ffmpeg.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 0fa2fe8c52..dfdfad3ce4 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1206,14 +1206,6 @@ static void do_video_out(OutputFile *of, } } - /* - * For video, number of frames in == number of packets out. - * But there may be reordering, so we can't throw away frames on encoder - * flush, we need to limit them here, before they go into encoder. - */ - nb_frames = FFMIN(nb_frames, ost->max_frames - ost->vsync_frame_number); - nb0_frames = FFMIN(nb0_frames, nb_frames); - memmove(ost->last_nb0_frames + 1, ost->last_nb0_frames, sizeof(ost->last_nb0_frames[0]) * (FF_ARRAY_ELEMS(ost->last_nb0_frames) - 1)); @@ -1262,7 +1254,9 @@ static void do_video_out(OutputFile *of, in_picture->pict_type = forced_kf_apply(ost, in_picture, i); ret = submit_encode_frame(of, ost, in_picture); - if (ret < 0 && ret != AVERROR_EOF) + if (ret == AVERROR_EOF) + break; + else if (ret < 0) exit_program(1); ost->next_pts++;