From patchwork Mon Mar 8 10:13:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 11511 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 F3B38BD1F1 for ; Mon, 8 Mar 2021 10:14:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A81F368AA1; Mon, 8 Mar 2021 11:14:11 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="jHFGfEUv"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 133E6602E6 for ; Mon, 8 Mar 2021 11:14:10 +0100 (CET) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 932988A3; Mon, 8 Mar 2021 11:14:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1615198449; bh=RN7RRonhHrIGcZusbzCmJmzrhMEFMO94nSqppmD+HA0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jHFGfEUvodTlIOaXMwev1lNGpJO3+a1nmjC1Lr3Q5l3bJ7GgzjtJRvTyztHVOhmoB EHJ5+UTMAa07t7qBUw1EgiKHBbKg5ngW6abGhDOlTUFFVikyyoCu0pEFqi71dn4skO voYfv+VwN9Kf1le0ctbp9O8WoqGOLAt/mCEpm19g= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Mon, 8 Mar 2021 19:13:54 +0900 Message-Id: <20210308101356.59333-3-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210308101356.59333-1-paul.elder@ideasonboard.com> References: <20210308101356.59333-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/4] android: jpeg: exif: Simplify setGPSDateTimestamp and setGPSDMS 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" Now that setRational() supports setting multiple rational values, use that in setGPSDateTimestamp and setGPSDMS which previously set every rational manually. Signed-off-by: Paul Elder Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/android/jpeg/exif.cpp | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/src/android/jpeg/exif.cpp b/src/android/jpeg/exif.cpp index e5a3e448..c8b2f072 100644 --- a/src/android/jpeg/exif.cpp +++ b/src/android/jpeg/exif.cpp @@ -345,24 +345,13 @@ void Exif::setGPSDateTimestamp(time_t timestamp) EXIF_FORMAT_ASCII, tsStr); /* Set GPS_TIME_STAMP */ - ExifEntry *entry = - createEntry(EXIF_IFD_GPS, - static_cast(EXIF_TAG_GPS_TIME_STAMP), - EXIF_FORMAT_RATIONAL, 3, 3 * sizeof(ExifRational)); - if (!entry) - return; - ExifRational ts[] = { { static_cast(tm.tm_hour), 1 }, { static_cast(tm.tm_min), 1 }, { static_cast(tm.tm_sec), 1 }, }; - for (int i = 0; i < 3; i++) - exif_set_rational(entry->data + i * sizeof(ExifRational), - order_, ts[i]); - - exif_entry_unref(entry); + setRational(EXIF_IFD_GPS, static_cast(EXIF_TAG_GPS_TIME_STAMP), 3, ts); } std::tuple Exif::degreesToDMS(double decimalDegrees) @@ -376,22 +365,13 @@ std::tuple Exif::degreesToDMS(double decimalDegrees) void Exif::setGPSDMS(ExifIfd ifd, ExifTag tag, int deg, int min, int sec) { - ExifEntry *entry = createEntry(ifd, tag, EXIF_FORMAT_RATIONAL, 3, - 3 * sizeof(ExifRational)); - if (!entry) - return; - ExifRational coords[] = { { static_cast(deg), 1 }, { static_cast(min), 1 }, { static_cast(sec), 1 }, }; - for (int i = 0; i < 3; i++) - exif_set_rational(entry->data + i * sizeof(ExifRational), - order_, coords[i]); - - exif_entry_unref(entry); + setRational(ifd, tag, 3, coords); } /*