Commit 638adce8 authored by Moritz Firsching's avatar Moritz Firsching Committed by Commit Bot

improve use of libjpeg-turbo api

Load non-interleaved progressive jpegs in a way such that the
first few intermediate scans don't show ugly color distortion.

We have run image_decode_bench and didn't notice regressions.

Bug: 1145069
Change-Id: I8f5ebfee4730795e20846cf5c2bbc9475ed4f036
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2515401
Commit-Queue: Moritz Firsching <firsching@google.com>
Reviewed-by: default avatarLeon Scroggins <scroggo@google.com>
Cr-Commit-Position: refs/heads/master@{#825189}
parent 9fde43d5
...@@ -818,14 +818,32 @@ class JPEGImageReader final { ...@@ -818,14 +818,32 @@ class JPEGImageReader final {
status = jpeg_consume_input(&info_); status = jpeg_consume_input(&info_);
} while ((status != JPEG_SUSPENDED) && (status != JPEG_REACHED_EOI)); } while ((status != JPEG_SUSPENDED) && (status != JPEG_REACHED_EOI));
bool all_components_seen = true;
if (info_.coef_bits) {
for (int c = 0; c < info_.num_components; ++c) {
bool current_component_seen = info_.coef_bits[c][0] != -1;
all_components_seen &= current_component_seen;
}
}
int first_scan_to_display = 0;
if (!first_scan_to_display && all_components_seen) {
first_scan_to_display = info_.input_scan_number;
}
if (!all_components_seen) {
return false; // I/O suspension
}
for (;;) { for (;;) {
if (!info_.output_scanline) { if (!info_.output_scanline) {
int scan = info_.input_scan_number; int scan = info_.input_scan_number;
// If we haven't displayed anything yet // If we haven't displayed anything yet
// (output_scan_number == 0) and we have enough data for // (output_scan_number == 0) and we have enough data for
// a complete scan, force output of the last full scan. // a complete scan, force output of the last full scan, but only
if (!info_.output_scan_number && (scan > 1) && // if this last scan has seen DC data from all components.
if (!info_.output_scan_number && (scan > first_scan_to_display) &&
(status != JPEG_REACHED_EOI)) (status != JPEG_REACHED_EOI))
--scan; --scan;
......
<img src="resources/non-interleaved_progressive-1.jpg">
<img src="resources/non-interleaved_progressive.jpg">
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment