Skip to content

Commit 850280d

Browse files
author
yash-puligundla
committed
debug - add decodePack and decodeRLE on top of CAT flag
1 parent e72147a commit 850280d

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

src/main/java/htsjdk/samtools/cram/compression/rans/ransnx16/RANSNx16Decode.java

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ public class RANSNx16Decode extends RANSDecode {
1717
private static final int FREQ_TABLE_OPTIONALLY_COMPRESSED_MASK = 0x01;
1818

1919
public ByteBuffer uncompress(final ByteBuffer inBuffer) {
20-
return uncompressStream(inBuffer, 0);
20+
return uncompress(inBuffer, 0);
2121
}
2222

23-
public ByteBuffer uncompressStream(final ByteBuffer inBuffer, int outSize) {
23+
public ByteBuffer uncompress(final ByteBuffer inBuffer, int outSize) {
2424
if (inBuffer.remaining() == 0) {
2525
return EMPTY_BUFFER;
2626
}
@@ -44,12 +44,12 @@ public ByteBuffer uncompressStream(final ByteBuffer inBuffer, int outSize) {
4444
int packDataLength = 0;
4545
int numSymbols = 0;
4646
int[] packMappingTable = new int[0];
47-
if (ransNx16Params.isPack()){
47+
if (ransNx16Params.isPack()) {
4848
packDataLength = outSize;
4949
numSymbols = inBuffer.get() & 0xFF;
5050

5151
// if (numSymbols > 16 or numSymbols==0), raise exception
52-
if (numSymbols <= 16 && numSymbols!=0) {
52+
if (numSymbols <= 16 && numSymbols != 0) {
5353
packMappingTable = new int[numSymbols];
5454
for (int i = 0; i < numSymbols; i++) {
5555
packMappingTable[i] = inBuffer.get() & 0xFF;
@@ -65,23 +65,23 @@ public ByteBuffer uncompressStream(final ByteBuffer inBuffer, int outSize) {
6565
int uncompressedRLEOutputLength = 0;
6666
final int[] rleSymbols = new int[Constants.NUMBER_OF_SYMBOLS];
6767
ByteBuffer uncompressedRLEMetaData = null;
68-
if (ransNx16Params.isRLE()){
68+
if (ransNx16Params.isRLE()) {
6969
uncompressedRLEMetaDataLength = Utils.readUint7(inBuffer);
7070
uncompressedRLEOutputLength = outSize;
7171
outSize = Utils.readUint7(inBuffer);
7272
// TODO: maybe move decodeRLEMeta in-line
73-
uncompressedRLEMetaData = decodeRLEMeta(inBuffer,ransNx16Params,uncompressedRLEMetaDataLength,rleSymbols);
73+
uncompressedRLEMetaData = decodeRLEMeta(inBuffer, ransNx16Params, uncompressedRLEMetaDataLength, rleSymbols);
7474
}
7575

76+
ByteBuffer outBuffer = ByteBuffer.allocate(outSize);
7677
// If CAT is set then, the input is uncompressed
77-
if (ransNx16Params.isCAT()){
78+
if (ransNx16Params.isCAT()) {
7879
byte[] data = new byte[outSize];
79-
inBuffer.get( data,0, outSize);
80-
return ByteBuffer.wrap(data);
81-
}
82-
else {
83-
ByteBuffer outBuffer = ByteBuffer.allocate(outSize);
84-
if (outSize!=0) {
80+
inBuffer.get(data, 0, outSize);
81+
outBuffer = ByteBuffer.wrap(data);
82+
} else {
83+
outBuffer = ByteBuffer.allocate(outSize);
84+
if (outSize != 0) {
8585
switch (ransNx16Params.getOrder()) {
8686
case ZERO:
8787
uncompressOrder0WayN(inBuffer, outBuffer, outSize, ransNx16Params);
@@ -93,18 +93,18 @@ public ByteBuffer uncompressStream(final ByteBuffer inBuffer, int outSize) {
9393
throw new RuntimeException("Unknown rANS order: " + ransNx16Params.getOrder());
9494
}
9595
}
96+
}
9697

97-
// if rle, then decodeRLE
98-
if (ransNx16Params.isRLE() && uncompressedRLEMetaData!=null ){
99-
outBuffer = decodeRLE(outBuffer,rleSymbols,uncompressedRLEMetaData, uncompressedRLEOutputLength);
100-
}
98+
// if rle, then decodeRLE
99+
if (ransNx16Params.isRLE() && uncompressedRLEMetaData != null) {
100+
outBuffer = decodeRLE(outBuffer, rleSymbols, uncompressedRLEMetaData, uncompressedRLEOutputLength);
101+
}
101102

102-
// if pack, then decodePack
103-
if (ransNx16Params.isPack() && packMappingTable.length > 0) {
104-
outBuffer = decodePack(outBuffer, packMappingTable, numSymbols, packDataLength);
105-
}
106-
return outBuffer;
103+
// if pack, then decodePack
104+
if (ransNx16Params.isPack() && packMappingTable.length > 0) {
105+
outBuffer = decodePack(outBuffer, packMappingTable, numSymbols, packDataLength);
107106
}
107+
return outBuffer;
108108
}
109109

110110
private ByteBuffer uncompressOrder0WayN(
@@ -466,7 +466,7 @@ private ByteBuffer decodeStripe(ByteBuffer inBuffer, final int outSize){
466466
ulen[j]++;
467467
}
468468

469-
T[j] = uncompressStream(inBuffer, ulen[j]);
469+
T[j] = uncompress(inBuffer, ulen[j]);
470470
}
471471

472472
// Transpose

0 commit comments

Comments
 (0)