From patchwork Fri Apr 5 23:05:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarek Samic X-Patchwork-Id: 12621 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 701E7448CBE for ; Sat, 6 Apr 2019 02:08:12 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3ECD968AAD3; Sat, 6 Apr 2019 02:08:12 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-it1-f193.google.com (mail-it1-f193.google.com [209.85.166.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8EF3C68AA7D for ; Sat, 6 Apr 2019 02:08:05 +0300 (EEST) Received: by mail-it1-f193.google.com with SMTP id s3so12216678itk.1 for ; Fri, 05 Apr 2019 16:08:05 -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=PyvnPlro7DwFAW6HLacJFBjdgD9a6IiyMiDilV9kbR4=; b=jkLYsSmPDQq3Szu6MhQ3cmgiXttJfdzlX0O3agBHldnC5ufoH+fxMjTcK5A9XnPKgb bK+nhu/D4rMcKySoVlQNlo5tiUO6IYj8X3rrZ8wZ7TzU30YrKCux1hu/V9ueGPml/59E dYV0sbIKaM8NWdTSTxTgtU59y1k6ENx7vVwKFjhiVU5T2lwUpOjlSekEYTMLsXHBIPzt VjIFCWSwoRi1mHeeQbeWlw5mmcZemwgSd2Hdyo9bLTOlO/v5wj8yQbaGjZAY7rg5/M7g VjdNnnnL91vurwC7KCcvGvxvxTxYhyudGA0VTjHqrScOqgwZJ5VLCxx7PtJVsb1R+1uM g46w== 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=PyvnPlro7DwFAW6HLacJFBjdgD9a6IiyMiDilV9kbR4=; b=j//9Bb1x68gWmoQWv7srWEi3MPgZVs9qizz1aJVeNTwwTO29MuPueXu1Xyjgcbysfv 462SKRr7llMWo6c5fNzuVoYAci6Jr+78cGa/BKkasx+A0xxfS5OY/UnZTi7It2am1Muy NFAMCeizYQEXlrKNDReWXqS8/LeaiHDlMsK2Ob3l6UIYFNd/L9e7jLz2b5KDkcEjIGNm gEQaLeTTaV1zJd7+OACXQTs5Y4DFR+hgTUNg0vXzPBDuoFEyTD6H4Z8AOQoB2jNv0eDY jW668gOJkRnL65aQF1bxIaJh6EXk7/N06TPJYo7svB6ohomkPjUbtu9bTarT5rJ/r4l/ QffA== X-Gm-Message-State: APjAAAVlougq28hiGStXUMmbP1n9v7czgCvAqGp2+8smYw8SpkUbUVP1 BzaTGOVW2fcuBYDZvNNlDrHk+5lgmCc= X-Google-Smtp-Source: APXvYqxSfnojvMwE+2ADUnNF+Rrr9zXgblSyk7WFn0RuDcW5T7bM2WlX11Ozzo0cXaNigH1hW5juCA== X-Received: by 2002:a02:6209:: with SMTP id d9mr11504855jac.34.1554505683264; Fri, 05 Apr 2019 16:08:03 -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 m143sm1727395itm.32.2019.04.05.16.08.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Apr 2019 16:08:02 -0700 (PDT) From: Jarek Samic To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Apr 2019 19:05:46 -0400 Message-Id: <20190405230545.26890-1-cldfire3@gmail.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] 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` field on components rather than the loop index to determine the value of `order` for RGB pixel formats (and leaves the formula to determine `order` the same for other formats so as not to break those cases). Signed-off-by: Jarek Samic --- I'm including this in the email (but not the commit description) to make this patch easier to review. In order to make sure I was fixing the bug and not messing up channel order mapping for any of the other formats, I set up a few quick print statements within the function after the `order` value was set. Here's the output without this patch: ``` [AVHWDeviceContext @ _] Maximum supported image size 16384x16384. [opencl_get_plane_format] order_num: 1, pixel_format: yuv420p, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuv420p, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuv420p, plane: 2 [AVHWDeviceContext @ _] Format yuv420p supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuv422p, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuv422p, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuv422p, plane: 2 [AVHWDeviceContext @ _] Format yuv422p supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuv444p, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuv444p, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuv444p, plane: 2 [AVHWDeviceContext @ _] Format yuv444p supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuv410p, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuv410p, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuv410p, plane: 2 [AVHWDeviceContext @ _] Format yuv410p supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuv411p, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuv411p, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuv411p, plane: 2 [AVHWDeviceContext @ _] Format yuv411p supported. [opencl_get_plane_format] order_num: 1, pixel_format: gray, plane: 0 [AVHWDeviceContext @ _] Format gray supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuvj420p, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuvj420p, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuvj420p, plane: 2 [AVHWDeviceContext @ _] Format yuvj420p supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuvj422p, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuvj422p, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuvj422p, plane: 2 [AVHWDeviceContext @ _] Format yuvj422p supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuvj444p, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuvj444p, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuvj444p, plane: 2 [AVHWDeviceContext @ _] Format yuvj444p supported. [opencl_get_plane_format] order_num: 1, pixel_format: nv12, plane: 0 [opencl_get_plane_format] order_num: 23, pixel_format: nv12, plane: 1 [AVHWDeviceContext @ _] Format nv12 supported. [opencl_get_plane_format] order_num: 1, pixel_format: nv21, plane: 0 [opencl_get_plane_format] order_num: 23, pixel_format: nv21, plane: 1 [AVHWDeviceContext @ _] Format nv21 supported. [opencl_get_plane_format] order_num: 1234, pixel_format: argb, plane: 0 [AVHWDeviceContext @ _] Format argb supported. [opencl_get_plane_format] order_num: 1234, pixel_format: rgba, plane: 0 [AVHWDeviceContext @ _] Format rgba supported. [opencl_get_plane_format] order_num: 1234, pixel_format: abgr, plane: 0 [AVHWDeviceContext @ _] Format abgr supported. [opencl_get_plane_format] order_num: 1234, pixel_format: bgra, plane: 0 [AVHWDeviceContext @ _] Format bgra supported. [opencl_get_plane_format] order_num: 1, pixel_format: gray16le, plane: 0 [AVHWDeviceContext @ _] Format gray16le supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuv440p, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuv440p, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuv440p, plane: 2 [AVHWDeviceContext @ _] Format yuv440p supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuvj440p, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuvj440p, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuvj440p, plane: 2 [AVHWDeviceContext @ _] Format yuvj440p supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuva420p, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuva420p, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuva420p, plane: 2 [opencl_get_plane_format] order_num: 4, pixel_format: yuva420p, plane: 3 [AVHWDeviceContext @ _] Format yuva420p supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuv420p16le, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuv420p16le, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuv420p16le, plane: 2 [AVHWDeviceContext @ _] Format yuv420p16le supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuv422p16le, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuv422p16le, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuv422p16le, plane: 2 [AVHWDeviceContext @ _] Format yuv422p16le supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuv444p16le, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuv444p16le, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuv444p16le, plane: 2 [AVHWDeviceContext @ _] Format yuv444p16le supported. [opencl_get_plane_format] order_num: 12, pixel_format: ya8, plane: 0 [AVHWDeviceContext @ _] Format ya8 supported. [opencl_get_plane_format] order_num: 2, pixel_format: gbrp, plane: 0 [opencl_get_plane_format] order_num: 3, pixel_format: gbrp, plane: 1 [opencl_get_plane_format] order_num: 1, pixel_format: gbrp, plane: 2 [AVHWDeviceContext @ _] Format gbrp supported. [opencl_get_plane_format] order_num: 2, pixel_format: gbrp16le, plane: 0 [opencl_get_plane_format] order_num: 3, pixel_format: gbrp16le, plane: 1 [opencl_get_plane_format] order_num: 1, pixel_format: gbrp16le, plane: 2 [AVHWDeviceContext @ _] Format gbrp16le supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuva422p, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuva422p, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuva422p, plane: 2 [opencl_get_plane_format] order_num: 4, pixel_format: yuva422p, plane: 3 [AVHWDeviceContext @ _] Format yuva422p supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuva444p, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuva444p, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuva444p, plane: 2 [opencl_get_plane_format] order_num: 4, pixel_format: yuva444p, plane: 3 [AVHWDeviceContext @ _] Format yuva444p supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuva420p16le, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuva420p16le, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuva420p16le, plane: 2 [opencl_get_plane_format] order_num: 4, pixel_format: yuva420p16le, plane: 3 [AVHWDeviceContext @ _] Format yuva420p16le supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuva422p16le, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuva422p16le, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuva422p16le, plane: 2 [opencl_get_plane_format] order_num: 4, pixel_format: yuva422p16le, plane: 3 [AVHWDeviceContext @ _] Format yuva422p16le supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuva444p16le, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuva444p16le, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuva444p16le, plane: 2 [opencl_get_plane_format] order_num: 4, pixel_format: yuva444p16le, plane: 3 [AVHWDeviceContext @ _] Format yuva444p16le supported. [opencl_get_plane_format] order_num: 1, pixel_format: nv16, plane: 0 [opencl_get_plane_format] order_num: 23, pixel_format: nv16, plane: 1 [AVHWDeviceContext @ _] Format nv16 supported. [opencl_get_plane_format] order_num: 1234, pixel_format: rgba64le, plane: 0 [AVHWDeviceContext @ _] Format rgba64le supported. [opencl_get_plane_format] order_num: 1234, pixel_format: bgra64le, plane: 0 [AVHWDeviceContext @ _] Format bgra64le supported. [opencl_get_plane_format] order_num: 12, pixel_format: ya16le, plane: 0 [AVHWDeviceContext @ _] Format ya16le supported. [opencl_get_plane_format] order_num: 2, pixel_format: gbrap, plane: 0 [opencl_get_plane_format] order_num: 3, pixel_format: gbrap, plane: 1 [opencl_get_plane_format] order_num: 1, pixel_format: gbrap, plane: 2 [opencl_get_plane_format] order_num: 4, pixel_format: gbrap, plane: 3 [AVHWDeviceContext @ _] Format gbrap supported. [opencl_get_plane_format] order_num: 2, pixel_format: gbrap16le, plane: 0 [opencl_get_plane_format] order_num: 3, pixel_format: gbrap16le, plane: 1 [opencl_get_plane_format] order_num: 1, pixel_format: gbrap16le, plane: 2 [opencl_get_plane_format] order_num: 4, pixel_format: gbrap16le, plane: 3 [AVHWDeviceContext @ _] Format gbrap16le supported. [opencl_get_plane_format] order_num: 123, pixel_format: 0rgb, plane: 0 [opencl_get_plane_format] order_num: 123, pixel_format: rgb0, plane: 0 [opencl_get_plane_format] order_num: 123, pixel_format: 0bgr, plane: 0 [opencl_get_plane_format] order_num: 123, pixel_format: bgr0, plane: 0 [opencl_get_plane_format] order_num: 1, pixel_format: yuvj411p, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuvj411p, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuvj411p, plane: 2 [AVHWDeviceContext @ _] Format yuvj411p supported. [opencl_get_plane_format] order_num: 1234, pixel_format: ayuv64le, plane: 0 [AVHWDeviceContext @ _] Format ayuv64le supported. [opencl_get_plane_format] order_num: 1, pixel_format: p010le, plane: 0 [opencl_get_plane_format] order_num: 23, pixel_format: p010le, plane: 1 [AVHWDeviceContext @ _] Format p010le supported. [opencl_get_plane_format] order_num: 1, pixel_format: p016le, plane: 0 [opencl_get_plane_format] order_num: 23, pixel_format: p016le, plane: 1 [AVHWDeviceContext @ _] Format p016le supported. ``` Here's the output with this patch: ``` [AVHWDeviceContext @ _] Maximum supported image size 16384x16384. [opencl_get_plane_format] order_num: 1, pixel_format: yuv420p, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuv420p, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuv420p, plane: 2 [AVHWDeviceContext @ _] Format yuv420p supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuv422p, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuv422p, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuv422p, plane: 2 [AVHWDeviceContext @ _] Format yuv422p supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuv444p, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuv444p, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuv444p, plane: 2 [AVHWDeviceContext @ _] Format yuv444p supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuv410p, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuv410p, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuv410p, plane: 2 [AVHWDeviceContext @ _] Format yuv410p supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuv411p, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuv411p, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuv411p, plane: 2 [AVHWDeviceContext @ _] Format yuv411p supported. [opencl_get_plane_format] order_num: 1, pixel_format: gray, plane: 0 [AVHWDeviceContext @ _] Format gray supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuvj420p, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuvj420p, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuvj420p, plane: 2 [AVHWDeviceContext @ _] Format yuvj420p supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuvj422p, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuvj422p, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuvj422p, plane: 2 [AVHWDeviceContext @ _] Format yuvj422p supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuvj444p, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuvj444p, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuvj444p, plane: 2 [AVHWDeviceContext @ _] Format yuvj444p supported. [opencl_get_plane_format] order_num: 1, pixel_format: nv12, plane: 0 [opencl_get_plane_format] order_num: 23, pixel_format: nv12, plane: 1 [AVHWDeviceContext @ _] Format nv12 supported. [opencl_get_plane_format] order_num: 1, pixel_format: nv21, plane: 0 [opencl_get_plane_format] order_num: 23, pixel_format: nv21, plane: 1 [AVHWDeviceContext @ _] Format nv21 supported. [opencl_get_plane_format] order_num: 2341, pixel_format: argb, plane: 0 [opencl_get_plane_format] order_num: 1234, pixel_format: rgba, plane: 0 [AVHWDeviceContext @ _] Format rgba supported. [opencl_get_plane_format] order_num: 4321, pixel_format: abgr, plane: 0 [opencl_get_plane_format] order_num: 3214, pixel_format: bgra, plane: 0 [AVHWDeviceContext @ _] Format bgra supported. [opencl_get_plane_format] order_num: 1, pixel_format: gray16le, plane: 0 [AVHWDeviceContext @ _] Format gray16le supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuv440p, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuv440p, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuv440p, plane: 2 [AVHWDeviceContext @ _] Format yuv440p supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuvj440p, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuvj440p, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuvj440p, plane: 2 [AVHWDeviceContext @ _] Format yuvj440p supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuva420p, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuva420p, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuva420p, plane: 2 [opencl_get_plane_format] order_num: 4, pixel_format: yuva420p, plane: 3 [AVHWDeviceContext @ _] Format yuva420p supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuv420p16le, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuv420p16le, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuv420p16le, plane: 2 [AVHWDeviceContext @ _] Format yuv420p16le supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuv422p16le, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuv422p16le, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuv422p16le, plane: 2 [AVHWDeviceContext @ _] Format yuv422p16le supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuv444p16le, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuv444p16le, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuv444p16le, plane: 2 [AVHWDeviceContext @ _] Format yuv444p16le supported. [opencl_get_plane_format] order_num: 12, pixel_format: ya8, plane: 0 [AVHWDeviceContext @ _] Format ya8 supported. [opencl_get_plane_format] order_num: 1, pixel_format: gbrp, plane: 0 [opencl_get_plane_format] order_num: 1, pixel_format: gbrp, plane: 1 [opencl_get_plane_format] order_num: 1, pixel_format: gbrp, plane: 2 [AVHWDeviceContext @ _] Format gbrp supported. [opencl_get_plane_format] order_num: 1, pixel_format: gbrp16le, plane: 0 [opencl_get_plane_format] order_num: 1, pixel_format: gbrp16le, plane: 1 [opencl_get_plane_format] order_num: 1, pixel_format: gbrp16le, plane: 2 [AVHWDeviceContext @ _] Format gbrp16le supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuva422p, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuva422p, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuva422p, plane: 2 [opencl_get_plane_format] order_num: 4, pixel_format: yuva422p, plane: 3 [AVHWDeviceContext @ _] Format yuva422p supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuva444p, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuva444p, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuva444p, plane: 2 [opencl_get_plane_format] order_num: 4, pixel_format: yuva444p, plane: 3 [AVHWDeviceContext @ _] Format yuva444p supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuva420p16le, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuva420p16le, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuva420p16le, plane: 2 [opencl_get_plane_format] order_num: 4, pixel_format: yuva420p16le, plane: 3 [AVHWDeviceContext @ _] Format yuva420p16le supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuva422p16le, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuva422p16le, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuva422p16le, plane: 2 [opencl_get_plane_format] order_num: 4, pixel_format: yuva422p16le, plane: 3 [AVHWDeviceContext @ _] Format yuva422p16le supported. [opencl_get_plane_format] order_num: 1, pixel_format: yuva444p16le, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuva444p16le, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuva444p16le, plane: 2 [opencl_get_plane_format] order_num: 4, pixel_format: yuva444p16le, plane: 3 [AVHWDeviceContext @ _] Format yuva444p16le supported. [opencl_get_plane_format] order_num: 1, pixel_format: nv16, plane: 0 [opencl_get_plane_format] order_num: 23, pixel_format: nv16, plane: 1 [AVHWDeviceContext @ _] Format nv16 supported. [opencl_get_plane_format] order_num: 1234, pixel_format: rgba64le, plane: 0 [AVHWDeviceContext @ _] Format rgba64le supported. [opencl_get_plane_format] order_num: 3214, pixel_format: bgra64le, plane: 0 [opencl_get_plane_format] order_num: 12, pixel_format: ya16le, plane: 0 [AVHWDeviceContext @ _] Format ya16le supported. [opencl_get_plane_format] order_num: 1, pixel_format: gbrap, plane: 0 [opencl_get_plane_format] order_num: 1, pixel_format: gbrap, plane: 1 [opencl_get_plane_format] order_num: 1, pixel_format: gbrap, plane: 2 [opencl_get_plane_format] order_num: 1, pixel_format: gbrap, plane: 3 [AVHWDeviceContext @ _] Format gbrap supported. [opencl_get_plane_format] order_num: 1, pixel_format: gbrap16le, plane: 0 [opencl_get_plane_format] order_num: 1, pixel_format: gbrap16le, plane: 1 [opencl_get_plane_format] order_num: 1, pixel_format: gbrap16le, plane: 2 [opencl_get_plane_format] order_num: 1, pixel_format: gbrap16le, plane: 3 [AVHWDeviceContext @ _] Format gbrap16le supported. [opencl_get_plane_format] order_num: 234, pixel_format: 0rgb, plane: 0 [opencl_get_plane_format] order_num: 123, pixel_format: rgb0, plane: 0 [opencl_get_plane_format] order_num: 432, pixel_format: 0bgr, plane: 0 [opencl_get_plane_format] order_num: 321, pixel_format: bgr0, plane: 0 [opencl_get_plane_format] order_num: 1, pixel_format: yuvj411p, plane: 0 [opencl_get_plane_format] order_num: 2, pixel_format: yuvj411p, plane: 1 [opencl_get_plane_format] order_num: 3, pixel_format: yuvj411p, plane: 2 [AVHWDeviceContext @ _] Format yuvj411p supported. [opencl_get_plane_format] order_num: 1234, pixel_format: ayuv64le, plane: 0 [AVHWDeviceContext @ _] Format ayuv64le supported. [opencl_get_plane_format] order_num: 1, pixel_format: p010le, plane: 0 [opencl_get_plane_format] order_num: 23, pixel_format: p010le, plane: 1 [AVHWDeviceContext @ _] Format p010le supported. [opencl_get_plane_format] order_num: 1, pixel_format: p016le, plane: 0 [opencl_get_plane_format] order_num: 23, pixel_format: p016le, plane: 1 [AVHWDeviceContext @ _] Format p016le supported. ``` Feel free to compare the two with your favorite diff tool. You'll notice that the various RGB formats (RGBA, ARGB, BGRA...) are now having the correct channel order assigned and that the channel order for the other formats is unchanged. libavutil/hwcontext_opencl.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/libavutil/hwcontext_opencl.c b/libavutil/hwcontext_opencl.c index b116c5b708..b6c389b95d 100644 --- a/libavutil/hwcontext_opencl.c +++ b/libavutil/hwcontext_opencl.c @@ -1376,6 +1376,7 @@ static int opencl_get_plane_format(enum AVPixelFormat pixfmt, int channels = 0, order = 0, depth = 0, step = 0; int wsub, hsub, alpha; int c; + int add_to_ord; if (plane >= AV_NUM_DATA_POINTERS) return AVERROR(ENOENT); @@ -1419,7 +1420,23 @@ 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; + + if (desc->flags & AV_PIX_FMT_FLAG_RGB) { + // If the format is RGB we determine the order number using the + // component's offset values + + // Here we handle 8 vs 16 bit components + if (comp->depth <= 8) { + add_to_ord = comp->offset; + } else { + add_to_ord = comp->offset / 2; + } + } else { + // Otherwise we maintain the previous behavior that used the loop + // index + add_to_ord = c; + } + order = order * 10 + add_to_ord + 1; depth = comp->depth; step = comp->step; alpha = (desc->flags & AV_PIX_FMT_FLAG_ALPHA &&