Advertisement
JetSerge

Untitled

Feb 27th, 2014
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.77 KB | None | 0 0
  1. // Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
  2. // Jad home page: http://www.geocities.com/kpdus/jad.html
  3. // Decompiler options: braces fieldsfirst space lnc
  4.  
  5. package com.tpvision.ambilightplushue.helpers;
  6.  
  7. import java.util.concurrent.atomic.AtomicInteger;
  8.  
  9. // Referenced classes of package com.tpvision.ambilightplushue.helpers:
  10. //            ColorGamut
  11.  
  12. public class Algorithm
  13. {
  14.  
  15.     private static final float MAX_BRI_0 = 0.3F;
  16.     private static final float MAX_BRI_SLIDER_DYN = 0.7F;
  17.     private static final float MAX_SAT = 1.25F;
  18.     private static final float MAX_SAT_SLIDER = 0.8F;
  19.     private static final float MAX_TT = 10F;
  20.     private static final float MAX_TT_DELTA = 8F;
  21.     private static final float MAX_TT_SLIDER = 1F;
  22.     private static final float MIN_BRI_IN = 0.2F;
  23.     private static final float MIN_SAT = 0.85F;
  24.     private static final float MIN_SAT_SLIDER = 0.2F;
  25.     private static final float MIN_TT = 3F;
  26.     private static final float MIN_TT_DELTA = 2F;
  27.     private static final float MIN_TT_SLIDER = 0.2F;
  28.     public static final int MODEL_DEFAULT = -1;
  29.     public static final int MODEL_TYPE_HUE = 0;
  30.     public static final int MODEL_TYPE_LIVING_COLOR = 1;
  31.     private static final float XB_AL = 0.270844F;
  32.     private static final float XG_AL = 0.301434F;
  33.     private static final float XR_AL = 0.399454F;
  34.     private static final float YB_AL = 0.130816F;
  35.     private static final float YG_AL = 0.666385F;
  36.     private static final float YR_AL = 0.202799F;
  37.     private static final float ZB_AL = 1.440815F;
  38.     private static final float ZG_AL = 0.108732F;
  39.     private static final float ZR_AL = 0.012291F;
  40.  
  41.     public Algorithm()
  42.     {
  43.     }
  44.  
  45.     private static float clip(float f, float f1, float f2)
  46.     {
  47.         if (f > f2)
  48.         {
  49.             return f2;
  50.         }
  51.         if (f < f1)
  52.         {
  53.             return f1;
  54.         } else
  55.         {
  56.             return f;
  57.         }
  58.     }
  59.  
  60.     public static float[] convertRGBtoXY_final(float f, float f1, float f2, int i, int j, int k, AtomicInteger atomicinteger, AtomicInteger atomicinteger1,
  61.             int l, int i1, String s)
  62.     {
  63.         float f3 = (float)i1 / 10F;
  64.         float f4 = Math.max(0.0F, Math.min(1.0F, (float)l / 10F));
  65.         float f5 = Math.max(0.0F, Math.min(1.0F, f3));
  66.         float f6 = clip(fun_y(f4, 0.2F, 0.8F, 0.85F, 1.25F), 0.85F, 1.25F);
  67.         float f7 = Math.max(f6 - 1.0F, 0.0F);
  68.         float f8 = Math.max(Math.max(f, f1), f2);
  69.         if (f6 < 1.0F)
  70.         {
  71.             float f35 = 0.2126F * f + 0.7152F * f1 + 0.0722F * f2;
  72.             f = f6 * f + f35 * (1.0F - f6);
  73.             f1 = f6 * f1 + f35 * (1.0F - f6);
  74.             f2 = f6 * f2 + f35 * (1.0F - f6);
  75.         }
  76.         float f9 = 0.399454F * f + 0.301434F * f1 + 0.270844F * f2;
  77.         float f10 = 0.202799F * f + 0.666385F * f1 + 0.130816F * f2;
  78.         float f11 = 0.012291F * f + 0.108732F * f1 + 1.440815F * f2 + (f9 + f10);
  79.         float f12;
  80.         float f13;
  81.         float f14;
  82.         float f15;
  83.         float f16;
  84.         if (f11 > 1E-06F)
  85.         {
  86.             f12 = f9 / f11;
  87.             f13 = f10 / f11;
  88.         } else
  89.         {
  90.             f12 = 0.33F;
  91.             f13 = 0.31F;
  92.         }
  93.         f14 = f12 + f7 * (f12 - 0.3127F);
  94.         f15 = f13 + f7 * (f13 - 0.329F);
  95.         f16 = 1.0F - f14 - f15;
  96.         if (getModelType(s) == 0)
  97.         {
  98.             float f25 = 3.5784F * f14 + -2.7387F * f15 + -0.6154F * f16;
  99.             float f26 = -1.0029F * f14 + 2.1013F * f15 + 0.1052F * f16;
  100.             float f27 = 0.1451F * f14 + -0.3176F * f15 + 1.4407F * f16;
  101.             float f28 = Math.max(0.0F, f25);
  102.             float f29 = Math.max(0.0F, f26);
  103.             float f30 = Math.max(0.0F, f27);
  104.             float f31 = f29;
  105.             float af[];
  106.             float af1[];
  107.             float f17;
  108.             float f18;
  109.             float f19;
  110.             float f20;
  111.             float f21;
  112.             float f22;
  113.             float f23;
  114.             float f24;
  115.             float f32;
  116.             float f33;
  117.             float f34;
  118.             if (f30 < f29 && f29 < f28)
  119.             {
  120.                 f31 = f29 - (0.5F * (f28 - f29) * (f29 - f30)) / (f28 - f30);
  121.             } else
  122.             if (f28 < f29 && f29 < f30)
  123.             {
  124.                 f31 = f29 - (0.5F * (f30 - f29) * (f29 - f28)) / (f30 - f28);
  125.             }
  126.             f32 = 0.4407F * f28 + 0.5962F * f31 + 0.1447F * f30;
  127.             f33 = 0.2102F * f28 + 0.7551F * f31 + 0.0347F * f30;
  128.             f34 = 0.002F * f28 + 0.1064F * f31 + 0.6872F * f30 + (f32 + f33);
  129.             if (f34 > 1E-06F)
  130.             {
  131.                 f14 = f32 / f34;
  132.                 f15 = f33 / f34;
  133.             } else
  134.             {
  135.                 f14 = 0.33F;
  136.                 f15 = 0.31F;
  137.             }
  138.         }
  139.         getModelType(s);
  140.         af = desaturate(f14, f15, 0.33F, 0.31F, f8, 0.1F);
  141.         af1 = ColorGamut.fixXYColor(af[0], af[1], s);
  142.         f17 = af1[0];
  143.         f18 = af1[1];
  144.         f19 = (float)Math.sqrt(f8);
  145.         f20 = f5 * Math.min(f4 / 0.7F, 1.0F);
  146.         f21 = Math.max(0.0F, f5 - f20);
  147.         f22 = f21 + Math.min(1.0F, f19 * f20);
  148.         if (f19 < 0.2F)
  149.         {
  150.             f24 = fun_y(f19, 0.0F, 0.2F, 0.3F, f21 + Math.min(1.0F, 0.2F * f20));
  151.             f22 = Math.min(f22, f24);
  152.         }
  153.         f23 = f22;
  154.         atomicinteger1.set((int)clip(fun_y(f4, 0.2F, 1.0F, 10F + 8F * (float)(j / 2), 3F + 2.0F * (float)(j / 2)), 3F + 2.0F * (float)(j / 2), 10F + 8F * (float)(j / 2)));
  155.         atomicinteger.set((int)(255F * Math.min(Math.max(f23 + 0.0F, 0.0F), 1.0F)));
  156.         return (new float[] {
  157.             f17, f18
  158.         });
  159.     }
  160.  
  161.     private static float[] desaturate(float f, float f1, float f2, float f3, float f4, float f5)
  162.     {
  163.         float f6 = f;
  164.         float f7 = f1;
  165.         if (f4 < f5)
  166.         {
  167.             float f8 = f4 / f5;
  168.             f6 = f * f8 + f2 * (1.0F - f8);
  169.             f7 = f1 * f8 + f3 * (1.0F - f8);
  170.         }
  171.         return (new float[] {
  172.             f6, f7
  173.         });
  174.     }
  175.  
  176.     private static float fun_y(float f, float f1, float f2, float f3, float f4)
  177.     {
  178.         int i = f2 - f1 != 0.0F;
  179.         float f5 = 0.0F;
  180.         if (i != 0)
  181.         {
  182.             float f6 = (f4 - f3) / (f2 - f1);
  183.             f5 = (f3 - f6 * f1) + f6 * f;
  184.         }
  185.         return f5;
  186.     }
  187.  
  188.     public static int getModelType(String s)
  189.     {
  190.         if (s.equals("LCT001") || s.equals("LCT002") || s.equals("LCT003"))
  191.         {
  192.             return 0;
  193.         }
  194.         return !s.equals("LLC001") && !s.equals("LLC005") && !s.equals("LLC006") && !s.equals("LLC007") && !s.equals("LLC011") && !s.equals("LLC012") && !s.equals("LLC013") && !s.equals("LLC014") && !s.equals("LLS001") && !s.equals("LST001") ? -1 : 1;
  195.     }
  196. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement