From c8e187aed5ba8aceac38380dd61bb0d3f183220d Mon Sep 17 00:00:00 2001 From: Florent Revest Date: Mon, 29 Aug 2016 17:44:23 +0200 Subject: [PATCH] Always clear v4l2_plane before sending them to the kernel --- src/buffer.c | 2 ++ src/mpeg2.c | 2 ++ src/mpeg4.c | 2 ++ src/picture.c | 3 +++ src/surface.c | 7 ++++++- 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/buffer.c b/src/buffer.c index 72a2b5d..9d02171 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -52,6 +52,8 @@ VAStatus sunxi_cedrus_CreateBuffer(VADriverContextP ctx, VAContextID context, struct v4l2_plane plane[1]; object_buffer_p obj_buffer; + memset(plane, 0, sizeof(struct v4l2_plane)); + /* Validate type */ switch (type) { diff --git a/src/mpeg2.c b/src/mpeg2.c index 3d8a642..464a1c0 100644 --- a/src/mpeg2.c +++ b/src/mpeg2.c @@ -48,6 +48,8 @@ VAStatus sunxi_cedrus_render_mpeg2_slice_data(VADriverContextP ctx, struct v4l2_buffer buf; struct v4l2_plane plane[1]; + memset(plane, 0, sizeof(struct v4l2_plane)); + /* Query */ memset(&(buf), 0, sizeof(buf)); buf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; diff --git a/src/mpeg4.c b/src/mpeg4.c index c12441e..43e4f99 100644 --- a/src/mpeg4.c +++ b/src/mpeg4.c @@ -48,6 +48,8 @@ VAStatus sunxi_cedrus_render_mpeg4_slice_data(VADriverContextP ctx, struct v4l2_buffer buf; struct v4l2_plane plane[1]; + memset(plane, 0, sizeof(struct v4l2_plane)); + /* Query */ memset(&(buf), 0, sizeof(buf)); buf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; diff --git a/src/picture.c b/src/picture.c index bab4488..90688d2 100644 --- a/src/picture.c +++ b/src/picture.c @@ -170,6 +170,9 @@ VAStatus sunxi_cedrus_EndPicture(VADriverContextP ctx, VAContextID context) * order the different RenderPicture will be called. */ + memset(plane, 0, sizeof(struct v4l2_plane)); + memset(planes, 0, 2 * sizeof(struct v4l2_plane)); + memset(&(out_buf), 0, sizeof(out_buf)); out_buf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; out_buf.memory = V4L2_MEMORY_MMAP; diff --git a/src/surface.c b/src/surface.c index 86043e4..be114cb 100644 --- a/src/surface.c +++ b/src/surface.c @@ -63,6 +63,8 @@ VAStatus sunxi_cedrus_CreateSurfaces(VADriverContextP ctx, int width, struct v4l2_create_buffers create_bufs; struct v4l2_format fmt; + memset(planes, 0, 2 * sizeof(struct v4l2_plane)); + /* We only support one format */ if (VA_RT_FORMAT_YUV420 != format) return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT; @@ -160,9 +162,13 @@ VAStatus sunxi_cedrus_SyncSurface(VADriverContextP ctx, object_surface_p obj_surface; struct v4l2_buffer buf; struct v4l2_plane plane[1]; + struct v4l2_plane planes[2]; fd_set read_fds; struct timeval tv = {0, 300000}; + memset(plane, 0, sizeof(struct v4l2_plane)); + memset(planes, 0, 2 * sizeof(struct v4l2_plane)); + obj_surface = SURFACE(render_target); assert(obj_surface); @@ -186,7 +192,6 @@ VAStatus sunxi_cedrus_SyncSurface(VADriverContextP ctx, } memset(&(buf), 0, sizeof(buf)); - struct v4l2_plane planes[2]; buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; buf.memory = V4L2_MEMORY_MMAP; buf.index = obj_surface->output_buf_index;