Java: Unset srcBuf12/16 with BufferedImage/YUV src
Due to an oversight in the multi-precision feature, TJCompressor.srcBuf12 and TJCompressor.srcBuf16 were not set to null in TJCompressor.setSourceImage(YUVImage) or TJCompressor.setSourceImage(BufferedImage, ...). Thus, if an application set a 12-bit or 16-bit packed-pixel buffer as the source image then set a BufferedImage with integer pixels as the source image, TJCompress.compress() would compress from the 12-bit or 16-bit packed-pixel buffer instead of the BufferedImage. The odds of an application actually doing that are very slim, however.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C)2011-2015, 2018, 2020, 2022-2023 D. R. Commander.
|
||||
* Copyright (C)2011-2015, 2018, 2020, 2022-2024 D. R. Commander.
|
||||
* All Rights Reserved.
|
||||
* Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
|
||||
*
|
||||
@@ -335,6 +335,8 @@ public class TJCompressor implements Closeable {
|
||||
DataBufferInt db = (DataBufferInt)wr.getDataBuffer();
|
||||
srcBufInt = db.getData();
|
||||
srcBuf8 = null;
|
||||
srcBuf12 = null;
|
||||
srcBuf16 = null;
|
||||
} else {
|
||||
ComponentSampleModel sm =
|
||||
(ComponentSampleModel)srcImage.getSampleModel();
|
||||
@@ -344,6 +346,8 @@ public class TJCompressor implements Closeable {
|
||||
srcPitch = sm.getScanlineStride();
|
||||
DataBufferByte db = (DataBufferByte)wr.getDataBuffer();
|
||||
srcBuf8 = db.getData();
|
||||
srcBuf12 = null;
|
||||
srcBuf16 = null;
|
||||
srcBufInt = null;
|
||||
}
|
||||
srcYUVImage = null;
|
||||
@@ -364,6 +368,8 @@ public class TJCompressor implements Closeable {
|
||||
srcYUVImage = srcImage;
|
||||
set(TJ.PARAM_SUBSAMP, srcImage.getSubsamp());
|
||||
srcBuf8 = null;
|
||||
srcBuf12 = null;
|
||||
srcBuf16 = null;
|
||||
srcBufInt = null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user