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 571094BAB5 for ; Wed, 26 Nov 2025 15:29:49 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'KP+YQteJcxZvHaCdVnVPvDSdBcAKdO1bg+6xtmGzCGQ=', expected b'+BeDCjbJgwkcM8W0E+7KpZ2/S7Z3L9tBE/Z0qE7sphw=')) header.d=google.com 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=1764170982; h=date : mime-version : message-id : to : 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=yx9bqFZDGTc1d0njyLwHH7p0JBd3wwC5tVoulNyUN5A=; b=aHvnD+K9h5u2AmbCpzc4Fa6vztgFBuMH0x4UJxElw/WXHiuE2e5TnZusacpo6s7GKBOxA tmvQmkSipbhGnrBJ5iH6RKGLdp1Skzc0zz43EQQig0nEZVGT3V8oBNHt1/6b/fRjgjYRUri x/49QEZRqpZda19AI0SAImlwwVUc3mVgiK51TEUvBjYWwOJd8nFlYXkmryCPBvCLKNEf2GL sw7UtLILN2MOl/7PTSAP1422lwSmmyF25GqFKMeKdQZXVwuFDRuH9eCxegq7oiC57S3gzPj jERkV7MhcLZP/e9tfyNHfWR+6DC0NJcXAwgEmzHMpxAF+s/icF2Ar4t6Insg== Received: from [172.19.0.3] (unknown [172.19.0.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 8F4E769016B; Wed, 26 Nov 2025 17:29:42 +0200 (EET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1764170968; b=OdAEfQlGNBCPEunrX8KSyWm5MmGv+0V6U0FADm5Iih151RmCIPdNxm5DNM8NZCZf2nyhy MWnuw4e4UQDWjsnoQMzNEG55uX69DE4i30eqyUnf1OHPB1ac97uHRmxAjCSaz0PUsxOVRPG 525XJumS2YXhhxxFgffrILdIntd+ITmQaaHEC3wrpmmGMGXJ7y53fj5ueWSzW9e3iI6/9A3 PcdbHdz7FAAY+2Php0s8H0oEoRY1aUjuCHE63ZTzK/SWEHiomjgCqJ5pgCxRextSIbvePW7 QMw9wHk6+1mc9Rt+DfQbx4lqk2ZioDGGZTtpnRwZ82+6pWM/3m3NcccThIdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1764170968; 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=KP+YQteJcxZvHaCdVnVPvDSdBcAKdO1bg+6xtmGzCGQ=; b=aQgL0VsyuyUqJg3/zOQiyr6svWMaQt50nPYltUAFtYdwtlSH23rSFuR86oFCtS2cpMYHh /uKbBRIy6U9fCAa4mfvdX40EhfXB+4jg8D1Q60+F2+xbkkWdQfMN9JS6Wx1pyMs/MXx2AdF qb2BNRo9pPA6W1YpyX6darEZAczWkM3zG7jwjL2Vl4vMUnBMO2JUOJix/PC6xjiAIMbEZfc 1/wjM5hGNy401zMSNMrQC/i/waB/uv5q3xD8Z7hG/JI4ohatS770B3irgH+KYI1AiCRaHe2 XNhF+l2XR/Q65aVF2eA2kT54IP09RMBIezWPNWPCY6tipJixeg/BkTF10n2Q== ARC-Authentication-Results: i=1; ffmpeg.org; dkim=pass header.d=google.com; arc=none; dmarc=pass header.from=google.com policy.dmarc=reject Authentication-Results: ffmpeg.org; dkim=pass header.d=google.com; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=google.com policy.dmarc=reject Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 409866900BD for ; Wed, 26 Nov 2025 17:29:16 +0200 (EET) Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-477cf25ceccso27330975e9.0 for ; Wed, 26 Nov 2025 07:29:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1764170955; x=1764775755; darn=ffmpeg.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=+BeDCjbJgwkcM8W0E+7KpZ2/S7Z3L9tBE/Z0qE7sphw=; b=Ghop5M6OmjHbmxci2I1rHk+LXh3KlOlNciBbz8m90Et4ElFgmSN3CG6gAePH0o2IPK BZSxw8wg+ADtX9TFNNQrx9VFsLRvtUzsmvDj1KJyNTxTYXuYGpjnrJiM3lye1hc/7swE jM+986A0W4ydDZ9CeOBM+O3Y4gDhepdyLymR3N+5/VG6mVp9/o/MZ/yVe9lkCJVtV14c I6niuCtddl7rkkKyd0ljM65rucD8fHhshuFT0YebCPRA35yd8GQ+p+ecbK4Uiki1CBX9 Httq/ht87VTqTPA/KMpZuM47hO6/ehe5+uyJ6xavf2W+dAuxlw0T8guntFj76h7ffmZa TF3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764170955; x=1764775755; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=+BeDCjbJgwkcM8W0E+7KpZ2/S7Z3L9tBE/Z0qE7sphw=; b=ZYnaqVtlu9Hsj/GWlcaG7jb4YriIGKchqOQaVzUdyNcua1/TcX4a6CSpKUKYcYMaCw hV4H4GuhiFafiFFlk/Y0Wqxha2SpaRD1WGAqO/mNafsNCEdj1o9P97vAgW+f7A/uN3U9 utXU8jz5FcU2+3OmGvOBTb0YLDa7OVWSwF4S1GjfzR8jITPjgPzt3O0WzUQvTXgRt2Wz kwyOp0uUYsXwDqcGCNrijMGPTMjGvSLh3ypOcI+bLR6+h9WfpeO2A9SHALhzOhv+2qzX IFHcEDfLvQ9vBkqZboLFW0TMy2u5UXGDfpIAZMSZdKS1Ui1yN61erU7UxJ3Ry1feV92e WogA== X-Gm-Message-State: AOJu0Yz6Oho+uog4R+VMyou9YzQCueLSDqM3SFqJzwj52g48JHs4/56Z q+dVDknSZJiobI/yzkbu9znZLSdx6dvM5bC9RBh4VYvNAm5Y87cSH5s1BijiO/PaYp6xvFSh+nb 2exLROWLpdzia6JbGv+nKbeZ8fDmFqMjQKNb67reENC7uHi2tIIAd47qNKHRjbBqu3+CSlkly27 JUk7FGfs8YhupfOB0V6IEVrveZd5utQBNC09XufA== X-Google-Smtp-Source: AGHT+IHMHK0Xo349OrZQq+pY5ciwx+/5pMdVVAD7F1jRrueKhGTzNVFnicRJCr1HHS+uRRXKtz5XxWrn8mQ= X-Received: from wmga5.prod.google.com ([2002:a05:600c:2d45:b0:477:aa1e:920c]) (user=darekm job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:3b96:b0:477:5c58:3d42 with SMTP id 5b1f17b1804b1-47904ad907amr78421575e9.10.1764170955399; Wed, 26 Nov 2025 07:29:15 -0800 (PST) Date: Wed, 26 Nov 2025 16:28:59 +0100 Mime-Version: 1.0 X-Mailer: git-send-email 2.52.0.487.g5c8c507ade-goog Message-ID: <20251126152859.1968312-1-darekm@google.com> To: ffmpeg-devel@ffmpeg.org Message-ID-Hash: GA54W4COIWIMBROLNG5MGT5W6LPUK2HG X-Message-ID-Hash: GA54W4COIWIMBROLNG5MGT5W6LPUK2HG X-MailFrom: SRS0=Op/O=6C=flex--darekm.bounces.google.com=3yxwnaQYKDPAVSjWceYggYdW.UgeXXehWY-VWnWdXXehWY.gjY@ffmpeg.org 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; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header 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 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: Dariusz Marcinkiewicz via ffmpeg-devel Cc: Dariusz Marcinkiewicz Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Archived-At: List-Archive: List-Post: 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.52.0.487.g5c8c507ade-goog _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org