Author: post
Date: 2010-03-21 16:16:04 +0100 (Sun, 21 Mar 2010)
New Revision: 208
Modified:
RawSpeed/BitPumpJPEG.cpp
RawSpeed/BitPumpJPEG.h
RawSpeed/BitPumpMSB.cpp
RawSpeed/BitPumpMSB.h
RawSpeed/BitPumpPlain.cpp
RawSpeed/BitPumpPlain.h
Log:
Remove some unused features in BitPimp code and clean up.
Modified: RawSpeed/BitPumpJPEG.cpp
===================================================================
--- RawSpeed/BitPumpJPEG.cpp 2010-03-21 15:14:44 UTC (rev 207)
+++ RawSpeed/BitPumpJPEG.cpp 2010-03-21 15:16:04 UTC (rev 208)
@@ -46,9 +46,6 @@
void __inline BitPumpJPEG::init() {
- for (int i = 0; i < 31; i++) {
- masks[i] = (1 << i) - 1;
- }
stuffed = 0;
fill();
}
@@ -99,7 +96,6 @@
if (mLeft < nbits) {
fill();
}
-
return ((mCurr >> (mLeft -= (nbits)))) & ((1 << nbits) - 1);
}
@@ -146,8 +142,7 @@
if (mLeft < nbits) {
fill();
- if (off > size)
- throw IOException("Out of buffer read");
+ checkPos();
}
return ((mCurr >> (mLeft -= (nbits)))) & ((1 << nbits) - 1);
}
@@ -158,9 +153,7 @@
if (mLeft < nbits) {
fill();
-
- if (off > size)
- throw IOException("Out of buffer read");
+ checkPos();
}
mLeft -= nbits;
@@ -179,9 +172,7 @@
unsigned char BitPumpJPEG::getByteSafe() {
if (mLeft < 8) {
fill();
-
- if (off > size)
- throw IOException("Out of buffer read");
+ checkPos();
}
return ((mCurr >> (mLeft -= 8))) & 0xff;
@@ -193,8 +184,8 @@
throw IOException("Offset set out of buffer");
mLeft = 0;
-
off = offset;
+ fill();
}
Modified: RawSpeed/BitPumpJPEG.h
===================================================================
--- RawSpeed/BitPumpJPEG.h 2010-03-21 15:14:44 UTC (rev 207)
+++ RawSpeed/BitPumpJPEG.h 2010-03-21 15:16:04 UTC (rev 208)
@@ -58,7 +58,6 @@
void __inline init();
const guchar* buffer;
const guint size; // This if the end of buffer.
- guint masks[31];
guint mLeft;
guint mCurr;
guint off; // Offset in bytes
Modified: RawSpeed/BitPumpMSB.cpp
===================================================================
--- RawSpeed/BitPumpMSB.cpp 2010-03-21 15:14:44 UTC (rev 207)
+++ RawSpeed/BitPumpMSB.cpp 2010-03-21 15:16:04 UTC (rev 208)
@@ -41,16 +41,13 @@
for (int i = 0; i < 31; i++) {
masks[i] = (1 << i) - 1;
}
-
fill();
}
guint BitPumpMSB::getBitSafe() {
if (!mLeft) {
fill();
-
- if (off > size)
- throw IOException("Out of buffer read");
+ checkPos();
}
return (mCurr >> (--mLeft)) & 1;
@@ -62,9 +59,7 @@
if (mLeft < nbits) {
fill();
-
- if (off > size)
- throw IOException("Out of buffer read");
+ checkPos();
}
return ((mCurr >> (mLeft -= (nbits)))) & ((1 << nbits) - 1);
@@ -74,9 +69,7 @@
unsigned char BitPumpMSB::getByteSafe() {
if (mLeft < 8) {
fill();
-
- if (off > size)
- throw IOException("Out of buffer read");
+ checkPos();
}
return ((mCurr >> (mLeft -= 8))) & 0xff;
@@ -87,10 +80,9 @@
throw IOException("Offset set out of buffer");
mLeft = 0;
-
mCurr = 0;
-
off = offset;
+ fill();
}
Modified: RawSpeed/BitPumpMSB.h
===================================================================
--- RawSpeed/BitPumpMSB.h 2010-03-21 15:14:44 UTC (rev 207)
+++ RawSpeed/BitPumpMSB.h 2010-03-21 15:16:04 UTC (rev 208)
@@ -65,9 +65,6 @@
__inline guint getBits(guint nbits) {
if (mLeft < nbits) {
- if (nbits>24)
- throw IOException("Invalid data, attempting to read more than 24
bits.");
-
fill();
}
@@ -82,9 +79,6 @@
__inline guint peekBits(guint nbits) {
if (mLeft < nbits) {
- if (nbits>24)
- throw IOException("Invalid data, attempting to read more than 24
bits.");
-
fill();
}
@@ -103,14 +97,13 @@
}
__inline void skipBits(unsigned int nbits) {
- if (mLeft < nbits) {
+ while (nbits) {
fill();
-
- if (off > size)
- throw IOException("Out of buffer read");
+ checkPos();
+ int n = MIN(nbits, mLeft);
+ mLeft -= n;
+ nbits -= n;
}
-
- mLeft -= nbits;
}
__inline void skipBitsNoFill(unsigned int nbits) {
Modified: RawSpeed/BitPumpPlain.cpp
===================================================================
--- RawSpeed/BitPumpPlain.cpp 2010-03-21 15:14:44 UTC (rev 207)
+++ RawSpeed/BitPumpPlain.cpp 2010-03-21 15:16:04 UTC (rev 208)
@@ -32,16 +32,10 @@
BitPumpPlain::BitPumpPlain(ByteStream *s):
buffer(s->getData()), size(8*s->getRemainSize()), off(0) {
- for (int i = 0; i < 31; i++) {
- masks[i] = (1 << i) - 1;
- }
}
BitPumpPlain::BitPumpPlain(const guchar* _buffer, guint _size) :
buffer(_buffer), size(_size*8), off(0) {
- for (int i = 0; i < 31; i++) {
- masks[i] = (1 << i) - 1;
- }
}
guint BitPumpPlain::getBit() {
@@ -69,24 +63,18 @@
}
guint BitPumpPlain::getBitSafe() {
- if (off > size)
- throw IOException("Out of buffer read");
-
+ checkPos();
return *(guint*)&buffer[off>>3] >> (off&7) & 1;
}
guint BitPumpPlain::getBitsSafe(unsigned int nbits) {
- if (off > size)
- throw IOException("Out of buffer read");
-
+ checkPos();
return *(guint*)&buffer[off>>3] >> (off&7) & ((1 << nbits) - 1);
}
void BitPumpPlain::skipBits(unsigned int nbits) {
off += nbits;
-
- if (off > size)
- throw IOException("Out of buffer read");
+ checkPos();
}
unsigned char BitPumpPlain::getByte() {
@@ -98,10 +86,8 @@
unsigned char BitPumpPlain::getByteSafe() {
guint v = *(guint*) & buffer[off>>3] >> (off & 7) & 0xff;
off += 8;
+ checkPos();
- if (off > size)
- throw IOException("Out of buffer read");
-
return v;
}
Modified: RawSpeed/BitPumpPlain.h
===================================================================
--- RawSpeed/BitPumpPlain.h 2010-03-21 15:14:44 UTC (rev 207)
+++ RawSpeed/BitPumpPlain.h 2010-03-21 15:16:04 UTC (rev 208)
@@ -50,7 +50,6 @@
const guchar* buffer;
const guint size; // This if the end of buffer.
guint off; // Offset in bytes
- guint masks[31];
private:
};
_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit