{"id":4073,"url":"https://patchwork.libcamera.org/api/patches/4073/?format=json","web_url":"https://patchwork.libcamera.org/patch/4073/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200617164442.2643-1-david.plowman@raspberrypi.com>","date":"2020-06-17T16:44:42","name":"[libcamera-devel] libcamera: add support for planar YUV422 and YUV420 formats","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"a5bafc0e93f5fdb650674172f0d212d6f1dc5780","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/?format=json","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/4073/mbox/","series":[{"id":1012,"url":"https://patchwork.libcamera.org/api/series/1012/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1012","date":"2020-06-17T16:44:42","name":"[libcamera-devel] libcamera: add support for planar YUV422 and YUV420 formats","version":1,"mbox":"https://patchwork.libcamera.org/series/1012/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/4073/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/4073/checks/","tags":{},"headers":{"Return-Path":"<david.plowman@raspberrypi.com>","Received":["from mail-wr1-x431.google.com (mail-wr1-x431.google.com\n\t[IPv6:2a00:1450:4864:20::431])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D81F8603BF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 17 Jun 2020 18:44:47 +0200 (CEST)","by mail-wr1-x431.google.com with SMTP id c3so3033459wru.12\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 17 Jun 2020 09:44:47 -0700 (PDT)","from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72])\n\tby smtp.gmail.com with ESMTPSA id\n\te5sm184300wrw.19.2020.06.17.09.44.46\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 17 Jun 2020 09:44:46 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"WmdUalhU\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=cemhbHAyQVJNGl5fy0sG9uWFtdvlcyoqKp6xMOB8roM=;\n\tb=WmdUalhUPZFw7SPbpre+kH+T3TPoxCardRL111PoPItCqlSpOI2P4Mobe8xM0B2BUO\n\tlGdbjA2USLE86Z+pb7e17cJO+od7imGre41c8OTB9pXv8Y34DhMnlUtNcI8URiHsQCAu\n\tT3NAaIV6yN88DGzDYS7tjVDz7U5DpLlFL6dzfsiY1i0v4iXDb84WppooG7T+BiwFmv/K\n\t4f19dskV07njkG3JCzwb04MKEf3YYP+MC3vIDWokgwlk5R3IaYmfxRAvPT72DCiQgr89\n\tTe8PX0NoOtVUpCoUPe38tNrNv1HdeO87Ogubo4PYEx5CnJlvjvYhT8ooq9jr2RVIW06e\n\tudtA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=cemhbHAyQVJNGl5fy0sG9uWFtdvlcyoqKp6xMOB8roM=;\n\tb=UdZjyblxcH1cskQ8JkEhJL2E6dpVji4vb2Af4rSL236yqlWbekjvSIsIohoJK/vDOh\n\tpLBl+xKoTqRZ0WtieQN5rV7RuAKOw/XON2KtbVfK4KO9nuaaY4RITTLJ5tNan95BFSIp\n\tKDVb+39+lI/IU4jgft+1j0aLVlq7yTpznwIalp/ZO8x8EpXybU5DxeLqTkUENoU/dHUY\n\tM3DlcCFGaJHOLn8wy0BcxEmPa13iZ2PnNjU5tYSngRDKRtFu9tWLb0/EvYB5ZZIVYPg8\n\tsSm2wcJBeZW7GBnyruoA1TKWhn2ZvxyyKdcwA+PYEeeUrVZW+W5CoOO9rZIPVSX7TzVg\n\tzcIQ==","X-Gm-Message-State":"AOAM53390ummriYHHlhEgc4vQ/l7vFHVTguvDtHCrGc9HWYFoiSuWId6\n\tzhpM29ENK5Dxp0zniIPiIvsZyAmupSA=","X-Google-Smtp-Source":"ABdhPJwFZACQ787rA0R+g2e+ZNLv7B/BzjsSv7TH/McoHT9mW5/qUFADh2UJqhtWsWyuOnlat0S5SQ==","X-Received":"by 2002:adf:fa89:: with SMTP id h9mr165499wrr.120.1592412287114; \n\tWed, 17 Jun 2020 09:44:47 -0700 (PDT)","From":"David Plowman <david.plowman@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 17 Jun 2020 17:44:42 +0100","Message-Id":"<20200617164442.2643-1-david.plowman@raspberrypi.com>","X-Mailer":"git-send-email 2.20.1","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH] libcamera: add support for planar YUV422\n\tand YUV420 formats","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Wed, 17 Jun 2020 16:44:48 -0000"},"content":"These formats can be helpful when downstream applications or libraries\nsupport them natively (avoiding a costly conversion).\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\n---\n src/libcamera/formats.cpp          | 14 ++++++++++++++\n src/libcamera/v4l2_pixelformat.cpp |  2 ++\n src/v4l2/v4l2_camera_proxy.cpp     |  2 ++\n 3 files changed, 18 insertions(+)","diff":"diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp\nindex 2ac3b41..dcd1dcf 100644\n--- a/src/libcamera/formats.cpp\n+++ b/src/libcamera/formats.cpp\n@@ -268,6 +268,20 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t\t.colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n \t\t.packed = false,\n \t} },\n+\t{ PixelFormat(DRM_FORMAT_YUV422), {\n+\t\t.format = PixelFormat(DRM_FORMAT_YUV422),\n+\t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_YUV422P),\n+\t\t.bitsPerPixel = 16,\n+\t\t.colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n+\t\t.packed = false,\n+\t} },\n+\t{ PixelFormat(DRM_FORMAT_YUV420), {\n+\t\t.format = PixelFormat(DRM_FORMAT_YUV420),\n+\t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_YUV420),\n+\t\t.bitsPerPixel = 12,\n+\t\t.colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n+\t\t.packed = false,\n+\t} },\n \n \t/* Greyscale formats. */\n \t{ PixelFormat(DRM_FORMAT_R8), {\ndiff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp\nindex 94fae47..01778c0 100644\n--- a/src/libcamera/v4l2_pixelformat.cpp\n+++ b/src/libcamera/v4l2_pixelformat.cpp\n@@ -64,6 +64,8 @@ const std::map<V4L2PixelFormat, PixelFormat> vpf2pf{\n \t{ V4L2PixelFormat(V4L2_PIX_FMT_NV61), PixelFormat(DRM_FORMAT_NV61) },\n \t{ V4L2PixelFormat(V4L2_PIX_FMT_NV12), PixelFormat(DRM_FORMAT_NV12) },\n \t{ V4L2PixelFormat(V4L2_PIX_FMT_NV21), PixelFormat(DRM_FORMAT_NV21) },\n+\t{ V4L2PixelFormat(V4L2_PIX_FMT_YUV422P), PixelFormat(DRM_FORMAT_YUV422) },\n+\t{ V4L2PixelFormat(V4L2_PIX_FMT_YUV420), PixelFormat(DRM_FORMAT_YUV420) },\n \n \t/* Greyscale formats. */\n \t{ V4L2PixelFormat(V4L2_PIX_FMT_GREY), PixelFormat(DRM_FORMAT_R8) },\ndiff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\nindex d7f14e6..a54d47e 100644\n--- a/src/v4l2/v4l2_camera_proxy.cpp\n+++ b/src/v4l2/v4l2_camera_proxy.cpp\n@@ -576,6 +576,8 @@ static const std::array<PixelFormatInfo, 14> pixelFormatInfo = {{\n \t{ PixelFormat(DRM_FORMAT_NV61),\t\tV4L2_PIX_FMT_NV61,\t2, {{ {  8, 1, 1 }, { 16, 2, 1 }, {  0, 0, 0 } }} },\n \t{ PixelFormat(DRM_FORMAT_NV24),\t\tV4L2_PIX_FMT_NV24,\t2, {{ {  8, 1, 1 }, { 16, 1, 1 }, {  0, 0, 0 } }} },\n \t{ PixelFormat(DRM_FORMAT_NV42),\t\tV4L2_PIX_FMT_NV42,\t2, {{ {  8, 1, 1 }, { 16, 1, 1 }, {  0, 0, 0 } }} },\n+\t{ PixelFormat(DRM_FORMAT_YUV422),\tV4L2_PIX_FMT_YUV422P,\t2, {{ {  8, 1, 1 }, { 8, 2, 1 }, {  8, 2, 1 } }} },\n+\t{ PixelFormat(DRM_FORMAT_YUV420),\tV4L2_PIX_FMT_YUV420,\t2, {{ {  8, 1, 1 }, { 8, 2, 2 }, {  8, 2, 2 } }} },\n \t/* Compressed formats. */\n \t/*\n \t * \\todo Get a better image size estimate for MJPEG, via\n","prefixes":["libcamera-devel"]}