Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] lavc/libvpxenc: prevent fifo from filling up
@ 2023-07-04  5:08 David Lemler
       [not found] ` <CABWgkX+D5b_7WJPDkv74tZVP_xWjSt8ym-T9FT-Ub3V_7g1LFA@mail.gmail.com>
  0 siblings, 1 reply; 9+ messages in thread
From: David Lemler @ 2023-07-04  5:08 UTC (permalink / raw)
  To: ffmpeg-devel

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 <david@lemler.family>
---
 libavcodec/libvpxenc.c | 6 ++++++
 1 file changed, 6 insertions(+)

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);
+            }
             break;
         }
         case VPX_CODEC_PSNR_PKT:
-- 
2.41.0.windows.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-07-14 16:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-04  5:08 [FFmpeg-devel] [PATCH] lavc/libvpxenc: prevent fifo from filling up David Lemler
     [not found] ` <CABWgkX+D5b_7WJPDkv74tZVP_xWjSt8ym-T9FT-Ub3V_7g1LFA@mail.gmail.com>
2023-07-05 19:16   ` James Zern
2023-07-06  2:22     ` David Lemler
2023-07-07 16:42       ` James Zern
2023-07-06  7:45     ` Anton Khirnov
2023-07-07 16:41       ` James Zern
2023-07-07 21:31         ` David Lemler
2023-07-13 19:38           ` James Zern
2023-07-14 16:58             ` James Zern

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git