File tree Expand file tree Collapse file tree 2 files changed +179
-82
lines changed
Expand file tree Collapse file tree 2 files changed +179
-82
lines changed Original file line number Diff line number Diff line change @@ -87,6 +87,31 @@ func (g *GolombRice) Bits() int {
8787 return g .bitCount
8888}
8989
90+ // Append concatenates another GolombRice bit-stream onto this one.
91+ func (g * GolombRice ) Append (other * GolombRice ) {
92+ if other .bitCount == 0 {
93+ return
94+ }
95+ shift := g .bitCount & 63
96+ targetSize := (g .bitCount + other .bitCount + 63 ) / 64
97+ for len (g .data ) < targetSize {
98+ g .data = append (g .data , 0 )
99+ }
100+ appendPtr := g .bitCount / 64
101+ nWords := (other .bitCount + 63 ) / 64
102+ if shift == 0 {
103+ copy (g .data [appendPtr :], other .data [:nWords ])
104+ } else {
105+ for i , w := range other .data [:nWords ] {
106+ g .data [appendPtr + i ] |= w << shift
107+ if appendPtr + i + 1 < len (g .data ) {
108+ g .data [appendPtr + i + 1 ] |= w >> (64 - shift )
109+ }
110+ }
111+ }
112+ g .bitCount += other .bitCount
113+ }
114+
90115func (g * GolombRiceReader ) ReadReset (bitPos , unaryOffset int ) {
91116 g .currFixedOffset = bitPos
92117 unaryPos := bitPos + unaryOffset
You can’t perform that action at this time.
0 commit comments