diff options
author | Andriy Gelman <andriy.gelman@gmail.com> | 2020-08-23 20:33:37 +0300 |
---|---|---|
committer | Andriy Gelman <andriy.gelman@gmail.com> | 2020-08-23 20:42:07 +0300 |
commit | 8bc7f69cefbcbb265b41717608dc8436dc864a55 (patch) | |
tree | 3d2de02c4d41984956f1aee890d12da3058c0d3a /libavcodec/v4l2_m2m_enc.c | |
parent | 994d2567f13c11422aeb6506b6afca42a900d620 (diff) |
avcodec/v4l2_m2m_enc: buffer frame if it cannot be enqueued
Currently if the frame buffers are full, the frame is unrefed and
dropped. Instead buffer the frame so that it is enqueued in the
next v4l2_receive_packet() call. The behavior was observed on
DragonBoard 410c.
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
Diffstat (limited to 'libavcodec/v4l2_m2m_enc.c')
-rw-r--r-- | libavcodec/v4l2_m2m_enc.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c index af0ed1e306..4230a415fd 100644 --- a/libavcodec/v4l2_m2m_enc.c +++ b/libavcodec/v4l2_m2m_enc.c @@ -295,16 +295,20 @@ static int v4l2_receive_packet(AVCodecContext *avctx, AVPacket *avpkt) if (s->draining) goto dequeue; + if (!frame->buf[0]) { ret = ff_encode_get_frame(avctx, frame); if (ret < 0 && ret != AVERROR_EOF) return ret; if (ret == AVERROR_EOF) frame = NULL; + } ret = v4l2_send_frame(avctx, frame); - av_frame_unref(frame); - if (ret < 0) + if (ret != AVERROR(EAGAIN)) + av_frame_unref(frame); + + if (ret < 0 && ret != AVERROR(EAGAIN)) return ret; if (!output->streamon) { |