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

media: vicodec: rename v4l2_fwht_default_fmt to v4l2_fwht_find_nth_fmt

Rename 'v4l2_fwht_default_fmt' to 'v4l2_fwht_find_nth_fmt'
and add a function 'v4l2_fwht_validate_fmt' to check if
a format info matches the parameters.
This function will also be used to validate the stateless
params when adding support for stateless codecs.
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 92dc64d4
...@@ -37,7 +37,19 @@ static const struct v4l2_fwht_pixfmt_info v4l2_fwht_pixfmts[] = { ...@@ -37,7 +37,19 @@ static const struct v4l2_fwht_pixfmt_info v4l2_fwht_pixfmts[] = {
{ V4L2_PIX_FMT_GREY, 1, 1, 1, 1, 0, 1, 1, 1, 1, FWHT_FL_PIXENC_RGB}, { V4L2_PIX_FMT_GREY, 1, 1, 1, 1, 0, 1, 1, 1, 1, FWHT_FL_PIXENC_RGB},
}; };
const struct v4l2_fwht_pixfmt_info *v4l2_fwht_default_fmt(u32 width_div, bool v4l2_fwht_validate_fmt(const struct v4l2_fwht_pixfmt_info *info,
u32 width_div, u32 height_div, u32 components_num,
u32 pixenc)
{
if (info->width_div == width_div &&
info->height_div == height_div &&
(!pixenc || info->pixenc == pixenc) &&
info->components_num == components_num)
return true;
return false;
}
const struct v4l2_fwht_pixfmt_info *v4l2_fwht_find_nth_fmt(u32 width_div,
u32 height_div, u32 height_div,
u32 components_num, u32 components_num,
u32 pixenc, u32 pixenc,
...@@ -46,10 +58,10 @@ const struct v4l2_fwht_pixfmt_info *v4l2_fwht_default_fmt(u32 width_div, ...@@ -46,10 +58,10 @@ const struct v4l2_fwht_pixfmt_info *v4l2_fwht_default_fmt(u32 width_div,
unsigned int i; unsigned int i;
for (i = 0; i < ARRAY_SIZE(v4l2_fwht_pixfmts); i++) { for (i = 0; i < ARRAY_SIZE(v4l2_fwht_pixfmts); i++) {
if (v4l2_fwht_pixfmts[i].width_div == width_div && bool is_valid = v4l2_fwht_validate_fmt(&v4l2_fwht_pixfmts[i],
v4l2_fwht_pixfmts[i].height_div == height_div && width_div, height_div,
(!pixenc || v4l2_fwht_pixfmts[i].pixenc == pixenc) && components_num, pixenc);
v4l2_fwht_pixfmts[i].components_num == components_num) { if (is_valid) {
if (start_idx == 0) if (start_idx == 0)
return v4l2_fwht_pixfmts + i; return v4l2_fwht_pixfmts + i;
start_idx--; start_idx--;
......
...@@ -48,7 +48,10 @@ struct v4l2_fwht_state { ...@@ -48,7 +48,10 @@ struct v4l2_fwht_state {
const struct v4l2_fwht_pixfmt_info *v4l2_fwht_find_pixfmt(u32 pixelformat); const struct v4l2_fwht_pixfmt_info *v4l2_fwht_find_pixfmt(u32 pixelformat);
const struct v4l2_fwht_pixfmt_info *v4l2_fwht_get_pixfmt(u32 idx); const struct v4l2_fwht_pixfmt_info *v4l2_fwht_get_pixfmt(u32 idx);
const struct v4l2_fwht_pixfmt_info *v4l2_fwht_default_fmt(u32 width_div, bool v4l2_fwht_validate_fmt(const struct v4l2_fwht_pixfmt_info *info,
u32 width_div, u32 height_div, u32 components_num,
u32 pixenc);
const struct v4l2_fwht_pixfmt_info *v4l2_fwht_find_nth_fmt(u32 width_div,
u32 height_div, u32 height_div,
u32 components_num, u32 components_num,
u32 pixenc, u32 pixenc,
......
...@@ -401,7 +401,7 @@ info_from_header(const struct fwht_cframe_hdr *p_hdr) ...@@ -401,7 +401,7 @@ info_from_header(const struct fwht_cframe_hdr *p_hdr)
FWHT_FL_COMPONENTS_NUM_OFFSET); FWHT_FL_COMPONENTS_NUM_OFFSET);
pixenc = (flags & FWHT_FL_PIXENC_MSK); pixenc = (flags & FWHT_FL_PIXENC_MSK);
} }
return v4l2_fwht_default_fmt(width_div, height_div, return v4l2_fwht_find_nth_fmt(width_div, height_div,
components_num, pixenc, 0); components_num, pixenc, 0);
} }
...@@ -622,7 +622,7 @@ static int enum_fmt(struct v4l2_fmtdesc *f, struct vicodec_ctx *ctx, ...@@ -622,7 +622,7 @@ static int enum_fmt(struct v4l2_fmtdesc *f, struct vicodec_ctx *ctx,
if (!info || ctx->is_enc) if (!info || ctx->is_enc)
info = v4l2_fwht_get_pixfmt(f->index); info = v4l2_fwht_get_pixfmt(f->index);
else else
info = v4l2_fwht_default_fmt(info->width_div, info = v4l2_fwht_find_nth_fmt(info->width_div,
info->height_div, info->height_div,
info->components_num, info->components_num,
info->pixenc, info->pixenc,
......
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