jpegrecoverymap: add initial recovery map calculations.
This change adds the starting point for generating and applying the
recovery map. A follow-up change will add more robust tests for this
update (eg. unit testing color conversions).
There are a few other known TODOs remaining for these map operations:
* Clean up handling around hdr_ratio (ie. utilizing XMP)
* Add color space information for inputs and utilize it for ICC data
* Add handling for PQ encode/decode
No-Typo-Check: Lint suggesting typo in code as if it's a comment
Test: build
Bug: b/252835416
Change-Id: I2f6a1bf3b046036292afe46bbd2396a87cdc5164
diff --git a/libs/jpegrecoverymap/jpegdecoder.cpp b/libs/jpegrecoverymap/jpegdecoder.cpp
index 22a5389..c1fb6c3 100644
--- a/libs/jpegrecoverymap/jpegdecoder.cpp
+++ b/libs/jpegrecoverymap/jpegdecoder.cpp
@@ -95,7 +95,7 @@
return true;
}
-const void* JpegDecoder::getDecompressedImagePtr() {
+void* JpegDecoder::getDecompressedImagePtr() {
return mResultBuffer.data();
}
@@ -103,6 +103,14 @@
return mResultBuffer.size();
}
+size_t JpegDecoder::getDecompressedImageWidth() {
+ return mWidth;
+}
+
+size_t JpegDecoder::getDecompressedImageHeight() {
+ return mHeight;
+}
+
bool JpegDecoder::decode(const void* image, int length) {
jpeg_decompress_struct cinfo;
jpegr_source_mgr mgr(static_cast<const uint8_t*>(image), length);
@@ -119,6 +127,9 @@
cinfo.src = &mgr;
jpeg_read_header(&cinfo, TRUE);
+ mWidth = cinfo.image_width;
+ mHeight = cinfo.image_height;
+
if (cinfo.jpeg_color_space == JCS_YCbCr) {
mResultBuffer.resize(cinfo.image_width * cinfo.image_height * 3 / 2, 0);
} else if (cinfo.jpeg_color_space == JCS_GRAYSCALE) {
@@ -222,4 +233,4 @@
return true;
}
-} // namespace android
\ No newline at end of file
+} // namespace android