Run dos2unix on bayou and remove white space at the end of lines.
[coreboot.git] / payloads / bayou / util / pbuilder / lzma / C / 7zip / Compress / RangeCoder / RangeCoderBit.h
index 64538e687948f1b8e50ab975636cac9460335609..624f887c946ab4877359e96498487533088d08c0 100644 (file)
-// Compress/RangeCoder/RangeCoderBit.h\r
-\r
-#ifndef __COMPRESS_RANGECODER_BIT_H\r
-#define __COMPRESS_RANGECODER_BIT_H\r
-\r
-#include "RangeCoder.h"\r
-\r
-namespace NCompress {\r
-namespace NRangeCoder {\r
-\r
-const int kNumBitModelTotalBits  = 11;\r
-const UInt32 kBitModelTotal = (1 << kNumBitModelTotalBits);\r
-\r
-const int kNumMoveReducingBits = 2;\r
-\r
-const int kNumBitPriceShiftBits = 6;\r
-const UInt32 kBitPrice = 1 << kNumBitPriceShiftBits;\r
-\r
-class CPriceTables\r
-{\r
-public:\r
-  static UInt32 ProbPrices[kBitModelTotal >> kNumMoveReducingBits];\r
-  static void Init();\r
-  CPriceTables();\r
-};\r
-\r
-template <int numMoveBits>\r
-class CBitModel\r
-{\r
-public:\r
-  UInt32 Prob;\r
-  void UpdateModel(UInt32 symbol)\r
-  {\r
-    /*\r
-    Prob -= (Prob + ((symbol - 1) & ((1 << numMoveBits) - 1))) >> numMoveBits;\r
-    Prob += (1 - symbol) << (kNumBitModelTotalBits - numMoveBits);\r
-    */\r
-    if (symbol == 0)\r
-      Prob += (kBitModelTotal - Prob) >> numMoveBits;\r
-    else\r
-      Prob -= (Prob) >> numMoveBits;\r
-  }\r
-public:\r
-  void Init() { Prob = kBitModelTotal / 2; }\r
-};\r
-\r
-template <int numMoveBits>\r
-class CBitEncoder: public CBitModel<numMoveBits>\r
-{\r
-public:\r
-  void Encode(CEncoder *encoder, UInt32 symbol)\r
-  {\r
-    /*\r
-    encoder->EncodeBit(this->Prob, kNumBitModelTotalBits, symbol);\r
-    this->UpdateModel(symbol);\r
-    */\r
-    UInt32 newBound = (encoder->Range >> kNumBitModelTotalBits) * this->Prob;\r
-    if (symbol == 0)\r
-    {\r
-      encoder->Range = newBound;\r
-      this->Prob += (kBitModelTotal - this->Prob) >> numMoveBits;\r
-    }\r
-    else\r
-    {\r
-      encoder->Low += newBound;\r
-      encoder->Range -= newBound;\r
-      this->Prob -= (this->Prob) >> numMoveBits;\r
-    }\r
-    if (encoder->Range < kTopValue)\r
-    {\r
-      encoder->Range <<= 8;\r
-      encoder->ShiftLow();\r
-    }\r
-  }\r
-  UInt32 GetPrice(UInt32 symbol) const\r
-  {\r
-    return CPriceTables::ProbPrices[\r
-      (((this->Prob - symbol) ^ ((-(int)symbol))) & (kBitModelTotal - 1)) >> kNumMoveReducingBits];\r
-  }\r
-  UInt32 GetPrice0() const { return CPriceTables::ProbPrices[this->Prob >> kNumMoveReducingBits]; }\r
-  UInt32 GetPrice1() const { return CPriceTables::ProbPrices[(kBitModelTotal - this->Prob) >> kNumMoveReducingBits]; }\r
-};\r
-\r
-\r
-template <int numMoveBits>\r
-class CBitDecoder: public CBitModel<numMoveBits>\r
-{\r
-public:\r
-  UInt32 Decode(CDecoder *decoder)\r
-  {\r
-    UInt32 newBound = (decoder->Range >> kNumBitModelTotalBits) * this->Prob;\r
-    if (decoder->Code < newBound)\r
-    {\r
-      decoder->Range = newBound;\r
-      this->Prob += (kBitModelTotal - this->Prob) >> numMoveBits;\r
-      if (decoder->Range < kTopValue)\r
-      {\r
-        decoder->Code = (decoder->Code << 8) | decoder->Stream.ReadByte();\r
-        decoder->Range <<= 8;\r
-      }\r
-      return 0;\r
-    }\r
-    else\r
-    {\r
-      decoder->Range -= newBound;\r
-      decoder->Code -= newBound;\r
-      this->Prob -= (this->Prob) >> numMoveBits;\r
-      if (decoder->Range < kTopValue)\r
-      {\r
-        decoder->Code = (decoder->Code << 8) | decoder->Stream.ReadByte();\r
-        decoder->Range <<= 8;\r
-      }\r
-      return 1;\r
-    }\r
-  }\r
-};\r
-\r
-}}\r
-\r
-#endif\r
+// Compress/RangeCoder/RangeCoderBit.h
+
+#ifndef __COMPRESS_RANGECODER_BIT_H
+#define __COMPRESS_RANGECODER_BIT_H
+
+#include "RangeCoder.h"
+
+namespace NCompress {
+namespace NRangeCoder {
+
+const int kNumBitModelTotalBits  = 11;
+const UInt32 kBitModelTotal = (1 << kNumBitModelTotalBits);
+
+const int kNumMoveReducingBits = 2;
+
+const int kNumBitPriceShiftBits = 6;
+const UInt32 kBitPrice = 1 << kNumBitPriceShiftBits;
+
+class CPriceTables
+{
+public:
+  static UInt32 ProbPrices[kBitModelTotal >> kNumMoveReducingBits];
+  static void Init();
+  CPriceTables();
+};
+
+template <int numMoveBits>
+class CBitModel
+{
+public:
+  UInt32 Prob;
+  void UpdateModel(UInt32 symbol)
+  {
+    /*
+    Prob -= (Prob + ((symbol - 1) & ((1 << numMoveBits) - 1))) >> numMoveBits;
+    Prob += (1 - symbol) << (kNumBitModelTotalBits - numMoveBits);
+    */
+    if (symbol == 0)
+      Prob += (kBitModelTotal - Prob) >> numMoveBits;
+    else
+      Prob -= (Prob) >> numMoveBits;
+  }
+public:
+  void Init() { Prob = kBitModelTotal / 2; }
+};
+
+template <int numMoveBits>
+class CBitEncoder: public CBitModel<numMoveBits>
+{
+public:
+  void Encode(CEncoder *encoder, UInt32 symbol)
+  {
+    /*
+    encoder->EncodeBit(this->Prob, kNumBitModelTotalBits, symbol);
+    this->UpdateModel(symbol);
+    */
+    UInt32 newBound = (encoder->Range >> kNumBitModelTotalBits) * this->Prob;
+    if (symbol == 0)
+    {
+      encoder->Range = newBound;
+      this->Prob += (kBitModelTotal - this->Prob) >> numMoveBits;
+    }
+    else
+    {
+      encoder->Low += newBound;
+      encoder->Range -= newBound;
+      this->Prob -= (this->Prob) >> numMoveBits;
+    }
+    if (encoder->Range < kTopValue)
+    {
+      encoder->Range <<= 8;
+      encoder->ShiftLow();
+    }
+  }
+  UInt32 GetPrice(UInt32 symbol) const
+  {
+    return CPriceTables::ProbPrices[
+      (((this->Prob - symbol) ^ ((-(int)symbol))) & (kBitModelTotal - 1)) >> kNumMoveReducingBits];
+  }
+  UInt32 GetPrice0() const { return CPriceTables::ProbPrices[this->Prob >> kNumMoveReducingBits]; }
+  UInt32 GetPrice1() const { return CPriceTables::ProbPrices[(kBitModelTotal - this->Prob) >> kNumMoveReducingBits]; }
+};
+
+
+template <int numMoveBits>
+class CBitDecoder: public CBitModel<numMoveBits>
+{
+public:
+  UInt32 Decode(CDecoder *decoder)
+  {
+    UInt32 newBound = (decoder->Range >> kNumBitModelTotalBits) * this->Prob;
+    if (decoder->Code < newBound)
+    {
+      decoder->Range = newBound;
+      this->Prob += (kBitModelTotal - this->Prob) >> numMoveBits;
+      if (decoder->Range < kTopValue)
+      {
+        decoder->Code = (decoder->Code << 8) | decoder->Stream.ReadByte();
+        decoder->Range <<= 8;
+      }
+      return 0;
+    }
+    else
+    {
+      decoder->Range -= newBound;
+      decoder->Code -= newBound;
+      this->Prob -= (this->Prob) >> numMoveBits;
+      if (decoder->Range < kTopValue)
+      {
+        decoder->Code = (decoder->Code << 8) | decoder->Stream.ReadByte();
+        decoder->Range <<= 8;
+      }
+      return 1;
+    }
+  }
+};
+
+}}
+
+#endif