summaryrefslogtreecommitdiff
path: root/trunk/jcdctmgr.c
diff options
context:
space:
mode:
authordcommander <dcommander@3789f03b-4d11-0410-bbf8-ca57d06f2519>2011-02-18 20:50:08 +0000
committerdcommander <dcommander@3789f03b-4d11-0410-bbf8-ca57d06f2519>2011-02-18 20:50:08 +0000
commitf2e1b583789bebde820cb23b68781c83638c892c (patch)
tree4ed295546cfecfed20a61a8236a8e2146c7ed450 /trunk/jcdctmgr.c
parent366d74a7bb57d42b117e772f61d7a02442d2c363 (diff)
The SIMD quantization algorithm does not produce correct results with the fast forward integer DCT and JPEG qualities >= 98, so for now, use the non-SIMD quantization function under those circumstances.
git-svn-id: https://libjpeg-turbo.svn.sourceforge.net/svnroot/libjpeg-turbo@395 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'trunk/jcdctmgr.c')
-rw-r--r--trunk/jcdctmgr.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/trunk/jcdctmgr.c b/trunk/jcdctmgr.c
index 156957a..711f9da 100644
--- a/trunk/jcdctmgr.c
+++ b/trunk/jcdctmgr.c
@@ -4,6 +4,7 @@
* Copyright (C) 1994-1996, Thomas G. Lane.
* Copyright (C) 1999-2006, MIYASAKA Masaru.
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
+ * Copyright (C) 2011 D. R. Commander
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -39,6 +40,8 @@ typedef JMETHOD(void, float_quantize_method_ptr,
(JCOEFPTR coef_block, FAST_FLOAT * divisors,
FAST_FLOAT * workspace));
+METHODDEF(void) quantize (JCOEFPTR, DCTELEM *, DCTELEM *);
+
typedef struct {
struct jpeg_forward_dct pub; /* public fields */
@@ -160,7 +163,7 @@ flss (UINT16 val)
* of in a consecutive manner, yet again in order to allow SIMD
* routines.
*/
-LOCAL(void)
+LOCAL(int)
compute_reciprocal (UINT16 divisor, DCTELEM * dtbl)
{
UDCTELEM2 fq, fr;
@@ -189,6 +192,9 @@ compute_reciprocal (UINT16 divisor, DCTELEM * dtbl)
dtbl[DCTSIZE2 * 1] = (DCTELEM) c; /* correction + roundfactor */
dtbl[DCTSIZE2 * 2] = (DCTELEM) (1 << (sizeof(DCTELEM)*8*2 - r)); /* scale */
dtbl[DCTSIZE2 * 3] = (DCTELEM) r - sizeof(DCTELEM)*8; /* shift */
+
+ if(r <= 16) return 0;
+ else return 1;
}
/*
@@ -232,7 +238,9 @@ start_pass_fdctmgr (j_compress_ptr cinfo)
}
dtbl = fdct->divisors[qtblno];
for (i = 0; i < DCTSIZE2; i++) {
- compute_reciprocal(qtbl->quantval[i] << 3, &dtbl[i]);
+ if(!compute_reciprocal(qtbl->quantval[i] << 3, &dtbl[i])
+ && fdct->quantize == jsimd_quantize)
+ fdct->quantize = quantize;
}
break;
#endif
@@ -266,10 +274,12 @@ start_pass_fdctmgr (j_compress_ptr cinfo)
}
dtbl = fdct->divisors[qtblno];
for (i = 0; i < DCTSIZE2; i++) {
- compute_reciprocal(
+ if(!compute_reciprocal(
DESCALE(MULTIPLY16V16((INT32) qtbl->quantval[i],
(INT32) aanscales[i]),
- CONST_BITS-3), &dtbl[i]);
+ CONST_BITS-3), &dtbl[i])
+ && fdct->quantize == jsimd_quantize)
+ fdct->quantize = quantize;
}
}
break;