#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};
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)
{
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;
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");
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;
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);
/* 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)
/* 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
#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;
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.