summaryrefslogtreecommitdiff
path: root/jdhuff.c
diff options
context:
space:
mode:
authorAaron Gable <agable@chromium.org>2015-08-03 09:34:32 -0700
committerAaron Gable <agable@chromium.org>2015-08-03 09:34:32 -0700
commitc9c8755c326b42c8d0dc938ec3f0d1d648bd361a (patch)
tree7ebff33dec9b7cc37d65746e0d89f32cb74d141e /jdhuff.c
parent7a6ab4e9ce76b07ac406a20700eb97b7dd6d05f5 (diff)
Add jpeg_skip_scanlines() API to libjpeg-turbo
jpeg_skip_scanlines() API, a subset decoding optimization aimed at Android, was submitted upstream r1582. Pull that change, and sundry fixes, into the Chromium repo. This new API is targetted at Android devices, not Chrome, and should have no affect on JPEG decode behavior or perf of Chrome. Chrome uses suspending data source JPEG decoding, and the new API does not support such sources. Adding support for suspending data sources is a future TODO, should the need arise (refer to skbug.com/4036). BUG=515694 BUG=468914 patch from issue 256280043 at patchset 50001 (http://crrev.com/256280043#ps50001) R=agable@chromium.org Review URL: https://codereview.chromium.org/1271803002 .
Diffstat (limited to 'jdhuff.c')
-rw-r--r--jdhuff.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/jdhuff.c b/jdhuff.c
index 5d023ae..7229f02 100644
--- a/jdhuff.c
+++ b/jdhuff.c
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1997, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2009-2011, D. R. Commander.
+ * Copyright (C) 2009-2011, 2015, D. R. Commander.
* For conditions of distribution and use, see the accompanying README file.
*
* This file contains Huffman entropy decoding routines.
@@ -561,7 +561,7 @@ decode_mcu_slow (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
ASSIGN_STATE(state, entropy->saved);
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
- JBLOCKROW block = MCU_data[blkn];
+ JBLOCKROW block = MCU_data ? MCU_data[blkn] : NULL;
d_derived_tbl * dctbl = entropy->dc_cur_tbls[blkn];
d_derived_tbl * actbl = entropy->ac_cur_tbls[blkn];
register int s, k, r;
@@ -581,11 +581,13 @@ decode_mcu_slow (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
int ci = cinfo->MCU_membership[blkn];
s += state.last_dc_val[ci];
state.last_dc_val[ci] = s;
- /* Output the DC coefficient (assumes jpeg_natural_order[0] = 0) */
- (*block)[0] = (JCOEF) s;
+ if (block) {
+ /* Output the DC coefficient (assumes jpeg_natural_order[0] = 0) */
+ (*block)[0] = (JCOEF) s;
+ }
}
- if (entropy->ac_needed[blkn]) {
+ if (entropy->ac_needed[blkn] && block) {
/* Section F.2.2.2: decode the AC coefficients */
/* Since zeroes are skipped, output area must be cleared beforehand */
@@ -674,10 +676,11 @@ decode_mcu_fast (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
int ci = cinfo->MCU_membership[blkn];
s += state.last_dc_val[ci];
state.last_dc_val[ci] = s;
- (*block)[0] = (JCOEF) s;
+ if (block)
+ (*block)[0] = (JCOEF) s;
}
- if (entropy->ac_needed[blkn]) {
+ if (entropy->ac_needed[blkn] && block) {
for (k = 1; k < DCTSIZE2; k++) {
HUFF_DECODE_FAST(s, l, actbl, slow_decode_mcu);