TJBench: Recover from non-fatal errors if possible
Previously, -stoponwarning only had an effect on the underlying TurboJPEG C functions, but TJBench still aborted if a non-fatal error occurred. This commit modifies the C version of TJBench such that it always recovers from a non-fatal error unless -stoponwarning is specified. Furthermore, the benchmark stores the details of the last non-fatal error and does not print any subsequent non-fatal error messages unless they differ from the last one. Due to limitations in the Java API (specifically, the fact that it cannot communicate errors, fatal or otherwise, to the calling program without throwing a TJException), it was only possible to make decompression operations fully recoverable within TJBench. With other operations, -stoponwarning still has an effect on the underlying C library but has no effect at the Java level. The Java API documentation has been amended to reflect that only certain methods are truly recoverable, regardless of the state of TJ.FLAG_STOPONWARNING.
This commit is contained in:
@@ -391,6 +391,11 @@ public final class TJ {
|
||||
* operation if the underlying codec throws a warning (non-fatal error). The
|
||||
* default behavior is to allow the operation to complete unless a fatal
|
||||
* error is encountered.
|
||||
* <p>
|
||||
* NOTE: due to the design of the TurboJPEG Java API, only certain methods
|
||||
* (specifically, {@link TJDecompressor TJDecompressor.decompress*()} methods
|
||||
* with a void return type) will complete and leave the output image in a
|
||||
* fully recoverable state after a non-fatal error occurs.
|
||||
*/
|
||||
public static final int FLAG_STOPONWARNING = 8192;
|
||||
/**
|
||||
@@ -409,6 +414,11 @@ public final class TJ {
|
||||
/**
|
||||
* The error was non-fatal and recoverable, but the image may still be
|
||||
* corrupt.
|
||||
* <p>
|
||||
* NOTE: due to the design of the TurboJPEG Java API, only certain methods
|
||||
* (specifically, {@link TJDecompressor TJDecompressor.decompress*()} methods
|
||||
* with a void return type) will complete and leave the output image in a
|
||||
* fully recoverable state after a non-fatal error occurs.
|
||||
*/
|
||||
public static final int ERR_WARNING = 0;
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user