summaryrefslogtreecommitdiff
path: root/jdsample.c
diff options
context:
space:
mode:
authorJonathan Wright <jonathan.wright@arm.com>2019-05-09 13:46:53 +0100
committerJonathan Wright <jonathan.wright@arm.com>2019-06-13 12:58:44 +0100
commitd78acdd58d99e49d9b7c1d97c347d4a9239c3f6b (patch)
treefb1b410e21d79b0ed08d6e068005d7909a768c16 /jdsample.c
parent2a34770be9715cfc1badff10fceba52dd393b094 (diff)
bugfix: add bias pattern for h1v2_fancy_upsample
Adds an ordered dither pattern for h1v2_fancy_upsample such that 0.5 will be rounded up or down at alternate pixel locations. Currently 0.5 is always rounded down. This ordered dither pattern is already used for h2v1_fancy_upsample and h2v2_fancy_upsample. Bug: 922430 Change-Id: Ib55ff5f6660b72d40a29b97ffa1ea1fb01ca9989
Diffstat (limited to 'jdsample.c')
-rw-r--r--jdsample.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/jdsample.c b/jdsample.c
index 52ee9af..3e98522 100644
--- a/jdsample.c
+++ b/jdsample.c
@@ -315,9 +315,9 @@ h1v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JSAMPARRAY output_data = *output_data_ptr;
JSAMPROW inptr0, inptr1, outptr;
#if BITS_IN_JSAMPLE == 8
- int thiscolsum;
+ int thiscolsum, bias;
#else
- JLONG thiscolsum;
+ JLONG thiscolsum, bias;
#endif
JDIMENSION colctr;
int inrow, outrow, v;
@@ -327,15 +327,18 @@ h1v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
for (v = 0; v < 2; v++) {
/* inptr0 points to nearest input row, inptr1 points to next nearest */
inptr0 = input_data[inrow];
- if (v == 0) /* next nearest is row above */
+ if (v == 0) { /* next nearest is row above */
inptr1 = input_data[inrow - 1];
- else /* next nearest is row below */
+ bias = 1;
+ } else { /* next nearest is row below */
inptr1 = input_data[inrow + 1];
+ bias = 2;
+ }
outptr = output_data[outrow++];
for (colctr = 0; colctr < compptr->downsampled_width; colctr++) {
thiscolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++);
- *outptr++ = (JSAMPLE)((thiscolsum + 1) >> 2);
+ *outptr++ = (JSAMPLE)((thiscolsum + bias) >> 2);
}
}
inrow++;