diff options
| author | 2023-05-24 00:39:42 +0000 | |
|---|---|---|
| committer | 2023-05-24 00:39:42 +0000 | |
| commit | dfb91b700f6c85056659aab689ec7b9bad4b989f (patch) | |
| tree | aa3eb43ff983a805f1f61848ff58788ba9324bc9 | |
| parent | 4b12fffef916f60127b1c0009dd6ede67580a949 (diff) | |
| parent | 2bd62ee471799b5b6e20a2c55400e6850db5d6c7 (diff) | |
Merge "ultrahdr: Add lower bounds to input resolution to avoid empty jpeg image" into udc-dev am: 74a75503af am: c0d30a9174 am: 2bd62ee471
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/23354602
Change-Id: I642f84f245b67558d9b581abcbd23ffee28794ef
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
| -rw-r--r-- | libs/ultrahdr/jpegr.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libs/ultrahdr/jpegr.cpp b/libs/ultrahdr/jpegr.cpp index da257266ee..78fa2af4b8 100644 --- a/libs/ultrahdr/jpegr.cpp +++ b/libs/ultrahdr/jpegr.cpp @@ -65,6 +65,13 @@ static const char* const kJpegrVersion = "1.0"; // Map is quarter res / sixteenth size static const size_t kMapDimensionScaleFactor = 4; + +// Gain Map width is (image_width / kMapDimensionScaleFactor). If we were to +// compress 420 GainMap in jpeg, then we need at least 2 samples. For Grayscale +// 1 sample is sufficient. We are using 2 here anyways +static const int kMinWidth = 2 * kMapDimensionScaleFactor; +static const int kMinHeight = 2 * kMapDimensionScaleFactor; + // JPEG block size. // JPEG encoding / decoding will require block based DCT transform 16 x 16 for luma, // and 8 x 8 for chroma. @@ -105,10 +112,10 @@ status_t JpegR::areInputArgumentsValid(jr_uncompressed_ptr uncompressed_p010_ima return ERROR_JPEGR_INVALID_INPUT_TYPE; } - if (uncompressed_p010_image->width == 0 - || uncompressed_p010_image->height == 0) { - ALOGE("Image dimensions cannot be zero, image dimensions %dx%d", - uncompressed_p010_image->width, uncompressed_p010_image->height); + if (uncompressed_p010_image->width < kMinWidth + || uncompressed_p010_image->height < kMinHeight) { + ALOGE("Image dimensions cannot be less than %dx%d, image dimensions %dx%d", + kMinWidth, kMinHeight, uncompressed_p010_image->width, uncompressed_p010_image->height); return ERROR_JPEGR_INVALID_INPUT_TYPE; } |