TurboJPEG: Use 4:4:4 for lossless JPEG buf calcs
This commit is contained in:
@@ -814,6 +814,9 @@ final class TJUnitTest {
|
|||||||
int size, quality = 100;
|
int size, quality = 100;
|
||||||
byte[] dstBuf;
|
byte[] dstBuf;
|
||||||
|
|
||||||
|
if (lossless && subsamp != TJ.SAMP_GRAY)
|
||||||
|
subsamp = TJ.SAMP_444;
|
||||||
|
|
||||||
dstBuf = new byte[TJ.bufSize(w, h, subsamp)];
|
dstBuf = new byte[TJ.bufSize(w, h, subsamp)];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -537,6 +537,9 @@ static void doTest(int w, int h, const int *formats, int nformats, int subsamp,
|
|||||||
unsigned long size = 0;
|
unsigned long size = 0;
|
||||||
int pfi, pf, i, quality = 100;
|
int pfi, pf, i, quality = 100;
|
||||||
|
|
||||||
|
if (lossless && subsamp != TJSAMP_GRAY)
|
||||||
|
subsamp = TJSAMP_444;
|
||||||
|
|
||||||
if (!alloc)
|
if (!alloc)
|
||||||
size = tjBufSize(w, h, subsamp);
|
size = tjBufSize(w, h, subsamp);
|
||||||
if (size != 0)
|
if (size != 0)
|
||||||
|
|||||||
@@ -231,6 +231,8 @@ static jint TJCompressor_compress
|
|||||||
arraySize = (y + height - 1) * actualPitch + (x + width) * tjPixelSize[pf];
|
arraySize = (y + height - 1) * actualPitch + (x + width) * tjPixelSize[pf];
|
||||||
if ((*env)->GetArrayLength(env, src) * srcElementSize < arraySize)
|
if ((*env)->GetArrayLength(env, src) * srcElementSize < arraySize)
|
||||||
THROW_ARG("Source buffer is not large enough");
|
THROW_ARG("Source buffer is not large enough");
|
||||||
|
if (flags & TJFLAG_LOSSLESS && jpegSubsamp != TJSAMP_GRAY)
|
||||||
|
jpegSubsamp = TJSAMP_444;
|
||||||
jpegSize = tjBufSize(width, height, jpegSubsamp);
|
jpegSize = tjBufSize(width, height, jpegSubsamp);
|
||||||
if ((*env)->GetArrayLength(env, dst) < (jsize)jpegSize)
|
if ((*env)->GetArrayLength(env, dst) < (jsize)jpegSize)
|
||||||
THROW_ARG("Destination buffer is not large enough");
|
THROW_ARG("Destination buffer is not large enough");
|
||||||
|
|||||||
@@ -746,6 +746,8 @@ DLLEXPORT int tjCompress2(tjhandle handle, const unsigned char *srcBuf,
|
|||||||
else if (flags & TJFLAG_FORCESSE) PUTENV_S("JSIMD_FORCESSE", "1");
|
else if (flags & TJFLAG_FORCESSE) PUTENV_S("JSIMD_FORCESSE", "1");
|
||||||
else if (flags & TJFLAG_FORCESSE2) PUTENV_S("JSIMD_FORCESSE2", "1");
|
else if (flags & TJFLAG_FORCESSE2) PUTENV_S("JSIMD_FORCESSE2", "1");
|
||||||
#endif
|
#endif
|
||||||
|
if (flags & TJFLAG_LOSSLESS && jpegSubsamp != TJSAMP_GRAY)
|
||||||
|
jpegSubsamp = TJSAMP_444;
|
||||||
|
|
||||||
if (flags & TJFLAG_NOREALLOC) {
|
if (flags & TJFLAG_NOREALLOC) {
|
||||||
alloc = FALSE; *jpegSize = tjBufSize(width, height, jpegSubsamp);
|
alloc = FALSE; *jpegSize = tjBufSize(width, height, jpegSubsamp);
|
||||||
|
|||||||
Reference in New Issue
Block a user