summaryrefslogtreecommitdiff
path: root/src/android/jpeg/thumbnailer.cpp
diff options
context:
space:
mode:
authorPaul Elder <paul.elder@ideasonboard.com>2021-01-23 13:56:01 +0900
committerPaul Elder <paul.elder@ideasonboard.com>2021-01-27 12:07:14 +0900
commit1264628d3c92dedfcee32caed776e2beaad74a2a (patch)
tree18f1b28fec856099287efb22fae67361de9f61f5 /src/android/jpeg/thumbnailer.cpp
parentabfabdd6e769a58ccd9ff1e884528211904888d8 (diff)
android: jpeg: Configure thumbnailer based on request metadata
Configure the thumbnailer based on the thumbnail parameters given by the android request metadata. Only the thumbnail encoder needs to be configured, and since it is only used at post-processing time, move the configuration out of the post-processor constructor and into the processing step. Also set the following android result metadata tags: - ANDROID_JPEG_THUMBNAIL_SIZE - ANDROID_JPEG_THUMBNAIL_QUALITY Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/android/jpeg/thumbnailer.cpp')
-rw-r--r--src/android/jpeg/thumbnailer.cpp25
1 files changed, 3 insertions, 22 deletions
diff --git a/src/android/jpeg/thumbnailer.cpp b/src/android/jpeg/thumbnailer.cpp
index 5374538a..f709d343 100644
--- a/src/android/jpeg/thumbnailer.cpp
+++ b/src/android/jpeg/thumbnailer.cpp
@@ -32,30 +32,11 @@ void Thumbnailer::configure(const Size &sourceSize, PixelFormat pixelFormat)
return;
}
- targetSize_ = computeThumbnailSize();
-
valid_ = true;
}
-/*
- * The Exif specification recommends the width of the thumbnail to be a
- * multiple of 16 (section 4.8.1). Hence, compute the corresponding height
- * keeping the aspect ratio same as of the source.
- */
-Size Thumbnailer::computeThumbnailSize() const
-{
- unsigned int targetHeight;
- constexpr unsigned int kTargetWidth = 160;
-
- targetHeight = kTargetWidth * sourceSize_.height / sourceSize_.width;
-
- if (targetHeight & 1)
- targetHeight++;
-
- return Size(kTargetWidth, targetHeight);
-}
-
void Thumbnailer::createThumbnail(const FrameBuffer &source,
+ const Size &targetSize,
std::vector<unsigned char> *destination)
{
MappedFrameBuffer frame(&source, PROT_READ);
@@ -73,8 +54,8 @@ void Thumbnailer::createThumbnail(const FrameBuffer &source,
const unsigned int sw = sourceSize_.width;
const unsigned int sh = sourceSize_.height;
- const unsigned int tw = targetSize_.width;
- const unsigned int th = targetSize_.height;
+ const unsigned int tw = targetSize.width;
+ const unsigned int th = targetSize.height;
ASSERT(tw % 2 == 0 && th % 2 == 0);