@@ -17,10 +17,10 @@ public class RANSNx16Decode extends RANSDecode {
17
17
private static final int FREQ_TABLE_OPTIONALLY_COMPRESSED_MASK = 0x01 ;
18
18
19
19
public ByteBuffer uncompress (final ByteBuffer inBuffer ) {
20
- return uncompressStream (inBuffer , 0 );
20
+ return uncompress (inBuffer , 0 );
21
21
}
22
22
23
- public ByteBuffer uncompressStream (final ByteBuffer inBuffer , int outSize ) {
23
+ public ByteBuffer uncompress (final ByteBuffer inBuffer , int outSize ) {
24
24
if (inBuffer .remaining () == 0 ) {
25
25
return EMPTY_BUFFER ;
26
26
}
@@ -44,12 +44,12 @@ public ByteBuffer uncompressStream(final ByteBuffer inBuffer, int outSize) {
44
44
int packDataLength = 0 ;
45
45
int numSymbols = 0 ;
46
46
int [] packMappingTable = new int [0 ];
47
- if (ransNx16Params .isPack ()){
47
+ if (ransNx16Params .isPack ()) {
48
48
packDataLength = outSize ;
49
49
numSymbols = inBuffer .get () & 0xFF ;
50
50
51
51
// if (numSymbols > 16 or numSymbols==0), raise exception
52
- if (numSymbols <= 16 && numSymbols != 0 ) {
52
+ if (numSymbols <= 16 && numSymbols != 0 ) {
53
53
packMappingTable = new int [numSymbols ];
54
54
for (int i = 0 ; i < numSymbols ; i ++) {
55
55
packMappingTable [i ] = inBuffer .get () & 0xFF ;
@@ -65,23 +65,23 @@ public ByteBuffer uncompressStream(final ByteBuffer inBuffer, int outSize) {
65
65
int uncompressedRLEOutputLength = 0 ;
66
66
final int [] rleSymbols = new int [Constants .NUMBER_OF_SYMBOLS ];
67
67
ByteBuffer uncompressedRLEMetaData = null ;
68
- if (ransNx16Params .isRLE ()){
68
+ if (ransNx16Params .isRLE ()) {
69
69
uncompressedRLEMetaDataLength = Utils .readUint7 (inBuffer );
70
70
uncompressedRLEOutputLength = outSize ;
71
71
outSize = Utils .readUint7 (inBuffer );
72
72
// TODO: maybe move decodeRLEMeta in-line
73
- uncompressedRLEMetaData = decodeRLEMeta (inBuffer ,ransNx16Params ,uncompressedRLEMetaDataLength ,rleSymbols );
73
+ uncompressedRLEMetaData = decodeRLEMeta (inBuffer , ransNx16Params , uncompressedRLEMetaDataLength , rleSymbols );
74
74
}
75
75
76
+ ByteBuffer outBuffer = ByteBuffer .allocate (outSize );
76
77
// If CAT is set then, the input is uncompressed
77
- if (ransNx16Params .isCAT ()){
78
+ if (ransNx16Params .isCAT ()) {
78
79
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 ) {
85
85
switch (ransNx16Params .getOrder ()) {
86
86
case ZERO :
87
87
uncompressOrder0WayN (inBuffer , outBuffer , outSize , ransNx16Params );
@@ -93,18 +93,18 @@ public ByteBuffer uncompressStream(final ByteBuffer inBuffer, int outSize) {
93
93
throw new RuntimeException ("Unknown rANS order: " + ransNx16Params .getOrder ());
94
94
}
95
95
}
96
+ }
96
97
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
+ }
101
102
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 );
107
106
}
107
+ return outBuffer ;
108
108
}
109
109
110
110
private ByteBuffer uncompressOrder0WayN (
@@ -466,7 +466,7 @@ private ByteBuffer decodeStripe(ByteBuffer inBuffer, final int outSize){
466
466
ulen [j ]++;
467
467
}
468
468
469
- T [j ] = uncompressStream (inBuffer , ulen [j ]);
469
+ T [j ] = uncompress (inBuffer , ulen [j ]);
470
470
}
471
471
472
472
// Transpose
0 commit comments