类com.google.zxing.common.reedsolomon.ReedSolomonException源码实例Demo

下面列出了怎么用com.google.zxing.common.reedsolomon.ReedSolomonException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: ScreenCapture   文件: Decoder.java
/**
 * <p>Given data and error-correction codewords received, possibly corrupted by errors, attempts to
 * correct the errors in-place using Reed-Solomon error correction.</p>
 *
 * @param codewordBytes data and error correction codewords
 * @param numDataCodewords number of codewords that are data bytes
 * @throws ChecksumException if error correction fails
 */
private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumException {
  int numCodewords = codewordBytes.length;
  // First read into an array of ints
  int[] codewordsInts = new int[numCodewords];
  for (int i = 0; i < numCodewords; i++) {
    codewordsInts[i] = codewordBytes[i] & 0xFF;
  }
  try {
    rsDecoder.decode(codewordsInts, codewordBytes.length - numDataCodewords);
  } catch (ReedSolomonException ignored) {
    throw ChecksumException.getChecksumInstance();
  }
  // Copy back into array of bytes -- only need to worry about the bytes that were data
  // We don't care about errors in the error-correction codewords
  for (int i = 0; i < numDataCodewords; i++) {
    codewordBytes[i] = (byte) codewordsInts[i];
  }
}
 
源代码2 项目: Tesseract-OCR-Scanner   文件: Decoder.java
/**
 * <p>Given data and error-correction codewords received, possibly corrupted by errors, attempts to
 * correct the errors in-place using Reed-Solomon error correction.</p>
 *
 * @param codewordBytes data and error correction codewords
 * @param numDataCodewords number of codewords that are data bytes
 * @throws ChecksumException if error correction fails
 */
private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumException {
  int numCodewords = codewordBytes.length;
  // First read into an array of ints
  int[] codewordsInts = new int[numCodewords];
  for (int i = 0; i < numCodewords; i++) {
    codewordsInts[i] = codewordBytes[i] & 0xFF;
  }
  try {
    rsDecoder.decode(codewordsInts, codewordBytes.length - numDataCodewords);
  } catch (ReedSolomonException ignored) {
    throw ChecksumException.getChecksumInstance();
  }
  // Copy back into array of bytes -- only need to worry about the bytes that were data
  // We don't care about errors in the error-correction codewords
  for (int i = 0; i < numDataCodewords; i++) {
    codewordBytes[i] = (byte) codewordsInts[i];
  }
}
 
源代码3 项目: QrCodeScanner   文件: Decoder.java
/**
 * <p>Given data and error-correction codewords received, possibly corrupted by errors, attempts to
 * correct the errors in-place using Reed-Solomon error correction.</p>
 *
 * @param codewordBytes data and error correction codewords
 * @param numDataCodewords number of codewords that are data bytes
 * @throws ChecksumException if error correction fails
 */
private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumException {
  int numCodewords = codewordBytes.length;
  // First read into an array of ints
  int[] codewordsInts = new int[numCodewords];
  for (int i = 0; i < numCodewords; i++) {
    codewordsInts[i] = codewordBytes[i] & 0xFF;
  }
  try {
    rsDecoder.decode(codewordsInts, codewordBytes.length - numDataCodewords);
  } catch (ReedSolomonException ignored) {
    throw ChecksumException.getChecksumInstance();
  }
  // Copy back into array of bytes -- only need to worry about the bytes that were data
  // We don't care about errors in the error-correction codewords
  for (int i = 0; i < numDataCodewords; i++) {
    codewordBytes[i] = (byte) codewordsInts[i];
  }
}
 
源代码4 项目: ZXing-Orient   文件: Decoder.java
/**
 * <p>Given data and error-correction codewords received, possibly corrupted by errors, attempts to
 * correct the errors in-place using Reed-Solomon error correction.</p>
 *
 * @param codewordBytes data and error correction codewords
 * @param numDataCodewords number of codewords that are data bytes
 * @throws ChecksumException if error correction fails
 */
private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumException {
  int numCodewords = codewordBytes.length;
  // First read into an array of ints
  int[] codewordsInts = new int[numCodewords];
  for (int i = 0; i < numCodewords; i++) {
    codewordsInts[i] = codewordBytes[i] & 0xFF;
  }
  int numECCodewords = codewordBytes.length - numDataCodewords;
  try {
    rsDecoder.decode(codewordsInts, numECCodewords);
  } catch (ReedSolomonException ignored) {
    throw ChecksumException.getChecksumInstance();
  }
  // Copy back into array of bytes -- only need to worry about the bytes that were data
  // We don't care about errors in the error-correction codewords
  for (int i = 0; i < numDataCodewords; i++) {
    codewordBytes[i] = (byte) codewordsInts[i];
  }
}
 
源代码5 项目: ZXing-Orient   文件: Decoder.java
/**
 * <p>Given data and error-correction codewords received, possibly corrupted by errors, attempts to
 * correct the errors in-place using Reed-Solomon error correction.</p>
 *
 * @param codewordBytes data and error correction codewords
 * @param numDataCodewords number of codewords that are data bytes
 * @throws ChecksumException if error correction fails
 */
private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumException {
  int numCodewords = codewordBytes.length;
  // First read into an array of ints
  int[] codewordsInts = new int[numCodewords];
  for (int i = 0; i < numCodewords; i++) {
    codewordsInts[i] = codewordBytes[i] & 0xFF;
  }
  int numECCodewords = codewordBytes.length - numDataCodewords;
  try {
    rsDecoder.decode(codewordsInts, numECCodewords);
  } catch (ReedSolomonException ignored) {
    throw ChecksumException.getChecksumInstance();
  }
  // Copy back into array of bytes -- only need to worry about the bytes that were data
  // We don't care about errors in the error-correction codewords
  for (int i = 0; i < numDataCodewords; i++) {
    codewordBytes[i] = (byte) codewordsInts[i];
  }
}
 
/**
 * <p>Given data and error-correction codewords received, possibly corrupted by errors, attempts to
 * correct the errors in-place using Reed-Solomon error correction.</p>
 *
 * @param codewordBytes data and error correction codewords
 * @param numDataCodewords number of codewords that are data bytes
 * @throws ChecksumException if error correction fails
 */
private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumException {
  int numCodewords = codewordBytes.length;
  // First read into an array of ints
  int[] codewordsInts = new int[numCodewords];
  for (int i = 0; i < numCodewords; i++) {
    codewordsInts[i] = codewordBytes[i] & 0xFF;
  }
  int numECCodewords = codewordBytes.length - numDataCodewords;
  try {
    rsDecoder.decode(codewordsInts, numECCodewords);
  } catch (ReedSolomonException ignored) {
    throw ChecksumException.getChecksumInstance();
  }
  // Copy back into array of bytes -- only need to worry about the bytes that were data
  // We don't care about errors in the error-correction codewords
  for (int i = 0; i < numDataCodewords; i++) {
    codewordBytes[i] = (byte) codewordsInts[i];
  }
}
 
/**
 * <p>Given data and error-correction codewords received, possibly corrupted by errors, attempts to
 * correct the errors in-place using Reed-Solomon error correction.</p>
 *
 * @param codewordBytes data and error correction codewords
 * @param numDataCodewords number of codewords that are data bytes
 * @throws ChecksumException if error correction fails
 */
private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumException {
  int numCodewords = codewordBytes.length;
  // First read into an array of ints
  int[] codewordsInts = new int[numCodewords];
  for (int i = 0; i < numCodewords; i++) {
    codewordsInts[i] = codewordBytes[i] & 0xFF;
  }
  int numECCodewords = codewordBytes.length - numDataCodewords;
  try {
    rsDecoder.decode(codewordsInts, numECCodewords);
  } catch (ReedSolomonException ignored) {
    throw ChecksumException.getChecksumInstance();
  }
  // Copy back into array of bytes -- only need to worry about the bytes that were data
  // We don't care about errors in the error-correction codewords
  for (int i = 0; i < numDataCodewords; i++) {
    codewordBytes[i] = (byte) codewordsInts[i];
  }
}
 
源代码8 项目: weex   文件: Decoder.java
/**
 * <p>Given data and error-correction codewords received, possibly corrupted by errors, attempts to
 * correct the errors in-place using Reed-Solomon error correction.</p>
 *
 * @param codewordBytes data and error correction codewords
 * @param numDataCodewords number of codewords that are data bytes
 * @throws ChecksumException if error correction fails
 */
private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumException {
  int numCodewords = codewordBytes.length;
  // First read into an array of ints
  int[] codewordsInts = new int[numCodewords];
  for (int i = 0; i < numCodewords; i++) {
    codewordsInts[i] = codewordBytes[i] & 0xFF;
  }
  int numECCodewords = codewordBytes.length - numDataCodewords;
  try {
    rsDecoder.decode(codewordsInts, numECCodewords);
  } catch (ReedSolomonException ignored) {
    throw ChecksumException.getChecksumInstance();
  }
  // Copy back into array of bytes -- only need to worry about the bytes that were data
  // We don't care about errors in the error-correction codewords
  for (int i = 0; i < numDataCodewords; i++) {
    codewordBytes[i] = (byte) codewordsInts[i];
  }
}
 
源代码9 项目: weex   文件: Decoder.java
/**
 * <p>Given data and error-correction codewords received, possibly corrupted by errors, attempts to
 * correct the errors in-place using Reed-Solomon error correction.</p>
 *
 * @param codewordBytes data and error correction codewords
 * @param numDataCodewords number of codewords that are data bytes
 * @throws ChecksumException if error correction fails
 */
private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumException {
  int numCodewords = codewordBytes.length;
  // First read into an array of ints
  int[] codewordsInts = new int[numCodewords];
  for (int i = 0; i < numCodewords; i++) {
    codewordsInts[i] = codewordBytes[i] & 0xFF;
  }
  int numECCodewords = codewordBytes.length - numDataCodewords;
  try {
    rsDecoder.decode(codewordsInts, numECCodewords);
  } catch (ReedSolomonException ignored) {
    throw ChecksumException.getChecksumInstance();
  }
  // Copy back into array of bytes -- only need to worry about the bytes that were data
  // We don't care about errors in the error-correction codewords
  for (int i = 0; i < numDataCodewords; i++) {
    codewordBytes[i] = (byte) codewordsInts[i];
  }
}
 
源代码10 项目: barcodescanner-lib-aar   文件: Decoder.java
/**
 * <p>Given data and error-correction codewords received, possibly corrupted by errors, attempts to
 * correct the errors in-place using Reed-Solomon error correction.</p>
 *
 * @param codewordBytes data and error correction codewords
 * @param numDataCodewords number of codewords that are data bytes
 * @throws ChecksumException if error correction fails
 */
private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumException {
  int numCodewords = codewordBytes.length;
  // First read into an array of ints
  int[] codewordsInts = new int[numCodewords];
  for (int i = 0; i < numCodewords; i++) {
    codewordsInts[i] = codewordBytes[i] & 0xFF;
  }
  try {
    rsDecoder.decode(codewordsInts, codewordBytes.length - numDataCodewords);
  } catch (ReedSolomonException ignored) {
    throw ChecksumException.getChecksumInstance();
  }
  // Copy back into array of bytes -- only need to worry about the bytes that were data
  // We don't care about errors in the error-correction codewords
  for (int i = 0; i < numDataCodewords; i++) {
    codewordBytes[i] = (byte) codewordsInts[i];
  }
}
 
源代码11 项目: barcodescanner-lib-aar   文件: Decoder.java
/**
 * <p>Given data and error-correction codewords received, possibly corrupted by errors, attempts to
 * correct the errors in-place using Reed-Solomon error correction.</p>
 *
 * @param codewordBytes data and error correction codewords
 * @param numDataCodewords number of codewords that are data bytes
 * @throws ChecksumException if error correction fails
 */
private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumException {
  int numCodewords = codewordBytes.length;
  // First read into an array of ints
  int[] codewordsInts = new int[numCodewords];
  for (int i = 0; i < numCodewords; i++) {
    codewordsInts[i] = codewordBytes[i] & 0xFF;
  }
  try {
    rsDecoder.decode(codewordsInts, codewordBytes.length - numDataCodewords);
  } catch (ReedSolomonException ignored) {
    throw ChecksumException.getChecksumInstance();
  }
  // Copy back into array of bytes -- only need to worry about the bytes that were data
  // We don't care about errors in the error-correction codewords
  for (int i = 0; i < numDataCodewords; i++) {
    codewordBytes[i] = (byte) codewordsInts[i];
  }
}
 
源代码12 项目: reacteu-app   文件: Decoder.java
/**
 * <p>Given data and error-correction codewords received, possibly corrupted by errors, attempts to
 * correct the errors in-place using Reed-Solomon error correction.</p>
 *
 * @param codewordBytes data and error correction codewords
 * @param numDataCodewords number of codewords that are data bytes
 * @throws ChecksumException if error correction fails
 */
private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumException {
  int numCodewords = codewordBytes.length;
  // First read into an array of ints
  int[] codewordsInts = new int[numCodewords];
  for (int i = 0; i < numCodewords; i++) {
    codewordsInts[i] = codewordBytes[i] & 0xFF;
  }
  int numECCodewords = codewordBytes.length - numDataCodewords;
  try {
    rsDecoder.decode(codewordsInts, numECCodewords);
  } catch (ReedSolomonException rse) {
    throw ChecksumException.getChecksumInstance();
  }
  // Copy back into array of bytes -- only need to worry about the bytes that were data
  // We don't care about errors in the error-correction codewords
  for (int i = 0; i < numDataCodewords; i++) {
    codewordBytes[i] = (byte) codewordsInts[i];
  }
}
 
源代码13 项目: reacteu-app   文件: Decoder.java
/**
 * <p>Given data and error-correction codewords received, possibly corrupted by errors, attempts to
 * correct the errors in-place using Reed-Solomon error correction.</p>
 *
 * @param codewordBytes data and error correction codewords
 * @param numDataCodewords number of codewords that are data bytes
 * @throws ChecksumException if error correction fails
 */
private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumException {
  int numCodewords = codewordBytes.length;
  // First read into an array of ints
  int[] codewordsInts = new int[numCodewords];
  for (int i = 0; i < numCodewords; i++) {
    codewordsInts[i] = codewordBytes[i] & 0xFF;
  }
  int numECCodewords = codewordBytes.length - numDataCodewords;
  try {
    rsDecoder.decode(codewordsInts, numECCodewords);
  } catch (ReedSolomonException rse) {
    throw ChecksumException.getChecksumInstance();
  }
  // Copy back into array of bytes -- only need to worry about the bytes that were data
  // We don't care about errors in the error-correction codewords
  for (int i = 0; i < numDataCodewords; i++) {
    codewordBytes[i] = (byte) codewordsInts[i];
  }
}
 
源代码14 项目: MiBandDecompiled   文件: Decoder.java
private void a(byte abyte0[], int i)
{
    int j = 0;
    int k = abyte0.length;
    int ai[] = new int[k];
    for (int l = 0; l < k; l++)
    {
        ai[l] = 0xff & abyte0[l];
    }

    int i1 = abyte0.length - i;
    try
    {
        a.decode(ai, i1);
    }
    catch (ReedSolomonException reedsolomonexception)
    {
        throw ChecksumException.getChecksumInstance();
    }
    for (; j < i; j++)
    {
        abyte0[j] = (byte)ai[j];
    }

}
 
源代码15 项目: MiBandDecompiled   文件: Decoder.java
private void a(byte abyte0[], int i)
{
    int j = 0;
    int k = abyte0.length;
    int ai[] = new int[k];
    for (int l = 0; l < k; l++)
    {
        ai[l] = 0xff & abyte0[l];
    }

    int i1 = abyte0.length - i;
    try
    {
        a.decode(ai, i1);
    }
    catch (ReedSolomonException reedsolomonexception)
    {
        throw ChecksumException.getChecksumInstance();
    }
    for (; j < i; j++)
    {
        abyte0[j] = (byte)ai[j];
    }

}
 
源代码16 项目: RipplePower   文件: Decoder.java
/**
 * <p>
 * Given data and error-correction codewords received, possibly corrupted by
 * errors, attempts to correct the errors in-place using Reed-Solomon error
 * correction.
 * </p>
 * 
 * @param codewordBytes
 *            data and error correction codewords
 * @param numDataCodewords
 *            number of codewords that are data bytes
 * @throws ChecksumException
 *             if error correction fails
 */
private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumException {
	int numCodewords = codewordBytes.length;
	// First read into an array of ints
	int[] codewordsInts = new int[numCodewords];
	for (int i = 0; i < numCodewords; i++) {
		codewordsInts[i] = codewordBytes[i] & 0xFF;
	}
	int numECCodewords = codewordBytes.length - numDataCodewords;
	try {
		rsDecoder.decode(codewordsInts, numECCodewords);
	} catch (ReedSolomonException ignored) {
		throw ChecksumException.getChecksumInstance();
	}
	// Copy back into array of bytes -- only need to worry about the bytes
	// that were data
	// We don't care about errors in the error-correction codewords
	for (int i = 0; i < numDataCodewords; i++) {
		codewordBytes[i] = (byte) codewordsInts[i];
	}
}
 
源代码17 项目: RipplePower   文件: Decoder.java
/**
 * <p>
 * Given data and error-correction codewords received, possibly corrupted by
 * errors, attempts to correct the errors in-place using Reed-Solomon error
 * correction.
 * </p>
 * 
 * @param codewordBytes
 *            data and error correction codewords
 * @param numDataCodewords
 *            number of codewords that are data bytes
 * @throws ChecksumException
 *             if error correction fails
 */
private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumException {
	int numCodewords = codewordBytes.length;
	// First read into an array of ints
	int[] codewordsInts = new int[numCodewords];
	for (int i = 0; i < numCodewords; i++) {
		codewordsInts[i] = codewordBytes[i] & 0xFF;
	}
	int numECCodewords = codewordBytes.length - numDataCodewords;
	try {
		rsDecoder.decode(codewordsInts, numECCodewords);
	} catch (ReedSolomonException ignored) {
		throw ChecksumException.getChecksumInstance();
	}
	// Copy back into array of bytes -- only need to worry about the bytes
	// that were data
	// We don't care about errors in the error-correction codewords
	for (int i = 0; i < numDataCodewords; i++) {
		codewordBytes[i] = (byte) codewordsInts[i];
	}
}
 
源代码18 项目: Telegram-FOSS   文件: Decoder.java
/**
 * <p>Given data and error-correction codewords received, possibly corrupted by errors, attempts to
 * correct the errors in-place using Reed-Solomon error correction.</p>
 *
 * @param codewordBytes data and error correction codewords
 * @param numDataCodewords number of codewords that are data bytes
 * @throws ChecksumException if error correction fails
 */
private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumException {
  int numCodewords = codewordBytes.length;
  // First read into an array of ints
  int[] codewordsInts = new int[numCodewords];
  for (int i = 0; i < numCodewords; i++) {
    codewordsInts[i] = codewordBytes[i] & 0xFF;
  }
  try {
    rsDecoder.decode(codewordsInts, codewordBytes.length - numDataCodewords);
  } catch (ReedSolomonException ignored) {
    throw ChecksumException.getChecksumInstance();
  }
  // Copy back into array of bytes -- only need to worry about the bytes that were data
  // We don't care about errors in the error-correction codewords
  for (int i = 0; i < numDataCodewords; i++) {
    codewordBytes[i] = (byte) codewordsInts[i];
  }
}
 
源代码19 项目: barterli_android   文件: Decoder.java
/**
 * <p>
 * Given data and error-correction codewords received, possibly corrupted by
 * errors, attempts to correct the errors in-place using Reed-Solomon error
 * correction.
 * </p>
 * 
 * @param codewordBytes
 *            data and error correction codewords
 * @param numDataCodewords
 *            number of codewords that are data bytes
 * @throws ChecksumException
 *             if error correction fails
 */
private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumException {
    int numCodewords = codewordBytes.length;
    // First read into an array of ints
    int[] codewordsInts = new int[numCodewords];
    for (int i = 0; i < numCodewords; i++) {
        codewordsInts[i] = codewordBytes[i] & 0xFF;
    }
    int numECCodewords = codewordBytes.length - numDataCodewords;
    try {
        rsDecoder.decode(codewordsInts, numECCodewords);
    } catch (ReedSolomonException rse) {
        throw ChecksumException.getChecksumInstance();
    }
    // Copy back into array of bytes -- only need to worry about the bytes
    // that were data
    // We don't care about errors in the error-correction codewords
    for (int i = 0; i < numDataCodewords; i++) {
        codewordBytes[i] = (byte) codewordsInts[i];
    }
}
 
源代码20 项目: android-quick-response-code   文件: Decoder.java
/**
 * <p>
 * Given data and error-correction codewords received, possibly corrupted by
 * errors, attempts to correct the errors in-place using Reed-Solomon error
 * correction.
 * </p>
 * 
 * @param codewordBytes
 *            data and error correction codewords
 * @param numDataCodewords
 *            number of codewords that are data bytes
 * @throws ChecksumException
 *             if error correction fails
 */
private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumException {
    int numCodewords = codewordBytes.length;
    // First read into an array of ints
    int[] codewordsInts = new int[numCodewords];
    for (int i = 0; i < numCodewords; i++) {
        codewordsInts[i] = codewordBytes[i] & 0xFF;
    }
    int numECCodewords = codewordBytes.length - numDataCodewords;
    try {
        rsDecoder.decode(codewordsInts, numECCodewords);
    } catch (ReedSolomonException rse) {
        throw ChecksumException.getChecksumInstance();
    }
    // Copy back into array of bytes -- only need to worry about the bytes
    // that were data
    // We don't care about errors in the error-correction codewords
    for (int i = 0; i < numDataCodewords; i++) {
        codewordBytes[i] = (byte) codewordsInts[i];
    }
}
 
源代码21 项目: Telegram   文件: Decoder.java
/**
 * <p>Given data and error-correction codewords received, possibly corrupted by errors, attempts to
 * correct the errors in-place using Reed-Solomon error correction.</p>
 *
 * @param codewordBytes data and error correction codewords
 * @param numDataCodewords number of codewords that are data bytes
 * @throws ChecksumException if error correction fails
 */
private void correctErrors(byte[] codewordBytes, int numDataCodewords) throws ChecksumException {
  int numCodewords = codewordBytes.length;
  // First read into an array of ints
  int[] codewordsInts = new int[numCodewords];
  for (int i = 0; i < numCodewords; i++) {
    codewordsInts[i] = codewordBytes[i] & 0xFF;
  }
  try {
    rsDecoder.decode(codewordsInts, codewordBytes.length - numDataCodewords);
  } catch (ReedSolomonException ignored) {
    throw ChecksumException.getChecksumInstance();
  }
  // Copy back into array of bytes -- only need to worry about the bytes that were data
  // We don't care about errors in the error-correction codewords
  for (int i = 0; i < numDataCodewords; i++) {
    codewordBytes[i] = (byte) codewordsInts[i];
  }
}
 
源代码22 项目: ZXing-Orient   文件: Detector.java
/**
 * Corrects the parameter bits using Reed-Solomon algorithm.
 *
 * @param parameterData parameter bits
 * @param compact true if this is a compact Aztec code
 * @throws NotFoundException if the array contains too many errors
 */
private static int getCorrectedParameterData(long parameterData, boolean compact) throws NotFoundException {
  int numCodewords;
  int numDataCodewords;

  if (compact) {
    numCodewords = 7;
    numDataCodewords = 2;
  } else {
    numCodewords = 10;
    numDataCodewords = 4;
  }

  int numECCodewords = numCodewords - numDataCodewords;
  int[] parameterWords = new int[numCodewords];
  for (int i = numCodewords - 1; i >= 0; --i) {
    parameterWords[i] = (int) parameterData & 0xF;
    parameterData >>= 4;
  }
  try {
    ReedSolomonDecoder rsDecoder = new ReedSolomonDecoder(GenericGF.AZTEC_PARAM);
    rsDecoder.decode(parameterWords, numECCodewords);
  } catch (ReedSolomonException ignored) {
    throw NotFoundException.getNotFoundInstance();
  }
  // Toss the error correction.  Just return the data as an integer
  int result = 0;
  for (int i = 0; i < numDataCodewords; i++) {
    result = (result << 4) + parameterWords[i];
  }
  return result;
}
 
源代码23 项目: ZXing-Orient   文件: Decoder.java
private void correctErrors(byte[] codewordBytes,
                           int start,
                           int dataCodewords,
                           int ecCodewords,
                           int mode) throws ChecksumException {
  int codewords = dataCodewords + ecCodewords;

  // in EVEN or ODD mode only half the codewords
  int divisor = mode == ALL ? 1 : 2;

  // First read into an array of ints
  int[] codewordsInts = new int[codewords / divisor];
  for (int i = 0; i < codewords; i++) {
    if ((mode == ALL) || (i % 2 == (mode - 1))) {
      codewordsInts[i / divisor] = codewordBytes[i + start] & 0xFF;
    }
  }
  try {
    rsDecoder.decode(codewordsInts, ecCodewords / divisor);
  } catch (ReedSolomonException ignored) {
    throw ChecksumException.getChecksumInstance();
  }
  // Copy back into array of bytes -- only need to worry about the bytes that were data
  // We don't care about errors in the error-correction codewords
  for (int i = 0; i < dataCodewords; i++) {
    if ((mode == ALL) || (i % 2 == (mode - 1))) {
      codewordBytes[i + start] = (byte) codewordsInts[i / divisor];
    }
  }
}
 
/**
 * Corrects the parameter bits using Reed-Solomon algorithm.
 *
 * @param parameterData parameter bits
 * @param compact true if this is a compact Aztec code
 * @throws NotFoundException if the array contains too many errors
 */
private static int getCorrectedParameterData(long parameterData, boolean compact) throws NotFoundException {
  int numCodewords;
  int numDataCodewords;

  if (compact) {
    numCodewords = 7;
    numDataCodewords = 2;
  } else {
    numCodewords = 10;
    numDataCodewords = 4;
  }

  int numECCodewords = numCodewords - numDataCodewords;
  int[] parameterWords = new int[numCodewords];
  for (int i = numCodewords - 1; i >= 0; --i) {
    parameterWords[i] = (int) parameterData & 0xF;
    parameterData >>= 4;
  }
  try {
    ReedSolomonDecoder rsDecoder = new ReedSolomonDecoder(GenericGF.AZTEC_PARAM);
    rsDecoder.decode(parameterWords, numECCodewords);
  } catch (ReedSolomonException ignored) {
    throw NotFoundException.getNotFoundInstance();
  }
  // Toss the error correction.  Just return the data as an integer
  int result = 0;
  for (int i = 0; i < numDataCodewords; i++) {
    result = (result << 4) + parameterWords[i];
  }
  return result;
}
 
private void correctErrors(byte[] codewordBytes,
                           int start,
                           int dataCodewords,
                           int ecCodewords,
                           int mode) throws ChecksumException {
  int codewords = dataCodewords + ecCodewords;

  // in EVEN or ODD mode only half the codewords
  int divisor = mode == ALL ? 1 : 2;

  // First read into an array of ints
  int[] codewordsInts = new int[codewords / divisor];
  for (int i = 0; i < codewords; i++) {
    if ((mode == ALL) || (i % 2 == (mode - 1))) {
      codewordsInts[i / divisor] = codewordBytes[i + start] & 0xFF;
    }
  }
  try {
    rsDecoder.decode(codewordsInts, ecCodewords / divisor);
  } catch (ReedSolomonException ignored) {
    throw ChecksumException.getChecksumInstance();
  }
  // Copy back into array of bytes -- only need to worry about the bytes that were data
  // We don't care about errors in the error-correction codewords
  for (int i = 0; i < dataCodewords; i++) {
    if ((mode == ALL) || (i % 2 == (mode - 1))) {
      codewordBytes[i + start] = (byte) codewordsInts[i / divisor];
    }
  }
}
 
源代码26 项目: weex   文件: Detector.java
/**
 * Corrects the parameter bits using Reed-Solomon algorithm.
 *
 * @param parameterData parameter bits
 * @param compact true if this is a compact Aztec code
 * @throws NotFoundException if the array contains too many errors
 */
private static int getCorrectedParameterData(long parameterData, boolean compact) throws NotFoundException {
  int numCodewords;
  int numDataCodewords;

  if (compact) {
    numCodewords = 7;
    numDataCodewords = 2;
  } else {
    numCodewords = 10;
    numDataCodewords = 4;
  }

  int numECCodewords = numCodewords - numDataCodewords;
  int[] parameterWords = new int[numCodewords];
  for (int i = numCodewords - 1; i >= 0; --i) {
    parameterWords[i] = (int) parameterData & 0xF;
    parameterData >>= 4;
  }
  try {
    ReedSolomonDecoder rsDecoder = new ReedSolomonDecoder(GenericGF.AZTEC_PARAM);
    rsDecoder.decode(parameterWords, numECCodewords);
  } catch (ReedSolomonException ignored) {
    throw NotFoundException.getNotFoundInstance();
  }
  // Toss the error correction.  Just return the data as an integer
  int result = 0;
  for (int i = 0; i < numDataCodewords; i++) {
    result = (result << 4) + parameterWords[i];
  }
  return result;
}
 
源代码27 项目: weex   文件: Decoder.java
private void correctErrors(byte[] codewordBytes,
                           int start,
                           int dataCodewords,
                           int ecCodewords,
                           int mode) throws ChecksumException {
  int codewords = dataCodewords + ecCodewords;

  // in EVEN or ODD mode only half the codewords
  int divisor = mode == ALL ? 1 : 2;

  // First read into an array of ints
  int[] codewordsInts = new int[codewords / divisor];
  for (int i = 0; i < codewords; i++) {
    if ((mode == ALL) || (i % 2 == (mode - 1))) {
      codewordsInts[i / divisor] = codewordBytes[i + start] & 0xFF;
    }
  }
  try {
    rsDecoder.decode(codewordsInts, ecCodewords / divisor);
  } catch (ReedSolomonException ignored) {
    throw ChecksumException.getChecksumInstance();
  }
  // Copy back into array of bytes -- only need to worry about the bytes that were data
  // We don't care about errors in the error-correction codewords
  for (int i = 0; i < dataCodewords; i++) {
    if ((mode == ALL) || (i % 2 == (mode - 1))) {
      codewordBytes[i + start] = (byte) codewordsInts[i / divisor];
    }
  }
}
 
源代码28 项目: pied-piper   文件: EncoderDecoder.java
/**
 * 
 * Repairs and decodes the supplied byte array, removing the error correction codes and returning the original data
 * 
 * @param data The bytes to be repaired/decoded
 * @param numErrorCorrectionBytes The number of error correction bytes present in the encoded data.
 * If this field is incorrect the encoded data may not be able to be repaired/encoded
 * @return The decoded/repaired data. The returned byte array will be N bytes shorter than the supplied 
 * encoded data, where N equals the number of error correction bytes within the encoded byte array
 * @throws ReedSolomonException if the data is not able to be repaired/decoded
 * @throws DataTooLargeException if the supplied byte array is greater than 256 bytes
 */
public byte[] decodeData(byte[] data, int numErrorCorrectionBytes) throws ReedSolomonException, DataTooLargeException{
		
	if(data == null || data.length == 0){
		return null;
	}
	if(data.length > 256){
		throw new DataTooLargeException("Data exceeds 256 bytes! Too large");
	}
	
	int[] dataInts = new int[data.length];
	
	for(int i = 0; i < data.length; i++){
	  dataInts[i] = data[i] & 0xFF;
	}
			
	int totalBytes = data.length - numErrorCorrectionBytes; 
	
	decoder.decode(dataInts, numErrorCorrectionBytes);		
	
	ByteArrayOutputStream bos = new ByteArrayOutputStream();
	
	for(int i = 0; i < totalBytes && i < dataInts.length; i++){
		bos.write(dataInts[i]); // read in all the data sans error correction codes
	}
	
	return bos.toByteArray();
}
 
源代码29 项目: barcodescanner-lib-aar   文件: Detector.java
/**
 * Corrects the parameter bits using Reed-Solomon algorithm.
 *
 * @param parameterData parameter bits
 * @param compact true if this is a compact Aztec code
 * @throws NotFoundException if the array contains too many errors
 */
private static int getCorrectedParameterData(long parameterData, boolean compact) throws NotFoundException {
  int numCodewords;
  int numDataCodewords;

  if (compact) {
    numCodewords = 7;
    numDataCodewords = 2;
  } else {
    numCodewords = 10;
    numDataCodewords = 4;
  }

  int numECCodewords = numCodewords - numDataCodewords;
  int[] parameterWords = new int[numCodewords];
  for (int i = numCodewords - 1; i >= 0; --i) {
    parameterWords[i] = (int) parameterData & 0xF;
    parameterData >>= 4;
  }
  try {
    ReedSolomonDecoder rsDecoder = new ReedSolomonDecoder(GenericGF.AZTEC_PARAM);
    rsDecoder.decode(parameterWords, numECCodewords);
  } catch (ReedSolomonException ignored) {
    throw NotFoundException.getNotFoundInstance();
  }
  // Toss the error correction.  Just return the data as an integer
  int result = 0;
  for (int i = 0; i < numDataCodewords; i++) {
    result = (result << 4) + parameterWords[i];
  }
  return result;
}
 
源代码30 项目: barcodescanner-lib-aar   文件: Decoder.java
private void correctErrors(byte[] codewordBytes,
                           int start,
                           int dataCodewords,
                           int ecCodewords,
                           int mode) throws ChecksumException {
  int codewords = dataCodewords + ecCodewords;

  // in EVEN or ODD mode only half the codewords
  int divisor = mode == ALL ? 1 : 2;

  // First read into an array of ints
  int[] codewordsInts = new int[codewords / divisor];
  for (int i = 0; i < codewords; i++) {
    if ((mode == ALL) || (i % 2 == (mode - 1))) {
      codewordsInts[i / divisor] = codewordBytes[i + start] & 0xFF;
    }
  }
  try {
    rsDecoder.decode(codewordsInts, ecCodewords / divisor);
  } catch (ReedSolomonException ignored) {
    throw ChecksumException.getChecksumInstance();
  }
  // Copy back into array of bytes -- only need to worry about the bytes that were data
  // We don't care about errors in the error-correction codewords
  for (int i = 0; i < dataCodewords; i++) {
    if ((mode == ALL) || (i % 2 == (mode - 1))) {
      codewordBytes[i + start] = (byte) codewordsInts[i / divisor];
    }
  }
}
 
 类所在包
 同包方法