| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 // Original code is licensed as follows: | 6 // Original code is licensed as follows: |
| 7 /* | 7 /* |
| 8 * Copyright 2007 ZXing authors | 8 * Copyright 2007 ZXing authors |
| 9 * | 9 * |
| 10 * Licensed under the Apache License, Version 2.0 (the "License"); | 10 * Licensed under the Apache License, Version 2.0 (the "License"); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 { | 36 { |
| 37 if (QRCodeFild) { | 37 if (QRCodeFild) { |
| 38 delete QRCodeFild; | 38 delete QRCodeFild; |
| 39 } | 39 } |
| 40 QRCodeFild = NULL; | 40 QRCodeFild = NULL; |
| 41 if (DataMatrixField) { | 41 if (DataMatrixField) { |
| 42 delete DataMatrixField; | 42 delete DataMatrixField; |
| 43 } | 43 } |
| 44 DataMatrixField = NULL; | 44 DataMatrixField = NULL; |
| 45 } | 45 } |
| 46 CBC_ReedSolomonGF256::CBC_ReedSolomonGF256(FX_INT32 primitive) | 46 CBC_ReedSolomonGF256::CBC_ReedSolomonGF256(int32_t primitive) |
| 47 { | 47 { |
| 48 FX_INT32 x = 1; | 48 int32_t x = 1; |
| 49 for(FX_INT32 j = 0; j < 256; j++) { | 49 for(int32_t j = 0; j < 256; j++) { |
| 50 m_expTable[j] = x; | 50 m_expTable[j] = x; |
| 51 x <<= 1; | 51 x <<= 1; |
| 52 if(x >= 0x100) { | 52 if(x >= 0x100) { |
| 53 x ^= primitive; | 53 x ^= primitive; |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 for(FX_INT32 i = 0; i < 255; i++) { | 56 for(int32_t i = 0; i < 255; i++) { |
| 57 m_logTable[m_expTable[i]] = i; | 57 m_logTable[m_expTable[i]] = i; |
| 58 } | 58 } |
| 59 m_logTable[0] = 0; | 59 m_logTable[0] = 0; |
| 60 } | 60 } |
| 61 void CBC_ReedSolomonGF256::Init() | 61 void CBC_ReedSolomonGF256::Init() |
| 62 { | 62 { |
| 63 m_zero = FX_NEW CBC_ReedSolomonGF256Poly(this, 0); | 63 m_zero = FX_NEW CBC_ReedSolomonGF256Poly(this, 0); |
| 64 m_one = FX_NEW CBC_ReedSolomonGF256Poly(this, 1); | 64 m_one = FX_NEW CBC_ReedSolomonGF256Poly(this, 1); |
| 65 } | 65 } |
| 66 CBC_ReedSolomonGF256::~CBC_ReedSolomonGF256() | 66 CBC_ReedSolomonGF256::~CBC_ReedSolomonGF256() |
| 67 { | 67 { |
| 68 if(m_zero != NULL) { | 68 if(m_zero != NULL) { |
| 69 delete m_zero; | 69 delete m_zero; |
| 70 m_zero = NULL; | 70 m_zero = NULL; |
| 71 } | 71 } |
| 72 if(m_one != NULL) { | 72 if(m_one != NULL) { |
| 73 delete m_one; | 73 delete m_one; |
| 74 m_one = NULL; | 74 m_one = NULL; |
| 75 } | 75 } |
| 76 } | 76 } |
| 77 CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::GetZero() | 77 CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::GetZero() |
| 78 { | 78 { |
| 79 return m_zero; | 79 return m_zero; |
| 80 } | 80 } |
| 81 CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::GetOne() | 81 CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::GetOne() |
| 82 { | 82 { |
| 83 return m_one; | 83 return m_one; |
| 84 } | 84 } |
| 85 CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::BuildMonomial(FX_INT32 degree, F
X_INT32 coefficient, FX_INT32 &e) | 85 CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::BuildMonomial(int32_t degree, in
t32_t coefficient, int32_t &e) |
| 86 { | 86 { |
| 87 if(degree < 0) { | 87 if(degree < 0) { |
| 88 e = BCExceptionDegreeIsNegative; | 88 e = BCExceptionDegreeIsNegative; |
| 89 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 89 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
| 90 } | 90 } |
| 91 if(coefficient == 0) { | 91 if(coefficient == 0) { |
| 92 CBC_ReedSolomonGF256Poly* temp = m_zero->Clone(e); | 92 CBC_ReedSolomonGF256Poly* temp = m_zero->Clone(e); |
| 93 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 93 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
| 94 return temp; | 94 return temp; |
| 95 } | 95 } |
| 96 CFX_Int32Array coefficients; | 96 CFX_Int32Array coefficients; |
| 97 coefficients.SetSize(degree + 1); | 97 coefficients.SetSize(degree + 1); |
| 98 coefficients[0] = coefficient; | 98 coefficients[0] = coefficient; |
| 99 CBC_ReedSolomonGF256Poly *temp = FX_NEW CBC_ReedSolomonGF256Poly(); | 99 CBC_ReedSolomonGF256Poly *temp = FX_NEW CBC_ReedSolomonGF256Poly(); |
| 100 temp->Init(this, &coefficients, e); | 100 temp->Init(this, &coefficients, e); |
| 101 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 101 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
| 102 return temp; | 102 return temp; |
| 103 } | 103 } |
| 104 FX_INT32 CBC_ReedSolomonGF256::AddOrSubtract(FX_INT32 a, FX_INT32 b) | 104 int32_t CBC_ReedSolomonGF256::AddOrSubtract(int32_t a, int32_t b) |
| 105 { | 105 { |
| 106 return a ^ b; | 106 return a ^ b; |
| 107 } | 107 } |
| 108 FX_INT32 CBC_ReedSolomonGF256::Exp(FX_INT32 a) | 108 int32_t CBC_ReedSolomonGF256::Exp(int32_t a) |
| 109 { | 109 { |
| 110 return m_expTable[a]; | 110 return m_expTable[a]; |
| 111 } | 111 } |
| 112 FX_INT32 CBC_ReedSolomonGF256::Log(FX_INT32 a, FX_INT32 &e) | 112 int32_t CBC_ReedSolomonGF256::Log(int32_t a, int32_t &e) |
| 113 { | 113 { |
| 114 if(a == 0) { | 114 if(a == 0) { |
| 115 e = BCExceptionAIsZero; | 115 e = BCExceptionAIsZero; |
| 116 BC_EXCEPTION_CHECK_ReturnValue(e, 0); | 116 BC_EXCEPTION_CHECK_ReturnValue(e, 0); |
| 117 } | 117 } |
| 118 return m_logTable[a]; | 118 return m_logTable[a]; |
| 119 } | 119 } |
| 120 FX_INT32 CBC_ReedSolomonGF256::Inverse(FX_INT32 a, FX_INT32 &e) | 120 int32_t CBC_ReedSolomonGF256::Inverse(int32_t a, int32_t &e) |
| 121 { | 121 { |
| 122 if(a == 0) { | 122 if(a == 0) { |
| 123 e = BCExceptionAIsZero; | 123 e = BCExceptionAIsZero; |
| 124 BC_EXCEPTION_CHECK_ReturnValue(e, 0); | 124 BC_EXCEPTION_CHECK_ReturnValue(e, 0); |
| 125 } | 125 } |
| 126 return m_expTable[255 - m_logTable[a]]; | 126 return m_expTable[255 - m_logTable[a]]; |
| 127 } | 127 } |
| 128 FX_INT32 CBC_ReedSolomonGF256::Multiply(FX_INT32 a, FX_INT32 b) | 128 int32_t CBC_ReedSolomonGF256::Multiply(int32_t a, int32_t b) |
| 129 { | 129 { |
| 130 if(a == 0 || b == 0) { | 130 if(a == 0 || b == 0) { |
| 131 return 0; | 131 return 0; |
| 132 } | 132 } |
| 133 if(a == 1) { | 133 if(a == 1) { |
| 134 return b; | 134 return b; |
| 135 } | 135 } |
| 136 if(b == 1) { | 136 if(b == 1) { |
| 137 return a; | 137 return a; |
| 138 } | 138 } |
| 139 return m_expTable[(m_logTable[a] + m_logTable[b]) % 255]; | 139 return m_expTable[(m_logTable[a] + m_logTable[b]) % 255]; |
| 140 } | 140 } |
| OLD | NEW |