From patchwork Mon Apr 8 02:01:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarek Samic X-Patchwork-Id: 12635 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id E0D8C448540 for ; Mon, 8 Apr 2019 05:02:10 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BE04568A722; Mon, 8 Apr 2019 05:02:10 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-it1-f194.google.com (mail-it1-f194.google.com [209.85.166.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 176E3680C8F for ; Mon, 8 Apr 2019 05:02:04 +0300 (EEST) Received: by mail-it1-f194.google.com with SMTP id y134so11685620itc.5 for ; Sun, 07 Apr 2019 19:02:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=AxvXL49KqQfKv3EtYhgFg9r/GtCzbhxcENGb2uC3QD0=; b=klgY3vIs5guq7urV1DKON041q/VJQ7qw31/6b7n93bNoyYJXUZKwoVbgtVCzanAc+O TTOQC1+pRVAmMkJa4fV98zRljfrUmPBDA16X2l6jhJ2HcQGlOuNdGvV4A0Gc+1LhGBHK qidhkFpzVjq/nGXYYnlsRLJ6Erc5ED9nNrhjMYjMSf3Zo6cYR5ypvUmzb8fKDhrE8r6X 8N4meDrvD6lbLDx3F9/JCNeTafgTmMpqbuA4jn4boRpH700IZ7nnCYxT0bjOYldS5qRc Wmw3ZIQTExpK+JFqf9t9dg6G1ygjURJRF90VCmDozo1D7G0bmZVOskCvNur9Na6zAwXW bQ0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=AxvXL49KqQfKv3EtYhgFg9r/GtCzbhxcENGb2uC3QD0=; b=GAwGGfGUrYia/aLjt8hqZmH+iYiObKh8UjpX6e0e7Hpc/mjgWxpUNHkeMNFQ+gUBfh oOu/x9zi4qf44r9sMdln150GDeOTaERjs7gFDY6kBqqeXr76fgiYbW5qJQl5wiM/e1di d2ypYE62sCE/p/O0OreJsRnmKWaEqtZK8H7c1MzPTd+WfoB3xoEUc/iPWUTj1FyfYCtF zEAKMCN3G+AlpWD9g1plMpzIdp/I5ONH3APnu+EuWMKCxgLOUZLmVQLhsc0FlCzWKEu0 Eqkhw0nM67F60br2Fl8Au2LGL0t7KNJ5nzp/AEfm0nL+7fHMVU02AXrCAEnzda19xFeY 4sTg== X-Gm-Message-State: APjAAAWMKM33usv72zxVYOBBV3qBk09GxArX3eOnIh8JmcrZPo/iGgEo fp2eQBSPHL1IBawxFPgHAk5N9Ed/VVw= X-Google-Smtp-Source: APXvYqywmgY76Fmoy/49X4xFcmdofTWJMUmM7hIkcQ4SpHvM9GIZ/mL/sSuHBKVbsRASg3lgTHsBMw== X-Received: by 2002:a02:c644:: with SMTP id k4mr7635038jan.0.1554688922325; Sun, 07 Apr 2019 19:02:02 -0700 (PDT) Received: from cldire-arch.stormhome.local (rrcs-70-61-229-139.central.biz.rr.com. [70.61.229.139]) by smtp.gmail.com with ESMTPSA id b8sm4666656itb.20.2019.04.07.19.02.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 07 Apr 2019 19:02:01 -0700 (PDT) From: Jarek Samic To: ffmpeg-devel@ffmpeg.org Date: Sun, 7 Apr 2019 22:01:23 -0400 Message-Id: <20190408020123.6439-1-cldfire3@gmail.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2] libavutil/hwcontext_opencl.c: fix bug in `opencl_get_plane_format` X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Jarek Samic Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 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 --- I have updated this patch in response to the comments on the first version. RGB is no longer special-cased, the 2, 3, and 4 mappings to `CL_R` have been removed, and the mapping for `CL_ARGB` has been changed to the correct value. libavutil/hwcontext_opencl.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/libavutil/hwcontext_opencl.c b/libavutil/hwcontext_opencl.c index b116c5b708..593de1ca41 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,11 @@ 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