Skip to content

Commit 1c50d61

Browse files
Cldfirefhvwy
authored andcommitted
libavutil/hwcontext_opencl: Fix channel order in format support check
The `opencl_get_plane_format` function was incorrectly determining the value used to set the image channel order. This resulted in all RGB pixel formats being set to the `CL_RGBA` pixel format, regardless of whether or not they actually *were* RGBA. This patch fixes the issue by using the `offset` and depth of components rather than the loop index to determine the value of `order`. Signed-off-by: Jarek Samic <cldfire3@gmail.com> Signed-off-by: Mark Thompson <sw@jkqxz.net>
1 parent 1ec777d commit 1c50d61

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

libavutil/hwcontext_opencl.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,8 +1419,9 @@ static int opencl_get_plane_format(enum AVPixelFormat pixfmt,
14191419
// from the same component.
14201420
if (step && comp->step != step)
14211421
return AVERROR(EINVAL);
1422-
order = order * 10 + c + 1;
1422+
14231423
depth = comp->depth;
1424+
order = order * 10 + comp->offset / ((depth + 7) / 8) + 1;
14241425
step = comp->step;
14251426
alpha = (desc->flags & AV_PIX_FMT_FLAG_ALPHA &&
14261427
c == desc->nb_components - 1);
@@ -1456,14 +1457,10 @@ static int opencl_get_plane_format(enum AVPixelFormat pixfmt,
14561457
case order: image_format->image_channel_order = type; break;
14571458
switch (order) {
14581459
CHANNEL_ORDER(1, CL_R);
1459-
CHANNEL_ORDER(2, CL_R);
1460-
CHANNEL_ORDER(3, CL_R);
1461-
CHANNEL_ORDER(4, CL_R);
14621460
CHANNEL_ORDER(12, CL_RG);
1463-
CHANNEL_ORDER(23, CL_RG);
14641461
CHANNEL_ORDER(1234, CL_RGBA);
1462+
CHANNEL_ORDER(2341, CL_ARGB);
14651463
CHANNEL_ORDER(3214, CL_BGRA);
1466-
CHANNEL_ORDER(4123, CL_ARGB);
14671464
#ifdef CL_ABGR
14681465
CHANNEL_ORDER(4321, CL_ABGR);
14691466
#endif

0 commit comments

Comments
 (0)