Beispiel #1
0
 /// <summary>
 /// <p>Given data and error-correction codewords received, possibly corrupted by errors, attempts to
 /// correct the errors in-place.</p>
 ///
 /// <param name="codewords">data and error correction codewords</param>
 /// </summary>
 private bool correctErrors(int[] codewords,
                            int[] erasures,
                            int numECCodewords)
 {
     if (erasures.Length > numECCodewords / 2 + MAX_ERRORS ||
         numECCodewords < 0 || numECCodewords > MAX_EC_CODEWORDS)
     {
         // Too many errors or EC Codewords is corrupted
         return(false);
     }
     return(errorCorrection.decode(codewords, numECCodewords, erasures));
 }
        private bool checkDecode(int[] received, int[] erasures)
        {
            if (!ec.decode(received, ECC_BYTES, erasures))
            {
                return(false);
            }

            for (int i = 0; i < PDF417_TEST.Length; i++)
            {
                if (received[i] != PDF417_TEST[i])
                {
                    return(false);
                }
            }

            return(true);
        }
        /// <summary>
        /// Given data and error-correction codewords received, possibly corrupted by errors, attempts to
        /// correct the errors in-place.
        /// </summary>
        /// <returns>The errors.</returns>
        /// <param name="codewords">data and error correction codewords.</param>
        /// <param name="erasures">positions of any known erasures.</param>
        /// <param name="numECCodewords">number of error correction codewords that are available in codewords.</param>
        private static int correctErrors(int[] codewords, int[] erasures, int numECCodewords)
        {
            if (erasures != null &&
                erasures.Length > numECCodewords / 2 + MAX_ERRORS ||
                numECCodewords < 0 ||
                numECCodewords > MAX_EC_CODEWORDS)
            {
                // Too many errors or EC Codewords is corrupted
                return(-1);
            }
            int errorCount;

            if (!errorCorrection.decode(codewords, numECCodewords, erasures, out errorCount))
            {
                return(-1);
            }
            return(errorCount);
        }