1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/chai2010-tiff

Клонировать/Скачать
bits_io.go 927
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
chaishushan@gmail.com Отправлено 22.02.2015 15:21 2af1d4f
// Copyright 2014 <chaishushan{AT}gmail.com>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package tiff
type bitsReader struct {
buf []byte
off int // Current offset in buf.
v uint32 // Buffer value for reading with arbitrary bit depths.
nbits uint // Remaining number of bits in v.
}
func newBitsReader(data []byte) *bitsReader {
return &bitsReader{
buf: data,
}
}
// readBits reads n bits from the internal buffer starting at the current offset.
func (p *bitsReader) ReadBits(n uint) uint32 {
for p.nbits < n {
p.v <<= 8
p.v |= uint32(p.buf[p.off])
p.off++
p.nbits += 8
}
p.nbits -= n
rv := p.v >> p.nbits
p.v &^= rv << p.nbits
return rv
}
// flushBits discards the unread bits in the buffer used by readBits.
// It is used at the end of a line.
func (p *bitsReader) flushBits() {
p.v = 0
p.nbits = 0
}

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/chai2010-tiff.git
git@api.gitlife.ru:oschina-mirror/chai2010-tiff.git
oschina-mirror
chai2010-tiff
chai2010-tiff
master