From patchwork Tue Oct 20 07:42:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 10122 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 DBD24BDB13 for ; Tue, 20 Oct 2020 07:42:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A391361373; Tue, 20 Oct 2020 09:42:42 +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="TuMte7+Q"; dkim-atps=neutral Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3E6C760353 for ; Tue, 20 Oct 2020 09:42:41 +0200 (CEST) Received: by mail-pl1-x642.google.com with SMTP id b19so590651pld.0 for ; Tue, 20 Oct 2020 00:42:41 -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=4GFgfk9SMXWs9mals3D4EQq8xd4Or6Xym7sScIqjpis=; b=TuMte7+QUDeHCHGfCLp6R7xz0kHdzXy7pHjgq17Xa3tl3mwH+TaMWLzMeZk1WQKIU9 urmKvNHuK4a+FqTgX37YpyeN0uefs3YVdlkQLhReyX1lF1WAliUGLPiI6pnyK0RCAE92 0Dfwpa+kJo0TGcmsYzA1Y6uJYsJOFPK5HzMk4= 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=4GFgfk9SMXWs9mals3D4EQq8xd4Or6Xym7sScIqjpis=; b=sCXkLwFXy/P17WzSvEO3nOl1jEf5QFdzZPcI4lnqbrVSq0mGdfIYZI06fUtcxA8nGh ckRicBtDjRVniJBLJcoZz1dGAXj8t40/zfcF+EKYq/3XSWQk7cZxVWqETOJyvImcvD0e fQ0FdmGmWOiyPMYJo6him1sFUurXjr/4Wqa9/I6J/Mg53v1kHvyXoXjpcXpX2FrxPPdC JxK48MxudYl+C1uueChsAmwBeb0OPd9v+hWH15DhA4zjOaAtHdyu9NGPm+D4bYb6hK9T NfpfRYMXHgDE9zJfkiMlKhufmINH351c6KsPMuOCuoYMC4AeQIE0GfNQsTSTO+IdazpI z0ZQ== X-Gm-Message-State: AOAM531QaOFragg/js3b4MyPGPqfO6VaGP7Cdeo1mduDihND13MupStq q9QshpmFw2VAY9ZIFGjp4VEQF+L0H5YGfA== X-Google-Smtp-Source: ABdhPJyEtfXDOoq6rjGlqorfuP/OLIsfzWW6Z4P+ufnkgDEfyUfkCWhK8hf2B3GM9NF1Pr0b+wUy/Q== X-Received: by 2002:a17:90b:438c:: with SMTP id in12mr1750546pjb.32.1603179759542; Tue, 20 Oct 2020 00:42:39 -0700 (PDT) Received: from hiroh.tok.corp.google.com ([2401:fa00:8f:2:de4a:3eff:fe7d:f78f]) by smtp.gmail.com with ESMTPSA id d26sm1193684pfo.82.2020.10.20.00.42.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 00:42:39 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Tue, 20 Oct 2020 16:42:27 +0900 Message-Id: <20201020074229.119151-2-hiroh@chromium.org> X-Mailer: git-send-email 2.29.0.rc1.297.gfa9743e501-goog In-Reply-To: <20201020074229.119151-1-hiroh@chromium.org> References: <20201020074229.119151-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/4] android: Modify Encoder interface 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" In Encoder::encode(), the |source| argument doesn't have to be a pointer. This replaces its type, const pointer, with const reference as the latter is preferred to the former. libcamera::Span is chea to construct/copy/move. We should deal with the type as pass-by-value parameter. Therefore this also drops the const reference in the |destination| argument. Signed-off-by: Hirokazu Honda Reviewed-by: Umang Jain Reviewed-by: Kieran Bingham --- src/android/jpeg/encoder.h | 4 ++-- src/android/jpeg/encoder_libjpeg.cpp | 6 +++--- src/android/jpeg/encoder_libjpeg.h | 4 ++-- src/android/jpeg/post_processor_jpeg.cpp | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/android/jpeg/encoder.h b/src/android/jpeg/encoder.h index 4483153..4fe71cf 100644 --- a/src/android/jpeg/encoder.h +++ b/src/android/jpeg/encoder.h @@ -17,8 +17,8 @@ public: virtual ~Encoder() {}; virtual int configure(const libcamera::StreamConfiguration &cfg) = 0; - virtual int encode(const libcamera::FrameBuffer *source, - const libcamera::Span &destination, + virtual int encode(const libcamera::FrameBuffer &source, + libcamera::Span destination, const libcamera::Span &exifData) = 0; }; diff --git a/src/android/jpeg/encoder_libjpeg.cpp b/src/android/jpeg/encoder_libjpeg.cpp index 8995ba5..4236c9d 100644 --- a/src/android/jpeg/encoder_libjpeg.cpp +++ b/src/android/jpeg/encoder_libjpeg.cpp @@ -179,11 +179,11 @@ void EncoderLibJpeg::compressNV(const libcamera::MappedBuffer *frame) } } -int EncoderLibJpeg::encode(const FrameBuffer *source, - const libcamera::Span &dest, +int EncoderLibJpeg::encode(const FrameBuffer &source, + libcamera::Span dest, const libcamera::Span &exifData) { - MappedFrameBuffer frame(source, PROT_READ); + MappedFrameBuffer frame(&source, PROT_READ); if (!frame.isValid()) { LOG(JPEG, Error) << "Failed to map FrameBuffer : " << strerror(frame.error()); diff --git a/src/android/jpeg/encoder_libjpeg.h b/src/android/jpeg/encoder_libjpeg.h index 934caef..391a53c 100644 --- a/src/android/jpeg/encoder_libjpeg.h +++ b/src/android/jpeg/encoder_libjpeg.h @@ -21,8 +21,8 @@ public: ~EncoderLibJpeg(); int configure(const libcamera::StreamConfiguration &cfg) override; - int encode(const libcamera::FrameBuffer *source, - const libcamera::Span &destination, + int encode(const libcamera::FrameBuffer &source, + libcamera::Span destination, const libcamera::Span &exifData) override; private: diff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp index 55b9088..6f33631 100644 --- a/src/android/jpeg/post_processor_jpeg.cpp +++ b/src/android/jpeg/post_processor_jpeg.cpp @@ -67,7 +67,7 @@ int PostProcessorJpeg::process(const libcamera::FrameBuffer &source, if (exif.generate() != 0) LOG(JPEG, Error) << "Failed to generate valid EXIF data"; - int jpeg_size = encoder_->encode(&source, destination, exif.data()); + int jpeg_size = encoder_->encode(source, destination, exif.data()); if (jpeg_size < 0) { LOG(JPEG, Error) << "Failed to encode stream image"; return jpeg_size;