From: Andriy Gelman <andriy.gelman@gmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH] avcodec/v4l2_m2m_dec: dequeue frame if input isn't ready
Date: Sat, 25 Dec 2021 02:28:31 -0500
Message-ID: <20211225072831.ox5rzxrzck6s6hp4@jackie> (raw)
In-Reply-To: <20211214021215.456493-1-aicommander@gmail.com>
On Tue, 14. Dec 02:12, Cameron Gutman wrote:
> The V4L2M2M API operates asynchronously, so multiple packets can
> be enqueued before getting a batch of frames back. Since it was
> only possible to receive a frame by submitting another packet,
> there wasn't a way to drain those excess output frames from when
> avcodec_receive_frame() returned AVERROR(EAGAIN).
>
> In my testing, this change reduced decode latency of a real-time
> 60 FPS H.264 stream by approximately 10x (200ms -> 20ms) on a
> Raspberry Pi 4.
>
> Signed-off-by: Cameron Gutman <aicommander@gmail.com>
> ---
> libavcodec/v4l2_m2m_dec.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
> index 224eb3d5e7..b0c3d30ac8 100644
> --- a/libavcodec/v4l2_m2m_dec.c
> +++ b/libavcodec/v4l2_m2m_dec.c
> @@ -142,8 +142,12 @@ static int v4l2_receive_frame(AVCodecContext *avctx, AVFrame *frame)
>
> if (!s->buf_pkt.size) {
> ret = ff_decode_get_packet(avctx, &s->buf_pkt);
> - if (ret < 0 && ret != AVERROR_EOF)
> - return ret;
> + if (ret < 0) {
> + if (ret == AVERROR(EAGAIN))
> + return ff_v4l2_context_dequeue_frame(capture, frame, 0);
> + else if (ret != AVERROR_EOF)
> + return ret;
> + }
> }
The change lgtm. I tested on Rpi4 and odroid xu4.
Will apply this on Sunday if no one else comments.
Thanks,
--
Andriy
_______________________________________________
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".
next parent reply other threads:[~2021-12-25 7:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20211214021215.456493-1-aicommander@gmail.com>
2021-12-25 7:28 ` Andriy Gelman [this message]
2021-12-27 6:17 ` Andriy Gelman
2021-12-27 9:18 ` Cameron Gutman
2021-12-28 23:41 ` Andriy Gelman
2022-01-02 16:56 ` Andriy Gelman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211225072831.ox5rzxrzck6s6hp4@jackie \
--to=andriy.gelman@gmail.com \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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