IppLUT8.java
4.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*
* Decompiled with CFR 0_118.
*/
package com.scene7.is.ipp.messages;
import com.scene7.is.ipp.messages.Ipp;
import com.scene7.is.ipp.messages.IppByte;
import com.scene7.is.ipp.messages.IppInt;
import com.scene7.is.ipp.messages.Offset;
import java.io.IOException;
import java.io.Writer;
public class IppLUT8 {
private byte[] lut_;
public IppLUT8(byte[] lut) {
this.lut_ = lut;
Ipp.Assert(this.lut_.length == 256, "IppLUT8 field lut length");
}
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append("[");
buffer.append("lut: ").append(String.valueOf(this.lut_)).append(" ");
buffer.append("]");
return buffer.toString();
}
public boolean equals(Object o) {
if (!(o instanceof IppLUT8)) {
return false;
}
IppLUT8 e = (IppLUT8)o;
Ipp.Assert(this.lut_.length == 256, "IppLUT8 field lut length");
Ipp.Assert(e.lut_.length == 256, "IppLUT8 field lut length");
for (int i = 0; i < 256; ++i) {
if (this.lut_[i] == e.lut_[i]) continue;
return false;
}
return true;
}
public static IppLUT8 Unstuff(byte[] arr, Offset arrayPos) {
byte[] lut = IppByte.UnstuffFixedArray(arr, arrayPos, 256);
return new IppLUT8(lut);
}
public static IppLUT8[] UnstuffArray(byte[] arr, Offset arrayPos) {
Ipp.Assert((arrayPos.val & 3) == 0, "IppLUT8 alignemt");
int count = IppInt.Unstuff(arr, arrayPos);
int size = IppInt.Unstuff(arr, arrayPos);
Ipp.Assert(count == 0 || size >= 256, "IppLUT8 count");
Offset roff = new Offset(IppInt.Unstuff(arr, arrayPos));
Offset loff = new Offset(roff.val);
IppLUT8[] result = new IppLUT8[count];
for (int i = 0; i < count; ++i) {
loff.val = roff.val;
result[i] = IppLUT8.Unstuff(arr, loff);
roff.val += size;
}
return result;
}
public static IppLUT8[] UnstuffFixedArray(byte[] arr, Offset arrayPos, int count) {
IppLUT8[] result = new IppLUT8[count];
for (int i = 0; i < count; ++i) {
result[i] = IppLUT8.Unstuff(arr, arrayPos);
}
return result;
}
public static void Stuff(byte[] arr, Offset arrayPos, Offset varPos, IppLUT8 val) {
if (val != null) {
IppByte.StuffFixedArray(arr, arrayPos, varPos, 256, val.lut());
} else {
Ipp.StuffNullBytes(arr, arrayPos, 256);
}
}
public static void StuffArray(byte[] arr, Offset arrayPos, Offset varPos, IppLUT8[] val) {
Ipp.Assert((arrayPos.val & 3) == 0, "IppLUT8 stuffarray align");
int len = val != null ? val.length : 0;
IppInt.Stuff(arr, arrayPos, varPos, len);
IppInt.Stuff(arr, arrayPos, varPos, 256);
Ipp.StuffOffset(arr, arrayPos, varPos, 1);
Offset varvarPos = new Offset(varPos.val + 256 * len);
for (int i = 0; i < len; ++i) {
IppLUT8.Stuff(arr, varPos, varvarPos, val[i]);
}
varPos.val = varvarPos.val;
}
public static void StuffFixedArray(byte[] arr, Offset arrayPos, Offset varPos, int count, IppLUT8[] val) {
Ipp.Assert(val.length == count, "IppLUT8 count");
for (int i = 0; i < count; ++i) {
IppLUT8.Stuff(arr, arrayPos, varPos, val[i]);
}
}
public static void Print(Writer tf, String label, IppLUT8 it) throws IOException {
tf.write(label + "IppLUT8: [ ");
tf.write(it.lut()[0]);
tf.write(" ... ");
tf.write(it.lut()[64]);
tf.write(" ... ");
tf.write(it.lut()[128]);
tf.write(" ... ");
tf.write(it.lut()[192]);
tf.write(" ... ");
tf.write(it.lut()[255]);
tf.write(" ]\n");
}
public static void PrintArray(Writer tf, String label, IppLUT8[] it) throws IOException {
String ll = label + "IppLUT8 Array, length: ";
tf.write(ll);
if (it == null) {
tf.write("NULL!!!\n");
return;
}
tf.write("" + it.length + "\n");
for (int i = 0; i < it.length; ++i) {
ll = label + "IppLUT8[" + String.valueOf(i) + "]: ";
IppLUT8.Print(tf, ll, it[i]);
}
}
public byte[] lut() {
return this.lut_;
}
}