summaryrefslogtreecommitdiff
path: root/libavcodec/v4l2_buffers.c
diff options
context:
space:
mode:
authorJorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>2017-10-06 09:51:43 +0200
committerMark Thompson <sw@jkqxz.net>2017-10-06 23:36:21 +0100
commit2a31ad7d60632cca0f43986b6a5b135848088b14 (patch)
tree1b16bd84966603056f0a95076c1f8f4939b77735 /libavcodec/v4l2_buffers.c
parent7d141e2cacb42a25df0c32a6deb5256fdbec4425 (diff)
avcodec/v4l2: fix single plane decoding
Diffstat (limited to 'libavcodec/v4l2_buffers.c')
-rw-r--r--libavcodec/v4l2_buffers.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/libavcodec/v4l2_buffers.c b/libavcodec/v4l2_buffers.c
index ef7d040032..ba70c5d14b 100644
--- a/libavcodec/v4l2_buffers.c
+++ b/libavcodec/v4l2_buffers.c
@@ -244,13 +244,23 @@ static int v4l2_buf_to_bufref(V4L2Buffer *in, int plane, AVBufferRef **buf)
static int v4l2_bufref_to_buf(V4L2Buffer *out, int plane, const uint8_t* data, int size, AVBufferRef* bref)
{
+ unsigned int bytesused, length;
+
if (plane >= out->num_planes)
return AVERROR(EINVAL);
+ bytesused = FFMIN(size, out->plane_info[plane].length);
+ length = out->plane_info[plane].length;
+
memcpy(out->plane_info[plane].mm_addr, data, FFMIN(size, out->plane_info[plane].length));
- out->planes[plane].bytesused = FFMIN(size, out->plane_info[plane].length);
- out->planes[plane].length = out->plane_info[plane].length;
+ if (V4L2_TYPE_IS_MULTIPLANAR(out->buf.type)) {
+ out->planes[plane].bytesused = bytesused;
+ out->planes[plane].length = length;
+ } else {
+ out->buf.bytesused = bytesused;
+ out->buf.length = length;
+ }
return 0;
}