Merge libjpeg-turbo 2.0.5

* tag '2.0.5':
  TurboJPEG: Make global error handling thread-safe
  ChangeLog.md: Add missing sub-header for 2.0.5
  ChangeLog.md: List CVE ID fixed by previous commit
  rdppm.c: Fix buf overrun caused by bad binary PPM
  Build: Add missing jpegtran-icc test dependency
  rdswitch.c: Eliminate spaces before semicolons
  TJCompressor.compress(int): Fix YUV-to-JPEG error
  Bump version to 2.0.5; Document previous commit
  MIPS DSPr2: Work around various 'make test' errors
  MIPS DSPr2: Fix compiler warning with -mdspr2
  MIPS SIMD: Always honor JSIMD_FORCE* env vars
  Test: Honor CMAKE_CROSSCOMPILING_EMULATOR variable
This commit is contained in:
Kornel Lesiński
2020-08-15 18:11:20 +01:00
11 changed files with 174 additions and 73 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C)2011-2015, 2018 D. R. Commander. All Rights Reserved.
* Copyright (C)2011-2015, 2018, 2020 D. R. Commander. All Rights Reserved.
* Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -377,8 +377,15 @@ public class TJCompressor implements Closeable {
* #getCompressedSize} to obtain the size of the JPEG image.
*/
public byte[] compress(int flags) throws TJException {
checkSourceImage();
byte[] buf = new byte[TJ.bufSize(srcWidth, srcHeight, subsamp)];
byte[] buf;
if (srcYUVImage != null) {
buf = new byte[TJ.bufSize(srcYUVImage.getWidth(),
srcYUVImage.getHeight(),
srcYUVImage.getSubsamp())];
} else {
checkSourceImage();
buf = new byte[TJ.bufSize(srcWidth, srcHeight, subsamp)];
}
compress(buf, flags);
return buf;
}