summaryrefslogtreecommitdiff
path: root/jdmaster.c
diff options
context:
space:
mode:
authorAaron Gable <agable@chromium.org>2015-08-06 09:54:48 -0700
committerAaron Gable <agable@chromium.org>2015-08-06 09:54:48 -0700
commitfeec46f80444b8eed4126a86a2c0e2cffe1c9673 (patch)
tree8bb36e3f61e201cb718af143ea8409ace64d6e4d /jdmaster.c
parentc9c8755c326b42c8d0dc938ec3f0d1d648bd361a (diff)
Add support for decoding to 565 to libjpeg_turbo
It was submitted upstream at libjpeg_turbo as r1295 plus sundry fixes and SIMD optimizations (r1385, r1386, r1398, and r1402). Now cherry pick the change into third_party/libjpeg-turbo. At this time, this new capability is intended for Android devices, not Chrome, and should have no affect on JPEG decode behavior or perf of Chrome. BUG=516761 R=noel@chromium.org Review URL: https://codereview.chromium.org/1270213002 .
Diffstat (limited to 'jdmaster.c')
-rw-r--r--jdmaster.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/jdmaster.c b/jdmaster.c
index e1f9f9e..f0dd15f 100644
--- a/jdmaster.c
+++ b/jdmaster.c
@@ -6,6 +6,8 @@
* Modified 2002-2009 by Guido Vollbeding.
* libjpeg-turbo Modifications:
* Copyright (C) 2009-2011, D. R. Commander.
+ * Copyright (C) 2013, Linaro Limited.
+
* For conditions of distribution and use, see the accompanying README file.
*
* This file contains master control logic for the JPEG decompressor.
@@ -51,9 +53,10 @@ use_merged_upsample (j_decompress_ptr cinfo)
/* Merging is the equivalent of plain box-filter upsampling */
if (cinfo->do_fancy_upsampling || cinfo->CCIR601_sampling)
return FALSE;
- /* jdmerge.c only supports YCC=>RGB color conversion */
+ /* jdmerge.c only supports YCC=>RGB and YCC=>RGB565 color conversion */
if (cinfo->jpeg_color_space != JCS_YCbCr || cinfo->num_components != 3 ||
(cinfo->out_color_space != JCS_RGB &&
+ cinfo->out_color_space != JCS_RGB565 &&
cinfo->out_color_space != JCS_EXT_RGB &&
cinfo->out_color_space != JCS_EXT_RGBX &&
cinfo->out_color_space != JCS_EXT_BGR &&
@@ -63,8 +66,12 @@ use_merged_upsample (j_decompress_ptr cinfo)
cinfo->out_color_space != JCS_EXT_RGBA &&
cinfo->out_color_space != JCS_EXT_BGRA &&
cinfo->out_color_space != JCS_EXT_ABGR &&
- cinfo->out_color_space != JCS_EXT_ARGB) ||
- cinfo->out_color_components != rgb_pixelsize[cinfo->out_color_space])
+ cinfo->out_color_space != JCS_EXT_ARGB))
+ return FALSE;
+ if ((cinfo->out_color_space == JCS_RGB565 &&
+ cinfo->out_color_components != 3) ||
+ (cinfo->out_color_space != JCS_RGB565 &&
+ cinfo->out_color_components != rgb_pixelsize[cinfo->out_color_space]))
return FALSE;
/* and it only handles 2h1v or 2h2v sampling ratios */
if (cinfo->comp_info[0].h_samp_factor != 2 ||
@@ -352,6 +359,7 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
cinfo->out_color_components = rgb_pixelsize[cinfo->out_color_space];
break;
case JCS_YCbCr:
+ case JCS_RGB565:
cinfo->out_color_components = 3;
break;
case JCS_CMYK: