You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2021/08/01 12:14:41 UTC
[sis] 02/03: Rename `Uncompressed` as `CopyFromBytes` because this
class can be used even for compressed data.
This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
commit 7bbdb81aca1f02f98c7e1743a2d58a67fe2cc01c
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Sat Jul 31 20:33:32 2021 +0200
Rename `Uncompressed` as `CopyFromBytes` because this class can be used even for compressed data.
---
.../{Uncompressed.java => CopyFromBytes.java} | 28 ++++++++++++----------
.../org/apache/sis/internal/geotiff/Inflater.java | 8 +++++--
2 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Uncompressed.java b/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/CopyFromBytes.java
similarity index 92%
rename from storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Uncompressed.java
rename to storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/CopyFromBytes.java
index faa815d..4fe7a12 100644
--- a/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Uncompressed.java
+++ b/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/CopyFromBytes.java
@@ -30,17 +30,19 @@ import org.apache.sis.util.Classes;
/**
- * A pseudo-inflater which copy values unchanged.
- * This implementation is useful for handling more complex subsampling
- * than what {@link org.apache.sis.internal.storage.io.HyperRectangleReader} can handle.
- * It is also useful for testing purpose.
+ * A pseudo-inflater which copies values from a buffer of bytes to the destination image buffer.
+ * When reading uncompressed TIFF images, the source buffer is the direct buffer used for I/O operations.
+ * When reading compressed TIFF images, the source buffer is a temporary buffer where data segments are
+ * uncompressed before to be copied to the destination image. This is useful when handling subsampling
+ * on-the-fly at decompression time would be too difficult: implementers can decompress everything in
+ * a temporary buffer and let this {@code CopyFromBytes} class do the subsampling.
*
* @author Martin Desruisseaux (Geomatys)
* @version 1.1
* @since 1.1
* @module
*/
-abstract class Uncompressed extends Inflater {
+abstract class CopyFromBytes extends Inflater {
/**
* Stream position where to perform the next reading.
*/
@@ -60,7 +62,7 @@ abstract class Uncompressed extends Inflater {
/**
* For constructors in inner classes.
*/
- private Uncompressed(final ChannelDataInput input, final long start, final int elementsPerRow,
+ private CopyFromBytes(final ChannelDataInput input, final long start, final int elementsPerRow,
final int samplesPerElement, final int[] skipAfterElements, final int sampleSize)
{
super(input, elementsPerRow, samplesPerElement, skipAfterElements);
@@ -80,7 +82,7 @@ abstract class Uncompressed extends Inflater {
* @return the inflater for the given targe type.
* @throws IllegalArgumentException if the buffer type is not recognized.
*/
- public static Uncompressed create(final ChannelDataInput input, final long start,
+ public static CopyFromBytes create(final ChannelDataInput input, final long start,
final int count, final int size, final int[] skips, final Buffer target)
{
if (target instanceof ByteBuffer) return new Bytes (input, start, count, size, skips, (ByteBuffer) target);
@@ -152,7 +154,7 @@ abstract class Uncompressed extends Inflater {
/**
* Inflater for sample values stored as bytes.
*/
- private static final class Bytes extends Uncompressed {
+ private static final class Bytes extends CopyFromBytes {
/** Where to copy the values that we will read. */
private final ByteBuffer target;
@@ -192,7 +194,7 @@ abstract class Uncompressed extends Inflater {
* Inflater for sample values stored as short integers.
* This is a copy of {@link Bytes} implementation with only the type changed.
*/
- private static final class Shorts extends Uncompressed {
+ private static final class Shorts extends CopyFromBytes {
/** Where to copy the values that we will read. */
private final ShortBuffer target;
@@ -226,7 +228,7 @@ abstract class Uncompressed extends Inflater {
* Inflater for sample values stored as 32 bits integers.
* This is a copy of {@link Bytes} implementation with only the type changed.
*/
- private static final class Ints extends Uncompressed {
+ private static final class Ints extends CopyFromBytes {
/** Where to copy the values that we will read. */
private final IntBuffer target;
@@ -260,7 +262,7 @@ abstract class Uncompressed extends Inflater {
* Inflater for sample values stored as long integers.
* This is a copy of {@link Bytes} implementation with only the type changed.
*/
- private static final class Longs extends Uncompressed {
+ private static final class Longs extends CopyFromBytes {
/** Where to copy the values that we will read. */
private final LongBuffer target;
@@ -294,7 +296,7 @@ abstract class Uncompressed extends Inflater {
* Inflater for sample values stored as single-precision floating point numbers.
* This is a copy of {@link Bytes} implementation with only the type changed.
*/
- private static final class Floats extends Uncompressed {
+ private static final class Floats extends CopyFromBytes {
/** Where to copy the values that we will read. */
private final FloatBuffer target;
@@ -328,7 +330,7 @@ abstract class Uncompressed extends Inflater {
* Inflater for sample values stored as double-precision floating point numbers.
* This is a copy of {@link Bytes} implementation with only the type changed.
*/
- private static final class Doubles extends Uncompressed {
+ private static final class Doubles extends CopyFromBytes {
/** Where to copy the values that we will read. */
private final DoubleBuffer target;
diff --git a/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Inflater.java b/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Inflater.java
index 60ca503..6848964 100644
--- a/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Inflater.java
+++ b/storage/sis-geotiff/src/main/java/org/apache/sis/internal/geotiff/Inflater.java
@@ -108,8 +108,12 @@ public abstract class Inflater {
final int elementsPerRow, final int samplesPerElement, final int[] skipAfterElements, final Buffer target)
{
switch (compression) {
- case NONE: return Uncompressed.create(input, start, elementsPerRow, samplesPerElement, skipAfterElements, target);
- default: return null;
+ case NONE: {
+ return CopyFromBytes.create(input, start, elementsPerRow, samplesPerElement, skipAfterElements, target);
+ }
+ default: {
+ return null;
+ }
}
}