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

media: vicodec: Change variable names

Change variables names in vicodec-core.c to *_src *_dst
to improve readability
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 da2c94c8
...@@ -151,52 +151,52 @@ static struct vicodec_q_data *get_q_data(struct vicodec_ctx *ctx, ...@@ -151,52 +151,52 @@ static struct vicodec_q_data *get_q_data(struct vicodec_ctx *ctx,
} }
static int device_process(struct vicodec_ctx *ctx, static int device_process(struct vicodec_ctx *ctx,
struct vb2_v4l2_buffer *in_vb, struct vb2_v4l2_buffer *src_vb,
struct vb2_v4l2_buffer *out_vb) struct vb2_v4l2_buffer *dst_vb)
{ {
struct vicodec_dev *dev = ctx->dev; struct vicodec_dev *dev = ctx->dev;
struct vicodec_q_data *q_cap; struct vicodec_q_data *q_dst;
struct v4l2_fwht_state *state = &ctx->state; struct v4l2_fwht_state *state = &ctx->state;
u8 *p_in, *p_out; u8 *p_src, *p_dst;
int ret; int ret;
q_cap = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); q_dst = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE);
if (ctx->is_enc) if (ctx->is_enc)
p_in = vb2_plane_vaddr(&in_vb->vb2_buf, 0); p_src = vb2_plane_vaddr(&src_vb->vb2_buf, 0);
else else
p_in = state->compressed_frame; p_src = state->compressed_frame;
p_out = vb2_plane_vaddr(&out_vb->vb2_buf, 0); p_dst = vb2_plane_vaddr(&dst_vb->vb2_buf, 0);
if (!p_in || !p_out) { if (!p_src || !p_dst) {
v4l2_err(&dev->v4l2_dev, v4l2_err(&dev->v4l2_dev,
"Acquiring kernel pointers to buffers failed\n"); "Acquiring kernel pointers to buffers failed\n");
return -EFAULT; return -EFAULT;
} }
if (ctx->is_enc) { if (ctx->is_enc) {
struct vicodec_q_data *q_out; struct vicodec_q_data *q_src;
q_out = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); q_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT);
state->info = q_out->info; state->info = q_src->info;
ret = v4l2_fwht_encode(state, p_in, p_out); ret = v4l2_fwht_encode(state, p_src, p_dst);
if (ret < 0) if (ret < 0)
return ret; return ret;
vb2_set_plane_payload(&out_vb->vb2_buf, 0, ret); vb2_set_plane_payload(&dst_vb->vb2_buf, 0, ret);
} else { } else {
state->info = q_cap->info; state->info = q_dst->info;
ret = v4l2_fwht_decode(state, p_in, p_out); ret = v4l2_fwht_decode(state, p_src, p_dst);
if (ret < 0) if (ret < 0)
return ret; return ret;
vb2_set_plane_payload(&out_vb->vb2_buf, 0, q_cap->sizeimage); vb2_set_plane_payload(&dst_vb->vb2_buf, 0, q_dst->sizeimage);
} }
out_vb->sequence = q_cap->sequence++; dst_vb->sequence = q_dst->sequence++;
out_vb->vb2_buf.timestamp = in_vb->vb2_buf.timestamp; dst_vb->vb2_buf.timestamp = src_vb->vb2_buf.timestamp;
if (in_vb->flags & V4L2_BUF_FLAG_TIMECODE) if (src_vb->flags & V4L2_BUF_FLAG_TIMECODE)
out_vb->timecode = in_vb->timecode; dst_vb->timecode = src_vb->timecode;
out_vb->field = in_vb->field; dst_vb->field = src_vb->field;
out_vb->flags &= ~V4L2_BUF_FLAG_LAST; dst_vb->flags &= ~V4L2_BUF_FLAG_LAST;
out_vb->flags |= in_vb->flags & dst_vb->flags |= src_vb->flags &
(V4L2_BUF_FLAG_TIMECODE | (V4L2_BUF_FLAG_TIMECODE |
V4L2_BUF_FLAG_KEYFRAME | V4L2_BUF_FLAG_KEYFRAME |
V4L2_BUF_FLAG_PFRAME | V4L2_BUF_FLAG_PFRAME |
...@@ -219,12 +219,12 @@ static void device_run(void *priv) ...@@ -219,12 +219,12 @@ 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_out; struct vicodec_q_data *q_src;
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_out = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); q_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT);
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))
...@@ -237,11 +237,11 @@ static void device_run(void *priv) ...@@ -237,11 +237,11 @@ static void device_run(void *priv)
v4l2_event_queue_fh(&ctx->fh, &eos_event); v4l2_event_queue_fh(&ctx->fh, &eos_event);
} }
if (ctx->is_enc) { if (ctx->is_enc) {
src_buf->sequence = q_out->sequence++; src_buf->sequence = q_src->sequence++;
src_buf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); src_buf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
v4l2_m2m_buf_done(src_buf, state); v4l2_m2m_buf_done(src_buf, state);
} else if (vb2_get_plane_payload(&src_buf->vb2_buf, 0) == ctx->cur_buf_offset) { } else if (vb2_get_plane_payload(&src_buf->vb2_buf, 0) == ctx->cur_buf_offset) {
src_buf->sequence = q_out->sequence++; src_buf->sequence = q_src->sequence++;
src_buf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); src_buf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
v4l2_m2m_buf_done(src_buf, state); v4l2_m2m_buf_done(src_buf, state);
ctx->cur_buf_offset = 0; ctx->cur_buf_offset = 0;
...@@ -259,15 +259,15 @@ static void device_run(void *priv) ...@@ -259,15 +259,15 @@ static void device_run(void *priv)
v4l2_m2m_job_finish(dev->dec_dev, ctx->fh.m2m_ctx); v4l2_m2m_job_finish(dev->dec_dev, ctx->fh.m2m_ctx);
} }
static void job_remove_out_buf(struct vicodec_ctx *ctx, u32 state) static void job_remove_src_buf(struct vicodec_ctx *ctx, u32 state)
{ {
struct vb2_v4l2_buffer *src_buf; struct vb2_v4l2_buffer *src_buf;
struct vicodec_q_data *q_out; struct vicodec_q_data *q_src;
q_out = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); q_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT);
spin_lock(ctx->lock); spin_lock(ctx->lock);
src_buf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); src_buf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
src_buf->sequence = q_out->sequence++; src_buf->sequence = q_src->sequence++;
v4l2_m2m_buf_done(src_buf, state); v4l2_m2m_buf_done(src_buf, state);
ctx->cur_buf_offset = 0; ctx->cur_buf_offset = 0;
spin_unlock(ctx->lock); spin_unlock(ctx->lock);
...@@ -280,7 +280,7 @@ static int job_ready(void *priv) ...@@ -280,7 +280,7 @@ static int job_ready(void *priv)
}; };
struct vicodec_ctx *ctx = priv; struct vicodec_ctx *ctx = priv;
struct vb2_v4l2_buffer *src_buf; struct vb2_v4l2_buffer *src_buf;
u8 *p_out; u8 *p_src;
u8 *p; u8 *p;
u32 sz; u32 sz;
u32 state; u32 state;
...@@ -293,15 +293,15 @@ static int job_ready(void *priv) ...@@ -293,15 +293,15 @@ static int job_ready(void *priv)
src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
if (!src_buf) if (!src_buf)
return 0; return 0;
p_out = vb2_plane_vaddr(&src_buf->vb2_buf, 0); p_src = vb2_plane_vaddr(&src_buf->vb2_buf, 0);
sz = vb2_get_plane_payload(&src_buf->vb2_buf, 0); sz = vb2_get_plane_payload(&src_buf->vb2_buf, 0);
p = p_out + ctx->cur_buf_offset; p = p_src + ctx->cur_buf_offset;
state = VB2_BUF_STATE_DONE; state = VB2_BUF_STATE_DONE;
if (!ctx->comp_size) { if (!ctx->comp_size) {
state = VB2_BUF_STATE_ERROR; state = VB2_BUF_STATE_ERROR;
for (; p < p_out + sz; p++) { for (; p < p_src + sz; p++) {
u32 copy; u32 copy;
p = memchr(p, magic[ctx->comp_magic_cnt], sz); p = memchr(p, magic[ctx->comp_magic_cnt], sz);
...@@ -310,8 +310,9 @@ static int job_ready(void *priv) ...@@ -310,8 +310,9 @@ static int job_ready(void *priv)
break; break;
} }
copy = sizeof(magic) - ctx->comp_magic_cnt; copy = sizeof(magic) - ctx->comp_magic_cnt;
if (p_out + sz - p < copy) if (p_src + sz - p < copy)
copy = p_out + sz - p; copy = p_src + sz - p;
memcpy(ctx->state.compressed_frame + ctx->comp_magic_cnt, memcpy(ctx->state.compressed_frame + ctx->comp_magic_cnt,
p, copy); p, copy);
ctx->comp_magic_cnt += copy; ctx->comp_magic_cnt += copy;
...@@ -324,7 +325,7 @@ static int job_ready(void *priv) ...@@ -324,7 +325,7 @@ static int job_ready(void *priv)
ctx->comp_magic_cnt = 0; ctx->comp_magic_cnt = 0;
} }
if (ctx->comp_magic_cnt < sizeof(magic)) { if (ctx->comp_magic_cnt < sizeof(magic)) {
job_remove_out_buf(ctx, state); job_remove_src_buf(ctx, state);
goto restart; goto restart;
} }
ctx->comp_size = sizeof(magic); ctx->comp_size = sizeof(magic);
...@@ -334,14 +335,14 @@ static int job_ready(void *priv) ...@@ -334,14 +335,14 @@ static int job_ready(void *priv)
(struct fwht_cframe_hdr *)ctx->state.compressed_frame; (struct fwht_cframe_hdr *)ctx->state.compressed_frame;
u32 copy = sizeof(struct fwht_cframe_hdr) - ctx->comp_size; u32 copy = sizeof(struct fwht_cframe_hdr) - ctx->comp_size;
if (copy > p_out + sz - p) if (copy > p_src + sz - p)
copy = p_out + sz - p; copy = p_src + sz - p;
memcpy(ctx->state.compressed_frame + ctx->comp_size, memcpy(ctx->state.compressed_frame + ctx->comp_size,
p, copy); p, copy);
p += copy; p += copy;
ctx->comp_size += copy; ctx->comp_size += copy;
if (ctx->comp_size < sizeof(struct fwht_cframe_hdr)) { if (ctx->comp_size < sizeof(struct fwht_cframe_hdr)) {
job_remove_out_buf(ctx, state); job_remove_src_buf(ctx, state);
goto restart; goto restart;
} }
ctx->comp_frame_size = ntohl(p_hdr->size) + sizeof(*p_hdr); ctx->comp_frame_size = ntohl(p_hdr->size) + sizeof(*p_hdr);
...@@ -351,18 +352,19 @@ static int job_ready(void *priv) ...@@ -351,18 +352,19 @@ static int job_ready(void *priv)
if (ctx->comp_size < ctx->comp_frame_size) { if (ctx->comp_size < ctx->comp_frame_size) {
u32 copy = ctx->comp_frame_size - ctx->comp_size; u32 copy = ctx->comp_frame_size - ctx->comp_size;
if (copy > p_out + sz - p) if (copy > p_src + sz - p)
copy = p_out + sz - p; copy = p_src + sz - p;
memcpy(ctx->state.compressed_frame + ctx->comp_size, memcpy(ctx->state.compressed_frame + ctx->comp_size,
p, copy); p, copy);
p += copy; p += copy;
ctx->comp_size += copy; ctx->comp_size += copy;
if (ctx->comp_size < ctx->comp_frame_size) { if (ctx->comp_size < ctx->comp_frame_size) {
job_remove_out_buf(ctx, state); job_remove_src_buf(ctx, state);
goto restart; goto restart;
} }
} }
ctx->cur_buf_offset = p - p_out; ctx->cur_buf_offset = p - p_src;
ctx->comp_has_frame = true; ctx->comp_has_frame = true;
ctx->comp_has_next_frame = false; ctx->comp_has_next_frame = false;
if (sz - ctx->cur_buf_offset >= sizeof(struct fwht_cframe_hdr)) { if (sz - ctx->cur_buf_offset >= sizeof(struct fwht_cframe_hdr)) {
......
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