Author: post
Date: 2012-09-30 22:07:22 +0200 (Sun, 30 Sep 2012)
New Revision: 464

Modified:
   RawSpeed/ByteStream.cpp
Log:
Fix byte stream in host endianness.

Modified: RawSpeed/ByteStream.cpp
===================================================================
--- RawSpeed/ByteStream.cpp     2012-09-30 18:19:58 UTC (rev 463)
+++ RawSpeed/ByteStream.cpp     2012-09-30 20:07:22 UTC (rev 464)
@@ -51,23 +51,22 @@
 uchar8 ByteStream::getByte() {
   if (off >= size)
     throw IOException("getByte:Out of buffer read");
-  return buffer[off++];
+  off++;
+  return buffer[off-1];
 }
 
 ushort16 ByteStream::getShort() {
   if (off + 1 >= size)
     throw IOException("getShort: Out of buffer read");
-  return *(ushort16*)&buffer[off+=4];
-  uint32 a = buffer[off++];
-  uint32 b = buffer[off++];
-  // !!! ENDIAN SWAP
-  return (a << 8) | b;
+  off +=2;
+  return *(ushort16*)&buffer[off-2];
 }
 
 int ByteStream::getInt() {
   if (off + 4 >= size)
     throw IOException("getInt:Out of buffer read");
-  return *(int*)&buffer[off+=4];
+  off+=4;
+  return *(int*)&buffer[off-4];
 }
 
 void ByteStream::setAbsoluteOffset(uint32 offset) {


_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit

Reply via email to