diff options
author | dcommander <dcommander@3789f03b-4d11-0410-bbf8-ca57d06f2519> | 2012-03-16 14:30:46 +0000 |
---|---|---|
committer | dcommander <dcommander@3789f03b-4d11-0410-bbf8-ca57d06f2519> | 2012-03-16 14:30:46 +0000 |
commit | c8aa02afed3d98c402e05a9870b4e12370f21622 (patch) | |
tree | 0127904fa97ac02f8ea9a11f184c79a0e6860ab4 | |
parent | fe4b1e0315107ca21120258ee7eb55514e131baf (diff) |
Fix the behavior of the alpha-enabled colorspace constants whenever libjpeg-turbo is built without SIMD support and merged upsampling is used.
git-svn-id: https://libjpeg-turbo.svn.sourceforge.net/svnroot/libjpeg-turbo@810 3789f03b-4d11-0410-bbf8-ca57d06f2519
-rw-r--r-- | trunk/ChangeLog.txt | 10 | ||||
-rw-r--r-- | trunk/java/TJUnitTest.java | 31 | ||||
-rw-r--r-- | trunk/jdmerge.c | 8 | ||||
-rw-r--r-- | trunk/jdmrgext.c | 28 | ||||
-rw-r--r-- | trunk/tjbench.c | 2 | ||||
-rw-r--r-- | trunk/tjunittest.c | 21 |
6 files changed, 71 insertions, 29 deletions
diff --git a/trunk/ChangeLog.txt b/trunk/ChangeLog.txt index 0f1f45c..cab96a9 100644 --- a/trunk/ChangeLog.txt +++ b/trunk/ChangeLog.txt @@ -2,8 +2,8 @@ ============ [1] Added support for additional scaling factors (3/8, 5/8, 3/4, 7/8, 9/8, 5/4, -11/8, 3/2, 13/8, 7/4, 15/8, and 2) when decompressing. Currently, the IDCT -will not be SIMD-accelerated when using any of these scaling factors. +11/8, 3/2, 13/8, 7/4, 15/8, and 2) when decompressing. Note that the IDCT will +not be SIMD-accelerated when using any of these new scaling factors. [2] Added SIMD acceleration for performing 4:2:2 upsampling on NEON-capable ARM platforms. This speeds up the decompression of 4:2:2 JPEGs by 20-25% on such @@ -13,6 +13,12 @@ platforms. properly work when the input or output colorspace is one of the libjpeg-turbo colorspace extensions. +[4] When libjpeg-turbo was built without SIMD support and merged (non-fancy) +upsampling was used along with an alpha-enabled colorspace during +decompression, the unused byte of the decompressed pixels was not being set to +0xFF. This has been fixed. TJUnitTest has also been extended to test for the +correct behavior of the colorspace extensions when merged upsampling is used. + 1.2.0 ===== diff --git a/trunk/java/TJUnitTest.java b/trunk/java/TJUnitTest.java index 557a85a..b88b28e 100644 --- a/trunk/java/TJUnitTest.java +++ b/trunk/java/TJUnitTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C)2011 D. R. Commander. All Rights Reserved. + * Copyright (C)2011-2012 D. R. Commander. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -765,6 +765,9 @@ public class TJUnitTest { for(int pf : formats) { for(int i = 0; i < 2; i++) { int flags = 0; + if (subsamp == TJ.SAMP_422 || subsamp == TJ.SAMP_420 + || subsamp == TJ.SAMP_440) + flags |= TJ.FLAG_FASTUPSAMPLE; if(i == 1) { if(yuv == YUVDECODE) { tjc.close(); tjd.close(); return; @@ -850,20 +853,18 @@ public class TJUnitTest { if(doyuv) yuv = YUVENCODE; doTest(35, 39, bi ? _3byteFormatsBI : _3byteFormats, TJ.SAMP_444, testName); doTest(39, 41, bi ? _4byteFormatsBI : _4byteFormats, TJ.SAMP_444, testName); - if(doyuv) { - doTest(41, 35, bi ? _3byteFormatsBI : _3byteFormats, TJ.SAMP_422, - testName); - doTest(35, 39, bi ? _4byteFormatsBI : _4byteFormats, TJ.SAMP_422, - testName); - doTest(39, 41, bi ? _3byteFormatsBI : _3byteFormats, TJ.SAMP_420, - testName); - doTest(41, 35, bi ? _4byteFormatsBI : _4byteFormats, TJ.SAMP_420, - testName); - doTest(35, 39, bi ? _3byteFormatsBI : _3byteFormats, TJ.SAMP_440, - testName); - doTest(39, 41, bi ? _4byteFormatsBI : _4byteFormats, TJ.SAMP_440, - testName); - } + doTest(41, 35, bi ? _3byteFormatsBI : _3byteFormats, TJ.SAMP_422, + testName); + doTest(35, 39, bi ? _4byteFormatsBI : _4byteFormats, TJ.SAMP_422, + testName); + doTest(39, 41, bi ? _3byteFormatsBI : _3byteFormats, TJ.SAMP_420, + testName); + doTest(41, 35, bi ? _4byteFormatsBI : _4byteFormats, TJ.SAMP_420, + testName); + doTest(35, 39, bi ? _3byteFormatsBI : _3byteFormats, TJ.SAMP_440, + testName); + doTest(39, 41, bi ? _4byteFormatsBI : _4byteFormats, TJ.SAMP_440, + testName); doTest(35, 39, bi ? onlyGrayBI : onlyGray, TJ.SAMP_GRAY, testName); doTest(39, 41, bi ? _3byteFormatsBI : _3byteFormats, TJ.SAMP_GRAY, testName); diff --git a/trunk/jdmerge.c b/trunk/jdmerge.c index cfa3bb9..5336125 100644 --- a/trunk/jdmerge.c +++ b/trunk/jdmerge.c @@ -103,6 +103,7 @@ typedef my_upsampler * my_upsample_ptr; #define RGB_RED EXT_RGBX_RED #define RGB_GREEN EXT_RGBX_GREEN #define RGB_BLUE EXT_RGBX_BLUE +#define RGB_ALPHA 3 #define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE #define h2v1_merged_upsample_internal extrgbx_h2v1_merged_upsample_internal #define h2v2_merged_upsample_internal extrgbx_h2v2_merged_upsample_internal @@ -110,6 +111,7 @@ typedef my_upsampler * my_upsample_ptr; #undef RGB_RED #undef RGB_GREEN #undef RGB_BLUE +#undef RGB_ALPHA #undef RGB_PIXELSIZE #undef h2v1_merged_upsample_internal #undef h2v2_merged_upsample_internal @@ -131,6 +133,7 @@ typedef my_upsampler * my_upsample_ptr; #define RGB_RED EXT_BGRX_RED #define RGB_GREEN EXT_BGRX_GREEN #define RGB_BLUE EXT_BGRX_BLUE +#define RGB_ALPHA 3 #define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE #define h2v1_merged_upsample_internal extbgrx_h2v1_merged_upsample_internal #define h2v2_merged_upsample_internal extbgrx_h2v2_merged_upsample_internal @@ -138,6 +141,7 @@ typedef my_upsampler * my_upsample_ptr; #undef RGB_RED #undef RGB_GREEN #undef RGB_BLUE +#undef RGB_ALPHA #undef RGB_PIXELSIZE #undef h2v1_merged_upsample_internal #undef h2v2_merged_upsample_internal @@ -145,6 +149,7 @@ typedef my_upsampler * my_upsample_ptr; #define RGB_RED EXT_XBGR_RED #define RGB_GREEN EXT_XBGR_GREEN #define RGB_BLUE EXT_XBGR_BLUE +#define RGB_ALPHA 0 #define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE #define h2v1_merged_upsample_internal extxbgr_h2v1_merged_upsample_internal #define h2v2_merged_upsample_internal extxbgr_h2v2_merged_upsample_internal @@ -152,6 +157,7 @@ typedef my_upsampler * my_upsample_ptr; #undef RGB_RED #undef RGB_GREEN #undef RGB_BLUE +#undef RGB_ALPHA #undef RGB_PIXELSIZE #undef h2v1_merged_upsample_internal #undef h2v2_merged_upsample_internal @@ -159,6 +165,7 @@ typedef my_upsampler * my_upsample_ptr; #define RGB_RED EXT_XRGB_RED #define RGB_GREEN EXT_XRGB_GREEN #define RGB_BLUE EXT_XRGB_BLUE +#define RGB_ALPHA 0 #define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE #define h2v1_merged_upsample_internal extxrgb_h2v1_merged_upsample_internal #define h2v2_merged_upsample_internal extxrgb_h2v2_merged_upsample_internal @@ -166,6 +173,7 @@ typedef my_upsampler * my_upsample_ptr; #undef RGB_RED #undef RGB_GREEN #undef RGB_BLUE +#undef RGB_ALPHA #undef RGB_PIXELSIZE #undef h2v1_merged_upsample_internal #undef h2v2_merged_upsample_internal diff --git a/trunk/jdmrgext.c b/trunk/jdmrgext.c index 95ddd55..2b93265 100644 --- a/trunk/jdmrgext.c +++ b/trunk/jdmrgext.c @@ -2,6 +2,7 @@ * jdmrgext.c * * Copyright (C) 1994-1996, Thomas G. Lane. + * 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. * @@ -54,11 +55,17 @@ h2v1_merged_upsample_internal (j_decompress_ptr cinfo, outptr[RGB_RED] = range_limit[y + cred]; outptr[RGB_GREEN] = range_limit[y + cgreen]; outptr[RGB_BLUE] = range_limit[y + cblue]; +#ifdef RGB_ALPHA + outptr[RGB_ALPHA] = 0xFF; +#endif outptr += RGB_PIXELSIZE; y = GETJSAMPLE(*inptr0++); outptr[RGB_RED] = range_limit[y + cred]; outptr[RGB_GREEN] = range_limit[y + cgreen]; outptr[RGB_BLUE] = range_limit[y + cblue]; +#ifdef RGB_ALPHA + outptr[RGB_ALPHA] = 0xFF; +#endif outptr += RGB_PIXELSIZE; } /* If image width is odd, do the last output column separately */ @@ -72,6 +79,9 @@ h2v1_merged_upsample_internal (j_decompress_ptr cinfo, outptr[RGB_RED] = range_limit[y + cred]; outptr[RGB_GREEN] = range_limit[y + cgreen]; outptr[RGB_BLUE] = range_limit[y + cblue]; +#ifdef RGB_ALPHA + outptr[RGB_ALPHA] = 0xFF; +#endif } } @@ -120,21 +130,33 @@ h2v2_merged_upsample_internal (j_decompress_ptr cinfo, outptr0[RGB_RED] = range_limit[y + cred]; outptr0[RGB_GREEN] = range_limit[y + cgreen]; outptr0[RGB_BLUE] = range_limit[y + cblue]; +#ifdef RGB_ALPHA + outptr0[RGB_ALPHA] = 0xFF; +#endif outptr0 += RGB_PIXELSIZE; y = GETJSAMPLE(*inptr00++); outptr0[RGB_RED] = range_limit[y + cred]; outptr0[RGB_GREEN] = range_limit[y + cgreen]; outptr0[RGB_BLUE] = range_limit[y + cblue]; +#ifdef RGB_ALPHA + outptr0[RGB_ALPHA] = 0xFF; +#endif outptr0 += RGB_PIXELSIZE; y = GETJSAMPLE(*inptr01++); outptr1[RGB_RED] = range_limit[y + cred]; outptr1[RGB_GREEN] = range_limit[y + cgreen]; outptr1[RGB_BLUE] = range_limit[y + cblue]; +#ifdef RGB_ALPHA + outptr1[RGB_ALPHA] = 0xFF; +#endif outptr1 += RGB_PIXELSIZE; y = GETJSAMPLE(*inptr01++); outptr1[RGB_RED] = range_limit[y + cred]; outptr1[RGB_GREEN] = range_limit[y + cgreen]; outptr1[RGB_BLUE] = range_limit[y + cblue]; +#ifdef RGB_ALPHA + outptr1[RGB_ALPHA] = 0xFF; +#endif outptr1 += RGB_PIXELSIZE; } /* If image width is odd, do the last output column separately */ @@ -148,9 +170,15 @@ h2v2_merged_upsample_internal (j_decompress_ptr cinfo, outptr0[RGB_RED] = range_limit[y + cred]; outptr0[RGB_GREEN] = range_limit[y + cgreen]; outptr0[RGB_BLUE] = range_limit[y + cblue]; +#ifdef RGB_ALPHA + outptr0[RGB_ALPHA] = 0xFF; +#endif y = GETJSAMPLE(*inptr01); outptr1[RGB_RED] = range_limit[y + cred]; outptr1[RGB_GREEN] = range_limit[y + cgreen]; outptr1[RGB_BLUE] = range_limit[y + cblue]; +#ifdef RGB_ALPHA + outptr1[RGB_ALPHA] = 0xFF; +#endif } } diff --git a/trunk/tjbench.c b/trunk/tjbench.c index 8125e56..e529ffc 100644 --- a/trunk/tjbench.c +++ b/trunk/tjbench.c @@ -681,7 +681,7 @@ void usage(char *progname) printf("-rgb, -bgr, -rgbx, -bgrx, -xbgr, -xrgb =\n"); printf(" Test the specified color conversion path in the codec (default: BGR)\n"); printf("-fastupsample = Use fast, inaccurate upsampling code to perform 4:2:2 and 4:2:0\n"); - printf(" YUV decoding in libjpeg decompressor\n"); + printf(" YUV decoding\n"); printf("-quiet = Output results in tabular rather than verbose format\n"); printf("-yuvencode = Encode RGB input as planar YUV rather than compressing as JPEG\n"); printf("-yuvdecode = Decode JPEG image to planar YUV rather than RGB\n"); diff --git a/trunk/tjunittest.c b/trunk/tjunittest.c index d14ec52..89a6d1d 100644 --- a/trunk/tjunittest.c +++ b/trunk/tjunittest.c @@ -1,5 +1,5 @@ /* - * Copyright (C)2009-2011 D. R. Commander. All Rights Reserved. + * Copyright (C)2009-2012 D. R. Commander. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -77,7 +77,7 @@ const int _onlyGray[]={TJPF_GRAY}; const int _onlyRGB[]={TJPF_RGB}; enum {YUVENCODE=1, YUVDECODE}; -int yuv=0, alloc=0, alpha=0; +int yuv=0, alloc=0; int exitStatus=0; #define bailout() {exitStatus=-1; goto bailout;} @@ -502,6 +502,8 @@ void doTest(int w, int h, const int *formats, int nformats, int subsamp, for(i=0; i<2; i++) { int flags=0; + if(subsamp==TJSAMP_422 || subsamp==TJSAMP_420 || subsamp==TJSAMP_440) + flags|=TJFLAG_FASTUPSAMPLE; if(i==1) { if(yuv==YUVDECODE) goto bailout; @@ -617,15 +619,12 @@ int main(int argc, char *argv[]) if(doyuv) {yuv=YUVENCODE; alloc=0;} doTest(35, 39, _3byteFormats, 2, TJSAMP_444, "test"); doTest(39, 41, _4byteFormats, 4, TJSAMP_444, "test"); - if(doyuv) - { - doTest(41, 35, _3byteFormats, 2, TJSAMP_422, "test"); - doTest(35, 39, _4byteFormats, 4, TJSAMP_422, "test"); - doTest(39, 41, _3byteFormats, 2, TJSAMP_420, "test"); - doTest(41, 35, _4byteFormats, 4, TJSAMP_420, "test"); - doTest(35, 39, _3byteFormats, 2, TJSAMP_440, "test"); - doTest(39, 41, _4byteFormats, 4, TJSAMP_440, "test"); - } + doTest(41, 35, _3byteFormats, 2, TJSAMP_422, "test"); + doTest(35, 39, _4byteFormats, 4, TJSAMP_422, "test"); + doTest(39, 41, _3byteFormats, 2, TJSAMP_420, "test"); + doTest(41, 35, _4byteFormats, 4, TJSAMP_420, "test"); + doTest(35, 39, _3byteFormats, 2, TJSAMP_440, "test"); + doTest(39, 41, _4byteFormats, 4, TJSAMP_440, "test"); doTest(35, 39, _onlyGray, 1, TJSAMP_GRAY, "test"); doTest(39, 41, _3byteFormats, 2, TJSAMP_GRAY, "test"); doTest(41, 35, _4byteFormats, 4, TJSAMP_GRAY, "test"); |