summaryrefslogtreecommitdiff
path: root/src/android/jpeg/encoder_libjpeg.cpp
diff options
context:
space:
mode:
authorPaul Elder <paul.elder@ideasonboard.com>2021-01-23 14:08:35 +0900
committerPaul Elder <paul.elder@ideasonboard.com>2021-01-27 12:07:21 +0900
commitab72e6641c56e876f91edee57a8969982a3ab9b7 (patch)
treedac370e8b2f56bf97578864302cc3b71b5415a44 /src/android/jpeg/encoder_libjpeg.cpp
parenta6de3f0203c5d338a2a86ff049d55907a12e04c5 (diff)
android: jpeg: Set thumbnail and JPEG quality based on request
Set the thumbnail quality and the JPEG quality based on the android request metadata. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src/android/jpeg/encoder_libjpeg.cpp')
-rw-r--r--src/android/jpeg/encoder_libjpeg.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/android/jpeg/encoder_libjpeg.cpp b/src/android/jpeg/encoder_libjpeg.cpp
index aed919b9..f006e1d1 100644
--- a/src/android/jpeg/encoder_libjpeg.cpp
+++ b/src/android/jpeg/encoder_libjpeg.cpp
@@ -68,7 +68,6 @@ const struct JPEGPixelFormatInfo &findPixelInfo(const PixelFormat &format)
} /* namespace */
EncoderLibJpeg::EncoderLibJpeg()
- : quality_(95)
{
/* \todo Expand error handling coverage with a custom handler. */
compress_.err = jpeg_std_error(&jerr_);
@@ -94,7 +93,6 @@ int EncoderLibJpeg::configure(const StreamConfiguration &cfg)
compress_.input_components = info.colorSpace == JCS_GRAYSCALE ? 1 : 3;
jpeg_set_defaults(&compress_);
- jpeg_set_quality(&compress_, quality_, TRUE);
pixelFormatInfo_ = &info.pixelFormatInfo;
@@ -180,7 +178,7 @@ void EncoderLibJpeg::compressNV(Span<const uint8_t> frame)
}
int EncoderLibJpeg::encode(const FrameBuffer &source, Span<uint8_t> dest,
- Span<const uint8_t> exifData)
+ Span<const uint8_t> exifData, unsigned int quality)
{
MappedFrameBuffer frame(&source, PROT_READ);
if (!frame.isValid()) {
@@ -189,15 +187,17 @@ int EncoderLibJpeg::encode(const FrameBuffer &source, Span<uint8_t> dest,
return frame.error();
}
- return encode(frame.maps()[0], dest, exifData);
+ return encode(frame.maps()[0], dest, exifData, quality);
}
int EncoderLibJpeg::encode(Span<const uint8_t> src, Span<uint8_t> dest,
- Span<const uint8_t> exifData)
+ Span<const uint8_t> exifData, unsigned int quality)
{
unsigned char *destination = dest.data();
unsigned long size = dest.size();
+ jpeg_set_quality(&compress_, quality, TRUE);
+
/*
* The jpeg_mem_dest will reallocate if the required size is not
* sufficient. That means the output won't be written to the correct