• R/O
  • SSH
  • HTTPS

reedsolomon: Commit


Commit MetaInfo

Revision31 (tree)
Time2009-07-31 08:10:40
Authorm-miyzaki

Log Message

delete BCH_15_5.java

Change Summary

  • delete: src/jp/sourceforge/reedsolomon/BCH_15_5.java

Incremental Difference

--- src/jp/sourceforge/reedsolomon/BCH_15_5.java (revision 30)
+++ src/jp/sourceforge/reedsolomon/BCH_15_5.java (nonexistent)
@@ -1,75 +0,0 @@
1-package jp.sourceforge.reedsolomon;
2-
3-/**
4- * BCH(15, 5) Encoder/Decoder
5- *
6- * @author Masayuki Miyazaki
7- * http://sourceforge.jp/projects/reedsolomon/
8- */
9-public final class BCH_15_5 {
10- private static final int GX = 0x137;
11- private static final BCH_15_5 instance = new BCH_15_5();
12- private int[] trueCodes = new int[32];
13-
14- private BCH_15_5() {
15- makeTrueCodes();
16- }
17-
18- public static BCH_15_5 getInstance() {
19- return instance;
20- }
21-
22- private void makeTrueCodes() {
23- for(int i = 0; i < trueCodes.length; i++) {
24- trueCodes[i] = slowEncode(i);
25- }
26- }
27-
28- private int slowEncode(int data) {
29- int wk = 0;
30- data <<= 5;
31- for(int i = 0; i < 5; i++) {
32- wk <<= 1;
33- data <<= 1;
34- if(((wk ^ data) & 0x400) != 0) {
35- wk ^= GX;
36- }
37- }
38- return (data & 0x7c00) | (wk & 0x3ff);
39- }
40-
41- public int encode(int data) {
42- return trueCodes[data & 0x1f];
43- }
44-
45- private static int calcDistance(int c1, int c2) {
46- int n = 0;
47- int wk = c1 ^ c2;
48- while(wk != 0) {
49- if((wk & 1) != 0) {
50- n++;
51- }
52- wk >>= 1;
53- }
54- return n;
55- }
56-
57- /**
58- * BCH(15, 5) Decoder
59- *
60- * @param data int
61- * input data
62- * @return int
63- * -1 : fail
64- * >= 0 : corrected data
65- */
66- public int decode(int data) {
67- data &= 0x7fff;
68- for(int code: trueCodes) {
69- if(calcDistance(data, code) <= 3) {
70- return code;
71- }
72- }
73- return -1;
74- }
75-}
Deleted: svn:executable
Show on old repository browser