From patchwork Fri Oct 2 10:34:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 9906 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 544ABC3B5C for ; Fri, 2 Oct 2020 10:34:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 21A73622B5; Fri, 2 Oct 2020 12:34:28 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=uajain.com header.i=@uajain.com header.b="Wr8z4r5A"; dkim-atps=neutral Received: from mail.uajain.com (static.126.159.217.95.clients.your-server.de [95.217.159.126]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AE20E6035D for ; Fri, 2 Oct 2020 12:34:26 +0200 (CEST) From: Umang Jain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=uajain.com; s=mail; t=1601634866; bh=QiG603B0Vq6LSYuygYIgakiBlTEi43DvdgI2kP1ff0w=; h=From:To:Cc:Subject:In-Reply-To:References; b=Wr8z4r5AxB15jle2CiZLeYPGJXxl+BJyFUXOmM42SfZR7zcEOPlrmK3+kyaYtGTL2 EahrrZw0cKUpa3aqIxfCY/9XB//vlm4L22u3z5TImKWehnv2wKTQUWGTCzCD1giICD IXumbJdFtHD8Zxr4ib1WDvjE32NaThDMKfkd9p2etTCRwiLFl82TesqOPiecUSpvsF nD/+yUqHHsd9V1CjaQC7wdd3q4d7z6fCiUGVyOCdq4jINlJNnlojjPpmiqxbYcuztF NuVUK7qUXJLDdUo3WH0pCopMS4vHlz8eTAHA27GoohCBidsWr08ssX2fMnjcFz5OJU aS+nEVudg/t3w== To: libcamera-devel@lists.libcamera.org Date: Fri, 2 Oct 2020 16:04:15 +0530 Message-Id: <20201002103416.53623-3-email@uajain.com> In-Reply-To: <20201002103416.53623-1-email@uajain.com> References: <20201002103416.53623-1-email@uajain.com> Mime-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 2/3] [DNI] jpeg/thumbnailer: write thumbnail to file 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" Signed-off-by: Umang Jain --- src/android/jpeg/thumbnailer.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/android/jpeg/thumbnailer.cpp b/src/android/jpeg/thumbnailer.cpp index d706ea6..d1dbdaf 100644 --- a/src/android/jpeg/thumbnailer.cpp +++ b/src/android/jpeg/thumbnailer.cpp @@ -34,6 +34,22 @@ void Thumbnailer::configure(const Size &sourceSize, PixelFormat pixelFormat) validConfiguration_ = true; } +static std::string datetime() +{ + time_t rawtime; + struct tm *timeinfo; + char buffer[80]; + static unsigned int milliseconds = 0; + + time(&rawtime); + timeinfo = localtime(&rawtime); + + strftime(buffer, 80, "%d-%m-%Y.%H-%M-%S.", timeinfo); + + /* milliseconds is just a fast hack to ensure unique filenames */ + return std::string(buffer) + std::to_string(milliseconds++); +} + /* Compute a thumbnail size with same aspect ratio as source. */ void Thumbnailer::computeThumbnailSize() { @@ -99,6 +115,12 @@ int Thumbnailer::scaleBuffer(const FrameBuffer *source, Span &dest) } } + /* Helper code: Write the output pixels to a file so we can inspect */ + File file("/tmp/" + datetime() + ".raw"); + int32_t ret = file.open(File::WriteOnly); + ret = file.write({ destination, dstSize }); + LOG(Thumbnailer, Info) << "Wrote " << ret << " bytes: " << targetSize_.width << "x" << targetSize_.height; + /* Write scaled pixels to dest */ dest = { destination, dstSize };