{"id":18265,"url":"https://patchwork.libcamera.org/api/1.1/patches/18265/?format=json","web_url":"https://patchwork.libcamera.org/patch/18265/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20230208033319.1361109-5-chenghaoyang@google.com>","date":"2023-02-08T03:33:18","name":"[libcamera-devel,v10,4/5] android: jpeg: Pass StreamBuffer to Encoder::encoder","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"37b9887eca9ec44c3d94914ed493fcc87e9677e9","submitter":{"id":117,"url":"https://patchwork.libcamera.org/api/1.1/people/117/?format=json","name":"Cheng-Hao Yang","email":"chenghaoyang@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/18265/mbox/","series":[{"id":3743,"url":"https://patchwork.libcamera.org/api/1.1/series/3743/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3743","date":"2023-02-08T03:33:14","name":"Add CrOS JEA implementation","version":10,"mbox":"https://patchwork.libcamera.org/series/3743/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/18265/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/18265/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id DD389C329C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  8 Feb 2023 03:33:33 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E636C62600;\n\tWed,  8 Feb 2023 04:33:32 +0100 (CET)","from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com\n\t[IPv6:2607:f8b0:4864:20::102c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6DF98625FD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  8 Feb 2023 04:33:30 +0100 (CET)","by mail-pj1-x102c.google.com with SMTP id\n\tgj9-20020a17090b108900b0023114156d36so498795pjb.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 07 Feb 2023 19:33:30 -0800 (PST)","from chenghaoyang-low.c.googlers.com.com\n\t(46.165.189.35.bc.googleusercontent.com. [35.189.165.46])\n\tby smtp.gmail.com with ESMTPSA id\n\te9-20020a170902784900b00194c82c2a7bsm9621963pln.224.2023.02.07.19.33.28\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 07 Feb 2023 19:33:29 -0800 (PST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1675827212;\n\tbh=+1QMbgog0McBeYlDQqZ1rFZC+2X8Dp1lA5jIT8JOnmU=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=1h7Stj6htVAcGhpiR6QfPOzHdMk9kp6+f7BbCzNwqUsMjxqWTTXdH+gYVykZ79GDh\n\t0oW5hsBA7d4v0/pzepZwQr4iLmhasf/t6/ciq0pg79P/LB9D0i2l7q0vQPLDWYBOjS\n\telEjGxRzeV0uqiRWnHjxB4GPgQc4ckyT3M2+Iap4w2H/VFTj+gETMDTEvByeUW/60v\n\tNtxIiuuz0OmZUvq/fPZtGtG/f39riWzUDjBSiTWo0AzOGYIwL+bvk0TNP3v6UTLFpe\n\tt8eGx5BZyquA9v2kAaAI5IjX8lxgmGTCGxF9aEM+NU/MDBWvn3FLEouKxDrp71Ct0L\n\tN8sbnokYoZHyg==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=wOi0iKwB5gRf/Y6naVY3wB0RYT3HDL7p4zqQoBj0Kbw=;\n\tb=RLx6EUhckO5zHJHVBeUf+RjojhX1QjRtBA1VM3sScYr+YFE/lPNhcZMRjt/v6OzskZ\n\t9NToK+7pSCnv3IweoaX+OBonRdSsRRlZreSkzqqgm9iUIdf3CUanbl7c456QFyCIHZwU\n\txyKzLlE3b1tSk+PFV2FoRV7I9KDZ9HK9NDeR4="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=chromium.org\n\theader.i=@chromium.org header.b=\"RLx6EUhc\"; \n\tdkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=wOi0iKwB5gRf/Y6naVY3wB0RYT3HDL7p4zqQoBj0Kbw=;\n\tb=At0UWk6h9Wu/mdL29Z9YlhsjeeZgULsBvllmOtVhcyF0ozrpzFHcH1yk+qlv15R3+b\n\t6q4MHvYOubVFyCL5SEr+cgX8qn5S7cc6AVtnvsvtFOQxsVuQU2YbWK+4PIaqjjuw4AOm\n\tqQmDQHjSuqNvVN9YLSL6PwgEjpc+Kw9tOlOWo3DWkFME8BzcoU1mQ+C/cRQl1LaKoIkz\n\t0CZ2F8GYW2DNK04oiHxjlADxAZ8fyelYAbOIj1mUtkPdDY7hg8EBKFE7c8+Vvq5+hgA0\n\t4uuor0eHZHfowCOgprevvKaIHL7s7QAaUE6/eVAszBsae3Ks24ON6wnd+KEmottTLycx\n\tYmTw==","X-Gm-Message-State":"AO0yUKUwFx3ao81zL6TrXPG0W9Pha/RK2KzH+8ZqulVfFuV0QrRH63cF\n\tX9i+1QyY6C8KSPeIKyEOxp4Mfc4l0IxUKSoT","X-Google-Smtp-Source":"AK7set/sdQjao30nyrWtEj6yPogVXvcMiJMOhmAxNt4WAFfUrrewzipv+siSyw3Vb7vOyYSlPvL+9g==","X-Received":"by 2002:a17:902:7c11:b0:196:6296:60e8 with SMTP id\n\tx17-20020a1709027c1100b00196629660e8mr4967342pll.45.1675827209776; \n\tTue, 07 Feb 2023 19:33:29 -0800 (PST)","X-Google-Original-From":"Harvey Yang <chenghaoyang@google.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed,  8 Feb 2023 03:33:18 +0000","Message-Id":"<20230208033319.1361109-5-chenghaoyang@google.com>","X-Mailer":"git-send-email 2.39.1.519.gcb327c4b5f-goog","In-Reply-To":"<20230208033319.1361109-1-chenghaoyang@google.com>","References":"<20230208033319.1361109-1-chenghaoyang@google.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v10 4/5] android: jpeg: Pass StreamBuffer\n\tto Encoder::encoder","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>","From":"Harvey Yang via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Harvey Yang <chenghaoyang@chromium.org>","Cc":"Harvey Yang <chenghaoyang@chromium.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"From: Harvey Yang <chenghaoyang@chromium.org>\n\nTo prepare for support of the JEA encoder in a following commit, which\nwill need to access the buffer_handle_t of the destination buffer, pass\nthe StreamBuffer to the Encoder::encoder() function. As the StreamBuffer\ncontains the source FrameBuffer and the destination Span, drop them from\nthe function arguments and access them directly from the StreamBuffer.\n\nSigned-off-by: Harvey Yang <chenghaoyang@chromium.org>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Han-Lin Chen <hanlinchen@chromium.org>\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/android/jpeg/encoder.h               |  5 +++--\n src/android/jpeg/encoder_libjpeg.cpp     | 13 +++++++++----\n src/android/jpeg/encoder_libjpeg.h       |  3 +--\n src/android/jpeg/post_processor_jpeg.cpp |  3 +--\n 4 files changed, 14 insertions(+), 10 deletions(-)","diff":"diff --git a/src/android/jpeg/encoder.h b/src/android/jpeg/encoder.h\nindex b974d367..31f26895 100644\n--- a/src/android/jpeg/encoder.h\n+++ b/src/android/jpeg/encoder.h\n@@ -12,14 +12,15 @@\n #include <libcamera/framebuffer.h>\n #include <libcamera/stream.h>\n \n+#include \"../camera_request.h\"\n+\n class Encoder\n {\n public:\n \tvirtual ~Encoder() = default;\n \n \tvirtual int configure(const libcamera::StreamConfiguration &cfg) = 0;\n-\tvirtual int encode(const libcamera::FrameBuffer &source,\n-\t\t\t   libcamera::Span<uint8_t> destination,\n+\tvirtual int encode(Camera3RequestDescriptor::StreamBuffer *buffer,\n \t\t\t   libcamera::Span<const uint8_t> exifData,\n \t\t\t   unsigned int quality) = 0;\n };\ndiff --git a/src/android/jpeg/encoder_libjpeg.cpp b/src/android/jpeg/encoder_libjpeg.cpp\nindex fd62bd9c..f4e8dfad 100644\n--- a/src/android/jpeg/encoder_libjpeg.cpp\n+++ b/src/android/jpeg/encoder_libjpeg.cpp\n@@ -24,6 +24,8 @@\n #include \"libcamera/internal/formats.h\"\n #include \"libcamera/internal/mapped_framebuffer.h\"\n \n+#include \"../camera_buffer.h\"\n+\n using namespace libcamera;\n \n LOG_DECLARE_CATEGORY(JPEG)\n@@ -178,17 +180,20 @@ void EncoderLibJpeg::compressNV(const std::vector<Span<uint8_t>> &planes)\n \t}\n }\n \n-int EncoderLibJpeg::encode(const FrameBuffer &source, Span<uint8_t> dest,\n-\t\t\t   Span<const uint8_t> exifData, unsigned int quality)\n+int EncoderLibJpeg::encode(Camera3RequestDescriptor::StreamBuffer *buffer,\n+\t\t\t   libcamera::Span<const uint8_t> exifData,\n+\t\t\t   unsigned int quality)\n {\n-\tMappedFrameBuffer frame(&source, MappedFrameBuffer::MapFlag::Read);\n+\tMappedFrameBuffer frame(buffer->srcBuffer,\n+\t\t\t\tMappedFrameBuffer::MapFlag::Read);\n \tif (!frame.isValid()) {\n \t\tLOG(JPEG, Error) << \"Failed to map FrameBuffer : \"\n \t\t\t\t << strerror(frame.error());\n \t\treturn frame.error();\n \t}\n \n-\treturn encode(frame.planes(), dest, exifData, quality);\n+\treturn encode(frame.planes(), buffer->dstBuffer->plane(0),\n+\t\t      exifData, quality);\n }\n \n int EncoderLibJpeg::encode(const std::vector<Span<uint8_t>> &src,\ndiff --git a/src/android/jpeg/encoder_libjpeg.h b/src/android/jpeg/encoder_libjpeg.h\nindex 1b3ac067..146a6a72 100644\n--- a/src/android/jpeg/encoder_libjpeg.h\n+++ b/src/android/jpeg/encoder_libjpeg.h\n@@ -22,8 +22,7 @@ public:\n \t~EncoderLibJpeg();\n \n \tint configure(const libcamera::StreamConfiguration &cfg) override;\n-\tint encode(const libcamera::FrameBuffer &source,\n-\t\t   libcamera::Span<uint8_t> destination,\n+\tint encode(Camera3RequestDescriptor::StreamBuffer *buffer,\n \t\t   libcamera::Span<const uint8_t> exifData,\n \t\t   unsigned int quality) override;\n \tint encode(const std::vector<libcamera::Span<uint8_t>> &planes,\ndiff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp\nindex 0cf56716..3e676eb4 100644\n--- a/src/android/jpeg/post_processor_jpeg.cpp\n+++ b/src/android/jpeg/post_processor_jpeg.cpp\n@@ -194,8 +194,7 @@ void PostProcessorJpeg::process(Camera3RequestDescriptor::StreamBuffer *streamBu\n \tconst uint8_t quality = ret ? *entry.data.u8 : 95;\n \tresultMetadata->addEntry(ANDROID_JPEG_QUALITY, quality);\n \n-\tint jpeg_size = encoder_->encode(source, destination->plane(0),\n-\t\t\t\t\t exif.data(), quality);\n+\tint jpeg_size = encoder_->encode(streamBuffer, exif.data(), quality);\n \tif (jpeg_size < 0) {\n \t\tLOG(JPEG, Error) << \"Failed to encode stream image\";\n \t\tprocessComplete.emit(streamBuffer, PostProcessor::Status::Error);\n","prefixes":["libcamera-devel","v10","4/5"]}