properly work when the input or output colorspace is one of the libjpeg-turbo
colorspace extensions.
+[2] 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
=====
/*
- * 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:
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;
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);
#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
#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
#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
#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
#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
#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
#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
#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
* 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.
*
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 */
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
}
}
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 */
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
}
}
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");
/*
- * 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:
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;}
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;
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");