From patchwork Tue Aug 31 06:34:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 13572 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 8FEE2BD87D for ; Tue, 31 Aug 2021 06:35:08 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4EBFB69170; Tue, 31 Aug 2021 08:35:08 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="kj1DizGk"; dkim-atps=neutral Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0A3D669166 for ; Tue, 31 Aug 2021 08:35:06 +0200 (CEST) Received: by mail-pj1-x102f.google.com with SMTP id j1so11097478pjv.3 for ; Mon, 30 Aug 2021 23:35:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3k3ExmsDADITCkoKoVxB6HQlr2nUSFrjo/RKrh85abo=; b=kj1DizGkPBg20cfkuiEPrdADt3O9UFlhkNvUJgLo57vpUVH1rI9GwB74WVuFrRMK6Z c4FR5v10ixF8arZomrfFedUdmEa/Wj9spcx9EpjRQwLquO/DROIWqlSHTWp5yyiSSvIz X7O6Zdg62O6t8OVU4+sy92u+7b5vhN4Lr+xcQ= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=3k3ExmsDADITCkoKoVxB6HQlr2nUSFrjo/RKrh85abo=; b=Nq1yA6KJUbKZ1w0ewO+yC03tUtF3IxVKsvhvXZdK3oBCu0iV2qxVE4hhYZAhzf5b4H N1eZPCz/9gncCujzcUjv3dOu1lSapkA91UFRwR+AtkeR6FIr5z4qIxTk1XWyv8mATaeI Y8P/45FXLczXiQSSkPdSKm/ve7ISw+A1Pv+AsBSrAKZitnBaBACNt90Wmzz1WkH9IbGH NHp7Z0Mg00Yp1OouS2aheM5uHG/8zEAAWSJy4H9JSJJiiG0Li3v2MM7FXiQulFSl9mj3 WBNN24lBt1UL4ihCCamPtHCAMtRNIlvAOQnYUaIOzKTZFFPrCv8KhOeQvl3Dyg0pGuWg RjQQ== X-Gm-Message-State: AOAM5326cu72oGX3bsCoJIKhcpP6BiFQnGy9GrcjWcvNxpO3pnoKVdFM dlO66STTzs5CRl2SdqIfLehsEqHbez7o2w== X-Google-Smtp-Source: ABdhPJzjO/H70wQsQYk1FhSiX/M/CsCA9g89+UhTj1yE3GLrKr8SziIzjlrtarJl0ftt+2nHulwDIg== X-Received: by 2002:a17:90a:44:: with SMTP id 4mr3463079pjb.130.1630391704276; Mon, 30 Aug 2021 23:35:04 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:3c62:aba4:18ea:5441]) by smtp.gmail.com with ESMTPSA id d17sm16304027pfn.110.2021.08.30.23.35.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Aug 2021 23:35:03 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Tue, 31 Aug 2021 15:34:34 +0900 Message-Id: <20210831063438.785767-2-hiroh@chromium.org> X-Mailer: git-send-email 2.33.0.259.gc128427fd7-goog In-Reply-To: <20210831063438.785767-1-hiroh@chromium.org> References: <20210831063438.785767-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/5] android: yuv: Use CameraBuffer::stride() in PostProcessorYuv 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" PostProcessorYuv computes strides for a CameraBuffer. CameraBuffer has stride() function. This replaces the computation with the function. Signed-off-by: Hirokazu Honda Reviewed-by: Laurent Pinchart --- src/android/yuv/post_processor_yuv.cpp | 13 +++++++------ src/android/yuv/post_processor_yuv.h | 1 - 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/android/yuv/post_processor_yuv.cpp b/src/android/yuv/post_processor_yuv.cpp index 6952fc38..12d6297d 100644 --- a/src/android/yuv/post_processor_yuv.cpp +++ b/src/android/yuv/post_processor_yuv.cpp @@ -69,9 +69,9 @@ int PostProcessorYuv::process(const FrameBuffer &source, sourceStride_[1], sourceSize_.width, sourceSize_.height, destination->plane(0).data(), - destinationStride_[0], + destination->stride(0), destination->plane(1).data(), - destinationStride_[1], + destination->stride(1), destinationSize_.width, destinationSize_.height, libyuv::FilterMode::kFilterBilinear); @@ -115,8 +115,8 @@ bool PostProcessorYuv::isValidBuffers(const FrameBuffer &source, << destination.plane(0).size() << ", " << destination.plane(1).size() << "}, expected size: {" - << sourceLength_[0] << ", " - << sourceLength_[1] << "}"; + << destinationLength_[0] << ", " + << destinationLength_[1] << "}"; return false; } @@ -132,13 +132,14 @@ void PostProcessorYuv::calculateLengths(const StreamConfiguration &inCfg, const PixelFormatInfo &nv12Info = PixelFormatInfo::info(formats::NV12); for (unsigned int i = 0; i < 2; i++) { sourceStride_[i] = inCfg.stride; - destinationStride_[i] = nv12Info.stride(destinationSize_.width, i, 1); + const unsigned int destinationStride = + nv12Info.stride(destinationSize_.width, i, 1); const unsigned int vertSubSample = nv12Info.planes[i].verticalSubSampling; sourceLength_[i] = sourceStride_[i] * ((sourceSize_.height + vertSubSample - 1) / vertSubSample); - destinationLength_[i] = destinationStride_[i] * + destinationLength_[i] = destinationStride * ((destinationSize_.height + vertSubSample - 1) / vertSubSample); } } diff --git a/src/android/yuv/post_processor_yuv.h b/src/android/yuv/post_processor_yuv.h index f8b1ba23..1a0b5e89 100644 --- a/src/android/yuv/post_processor_yuv.h +++ b/src/android/yuv/post_processor_yuv.h @@ -36,7 +36,6 @@ private: unsigned int sourceLength_[2] = {}; unsigned int destinationLength_[2] = {}; unsigned int sourceStride_[2] = {}; - unsigned int destinationStride_[2] = {}; }; #endif /* __ANDROID_POST_PROCESSOR_YUV_H__ */ From patchwork Tue Aug 31 06:34:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 13573 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 41114BD87D for ; Tue, 31 Aug 2021 06:35:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0426669176; Tue, 31 Aug 2021 08:35:10 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="bq1qarvb"; dkim-atps=neutral Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9EAB960137 for ; Tue, 31 Aug 2021 08:35:07 +0200 (CEST) Received: by mail-pj1-x102b.google.com with SMTP id d3-20020a17090ae28300b0019629c96f25so1646074pjz.2 for ; Mon, 30 Aug 2021 23:35:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Oi7VNQOpVLdn4SHrGSxhRVEEm/yhbmfU+hI02STYM+s=; b=bq1qarvbyTuSIm5KQ4B3mI5wMMgXVcaY+e0G2rt1IMBz+SgQQDqEH40//Vk2aV1nrC hkWIb7F2rYa2+9k8fO8cviG+aPkrs5q/wygYNHt5AUyAS62GCe0JI6f+Kf5Oip08WScg ZJQegB5dSjolGPcdWL9kp+OMPny8wiLoi2KRE= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=Oi7VNQOpVLdn4SHrGSxhRVEEm/yhbmfU+hI02STYM+s=; b=ocTNAn3RQQJS4h0rNVA/h8emt9KTgKRf1BpPC/+Tc2JDDFawOOpE2hoU6Hd3M3sF3O cy5zOqwgvHrA348tYfUR8ExrLOfBJ541GhaM2y2OCphH6lUdjvIJWq3qA/mT05PAVRIV dCfI2/T8tCrSX4ZrIvjBURL9SG1/lgEEuPDa7Buyy0EmiqwcdV4imffnH9bz54mG2yEg MR1KK8Q3oV8xFQtTiHItYIUZpPqWrxOHGtIdX75Tnqc/doGLbnkjdx6lXyZpawqykEXc 6E7KsPzEpGSsu6RQn57vBITabqMYn5UlE+lgGuvcDJyoal2Xt9Peh4erL8/S+JCEgTNy 6BDg== X-Gm-Message-State: AOAM530J9yNYa9BDNF+YABb4FrMuHfsOEFXuB2iRnACWZbFKX940XgHy eWxGgow6QGKe97bgPX1UtDpgrUuSTHIMtQ== X-Google-Smtp-Source: ABdhPJwOTWPktF57eEcScbSlqhn7hoUXmUg/16HbJAgKE0BKP1f1EqCy4gHyLBPo1+ygPrP+W7B55g== X-Received: by 2002:a17:902:724b:b0:131:ab33:1e4e with SMTP id c11-20020a170902724b00b00131ab331e4emr3251131pll.12.1630391705860; Mon, 30 Aug 2021 23:35:05 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:3c62:aba4:18ea:5441]) by smtp.gmail.com with ESMTPSA id d17sm16304027pfn.110.2021.08.30.23.35.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Aug 2021 23:35:05 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Tue, 31 Aug 2021 15:34:35 +0900 Message-Id: <20210831063438.785767-3-hiroh@chromium.org> X-Mailer: git-send-email 2.33.0.259.gc128427fd7-goog In-Reply-To: <20210831063438.785767-1-hiroh@chromium.org> References: <20210831063438.785767-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/5] android: jpeg: thumbnailer: Use MappedFrameBuffer::planes() 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" Thumbnailer gets the address of NV12 UV Plane by computing the first plane size. MappedFrameBuffer::planes() returns the plane address. This replaces the address computation with MappedFrameBuffer::planes() in Thumbnailer. Signed-off-by: Hirokazu Honda Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/android/jpeg/thumbnailer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/android/jpeg/thumbnailer.cpp b/src/android/jpeg/thumbnailer.cpp index 043c7b33..fe2c4969 100644 --- a/src/android/jpeg/thumbnailer.cpp +++ b/src/android/jpeg/thumbnailer.cpp @@ -63,7 +63,7 @@ void Thumbnailer::createThumbnail(const FrameBuffer &source, /* Image scaling block implementing nearest-neighbour algorithm. */ unsigned char *src = static_cast(frame.planes()[0].data()); - unsigned char *srcC = src + sh * sw; + unsigned char *srcC = static_cast(frame.planes()[1].data()); unsigned char *srcCb, *srcCr; unsigned char *dstY, *srcY; From patchwork Tue Aug 31 06:34:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 13575 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 C2A4BC3242 for ; Tue, 31 Aug 2021 06:35:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6ECE86916A; Tue, 31 Aug 2021 08:35:15 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="W+NKqbEv"; dkim-atps=neutral Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8EDD26916D for ; Tue, 31 Aug 2021 08:35:12 +0200 (CEST) Received: by mail-pl1-x62d.google.com with SMTP id u1so6210383plq.5 for ; Mon, 30 Aug 2021 23:35:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qBdnyVWP1J27KA/6C2MYOFwAsmP2Kaj2I8YDdtscb3c=; b=W+NKqbEvZ+I6M8anax7188qTo4pQNE6VBlbx0mJ1BNgqJ/rvrNI5S1jmaW0o3BB/6x NRNHAC4PwUFJ1AEQRNhj7RMjwu8DscQum04zYml1DE+PkVj3ucIG7EyVJlalgmRq42gV nArF0W6adiCKZu3QyAo4sdzaM+CM6Oo+53wh4= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=qBdnyVWP1J27KA/6C2MYOFwAsmP2Kaj2I8YDdtscb3c=; b=bjJh+eXiUAyXbOHkL/IaiYWCo/djpo59kaYv8t7fzSNqTGnpXbT1QaJlv+0b1H3M4Y ZzF8Ocxc7mWKpfIvTBMSoT5AkGBhKKdPfjMheHiP15bVeQg0knuAtGNvELWuJyrMreYv TVsJXgqyBX0jodJ4K0Im+ARtMl8s6ZYLmSn4HuTjvbApqP3DRe7jmeR3jJNsGPJDKtAT btWWaoqAJwqe0fJ9vGgMFvLNG1sOEQqbNBEh2b7tJcrKtX/4g+VzoEmnnaRvf/jJadO9 tYJ1C29vQoMkLPYFwnGBkFkmdyzpsX1UpyznJrnGyOb2WA2C/n4lT4jBC1EmByFfPJLz mxyQ== X-Gm-Message-State: AOAM530cl5NaShkhxXFV2VHv37vkkgNZVlYx2xNg5O8VpzPiLEkJDhfK /1Q6WziRu61PqhcJXHWEnzZlVfzhPfjedg== X-Google-Smtp-Source: ABdhPJz2Etq/VdCItvytwySZeYNU9DdNLQt38aSyU8uN7vAr1okT3k8u9isj29JKGUnQ+i/wSEGJnA== X-Received: by 2002:a17:90b:4c8b:: with SMTP id my11mr3416812pjb.220.1630391710752; Mon, 30 Aug 2021 23:35:10 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:3c62:aba4:18ea:5441]) by smtp.gmail.com with ESMTPSA id d17sm16304027pfn.110.2021.08.30.23.35.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Aug 2021 23:35:10 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Tue, 31 Aug 2021 15:34:38 +0900 Message-Id: <20210831063438.785767-6-hiroh@chromium.org> X-Mailer: git-send-email 2.33.0.259.gc128427fd7-goog In-Reply-To: <20210831063438.785767-1-hiroh@chromium.org> References: <20210831063438.785767-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 5/5] android: encoder_libjpeg: Use MappedBuffer for the source frame 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" EncoderLibJpeg handles the source frame with Span. Since it is plane, MappedBuffer should be more appropriate interface for it. So this changes its type to MappedBuffer. Signed-off-by: Hirokazu Honda --- src/android/jpeg/encoder_libjpeg.cpp | 28 ++++++++++++++---------- src/android/jpeg/encoder_libjpeg.h | 7 +++--- src/android/jpeg/post_processor_jpeg.cpp | 6 ++--- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/android/jpeg/encoder_libjpeg.cpp b/src/android/jpeg/encoder_libjpeg.cpp index b8b01e20..d165fd6a 100644 --- a/src/android/jpeg/encoder_libjpeg.cpp +++ b/src/android/jpeg/encoder_libjpeg.cpp @@ -103,9 +103,10 @@ int EncoderLibJpeg::configure(const StreamConfiguration &cfg) return 0; } -void EncoderLibJpeg::compressRGB(Span frame) +void EncoderLibJpeg::compressRGB(const MappedBuffer &frame) { - unsigned char *src = const_cast(frame.data()); + ASSERT(frame.planes().size() == 1); + unsigned char *src = const_cast(frame.planes()[0].data()); /* \todo Stride information should come from buffer configuration. */ unsigned int stride = pixelFormatInfo_->stride(compress_.image_width, 0); @@ -121,7 +122,7 @@ void EncoderLibJpeg::compressRGB(Span frame) * Compress the incoming buffer from a supported NV format. * This naively unpacks the semi-planar NV12 to a YUV888 format for libjpeg. */ -void EncoderLibJpeg::compressNV(Span frame) +void EncoderLibJpeg::compressNV(const MappedBuffer &frame) { uint8_t tmprowbuf[compress_.image_width * 3]; @@ -143,8 +144,9 @@ void EncoderLibJpeg::compressNV(Span frame) unsigned int cb_pos = nvSwap_ ? 1 : 0; unsigned int cr_pos = nvSwap_ ? 0 : 1; - const unsigned char *src = frame.data(); - const unsigned char *src_c = src + y_stride * compress_.image_height; + ASSERT(frame.planes().size() == 2); + const unsigned char *src = frame.planes()[0].data(); + const unsigned char *src_c = frame.planes()[1].data(); JSAMPROW row_pointer[1]; row_pointer[0] = &tmprowbuf[0]; @@ -152,7 +154,7 @@ void EncoderLibJpeg::compressNV(Span frame) for (unsigned int y = 0; y < compress_.image_height; y++) { unsigned char *dst = &tmprowbuf[0]; - const unsigned char *src_y = src + y * compress_.image_width; + const unsigned char *src_y = src + y * y_stride; const unsigned char *src_cb = src_c + (y / vertSubSample) * c_stride + cb_pos; const unsigned char *src_cr = src_c + (y / vertSubSample) * c_stride + cr_pos; @@ -178,8 +180,10 @@ void EncoderLibJpeg::compressNV(Span frame) } } -int EncoderLibJpeg::encode(const FrameBuffer &source, Span dest, - Span exifData, unsigned int quality) +int EncoderLibJpeg::encode(const libcamera::FrameBuffer &source, + libcamera::Span destination, + libcamera::Span exifData, + unsigned int quality) { MappedFrameBuffer frame(&source, MappedFrameBuffer::MapFlag::Read); if (!frame.isValid()) { @@ -188,10 +192,10 @@ int EncoderLibJpeg::encode(const FrameBuffer &source, Span dest, return frame.error(); } - return encode(frame.planes()[0], dest, exifData, quality); + return encode(frame, destination, exifData, quality); } -int EncoderLibJpeg::encode(Span src, Span dest, +int EncoderLibJpeg::encode(const MappedBuffer &source, Span dest, Span exifData, unsigned int quality) { unsigned char *destination = dest.data(); @@ -221,9 +225,9 @@ int EncoderLibJpeg::encode(Span src, Span dest, << "x" << compress_.image_height; if (nv_) - compressNV(src); + compressNV(source); else - compressRGB(src); + compressRGB(source); jpeg_finish_compress(&compress_); diff --git a/src/android/jpeg/encoder_libjpeg.h b/src/android/jpeg/encoder_libjpeg.h index 61fbd1a6..13a47b72 100644 --- a/src/android/jpeg/encoder_libjpeg.h +++ b/src/android/jpeg/encoder_libjpeg.h @@ -10,6 +10,7 @@ #include "encoder.h" #include "libcamera/internal/formats.h" +#include "libcamera/internal/mapped_framebuffer.h" #include @@ -24,14 +25,14 @@ public: libcamera::Span destination, libcamera::Span exifData, unsigned int quality) override; - int encode(libcamera::Span source, + int encode(const libcamera::MappedBuffer &source, libcamera::Span destination, libcamera::Span exifData, unsigned int quality); private: - void compressRGB(libcamera::Span frame); - void compressNV(libcamera::Span frame); + void compressRGB(const libcamera::MappedBuffer &frame); + void compressNV(const libcamera::MappedBuffer &frame); struct jpeg_compress_struct compress_; struct jpeg_error_mgr jerr_; diff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp index 6eefce0f..a4e56b88 100644 --- a/src/android/jpeg/post_processor_jpeg.cpp +++ b/src/android/jpeg/post_processor_jpeg.cpp @@ -75,8 +75,7 @@ void PostProcessorJpeg::generateThumbnail(const FrameBuffer &source, bufferSize += plane.size(); thumbnail->resize(bufferSize); - libcamera::Span rawThumbnailData(rawThumbnail->planes()[0].data(), bufferSize); - int jpeg_size = thumbnailEncoder_.encode(rawThumbnailData, + int jpeg_size = thumbnailEncoder_.encode(*rawThumbnail, *thumbnail, {}, quality); thumbnail->resize(jpeg_size); @@ -181,7 +180,8 @@ int PostProcessorJpeg::process(const FrameBuffer &source, const uint8_t quality = ret ? *entry.data.u8 : 95; resultMetadata->addEntry(ANDROID_JPEG_QUALITY, quality); - int jpeg_size = encoder_->encode(source, destination->plane(0), + int jpeg_size = encoder_->encode(source, + destination->plane(0), exif.data(), quality); if (jpeg_size < 0) { LOG(JPEG, Error) << "Failed to encode stream image";