aboutsummaryrefslogtreecommitdiff
path: root/lib/UnrarXLib/coder.cpp
diff options
context:
space:
mode:
authortheuni <theuni-nospam-@xbmc.org>2011-01-24 16:05:21 -0500
committertheuni <theuni-nospam-@xbmc.org>2011-01-24 16:05:21 -0500
commitc51b1189e3d5353e842991f5859ddcea0f73e426 (patch)
treeef2cb8a6184699aa614f3655dca4ce661cdc108e /lib/UnrarXLib/coder.cpp
parentbe61ebdc9e897fe40c6f371111724de79ddee8d5 (diff)
Merged cptspiff's code-reshuffle branch.
Squashed commit due to build breakage during code-reshuffle history. Conflicts: xbmc/Util.cpp xbmc/cdrip/CDDARipper.cpp xbmc/filesystem/Directory.cpp xbmc/filesystem/File.cpp
Diffstat (limited to 'lib/UnrarXLib/coder.cpp')
-rw-r--r--lib/UnrarXLib/coder.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/lib/UnrarXLib/coder.cpp b/lib/UnrarXLib/coder.cpp
new file mode 100644
index 0000000000..d556f0e18c
--- /dev/null
+++ b/lib/UnrarXLib/coder.cpp
@@ -0,0 +1,47 @@
+
+
+inline unsigned int RangeCoder::GetChar()
+{
+ return(UnpackRead->GetChar());
+}
+
+
+void RangeCoder::InitDecoder(Unpack *UnpackRead)
+{
+ RangeCoder::UnpackRead=UnpackRead;
+
+ low=code=0;
+ range=uint(-1);
+ for (int i=0;i < 4;i++)
+ code=(code << 8) | GetChar();
+}
+
+
+#define ARI_DEC_NORMALIZE(code,low,range,read) \
+{ \
+ while ((low^(low+range))<TOP || (range<BOT && ((range=-low&(BOT-1)),1))) \
+ { \
+ code=(code << 8) | read->GetChar(); \
+ range <<= 8; \
+ low <<= 8; \
+ } \
+}
+
+
+inline int RangeCoder::GetCurrentCount()
+{
+ return (code-low)/(range /= SubRange.scale);
+}
+
+
+inline uint RangeCoder::GetCurrentShiftCount(uint SHIFT)
+{
+ return (code-low)/(range >>= SHIFT);
+}
+
+
+inline void RangeCoder::Decode()
+{
+ low += range*SubRange.LowCount;
+ range *= SubRange.HighCount-SubRange.LowCount;
+}