⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dmtxreedsol.c

📁 Linux系统下,二维码生成源代码.希望对大家有所帮助.
💻 C
字号:
/*libdmtx - Data Matrix Encoding/Decoding LibraryCopyright (C) 2006 Mike LaughtonThis library is free software; you can redistribute it and/ormodify it under the terms of the GNU Lesser General PublicLicense as published by the Free Software Foundation; eitherversion 2.1 of the License, or (at your option) any later version.This library is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNULesser General Public License for more details.You should have received a copy of the GNU Lesser General PublicLicense along with this library; if not, write to the Free SoftwareFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USAContact: mike@dragonflylogic.com*//* $Id: dmtxreedsol.c,v 1.3 2006/10/09 17:18:10 mblaughton Exp $ *//** * * @param XXX * @return XXX */static voidGenReedSolEcc(DmtxMatrixRegion *matrixRegion){   int i, j, val;   int dataLength = dataWordLength[matrixRegion->sizeIdx];   int errorWordCount = errorWordLength[matrixRegion->sizeIdx];   int totalLength = dataLength + errorWordCount;   unsigned char g[69], b[68];   unsigned char *codewords = matrixRegion->code;   SetEccPoly(g, errorWordCount);   memset(b, 0x00, sizeof(b));   for(i = 0; i < totalLength; i++) {      if(i < dataLength) {         val = GfSum(b[errorWordCount-1], codewords[i]);         for(j = errorWordCount - 1; j > 0; j--) {            b[j] = GfSum(b[j-1], GfProduct(g[j], val));         }         b[0] = GfProduct(g[0], val);      }      else {         codewords[i] = b[totalLength-i-1];      }   }   fprintf(stdout, "\nadd ecc:");   for(i = 0; i < matrixRegion->codeSize; i++) {      fprintf(stdout, " %d", codewords[i]);   }   fprintf(stdout, "\n");}/** * * @param XXX * @return XXX */static voidSetEccPoly(unsigned char *g, int errorWordCount){   int i, j;   memset(g, 0x01, sizeof(unsigned char) * (errorWordCount + 1));   for(i = 1; i <= errorWordCount; i++) {      for(j = i - 1; j >= 0; j--) {         g[j] = GfDoublify(g[j], i);     // g[j] *= 2**i         if(j > 0)            g[j] = GfSum(g[j], g[j-1]);  // g[j] += g[j-1]      }   }}/** * XXX * * @param * @return XXX */static intDecodeCheckErrors(DmtxMatrixRegion *matrixRegion){   int i, j;   unsigned char reg, a;   for(i = 0; i < errorWordLength[matrixRegion->sizeIdx]; i++) {      a = aLogVal[i+1];      for(j = 0, reg = 0; j < matrixRegion->codeSize; j++)         reg = GfSum(matrixRegion->code[j], GfProduct(a, reg));      if(reg != 0)         return DMTX_FAILURE;   }   return DMTX_SUCCESS;}/** * * @param XXX * @return XXX */static intGfSum(int a, int b){   return a ^ b;}/** * a times b * @param XXX * @return XXX */static intGfProduct(int a, int b){   if(a == 0 || b == 0)      return 0;   else      return aLogVal[(logVal[a] + logVal[b]) % 255];}/** * * @param XXX * @return XXX */static intGfDoublify(int a, int b){   if(a == 0) // XXX this is right, right?      return 0;   else if(b == 0)      return a; // XXX this is right, right?   else      return aLogVal[(logVal[a] + b) % 255];}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -