TurboJPEG: Use 4:4:4 for lossless JPEG buf calcs

This commit is contained in:
DRC
2023-01-14 18:27:37 -06:00
parent d4589f4f1c
commit d859232da3
4 changed files with 10 additions and 0 deletions

View File

@@ -814,6 +814,9 @@ final class TJUnitTest {
int size, quality = 100;
byte[] dstBuf;
if (lossless && subsamp != TJ.SAMP_GRAY)
subsamp = TJ.SAMP_444;
dstBuf = new byte[TJ.bufSize(w, h, subsamp)];
try {

View File

@@ -537,6 +537,9 @@ static void doTest(int w, int h, const int *formats, int nformats, int subsamp,
unsigned long size = 0;
int pfi, pf, i, quality = 100;
if (lossless && subsamp != TJSAMP_GRAY)
subsamp = TJSAMP_444;
if (!alloc)
size = tjBufSize(w, h, subsamp);
if (size != 0)

View File

@@ -231,6 +231,8 @@ static jint TJCompressor_compress
arraySize = (y + height - 1) * actualPitch + (x + width) * tjPixelSize[pf];
if ((*env)->GetArrayLength(env, src) * srcElementSize < arraySize)
THROW_ARG("Source buffer is not large enough");
if (flags & TJFLAG_LOSSLESS && jpegSubsamp != TJSAMP_GRAY)
jpegSubsamp = TJSAMP_444;
jpegSize = tjBufSize(width, height, jpegSubsamp);
if ((*env)->GetArrayLength(env, dst) < (jsize)jpegSize)
THROW_ARG("Destination buffer is not large enough");

View File

@@ -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_FORCESSE2) PUTENV_S("JSIMD_FORCESSE2", "1");
#endif
if (flags & TJFLAG_LOSSLESS && jpegSubsamp != TJSAMP_GRAY)
jpegSubsamp = TJSAMP_444;
if (flags & TJFLAG_NOREALLOC) {
alloc = FALSE; *jpegSize = tjBufSize(width, height, jpegSubsamp);