From patchwork Wed Dec 23 12:10:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Fricke X-Patchwork-Id: 10697 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 9130BC0F1A for ; Wed, 23 Dec 2020 12:11:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1879B615AC; Wed, 23 Dec 2020 13:11:11 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="d4yI+mo9"; dkim-atps=neutral Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 09F1360527 for ; Wed, 23 Dec 2020 13:11:10 +0100 (CET) Received: by mail-wr1-x42d.google.com with SMTP id 91so18429529wrj.7 for ; Wed, 23 Dec 2020 04:11:09 -0800 (PST) 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=erUm07r1r3kYPNrHMcRuSKsM2/7Z+DUp2hWPkZgynR0=; b=d4yI+mo98iqkuX9DTyUojkG3ZEy3MFaABGCg+jRmW8rO+LB7VHf24RRq1zWdw1ouzH Y0teqoOfmg70fTPQ6F1ouFD81ciPG2JTHAKauq+6ojktgMyGq5wDxHxoVhIT5y4x56o0 LgVtn1UkMZHQducPqwm5q2Mr+Fw1SynmWBK+NgU937OMlUGpADWFqX5vqjPjfMxtTAgr fmDkb27QECFtQBcsNUS6DBKERftuUJiql58Yfi37tUHMX85nZqhWQOlRESkay2ELXxMh rHsPSlDEtFJ35siJWY/J4rh1qaO5zzITMx6g2mOYaL6u7Teh+I8x0xc/BbrxBk9TlIVV mfqQ== 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=erUm07r1r3kYPNrHMcRuSKsM2/7Z+DUp2hWPkZgynR0=; b=S/3cCVSTS1iCaOC6X1+eoVkotoT8DRpzxtlz7jubqjOINsX9/maAlmi4BtKRrLoYTJ aUKsRVxxGFqROvZsaETQ8FZcpzus/nwy/akU7RIA0iFoK2wDw+iIiqRcvS1rYYkIFbVH NH5ssGhyEApy9pvvIq0sUFTfcgBUwMaoCVUo+JqO8AwZUMIU6Uq4FSBPItp/Nf/9AG4h vYcjKZZkE818x8l1+Z4l3iCfjz5i6hj3JMsJ7548EP1qQT5WME2TSyhiW26sI5KIAqoL vXErMbdgWSoF/vg3zuOi+qqtHOtgiF6BHLggfRvoiHipqXfXJNXjn5IOGfZ94x4iKpiG LAog== X-Gm-Message-State: AOAM5312oatq/kJlKQjh3Fh1aStqLAQ1vJ7liu+Z6H63hYd6Wp3zCGGT 43SEm0TtqA15ELKcAGj8Jkdv7bAthDhsaA== X-Google-Smtp-Source: ABdhPJyg0dtQUXGDEKwAxOhSQtWkIQf/yf6Wo9FVIDh4G0RS0O3v8dxoiMeCDvK8X1uWIqEkeY8Cog== X-Received: by 2002:adf:f18a:: with SMTP id h10mr30641233wro.244.1608725469726; Wed, 23 Dec 2020 04:11:09 -0800 (PST) Received: from basti.fritz.box (p200300d1ff2be200e1a8f8b471c12212.dip0.t-ipconnect.de. [2003:d1:ff2b:e200:e1a8:f8b4:71c1:2212]) by smtp.gmail.com with ESMTPSA id u6sm36787733wrm.90.2020.12.23.04.11.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Dec 2020 04:11:09 -0800 (PST) From: Sebastian Fricke To: libcamera-devel@lists.libcamera.org Date: Wed, 23 Dec 2020 13:10:53 +0100 Message-Id: <20201223121055.14178-1-sebastian.fricke.linux@gmail.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 0/2] Improve BayerFormat class X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" This patch series adds unit-tests and the `fromV4L2PixelFormat` method to the BayerFormat class. I also wanted to discuss one alternative that I played around with. We could maybe drop one of the two mapping tables and use the following logic to get the map key from a mapped value. ``` #include ... BayerFormat BayerFormat::fromV4L2PixelFormat(V4L2PixelFormat v4l2Format) const { auto it = std::find_if( bayerToV4l2.begin(), bayerToV4l2.end(), [v4l2Format](const auto& i) { return i->second == v4l2Format; } ); if (it != bayerToV4l2.end()) return it->first; return BayerFormat(); } ``` Sebastian Fricke (2): libcamera: Add the fromV4L2PixelFormat method test: Add unit tests for the BayerFormat class include/libcamera/internal/bayer_format.h | 1 + src/libcamera/bayer_format.cpp | 14 ++ test/bayer_format.cpp | 154 ++++++++++++++++++++++ test/meson.build | 1 + 4 files changed, 170 insertions(+) create mode 100644 test/bayer_format.cpp