[FFmpeg-cvslog] libavutil/hwcontext_opencl: Fix channel order in format support check

Jarek Samic git at videolan.org
Wed Apr 10 00:17:42 EEST 2019


ffmpeg | branch: master | Jarek Samic <cldfire3 at gmail.com> | Sun Apr  7 22:01:23 2019 -0400| [1c50d61a5a689f8eabef37f504c6f8f33eb178ba] | committer: Mark Thompson

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 at gmail.com>
Signed-off-by: Mark Thompson <sw at jkqxz.net>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1c50d61a5a689f8eabef37f504c6f8f33eb178ba
---

 libavutil/hwcontext_opencl.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/libavutil/hwcontext_opencl.c b/libavutil/hwcontext_opencl.c
index b116c5b708..41fdfe96f1 100644
--- a/libavutil/hwcontext_opencl.c
+++ b/libavutil/hwcontext_opencl.c
@@ -1419,8 +1419,9 @@ static int opencl_get_plane_format(enum AVPixelFormat pixfmt,
         // from the same component.
         if (step && comp->step != step)
             return AVERROR(EINVAL);
-        order = order * 10 + c + 1;
+
         depth = comp->depth;
+        order = order * 10 + comp->offset / ((depth + 7) / 8) + 1;
         step  = comp->step;
         alpha = (desc->flags & AV_PIX_FMT_FLAG_ALPHA &&
                  c == desc->nb_components - 1);
@@ -1456,14 +1457,10 @@ static int opencl_get_plane_format(enum AVPixelFormat pixfmt,
     case order: image_format->image_channel_order = type; break;
     switch (order) {
         CHANNEL_ORDER(1,    CL_R);
-        CHANNEL_ORDER(2,    CL_R);
-        CHANNEL_ORDER(3,    CL_R);
-        CHANNEL_ORDER(4,    CL_R);
         CHANNEL_ORDER(12,   CL_RG);
-        CHANNEL_ORDER(23,   CL_RG);
         CHANNEL_ORDER(1234, CL_RGBA);
+        CHANNEL_ORDER(2341, CL_ARGB);
         CHANNEL_ORDER(3214, CL_BGRA);
-        CHANNEL_ORDER(4123, CL_ARGB);
 #ifdef CL_ABGR
         CHANNEL_ORDER(4321, CL_ABGR);
 #endif



More information about the ffmpeg-cvslog mailing list