Commit 56ba4d03 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

media: vicodec: simplify flags handling

The flags field can be removed from struct vicodec_q_data.
This simplifies the flags handling elsewhere.
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 29a7a5e9
...@@ -101,7 +101,6 @@ static struct platform_device vicodec_pdev = { ...@@ -101,7 +101,6 @@ static struct platform_device vicodec_pdev = {
struct vicodec_q_data { struct vicodec_q_data {
unsigned int width; unsigned int width;
unsigned int height; unsigned int height;
unsigned int flags;
unsigned int sizeimage; unsigned int sizeimage;
unsigned int sequence; unsigned int sequence;
const struct pixfmt_info *info; const struct pixfmt_info *info;
...@@ -188,7 +187,7 @@ static struct vicodec_q_data *get_q_data(struct vicodec_ctx *ctx, ...@@ -188,7 +187,7 @@ static struct vicodec_q_data *get_q_data(struct vicodec_ctx *ctx,
static void encode(struct vicodec_ctx *ctx, static void encode(struct vicodec_ctx *ctx,
struct vicodec_q_data *q_data, struct vicodec_q_data *q_data,
u8 *p_in, u8 *p_out) u8 *p_in, u8 *p_out, u32 flags)
{ {
unsigned int size = q_data->width * q_data->height; unsigned int size = q_data->width * q_data->height;
const struct pixfmt_info *info = q_data->info; const struct pixfmt_info *info = q_data->info;
...@@ -293,17 +292,17 @@ static void encode(struct vicodec_ctx *ctx, ...@@ -293,17 +292,17 @@ static void encode(struct vicodec_ctx *ctx,
p_hdr->version = htonl(VICODEC_VERSION); p_hdr->version = htonl(VICODEC_VERSION);
p_hdr->width = htonl(cf.width); p_hdr->width = htonl(cf.width);
p_hdr->height = htonl(cf.height); p_hdr->height = htonl(cf.height);
p_hdr->flags = htonl(q_data->flags);
if (encoding & LUMA_UNENCODED) if (encoding & LUMA_UNENCODED)
p_hdr->flags |= htonl(VICODEC_FL_LUMA_IS_UNCOMPRESSED); flags |= VICODEC_FL_LUMA_IS_UNCOMPRESSED;
if (encoding & CB_UNENCODED) if (encoding & CB_UNENCODED)
p_hdr->flags |= htonl(VICODEC_FL_CB_IS_UNCOMPRESSED); flags |= VICODEC_FL_CB_IS_UNCOMPRESSED;
if (encoding & CR_UNENCODED) if (encoding & CR_UNENCODED)
p_hdr->flags |= htonl(VICODEC_FL_CR_IS_UNCOMPRESSED); flags |= VICODEC_FL_CR_IS_UNCOMPRESSED;
if (rf.height_div == 1) if (rf.height_div == 1)
p_hdr->flags |= htonl(VICODEC_FL_CHROMA_FULL_HEIGHT); flags |= VICODEC_FL_CHROMA_FULL_HEIGHT;
if (rf.width_div == 1) if (rf.width_div == 1)
p_hdr->flags |= htonl(VICODEC_FL_CHROMA_FULL_WIDTH); flags |= VICODEC_FL_CHROMA_FULL_WIDTH;
p_hdr->flags = htonl(flags);
p_hdr->colorspace = htonl(ctx->colorspace); p_hdr->colorspace = htonl(ctx->colorspace);
p_hdr->xfer_func = htonl(ctx->xfer_func); p_hdr->xfer_func = htonl(ctx->xfer_func);
p_hdr->ycbcr_enc = htonl(ctx->ycbcr_enc); p_hdr->ycbcr_enc = htonl(ctx->ycbcr_enc);
...@@ -320,6 +319,7 @@ static int decode(struct vicodec_ctx *ctx, ...@@ -320,6 +319,7 @@ static int decode(struct vicodec_ctx *ctx,
unsigned int size = q_data->width * q_data->height; unsigned int size = q_data->width * q_data->height;
unsigned int chroma_size = size; unsigned int chroma_size = size;
unsigned int i; unsigned int i;
u32 flags;
struct cframe_hdr *p_hdr; struct cframe_hdr *p_hdr;
struct cframe cf; struct cframe cf;
u8 *p; u8 *p;
...@@ -327,7 +327,7 @@ static int decode(struct vicodec_ctx *ctx, ...@@ -327,7 +327,7 @@ static int decode(struct vicodec_ctx *ctx,
p_hdr = (struct cframe_hdr *)p_in; p_hdr = (struct cframe_hdr *)p_in;
cf.width = ntohl(p_hdr->width); cf.width = ntohl(p_hdr->width);
cf.height = ntohl(p_hdr->height); cf.height = ntohl(p_hdr->height);
q_data->flags = ntohl(p_hdr->flags); flags = ntohl(p_hdr->flags);
ctx->colorspace = ntohl(p_hdr->colorspace); ctx->colorspace = ntohl(p_hdr->colorspace);
ctx->xfer_func = ntohl(p_hdr->xfer_func); ctx->xfer_func = ntohl(p_hdr->xfer_func);
ctx->ycbcr_enc = ntohl(p_hdr->ycbcr_enc); ctx->ycbcr_enc = ntohl(p_hdr->ycbcr_enc);
...@@ -348,12 +348,12 @@ static int decode(struct vicodec_ctx *ctx, ...@@ -348,12 +348,12 @@ static int decode(struct vicodec_ctx *ctx,
if (cf.width != q_data->width || cf.height != q_data->height) if (cf.width != q_data->width || cf.height != q_data->height)
return -EINVAL; return -EINVAL;
if (!(q_data->flags & VICODEC_FL_CHROMA_FULL_WIDTH)) if (!(flags & VICODEC_FL_CHROMA_FULL_WIDTH))
chroma_size /= 2; chroma_size /= 2;
if (!(q_data->flags & VICODEC_FL_CHROMA_FULL_HEIGHT)) if (!(flags & VICODEC_FL_CHROMA_FULL_HEIGHT))
chroma_size /= 2; chroma_size /= 2;
decode_frame(&cf, &ctx->ref_frame, q_data->flags); decode_frame(&cf, &ctx->ref_frame, flags);
switch (q_data->info->id) { switch (q_data->info->id) {
case V4L2_PIX_FMT_YUV420: case V4L2_PIX_FMT_YUV420:
...@@ -486,7 +486,7 @@ static int device_process(struct vicodec_ctx *ctx, ...@@ -486,7 +486,7 @@ static int device_process(struct vicodec_ctx *ctx,
if (ctx->is_enc) { if (ctx->is_enc) {
struct cframe_hdr *p_hdr = (struct cframe_hdr *)p_out; struct cframe_hdr *p_hdr = (struct cframe_hdr *)p_out;
encode(ctx, q_out, p_in, p_out); encode(ctx, q_out, p_in, p_out, 0);
vb2_set_plane_payload(&out_vb->vb2_buf, 0, vb2_set_plane_payload(&out_vb->vb2_buf, 0,
sizeof(*p_hdr) + ntohl(p_hdr->size)); sizeof(*p_hdr) + ntohl(p_hdr->size));
} else { } else {
......
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