* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1997, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2009-2011, 2014-2016, 2018, D. R. Commander.
+ * Copyright (C) 2009-2011, 2014-2016, 2018-2019, D. R. Commander.
* Copyright (C) 2015, Matthieu Darbois.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
put_buffer = (put_buffer << size) | code; \
}
+#if SIZEOF_SIZE_T != 8 && !defined(_WIN64)
+
#define CHECKBUF15() { \
if (put_bits > 15) { \
EMIT_BYTE() \
} \
}
+#endif
+
#define CHECKBUF31() { \
if (put_bits > 31) { \
EMIT_BYTE() \
*/
master->pass_type = output_pass;
master->pass_number++;
- /*FALLTHROUGH*/
#endif
+ /*FALLTHROUGH*/
case output_pass:
/* Do a data-output pass. */
/* We need not repeat per-scan setup if prior optimization pass did it. */
* Copyright (C) 1994-1996, Thomas G. Lane.
* Modified 2009-2012 by Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2011, 2014, 2016, D. R. Commander.
+ * Copyright (C) 2011, 2014, 2016, 2019, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
extern void *malloc(size_t size);
extern void free(void *ptr);
#endif
+void jpeg_mem_dest_tj(j_compress_ptr cinfo, unsigned char **outbuffer,
+ unsigned long *outsize, boolean alloc);
#define OUTPUT_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */
* Copyright (C) 1994-1996, Thomas G. Lane.
* Modified 2009-2011 by Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2011, 2016, D. R. Commander.
+ * Copyright (C) 2011, 2016, 2019, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
#include "jpeglib.h"
#include "jerror.h"
+void jpeg_mem_src_tj(j_decompress_ptr cinfo, const unsigned char *inbuffer,
+ unsigned long insize);
+
/*
* Initialize source --- called by jpeg_read_header
#define PACK_TWO_PIXELS_LE(l, r) ((r << 16) | l)
#define PACK_TWO_PIXELS_BE(l, r) ((l << 16) | r)
-#define PACK_NEED_ALIGNMENT(ptr) (((size_t)(ptr)) & 3)
-
#define WRITE_TWO_PIXELS_LE(addr, pixels) { \
((INT16 *)(addr))[0] = (INT16)(pixels); \
((INT16 *)(addr))[1] = (INT16)((pixels) >> 16); \
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
* libjpeg-turbo Modifications:
- * Copyright (C)2016, 2018 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2016, 2018-2019 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:
#include "./md5.h"
-char *MD5End(MD5_CTX *ctx, char *buf)
+static char *MD5End(MD5_CTX *ctx, char *buf)
{
int i;
unsigned char digest[LENGTH];
off_t n;
MD5Init(&ctx);
-#if _WIN32
+#ifdef _WIN32
f = _open(filename, O_RDONLY | O_BINARY);
#else
f = open(filename, O_RDONLY);
return 0;
return (MD5End(&ctx, buf));
}
-
-char *MD5Data(const void *data, unsigned int len, char *buf)
-{
- MD5_CTX ctx;
-
- MD5Init(&ctx);
- MD5Update(&ctx, (unsigned char *)data, len);
- return (MD5End(&ctx, buf));
-}
#define M_SOI 0xD8 /* Start Of Image (beginning of datastream) */
#define M_EOI 0xD9 /* End Of Image (end of datastream) */
#define M_SOS 0xDA /* Start Of Scan (begins compressed data) */
-#define M_APP0 0xE0 /* Application-specific marker, type N */
#define M_APP12 0xEC /* (we don't bother to list all 16 APPn's) */
#define M_COM 0xFE /* COMment */
double benchTime = 5.0, warmup = 1.0;
-char *formatName(int subsamp, int cs, char *buf)
+static char *formatName(int subsamp, int cs, char *buf)
{
if (cs == TJCS_YCbCr)
return (char *)subNameLong[subsamp];
}
-char *sigfig(double val, int figs, char *buf, int len)
+static char *sigfig(double val, int figs, char *buf, int len)
{
char format[80];
int digitsAfterDecimal = figs - (int)ceil(log10(fabs(val)));
/* Custom DCT filter which produces a negative of the image */
-int dummyDCTFilter(short *coeffs, tjregion arrayRegion, tjregion planeRegion,
- int componentIndex, int transformIndex,
- tjtransform *transform)
+static int dummyDCTFilter(short *coeffs, tjregion arrayRegion,
+ tjregion planeRegion, int componentIndex,
+ int transformIndex, tjtransform *transform)
{
int i;
/* Decompression test */
-int decomp(unsigned char *srcBuf, unsigned char **jpegBuf,
- unsigned long *jpegSize, unsigned char *dstBuf, int w, int h,
- int subsamp, int jpegQual, char *fileName, int tilew, int tileh)
+static int decomp(unsigned char *srcBuf, unsigned char **jpegBuf,
+ unsigned long *jpegSize, unsigned char *dstBuf, int w, int h,
+ int subsamp, int jpegQual, char *fileName, int tilew,
+ int tileh)
{
- char tempStr[1024], sizeStr[20] = "\0", qualStr[13] = "\0", *ptr;
+ char tempStr[1024], sizeStr[24] = "\0", qualStr[13] = "\0", *ptr;
FILE *file = NULL;
tjhandle handle = NULL;
int row, col, iter = 0, dstBufAlloc = 0, retval = 0;
if (!doWrite) goto bailout;
if (sf.num != 1 || sf.denom != 1)
- snprintf(sizeStr, 20, "%d_%d", sf.num, sf.denom);
+ snprintf(sizeStr, 24, "%d_%d", sf.num, sf.denom);
else if (tilew != w || tileh != h)
- snprintf(sizeStr, 20, "%dx%d", tilew, tileh);
- else snprintf(sizeStr, 20, "full");
+ snprintf(sizeStr, 24, "%dx%d", tilew, tileh);
+ else snprintf(sizeStr, 24, "full");
if (decompOnly)
snprintf(tempStr, 1024, "%s_%s.%s", fileName, sizeStr, ext);
else
}
-int fullTest(unsigned char *srcBuf, int w, int h, int subsamp, int jpegQual,
- char *fileName)
+static int fullTest(unsigned char *srcBuf, int w, int h, int subsamp,
+ int jpegQual, char *fileName)
{
char tempStr[1024], tempStr2[80];
FILE *file = NULL;
}
-int decompTest(char *fileName)
+static int decompTest(char *fileName)
{
FILE *file = NULL;
tjhandle handle = NULL;
}
-void usage(char *progName)
+static void usage(char *progName)
{
int i;
else if (!strcasecmp(argv[i], "-copynone"))
xformOpt |= TJXOPT_COPYNONE;
else if (!strcasecmp(argv[i], "-benchtime") && i < argc - 1) {
- double temp = atof(argv[++i]);
+ double tempd = atof(argv[++i]);
- if (temp > 0.0) benchTime = temp;
+ if (tempd > 0.0) benchTime = tempd;
else usage(argv[0]);
} else if (!strcasecmp(argv[i], "-warmup") && i < argc - 1) {
- double temp = atof(argv[++i]);
+ double tempd = atof(argv[++i]);
- if (temp >= 0.0) warmup = temp;
+ if (tempd >= 0.0) warmup = tempd;
else usage(argv[0]);
printf("Warmup time = %.1f seconds\n\n", warmup);
} else if (!strcasecmp(argv[i], "-alloc"))
printf("Testing YUV planar encoding/decoding\n\n");
doYUV = 1;
} else if (!strcasecmp(argv[i], "-yuvpad") && i < argc - 1) {
- int temp = atoi(argv[++i]);
+ int tempi = atoi(argv[++i]);
- if (temp >= 1) yuvPad = temp;
+ if (tempi >= 1) yuvPad = tempi;
} else if (!strcasecmp(argv[i], "-subsamp") && i < argc - 1) {
i++;
if (toupper(argv[i][0]) == 'G') subsamp = TJSAMP_GRAY;
else {
- int temp = atoi(argv[i]);
+ int tempi = atoi(argv[i]);
- switch (temp) {
+ switch (tempi) {
case 444: subsamp = TJSAMP_444; break;
case 422: subsamp = TJSAMP_422; break;
case 440: subsamp = TJSAMP_440; break;
/*
- * Copyright (C)2011-2012, 2014-2015, 2017 D. R. Commander.
- * All Rights Reserved.
+ * Copyright (C)2011-2012, 2014-2015, 2017, 2019 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:
/* DCT filter example. This produces a negative of the image. */
-int customFilter(short *coeffs, tjregion arrayRegion, tjregion planeRegion,
- int componentIndex, int transformIndex,
- tjtransform *transform)
+static int customFilter(short *coeffs, tjregion arrayRegion,
+ tjregion planeRegion, int componentIndex,
+ int transformIndex, tjtransform *transform)
{
int i;
}
-void usage(char *programName)
+static void usage(char *programName)
{
int i;
if (!strcasecmp(outFormat, "jpg")) {
/* Output image format is JPEG. Compress the uncompressed image. */
- unsigned char *jpegBuf = NULL; /* Dynamically allocate the JPEG buffer */
unsigned long jpegSize = 0;
+ jpegBuf = NULL; /* Dynamically allocate the JPEG buffer */
+
if (outQual < 0)
outQual = DEFAULT_QUALITY;
printf(", %s subsampling, quality = %d\n", subsampName[outSubsamp],
/*
- * Copyright (C)2009-2014, 2017-2018 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2009-2014, 2017-2019 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:
#endif
-void usage(char *progName)
+static void usage(char *progName)
{
printf("\nUSAGE: %s [options]\n\n", progName);
printf("Options:\n");
#define BAILOUT() { exitStatus = -1; goto bailout; }
-void initBuf(unsigned char *buf, int w, int h, int pf, int flags)
+static void initBuf(unsigned char *buf, int w, int h, int pf, int flags)
{
int roffset = tjRedOffset[pf];
int goffset = tjGreenOffset[pf];
}
-int checkBuf(unsigned char *buf, int w, int h, int pf, int subsamp,
- tjscalingfactor sf, int flags)
+static int checkBuf(unsigned char *buf, int w, int h, int pf, int subsamp,
+ tjscalingfactor sf, int flags)
{
int roffset = tjRedOffset[pf];
int goffset = tjGreenOffset[pf];
#define PAD(v, p) ((v + (p) - 1) & (~((p) - 1)))
-int checkBufYUV(unsigned char *buf, int w, int h, int subsamp,
- tjscalingfactor sf)
+static int checkBufYUV(unsigned char *buf, int w, int h, int subsamp,
+ tjscalingfactor sf)
{
int row, col;
int hsf = tjMCUWidth[subsamp] / 8, vsf = tjMCUHeight[subsamp] / 8;
}
}
if (subsamp != TJSAMP_GRAY) {
- int halfway = 16 / vsf * sf.num / sf.denom;
+ halfway = 16 / vsf * sf.num / sf.denom;
for (row = 0; row < ch; row++) {
for (col = 0; col < cw; col++) {
}
-void writeJPEG(unsigned char *jpegBuf, unsigned long jpegSize, char *filename)
+static void writeJPEG(unsigned char *jpegBuf, unsigned long jpegSize,
+ char *filename)
{
FILE *file = fopen(filename, "wb");
}
-void compTest(tjhandle handle, unsigned char **dstBuf, unsigned long *dstSize,
- int w, int h, int pf, char *basename, int subsamp, int jpegQual,
- int flags)
+static void compTest(tjhandle handle, unsigned char **dstBuf,
+ unsigned long *dstSize, int w, int h, int pf,
+ char *basename, int subsamp, int jpegQual, int flags)
{
char tempStr[1024];
unsigned char *srcBuf = NULL, *yuvBuf = NULL;
}
-void _decompTest(tjhandle handle, unsigned char *jpegBuf,
- unsigned long jpegSize, int w, int h, int pf, char *basename,
- int subsamp, int flags, tjscalingfactor sf)
+static void _decompTest(tjhandle handle, unsigned char *jpegBuf,
+ unsigned long jpegSize, int w, int h, int pf,
+ char *basename, int subsamp, int flags,
+ tjscalingfactor sf)
{
unsigned char *dstBuf = NULL, *yuvBuf = NULL;
int _hdrw = 0, _hdrh = 0, _hdrsubsamp = -1;
}
-void decompTest(tjhandle handle, unsigned char *jpegBuf,
- unsigned long jpegSize, int w, int h, int pf, char *basename,
- int subsamp, int flags)
+static void decompTest(tjhandle handle, unsigned char *jpegBuf,
+ unsigned long jpegSize, int w, int h, int pf,
+ char *basename, int subsamp, int flags)
{
int i, n = 0;
tjscalingfactor *sf = tjGetScalingFactors(&n);
}
-void doTest(int w, int h, const int *formats, int nformats, int subsamp,
- char *basename)
+static void doTest(int w, int h, const int *formats, int nformats, int subsamp,
+ char *basename)
{
tjhandle chandle = NULL, dhandle = NULL;
unsigned char *dstBuf = NULL;
}
-void bufSizeTest(void)
+static void bufSizeTest(void)
{
int w, h, i, subsamp;
unsigned char *srcBuf = NULL, *dstBuf = NULL;
}
-void initBitmap(unsigned char *buf, int width, int pitch, int height, int pf,
- int flags)
+static void initBitmap(unsigned char *buf, int width, int pitch, int height,
+ int pf, int flags)
{
int roffset = tjRedOffset[pf];
int goffset = tjGreenOffset[pf];
}
-int cmpBitmap(unsigned char *buf, int width, int pitch, int height, int pf,
- int flags, int gray2rgb)
+static int cmpBitmap(unsigned char *buf, int width, int pitch, int height,
+ int pf, int flags, int gray2rgb)
{
int roffset = tjRedOffset[pf];
int goffset = tjGreenOffset[pf];
}
-int doBmpTest(const char *ext, int width, int align, int height, int pf,
- int flags)
+static int doBmpTest(const char *ext, int width, int align, int height, int pf,
+ int flags)
{
char filename[80], *md5sum, md5buf[65];
int ps = tjPixelSize[pf], pitch = PAD(width * ps, align), loadWidth = 0,
}
-int bmpTest(void)
+static int bmpTest(void)
{
int align, width = 35, height = 39, format;
/*
- * Copyright (C)2011 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2011, 2019 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:
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include "tjutil.h"
+
#ifdef _WIN32
#include <windows.h>
/*
- * Copyright (C)2011-2018 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2011-2019 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:
#include <jni.h>
#include "java/org_libjpegturbo_turbojpeg_TJCompressor.h"
#include "java/org_libjpegturbo_turbojpeg_TJDecompressor.h"
+#include "java/org_libjpegturbo_turbojpeg_TJTransformer.h"
#include "java/org_libjpegturbo_turbojpeg_TJ.h"
-#define PAD(v, p) ((v + (p) - 1) & (~((p) - 1)))
-
#define BAILIF0(f) { \
if (!(f) || (*env)->ExceptionCheck(env)) { \
goto bailout; \
cArray = NULL; \
}
-int ProcessSystemProperties(JNIEnv *env)
+static int ProcessSystemProperties(JNIEnv *env)
{
jclass cls;
jmethodID mid;
return;
}
-JNIEXPORT void JNICALL TJCompressor_encodeYUV_12
+static void JNICALL TJCompressor_encodeYUV_12
(JNIEnv *env, jobject obj, jarray src, jint srcElementSize, jint width,
jint pitch, jint height, jint pf, jbyteArray dst, jint subsamp, jint flags)
{
}
-int my_read_markers(j_decompress_ptr dinfo)
+static int my_read_markers(j_decompress_ptr dinfo)
{
return JPEG_REACHED_SOS;
}
-void my_reset_marker_reader(j_decompress_ptr dinfo)
+static void my_reset_marker_reader(j_decompress_ptr dinfo)
{
}