"4:1:1 = 4:2:0" git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@3757 3789f03b-4d11-0410-bbf8-ca57d06f2519tags/v0.0.90
@@ -21,8 +21,8 @@ | |||
#define _catch(f) {if((f)==-1) {printf("TJPEG: %s\n", tjGetErrorStr()); goto finally;}} | |||
const char *_subnamel[NUMSUBOPT]={"4:4:4", "4:2:2", "4:1:1", "GRAY"}; | |||
const char *_subnames[NUMSUBOPT]={"444", "422", "411", "GRAY"}; | |||
const char *_subnamel[NUMSUBOPT]={"4:4:4", "4:2:2", "4:2:0", "GRAY"}; | |||
const char *_subnames[NUMSUBOPT]={"444", "422", "420", "GRAY"}; | |||
int pixels[9][3]= | |||
{ |
@@ -23,7 +23,7 @@ | |||
#define _catch(f) {if((f)==-1) {printf("Error in %s:\n%s\n", #f, tjGetErrorStr()); goto bailout;}} | |||
int forcemmx=0, forcesse=0, forcesse2=0, forcesse3=0; | |||
int forcemmx=0, forcesse=0, forcesse2=0, forcesse3=0, fastupsample=0; | |||
const int _ps[BMPPIXELFORMATS]={3, 4, 3, 4, 4, 4}; | |||
const int _flags[BMPPIXELFORMATS]={0, 0, TJ_BGR, TJ_BGR, | |||
TJ_BGR|TJ_ALPHAFIRST, TJ_ALPHAFIRST}; | |||
@@ -31,8 +31,8 @@ const int _rindex[BMPPIXELFORMATS]={0, 0, 2, 2, 3, 1}; | |||
const int _gindex[BMPPIXELFORMATS]={1, 1, 1, 1, 2, 2}; | |||
const int _bindex[BMPPIXELFORMATS]={2, 2, 0, 0, 1, 3}; | |||
const char *_pfname[]={"RGB", "RGBA", "BGR", "BGRA", "ABGR", "ARGB"}; | |||
const char *_subnamel[NUMSUBOPT]={"4:4:4", "4:2:2", "4:1:1", "GRAY"}; | |||
const char *_subnames[NUMSUBOPT]={"444", "422", "411", "GRAY"}; | |||
const char *_subnamel[NUMSUBOPT]={"4:4:4", "4:2:2", "4:2:0", "GRAY"}; | |||
const char *_subnames[NUMSUBOPT]={"444", "422", "420", "GRAY"}; | |||
void printsigfig(double val, int figs) | |||
{ | |||
@@ -62,7 +62,8 @@ void dotest(unsigned char *srcbuf, int w, int h, BMPPIXELFORMAT pf, int bu, | |||
int jpgbufsize=0, i, j, tilesizex, tilesizey, numtilesx, numtilesy, ITER; | |||
unsigned long *comptilesize=NULL; | |||
int flags=(forcemmx?TJ_FORCEMMX:0)|(forcesse?TJ_FORCESSE:0) | |||
|(forcesse2?TJ_FORCESSE2:0)|(forcesse3?TJ_FORCESSE3:0); | |||
|(forcesse2?TJ_FORCESSE2:0)|(forcesse3?TJ_FORCESSE3:0) | |||
|(fastupsample?TJ_FASTUPSAMPLE:0); | |||
int ps=_ps[pf]; | |||
int pitch=w*ps; | |||
@@ -294,6 +295,9 @@ int main(int argc, char *argv[]) | |||
printf(" Force MMX, SSE, or SSE2 code paths in Intel codec\n\n"); | |||
printf(" [-rgb | -bgr | -rgba | -bgra | -abgr | -argb]\n"); | |||
printf(" Test the specified color conversion path in the codec (default: BGR)\n\n"); | |||
printf(" [-fastupsample]\n"); | |||
printf(" Use fast, inaccurate upsampling code to perform 4:2:2 and 4:2:0\n\n"); | |||
printf(" YUV decoding in libjpeg decompressor\n"); | |||
printf(" [-quiet]\n"); | |||
printf(" Output in tabular rather than verbose format\n\n"); | |||
printf(" NOTE: If the quality is specified as a range, i.e. 90-100, a separate\n"); | |||
@@ -335,6 +339,11 @@ int main(int argc, char *argv[]) | |||
printf("Using MMX code in Intel compressor\n"); | |||
forcemmx=1; | |||
} | |||
if(!stricmp(argv[i], "-fastupsample")) | |||
{ | |||
printf("Using fast upsampling code\n"); | |||
fastupsample=1; | |||
} | |||
if(!stricmp(argv[i], "-rgb")) pf=BMP_RGB; | |||
if(!stricmp(argv[i], "-rgba")) pf=BMP_RGBA; | |||
if(!stricmp(argv[i], "-bgr")) pf=BMP_BGR; | |||
@@ -369,7 +378,7 @@ int main(int argc, char *argv[]) | |||
dotest(bmpbuf, w, h, pf, bu, TJ_GRAYSCALE, i, argv[1], dotile, useppm, quiet); | |||
if(quiet) printf("\n"); | |||
for(i=hiqual; i>=qual; i--) | |||
dotest(bmpbuf, w, h, pf, bu, TJ_411, i, argv[1], dotile, useppm, quiet); | |||
dotest(bmpbuf, w, h, pf, bu, TJ_420, i, argv[1], dotile, useppm, quiet); | |||
if(quiet) printf("\n"); | |||
for(i=hiqual; i>=qual; i--) | |||
dotest(bmpbuf, w, h, pf, bu, TJ_422, i, argv[1], dotile, useppm, quiet); |
@@ -1,5 +1,6 @@ | |||
/* Copyright (C)2004 Landmark Graphics Corporation | |||
* Copyright (C)2005, 2006 Sun Microsystems, Inc. | |||
* Copyright (C)2009 D. R. Commander | |||
* | |||
* This library is free software and may be redistributed and/or modified under | |||
* the terms of the wxWindows Library License, Version 3.1 or (at your option) | |||
@@ -23,7 +24,7 @@ | |||
/* Subsampling */ | |||
#define NUMSUBOPT 4 | |||
enum {TJ_444=0, TJ_422, TJ_411, TJ_GRAYSCALE}; | |||
enum {TJ_444=0, TJ_422, TJ_420, TJ_GRAYSCALE}; | |||
/* Flags */ | |||
#define TJ_BGR 1 | |||
@@ -33,6 +34,7 @@ enum {TJ_444=0, TJ_422, TJ_411, TJ_GRAYSCALE}; | |||
#define TJ_FORCESSE2 32 /* Force IPP to use SSE2 code (useful if auto-detect is not working properly) */ | |||
#define TJ_ALPHAFIRST 64 /* BGR buffer is ABGR and RGB buffer is ARGB */ | |||
#define TJ_FORCESSE3 128 /* Force IPP to use SSE3 code (useful if auto-detect is not working properly) */ | |||
#define TJ_FASTUPSAMPLE 256 /* Use fast, inaccurate 4:2:2 and 4:2:0 YUV upsampling routines in libjpeg decompressor */ | |||
typedef void* tjhandle; | |||
@@ -86,14 +88,14 @@ DLLEXPORT tjhandle DLLCALL tjInitCompress(void); | |||
the appropriate size for this buffer based on the image width and height. | |||
[OUTPUT] size = pointer to unsigned long which receives the size (in bytes) | |||
of the compressed image | |||
[INPUT] jpegsubsamp = Specifies either 4:1:1, 4:2:2, or 4:4:4 subsampling. | |||
[INPUT] jpegsubsamp = Specifies either 4:2:0, 4:2:2, or 4:4:4 subsampling. | |||
When the image is converted from the RGB to YCbCr colorspace as part of the | |||
JPEG compression process, every other Cb and Cr (chrominance) pixel can be | |||
discarded to produce a smaller image with little perceptible loss of | |||
image clarity (the human eye is more sensitive to small changes in | |||
brightness than small changes in color.) | |||
TJ_411: 4:1:1 subsampling. Discards every other Cb, Cr pixel in both | |||
TJ_420: 4:2:0 subsampling. Discards every other Cb, Cr pixel in both | |||
horizontal and vertical directions. | |||
TJ_422: 4:2:2 subsampling. Discards every other Cb, Cr pixel only in | |||
the horizontal direction. |
@@ -1,5 +1,6 @@ | |||
/* Copyright (C)2004 Landmark Graphics Corporation | |||
* Copyright (C)2005 Sun Microsystems, Inc. | |||
* Copyright (C)2009 D. R. Commander | |||
* | |||
* This library is free software and may be redistributed and/or modified under | |||
* the terms of the wxWindows Library License, Version 3.1 or (at your option) | |||
@@ -320,6 +321,7 @@ DLLEXPORT int DLLCALL tjDecompress(tjhandle h, | |||
#else | |||
#error "TurboJPEG requires JPEG colorspace extensions" | |||
#endif | |||
if(flags&TJ_FASTUPSAMPLE) j->dinfo.do_fancy_upsampling=FALSE; | |||
jpeg_start_decompress(&j->dinfo); | |||
while(j->dinfo.output_scanline<j->dinfo.output_height) |