media: vicodec: prepare support for various number of planes

Add fields to the structs `fwht_raw_frame`, `v4l2_fwht_pixfmts`
to support various number of planes - formats
with alpha channel that have 4 planes and greyscale formats
that have 1 plane.

Signed-off-by: Dafna Hirschfeld <dafna3@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:
Dafna Hirschfeld 2018-11-15 06:23:30 -05:00 committed by Mauro Carvalho Chehab
parent 4e3f14052f
commit aec8991754
5 changed files with 32 additions and 27 deletions

View File

@ -760,7 +760,7 @@ u32 fwht_encode_frame(struct fwht_raw_frame *frm,
rlco_max = rlco + size / 2 - 256;
encoding = encode_plane(frm->luma, ref_frm->luma, &rlco, rlco_max, cf,
frm->height, frm->width,
frm->luma_step, is_intra, next_is_intra);
frm->luma_alpha_step, is_intra, next_is_intra);
if (encoding & FWHT_FRAME_UNENCODED)
encoding |= FWHT_LUMA_UNENCODED;
encoding &= ~FWHT_FRAME_UNENCODED;

View File

@ -104,9 +104,10 @@ struct fwht_raw_frame {
unsigned int width, height;
unsigned int width_div;
unsigned int height_div;
unsigned int luma_step;
unsigned int luma_alpha_step;
unsigned int chroma_step;
u8 *luma, *cb, *cr;
unsigned int components_num;
u8 *luma, *cb, *cr, *alpha;
};
#define FWHT_FRAME_PCODED BIT(0)

View File

@ -11,27 +11,28 @@
#include "codec-v4l2-fwht.h"
static const struct v4l2_fwht_pixfmt_info v4l2_fwht_pixfmts[] = {
{ V4L2_PIX_FMT_YUV420, 1, 3, 2, 1, 1, 2, 2 },
{ V4L2_PIX_FMT_YVU420, 1, 3, 2, 1, 1, 2, 2 },
{ V4L2_PIX_FMT_YUV422P, 1, 2, 1, 1, 1, 2, 1 },
{ V4L2_PIX_FMT_NV12, 1, 3, 2, 1, 2, 2, 2 },
{ V4L2_PIX_FMT_NV21, 1, 3, 2, 1, 2, 2, 2 },
{ V4L2_PIX_FMT_NV16, 1, 2, 1, 1, 2, 2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, 1, 3, 1, 1, 2, 1, 1, 3},
{ V4L2_PIX_FMT_YUYV, 2, 2, 1, 2, 4, 2, 1, 3},
{ V4L2_PIX_FMT_YVYU, 2, 2, 1, 2, 4, 2, 1, 3},
{ V4L2_PIX_FMT_UYVY, 2, 2, 1, 2, 4, 2, 1, 3},
{ V4L2_PIX_FMT_VYUY, 2, 2, 1, 2, 4, 2, 1, 3},
{ V4L2_PIX_FMT_BGR24, 3, 3, 1, 3, 3, 1, 1, 3},
{ V4L2_PIX_FMT_RGB24, 3, 3, 1, 3, 3, 1, 1, 3},
{ V4L2_PIX_FMT_HSV24, 3, 3, 1, 3, 3, 1, 1, 3},
{ V4L2_PIX_FMT_BGR32, 4, 4, 1, 4, 4, 1, 1, 3},
{ V4L2_PIX_FMT_XBGR32, 4, 4, 1, 4, 4, 1, 1, 3},
{ V4L2_PIX_FMT_RGB32, 4, 4, 1, 4, 4, 1, 1, 3},
{ V4L2_PIX_FMT_XRGB32, 4, 4, 1, 4, 4, 1, 1, 3},
{ V4L2_PIX_FMT_HSV32, 4, 4, 1, 4, 4, 1, 1, 3},
};
const struct v4l2_fwht_pixfmt_info *v4l2_fwht_find_pixfmt(u32 pixelformat)
@ -68,8 +69,10 @@ int v4l2_fwht_encode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out)
rf.luma = p_in;
rf.width_div = info->width_div;
rf.height_div = info->height_div;
rf.luma_step = info->luma_step;
rf.luma_alpha_step = info->luma_alpha_step;
rf.chroma_step = info->chroma_step;
rf.alpha = NULL;
rf.components_num = info->components_num;
switch (info->id) {
case V4L2_PIX_FMT_YUV420:

View File

@ -13,11 +13,12 @@ struct v4l2_fwht_pixfmt_info {
unsigned int bytesperline_mult;
unsigned int sizeimage_mult;
unsigned int sizeimage_div;
unsigned int luma_step;
unsigned int luma_alpha_step;
unsigned int chroma_step;
/* Chroma plane subsampling */
unsigned int width_div;
unsigned int height_div;
unsigned int components_num;
};
struct v4l2_fwht_state {

View File

@ -61,7 +61,7 @@ struct pixfmt_info {
};
static const struct v4l2_fwht_pixfmt_info pixfmt_fwht = {
V4L2_PIX_FMT_FWHT, 0, 3, 1, 1, 1, 1, 1
V4L2_PIX_FMT_FWHT, 0, 3, 1, 1, 1, 1, 1, 0
};
static void vicodec_dev_release(struct device *dev)