forked from ome/bioformats
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge master -Dorg -Ssuccess-only: PR 4249 (Imaris Reader: support fo…
…r LZ4 compression and performance improvements)
- Loading branch information
Showing
8 changed files
with
262 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
components/formats-gpl/src/META-INF/services/ucar.nc2.filter.FilterProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
loci.formats.filter.LZ4Filter$LZ4FilterProvider |
98 changes: 98 additions & 0 deletions
98
components/formats-gpl/src/loci/formats/filter/LZ4Filter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* | ||
* #%L | ||
* OME Bio-Formats package for reading and converting biological file formats. | ||
* %% | ||
* Copyright (C) 2005 - 2017 Open Microscopy Environment: | ||
* - Board of Regents of the University of Wisconsin-Madison | ||
* - Glencoe Software, Inc. | ||
* - University of Dundee | ||
* %% | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as | ||
* published by the Free Software Foundation, either version 2 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public | ||
* License along with this program. If not, see | ||
* <http://www.gnu.org/licenses/gpl-2.0.html>. | ||
* #L% | ||
*/ | ||
|
||
package loci.formats.filter; | ||
|
||
import ucar.nc2.filter.FilterProvider; | ||
import ucar.nc2.filter.Filter; | ||
|
||
import io.airlift.compress.lz4.Lz4Decompressor; | ||
|
||
import java.util.Map; | ||
import java.io.IOException; | ||
import java.nio.ByteBuffer; | ||
|
||
public class LZ4Filter extends Filter { | ||
|
||
static final String name = "LZ4 filter"; | ||
static final int id = 32004; | ||
private Lz4Decompressor decompressor; | ||
|
||
public LZ4Filter(Map<String, Object> properties) { | ||
decompressor = new Lz4Decompressor(); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public int getId() { | ||
return id; | ||
} | ||
|
||
@Override | ||
public byte[] encode(byte[] dataIn) throws IOException { | ||
throw new UnsupportedOperationException("LZ4Filter does not support data compression"); | ||
} | ||
|
||
@Override | ||
public byte[] decode(byte[] dataIn) throws IOException { | ||
ByteBuffer byteBuffer = ByteBuffer.wrap(dataIn); | ||
|
||
long totalDecompressedSize = byteBuffer.getLong(); | ||
int decompressedBlockSize = byteBuffer.getInt(); | ||
int compressedBlockSize = byteBuffer.getInt(); | ||
|
||
byte[] decompressedBlock = new byte[Math.toIntExact(totalDecompressedSize)]; | ||
byte[] compressedBlock = new byte[compressedBlockSize]; | ||
|
||
byteBuffer.get(compressedBlock, 0, compressedBlockSize); | ||
decompressor.decompress(compressedBlock, 0, compressedBlockSize, decompressedBlock, 0, decompressedBlockSize); | ||
|
||
return decompressedBlock; | ||
} | ||
|
||
public static class LZ4FilterProvider implements FilterProvider { | ||
|
||
@Override | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public int getId() { | ||
return id; | ||
} | ||
|
||
@Override | ||
public Filter create(Map<String, Object> properties) { | ||
return new LZ4Filter(properties); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters