From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id DFC994BB02 for ; Thu, 27 Nov 2025 13:20:35 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'7+ejD4xdMrdp6VfqYwjMZpqahlcOcRd2w9NJ+9DyiqM=', expected b'DIp736wu1Y8m022TCeLpFnNmhQwsZ1C8H9efmvkdbpA=')) header.d=ffmpeg.org header.i=@ffmpeg.org header.a=rsa-sha256 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1764249623; h=mime-version : to : date : message-id : reply-to : subject : list-id : list-archive : list-archive : list-help : list-owner : list-post : list-subscribe : list-unsubscribe : from : cc : content-type : content-transfer-encoding : from; bh=7+ejD4xdMrdp6VfqYwjMZpqahlcOcRd2w9NJ+9DyiqM=; b=SYXswi3WUCfkKBbFxc3h71ADClNxzxRdj4ZTjgEooVlBZaF/pdhxUEVRg/90OLRmKy018 e4umHdEWMnfUyyqCCnhy/A4YTSESc/SJ5CoWbh1Z7TnNUhCuGIMCFSTipGoEoBni/KprzT5 MptPrtauruU+PM3VLfl/LcjSFB8qgVtUOEw7K9ZXnNr1SPBgjzaruF7Ox7S0wQWiiu+y4IX xCKxnV+b98JMZHfMDwMV3JxkkZSqUB/pk6JaIK6i2a5qzthRtXQSdzbgukaYUIGFIvfL2g4 wklN7oYEAGJpQF792NOYZhvYe12ovEXTEaV5spTxNSylOYYeDT0hvI+GxalA== Received: from [172.19.0.3] (unknown [172.19.0.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 10C02690246; Thu, 27 Nov 2025 15:20:23 +0200 (EET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1764249608; b=g5RQ93fNNsWqhnD8ZO+ciMUBxURUXubVJ+jormn059+3tSXzgGLRsmRkbyZR1MmkN/ty8 Ni5D469dTC//wXrt7R2wvB4bMi7BIfIzH4fM7EiGpGq8xFK0PzMIc7lw+3MuqwUMq3KouGE 79uyZyNRq9HuvlG4tAWGdTnc942iSWM9iX0dGtEM8Sy280tgFEc30+PZixi1u3E0XsVgPo8 Tvikt/vT9K9uByp3iskHzEthIlPxHLK0xOHzJblsBluobRlgLSuBWqauEl3YP6wKxYm+gzo JNtzfsBFaVzO6midqRHFAtnyZL+Ge0Z5vMyDos+Ga5mCtum98uyRKeQzOpJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1764249608; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=JnYsxtgqXmOlnbxGilffNUXdfjOjo1lLg+B+UOPYy3k=; b=WmykrP45cPdhTmxqeruhjXqGiXrBpcE0sWV0Zj1vNxvXdPizC1A79mozlwahqCopDAuLC Q0o5LhtDmBynpDR2clxM7ahOWX2CE9ieKobufTBX4BP64mymNEOaMQJNf4/TTdPff14fvGV 6RhiXVY9GHPYJPueGOvAp4dxN83teRQu6TAYYbIyKQwldBiYOCP/JcYYVTORMt1RgG/Guh+ bigXVkiTpMvYc+nDI00IOeAiV4kqfwmumj+svAqhtGD+GQpX3iqbWLQqD2rIrR8G0l8LLYJ mwfq/mN8Q1kbEKRO7+7ug83ckDgplcxcClESqQccJz23FfYIj5vGwlB11d6A== ARC-Authentication-Results: i=1; ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none; dmarc=pass header.from=ffmpeg.org policy.dmarc=quarantine Authentication-Results: ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=ffmpeg.org policy.dmarc=quarantine DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1764249599; h=content-type : mime-version : content-transfer-encoding : from : to : reply-to : subject : date : from; bh=DIp736wu1Y8m022TCeLpFnNmhQwsZ1C8H9efmvkdbpA=; b=0FfhmptttX/xX3p6wH49qmugVRjU0Iu+b600lBin4CfD5hGbIqCq4Nmf9sEdFRwTi+QFe e/GI6jRixhlaPX6GZKnoV/qqVnn874wOiTtqIHJ1DTk82zI7Ifo+ScuprQD12ZZAkoOsMUo +25XhYMqrbihSPMAVHH8rGtn/ewuVGwDmH5zlUN7Dpq+H5d5XyWiyCOq3x8QlsZcryHoCpL YVcvJlUsxST36v2EeZzlMt4eLRJUA720BAhg+9NYAGwrojuo97TmZ6tIGi1lMbtimOuhHrg jAbd43L0byE8xp8I+drGgyhMVyTwDw4glya5cAzOROzq7QAeiCKCs6NSqdUw== Received: from 55ca25703178 (code.ffmpeg.org [188.245.149.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 1DB1368F21B for ; Thu, 27 Nov 2025 15:19:59 +0200 (EET) MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Date: Thu, 27 Nov 2025 13:19:58 -0000 Message-ID: <176424959923.39.11759440347503029157@2cb04c0e5124> Message-ID-Hash: L26RRKRSE7M5HENLGJXHNPU7LMLE5EUI X-Message-ID-Hash: L26RRKRSE7M5HENLGJXHNPU7LMLE5EUI X-MailFrom: code@ffmpeg.org X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-ffmpeg-devel.ffmpeg.org-0; header-match-ffmpeg-devel.ffmpeg.org-1; header-match-ffmpeg-devel.ffmpeg.org-2; header-match-ffmpeg-devel.ffmpeg.org-3; emergency; member-moderation X-Mailman-Version: 3.3.10 Precedence: list Reply-To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PATCH] libavcodec: support frame dropping in libvpxenc (PR #21033) List-Id: FFmpeg development discussions and patches Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: darekm via ffmpeg-devel Cc: darekm Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Archived-At: List-Archive: List-Post: PR #21033 opened by darekm URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21033 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21033.patch vp8 encoder can be configured to drop frames, when e.g. bitrate overshoot is detected. At present the code responsible for managing an internal fifo assumes that we will get an output frame per each frame fed into encoder. That is not the case if the encoder can decide to drop frames. Running: ffmpeg -stream_loop 100 -i dash_video3.webm -c:v libvpx -b:v 50k -drop-threshold 20 -screen-content-mode 2 output.webm results in lots of warnings like: [libvpx @ 0x563fd8aba100] Mismatching timestamps: libvpx 2187 queued 2185; this is a bug, please report it [libvpx @ 0x563fd8aba100] Mismatching timestamps: libvpx 2189 queued 2186; this is a bug, please report it followed by: [vost#0:0/libvpx @ 0x563fd8ab9b40] [enc:libvpx @ 0x563fd8aba080] Error submitting video frame to the encoder [vost#0:0/libvpx @ 0x563fd8ab9b40] [enc:libvpx @ 0x563fd8aba080] Error encoding a frame: No space left on device [vost#0:0/libvpx @ 0x563fd8ab9b40] Task finished with error code: -28 (No space left on device) [vost#0:0/libvpx @ 0x563fd8ab9b40] Terminating thread with return code -28 (No space left on device) The reason for the above error is that each dropped frame leaves an extra item in the fifo, which eventually overflows. The proposed fix is to keep popping elements from the fifo until the one with the matching pts is found. A side effect of this change is that the code no longer considers pts mismatch to be a bug. This has likely regressed around 5bda4ec6c3cb6f286bb40dee4457c3c26e0f78cb when fifo started to be universally used. Signed-off-by: Dariusz Marcinkiewicz >>From b9753136ae43fdd6174622f3d037dcc6ccf08dc4 Mon Sep 17 00:00:00 2001 From: Dariusz Marcinkiewicz Date: Wed, 26 Nov 2025 14:15:48 +0100 Subject: [PATCH] libavcodec: support frame dropping in libvpxenc vp8 encoder can be configured to drop frames, when e.g. bitrate overshoot is detected. At present the code responsible for managing an internal fifo assumes that we will get an output frame per each frame fed into encoder. That is not the case if the encoder can decide to drop frames. Running: ffmpeg -stream_loop 100 -i dash_video3.webm -c:v libvpx -b:v 50k -drop-threshold 20 -screen-content-mode 2 output.webm results in lots of warnings like: [libvpx @ 0x563fd8aba100] Mismatching timestamps: libvpx 2187 queued 2185; this is a bug, please report it [libvpx @ 0x563fd8aba100] Mismatching timestamps: libvpx 2189 queued 2186; this is a bug, please report it followed by: [vost#0:0/libvpx @ 0x563fd8ab9b40] [enc:libvpx @ 0x563fd8aba080] Error submitting video frame to the encoder [vost#0:0/libvpx @ 0x563fd8ab9b40] [enc:libvpx @ 0x563fd8aba080] Error encoding a frame: No space left on device [vost#0:0/libvpx @ 0x563fd8ab9b40] Task finished with error code: -28 (No space left on device) [vost#0:0/libvpx @ 0x563fd8ab9b40] Terminating thread with return code -28 (No space left on device) The reason for the above error is that each dropped frame leaves an extra item in the fifo, which eventually overflows. The proposed fix is to keep popping elements from the fifo until the one with the matching pts is found. A side effect of this change is that the code no longer considers pts mismatch to be a bug. This has likely regressed around 5bda4ec6c3cb6f286bb40dee4457c3c26e0f78cb when fifo started to be universally used. Signed-off-by: Dariusz Marcinkiewicz --- libavcodec/libvpxenc.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index 05c34a6857..c537c96603 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -383,6 +383,18 @@ static int frame_data_submit(AVCodecContext *avctx, AVFifo *fifo, } ret = av_fifo_write(fifo, &fd, 1); + if (ret == AVERROR(ENOSPC)) { + FrameData fd2; + + av_log(avctx, AV_LOG_WARNING, "Fifo full, will drop a front element\n"); + + ret = av_fifo_read(fifo, &fd2, 1); + if (ret >= 0) { + frame_data_uninit(&fd2); + ret = av_fifo_write(fifo, &fd, 1); + } + } + if (ret < 0) goto fail; @@ -398,13 +410,18 @@ static int frame_data_apply(AVCodecContext *avctx, AVFifo *fifo, AVPacket *pkt) uint8_t *data; int ret = 0; - if (av_fifo_peek(fifo, &fd, 1, 0) < 0) - return 0; - if (fd.pts != pkt->pts) { - av_log(avctx, AV_LOG_WARNING, - "Mismatching timestamps: libvpx %"PRId64" queued %"PRId64"; " - "this is a bug, please report it\n", pkt->pts, fd.pts); - goto skip; + while (1) { + if (av_fifo_peek(fifo, &fd, 1, 0) < 0) + return 0; + + if (fd.pts == pkt->pts) { + break; + } + + av_log(avctx, AV_LOG_DEBUG, "Dropped frame with pts %"PRId64"\n", + fd.pts); + av_fifo_drain2(fifo, 1); + frame_data_uninit(&fd); } pkt->duration = fd.duration; -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org