From patchwork Mon Aug 24 20:46:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 9377 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 BF529BD87C for ; Mon, 24 Aug 2020 20:46:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BC44462849; Mon, 24 Aug 2020 22:46:57 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=uajain.com header.i=@uajain.com header.b="N5gJSM//"; dkim-atps=neutral Received: from o1.f.az.sendgrid.net (o1.f.az.sendgrid.net [208.117.55.132]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 54E8E62113 for ; Mon, 24 Aug 2020 22:46:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uajain.com; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type; s=s1; bh=8/qcuugyt4BWpSoJ4t9q0NrplB2eQ4owPbxugcT20d8=; b=N5gJSM//BuKaLrKJ+3n8WpuYRlD4cP7G7m3PjRC1+jXeizUfsbmM0Fzma5JqCwEtXhJT RczbrHpdSyySxRznNFXNYRjmO/1RRI9Q01tYGDJvwiTOIdtJVUC0hdq42020/nyLNpPjZO NU8wRnZVozzOEskDvL2S9+hczDB7hRz28= Received: by filterdrecv-p3iad2-canary-d97c86fd5-k8f6p with SMTP id filterdrecv-p3iad2-canary-d97c86fd5-k8f6p-18-5F44273D-4F 2020-08-24 20:46:54.080920535 +0000 UTC m=+18539.274374053 Received: from mail.uajain.com (unknown) by ismtpd0001p1hnd1.sendgrid.net (SG) with ESMTP id 3W2yccn9TLiNS34kIun2Dg for ; Mon, 24 Aug 2020 20:46:53.758 +0000 (UTC) From: Umang Jain Date: Mon, 24 Aug 2020 20:46:54 +0000 (UTC) Message-Id: <20200824204646.16866-3-email@uajain.com> In-Reply-To: <20200824204646.16866-1-email@uajain.com> References: <20200824204646.16866-1-email@uajain.com> Mime-Version: 1.0 X-SG-EID: 1Q40EQ7YGir8a9gjSIAdTjhngY657NMk9ckeo4dbHZDiOpywc/L3L9rFqlwE4KPcROc560Os82e1tQwAlD2FoKZ1gYInNEr2A12ZKoe3r+iLhS1vvkgcNXhQkusThCRA0/CDIz+Nxjf7yVPmFVbgnN6ROcO+aepCj5mVNhi51K3eJTIkQCsNjKnZQ71h1rMjJdj/OZgLJouyTRyrXMEIi6cgBwj4rEgGgbMStbw75m5Q7ioun+LDUZN/48uVUuP8/xdm4bmW3M+PRg14XRQGR/DCC7K0VBY2g6q0E6W5ps4= To: libcamera-devel@lists.libcamera.org Subject: [libcamera-devel] [PATCH 2/3] android: jpeg: Pass a Exif object while encoding 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" Create a Exif object when the jpeg encoder is about to start encoding the stream in CameraDevice::requestComplete(). This is done so that the CameraDevice's metadata (like Orientation) can be populated inside the Exif object and passed on to the encoder (which will populate FrameBuffer associated metadata). Signed-off-by: Umang Jain --- src/android/camera_device.cpp | 4 +++- src/android/jpeg/encoder.h | 5 ++++- src/android/jpeg/encoder_libjpeg.cpp | 3 ++- src/android/jpeg/encoder_libjpeg.h | 3 ++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index de6f86f..bc5690e 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1434,7 +1434,9 @@ void CameraDevice::requestComplete(Request *request) continue; } - int jpeg_size = encoder->encode(buffer, mapped.maps()[0]); + Exif exif; + + int jpeg_size = encoder->encode(buffer, mapped.maps()[0], &exif); if (jpeg_size < 0) { LOG(HAL, Error) << "Failed to encode stream image"; status = CAMERA3_BUFFER_STATUS_ERROR; diff --git a/src/android/jpeg/encoder.h b/src/android/jpeg/encoder.h index f9eb88e..806cf4f 100644 --- a/src/android/jpeg/encoder.h +++ b/src/android/jpeg/encoder.h @@ -7,6 +7,8 @@ #ifndef __ANDROID_JPEG_ENCODER_H__ #define __ANDROID_JPEG_ENCODER_H__ +#include "exif.h" + #include #include #include @@ -18,7 +20,8 @@ public: virtual int configure(const libcamera::StreamConfiguration &cfg) = 0; virtual int encode(const libcamera::FrameBuffer *source, - const libcamera::Span &destination) = 0; + const libcamera::Span &destination, + Exif *exif) = 0; }; #endif /* __ANDROID_JPEG_ENCODER_H__ */ diff --git a/src/android/jpeg/encoder_libjpeg.cpp b/src/android/jpeg/encoder_libjpeg.cpp index 977538c..0cd93b6 100644 --- a/src/android/jpeg/encoder_libjpeg.cpp +++ b/src/android/jpeg/encoder_libjpeg.cpp @@ -180,7 +180,8 @@ void EncoderLibJpeg::compressNV(const libcamera::MappedBuffer *frame) } int EncoderLibJpeg::encode(const FrameBuffer *source, - const libcamera::Span &dest) + const libcamera::Span &dest, + Exif *exif) { MappedFrameBuffer frame(source, PROT_READ); if (!frame.isValid()) { diff --git a/src/android/jpeg/encoder_libjpeg.h b/src/android/jpeg/encoder_libjpeg.h index aed081a..7e0757a 100644 --- a/src/android/jpeg/encoder_libjpeg.h +++ b/src/android/jpeg/encoder_libjpeg.h @@ -22,7 +22,8 @@ public: int configure(const libcamera::StreamConfiguration &cfg) override; int encode(const libcamera::FrameBuffer *source, - const libcamera::Span &destination) override; + const libcamera::Span &destination, + Exif *exif) override; private: void compressRGB(const libcamera::MappedBuffer *frame);