From 9e13e8c78ed69bb7afcd49abe8bf69340dc06223 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 3 Dec 2014 20:30:46 +0100 Subject: Bug 1106 - Bitstream: Simplify 'msbFirst' case for bulk operations / Add setting of stream position (optional) - Add setting position entry, optionally supported, e.g. ByteBufferStream and ByteArrayStream - Remove 'msbFirst' parameter on all 'bulk' read/write operations. These methods use LSB-first always, allowing proper stream access of data w/ different bit-sizes. Data is now read/write as little-endian and swapped accordingly. Optimizations are adopted for LSB-first operations. This change removes API confusion/bugs: - removes one decision (parameter) - removes the data reversion case - removes bugs w/ different bit-sizes --- .../com/jogamp/common/util/TestBitstream04.java | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/junit/com/jogamp/common/util/TestBitstream04.java') diff --git a/src/junit/com/jogamp/common/util/TestBitstream04.java b/src/junit/com/jogamp/common/util/TestBitstream04.java index 277510e..47be38d 100644 --- a/src/junit/com/jogamp/common/util/TestBitstream04.java +++ b/src/junit/com/jogamp/common/util/TestBitstream04.java @@ -47,8 +47,8 @@ import org.junit.runners.MethodSorters; * Test {@link Bitstream} w/ int32 read/write access w/ semantics * as well as with aligned and unaligned access. * */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) @@ -82,11 +82,12 @@ public class TestBitstream04 extends SingletonJunitCase { System.err.println("XXX Test01Int32BitsAligned: "+val32+", "+val32_hs); bb.putInt(0, val32); + dumpData("TestData.1: ", bb, 0, 4); final Bitstream.ByteBufferStream bbs = new Bitstream.ByteBufferStream(bb); final Bitstream bs = new Bitstream(bbs, false /* outputMode */); { - final long uint32_l = bs.readUInt32(true /* msbFirst */, bigEndian); + final long uint32_l = bs.readUInt32(bigEndian); final int int32_l = (int)uint32_l; final String uint32_l_hs = toHexString(uint32_l); final int uint32_i = Bitstream.uint32LongToInt(uint32_l); @@ -99,10 +100,11 @@ public class TestBitstream04 extends SingletonJunitCase { // Test with written bitstream value bs.setStream(bs.getSubStream(), true /* outputMode */); - bs.writeInt32(true /* msbFirst */, bigEndian, val32); + bs.writeInt32(bigEndian, val32); bs.setStream(bs.getSubStream(), false /* outputMode */); // switch to input-mode, implies flush() + dumpData("TestData.2: ", bb, 0, 4); { - final long uint32_l = bs.readUInt32(true /* msbFirst */, bigEndian); + final long uint32_l = bs.readUInt32(bigEndian); final int int32_l = (int)uint32_l; final String uint32_l_hs = toHexString(uint32_l); final int uint32_i = Bitstream.uint32LongToInt(uint32_l); @@ -154,12 +156,12 @@ public class TestBitstream04 extends SingletonJunitCase { // Test with written bitstream value final Bitstream.ByteBufferStream bbs = new Bitstream.ByteBufferStream(bb); final Bitstream bs = new Bitstream(bbs, true /* outputMode */); - bs.writeBits31(true /* msbFirst */, preBits, 0); - bs.writeInt32(true /* msbFirst */, bigEndian, val32); + bs.writeBits31(preBits, 0); + bs.writeInt32(bigEndian, val32); bs.setStream(bs.getSubStream(), false /* outputMode */); // switch to input-mode, implies flush() - final int rPre = bs.readBits31(true /* msbFirst */, preBits); - final long uint32_l = bs.readUInt32(true /* msbFirst */, bigEndian); + final int rPre = bs.readBits31(preBits); + final long uint32_l = bs.readUInt32(bigEndian); final int int32_l = (int)uint32_l; final String uint32_l_hs = toHexString(uint32_l); final int uint32_i = Bitstream.uint32LongToInt(uint32_l); -- cgit v1.2.3