Changed license to CC0
[imagesqueeze.git] / src / main / java / eu / svjatoslav / imagesqueeze / codec / OperatingContext.java
index e96d610..b79e1e6 100755 (executable)
@@ -1,64 +1,59 @@
 /*
- * Imagesqueeze - Image codec optimized for photos.
- * Copyright (C) 2012, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
- * 
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public License
- * as published by the Free Software Foundation.
+ * Image codec. Author: Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
+ * This project is released under Creative Commons Zero (CC0) license.
  */
-
 package eu.svjatoslav.imagesqueeze.codec;
 
-public class OperatingContext {
-
-       Image image;
-       byte[] yMap;
-       byte[] uMap;
-       byte[] vMap;
-       ColorStats colorStats = new ColorStats();
-
-       public OperatingContext() {
-       }
-
-       public int getURange(final int index) {
-               final int colorness = ImageEncoder.byteToInt(uMap[index]);
-               return Math.abs(colorness - colorStats.getAverageU());
-       }
-
-       public int getVRange(final int index) {
-               final int color = ImageEncoder.byteToInt(vMap[index]);
-               return Math.abs(color - colorStats.getAverageV());
-       }
-
-       public int getYRange(final int index) {
-               final int brightness = ImageEncoder.byteToInt(yMap[index]);
-               return Math.abs(brightness - colorStats.getAverageY());
-       }
-
-       public void initialize(final Image image, final byte[] brightnessMap,
-                       final byte[] colornessMap, final byte[] colorMap) {
-               this.image = image;
-               yMap = brightnessMap;
-               uMap = colornessMap;
-               vMap = colorMap;
-
-               colorStats.reset();
-       }
-
-       public void measureNeighborEncode(final int x, final int y) {
-               if ((y >= 0) && (y < image.metaData.height) && (x >= 0)
-                               && (x < image.metaData.width)) {
-
-                       final int neighborIndex = (y * image.metaData.width) + x;
-
-                       colorStats.ySum = colorStats.ySum
-                                       + ImageEncoder.byteToInt(yMap[neighborIndex]);
-                       colorStats.uSum = colorStats.uSum
-                                       + ImageEncoder.byteToInt(uMap[neighborIndex]);
-                       colorStats.vSum = colorStats.vSum
-                                       + ImageEncoder.byteToInt(vMap[neighborIndex]);
-                       colorStats.pixelCount++;
-               }
-       }
+class OperatingContext {
+
+    final ColorStats colorStats = new ColorStats();
+    private Image image;
+    private byte[] yMap;
+    private byte[] uMap;
+    private byte[] vMap;
+
+    public OperatingContext() {
+    }
+
+    public int getURange(final int index) {
+        final int colorness = ImageEncoder.byteToInt(uMap[index]);
+        return Math.abs(colorness - colorStats.getAverageU());
+    }
+
+    public int getVRange(final int index) {
+        final int color = ImageEncoder.byteToInt(vMap[index]);
+        return Math.abs(color - colorStats.getAverageV());
+    }
+
+    public int getYRange(final int index) {
+        final int brightness = ImageEncoder.byteToInt(yMap[index]);
+        return Math.abs(brightness - colorStats.getAverageY());
+    }
+
+    public void initialize(final Image image, final byte[] brightnessMap,
+                           final byte[] colornessMap, final byte[] colorMap) {
+        this.image = image;
+        yMap = brightnessMap;
+        uMap = colornessMap;
+        vMap = colorMap;
+
+        colorStats.reset();
+    }
+
+    public void measureNeighborEncode(final int x, final int y) {
+        if ((y >= 0) && (y < image.metaData.height) && (x >= 0)
+                && (x < image.metaData.width)) {
+
+            final int neighborIndex = (y * image.metaData.width) + x;
+
+            colorStats.ySum = colorStats.ySum
+                    + ImageEncoder.byteToInt(yMap[neighborIndex]);
+            colorStats.uSum = colorStats.uSum
+                    + ImageEncoder.byteToInt(uMap[neighborIndex]);
+            colorStats.vSum = colorStats.vSum
+                    + ImageEncoder.byteToInt(vMap[neighborIndex]);
+            colorStats.pixelCount++;
+        }
+    }
 
 }