OSDN
> 軟體搜索
> Multimedia
> Graphics
> Open Source QR Code Library
> 討論區
> English
> ** Good News: Fixed ReedSolomon.java available **

From <a href=http://www.drhu.org/j2se.php?url=QRCode/QRCode.html>here</a>, you can find the fixed java source code of ReedSolomon.java which fixed several bugs in the original c version.

Great job, it really works,

but I have to change lines with eccPerRSBlock/2 to

eccPerRSBlock

jascco

but I have to change lines with eccPerRSBlock/2 to

eccPerRSBlock

jascco

回覆: #32698

Congratulations!

I'm a project leader for JAVA reed-solomon library at

http://sourceforge.jp/projects/reedsolomon

Your source code has a problem for ramdom data correction as below and returns correctionSucceeded is true.

It was succeeded from the original c-source.

public static void main(String[] args) {

java.util.Random random = new java.util.Random();

for(int count = 0; count < 10; count++) {

int[] data = new int[255];

for(int i = 0; i < data.length; i++) {

data[i] = random.nextInt() & 0xff;

}

ReedSolomon rs = new ReedSolomon(data, 17);

rs.correct();

System.out.println(rs.correctionSucceeded);

}

}

I'm a project leader for JAVA reed-solomon library at

http://sourceforge.jp/projects/reedsolomon

Your source code has a problem for ramdom data correction as below and returns correctionSucceeded is true.

It was succeeded from the original c-source.

public static void main(String[] args) {

java.util.Random random = new java.util.Random();

for(int count = 0; count < 10; count++) {

int[] data = new int[255];

for(int i = 0; i < data.length; i++) {

data[i] = random.nextInt() & 0xff;

}

ReedSolomon rs = new ReedSolomon(data, 17);

rs.correct();

System.out.println(rs.correctionSucceeded);

}

}

回覆: #32698

*** orig\ReedSolomon.java Fri Oct 12 01:15:41 2007

--- ReedSolomon.java Fri Oct 12 01:04:07 2007

***************

*** 161,167 ****

}

/* From Cain, Clark, "Error-Correction Coding For Digital Communications", pp. 216. */

! void Modified_Berlekamp_Massey() {

int L2, d;

int[] psi = new int[MAXDEG];

int[] psi2 = new int[MAXDEG];

--- 161,167 ----

}

/* From Cain, Clark, "Error-Correction Coding For Digital Communications", pp. 216. */

! boolean Modified_Berlekamp_Massey() {

int L2, d;

int[] psi = new int[MAXDEG];

int[] psi2 = new int[MAXDEG];

***************

*** 196,201 ****

--- 196,203 ----

/* D = scale_poly(ginv(d), psi); */

for (int i = 0; i < MAXDEG; i++) D[i] = gmult(psi[i], ginv(d));

L = L2;

+ if(L > NPAR / 2)

+ return false;

}

/* psi = psi2 */

***************

*** 208,213 ****

--- 210,216 ----

for(int i = 0; i < MAXDEG; i++) Lambda[i] = psi[i];

//printArray(Lambda);

compute_modified_omega();

+ return true;

}

/* given Psi (called Lambda in Modified_Berlekamp_Massey) and synBytes,

***************

*** 328,334 ****

NErasures = nerasures;

for (int i = 0; i < NErasures; i++) ErasureLocs[i] = erasures[i];

! Modified_Berlekamp_Massey();

Find_Roots();

if (NErrors == 0) return true;

--- 331,338 ----

NErasures = nerasures;

for (int i = 0; i < NErasures; i++) ErasureLocs[i] = erasures[i];

! if(!Modified_Berlekamp_Massey())

! return false;

Find_Roots();

if (NErrors == 0) return true;

--- ReedSolomon.java Fri Oct 12 01:04:07 2007

***************

*** 161,167 ****

}

/* From Cain, Clark, "Error-Correction Coding For Digital Communications", pp. 216. */

! void Modified_Berlekamp_Massey() {

int L2, d;

int[] psi = new int[MAXDEG];

int[] psi2 = new int[MAXDEG];

--- 161,167 ----

}

/* From Cain, Clark, "Error-Correction Coding For Digital Communications", pp. 216. */

! boolean Modified_Berlekamp_Massey() {

int L2, d;

int[] psi = new int[MAXDEG];

int[] psi2 = new int[MAXDEG];

***************

*** 196,201 ****

--- 196,203 ----

/* D = scale_poly(ginv(d), psi); */

for (int i = 0; i < MAXDEG; i++) D[i] = gmult(psi[i], ginv(d));

L = L2;

+ if(L > NPAR / 2)

+ return false;

}

/* psi = psi2 */

***************

*** 208,213 ****

--- 210,216 ----

for(int i = 0; i < MAXDEG; i++) Lambda[i] = psi[i];

//printArray(Lambda);

compute_modified_omega();

+ return true;

}

/* given Psi (called Lambda in Modified_Berlekamp_Massey) and synBytes,

***************

*** 328,334 ****

NErasures = nerasures;

for (int i = 0; i < NErasures; i++) ErasureLocs[i] = erasures[i];

! Modified_Berlekamp_Massey();

Find_Roots();

if (NErrors == 0) return true;

--- 331,338 ----

NErasures = nerasures;

for (int i = 0; i < NErasures; i++) ErasureLocs[i] = erasures[i];

! if(!Modified_Berlekamp_Massey())

! return false;

Find_Roots();

if (NErrors == 0) return true;

回覆: #32729

The degree of the lambda is compared with NErrors.

*** orig/ReedSolomon.java 2007-10-13 08:07:22.000000000 +0900

--- ReedSolomon.java 2007-10-13 09:01:20.000000000 +0900

***************

*** 160,166 ****

}

/* From Cain, Clark, "Error-Correction Coding For Digital Communications", pp. 216. */

! void Modified_Berlekamp_Massey() {

int L2, d;

int[] psi = new int[MAXDEG];

int[] psi2 = new int[MAXDEG];

--- 160,166 ----

}

/* From Cain, Clark, "Error-Correction Coding For Digital Communications", pp. 216. */

! int Modified_Berlekamp_Massey() {

int L2, d;

int[] psi = new int[MAXDEG];

int[] psi2 = new int[MAXDEG];

***************

*** 207,212 ****

--- 207,213 ----

for(int i = 0; i < MAXDEG; i++) Lambda[i] = psi[i];

//printArray(Lambda);

compute_modified_omega();

+ return L;

}

/* given Psi (called Lambda in Modified_Berlekamp_Massey) and synBytes,

***************

*** 327,334 ****

NErasures = nerasures;

for (int i = 0; i < NErasures; i++) ErasureLocs[i] = erasures[i];

! Modified_Berlekamp_Massey();

Find_Roots();

if (NErrors == 0) return true;

if (NErrors <= NPAR) {

--- 328,337 ----

NErasures = nerasures;

for (int i = 0; i < NErasures; i++) ErasureLocs[i] = erasures[i];

! int degree = Modified_Berlekamp_Massey();

! if(degree > NPAR / 2) return false;

Find_Roots();

+ if(degree != NErrors) return false;

if (NErrors == 0) return true;

if (NErrors <= NPAR) {

*** orig/ReedSolomon.java 2007-10-13 08:07:22.000000000 +0900

--- ReedSolomon.java 2007-10-13 09:01:20.000000000 +0900

***************

*** 160,166 ****

}

/* From Cain, Clark, "Error-Correction Coding For Digital Communications", pp. 216. */

! void Modified_Berlekamp_Massey() {

int L2, d;

int[] psi = new int[MAXDEG];

int[] psi2 = new int[MAXDEG];

--- 160,166 ----

}

/* From Cain, Clark, "Error-Correction Coding For Digital Communications", pp. 216. */

! int Modified_Berlekamp_Massey() {

int L2, d;

int[] psi = new int[MAXDEG];

int[] psi2 = new int[MAXDEG];

***************

*** 207,212 ****

--- 207,213 ----

for(int i = 0; i < MAXDEG; i++) Lambda[i] = psi[i];

//printArray(Lambda);

compute_modified_omega();

+ return L;

}

/* given Psi (called Lambda in Modified_Berlekamp_Massey) and synBytes,

***************

*** 327,334 ****

NErasures = nerasures;

for (int i = 0; i < NErasures; i++) ErasureLocs[i] = erasures[i];

! Modified_Berlekamp_Massey();

Find_Roots();

if (NErrors == 0) return true;

if (NErrors <= NPAR) {

--- 328,337 ----

NErasures = nerasures;

for (int i = 0; i < NErasures; i++) ErasureLocs[i] = erasures[i];

! int degree = Modified_Berlekamp_Massey();

! if(degree > NPAR / 2) return false;

Find_Roots();

+ if(degree != NErrors) return false;

if (NErrors == 0) return true;

if (NErrors <= NPAR) {

回覆: #32732

I don't understand what you mean. If you find a bug in my code, please let me know. Or if you have a specific test tthat can fail my code, let me know also.

回覆: #32729

It is an original c-source bug rather than yours.

Please test on the following conditions.

Number of parity(NPAR) = 17

data length(with parity) = 255

Number of errors = 9

The decoder should notify the correction failure.

However, the success is actually notified.

(correctionSucceeded = true)

I will E-mail the test program, if you need it.

Please test on the following conditions.

Number of parity(NPAR) = 17

data length(with parity) = 255

Number of errors = 9

The decoder should notify the correction failure.

However, the success is actually notified.

(correctionSucceeded = true)

I will E-mail the test program, if you need it.

回覆: #32760

The degree of Lambda must be equal to NErrors to correct RS-CODE correctly. It is necessary to notify the correction failure, if it is not so.

However, the original source code and yours lack this check.

However, the original source code and yours lack this check.

回覆: #32760

Please try my decoder if you are interested.

It has not such a bug and might be two times faster.

http://sourceforge.jp/projects/reedsolomon/

It has not such a bug and might be two times faster.

http://sourceforge.jp/projects/reedsolomon/

回覆: #32760

good news.

回覆: #32698