summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHirokazu Honda <hiroh@chromium.org>2020-10-21 10:39:53 +0900
committerKieran Bingham <kieran.bingham@ideasonboard.com>2020-10-21 11:18:12 +0100
commit90c193f2a70093917730b86359c6e459c28d2c24 (patch)
treef32f6dffbb7542df962adf1fa46f7b4f026d1e14
parentb8dd5ce944eca4d17df585bb059595729905f7ec (diff)
android: Modify Encoder interface
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 cheap 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 <hiroh@chromium.org> Reviewed-by: Umang Jain <email@uajain.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
-rw-r--r--src/android/jpeg/encoder.h4
-rw-r--r--src/android/jpeg/encoder_libjpeg.cpp6
-rw-r--r--src/android/jpeg/encoder_libjpeg.h4
-rw-r--r--src/android/jpeg/post_processor_jpeg.cpp2
4 files changed, 8 insertions, 8 deletions
diff --git a/src/android/jpeg/encoder.h b/src/android/jpeg/encoder.h
index 4e859961..270ea609 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<uint8_t> &destination,
+ virtual int encode(const libcamera::FrameBuffer &source,
+ libcamera::Span<uint8_t> destination,
const libcamera::Span<const uint8_t> &exifData) = 0;
};
diff --git a/src/android/jpeg/encoder_libjpeg.cpp b/src/android/jpeg/encoder_libjpeg.cpp
index f11e0043..5a2f88fb 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<uint8_t> &dest,
+int EncoderLibJpeg::encode(const FrameBuffer &source,
+ libcamera::Span<uint8_t> dest,
const libcamera::Span<const uint8_t> &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 934caefd..391a53ca 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<uint8_t> &destination,
+ int encode(const libcamera::FrameBuffer &source,
+ libcamera::Span<uint8_t> destination,
const libcamera::Span<const uint8_t> &exifData) override;
private:
diff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp
index 90bf10d5..8b01bd63 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;