move to singleton ReaderException for a bit more performance
[zxing.git] / core / src / com / google / zxing / qrcode / decoder / DataMask.java
index 225d463..6ba1b35 100755 (executable)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright 2007 Google Inc.\r
+ * Copyright 2007 ZXing authors\r
  *\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
@@ -25,14 +25,14 @@ package com.google.zxing.qrcode.decoder;
  * <p>Note that the diagram in section 6.8.1 is misleading since it indicates that i is column position\r
  * and j is row position. In fact, as the text says, i is row position and j is column position.</p>\r
  *\r
- * @author srowen@google.com (Sean Owen)\r
+ * @author Sean Owen\r
  */\r
 abstract class DataMask {\r
 \r
   /**\r
    * See ISO 18004:2006 6.8.1\r
    */\r
-  private static final DataMask[] DATA_MASKS = new DataMask[]{\r
+  private static final DataMask[] DATA_MASKS = {\r
       new DataMask000(),\r
       new DataMask001(),\r
       new DataMask010(),\r
@@ -57,7 +57,7 @@ abstract class DataMask {
 \r
   /**\r
    * @param reference a value between 0 and 7 indicating one of the eight possible\r
-   *  data mask patterns a QR Code may use\r
+   * data mask patterns a QR Code may use\r
    * @return {@link DataMask} encapsulating the data mask pattern\r
    */\r
   static DataMask forReference(int reference) {\r
@@ -84,7 +84,7 @@ abstract class DataMask {
   }\r
 \r
   /**\r
-   * 001: mask bits for which j mod 2 == 0\r
+   * 001: mask bits for which i mod 2 == 0\r
    */\r
   private static class DataMask001 extends DataMask {\r
     void unmaskBitMatrix(int[] bits, int dimension) {\r
@@ -165,9 +165,9 @@ abstract class DataMask {
       int count = 0;\r
       int offset = 0;\r
       for (int j = 0; j < dimension; j++) {\r
-        int jComponent = j / 3;\r
+        int jComponentParity = (j / 3) & 0x01;\r
         for (int i = 0; i < dimension; i++) {\r
-          if (((i >> 1 + jComponent) & 0x01) == 0) {\r
+          if (((i >> 1) & 0x01) == jComponentParity) {\r
             bitMask |= 1 << count;\r
           }\r
           if (++count == 32) {\r