Commit 8eead25c authored by Dafna Hirschfeld's avatar Dafna Hirschfeld Committed by Mauro Carvalho Chehab

media: vicodec: bugfix - call v4l2_m2m_buf_copy_metadata also if decoding fails

The function 'v4l2_m2m_buf_copy_metadata' should
be called even if decoding/encoding ends with
status VB2_BUF_STATE_ERROR, so that the metadata
is copied from the source buffer to the dest buffer.
Signed-off-by: default avatarDafna Hirschfeld <dafna3@gmail.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent f902796a
...@@ -158,12 +158,10 @@ static int device_process(struct vicodec_ctx *ctx, ...@@ -158,12 +158,10 @@ static int device_process(struct vicodec_ctx *ctx,
struct vb2_v4l2_buffer *dst_vb) struct vb2_v4l2_buffer *dst_vb)
{ {
struct vicodec_dev *dev = ctx->dev; struct vicodec_dev *dev = ctx->dev;
struct vicodec_q_data *q_dst;
struct v4l2_fwht_state *state = &ctx->state; struct v4l2_fwht_state *state = &ctx->state;
u8 *p_src, *p_dst; u8 *p_src, *p_dst;
int ret; int ret;
q_dst = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE);
if (ctx->is_enc) if (ctx->is_enc)
p_src = vb2_plane_vaddr(&src_vb->vb2_buf, 0); p_src = vb2_plane_vaddr(&src_vb->vb2_buf, 0);
else else
...@@ -186,8 +184,10 @@ static int device_process(struct vicodec_ctx *ctx, ...@@ -186,8 +184,10 @@ static int device_process(struct vicodec_ctx *ctx,
return comp_sz_or_errcode; return comp_sz_or_errcode;
vb2_set_plane_payload(&dst_vb->vb2_buf, 0, comp_sz_or_errcode); vb2_set_plane_payload(&dst_vb->vb2_buf, 0, comp_sz_or_errcode);
} else { } else {
struct vicodec_q_data *q_dst;
unsigned int comp_frame_size = ntohl(ctx->state.header.size); unsigned int comp_frame_size = ntohl(ctx->state.header.size);
q_dst = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE);
if (comp_frame_size > ctx->comp_max_size) if (comp_frame_size > ctx->comp_max_size)
return -EINVAL; return -EINVAL;
state->info = q_dst->info; state->info = q_dst->info;
...@@ -196,11 +196,6 @@ static int device_process(struct vicodec_ctx *ctx, ...@@ -196,11 +196,6 @@ static int device_process(struct vicodec_ctx *ctx,
return ret; return ret;
vb2_set_plane_payload(&dst_vb->vb2_buf, 0, q_dst->sizeimage); vb2_set_plane_payload(&dst_vb->vb2_buf, 0, q_dst->sizeimage);
} }
dst_vb->sequence = q_dst->sequence++;
dst_vb->flags &= ~V4L2_BUF_FLAG_LAST;
v4l2_m2m_buf_copy_metadata(src_vb, dst_vb, !ctx->is_enc);
return 0; return 0;
} }
...@@ -274,16 +269,22 @@ static void device_run(void *priv) ...@@ -274,16 +269,22 @@ static void device_run(void *priv)
struct vicodec_ctx *ctx = priv; struct vicodec_ctx *ctx = priv;
struct vicodec_dev *dev = ctx->dev; struct vicodec_dev *dev = ctx->dev;
struct vb2_v4l2_buffer *src_buf, *dst_buf; struct vb2_v4l2_buffer *src_buf, *dst_buf;
struct vicodec_q_data *q_src; struct vicodec_q_data *q_src, *q_dst;
u32 state; u32 state;
src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
dst_buf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); dst_buf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
q_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); q_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT);
q_dst = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE);
state = VB2_BUF_STATE_DONE; state = VB2_BUF_STATE_DONE;
if (device_process(ctx, src_buf, dst_buf)) if (device_process(ctx, src_buf, dst_buf))
state = VB2_BUF_STATE_ERROR; state = VB2_BUF_STATE_ERROR;
else
dst_buf->sequence = q_dst->sequence++;
dst_buf->flags &= ~V4L2_BUF_FLAG_LAST;
v4l2_m2m_buf_copy_metadata(src_buf, dst_buf, !ctx->is_enc);
ctx->last_dst_buf = dst_buf; ctx->last_dst_buf = dst_buf;
spin_lock(ctx->lock); spin_lock(ctx->lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment