Cleanup some fx_codec_fax.cpp code.
[pdfium.git] / core / src / fxcodec / jbig2 / JBig2_HuffmanDecoder.cpp
index 8199fe7..d5acc36 100644 (file)
@@ -1,55 +1,53 @@
-// Copyright 2014 PDFium Authors. All rights reserved.\r
-// Use of this source code is governed by a BSD-style license that can be\r
-// found in the LICENSE file.\r
\r
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
-\r
-#include "JBig2_HuffmanDecoder.h"\r
-CJBig2_HuffmanDecoder::CJBig2_HuffmanDecoder(CJBig2_BitStream *pStream)\r
-{\r
-    m_pStream = pStream;\r
-}\r
-CJBig2_HuffmanDecoder::~CJBig2_HuffmanDecoder()\r
-{\r
-}\r
-int CJBig2_HuffmanDecoder::decodeAValue(CJBig2_HuffmanTable *pTable, int *nResult)\r
-{\r
-    int nVal, nTmp, i, nBits;\r
-    nVal = 0;\r
-    nBits = 0;\r
-    while(1) {\r
-        if(m_pStream->read1Bit(&nTmp) == -1) {\r
-            return -1;\r
-        }\r
-        nVal = (nVal << 1) | nTmp;\r
-        nBits ++;\r
-        for(i = 0; i < pTable->NTEMP; i++) {\r
-            if((pTable->PREFLEN[i] == nBits) && (pTable->CODES[i] == nVal)) {\r
-                if((pTable->HTOOB == 1) && (i == pTable->NTEMP - 1)) {\r
-                    return JBIG2_OOB;\r
-                }\r
-                if(m_pStream->readNBits(pTable->RANGELEN[i], &nTmp) == -1) {\r
-                    return -1;\r
-                }\r
-                if(pTable->HTOOB) {\r
-                    if(i == pTable->NTEMP - 3) {\r
-                        *nResult = pTable->RANGELOW[i] - nTmp;\r
-                        return 0;\r
-                    } else {\r
-                        *nResult = pTable->RANGELOW[i] + nTmp;\r
-                        return 0;\r
-                    }\r
-                } else {\r
-                    if(i == pTable->NTEMP - 2) {\r
-                        *nResult = pTable->RANGELOW[i] - nTmp;\r
-                        return 0;\r
-                    } else {\r
-                        *nResult = pTable->RANGELOW[i] + nTmp;\r
-                        return 0;\r
-                    }\r
-                }\r
-            }\r
-        }\r
-    }\r
-    return -2;\r
-}\r
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "JBig2_HuffmanDecoder.h"
+CJBig2_HuffmanDecoder::CJBig2_HuffmanDecoder(CJBig2_BitStream* pStream) {
+  m_pStream = pStream;
+}
+CJBig2_HuffmanDecoder::~CJBig2_HuffmanDecoder() {}
+int CJBig2_HuffmanDecoder::decodeAValue(CJBig2_HuffmanTable* pTable,
+                                        int* nResult) {
+  int i;
+  int nVal = 0;
+  int nBits = 0;
+  FX_DWORD nTmp;
+  while (1) {
+    if (m_pStream->read1Bit(&nTmp) == -1) {
+      return -1;
+    }
+    nVal = (nVal << 1) | nTmp;
+    nBits++;
+    for (i = 0; i < pTable->NTEMP; i++) {
+      if ((pTable->PREFLEN[i] == nBits) && (pTable->CODES[i] == nVal)) {
+        if ((pTable->HTOOB == 1) && (i == pTable->NTEMP - 1)) {
+          return JBIG2_OOB;
+        }
+        if (m_pStream->readNBits(pTable->RANGELEN[i], &nTmp) == -1) {
+          return -1;
+        }
+        if (pTable->HTOOB) {
+          if (i == pTable->NTEMP - 3) {
+            *nResult = pTable->RANGELOW[i] - nTmp;
+            return 0;
+          } else {
+            *nResult = pTable->RANGELOW[i] + nTmp;
+            return 0;
+          }
+        } else {
+          if (i == pTable->NTEMP - 2) {
+            *nResult = pTable->RANGELOW[i] - nTmp;
+            return 0;
+          } else {
+            *nResult = pTable->RANGELOW[i] + nTmp;
+            return 0;
+          }
+        }
+      }
+    }
+  }
+  return -2;
+}