OLD | NEW |
1 /* | 1 /* |
2 * jcdctmgr.c | 2 * jcdctmgr.c |
3 * | 3 * |
4 * Copyright (C) 1994-1996, Thomas G. Lane. | 4 * Copyright (C) 1994-1996, Thomas G. Lane. |
5 * Copyright (C) 1999-2006, MIYASAKA Masaru. | 5 * Copyright (C) 1999-2006, MIYASAKA Masaru. |
6 * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB | 6 * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB |
7 * Copyright (C) 2011 D. R. Commander | 7 * Copyright (C) 2011 D. R. Commander |
8 * This file is part of the Independent JPEG Group's software. | 8 * This file is part of the Independent JPEG Group's software. |
9 * For conditions of distribution and use, see the accompanying README file. | 9 * For conditions of distribution and use, see the accompanying README file. |
10 * | 10 * |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 | 175 |
176 fq = ((UDCTELEM2)1 << r) / divisor; | 176 fq = ((UDCTELEM2)1 << r) / divisor; |
177 fr = ((UDCTELEM2)1 << r) % divisor; | 177 fr = ((UDCTELEM2)1 << r) % divisor; |
178 | 178 |
179 c = divisor / 2; /* for rounding */ | 179 c = divisor / 2; /* for rounding */ |
180 | 180 |
181 if (fr == 0) { /* divisor is power of two */ | 181 if (fr == 0) { /* divisor is power of two */ |
182 /* fq will be one bit too large to fit in DCTELEM, so adjust */ | 182 /* fq will be one bit too large to fit in DCTELEM, so adjust */ |
183 fq >>= 1; | 183 fq >>= 1; |
184 r--; | 184 r--; |
185 } else if (fr <= (divisor / 2)) { /* fractional part is < 0.5 */ | 185 } else if (fr <= (divisor / 2U)) { /* fractional part is < 0.5 */ |
186 c++; | 186 c++; |
187 } else { /* fractional part is > 0.5 */ | 187 } else { /* fractional part is > 0.5 */ |
188 fq++; | 188 fq++; |
189 } | 189 } |
190 | 190 |
191 dtbl[DCTSIZE2 * 0] = (DCTELEM) fq; /* reciprocal */ | 191 dtbl[DCTSIZE2 * 0] = (DCTELEM) fq; /* reciprocal */ |
192 dtbl[DCTSIZE2 * 1] = (DCTELEM) c; /* correction + roundfactor */ | 192 dtbl[DCTSIZE2 * 1] = (DCTELEM) c; /* correction + roundfactor */ |
193 dtbl[DCTSIZE2 * 2] = (DCTELEM) (1 << (sizeof(DCTELEM)*8*2 - r)); /* scale */ | 193 dtbl[DCTSIZE2 * 2] = (DCTELEM) (1 << (sizeof(DCTELEM)*8*2 - r)); /* scale */ |
194 dtbl[DCTSIZE2 * 3] = (DCTELEM) r - sizeof(DCTELEM)*8; /* shift */ | 194 dtbl[DCTSIZE2 * 3] = (DCTELEM) r - sizeof(DCTELEM)*8; /* shift */ |
195 | 195 |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 SIZEOF(DCTELEM) * DCTSIZE2); | 633 SIZEOF(DCTELEM) * DCTSIZE2); |
634 | 634 |
635 /* Mark divisor tables unallocated */ | 635 /* Mark divisor tables unallocated */ |
636 for (i = 0; i < NUM_QUANT_TBLS; i++) { | 636 for (i = 0; i < NUM_QUANT_TBLS; i++) { |
637 fdct->divisors[i] = NULL; | 637 fdct->divisors[i] = NULL; |
638 #ifdef DCT_FLOAT_SUPPORTED | 638 #ifdef DCT_FLOAT_SUPPORTED |
639 fdct->float_divisors[i] = NULL; | 639 fdct->float_divisors[i] = NULL; |
640 #endif | 640 #endif |
641 } | 641 } |
642 } | 642 } |
OLD | NEW |