Commit 49a56266 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

media: vicodec: process all 4 components for RGB32 formats

Only ARGB32-type pixelformat were assumed to have 4 components, which is
wrong since RGB32-type pixelformats may have an alpha channel, so they
should also assume 4 color components.

The XRGB32-type pixelformats really have only 3 color components, but this
complicated matters since that creates strides that are sometimes width * 3
and sometimes width * 4, and in fact this can result in buffer overflows.

Keep things simple by just always processing all 4 color components.

In the future we might want to optimize this again for the XRGB32-type
pixelformats, but for now keep it simple and robust.
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: <stable@vger.kernel.org>      # for v5.4 and up
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent aa9eda76
...@@ -27,17 +27,17 @@ static const struct v4l2_fwht_pixfmt_info v4l2_fwht_pixfmts[] = { ...@@ -27,17 +27,17 @@ static const struct v4l2_fwht_pixfmt_info v4l2_fwht_pixfmts[] = {
{ V4L2_PIX_FMT_BGR24, 3, 3, 1, 3, 3, 1, 1, 3, 1, FWHT_FL_PIXENC_RGB}, { V4L2_PIX_FMT_BGR24, 3, 3, 1, 3, 3, 1, 1, 3, 1, FWHT_FL_PIXENC_RGB},
{ V4L2_PIX_FMT_RGB24, 3, 3, 1, 3, 3, 1, 1, 3, 1, FWHT_FL_PIXENC_RGB}, { V4L2_PIX_FMT_RGB24, 3, 3, 1, 3, 3, 1, 1, 3, 1, FWHT_FL_PIXENC_RGB},
{ V4L2_PIX_FMT_HSV24, 3, 3, 1, 3, 3, 1, 1, 3, 1, FWHT_FL_PIXENC_HSV}, { V4L2_PIX_FMT_HSV24, 3, 3, 1, 3, 3, 1, 1, 3, 1, FWHT_FL_PIXENC_HSV},
{ V4L2_PIX_FMT_BGR32, 4, 4, 1, 4, 4, 1, 1, 3, 1, FWHT_FL_PIXENC_RGB}, { V4L2_PIX_FMT_BGR32, 4, 4, 1, 4, 4, 1, 1, 4, 1, FWHT_FL_PIXENC_RGB},
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, 4, 4, 1, 1, 4, 1, FWHT_FL_PIXENC_RGB},
{ V4L2_PIX_FMT_RGBA32, 4, 4, 1, 4, 4, 1, 1, 4, 1, FWHT_FL_PIXENC_RGB}, { V4L2_PIX_FMT_RGBA32, 4, 4, 1, 4, 4, 1, 1, 4, 1, FWHT_FL_PIXENC_RGB},
{ V4L2_PIX_FMT_HSV32, 4, 4, 1, 4, 4, 1, 1, 3, 1, FWHT_FL_PIXENC_HSV}, { V4L2_PIX_FMT_HSV32, 4, 4, 1, 4, 4, 1, 1, 4, 1, FWHT_FL_PIXENC_HSV},
{ 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},
}; };
...@@ -175,22 +175,14 @@ static int prepare_raw_frame(struct fwht_raw_frame *rf, ...@@ -175,22 +175,14 @@ static int prepare_raw_frame(struct fwht_raw_frame *rf,
case V4L2_PIX_FMT_RGB32: case V4L2_PIX_FMT_RGB32:
case V4L2_PIX_FMT_XRGB32: case V4L2_PIX_FMT_XRGB32:
case V4L2_PIX_FMT_HSV32: case V4L2_PIX_FMT_HSV32:
rf->cr = rf->luma + 1;
rf->cb = rf->cr + 2;
rf->luma += 2;
break;
case V4L2_PIX_FMT_BGR32:
case V4L2_PIX_FMT_XBGR32:
rf->cb = rf->luma;
rf->cr = rf->cb + 2;
rf->luma++;
break;
case V4L2_PIX_FMT_ARGB32: case V4L2_PIX_FMT_ARGB32:
rf->alpha = rf->luma; rf->alpha = rf->luma;
rf->cr = rf->luma + 1; rf->cr = rf->luma + 1;
rf->cb = rf->cr + 2; rf->cb = rf->cr + 2;
rf->luma += 2; rf->luma += 2;
break; break;
case V4L2_PIX_FMT_BGR32:
case V4L2_PIX_FMT_XBGR32:
case V4L2_PIX_FMT_ABGR32: case V4L2_PIX_FMT_ABGR32:
rf->cb = rf->luma; rf->cb = rf->luma;
rf->cr = rf->cb + 2; rf->cr = rf->cb + 2;
...@@ -198,10 +190,6 @@ static int prepare_raw_frame(struct fwht_raw_frame *rf, ...@@ -198,10 +190,6 @@ static int prepare_raw_frame(struct fwht_raw_frame *rf,
rf->alpha = rf->cr + 1; rf->alpha = rf->cr + 1;
break; break;
case V4L2_PIX_FMT_BGRX32: case V4L2_PIX_FMT_BGRX32:
rf->cb = rf->luma + 1;
rf->cr = rf->cb + 2;
rf->luma += 2;
break;
case V4L2_PIX_FMT_BGRA32: case V4L2_PIX_FMT_BGRA32:
rf->alpha = rf->luma; rf->alpha = rf->luma;
rf->cb = rf->luma + 1; rf->cb = rf->luma + 1;
...@@ -209,10 +197,6 @@ static int prepare_raw_frame(struct fwht_raw_frame *rf, ...@@ -209,10 +197,6 @@ static int prepare_raw_frame(struct fwht_raw_frame *rf,
rf->luma += 2; rf->luma += 2;
break; break;
case V4L2_PIX_FMT_RGBX32: case V4L2_PIX_FMT_RGBX32:
rf->cr = rf->luma;
rf->cb = rf->cr + 2;
rf->luma++;
break;
case V4L2_PIX_FMT_RGBA32: case V4L2_PIX_FMT_RGBA32:
rf->alpha = rf->luma + 3; rf->alpha = rf->luma + 3;
rf->cr = rf->luma; rf->cr = rf->luma;
......
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