summaryrefslogtreecommitdiff
path: root/jmemnobs.c
diff options
context:
space:
mode:
authorLeon Scroggins III <scroggo@google.com>2018-02-28 14:05:04 -0500
committerLeon Scroggins III <scroggo@google.com>2018-03-02 12:45:15 -0500
commitbd7903e2a5584fe8d4c1103da25dff429e77c304 (patch)
treee4ccd14967629b2776c7c0b49f59027871a72946 /jmemnobs.c
parent531ad7a4e8ca1768dfb31b6d4323cb4563be1f39 (diff)
Update libjpeg-turbo to 1.5.3
Bug: 70203010 Test: Existing tests Use commit at tag 1.5.3 (bf6c774305c9feb30cff7b99e1a475df61bfa008). This includes a fix for decompressing grayscale JPEG images that were compressed with a sampling factor other than 1 (b/70203010). The bug manifested as black stripes appearing when using the region decoder. ChangeLog.md contains more detailed changes. Add -Wno-sign-compare to Android.bp to silence a warning in jmemnobs.c. Change-Id: Ifefc70073fdff9c68e9b2cbcddf114c8bcb7d366
Diffstat (limited to 'jmemnobs.c')
-rw-r--r--jmemnobs.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/jmemnobs.c b/jmemnobs.c
index 5797198..ac12afa 100644
--- a/jmemnobs.c
+++ b/jmemnobs.c
@@ -3,8 +3,8 @@
*
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1992-1996, Thomas G. Lane.
- * It was modified by The libjpeg-turbo Project to include only code and
- * information relevant to libjpeg-turbo.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2017, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -15,7 +15,6 @@
* This is very portable in the sense that it'll compile on almost anything,
* but you'd better have lots of main memory (or virtual memory) if you want
* to process big images.
- * Note that the max_memory_to_use option is ignored by this implementation.
*/
#define JPEG_INTERNALS
@@ -66,14 +65,21 @@ jpeg_free_large (j_common_ptr cinfo, void *object, size_t sizeofobject)
/*
* This routine computes the total memory space available for allocation.
- * Here we always say, "we got all you want bud!"
*/
GLOBAL(size_t)
jpeg_mem_available (j_common_ptr cinfo, size_t min_bytes_needed,
size_t max_bytes_needed, size_t already_allocated)
{
- return max_bytes_needed;
+ if (cinfo->mem->max_memory_to_use) {
+ if (cinfo->mem->max_memory_to_use > already_allocated)
+ return cinfo->mem->max_memory_to_use - already_allocated;
+ else
+ return 0;
+ } else {
+ /* Here we always say, "we got all you want bud!" */
+ return max_bytes_needed;
+ }
}