summaryrefslogtreecommitdiff
path: root/libs/ultrahdr/jpegencoderhelper.cpp
diff options
context:
space:
mode:
author Dichen Zhang <dichenzhang@google.com> 2023-04-14 16:57:34 +0000
committer Dichen Zhang <dichenzhang@google.com> 2023-04-18 01:50:38 +0000
commit56a7d594d98466b21d5ec499b817d55874bb8063 (patch)
treee739954ff28ca244870bd0b557de846a0331c5c1 /libs/ultrahdr/jpegencoderhelper.cpp
parent5d39549b47832f38a9ee4c8c35a6e9c6fc56fbf1 (diff)
JPEG/R: lift the checking criteria for width 8-alignment
JPEG/R library uses jpeg-turbo for JPEG encoding, which runs DCT transform on block size of 16x16 for luma, and 8x8 for chroma. The resolution in the bug report is not 16-aligned and it results in null pointer dereference for the last line in jpeg-turbo. The original checking for 8-alignment width was wrong (should check 16-alignment). jpeg-turbo has some edge case handling for this case, and it requires some extra room at the end of input. This change removed the checking criteria by adding a padding zero method. A reason size of the padding zeros is a CB block, which is 8x8, 64 bytes. Bug: 277982036 Test: CTS: ImageReaderTest#testJpegR, uint test: jpegrencoderhelper_test.cpp Change-Id: I1313a002db6d4bc63b32dc3dd3d6ccdf06779149
Diffstat (limited to 'libs/ultrahdr/jpegencoderhelper.cpp')
-rw-r--r--libs/ultrahdr/jpegencoderhelper.cpp5
1 files changed, 0 insertions, 5 deletions
diff --git a/libs/ultrahdr/jpegencoderhelper.cpp b/libs/ultrahdr/jpegencoderhelper.cpp
index fc6e4d1e64..10a763035f 100644
--- a/libs/ultrahdr/jpegencoderhelper.cpp
+++ b/libs/ultrahdr/jpegencoderhelper.cpp
@@ -38,11 +38,6 @@ JpegEncoderHelper::~JpegEncoderHelper() {
bool JpegEncoderHelper::compressImage(const void* image, int width, int height, int quality,
const void* iccBuffer, unsigned int iccSize,
bool isSingleChannel) {
- if (width % 8 != 0 || height % 2 != 0) {
- ALOGE("Image size can not be handled: %dx%d", width, height);
- return false;
- }
-
mResultBuffer.clear();
if (!encode(image, width, height, quality, iccBuffer, iccSize, isSingleChannel)) {
return false;