Anonymous avatar Anonymous committed d0c8e92

migration from personal repo: added initial files

Comments (0)

Files changed (18)

+syntax:glob
+.DS_Store
+.git
+.gitignore
+*.ao
+*.so
+*.pyc
+._*
+_obj
+_test
+
+
+Copyright (c) 2010 Joseph D Poirier, jdpoirier@gmail.com
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above copyright
+      notice, this list of conditions and the following disclaimer in the
+      documentation and/or other materials provided with the distribution.
+    * Neither the name of the Joseph D Poirier nor the
+      names of its contributors may be used to endorse or promote products
+      derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Description
+------------
+
+
+Usage
+-----
+
+
+Compiling
+---------
+
+
+Testing
+-------
+
+
+

nodeb/encoder/Makefile

+# Copyright (c) 2010 Joseph D Poirier
+# Distributable under the terms of The New BSD License
+# that can be found in the LICENSE file.
+
+
+include $(GOROOT)/src/Make.inc
+
+
+
+TARG=lte/l1enc
+
+GOFILES=\
+	adhoc.go\
+	crc.go\
+	blkseg.go\
+
+#	turbointerl.go\
+#	encode.go\
+#	turboenc.go\
+
+
+
+include $(GOROOT)/src/Make.pkg

nodeb/encoder/adhoc.go

+// Copyright (c) 2010 Joseph D Poirier
+// Distributable under the terms of The New BSD License
+// that can be found in the LICENSE file.
+
+// Slices are a really quick and efficient way to work with chunks of
+// data; this file contains some builtin methods that add functionality (???)
+// to the "Data" data type.
+
+package l1enc
+
+//import "fmt"
+
+type Data []uint8
+
+// Len is an alias for len()
+func (d Data) Len() int {
+	return len(d)
+}
+
+// Cap is an alias for cap()
+func (d Data) Cap() int {
+	return cap(d)
+}
+
+// CapGrow returns a copy of the source slice
+// with its capacity increased by cnt bytes.
+func (s Data) CapGrow(cnt int) (d Data) {
+	d = make(Data, s.Len(), s.Cap() + cnt)
+	copy(d, s)
+
+	return
+}
+
+// Copy returns a copy of the length of the source slice.
+func (s Data) Copy() (d Data) {
+	d = make(Data, s.Len())
+	copy(d, s)
+
+	return
+}
+
+// Append returns a slice with c appended to s.
+func (s Data) Append(c Data) (d Data) {
+	l := s.Len()
+
+	d = make(Data, l + c.Len())
+	copy(d, s)
+
+	x := d[l:]
+	copy(x, c)
+
+	return
+}
+
+// Rsh returns a copy of the source slice with bitCnt bits
+// right-shifted by shiftCnt bits.
+func (s Data) Rsh(bitCnt, shiftCnt int) (d Data) {
+	ovflwByteCntShft := shiftCnt / 8
+	orphanCnt := shiftCnt % 0x8
+
+	byteCntSrc := bitCnt / 8
+	orphanCntSrc := bitCnt % 8
+	if orphanCntSrc > 0 { byteCntSrc += 1 }
+
+	z := orphanCnt
+	if orphanCntSrc > 0 { z -= (8 - orphanCntSrc) }
+
+	if z > 0 {
+		z = 1
+	} else {
+		z = 0
+	}
+
+	d = make(Data, byteCntSrc + ovflwByteCntShft + z)
+	dNdx := ovflwByteCntShft
+
+	rShft := uint32(orphanCnt)
+	lShft := uint32(8 - orphanCnt)
+	t := uint8(0)
+
+// (TODO) is processing an extra byte for orphan bits is really innocuous
+	for i := 0; i < byteCntSrc; i++ {
+		x := s[i]
+		y := x >> rShft
+		d[dNdx + i] = y | t
+		t = x << lShft
+	}
+
+	return
+}
+
+// Lsh returns a copy of the source slice shifted left by shiftCnt bits
+func (s Data) Lsh(shiftCnt int) (d Data) {
+// - handle if all the bits of the slice are being shifted out
+
+	offset := shiftCnt / 8
+	orphanCnt := shiftCnt % 0x8
+
+	// default to src length then reset later
+	d = make(Data, s.Len(), s.Cap())
+
+	lShft := uint32(orphanCnt)
+	rShft := uint32(8 - orphanCnt)
+	bytesToProc := s.Len() - offset
+
+	i := 0
+	x := s[offset]
+	y := uint8(0)
+	offset += 1
+
+	for i = 1; i < bytesToProc; i++ {
+		y = s[offset]
+		d[i - 1] = (x << lShft) | (y >> rShft)
+		x = y
+		offset += 1
+	}
+
+	d[i - 1] = x << lShft
+
+	return
+}
+

nodeb/encoder/adhoc_test.go

+// Copyright (c) 2010 Joseph D Poirier
+// Distributable under the terms of The New BSD License
+// that can be found in the LICENSE file.
+
+package l1enc
+
+import (
+//	"fmt"
+	"testing"
+)
+
+func TestCopy(t *testing.T) {
+	a  := make(Data, 5)
+	b  := make(Data, 50)
+	c  := make(Data, 500)
+	z  := []Data { a, b, c }
+
+	for _, o := range z {
+		for i, _ := range o {
+			o[i] = 0x56
+		}
+	}
+
+	for i, o := range z {
+		x := o.Copy()
+
+		if x.Len() != o.Len() {
+			t.Errorf("Len mismatch: %d != %d \n", x.Len(), o.Len())
+		}
+
+		for j, v := range o {
+			if x[j] != v {
+				t.Errorf("Iter: %d, index: %d, x[0x%X] != o[0x%X] \n", i, j, x[j], v)
+			}
+		}
+	}
+}
+
+func TesAppend(t *testing.T) {
+	a := Data {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
+	b := Data {10, 11, 12, 13, 14, 15}
+	c := Data {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
+
+	x := a.Append(b)
+
+	if x.Len() != (a.Len() + b.Len()) {
+		t.Errorf("Len mismatch: %d != %d \n", x.Len(), a.Len() + b.Len())
+	}
+
+	for i := 0; i < x.Len(); i++ {
+		if x[i] != c[i] {
+			t.Errorf("Index %, x[%d] != c[%d] \n", i, x[i], c[i])
+		}
+	}
+}
+
+func TestRsh(t *testing.T) {
+	a := Data {0xAA, 0xAA}
+	b := Data {0x55, 0x55, 0x00}
+	c := Data {0x2A, 0xAA, 0x80}
+	d := Data {0x15, 0x55, 0x40}
+	e := Data {0x0A, 0xAA, 0xA0}
+	f := Data {0x05, 0x55, 0x50}
+	g := Data {0x02, 0xAA, 0xA8}
+	h := Data {0x01, 0x55, 0x54}
+	k := Data {0x00, 0xAA, 0xAA}
+	l := Data {0x00, 0x55, 0x55,0x00}
+	z := []Data {b, c, d, e, f, g, h, k, l}
+
+	bitCnt := 16 	// number of bits to be shifted
+
+	for i, o := range z {
+		a = a.Rsh(bitCnt, 1)	// recycle the reference variable with each iteration
+		bitCnt += 1				// the data increases by 1 bit with each iteration
+
+		// Rsh should handle the length correctly when
+		// a right shift crosses a byte boundary
+		if a.Len() < o.Len() {
+			t.Errorf("Iter: %d, a.Len() !< o.Len() \n", i)
+		}
+
+		for j := 0; j < o.Len(); j++ {
+			if a[j] != o[j] {
+				t.Errorf("Iter: %d, index %d, a[0x%.2X] != o[0x%.2X] \n", i, j, a[i], o[i])
+			}
+		}
+	}
+}
+
+func TestLshCopy(t *testing.T) {
+	a := Data {0xAA, 0xAA}
+	b := Data {0x55, 0x54}
+	c := Data {0xAA, 0xA8}
+	d := Data {0x55, 0x50}
+	e := Data {0xAA, 0xA0}
+	f := Data {0x55, 0x40}
+	g := Data {0xAA, 0x80}
+	h := Data {0x55, 0x00}
+	k := Data {0xAA, 0x00}
+	l := Data {0x54, 0x00}
+	m := Data {0xA8, 0x00}
+	n := Data {0x50, 0x00}
+	p := Data {0xA0, 0x00}
+	q := Data {0x40, 0x00}
+	r := Data {0x80, 0x00}
+	s := Data {0x00, 0x00}
+
+	z := []Data {b, c, d, e, f, g, h, k, l, m, n, p, q, r, s}
+
+	for i, o := range z {
+		a = a.Lsh(1)	// recycle the reference variable with each iteration
+
+		for j := 0; j < o.Len(); j++ {
+			if a[j] != o[j] {
+				t.Errorf("Iter: %d, index %d, a[0x%.2X] != o[0x%.2X] \n", i, j, a[j], o[j])
+			}
+		}
+	}
+}
+
+func BenchmarkCopy(b *testing.B) {
+	b.StopTimer()
+
+	// data creation
+	s := make(Data, 5000)
+	d := Data {}
+
+	b.StartTimer()
+	d = s.Copy()
+	d[0] = 1
+}
+
+func BenchmarkAppend(b *testing.B) {
+	b.StopTimer()
+
+	// data creation
+	x := make(Data, 2500)
+	y := Data {}
+
+	b.StartTimer()
+	y = x.Copy()
+	y[0] = 1
+}

nodeb/encoder/blkseg.go

+// Copyright (c) 2010 Joseph D Poirier
+// Distributable under the terms of The New BSD License
+// that can be found in the LICENSE file.
+
+// GPP TS 36.212 V8.6.0 (2009-03) Multiplexing and channel coding (Release 8)
+// Section 5.1.2	Code block segmentation and code block CRC attachment
+
+package l1enc
+
+import (
+	"math"
+)
+
+const Z = 6144		// turbo coder max block size
+
+type BlkSegNfo struct {
+	BlkCnt  int		// code block count
+	FillCnt int		// fill bit count
+	EblkCnt int		// even code block count
+	EbyteCnt int	// bytes per block
+	EbitCnt int		// bit count even code blocks
+	Eorphans int	// orphan bits in the last byte
+	OblkCnt int		// odd code block count
+	ObyteCnt int	// bytes per block
+	ObitCnt int		// bit count odd code blocks
+	Oorphans int	// orphan bits in the last byte
+	CrcSz int		// individual block segment crc size
+}
+
+//Crc(data []uint8, table *[256]uint32, bitCnt int, crcSz int) (err bool, crc uint32) {
+
+func BlkSeg(data Data, nfo BlkSegNfo) []Data {
+// (todo) add some sort of sanity check of the src buffer bit count!
+// sanity check
+//	t1 := (srcByteCnt * 8) + (nfo.crcSz * nfo.blkCnt) + nfo.fillCnt
+//	t2 := (nfo.blkCnt * eBitCnt) + (nfo.blkCnt * oBitCnt)
+// 	t1 should equal t2
+
+// 20 MB user throughput @ 2ms TTI = 5,000 bytes
+// 6114 / 8 = 765 bytes
+
+	// slice buffer
+	segCnt := nfo.EblkCnt + nfo.OblkCnt
+	blkSegs := make([]Data, segCnt)
+
+	// even/odd segment bit counts, excluding the crc
+	eRawBits := nfo.EbitCnt - nfo.CrcSz
+	oRawBits := nfo.ObitCnt - nfo.CrcSz
+
+	// special case, process the first block segment
+	b:= (eRawBits - nfo.FillCnt) / 8
+	o := (eRawBits - nfo.FillCnt) % 8
+	if o > 0 { b += 1 }
+
+	s := data[0:b]	// src slice
+	d := s.Copy()
+
+	// right shift implicitly adds zeros for the fill bits
+	blkSegs[0] = d.Rsh(eRawBits - nfo.FillCnt, nfo.FillCnt)
+//	blkSegs[0] = d
+
+	oZ := oRawBits / 8
+	if (oRawBits % 8) > 0 { oZ += 1 }
+
+	eZ := oRawBits / 8
+	if (oRawBits % 8) > 0 { eZ += 1 }
+
+	z := 0
+	orphans := 0
+	x := (eRawBits - nfo.FillCnt)
+
+	for i := 1; i < segCnt; i++ {
+		if (i & 1) == 1 { // odd case
+			z = oZ
+		} else { // even case
+			z = eZ
+		}
+
+		// calc the start and end of
+		// the src data to be copied
+		y := x / 8
+		orphans = x % 8
+		s = data[y : y + z]
+
+		// dst slice
+//		d = Data {}
+//		d.Copy(s)
+//		d.Lsh(orphans)
+//		blkSegs[i] = d
+
+		d = s.Copy()
+		blkSegs[i] = d.Lsh(orphans)
+
+		if (i & 1) == 1 { // odd case
+			x += oRawBits
+		} else { // even case
+			x += eRawBits
+		}
+	}
+
+	return blkSegs
+}
+
+func BlkSegParams(BlkSz int) (err bool, nfo BlkSegNfo) {
+	if BlkSz <= 0 { err = true; return }
+
+	var Bpri int = 0
+	var K int = 0
+
+	// number of code blocks
+	if BlkSz <= Z {
+		nfo.CrcSz = 0
+		nfo.BlkCnt = 1
+		Bpri = BlkSz
+	} else {
+		nfo.CrcSz = 24
+		nfo.BlkCnt = int(math.Ceil((float64(BlkSz) / float64(Z - nfo.CrcSz))))
+		Bpri = BlkSz + nfo.BlkCnt * nfo.CrcSz
+	}
+
+	// segmentation size
+	// first segmentation size: eBitCnt = minimum K in table  5.1.3-3 such that blkCnt * K >= Bpri
+	if nfo.BlkCnt == 1 {
+		nfo.EbitCnt = blkSizeMin(Bpri)
+		nfo.EblkCnt = 1
+		nfo.ObitCnt = 0
+		nfo.OblkCnt = 0
+	} else if nfo.BlkCnt > 1 {
+		sanity := 5
+		K = Bpri / nfo.BlkCnt
+
+		for {
+			sanity -= 1
+			nfo.EbitCnt = blkSizeMin(K)
+
+			if nfo.BlkCnt * nfo.EbitCnt >= Bpri {
+				break
+			}
+
+			if sanity == 0 {
+				err = true
+				return
+			}
+		}
+
+		// second segmentation size: oBitCnt = maximum K in table 5.1.3-3 such that K < eBitCnt
+		nfo.ObitCnt = blkSizeMax(nfo.EbitCnt)
+		DeltaK := nfo.EbitCnt - nfo.ObitCnt
+		nfo.OblkCnt = int(math.Floor((float64(nfo.BlkCnt * nfo.EbitCnt - Bpri) / float64(DeltaK))))
+		nfo.EblkCnt = nfo.BlkCnt - nfo.OblkCnt
+	}
+
+	// fill-bit count
+	nfo.FillCnt = nfo.EblkCnt * nfo.EbitCnt + nfo.OblkCnt * nfo.ObitCnt - Bpri
+
+	nfo.Eorphans = nfo.EbitCnt % 0x8
+	nfo.Oorphans = nfo.ObitCnt & 0x8
+	nfo.EbyteCnt = nfo.EbitCnt / 8
+	nfo.ObyteCnt = nfo.ObitCnt / 8
+	if nfo.Eorphans > 0 { nfo.EbyteCnt += 1 }
+	if nfo.Oorphans > 0 { nfo.ObyteCnt += 1 }
+
+	return
+}
+
+func blkSizeMax(bitCnt int) (blkSz int) {
+	switch {
+		case bitCnt == 40:
+			blkSz = 39
+		case bitCnt <= 512:
+			blkSz = bitCnt - 8
+		case bitCnt <= 1024:
+			blkSz = bitCnt -  16
+		case bitCnt <= 2048:
+			blkSz = bitCnt -  32
+		case bitCnt <= 4096:
+			blkSz = bitCnt -  64
+		case bitCnt <= 6144:
+			blkSz = bitCnt -  128
+	}
+
+	return
+}
+
+func blkSizeMin(bitCnt int) (blkSz int) {
+	switch {
+		case bitCnt < 40:
+			blkSz = 40
+		case bitCnt <= 512:
+			// 40   -  512 incre by 8
+			blkSz = ((bitCnt + 7) / 8) * 8
+		case bitCnt <= 1024:
+			// 513  - 1024 incre by 16
+			blkSz = ((bitCnt + 15) / 16) * 16
+		case bitCnt <= 2048:
+			// 1025 - 2048 incre by 32
+			blkSz = ((bitCnt + 31) / 32) * 32
+		case bitCnt <= 4096:
+			// 2049 - 4096 incre by 64
+			blkSz = ((bitCnt + 63) / 64) * 64
+		case bitCnt <= 6144:
+			// 4097 - 6144 incre by 128
+			blkSz = ((bitCnt + 127) / 128) * 128
+	}
+
+	return
+}
+

nodeb/encoder/blkseg_test.go

+/*
+	3GPP TS 36.212 v8.3.0 Multiplexing and channel coding (Release 8)
+	Section 5.1.2 Code block segmentation and code block CRC attachment
+*/
+package l1enc
+
+import (
+	"testing"
+)
+
+func TestBlkSegParams(t *testing.T) {
+	var bitCnts = []int {40, 500, 2000, 4000, 6000, 10000, 15000, 25000, 51000}
+
+	for _, v := range bitCnts {
+		if err, _ := BlkSegParams(v); err {
+			t.Errorf("Bit cnt: %d \n", v)
+		}
+//fmt.Printf("C: %v, Ce: %v, Co: %v, Ke: %v, Ko: %v, F: %v, L: %v \n\n", nfo.C, nfo.Ce, nfo.Co, nfo.Ke, nfo.Ko, nfo.F, nfo.L)
+	}
+}

nodeb/encoder/crc.go

+// Copyright (c) 2010 Joseph D Poirier
+// Distributable under the terms of The New BSD License
+// that can be found in the LICENSE file.
+
+// 3GPP TS 36.212 V8.6.0 (2009-03) Multiplexing and channel coding (Release 8)
+// Section 5.1.1	CRC calculation
+
+package l1enc
+
+//import "fmt"
+
+/**
+ * G24 CRC lookup table
+ *
+ * CRC24	: P(X) = x^24+x^23+x^18+x^17+x^14+x^11+x^10+x^7+x^6+x^5+x^4+x^3+x^1+1
+ * Width     	: 3 bytes
+ * Poly      	: 0x864CFB
+ * Reflected 	: false
+ */
+var Crc24_A = [256]uint32 {
+  0x00000000,0x00864cfb,0x008ad50d,0x000c99f6,0x0093e6e1,0x0015aa1a,0x001933ec,0x009f7f17,
+  0x00a18139,0x0027cdc2,0x002b5434,0x00ad18cf,0x003267d8,0x00b42b23,0x00b8b2d5,0x003efe2e,
+  0x00c54e89,0x00430272,0x004f9b84,0x00c9d77f,0x0056a868,0x00d0e493,0x00dc7d65,0x005a319e,
+  0x0064cfb0,0x00e2834b,0x00ee1abd,0x00685646,0x00f72951,0x007165aa,0x007dfc5c,0x00fbb0a7,
+  0x000cd1e9,0x008a9d12,0x008604e4,0x0000481f,0x009f3708,0x00197bf3,0x0015e205,0x0093aefe,
+  0x00ad50d0,0x002b1c2b,0x002785dd,0x00a1c926,0x003eb631,0x00b8faca,0x00b4633c,0x00322fc7,
+  0x00c99f60,0x004fd39b,0x00434a6d,0x00c50696,0x005a7981,0x00dc357a,0x00d0ac8c,0x0056e077,
+  0x00681e59,0x00ee52a2,0x00e2cb54,0x006487af,0x00fbf8b8,0x007db443,0x00712db5,0x00f7614e,
+  0x0019a3d2,0x009fef29,0x009376df,0x00153a24,0x008a4533,0x000c09c8,0x0000903e,0x0086dcc5,
+  0x00b822eb,0x003e6e10,0x0032f7e6,0x00b4bb1d,0x002bc40a,0x00ad88f1,0x00a11107,0x00275dfc,
+  0x00dced5b,0x005aa1a0,0x00563856,0x00d074ad,0x004f0bba,0x00c94741,0x00c5deb7,0x0043924c,
+  0x007d6c62,0x00fb2099,0x00f7b96f,0x0071f594,0x00ee8a83,0x0068c678,0x00645f8e,0x00e21375,
+  0x0015723b,0x00933ec0,0x009fa736,0x0019ebcd,0x008694da,0x0000d821,0x000c41d7,0x008a0d2c,
+  0x00b4f302,0x0032bff9,0x003e260f,0x00b86af4,0x002715e3,0x00a15918,0x00adc0ee,0x002b8c15,
+  0x00d03cb2,0x00567049,0x005ae9bf,0x00dca544,0x0043da53,0x00c596a8,0x00c90f5e,0x004f43a5,
+  0x0071bd8b,0x00f7f170,0x00fb6886,0x007d247d,0x00e25b6a,0x00641791,0x00688e67,0x00eec29c,
+  0x003347a4,0x00b50b5f,0x00b992a9,0x003fde52,0x00a0a145,0x0026edbe,0x002a7448,0x00ac38b3,
+  0x0092c69d,0x00148a66,0x00181390,0x009e5f6b,0x0001207c,0x00876c87,0x008bf571,0x000db98a,
+  0x00f6092d,0x007045d6,0x007cdc20,0x00fa90db,0x0065efcc,0x00e3a337,0x00ef3ac1,0x0069763a,
+  0x00578814,0x00d1c4ef,0x00dd5d19,0x005b11e2,0x00c46ef5,0x0042220e,0x004ebbf8,0x00c8f703,
+  0x003f964d,0x00b9dab6,0x00b54340,0x00330fbb,0x00ac70ac,0x002a3c57,0x0026a5a1,0x00a0e95a,
+  0x009e1774,0x00185b8f,0x0014c279,0x00928e82,0x000df195,0x008bbd6e,0x00872498,0x00016863,
+  0x00fad8c4,0x007c943f,0x00700dc9,0x00f64132,0x00693e25,0x00ef72de,0x00e3eb28,0x0065a7d3,
+  0x005b59fd,0x00dd1506,0x00d18cf0,0x0057c00b,0x00c8bf1c,0x004ef3e7,0x00426a11,0x00c426ea,
+  0x002ae476,0x00aca88d,0x00a0317b,0x00267d80,0x00b90297,0x003f4e6c,0x0033d79a,0x00b59b61,
+  0x008b654f,0x000d29b4,0x0001b042,0x0087fcb9,0x001883ae,0x009ecf55,0x009256a3,0x00141a58,
+  0x00efaaff,0x0069e604,0x00657ff2,0x00e33309,0x007c4c1e,0x00fa00e5,0x00f69913,0x0070d5e8,
+  0x004e2bc6,0x00c8673d,0x00c4fecb,0x0042b230,0x00ddcd27,0x005b81dc,0x0057182a,0x00d154d1,
+  0x0026359f,0x00a07964,0x00ace092,0x002aac69,0x00b5d37e,0x00339f85,0x003f0673,0x00b94a88,
+  0x0087b4a6,0x0001f85d,0x000d61ab,0x008b2d50,0x00145247,0x00921ebc,0x009e874a,0x0018cbb1,
+  0x00e37b16,0x006537ed,0x0069ae1b,0x00efe2e0,0x00709df7,0x00f6d10c,0x00fa48fa,0x007c0401,
+  0x0042fa2f,0x00c4b6d4,0x00c82f22,0x004e63d9,0x00d11cce,0x00575035,0x005bc9c3,0x00dd8538}
+
+/**
+ * G24 CRC lookup table
+ *
+ * CRC24		: P(X) = x^24+x^23+x^6+x^5+x^1+1
+ * Width     	: 3 bytes
+ * Poly      	: 0x800063
+ * Reflected 	: false
+ */
+var Crc24_B = [256]uint32 {
+  0x00000000,0x00800063,0x008000a5,0x000000c6,0x00800129,0x0000014a,0x0000018c,0x008001ef,
+  0x00800231,0x00000252,0x00000294,0x008002f7,0x00000318,0x0080037b,0x008003bd,0x000003de,
+  0x00800401,0x00000462,0x000004a4,0x008004c7,0x00000528,0x0080054b,0x0080058d,0x000005ee,
+  0x00000630,0x00800653,0x00800695,0x000006f6,0x00800719,0x0000077a,0x000007bc,0x008007df,
+  0x00800861,0x00000802,0x000008c4,0x008008a7,0x00000948,0x0080092b,0x008009ed,0x0000098e,
+  0x00000a50,0x00800a33,0x00800af5,0x00000a96,0x00800b79,0x00000b1a,0x00000bdc,0x00800bbf,
+  0x00000c60,0x00800c03,0x00800cc5,0x00000ca6,0x00800d49,0x00000d2a,0x00000dec,0x00800d8f,
+  0x00800e51,0x00000e32,0x00000ef4,0x00800e97,0x00000f78,0x00800f1b,0x00800fdd,0x00000fbe,
+  0x008010a1,0x000010c2,0x00001004,0x00801067,0x00001188,0x008011eb,0x0080112d,0x0000114e,
+  0x00001290,0x008012f3,0x00801235,0x00001256,0x008013b9,0x000013da,0x0000131c,0x0080137f,
+  0x000014a0,0x008014c3,0x00801405,0x00001466,0x00801589,0x000015ea,0x0000152c,0x0080154f,
+  0x00801691,0x000016f2,0x00001634,0x00801657,0x000017b8,0x008017db,0x0080171d,0x0000177e,
+  0x000018c0,0x008018a3,0x00801865,0x00001806,0x008019e9,0x0000198a,0x0000194c,0x0080192f,
+  0x00801af1,0x00001a92,0x00001a54,0x00801a37,0x00001bd8,0x00801bbb,0x00801b7d,0x00001b1e,
+  0x00801cc1,0x00001ca2,0x00001c64,0x00801c07,0x00001de8,0x00801d8b,0x00801d4d,0x00001d2e,
+  0x00001ef0,0x00801e93,0x00801e55,0x00001e36,0x00801fd9,0x00001fba,0x00001f7c,0x00801f1f,
+  0x00802121,0x00002142,0x00002184,0x008021e7,0x00002008,0x0080206b,0x008020ad,0x000020ce,
+  0x00002310,0x00802373,0x008023b5,0x000023d6,0x00802239,0x0000225a,0x0000229c,0x008022ff,
+  0x00002520,0x00802543,0x00802585,0x000025e6,0x00802409,0x0000246a,0x000024ac,0x008024cf,
+  0x00802711,0x00002772,0x000027b4,0x008027d7,0x00002638,0x0080265b,0x0080269d,0x000026fe,
+  0x00002940,0x00802923,0x008029e5,0x00002986,0x00802869,0x0000280a,0x000028cc,0x008028af,
+  0x00802b71,0x00002b12,0x00002bd4,0x00802bb7,0x00002a58,0x00802a3b,0x00802afd,0x00002a9e,
+  0x00802d41,0x00002d22,0x00002de4,0x00802d87,0x00002c68,0x00802c0b,0x00802ccd,0x00002cae,
+  0x00002f70,0x00802f13,0x00802fd5,0x00002fb6,0x00802e59,0x00002e3a,0x00002efc,0x00802e9f,
+  0x00003180,0x008031e3,0x00803125,0x00003146,0x008030a9,0x000030ca,0x0000300c,0x0080306f,
+  0x008033b1,0x000033d2,0x00003314,0x00803377,0x00003298,0x008032fb,0x0080323d,0x0000325e,
+  0x00803581,0x000035e2,0x00003524,0x00803547,0x000034a8,0x008034cb,0x0080340d,0x0000346e,
+  0x000037b0,0x008037d3,0x00803715,0x00003776,0x00803699,0x000036fa,0x0000363c,0x0080365f,
+  0x008039e1,0x00003982,0x00003944,0x00803927,0x000038c8,0x008038ab,0x0080386d,0x0000380e,
+  0x00003bd0,0x00803bb3,0x00803b75,0x00003b16,0x00803af9,0x00003a9a,0x00003a5c,0x00803a3f,
+  0x00003de0,0x00803d83,0x00803d45,0x00003d26,0x00803cc9,0x00003caa,0x00003c6c,0x00803c0f,
+  0x00803fd1,0x00003fb2,0x00003f74,0x00803f17,0x00003ef8,0x00803e9b,0x00803e5d,0x00003e3e}
+
+/**
+ * G16 CRC lookup table
+ *
+ * CRC16		: P(X) = x^16+x^12+x^5+1
+ * Width     	: 2 bytes
+ * Poly      	: 0x1021
+ * Reflected 	: false
+ */
+var Crc16 = [256]uint32 {
+  0x00000000,0x00001021,0x00002042,0x00003063,0x00004084,0x000050a5,0x000060c6,0x000070e7,
+  0x00008108,0x00009129,0x0000a14a,0x0000b16b,0x0000c18c,0x0000d1ad,0x0000e1ce,0x0000f1ef,
+  0x00001231,0x00000210,0x00003273,0x00002252,0x000052b5,0x00004294,0x000072f7,0x000062d6,
+  0x00009339,0x00008318,0x0000b37b,0x0000a35a,0x0000d3bd,0x0000c39c,0x0000f3ff,0x0000e3de,
+  0x00002462,0x00003443,0x00000420,0x00001401,0x000064e6,0x000074c7,0x000044a4,0x00005485,
+  0x0000a56a,0x0000b54b,0x00008528,0x00009509,0x0000e5ee,0x0000f5cf,0x0000c5ac,0x0000d58d,
+  0x00003653,0x00002672,0x00001611,0x00000630,0x000076d7,0x000066f6,0x00005695,0x000046b4,
+  0x0000b75b,0x0000a77a,0x00009719,0x00008738,0x0000f7df,0x0000e7fe,0x0000d79d,0x0000c7bc,
+  0x000048c4,0x000058e5,0x00006886,0x000078a7,0x00000840,0x00001861,0x00002802,0x00003823,
+  0x0000c9cc,0x0000d9ed,0x0000e98e,0x0000f9af,0x00008948,0x00009969,0x0000a90a,0x0000b92b,
+  0x00005af5,0x00004ad4,0x00007ab7,0x00006a96,0x00001a71,0x00000a50,0x00003a33,0x00002a12,
+  0x0000dbfd,0x0000cbdc,0x0000fbbf,0x0000eb9e,0x00009b79,0x00008b58,0x0000bb3b,0x0000ab1a,
+  0x00006ca6,0x00007c87,0x00004ce4,0x00005cc5,0x00002c22,0x00003c03,0x00000c60,0x00001c41,
+  0x0000edae,0x0000fd8f,0x0000cdec,0x0000ddcd,0x0000ad2a,0x0000bd0b,0x00008d68,0x00009d49,
+  0x00007e97,0x00006eb6,0x00005ed5,0x00004ef4,0x00003e13,0x00002e32,0x00001e51,0x00000e70,
+  0x0000ff9f,0x0000efbe,0x0000dfdd,0x0000cffc,0x0000bf1b,0x0000af3a,0x00009f59,0x00008f78,
+  0x00009188,0x000081a9,0x0000b1ca,0x0000a1eb,0x0000d10c,0x0000c12d,0x0000f14e,0x0000e16f,
+  0x00001080,0x000000a1,0x000030c2,0x000020e3,0x00005004,0x00004025,0x00007046,0x00006067,
+  0x000083b9,0x00009398,0x0000a3fb,0x0000b3da,0x0000c33d,0x0000d31c,0x0000e37f,0x0000f35e,
+  0x000002b1,0x00001290,0x000022f3,0x000032d2,0x00004235,0x00005214,0x00006277,0x00007256,
+  0x0000b5ea,0x0000a5cb,0x000095a8,0x00008589,0x0000f56e,0x0000e54f,0x0000d52c,0x0000c50d,
+  0x000034e2,0x000024c3,0x000014a0,0x00000481,0x00007466,0x00006447,0x00005424,0x00004405,
+  0x0000a7db,0x0000b7fa,0x00008799,0x000097b8,0x0000e75f,0x0000f77e,0x0000c71d,0x0000d73c,
+  0x000026d3,0x000036f2,0x00000691,0x000016b0,0x00006657,0x00007676,0x00004615,0x00005634,
+  0x0000d94c,0x0000c96d,0x0000f90e,0x0000e92f,0x000099c8,0x000089e9,0x0000b98a,0x0000a9ab,
+  0x00005844,0x00004865,0x00007806,0x00006827,0x000018c0,0x000008e1,0x00003882,0x000028a3,
+  0x0000cb7d,0x0000db5c,0x0000eb3f,0x0000fb1e,0x00008bf9,0x00009bd8,0x0000abbb,0x0000bb9a,
+  0x00004a75,0x00005a54,0x00006a37,0x00007a16,0x00000af1,0x00001ad0,0x00002ab3,0x00003a92,
+  0x0000fd2e,0x0000ed0f,0x0000dd6c,0x0000cd4d,0x0000bdaa,0x0000ad8b,0x00009de8,0x00008dc9,
+  0x00007c26,0x00006c07,0x00005c64,0x00004c45,0x00003ca2,0x00002c83,0x00001ce0,0x00000cc1,
+  0x0000ef1f,0x0000ff3e,0x0000cf5d,0x0000df7c,0x0000af9b,0x0000bfba,0x00008fd9,0x00009ff8,
+  0x00006e17,0x00007e36,0x00004e55,0x00005e74,0x00002e93,0x00003eb2,0x00000ed1,0x00001ef0}
+
+/**
+ * G8 CRC lookup table
+ *
+ * CRC8			: P(X) = x^8+x^7+x^4+x^3+x^1+1
+ * Width     	: 1 byte
+ * Poly      	: 0x9B
+ * Reflected 	: false
+ */
+var Crc8 = [256]uint32 {
+  0x00000000,0x0000009b,0x000000ad,0x00000036,0x000000c1,0x0000005a,0x0000006c,0x000000f7,
+  0x00000019,0x00000082,0x000000b4,0x0000002f,0x000000d8,0x00000043,0x00000075,0x000000ee,
+  0x00000032,0x000000a9,0x0000009f,0x00000004,0x000000f3,0x00000068,0x0000005e,0x000000c5,
+  0x0000002b,0x000000b0,0x00000086,0x0000001d,0x000000ea,0x00000071,0x00000047,0x000000dc,
+  0x00000064,0x000000ff,0x000000c9,0x00000052,0x000000a5,0x0000003e,0x00000008,0x00000093,
+  0x0000007d,0x000000e6,0x000000d0,0x0000004b,0x000000bc,0x00000027,0x00000011,0x0000008a,
+  0x00000056,0x000000cd,0x000000fb,0x00000060,0x00000097,0x0000000c,0x0000003a,0x000000a1,
+  0x0000004f,0x000000d4,0x000000e2,0x00000079,0x0000008e,0x00000015,0x00000023,0x000000b8,
+  0x000000c8,0x00000053,0x00000065,0x000000fe,0x00000009,0x00000092,0x000000a4,0x0000003f,
+  0x000000d1,0x0000004a,0x0000007c,0x000000e7,0x00000010,0x0000008b,0x000000bd,0x00000026,
+  0x000000fa,0x00000061,0x00000057,0x000000cc,0x0000003b,0x000000a0,0x00000096,0x0000000d,
+  0x000000e3,0x00000078,0x0000004e,0x000000d5,0x00000022,0x000000b9,0x0000008f,0x00000014,
+  0x000000ac,0x00000037,0x00000001,0x0000009a,0x0000006d,0x000000f6,0x000000c0,0x0000005b,
+  0x000000b5,0x0000002e,0x00000018,0x00000083,0x00000074,0x000000ef,0x000000d9,0x00000042,
+  0x0000009e,0x00000005,0x00000033,0x000000a8,0x0000005f,0x000000c4,0x000000f2,0x00000069,
+  0x00000087,0x0000001c,0x0000002a,0x000000b1,0x00000046,0x000000dd,0x000000eb,0x00000070,
+  0x0000000b,0x00000090,0x000000a6,0x0000003d,0x000000ca,0x00000051,0x00000067,0x000000fc,
+  0x00000012,0x00000089,0x000000bf,0x00000024,0x000000d3,0x00000048,0x0000007e,0x000000e5,
+  0x00000039,0x000000a2,0x00000094,0x0000000f,0x000000f8,0x00000063,0x00000055,0x000000ce,
+  0x00000020,0x000000bb,0x0000008d,0x00000016,0x000000e1,0x0000007a,0x0000004c,0x000000d7,
+  0x0000006f,0x000000f4,0x000000c2,0x00000059,0x000000ae,0x00000035,0x00000003,0x00000098,
+  0x00000076,0x000000ed,0x000000db,0x00000040,0x000000b7,0x0000002c,0x0000001a,0x00000081,
+  0x0000005d,0x000000c6,0x000000f0,0x0000006b,0x0000009c,0x00000007,0x00000031,0x000000aa,
+  0x00000044,0x000000df,0x000000e9,0x00000072,0x00000085,0x0000001e,0x00000028,0x000000b3,
+  0x000000c3,0x00000058,0x0000006e,0x000000f5,0x00000002,0x00000099,0x000000af,0x00000034,
+  0x000000da,0x00000041,0x00000077,0x000000ec,0x0000001b,0x00000080,0x000000b6,0x0000002d,
+  0x000000f1,0x0000006a,0x0000005c,0x000000c7,0x00000030,0x000000ab,0x0000009d,0x00000006,
+  0x000000e8,0x00000073,0x00000045,0x000000de,0x00000029,0x000000b2,0x00000084,0x0000001f,
+  0x000000a7,0x0000003c,0x0000000a,0x00000091,0x00000066,0x000000fd,0x000000cb,0x00000050,
+  0x000000be,0x00000025,0x00000013,0x00000088,0x0000007f,0x000000e4,0x000000d2,0x00000049,
+  0x00000095,0x0000000e,0x00000038,0x000000a3,0x00000054,0x000000cf,0x000000f9,0x00000062,
+  0x0000008c,0x00000017,0x00000021,0x000000ba,0x0000004d,0x000000d6,0x000000e0,0x0000007b}
+
+// reflectBits reverses the such that the bit in position 31 is moved to position 0,
+// the bit in position 30 is moved to position 1, etc...
+func reflectBits(x uint32) uint32 {
+	x = ((x & 0x55555555) << 1) | ((x >> 1) & 0x55555555);
+	x = ((x & 0x33333333) << 2) | ((x >> 2) & 0x33333333);
+	x = ((x & 0x0F0F0F0F) << 4) | ((x >> 4) & 0x0F0F0F0F);
+	x = (x << 24) | ((x & 0xFF00) << 8) | ((x >> 8) & 0xFF00) | (x >> 24)
+
+	return x
+}
+
+// Crc calculates the CRC over bitCnt bits of the data slice. The CRC is returned with
+// the highest order byte starting at index zero and so on so that the Append method
+// can be used.
+func Crc(data Data, table *[256]uint32, bitCnt int, crcSz int) (err bool, crc Data) {
+	switch crcSz {
+		case 8, 16, 24:
+			err = false
+		default:
+			err = true
+			return
+	}
+
+	i := 0
+	z := uint32(0)
+	byteCnt := bitCnt / 8
+	orphanCnt := bitCnt % 0x8
+	orphanShift := uint32(8 - orphanCnt)
+	regShift := uint32(32 - crcSz)
+
+	for i = 0; i < byteCnt; i++ {
+		z = (table[uint32(data[i] ^ byte(z >> 24))] << regShift) ^ (z << 8);
+	}
+
+	if orphanCnt > 0 {
+		z = (table[(uint32(data[i] ^ byte(z >> 24))) >> orphanShift] << regShift) ^ (z << uint8(orphanCnt));
+	}
+
+	z = reflectBits(z)  & (0xFFFFFFFF >> regShift)
+	c := crcSz / 8
+
+	crc = make(Data, c)
+
+	for i = (c - 1); i >= 0; i-- {
+		// upper most byte to lowest address, etc...
+		crc[i] = uint8(z >> (uint32(i) * 8))
+	}
+
+	return
+}
+

nodeb/encoder/crc_gen_tables.go

+// Copyright (c) 2010 Joseph D Poirier
+// Distributable under the terms of The New BSD License
+// that can be found in the LICENSE file.
+
+package main
+
+import (
+	"fmt"
+)
+
+// Predefined polynomials.
+const (
+	crc24_a = 0x864cfb // byte width = 3
+	crc24_b = 0x800063 // byte width = 3
+	crc16   = 0x001021 // byte width = 2
+	crc8    = 0x00009b // byte width = 1
+)
+
+// MakeTable returns the Table constructed from the specified polynomial.
+func MakeTable(poly uint32, bitWidth uint32) []uint32 {
+	t := make([]uint32, 256)
+
+	topBit := uint32(1 << (bitWidth - 1))
+
+	widthMask := uint32((((1 << (bitWidth - 1)) - 1) << 1) | 1)
+
+	for i := 0; i < 256; i++ {
+		crc := uint32(i) << (bitWidth - 8)
+
+		for j := 0; j < 8; j++ {
+			if (crc & topBit) > 0 {
+				crc = (crc << 1) ^ poly
+			} else {
+				crc <<= 1
+			}
+		}
+
+		t[i] = crc & widthMask
+	}
+
+	return t
+}
+
+func stdio(t []uint32) {
+	for i := 0; i < 256; i++ {
+		fmt.Printf("0x%.8x", t[i])
+
+		if i != 255 {
+			fmt.Printf(",")
+		}
+
+		if ((i + 1) % 10) == 0 {
+			fmt.Printf("\n")
+		}
+	}
+
+	fmt.Printf( "\n" )
+}
+
+
+func main() {
+
+	// poly byte width times bits per byte
+        t := MakeTable(crc24_a, 3 * 8)
+
+	fmt.Printf("\n --- crc24_a table --- \n")
+	stdio(t)
+	
+	// -----------------------------------------
+	// poly byte width times bits per byte
+        t = MakeTable(crc24_b, 3 * 8)
+
+	fmt.Printf("\n --- crc24_b table --- \n")
+	stdio(t)
+
+	// -----------------------------------------
+	// poly byte width times bits per byte
+        t = MakeTable(crc16, 2 * 8)
+
+	fmt.Printf("\n --- crc16 table --- \n")
+	stdio(t)
+
+	// -----------------------------------------
+	// poly byte width times bits per byte
+        t = MakeTable(crc8, 1 * 8)
+
+	fmt.Printf("\n --- crc8 table --- \n")
+	stdio(t)
+}

nodeb/encoder/crc_prof.go

+// Copyright (c) 2010 Joseph D Poirier
+// Distributable under the terms of The New BSD License
+// that can be found in the LICENSE file.
+
+package main
+
+import (
+    "lte/l1enc"
+    "fmt"
+    "runtime"
+    "time"
+)
+
+// 50 MB/s = 100,000 @ 2ms intervals
+// 40 MB/s =  80,000 @ 2ms intervals
+// 30 MB/s =  60,000 @ 2ms intervals
+// 20 MB/s =  40,000 @ 2ms intervals
+// 10 MB/s =  20,000 @ 2ms intervals
+//  5 MB/s =  10,000 @ 2ms intervals
+
+var bitCnts = []int {100000, 80000, 60000, 40000, 20000, 10000}
+func main() {
+	runtime.GOMAXPROCS(2)
+	var tBeg, tEnd int64
+
+	// 20 MB @ 10ms intervals = 25,000 * 8 = 200,000 bits
+	data := make([]uint8, bitCnts[0]/8)
+
+	for i := 0; i < bitCnts[0] / 8; i+=4 {
+		// known data associated with ref crcs
+		// 0x12345678
+		data[i+0] = 0x12
+		data[i+1] = 0x34
+		data[i+2] = 0x56
+		data[i+3] = 0x78
+	}
+
+	tBeg = time.Nanoseconds()
+	_,_ = encoder.Crc(data, &encoder.Crc24_B, 24)
+	tEnd = time.Nanoseconds()
+
+	fmt.Printf( "Test took %f seconds to run\n", float(tEnd - tBeg) / 1e9)
+}

nodeb/encoder/crc_test.go

+// Copyright (c) 2010 Joseph D Poirier
+// Distributable under the terms of The New BSD License
+// that can be found in the LICENSE file.
+
+package l1enc
+
+import (
+	"testing"
+)
+
+type Table [256]uint32
+
+var crcSzs 	= [3]int {24, 16, 8}
+var tables 	= [3]*[256]uint32 {&Crc24_B, &Crc16, &Crc8}
+
+//                                  3.840 bits
+// non-reflected         0x97561000, 0x22F90000, 0x6A000000
+var refCrcs = [3]uint32 {0x00E96A08, 0x0000449F, 0x00000056}
+
+//							6113		4519		2013
+// non-reflected         0x553D9500, 0xBB441A00, 0x7062B500
+var refCRC24 = []uint32 {0x00953D55, 0x001A44BB, 0x00B56270}
+
+// non-reflected         0xBCC30000, 0x2B190000, 0x98110000
+var refCRC16 = []uint32 {0x0000C3BC, 0x0000192B, 0x00001198}
+
+// non-reflected         0x68000000, 0xBF000000, 0x32000000
+var refCRC8  = []uint32 {0x00000068, 0x000000BF, 0x00000032}
+
+func TestCrc(t *testing.T) {
+	var v uint32
+	var c uint32
+
+	//------------------- CRC bit counts with no orphan bits
+	bitCnt := (480 * 8)
+
+	// data buffer
+	data := make(Data, 480)
+
+	for i := 0; i < 480; i += 4 {
+		// known data associated with ref crcs
+		// 0x12345678
+		data[i + 0] = 0x12
+		data[i + 1] = 0x34
+		data[i + 2] = 0x56
+		data[i + 3] = 0x78
+	}
+
+	for i := 0; i < len(tables); i++ {
+		if err, crc := Crc(data, tables[i], bitCnt, crcSzs[i]); err {
+			t.Errorf("Iteration: %d, CRC size error \n", i)
+		} else {
+			switch crcSzs[i] {
+				case  8:
+					v =  uint32(crc[0])
+				case 16:
+					v = (uint32(crc[0]) << 8) | uint32(crc[1])
+				case 24:
+					v = (uint32(crc[0]) << 16) | (uint32(crc[1]) << 8) | uint32(crc[2])
+			}
+
+			if v != refCrcs[i] {
+				t.Errorf("Expected: 0x%X, received: 0x%X \n", refCrcs[i], v)
+			}
+		}
+	}
+
+	//------------------- CRC bit counts with orphan bits
+	d1 := make(Data, 800)
+	d2 := make(Data, 800)
+ 	d3 := make(Data, 800)
+
+	bitCnts := [3]int{6113, 4519, 2013}
+	byteCnts := [3]int{6113/8+1, 4519/8+1, 2013/8+1}
+	buffers := [3][]uint8{d1, d2, d3}
+
+	for i, b := range buffers {
+		for j := 0; j < byteCnts[i]; j++ {
+			switch j % 0x4 {
+				case 0:
+					b[j] = 0x12
+				case 1:
+					b[j] = 0x34
+				case 2:
+					b[j] = 0x56
+				case 3:
+					b[j] = 0x78
+			}
+		}	
+	}
+
+	for i := 0; i < len(crcSzs); i++ {
+		for j := 0; j < len(buffers); j++ {
+			if err, crc := Crc(buffers[j], tables[i], bitCnts[j], crcSzs[i]); err {
+				t.Errorf("CRC FUNC ERROR: CRC sz: %d, Bit cnt \n", crcSzs[i], bitCnts[j])
+			} else {
+				switch crcSzs[i] {
+					case  8:
+						c = refCRC8[j]
+						v =  uint32(crc[0])
+					case 16:
+						c = refCRC16[j]
+						v = (uint32(crc[0]) << 8) | uint32(crc[1])
+					case 24:
+						c = refCRC24[j]
+						v = (uint32(crc[0]) << 16) | (uint32(crc[1]) << 8) | uint32(crc[2])
+				}
+
+				if v != c {
+					t.Errorf("CRC: %d, Bit Cnt: %d, Expected: 0x%X, received: 0x%X \n", crcSzs[i], bitCnts[j], c, v)
+				}
+			}
+		}
+	}
+}
+
+func BenchmarkCrc(b *testing.B) {
+	b.StopTimer()
+
+	// data creation
+	data := make([]uint8, 765)
+
+	for i := 0; i < len(data); i += 4 {
+		// 0x12345678
+		data[i + 0] = 0x12
+		data[i + 1] = 0x34
+		data[i + 2] = 0x56
+		data[i + 3] = 0x78
+	}
+
+	b.StartTimer()
+
+	for i := 0; i < len(tables); i++ {
+		_, _ = Crc(data, tables[i], (6114), crcSzs[i])
+	}
+}

nodeb/encoder/encode.go

+// Copyright (c) 2010 Joseph D Poirier
+// Distributable under the terms of The New BSD License
+// that can be found in the LICENSE file.
+
+package l1enc
+
+import (
+//	"fmt"	
+//	"os"
+)
+
+// (TODO) jdp: the function should take a struct of info rather than blkSz
+
+func Encode(src []uint8, blkSz int) (dst []uint8) {
+    segNfo := encoder.BlkSegParams(blkSz)
+
+}

nodeb/encoder/intrl.go

+// Copyright (c) 2010 Joseph D Poirier
+// Distributable under the terms of The New BSD License
+// that can be found in the LICENSE file.
+
+// 3GPP TS 36.212 V8.6.0 (2009-03) Multiplexing and channel coding (Release 8)
+// Section 5.1.3	Channel coding
+
+package l1enc
+
+type Data []uint8
+
+type params struct {
+   Ki uint32
+   f1 uint32
+   f2 uint32
+}
+
+var intrlParams = [188]params {
+	// 	Ki   f1   f2       i
+	params{  40,   3,  10}, // 1
+	params{  48,   7,  12},
+	params{  56,  19,  42},
+	params{  64,   7,  16},
+	params{  72,   7,  18},
+	params{  80,  11,  20},
+	params{  88,   5,  22},
+	params{  96,  11,  24},
+	params{ 104,   7,  26},
+	params{ 112,  41,  84}, // 10
+	params{ 120, 103,  90},
+	params{ 128,  15,  32},
+	params{ 136,   9 , 34},
+	params{ 144,  17, 108},
+	params{ 152,   9,  38},
+	params{ 160,  21, 120},
+	params{ 168, 101,  84},
+	params{ 176,  21,  44},
+	params{ 184,  57,  46},
+	params{ 192,  23,  48}, // 20
+	params{ 200,  13,  50},
+	params{ 208,  27,  52},
+	params{ 216,  11,  36},
+	params{ 224,  27,  56},
+	params{ 232,  85,  58},
+	params{ 240,  29,  60},
+	params{ 248,  33,  62},
+	params{ 256,  15,  32},
+	params{ 264,  17, 198},
+	params{ 272,  33,  68}, // 30
+	params{ 280, 103, 210},
+	params{ 288,  19,  36},
+	params{ 296,  19,  74},
+	params{ 304,  37,  76},
+	params{ 312,  19,  78},
+	params{ 320,  21, 120},
+	params{ 328,  21,  82},
+	params{ 336, 115,  84},
+	params{ 344, 193,  86},
+	params{ 352,  21,  44}, // 40
+	params{ 360, 133,  90},
+	params{ 368,  81,  46},
+	params{ 376,  45,  94},
+	params{ 384,  23,  48},
+	params{ 392, 243,  98},
+	params{ 400, 151,  40},
+	params{ 408, 155, 102},
+	params{ 416,  25,  52},
+	params{ 424,  51, 106},
+	params{ 432,  47,  72}, // 50
+	params{ 440,  91, 110},
+	params{ 448,  29, 168},
+	params{ 456,  29, 114},
+	params{ 464, 247,  58},
+	params{ 472,  29, 118},
+	params{ 480,  89, 180},
+	params{ 488,  91, 122},
+	params{ 496, 157,  62},
+	params{ 504,  55,  84},
+	params{ 512,  31,  64}, // 60
+	params{ 528,  17,  66},
+	params{ 544,  35,  68},
+	params{ 560, 227, 420},
+	params{ 576,  65,  96},
+	params{ 592,  19,  74},
+	params{ 608,  37,  76},
+	params{ 624,  41, 234},
+	params{ 640,  39,  80},
+	params{ 656, 185,  82},
+	params{ 672,  43, 252}, // 70
+	params{ 688,  21,  86},
+	params{ 704, 155,  44},
+	params{ 720,  79, 120},
+	params{ 736, 139,  92},
+	params{ 752,  23,  94},
+	params{ 768, 217,  48},
+	params{ 784,  25,  98},
+	params{ 800,  17,  80},
+	params{ 816, 127, 102},
+	params{ 832,  25,  52}, // 80
+	params{ 848, 239, 106},
+	params{ 864,  17,  48},
+	params{ 880, 137, 110},
+	params{ 896, 215, 112},
+	params{ 912,  29, 114},
+	params{ 928,  15,  58},
+	params{ 944, 147, 118},
+	params{ 960,  29,  60},
+	params{ 976,  59, 122},
+	params{ 992,  65, 124}, // 90
+	params{1008,  55,  84},
+	params{1024,  31,  64},
+	params{1056,  17,  66},
+	params{1088, 171, 204},
+	params{1120,  67, 140},
+	params{1152,  35,  72},
+	params{1184,  19,  74},
+	params{1216,  39,  76},
+	params{1248,  19,  78},
+	params{1280, 199, 240}, // 100
+	params{1312,  21,  82},
+	params{1344, 211, 252},
+	params{1376,  21,  86},
+	params{1408,  43,  88},
+	params{1440, 149,  60},
+	params{1472,  45,  92},
+	params{1504,  49, 846},
+	params{1536,  71,  48},
+	params{1568,  13,  28},
+	params{1600,  17,  80}, // 100
+	params{1632,  25, 102},
+	params{1664, 183, 104},
+	params{1696,  55, 954},
+	params{1728, 127,  96},
+	params{1760,  27, 110},
+	params{1792,  29, 112},
+	params{1824,  29, 114},
+	params{1856,  57, 116},
+	params{1888,  45, 354},
+	params{1920,  31, 120}, // 120
+	params{1952,  59, 610},
+	params{1984, 185, 124},
+	params{2016, 113, 420},
+	params{2048,  31,  64},
+	params{2112,  17,  66},
+	params{2176, 171, 136},
+	params{2240, 209, 420},
+	params{2304, 253, 216},
+	params{2368, 367, 444},
+	params{2432, 265, 456}, // 130
+	params{2496, 181, 468},
+	params{2560,  39,  80},
+	params{2624,  27, 164},
+	params{2688, 127, 504},
+	params{2752, 143, 172},
+	params{2816,  43,  88},
+	params{2880,  29, 300},
+	params{2944,  45,  92},
+	params{3008, 157, 188},
+	params{3072,  47,  96}, // 140
+	params{3136,  13,  28},
+	params{3200, 111, 240},
+	params{3264, 443, 204},
+	params{3328,  51, 104},
+	params{3392,  51, 212},
+	params{3456, 451, 192},
+	params{3520, 257, 220},
+	params{3584,  57, 336},
+	params{3648, 313, 228},
+	params{3712, 271, 232}, // 150
+	params{3776, 179, 236},
+	params{3840, 331, 120},
+	params{3904, 363, 244},
+	params{3968, 375, 248},
+	params{4032, 127, 168},
+	params{4096,  31,  64},
+	params{4160,  33, 130},
+	params{4224,  43, 264},
+	params{4288,  33, 134},
+	params{4352, 477, 408}, // 160
+	params{4416,  35, 138},
+	params{4480, 233, 280},
+	params{4544, 357, 142},
+	params{4608, 337, 480},
+	params{4672,  37, 146},
+	params{4736,  71, 444},
+	params{4800,  71, 120},
+	params{4864,  37, 152},
+	params{4928,  39, 462},
+	params{4992, 127, 234}, // 170
+	params{5056,  39, 158},
+	params{5120,  39,  80},
+	params{5184,  31,  96},
+	params{5248, 113, 902},
+	params{5312,  41, 166},
+	params{5376, 251, 336},
+	params{5440,  43, 170},
+	params{5504,  21,  86},
+	params{5568,  43, 174},
+	params{5632,  45, 176}, // 180
+	params{5696,  45, 178},
+	params{5760, 161, 120},
+	params{5824,  89, 182},
+	params{5888, 323, 184},
+	params{5952,  47, 186},
+	params{6016,  23,  94},
+	params{6080,  47, 190},
+	params{6144, 263, 480}} // 188
+
+func qppIntrl(src Data, dst Data, bitCnt uint32) (err bool) {
+
+	var iSrc uint32
+	var iDst uint32
+	var i uint32
+	var j uint32
+	var aa uint32
+	var bitPos uint32
+	var bit	uint8
+
+	K := bitCnt
+	
+	switch {
+		default:
+			err = true
+			return
+		case K < 40:
+			i = 0
+		case K < 512:
+			i = (K / 8) - 5
+		case K < 1024:
+			i = (K / 16) + 27
+		case K < 2048:
+			i = (K / 32) + 59
+		case K < 6144:
+			i = (K / 64) + 91
+	}
+
+	f := intrlParams[i]
+
+	for j = 0; j < K; j++ {
+		// a % n  < same as >  a - (n * int(a / n))
+		// calc the src and dst data indicies (sect 5.1.3.2.3)
+		aa 	= (f.f1 * j) + (f.f2 * j * j)
+		aa 	= aa - (K * (aa / K))
+		iSrc 	= aa / 8
+		iDst 	= j / 8
+
+		// fetch the source bit
+		bitPos	= aa & 0x7
+		bit 	= (src[iSrc] >> (7 - bitPos)) & 0x1
+
+		// store the output bit
+		bitPos	= j & 0x7
+		dst[iDst] |= (bit << (7 - bitPos))
+	}
+
+	return
+}
+

nodeb/encoder/todo.txt

+6-10-10
+-------
+- still need to validate the CRC 24_A table
+- stopped at the segmentation of blocks, func BlkSeg (hideous stuff!!)
+- finish the adhoc Append function
+
+- as far as a turbo encoder is concerned us the RSC version
+
+6-18-10
+-------
+- reformat CRC tables
+- fixed the crc test to handle the CRC slice return value
+
+6-19-10
+-------
+- validated the orphan bit crcs
+- started writings tests for the adhoc methods
+
+6-21-10
+-------
+- validated the Rsh method via TestRsh but it needs to be refactored
+- finished the adhoc.go file, but the scope of the unit tests need to be expanded
+
+6-22-10
+-------
+- left off at the BlkSeg function, the blkseg buffer creation needs to change
+  so that each segment slice is an independant slice and not a park of any
+  contiguous buffer, because of the way the addhoc functions work
+
+
+

nodeb/encoder/turboenc.go

+// Copyright (c) 2010 Joseph D Poirier
+// Distributable under the terms of The New BSD License
+// that can be found in the LICENSE file.
+
+// 3GPP TS 36.212 V8.6.0 (2009-03) Multiplexing and channel coding (Release 8)
+// Section 5.1.3	Channel coding
+
+package l1enc
+
+import (
+
+)
+
+var terminationTable = [64]uint32 {
+	0x0000,0x0033,0x0302,0x0331,0x0220,0x0213,0x0122,0x0111,0x00CC,0x00FF,
+	0x03CE,0x03FD,0x02EC,0x02DF,0x01EE,0x01DD,0x0C08,0x0C3B,0x0F0A,0x0F39,
+	0x0E28,0x0E1B,0x0D2A,0x0D19,0x0CC4,0x0CF7,0x0FC6,0x0FF5,0x0EE4,0x0ED7,
+	0x0DE6,0x0DD5,0x0880,0x08B3,0x0B82,0x0BB1,0x0AA0,0x0A93,0x09A2,0x0991,
+	0x084C,0x087F,0x0B4E,0x0B7D,0x0A6C,0x0A5F,0x096E,0x095D,0x0488,0x04BB,
+	0x078A,0x07B9,0x06A8,0x069B,0x05AA,0x0599,0x0444,0x0477,0x0746,0x0775,
+	0x0664,0x0657,0x0566,0x0555}
+
+var internalStateOfTurboCoder = [256]uint32 {
+	0x00,0x01,0x02,0x03,0x05,0x04,0x07,0x06,0x0B,0x0A,0x09,0x08,0x0E,0x0F,0x0C,0x0D,
+	0x17,0x16,0x15,0x14,0x12,0x13,0x10,0x11,0x1C,0x1D,0x1E,0x1F,0x19,0x18,0x1B,0x1A,
+	0x2E,0x2F,0x2C,0x2D,0x2B,0x2A,0x29,0x28,0x25,0x24,0x27,0x26,0x20,0x21,0x22,0x23,
+	0x39,0x38,0x3B,0x3A,0x3C,0x3D,0x3E,0x3F,0x32,0x33,0x30,0x31,0x37,0x36,0x35,0x34,
+	0x5C,0x5D,0x5E,0x5F,0x59,0x58,0x5B,0x5A,0x57,0x56,0x55,0x54,0x52,0x53,0x50,0x51,
+	0x4B,0x4A,0x49,0x48,0x4E,0x4F,0x4C,0x4D,0x40,0x41,0x42,0x43,0x45,0x44,0x47,0x46,
+	0x72,0x73,0x70,0x71,0x77,0x76,0x75,0x74,0x79,0x78,0x7B,0x7A,0x7C,0x7D,0x7E,0x7F,
+	0x65,0x64,0x67,0x66,0x60,0x61,0x62,0x63,0x6E,0x6F,0x6C,0x6D,0x6B,0x6A,0x69,0x68,
+	0xB9,0xB8,0xBB,0xBA,0xBC,0xBD,0xBE,0xBF,0xB2,0xB3,0xB0,0xB1,0xB7,0xB6,0xB5,0xB4,
+	0xAE,0xAF,0xAC,0xAD,0xAB,0xAA,0xA9,0xA8,0xA5,0xA4,0xA7,0xA6,0xA0,0xA1,0xA2,0xA3,
+	0x97,0x96,0x95,0x94,0x92,0x93,0x90,0x91,0x9C,0x9D,0x9E,0x9F,0x99,0x98,0x9B,0x9A,
+	0x80,0x81,0x82,0x83,0x85,0x84,0x87,0x86,0x8B,0x8A,0x89,0x88,0x8E,0x8F,0x8C,0x8D,
+	0xE5,0xE4,0xE7,0xE6,0xE0,0xE1,0xE2,0xE3,0xEE,0xEF,0xEC,0xED,0xEB,0xEA,0xE9,0xE8,
+	0xF2,0xF3,0xF0,0xF1,0xF7,0xF6,0xF5,0xF4,0xF9,0xF8,0xFB,0xFA,0xFC,0xFD,0xFE,0xFF,
+	0xCB,0xCA,0xC9,0xC8,0xCE,0xCF,0xCC,0xCD,0xC0,0xC1,0xC2,0xC3,0xC5,0xC4,0xC7,0xC6,
+	0xDC,0xDD,0xDE,0xDF,0xD9,0xD8,0xDB,0xDA,0xD7,0xD6,0xD5,0xD4,0xD2,0xD3,0xD0,0xD1}
+
+var turboFeedBack = [128]uint32 {
+	0xA0600000,0xE0A040C0,0x808020E0,0xC0406020,0x40C0E0A0,0x0000A060,0x6020C040,
+	0x20E08080,0xC0406020,0x808020E0,0xE0A040C0,0xA0600000,0x20E08080,0x6020C040,
+	0x0000A060,0x40C0E0A0,0x6020C040,0x20E08080,0x40C0E0A0,0x0000A060,0x808020E0,
+	0xC0406020,0xA0600000,0xE0A040C0,0x0000A060,0x40C0E0A0,0x20E08080,0x6020C040,
+	0xE0A040C0,0xA0600000,0xC0406020,0x808020E0,0x20E08080,0x6020C040,0x0000A060,
+	0x40C0E0A0,0xC0406020,0x808020E0,0xE0A040C0,0xA0600000,0x40C0E0A0,0x0000A060,
+	0x6020C040,0x20E08080,0xA0600000,0xE0A040C0,0x808020E0,0xC0406020,0xE0A040C0,
+	0xA0600000,0xC0406020,0x808020E0,0x0000A060,0x40C0E0A0,0x20E08080,0x6020C040,
+	0x808020E0,0xC0406020,0xA0600000,0xE0A040C0,0x6020C040,0x20E08080,0x40C0E0A0,
+	0x0000A060,0x0000A060,0x40C0E0A0,0x20E08080,0x6020C040,0xE0A040C0,0xA0600000,
+	0xC0406020,0x808020E0,0x6020C040,0x20E08080,0x40C0E0A0,0x0000A060,0x808020E0,
+	0xC0406020,0xA0600000,0xE0A040C0,0xC0406020,0x808020E0,0xE0A040C0,0xA0600000,
+	0x20E08080,0x6020C040,0x0000A060,0x40C0E0A0,0xA0600000,0xE0A040C0,0x808020E0,
+	0xC0406020,0x40C0E0A0,0x0000A060,0x6020C040,0x20E08080,0x808020E0,0xC0406020,
+	0xA0600000,0xE0A040C0,0x6020C040,0x20E08080,0x40C0E0A0,0x0000A060,0xE0A040C0,
+	0xA0600000,0xC0406020,0x808020E0,0x0000A060,0x40C0E0A0,0x20E08080,0x6020C040,
+	0x40C0E0A0,0x0000A060,0x6020C040,0x20E08080,0xA0600000,0xE0A040C0,0x808020E0,
+	0xC0406020,0x20E08080,0x6020C040,0x0000A060,0x40C0E0A0,0xC0406020,0x808020E0,
+	0xE0A040C0,0xA0600000}
+
+var turboLookUpTable = [64]uint32 {
+	0x02030100,0x05040607,0x0D0C0E0F,0x0A0B0908,0x1C1D1F1E,0x1B1A1819,0x13121011,
+	0x14151716,0x3E3F3D3C,0x39383A3B,0x31303233,0x36373534,0x20212322,0x27262425,
+	0x2F2E2C2D,0x28292B2A,0x7B7A7879,0x7C7D7F7E,0x74757776,0x73727071,0x65646667,
+	0x62636160,0x6A6B6968,0x6D6C6E6F,0x47464445,0x40414342,0x48494B4A,0x4F4E4C4D,
+	0x59585A5B,0x5E5F5D5C,0x56575554,0x51505253,0xF0F1F3F2,0xF7F6F4F5,0xFFFEFCFD,
+	0xF8F9FBFA,0xEEEFEDEC,0xE9E8EAEB,0xE1E0E2E3,0xE6E7E5E4,0xCCCDCFCE,0xCBCAC8C9,
+	0xC3C2C0C1,0xC4C5C7C6,0xD2D3D1D0,0xD5D4D6D7,0xDDDCDEDF,0xDADBD9D8,0x89888A8B,
+	0x8E8F8D8C,0x86878584,0x81808283,0x97969495,0x90919392,0x98999B9A,0x9F9E9C9D,
+	0xB5B4B6B7,0xB2B3B1B0,0xBABBB9B8,0xBDBCBEBF,0xABAAA8A9,0xACADAFAE,0xA4A5A7A6,
+	0xA3A2A0A1}
+
+// Table 5.1.3-3: Turbo code internal interleaver parameters
+
+
+

nodeb/encoder/turbointerl.go

+// Copyright (c) 2010 Joseph D Poirier
+// Distributable under the terms of The New BSD License
+// that can be found in the LICENSE file.
+
+// 3GPP TS 36.212 V8.6.0 (2009-03) Multiplexing and channel coding (Release 8)
+// Section 5.1.3	Channel coding
+
+package l1enc
+
+type params struct {
+	Ki uint32
+	f1 uint32
+	f2 uint32
+}
+
+var intrlParams = [188]params {
+	// 	Ki   f1   f2       i
+	params{  40,   3,  10}, // 1
+	params{  48,   7,  12},
+	params{  56,  19,  42},
+	params{  64,   7,  16},
+	params{  72,   7,  18},
+	params{  80,  11,  20},
+	params{  88,   5,  22},
+	params{  96,  11,  24},
+	params{ 104,   7,  26},
+	params{ 112,  41,  84}, // 10
+	params{ 120, 103,  90},
+	params{ 128,  15,  32},
+	params{ 136,   9 , 34},
+	params{ 144,  17, 108},
+	params{ 152,   9,  38},
+	params{ 160,  21, 120},
+	params{ 168, 101,  84},
+	params{ 176,  21,  44},
+	params{ 184,  57,  46},
+	params{ 192,  23,  48}, // 20
+	params{ 200,  13,  50},
+	params{ 208,  27,  52},
+	params{ 216,  11,  36},
+	params{ 224,  27,  56},
+	params{ 232,  85,  58},
+	params{ 240,  29,  60},
+	params{ 248,  33,  62},
+	params{ 256,  15,  32},
+	params{ 264,  17, 198},
+	params{ 272,  33,  68}, // 30
+	params{ 280, 103, 210},
+	params{ 288,  19,  36},
+	params{ 296,  19,  74},
+	params{ 304,  37,  76},
+	params{ 312,  19,  78},
+	params{ 320,  21, 120},
+	params{ 328,  21,  82},
+	params{ 336, 115,  84},
+	params{ 344, 193,  86},
+	params{ 352,  21,  44}, // 40
+	params{ 360, 133,  90},
+	params{ 368,  81,  46},
+	params{ 376,  45,  94},
+	params{ 384,  23,  48},
+	params{ 392, 243,  98},
+	params{ 400, 151,  40},
+	params{ 408, 155, 102},
+	params{ 416,  25,  52},
+	params{ 424,  51, 106},
+	params{ 432,  47,  72}, // 50
+	params{ 440,  91, 110},
+	params{ 448,  29, 168},
+	params{ 456,  29, 114},
+	params{ 464, 247,  58},
+	params{ 472,  29, 118},
+	params{ 480,  89, 180},
+	params{ 488,  91, 122},
+	params{ 496, 157,  62},
+	params{ 504,  55,  84},
+	params{ 512,  31,  64}, // 60
+	params{ 528,  17,  66},
+	params{ 544,  35,  68},
+	params{ 560, 227, 420},
+	params{ 576,  65,  96},
+	params{ 592,  19,  74},
+	params{ 608,  37,  76},
+	params{ 624,  41, 234},
+	params{ 640,  39,  80},
+	params{ 656, 185,  82},
+	params{ 672,  43, 252}, // 70
+	params{ 688,  21,  86},
+	params{ 704, 155,  44},
+	params{ 720,  79, 120},
+	params{ 736, 139,  92},
+	params{ 752,  23,  94},
+	params{ 768, 217,  48},
+	params{ 784,  25,  98},
+	params{ 800,  17,  80},
+	params{ 816, 127, 102},
+	params{ 832,  25,  52}, // 80
+	params{ 848, 239, 106},
+	params{ 864,  17,  48},
+	params{ 880, 137, 110},
+	params{ 896, 215, 112},
+	params{ 912,  29, 114},
+	params{ 928,  15,  58},
+	params{ 944, 147, 118},
+	params{ 960,  29,  60},
+	params{ 976,  59, 122},
+	params{ 992,  65, 124}, // 90
+	params{1008,  55,  84},
+	params{1024,  31,  64},
+	params{1056,  17,  66},
+	params{1088, 171, 204},
+	params{1120,  67, 140},
+	params{1152,  35,  72},
+	params{1184,  19,  74},
+	params{1216,  39,  76},
+	params{1248,  19,  78},
+	params{1280, 199, 240}, // 100
+	params{1312,  21,  82},
+	params{1344, 211, 252},
+	params{1376,  21,  86},
+	params{1408,  43,  88},
+	params{1440, 149,  60},
+	params{1472,  45,  92},
+	params{1504,  49, 846},
+	params{1536,  71,  48},
+	params{1568,  13,  28},
+	params{1600,  17,  80}, // 100
+	params{1632,  25, 102},
+	params{1664, 183, 104},
+	params{1696,  55, 954},
+	params{1728, 127,  96},
+	params{1760,  27, 110},
+	params{1792,  29, 112},
+	params{1824,  29, 114},
+	params{1856,  57, 116},
+	params{1888,  45, 354},
+	params{1920,  31, 120}, // 120
+	params{1952,  59, 610},
+	params{1984, 185, 124},
+	params{2016, 113, 420},
+	params{2048,  31,  64},
+	params{2112,  17,  66},
+	params{2176, 171, 136},
+	params{2240, 209, 420},
+	params{2304, 253, 216},
+	params{2368, 367, 444},
+	params{2432, 265, 456}, // 130
+	params{2496, 181, 468},
+	params{2560,  39,  80},
+	params{2624,  27, 164},
+	params{2688, 127, 504},
+	params{2752, 143, 172},
+	params{2816,  43,  88},
+	params{2880,  29, 300},
+	params{2944,  45,  92},
+	params{3008, 157, 188},
+	params{3072,  47,  96}, // 140
+	params{3136,  13,  28},
+	params{3200, 111, 240},
+	params{3264, 443, 204},
+	params{3328,  51, 104},
+	params{3392,  51, 212},
+	params{3456, 451, 192},
+	params{3520, 257, 220},
+	params{3584,  57, 336},
+	params{3648, 313, 228},
+	params{3712, 271, 232}, // 150
+	params{3776, 179, 236},
+	params{3840, 331, 120},
+	params{3904, 363, 244},
+	params{3968, 375, 248},
+	params{4032, 127, 168},
+	params{4096,  31,  64},
+	params{4160,  33, 130},
+	params{4224,  43, 264},
+	params{4288,  33, 134},
+	params{4352, 477, 408}, // 160
+	params{4416,  35, 138},
+	params{4480, 233, 280},
+	params{4544, 357, 142},
+	params{4608, 337, 480},
+	params{4672,  37, 146},
+	params{4736,  71, 444},
+	params{4800,  71, 120},
+	params{4864,  37, 152},
+	params{4928,  39, 462},
+	params{4992, 127, 234}, // 170
+	params{5056,  39, 158},
+	params{5120,  39,  80},
+	params{5184,  31,  96},
+	params{5248, 113, 902},
+	params{5312,  41, 166},
+	params{5376, 251, 336},
+	params{5440,  43, 170},
+	params{5504,  21,  86},
+	params{5568,  43, 174},
+	params{5632,  45, 176}, // 180
+	params{5696,  45, 178},
+	params{5760, 161, 120},
+	params{5824,  89, 182},
+	params{5888, 323, 184},
+	params{5952,  47, 186},
+	params{6016,  23,  94},
+	params{6080,  47, 190},
+	params{6144, 263, 480}} // 188
+
+func qppIntrl(src Data, dst Data, bitCnt uint32) (err bool) {
+	var iSrc uint32
+	var iDst uint32
+	var i uint32
+	var j uint32
+	var aa uint32
+	var bitPos uint32
+	var bit	uint8
+
+	K := bitCnt
+	
+	switch {
+		default:
+			err = true
+			return
+		case K < 40:
+			i = 0
+		case K < 512:
+			i = (K / 8) - 5
+		case K < 1024:
+			i = (K / 16) + 27
+		case K < 2048:
+			i = (K / 32) + 59
+		case K < 6144:
+			i = (K / 64) + 91
+	}
+
+	f := intrlParams[i]
+
+	for j = 0; j < K; j++ {
+		// a % n  < same as >  a - (n * int(a / n))
+		// calc the src and dst data indicies (sect 5.1.3.2.3)
+		aa 	= (f.f1 * j) + (f.f2 * j * j)
+		aa 	= aa - (K * (aa / K))
+		iSrc 	= aa / 8
+		iDst 	= j / 8
+
+		// fetch the source bit
+		bitPos	= aa & 0x7
+		bit 	= (src[iSrc] >> (7 - bitPos)) & 0x1
+
+		// store the output bit
+		bitPos	= j & 0x7
+		dst[iDst] |= (bit << (7 - bitPos))
+	}
+
+	return
+}
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.