diff options
Diffstat (limited to 'vendor/github.com/boombuler/barcode/qr/errorcorrection.go')
| -rw-r--r-- | vendor/github.com/boombuler/barcode/qr/errorcorrection.go | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/vendor/github.com/boombuler/barcode/qr/errorcorrection.go b/vendor/github.com/boombuler/barcode/qr/errorcorrection.go deleted file mode 100644 index 950fa82..0000000 --- a/vendor/github.com/boombuler/barcode/qr/errorcorrection.go +++ /dev/null @@ -1,54 +0,0 @@ -package qr - -import ( - "github.com/boombuler/barcode/utils" - "sync" -) - -type errorCorrection struct { - fld *utils.GaloisField - - m *sync.Mutex - polynomes []*utils.GFPoly -} - -var ec = newGF() - -func newGF() *errorCorrection { - fld := utils.NewGaloisField(285) - - return &errorCorrection{fld, - new(sync.Mutex), - []*utils.GFPoly{ - utils.NewGFPoly(fld, []byte{1}), - }, - } -} - -func (ec *errorCorrection) getPolynomial(degree int) *utils.GFPoly { - ec.m.Lock() - defer ec.m.Unlock() - - if degree >= len(ec.polynomes) { - last := ec.polynomes[len(ec.polynomes)-1] - for d := len(ec.polynomes); d <= degree; d++ { - next := last.Multiply(utils.NewGFPoly(ec.fld, []byte{1, byte(ec.fld.ALogTbl[d-1])})) - ec.polynomes = append(ec.polynomes, next) - last = next - } - } - return ec.polynomes[degree] -} - -func (ec *errorCorrection) calcECC(data []byte, eccCount byte) []byte { - generator := ec.getPolynomial(int(eccCount)) - info := utils.NewGFPoly(ec.fld, data) - info = info.MultByMonominal(int(eccCount), 1) - - _, remainder := info.Divide(generator) - - result := make([]byte, eccCount) - numZero := int(eccCount) - len(remainder.Coefficients) - copy(result[numZero:], remainder.Coefficients) - return result -} |
