From patchwork Tue Jul 4 05:08:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lemler X-Patchwork-Id: 42422 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1e:b0:12b:9ae3:586d with SMTP id c30csp4827135pzh; Mon, 3 Jul 2023 22:08:56 -0700 (PDT) X-Google-Smtp-Source: APBJJlEUveJJU7AGa6g16SbopZ7STeI+xQgfoCfyltpH/x4KyJNQerVraC/PQXw/k0Lm+nqh0dxl X-Received: by 2002:a17:906:c453:b0:98d:5293:55f7 with SMTP id ck19-20020a170906c45300b0098d529355f7mr8977049ejb.6.1688447336230; Mon, 03 Jul 2023 22:08:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688447336; cv=none; d=google.com; s=arc-20160816; b=plCkwZelwDpMXXcWpI53s72/GfGBWpbq9tqlGG/6iPsVIQhdlfHrc4GLH/n0k7m9lA t5tZJqxr4A3qQCUlEdl0iQNs8wtAw76yo3wCH5W75mKCaWEeBxp0yjivOE03cyoNzDyQ m+lPZQIESRP2Tcs4hZwhlAu7WJuSBschlzE0aGPU9c6kbNhz9QnbkhzX6Un2Bk5mX5Pe 0KYUXkY1Bqp1SLjQ0Vp9SV1Tv20c137xaw9pbk22vbos9EQqUNiq3C2NhCFsW9EhtF4E 4iLZ6Hr5u0tCYZ86XQbPh9NM+cCCXZLcfv2D4fpv5cDrAE1ldljZOO1Jm6cBUNkMw7OF j+ow== 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:content-language:thread-index:mime-version :message-id:date:to:from:dkim-signature:delivered-to; bh=maiz4byLQdKU+MCq21dtgkME7Rb/EHYsRzEVgfuJI6A=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=G6zM8AQybP1ft0BCpxoNu/B75FT8rXgzy0G1iJEEN6ZRRHJEmf4izBr1QtJ57wpBxs p1U/3xttA/atzQxnOM/SjmX4Qhp/IDA++dg5jcYPkYugGVhbB8CZQf3nc8PYgfIeYPik /yGnzJ/+0+7Y8yizy74M0pwuCzfC92RDINB2k6Y9H6yEaPbxQoFFoA6SJvEBAk+2mv4Y azhS9ISgNC2Lo0nj2jPnZSq2zAKGGwhDTRLbnhmEhQ65tu31YiAnFlXoeDUw5SK0qmP1 1XZ9U14UYLKRTUBemNvz9qTFhxCkUKbzqipPWhF8Fuca3PiEL3BmbFW838qVzdTWswzB vMMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@lemler.family header.s=default header.b=BsBcbEB6; 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=lemler.family Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id k14-20020a1709065fce00b00988be9d8c53si3979440ejv.946.2023.07.03.22.08.55; Mon, 03 Jul 2023 22:08:56 -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; dkim=neutral (body hash did not verify) header.i=@lemler.family header.s=default header.b=BsBcbEB6; 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=lemler.family Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E8CFC68C02A; Tue, 4 Jul 2023 08:08:51 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from MTA-07-3.privateemail.com (mta-07-3.privateemail.com [198.54.118.214]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B720E68C366 for ; Tue, 4 Jul 2023 08:08:44 +0300 (EEST) Received: from mta-07.privateemail.com (localhost [127.0.0.1]) by mta-07.privateemail.com (Postfix) with ESMTP id D88D618000BA for ; Tue, 4 Jul 2023 01:08:40 -0400 (EDT) Received: from EAS-10 (unknown [10.50.14.248]) by mta-07.privateemail.com (Postfix) with ESMTPA id B3C7E18000A1 for ; Tue, 4 Jul 2023 01:08:40 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=lemler.family; s=default; t=1688447320; bh=sHRnnDop2xdCb1VIXCjTaNKJsLHtSVzxXH5FaOKPJjA=; h=From:To:Subject:Date:From; b=BsBcbEB6WER7kBGoLiNLouD1Jr6fDLuwpUb0IlY75dlBpFgbNVIFgWuFbYpF+pVEA BANBsS9cVOQE6ey9nd21+Aj0YK/AebJE9HIxki9n00oXA8JJigq8XcUW7ezh1LPnva XXiPgrUr8EyzvzKCTvsuehQpPL2I81lpAWfprSPdzrl0xxhCTy0NKQ0JUQlRE6ROV5 HH9F/4ZaRBxmKyagag/AzyTzYAckqfEoF7DfNDQrdJb9Opaxz9rKvs1C1+z4aGlmCb NbNv9qEBp545muq7t12O9FkIf5+FLOEsF1fV0fCw7MSXNjSXuxdf+/JgqwEhQgFzDQ /8PbqPzq1rj0Q== X-Header: Open-Xchange USM Mailer (USM Version: 7.10.6-4, EAS Version: 7.10.6-6, Build e35e63b749ebb3437d8208dad0793e43aace07d1) From: David Lemler To: ffmpeg-devel@ffmpeg.org Date: Tue, 4 Jul 2023 00:08:39 -0500 Message-ID: <1970349688.12787.1688447320689@localhost> MIME-Version: 1.0 X-Mailer: Open-Xchange Mailer v7.10.6-Rev47 Thread-Index: AdmuMfdQd6r7Fx/aQlGmy8+xsX1zKA== Content-Language: en-us X-Originating-Client: USM-EAS X-Virus-Scanned: ClamAV using ClamSMTP Subject: [FFmpeg-devel] [PATCH] lavc/libvpxenc: prevent fifo from filling up 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: 7AQPT1Nf1WYM Prevent the fifo used in encoding VPx videos from filling up and stopping encode when it reaches 21845 items, which happens when the video has more than that number of frames. This problem occurs when performing the first pass of a 2-pass encode, as otherwise, the fifo is properly drained, preventing it from overflowing. Problem is fixed by manually draining the fifo when performing the first pass of a 2-pass encode. Fixes the regression originally introduced in 5bda4ec6c3cb6f286bb40dee4457c3c26e0f78cb Signed-off-by: David Lemler --- libavcodec/libvpxenc.c | 6 ++++++ 1 file changed, 6 insertions(+) break; } case VPX_CODEC_PSNR_PKT: diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index 8833df2d68..e4ab13e6ab 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -1452,6 +1452,12 @@ static int queue_frames(AVCodecContext *avctx, struct vpx_codec_ctx *encoder, memcpy((uint8_t*)stats->buf + stats->sz, pkt->data.twopass_stats.buf, pkt->data.twopass_stats.sz); stats->sz += pkt->data.twopass_stats.sz; + /* Drain the fifo if it has any items in it to prevent it from + filling up when performing the first pass of a 2-pass encode if + the video has more than 21845 frames. */ + if (av_fifo_can_read(ctx->fifo) > 0) { + av_fifo_drain2(ctx->fifo, 1); + }