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: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.2.x@811 632fc199-4ca6-4c93-a231-07263d6284db
This commit is contained in:
@@ -5,6 +5,12 @@
|
||||
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
|
||||
=====
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
28
jdmrgext.c
28
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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
21
tjunittest.c
21
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");
|
||||
|
||||
Reference in New Issue
Block a user