if((hnd=tjInitDecompress())==NULL) _throwtj("executing tjInitDecompress()");
if(tjDecompressHeader2(hnd, jpegbuf, jpgbufsize, &w, &h, &jpegsub)==-1)
_throwtj("executing tjDecompressHeader2()");
-
- hsf=_hsf[jpegsub], vsf=_vsf[jpegsub];
- pw=PAD(w, hsf), ph=PAD(h, vsf);
- cw=pw/hsf, ch=ph/vsf;
- ypitch=PAD(pw, 4), uvpitch=PAD(cw, 4);
- yuvsize=ypitch*ph + (jpegsub==TJ_GRAYSCALE? 0:uvpitch*ch*2);
-
- pitch=w*ps;
+ if(tjDestroy(hnd)==-1) _throwtj("executing tjDestroy()");
+ hnd=NULL;
- if(quiet)
+ if(quiet==1)
{
- printf("All performance values in Mpixels/sec\n\n");
+ printf("\nAll performance values in Mpixels/sec\n\n");
- printf("Bitmap\tBitmap\tImage Size\tDecomp\n"),
- printf("Format\tOrder\t X Y \tPerf\n\n");
- printf("%s\t%s\t%-4d %-4d\t", _pfname[pf], bu?"BU":"TD", w, h);
+ printf("Bitmap\tBitmap\tJPEG\tImage Size\tDecomp\n"),
+ printf("Format\tOrder\tFormat\t X Y \tPerf\n\n");
+ printf("%s\t%s\t%s\t%-4d %-4d\t", _pfname[pf], bu?"BU":"TD",
+ _subnamel[jpegsub], w, h);
}
-
- if((rgbbuf=(unsigned char *)malloc(max(yuvsize, pitch*h)))==NULL)
- _throwunix("allocating image buffer");
-
- if(!quiet)
+ else
{
if(yuv==YUVDECODE)
printf("\n>>>>> JPEG --> YUV %s <<<<<\n", _subnamel[jpegsub]);
int main(int argc, char *argv[])
{
- unsigned char *bmpbuf=NULL; int w, h, i, useppm=0;
- int qual, dotile=0, quiet=0, hiqual=-1; char *temp;
- int pf=BMP_BGR;
- int bu=0, minarg=2;
+ unsigned char *bmpbuf=NULL; int w, h, i;
+ int qual, hiqual=-1; char *temp;
+ int minarg=2;
- printf("\n");
-
if(argc<minarg) usage(argv[0]);
temp=strrchr(argv[1], '.');
if(!stricmp(argv[i], "-argb")) pf=BMP_ARGB;
if(!stricmp(argv[i], "-bottomup")) bu=1;
if(!stricmp(argv[i], "-quiet")) quiet=1;
+ if(!stricmp(argv[i], "-qq")) quiet=2;
+ if(!stricmp(argv[i], "-scale") && i<argc-1)
+ {
+ int temp1=0, temp2=0;
+ if(sscanf(argv[++i], "%d/%d", &temp1, &temp2)!=2
+ || temp1!=1 || temp2<1 || temp2>8 || (temp2&(temp2-1))!=0)
+ usage(argv[0]);
+ scalefactor=temp2;
+ }
}
}