fixes issue #11
This commit is contained in:
parent
d1c739eed5
commit
56a31058a9
|
@ -29,7 +29,15 @@ func (s *dmCodeSize) DataCodewords() int {
|
|||
return ((s.MatrixColumns() * s.MatrixRows()) / 8) - s.ECCCount
|
||||
}
|
||||
|
||||
func (s *dmCodeSize) DataCodewordsPerBlock() int {
|
||||
func (s *dmCodeSize) DataCodewordsForBlock(idx int) int {
|
||||
if s.Rows == 144 && s.Columns == 144 {
|
||||
// Special Case...
|
||||
if idx < 8 {
|
||||
return 156
|
||||
} else {
|
||||
return 155
|
||||
}
|
||||
}
|
||||
return s.DataCodewords() / s.BlockCount
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ func (ec *errorCorrection) calcECCBlock(data []byte, poly []int) []byte {
|
|||
}
|
||||
|
||||
func (ec *errorCorrection) calcECC(data []byte, size *dmCodeSize) []byte {
|
||||
buff := make([]byte, size.DataCodewordsPerBlock())
|
||||
|
||||
poly := ec.getPolynomial(size.ErrorCorrectionCodewordsPerBlock())
|
||||
|
||||
dataSize := len(data)
|
||||
|
@ -62,6 +62,9 @@ func (ec *errorCorrection) calcECC(data []byte, size *dmCodeSize) []byte {
|
|||
data = append(data, make([]byte, size.ECCCount)...)
|
||||
|
||||
for block := 0; block < size.BlockCount; block++ {
|
||||
dataCnt := size.DataCodewordsForBlock(block)
|
||||
|
||||
buff := make([]byte, dataCnt)
|
||||
// copy the data for the current block to buff
|
||||
j := 0
|
||||
for i := block; i < dataSize; i += size.BlockCount {
|
||||
|
|
Loading…
Reference in New Issue