Merge branch 'master' into dev

This commit is contained in:
DRC
2019-04-23 14:54:23 -05:00
16 changed files with 129 additions and 107 deletions

View File

@@ -45,6 +45,12 @@ approximately 2x when using the fast integer IDCT
platforms when passing invalid arguments to certain methods in the TurboJPEG platforms when passing invalid arguments to certain methods in the TurboJPEG
Java API. Java API.
2. Fixed a regression in the SIMD feature detection code, introduced by
the AVX2 SIMD extensions (2.0 beta1[1]), that was known to cause an illegal
instruction exception, in rare cases, on CPUs that lack support for CPUID leaf
07H (or on which the maximum CPUID leaf has been limited by way of a BIOS
setting.)
2.0.2 2.0.2
===== =====

View File

@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software: * This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1997, Thomas G. Lane. * Copyright (C) 1991-1997, Thomas G. Lane.
* libjpeg-turbo Modifications: * 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. * Copyright (C) 2015, Matthieu Darbois.
* Copyright (C) 2018, Matthias Räncker. * Copyright (C) 2018, Matthias Räncker.
* For conditions of distribution and use, see the accompanying README.ijg * For conditions of distribution and use, see the accompanying README.ijg
@@ -363,6 +363,8 @@ dump_buffer(working_state *state)
put_buffer = (put_buffer << size) | code; \ put_buffer = (put_buffer << size) | code; \
} }
#if SIZEOF_SIZE_T != 8 && !defined(_WIN64)
#define CHECKBUF15() { \ #define CHECKBUF15() { \
if (put_bits > 15) { \ if (put_bits > 15) { \
EMIT_BYTE() \ EMIT_BYTE() \
@@ -370,6 +372,8 @@ dump_buffer(working_state *state)
} \ } \
} }
#endif
#define CHECKBUF31() { \ #define CHECKBUF31() { \
if (put_bits > 31) { \ if (put_bits > 31) { \
EMIT_BYTE() \ EMIT_BYTE() \

View File

@@ -492,8 +492,8 @@ prepare_for_pass(j_compress_ptr cinfo)
*/ */
master->pass_type = output_pass; master->pass_type = output_pass;
master->pass_number++; master->pass_number++;
/*FALLTHROUGH*/
#endif #endif
/*FALLTHROUGH*/
case output_pass: case output_pass:
/* Do a data-output pass. */ /* Do a data-output pass. */
/* We need not repeat per-scan setup if prior optimization pass did it. */ /* We need not repeat per-scan setup if prior optimization pass did it. */

View File

@@ -5,7 +5,7 @@
* Copyright (C) 1994-1996, Thomas G. Lane. * Copyright (C) 1994-1996, Thomas G. Lane.
* Modified 2009-2012 by Guido Vollbeding. * Modified 2009-2012 by Guido Vollbeding.
* libjpeg-turbo Modifications: * 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 * For conditions of distribution and use, see the accompanying README.ijg
* file. * file.
* *
@@ -27,6 +27,8 @@
extern void *malloc(size_t size); extern void *malloc(size_t size);
extern void free(void *ptr); extern void free(void *ptr);
#endif #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 */ #define OUTPUT_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */

View File

@@ -5,7 +5,7 @@
* Copyright (C) 1994-1996, Thomas G. Lane. * Copyright (C) 1994-1996, Thomas G. Lane.
* Modified 2009-2011 by Guido Vollbeding. * Modified 2009-2011 by Guido Vollbeding.
* libjpeg-turbo Modifications: * 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 * For conditions of distribution and use, see the accompanying README.ijg
* file. * file.
* *
@@ -23,6 +23,9 @@
#include "jpeglib.h" #include "jpeglib.h"
#include "jerror.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 * Initialize source --- called by jpeg_read_header

View File

@@ -429,8 +429,6 @@ h2v2_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
#define PACK_TWO_PIXELS_LE(l, r) ((r << 16) | l) #define PACK_TWO_PIXELS_LE(l, r) ((r << 16) | l)
#define PACK_TWO_PIXELS_BE(l, r) ((l << 16) | r) #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) { \ #define WRITE_TWO_PIXELS_LE(addr, pixels) { \
((INT16 *)(addr))[0] = (INT16)(pixels); \ ((INT16 *)(addr))[0] = (INT16)(pixels); \
((INT16 *)(addr))[1] = (INT16)((pixels) >> 16); \ ((INT16 *)(addr))[1] = (INT16)((pixels) >> 16); \

View File

@@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ---------------------------------------------------------------------------- * ----------------------------------------------------------------------------
* libjpeg-turbo Modifications: * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
@@ -56,7 +56,7 @@
#include "./md5.h" #include "./md5.h"
char *MD5End(MD5_CTX *ctx, char *buf) static char *MD5End(MD5_CTX *ctx, char *buf)
{ {
int i; int i;
unsigned char digest[LENGTH]; unsigned char digest[LENGTH];
@@ -89,7 +89,7 @@ char *MD5FileChunk(const char *filename, char *buf, off_t ofs, off_t len)
off_t n; off_t n;
MD5Init(&ctx); MD5Init(&ctx);
#if _WIN32 #ifdef _WIN32
f = _open(filename, O_RDONLY | O_BINARY); f = _open(filename, O_RDONLY | O_BINARY);
#else #else
f = open(filename, O_RDONLY); f = open(filename, O_RDONLY);
@@ -123,12 +123,3 @@ char *MD5FileChunk(const char *filename, char *buf, off_t ofs, off_t len)
return 0; return 0;
return (MD5End(&ctx, buf)); 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));
}

View File

@@ -118,7 +118,6 @@ read_2_bytes(void)
#define M_SOI 0xD8 /* Start Of Image (beginning of datastream) */ #define M_SOI 0xD8 /* Start Of Image (beginning of datastream) */
#define M_EOI 0xD9 /* End Of Image (end of datastream) */ #define M_EOI 0xD9 /* End Of Image (end of datastream) */
#define M_SOS 0xDA /* Start Of Scan (begins compressed data) */ #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_APP12 0xEC /* (we don't bother to list all 16 APPn's) */
#define M_COM 0xFE /* COMment */ #define M_COM 0xFE /* COMment */

View File

@@ -51,29 +51,14 @@ EXTN(jpeg_simd_cpu_support):
xor eax, edx xor eax, edx
jz near .return ; CPUID is not supported jz near .return ; CPUID is not supported
; Check for MMX instruction support ; Check whether CPUID leaf 07H is supported
; (leaf 07H is used to check for AVX2 instruction support)
xor eax, eax xor eax, eax
cpuid cpuid
test eax, eax test eax, eax
jz near .return jz near .return
cmp eax, 7
xor eax, eax jl short .no_avx2 ; Maximum leaf < 07H
inc eax
cpuid
mov eax, edx ; eax = Standard feature flags
test eax, 1<<23 ; bit23:MMX
jz short .no_mmx
or edi, byte JSIMD_MMX
.no_mmx:
test eax, 1<<25 ; bit25:SSE
jz short .no_sse
or edi, byte JSIMD_SSE
.no_sse:
test eax, 1<<26 ; bit26:SSE2
jz short .no_sse2
or edi, byte JSIMD_SSE2
.no_sse2:
; Check for AVX2 instruction support ; Check for AVX2 instruction support
mov eax, 7 mov eax, 7
@@ -102,6 +87,26 @@ EXTN(jpeg_simd_cpu_support):
or edi, JSIMD_AVX2 or edi, JSIMD_AVX2
.no_avx2: .no_avx2:
; Check CPUID leaf 01H for MMX, SSE, and SSE2 support
xor eax, eax
inc eax
cpuid
mov eax, edx ; eax = Standard feature flags
; Check for MMX instruction support
test eax, 1<<23 ; bit23:MMX
jz short .no_mmx
or edi, byte JSIMD_MMX
.no_mmx:
test eax, 1<<25 ; bit25:SSE
jz short .no_sse
or edi, byte JSIMD_SSE
.no_sse:
test eax, 1<<26 ; bit26:SSE2
jz short .no_sse2
or edi, byte JSIMD_SSE2
.no_sse2:
; Check for 3DNow! instruction support ; Check for 3DNow! instruction support
mov eax, 0x80000000 mov eax, 0x80000000
cpuid cpuid

View File

@@ -38,14 +38,23 @@ EXTN(jpeg_simd_cpu_support):
xor rdi, rdi ; simd support flag xor rdi, rdi ; simd support flag
; Assume that all x86-64 processors support SSE & SSE2 instructions
or rdi, JSIMD_SSE2
or rdi, JSIMD_SSE
; Check whether CPUID leaf 07H is supported
; (leaf 07H is used to check for AVX2 instruction support)
mov rax, 0
cpuid
cmp rax, 7
jl short .return ; Maximum leaf < 07H
; Check for AVX2 instruction support ; Check for AVX2 instruction support
mov rax, 7 mov rax, 7
xor rcx, rcx xor rcx, rcx
cpuid cpuid
mov rax, rbx ; rax = Extended feature flags mov rax, rbx ; rax = Extended feature flags
or rdi, JSIMD_SSE2
or rdi, JSIMD_SSE
test rax, 1<<5 ; bit5:AVX2 test rax, 1<<5 ; bit5:AVX2
jz short .return jz short .return

View File

@@ -95,7 +95,7 @@ int (*customFilter) (short *, tjregion, tjregion, int, int, tjtransform *);
double benchTime = 5.0, warmup = 1.0; 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) if (cs == TJCS_YCbCr)
return (char *)subNameLong[subsamp]; return (char *)subNameLong[subsamp];
@@ -107,7 +107,7 @@ char *formatName(int subsamp, int cs, char *buf)
} }
char *sigfig(double val, int figs, char *buf, int len) static char *sigfig(double val, int figs, char *buf, int len)
{ {
char format[80]; char format[80];
int digitsAfterDecimal = figs - (int)ceil(log10(fabs(val))); int digitsAfterDecimal = figs - (int)ceil(log10(fabs(val)));
@@ -122,9 +122,9 @@ char *sigfig(double val, int figs, char *buf, int len)
/* Custom DCT filter which produces a negative of the image */ /* Custom DCT filter which produces a negative of the image */
int dummyDCTFilter(short *coeffs, tjregion arrayRegion, tjregion planeRegion, static int dummyDCTFilter(short *coeffs, tjregion arrayRegion,
int componentIndex, int transformIndex, tjregion planeRegion, int componentIndex,
tjtransform *transform) int transformIndex, tjtransform *transform)
{ {
int i; int i;
@@ -135,11 +135,12 @@ int dummyDCTFilter(short *coeffs, tjregion arrayRegion, tjregion planeRegion,
/* Decompression test */ /* Decompression test */
int decomp(unsigned char *srcBuf, unsigned char **jpegBuf, static int decomp(unsigned char *srcBuf, unsigned char **jpegBuf,
unsigned long *jpegSize, unsigned char *dstBuf, int w, int h, unsigned long *jpegSize, unsigned char *dstBuf, int w, int h,
int subsamp, int jpegQual, char *fileName, int tilew, int tileh) 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; FILE *file = NULL;
tjhandle handle = NULL; tjhandle handle = NULL;
int row, col, iter = 0, dstBufAlloc = 0, retval = 0; int row, col, iter = 0, dstBufAlloc = 0, retval = 0;
@@ -249,10 +250,10 @@ int decomp(unsigned char *srcBuf, unsigned char **jpegBuf,
if (!doWrite) goto bailout; if (!doWrite) goto bailout;
if (sf.num != 1 || sf.denom != 1) 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) else if (tilew != w || tileh != h)
snprintf(sizeStr, 20, "%dx%d", tilew, tileh); snprintf(sizeStr, 24, "%dx%d", tilew, tileh);
else snprintf(sizeStr, 20, "full"); else snprintf(sizeStr, 24, "full");
if (decompOnly) if (decompOnly)
snprintf(tempStr, 1024, "%s_%s.%s", fileName, sizeStr, ext); snprintf(tempStr, 1024, "%s_%s.%s", fileName, sizeStr, ext);
else else
@@ -303,8 +304,8 @@ bailout:
} }
int fullTest(unsigned char *srcBuf, int w, int h, int subsamp, int jpegQual, static int fullTest(unsigned char *srcBuf, int w, int h, int subsamp,
char *fileName) int jpegQual, char *fileName)
{ {
char tempStr[1024], tempStr2[80]; char tempStr[1024], tempStr2[80];
FILE *file = NULL; FILE *file = NULL;
@@ -504,7 +505,7 @@ bailout:
} }
int decompTest(char *fileName) static int decompTest(char *fileName)
{ {
FILE *file = NULL; FILE *file = NULL;
tjhandle handle = NULL; tjhandle handle = NULL;
@@ -724,7 +725,7 @@ bailout:
} }
void usage(char *progName) static void usage(char *progName)
{ {
int i; int i;
@@ -902,14 +903,14 @@ int main(int argc, char *argv[])
else if (!strcasecmp(argv[i], "-copynone")) else if (!strcasecmp(argv[i], "-copynone"))
xformOpt |= TJXOPT_COPYNONE; xformOpt |= TJXOPT_COPYNONE;
else if (!strcasecmp(argv[i], "-benchtime") && i < argc - 1) { 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 usage(argv[0]);
} else if (!strcasecmp(argv[i], "-warmup") && i < argc - 1) { } 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]); else usage(argv[0]);
printf("Warmup time = %.1f seconds\n\n", warmup); printf("Warmup time = %.1f seconds\n\n", warmup);
} else if (!strcasecmp(argv[i], "-alloc")) } else if (!strcasecmp(argv[i], "-alloc"))
@@ -920,16 +921,16 @@ int main(int argc, char *argv[])
printf("Testing YUV planar encoding/decoding\n\n"); printf("Testing YUV planar encoding/decoding\n\n");
doYUV = 1; doYUV = 1;
} else if (!strcasecmp(argv[i], "-yuvpad") && i < argc - 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) { } else if (!strcasecmp(argv[i], "-subsamp") && i < argc - 1) {
i++; i++;
if (toupper(argv[i][0]) == 'G') subsamp = TJSAMP_GRAY; if (toupper(argv[i][0]) == 'G') subsamp = TJSAMP_GRAY;
else { else {
int temp = atoi(argv[i]); int tempi = atoi(argv[i]);
switch (temp) { switch (tempi) {
case 444: subsamp = TJSAMP_444; break; case 444: subsamp = TJSAMP_444; break;
case 422: subsamp = TJSAMP_422; break; case 422: subsamp = TJSAMP_422; break;
case 440: subsamp = TJSAMP_440; break; case 440: subsamp = TJSAMP_440; break;

View File

@@ -1,6 +1,6 @@
/* /*
* Copyright (C)2011-2012, 2014-2015, 2017 D. R. Commander. * Copyright (C)2011-2012, 2014-2015, 2017, 2019 D. R. Commander.
* All Rights Reserved. * All Rights Reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
@@ -71,9 +71,9 @@ int numScalingFactors = 0;
/* DCT filter example. This produces a negative of the image. */ /* DCT filter example. This produces a negative of the image. */
int customFilter(short *coeffs, tjregion arrayRegion, tjregion planeRegion, static int customFilter(short *coeffs, tjregion arrayRegion,
int componentIndex, int transformIndex, tjregion planeRegion, int componentIndex,
tjtransform *transform) int transformIndex, tjtransform *transform)
{ {
int i; int i;
@@ -84,7 +84,7 @@ int customFilter(short *coeffs, tjregion arrayRegion, tjregion planeRegion,
} }
void usage(char *programName) static void usage(char *programName)
{ {
int i; int i;
@@ -355,9 +355,10 @@ int main(int argc, char **argv)
if (!strcasecmp(outFormat, "jpg")) { if (!strcasecmp(outFormat, "jpg")) {
/* Output image format is JPEG. Compress the uncompressed image. */ /* Output image format is JPEG. Compress the uncompressed image. */
unsigned char *jpegBuf = NULL; /* Dynamically allocate the JPEG buffer */
unsigned long jpegSize = 0; unsigned long jpegSize = 0;
jpegBuf = NULL; /* Dynamically allocate the JPEG buffer */
if (outQual < 0) if (outQual < 0)
outQual = DEFAULT_QUALITY; outQual = DEFAULT_QUALITY;
printf(", %s subsampling, quality = %d\n", subsampName[outSubsamp], printf(", %s subsampling, quality = %d\n", subsampName[outSubsamp],

View File

@@ -1,5 +1,5 @@
/* /*
* 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
@@ -46,7 +46,7 @@
#endif #endif
void usage(char *progName) static void usage(char *progName)
{ {
printf("\nUSAGE: %s [options]\n\n", progName); printf("\nUSAGE: %s [options]\n\n", progName);
printf("Options:\n"); printf("Options:\n");
@@ -96,7 +96,7 @@ int exitStatus = 0;
#define BAILOUT() { exitStatus = -1; goto bailout; } #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 roffset = tjRedOffset[pf];
int goffset = tjGreenOffset[pf]; int goffset = tjGreenOffset[pf];
@@ -174,8 +174,8 @@ void initBuf(unsigned char *buf, int w, int h, int pf, int flags)
} }
int checkBuf(unsigned char *buf, int w, int h, int pf, int subsamp, static int checkBuf(unsigned char *buf, int w, int h, int pf, int subsamp,
tjscalingfactor sf, int flags) tjscalingfactor sf, int flags)
{ {
int roffset = tjRedOffset[pf]; int roffset = tjRedOffset[pf];
int goffset = tjGreenOffset[pf]; int goffset = tjGreenOffset[pf];
@@ -270,8 +270,8 @@ bailout:
#define PAD(v, p) ((v + (p) - 1) & (~((p) - 1))) #define PAD(v, p) ((v + (p) - 1) & (~((p) - 1)))
int checkBufYUV(unsigned char *buf, int w, int h, int subsamp, static int checkBufYUV(unsigned char *buf, int w, int h, int subsamp,
tjscalingfactor sf) tjscalingfactor sf)
{ {
int row, col; int row, col;
int hsf = tjMCUWidth[subsamp] / 8, vsf = tjMCUHeight[subsamp] / 8; int hsf = tjMCUWidth[subsamp] / 8, vsf = tjMCUHeight[subsamp] / 8;
@@ -296,7 +296,7 @@ int checkBufYUV(unsigned char *buf, int w, int h, int subsamp,
} }
} }
if (subsamp != TJSAMP_GRAY) { 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 (row = 0; row < ch; row++) {
for (col = 0; col < cw; col++) { for (col = 0; col < cw; col++) {
@@ -342,7 +342,8 @@ bailout:
} }
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"); FILE *file = fopen(filename, "wb");
@@ -356,9 +357,9 @@ bailout:
} }
void compTest(tjhandle handle, unsigned char **dstBuf, unsigned long *dstSize, static void compTest(tjhandle handle, unsigned char **dstBuf,
int w, int h, int pf, char *basename, int subsamp, int jpegQual, unsigned long *dstSize, int w, int h, int pf,
int flags) char *basename, int subsamp, int jpegQual, int flags)
{ {
char tempStr[1024]; char tempStr[1024];
unsigned char *srcBuf = NULL, *yuvBuf = NULL; unsigned char *srcBuf = NULL, *yuvBuf = NULL;
@@ -414,9 +415,10 @@ bailout:
} }
void _decompTest(tjhandle handle, unsigned char *jpegBuf, static void _decompTest(tjhandle handle, unsigned char *jpegBuf,
unsigned long jpegSize, int w, int h, int pf, char *basename, unsigned long jpegSize, int w, int h, int pf,
int subsamp, int flags, tjscalingfactor sf) char *basename, int subsamp, int flags,
tjscalingfactor sf)
{ {
unsigned char *dstBuf = NULL, *yuvBuf = NULL; unsigned char *dstBuf = NULL, *yuvBuf = NULL;
int _hdrw = 0, _hdrh = 0, _hdrsubsamp = -1; int _hdrw = 0, _hdrh = 0, _hdrsubsamp = -1;
@@ -481,9 +483,9 @@ bailout:
} }
void decompTest(tjhandle handle, unsigned char *jpegBuf, static void decompTest(tjhandle handle, unsigned char *jpegBuf,
unsigned long jpegSize, int w, int h, int pf, char *basename, unsigned long jpegSize, int w, int h, int pf,
int subsamp, int flags) char *basename, int subsamp, int flags)
{ {
int i, n = 0; int i, n = 0;
tjscalingfactor *sf = tjGetScalingFactors(&n); tjscalingfactor *sf = tjGetScalingFactors(&n);
@@ -505,8 +507,8 @@ bailout:
} }
void doTest(int w, int h, const int *formats, int nformats, int subsamp, static void doTest(int w, int h, const int *formats, int nformats, int subsamp,
char *basename) char *basename)
{ {
tjhandle chandle = NULL, dhandle = NULL; tjhandle chandle = NULL, dhandle = NULL;
unsigned char *dstBuf = NULL; unsigned char *dstBuf = NULL;
@@ -552,7 +554,7 @@ bailout:
} }
void bufSizeTest(void) static void bufSizeTest(void)
{ {
int w, h, i, subsamp; int w, h, i, subsamp;
unsigned char *srcBuf = NULL, *dstBuf = NULL; unsigned char *srcBuf = NULL, *dstBuf = NULL;
@@ -633,8 +635,8 @@ bailout:
} }
void initBitmap(unsigned char *buf, int width, int pitch, int height, int pf, static void initBitmap(unsigned char *buf, int width, int pitch, int height,
int flags) int pf, int flags)
{ {
int roffset = tjRedOffset[pf]; int roffset = tjRedOffset[pf];
int goffset = tjGreenOffset[pf]; int goffset = tjGreenOffset[pf];
@@ -667,8 +669,8 @@ void initBitmap(unsigned char *buf, int width, int pitch, int height, int pf,
} }
int cmpBitmap(unsigned char *buf, int width, int pitch, int height, int pf, static int cmpBitmap(unsigned char *buf, int width, int pitch, int height,
int flags, int gray2rgb) int pf, int flags, int gray2rgb)
{ {
int roffset = tjRedOffset[pf]; int roffset = tjRedOffset[pf];
int goffset = tjGreenOffset[pf]; int goffset = tjGreenOffset[pf];
@@ -718,8 +720,8 @@ int cmpBitmap(unsigned char *buf, int width, int pitch, int height, int pf,
} }
int doBmpTest(const char *ext, int width, int align, int height, int pf, static int doBmpTest(const char *ext, int width, int align, int height, int pf,
int flags) int flags)
{ {
char filename[80], *md5sum, md5buf[65]; char filename[80], *md5sum, md5buf[65];
int ps = tjPixelSize[pf], pitch = PAD(width * ps, align), loadWidth = 0, int ps = tjPixelSize[pf], pitch = PAD(width * ps, align), loadWidth = 0,
@@ -807,7 +809,7 @@ bailout:
} }
int bmpTest(void) static int bmpTest(void)
{ {
int align, width = 35, height = 39, format; int align, width = 35, height = 39, format;

View File

@@ -1,5 +1,5 @@
/* /*
* 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
@@ -26,6 +26,8 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "tjutil.h"
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>

View File

@@ -1,5 +1,5 @@
/* /*
* 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
@@ -35,10 +35,9 @@
#include <jni.h> #include <jni.h>
#include "java/org_libjpegturbo_turbojpeg_TJCompressor.h" #include "java/org_libjpegturbo_turbojpeg_TJCompressor.h"
#include "java/org_libjpegturbo_turbojpeg_TJDecompressor.h" #include "java/org_libjpegturbo_turbojpeg_TJDecompressor.h"
#include "java/org_libjpegturbo_turbojpeg_TJTransformer.h"
#include "java/org_libjpegturbo_turbojpeg_TJ.h" #include "java/org_libjpegturbo_turbojpeg_TJ.h"
#define PAD(v, p) ((v + (p) - 1) & (~((p) - 1)))
#define BAILIF0(f) { \ #define BAILIF0(f) { \
if (!(f) || (*env)->ExceptionCheck(env)) { \ if (!(f) || (*env)->ExceptionCheck(env)) { \
goto bailout; \ goto bailout; \
@@ -104,7 +103,7 @@
cArray = NULL; \ cArray = NULL; \
} }
int ProcessSystemProperties(JNIEnv *env) static int ProcessSystemProperties(JNIEnv *env)
{ {
jclass cls; jclass cls;
jmethodID mid; jmethodID mid;
@@ -520,7 +519,7 @@ bailout:
return; return;
} }
JNIEXPORT void JNICALL TJCompressor_encodeYUV_12 static void JNICALL TJCompressor_encodeYUV_12
(JNIEnv *env, jobject obj, jarray src, jint srcElementSize, jint width, (JNIEnv *env, jobject obj, jarray src, jint srcElementSize, jint width,
jint pitch, jint height, jint pf, jbyteArray dst, jint subsamp, jint flags) jint pitch, jint height, jint pf, jbyteArray dst, jint subsamp, jint flags)
{ {

View File

@@ -1364,12 +1364,12 @@ static int setDecodeDefaults(struct jpeg_decompress_struct *dinfo,
} }
int my_read_markers(j_decompress_ptr dinfo) static int my_read_markers(j_decompress_ptr dinfo)
{ {
return JPEG_REACHED_SOS; return JPEG_REACHED_SOS;
} }
void my_reset_marker_reader(j_decompress_ptr dinfo) static void my_reset_marker_reader(j_decompress_ptr dinfo)
{ {
} }