From: Ming Qian <ming.qian@nxp.com>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/v4l2_m2m_enc: add a dequeue_timeout parameter
Date: Thu, 24 Mar 2022 14:14:13 +0800
Message-ID: <b8f43d5ff274afdef8c2fc3440970a4c27d2bf9c.1648101782.git.ming.qian@nxp.com> (raw)
In-Reply-To: <cover.1648101782.git.ming.qian@nxp.com>
For the reason similar to decoder,
Set a reasonable timeout instead of -1
to avoid dead waiting in some case.
Signed-off-by: Ming Qian <ming.qian@nxp.com>
---
libavcodec/v4l2_context.c | 4 ++--
libavcodec/v4l2_context.h | 2 +-
libavcodec/v4l2_m2m_enc.c | 5 ++++-
3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c
index 8910ae08d3a5..1122e68f9a97 100644
--- a/libavcodec/v4l2_context.c
+++ b/libavcodec/v4l2_context.c
@@ -644,7 +644,7 @@ int ff_v4l2_context_dequeue_frame(V4L2Context* ctx, AVFrame* frame, int timeout)
return ff_v4l2_buffer_buf_to_avframe(frame, avbuf);
}
-int ff_v4l2_context_dequeue_packet(V4L2Context* ctx, AVPacket* pkt)
+int ff_v4l2_context_dequeue_packet(V4L2Context* ctx, AVPacket* pkt, int timeout)
{
V4L2Buffer *avbuf;
@@ -653,7 +653,7 @@ int ff_v4l2_context_dequeue_packet(V4L2Context* ctx, AVPacket* pkt)
* 1. encoded packet available
* 2. an input buffer ready to be dequeued
*/
- avbuf = v4l2_dequeue_v4l2buf(ctx, -1);
+ avbuf = v4l2_dequeue_v4l2buf(ctx, timeout);
if (!avbuf) {
if (ctx->done)
return AVERROR_EOF;
diff --git a/libavcodec/v4l2_context.h b/libavcodec/v4l2_context.h
index 6f7460c89a9d..b385bccc82a9 100644
--- a/libavcodec/v4l2_context.h
+++ b/libavcodec/v4l2_context.h
@@ -148,7 +148,7 @@ int ff_v4l2_context_set_status(V4L2Context* ctx, uint32_t cmd);
* @param[inout] pkt The AVPacket to dequeue to.
* @return 0 in case of success, AVERROR(EAGAIN) if no buffer was ready, another negative error in case of error.
*/
-int ff_v4l2_context_dequeue_packet(V4L2Context* ctx, AVPacket* pkt);
+int ff_v4l2_context_dequeue_packet(V4L2Context* ctx, AVPacket* pkt, int timeout);
/**
* Dequeues a buffer from a V4L2Context to an AVFrame.
diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
index 1d90de2b9d14..7eae121cf33f 100644
--- a/libavcodec/v4l2_m2m_enc.c
+++ b/libavcodec/v4l2_m2m_enc.c
@@ -290,6 +290,7 @@ static int v4l2_receive_packet(AVCodecContext *avctx, AVPacket *avpkt)
V4L2Context *const capture = &s->capture;
V4L2Context *const output = &s->output;
AVFrame *frame = s->frame;
+ int timeout = ((V4L2m2mPriv*)avctx->priv_data)->dequeue_timeout;
int ret;
if (s->draining)
@@ -328,7 +329,9 @@ static int v4l2_receive_packet(AVCodecContext *avctx, AVPacket *avpkt)
}
dequeue:
- return ff_v4l2_context_dequeue_packet(capture, avpkt);
+ if (s->draining)
+ timeout = -1;
+ return ff_v4l2_context_dequeue_packet(capture, avpkt, timeout);
}
static av_cold int v4l2_encode_init(AVCodecContext *avctx)
--
2.33.0
_______________________________________________
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".
prev parent reply other threads:[~2022-03-24 6:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1648101782.git.ming.qian@nxp.com>
2022-03-24 6:14 ` [FFmpeg-devel] [PATCH 1/2] avcodec/v4l2_m2m_dec: " Ming Qian
2022-03-24 11:22 ` Lynne
2022-03-24 6:14 ` Ming Qian [this message]
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=b8f43d5ff274afdef8c2fc3440970a4c27d2bf9c.1648101782.git.ming.qian@nxp.com \
--to=ming.qian@nxp.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