mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-04 12:05:29 -04:00
#646: Spi now recognizes VP8 encoded images in VP8X ("extended format").
This commit is contained in:
parent
529c59f93f
commit
25c703f4b2
@ -35,6 +35,7 @@ import com.twelvemonkeys.imageio.spi.ImageReaderSpiBase;
|
||||
|
||||
import javax.imageio.ImageReader;
|
||||
import javax.imageio.stream.ImageInputStream;
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Locale;
|
||||
@ -76,7 +77,8 @@ public final class WebPImageReaderSpi extends ImageReaderSpiBase {
|
||||
switch (chunk) {
|
||||
// TODO. Support lossless
|
||||
// case WebP.CHUNK_VP8L:
|
||||
// case WebP.CHUNK_VP8X:
|
||||
case WebP.CHUNK_VP8X:
|
||||
return containsSupportedChunk(stream, chunk);
|
||||
case WebP.CHUNK_VP8_:
|
||||
return true;
|
||||
default:
|
||||
@ -89,6 +91,30 @@ public final class WebPImageReaderSpi extends ImageReaderSpiBase {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean containsSupportedChunk(ImageInputStream stream, int chunk) throws IOException {
|
||||
// Temporary: Seek for VP8_, either first or second (after ICCP), or inside ANMF...
|
||||
try {
|
||||
while (chunk != WebP.CHUNK_VP8L && chunk != WebP.CHUNK_ALPH) {
|
||||
long length = stream.readUnsignedInt();
|
||||
stream.seek(stream.getStreamPosition() + length);
|
||||
chunk = stream.readInt();
|
||||
|
||||
// Look inside ANMF chunks...
|
||||
if (chunk == WebP.CHUNK_ANMF) {
|
||||
stream.seek(stream.getStreamPosition() + 4 + 16);
|
||||
chunk = stream.readInt();
|
||||
}
|
||||
|
||||
if (chunk == WebP.CHUNK_VP8_) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (EOFException ignore) {}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImageReader createReaderInstance(final Object extension) {
|
||||
return new WebPImageReader(this);
|
||||
|
Loading…
x
Reference in New Issue
Block a user