mirror of
https://github.com/libjpeg-turbo/libjpeg-turbo.git
synced 2026-01-19 00:06:16 +08:00
TurboJPEG: Add lossless JPEG detection capability
Add a new TurboJPEG C API function (tjDecompressHeader4()) and Java API method (TJDecompressor.getFlags()) that return the bitwise OR of any flags that are relevant to the JPEG image being decompressed (currently TJFLAG_PROGRESSIVE, TJFLAG_ARITHMETIC, TJFLAG_LOSSLESS, and their Java equivalents.) This allows a calling program to determine whether the image being decompressed is a lossless JPEG image, which means that the decompression scaling feature will not be available and that a full-sized destination buffer should be allocated. More specifically, this fixes a buffer overrun in TJBench, TJExample, and the decompress* fuzz targets that occurred when attempting (in vain) to decompress a lossless JPEG image with decompression scaling enabled.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (C)2011-2012, 2014-2015, 2017-2018 D. R. Commander.
|
||||
* All Rights Reserved.
|
||||
* Copyright (C)2011-2012, 2014-2015, 2017-2018, 2022 D. R. Commander.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -304,6 +304,10 @@ class TJExample implements TJCustomFilter {
|
||||
height = tjd.getHeight();
|
||||
int inSubsamp = tjd.getSubsamp();
|
||||
int inColorspace = tjd.getColorspace();
|
||||
int inFlags = tjd.getFlags();
|
||||
|
||||
if ((inFlags & TJ.FLAG_LOSSLESS) != 0)
|
||||
scalingFactor = new TJScalingFactor(1, 1);
|
||||
|
||||
System.out.println((doTransform ? "Transformed" : "Input") +
|
||||
" Image (jpg): " + width + " x " + height +
|
||||
|
||||
Reference in New Issue
Block a user