nazabits

package
v0.27.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2021 License: MIT Imports: 1 Imported by: 36

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNazaBits = errors.New("nazabits: fxxk")

Functions

func GetBit16 added in v0.10.0

func GetBit16(v []byte, pos uint) uint8

func GetBit8

func GetBit8(v uint8, pos uint) uint8

@param pos: 取值范围 [0, 7],0表示最低位 @return: [0, 1]

func GetBits16 added in v0.10.0

func GetBits16(v []byte, pos uint, n uint) uint16

func GetBits8

func GetBits8(v uint8, pos uint, n uint) uint8

@param pos: 取值范围 [0, 7],0表示最低位 @param n: 取多少位, 取值范围 [1, 8]

举例,GetBits8(105, 2, 4) = 10(即1010)

v: 0110 1001

pos: 2

n:   .. ..

Types

type BitReader added in v0.11.0

type BitReader struct {
	// contains filtered or unexported fields
}

按位流式读取字节切片 从高位向低位读 注意,可以在每次读取后,判断是否发生错误。也可以在多次读取后,判断是否发生错误。

func NewBitReader added in v0.11.0

func NewBitReader(b []byte) BitReader

func (*BitReader) AvailBits added in v0.18.3

func (br *BitReader) AvailBits() (uint, error)

返回可读bit数量

func (*BitReader) Err added in v0.17.1

func (br *BitReader) Err() error

func (*BitReader) ReadBit added in v0.11.0

func (br *BitReader) ReadBit() (uint8, error)

func (*BitReader) ReadBits16 added in v0.12.1

func (br *BitReader) ReadBits16(n uint) (r uint16, err error)

@param n: 取值范围 [1, 16]

func (*BitReader) ReadBits32 added in v0.12.1

func (br *BitReader) ReadBits32(n uint) (r uint32, err error)

@param n: 取值范围 [1, 32]

func (*BitReader) ReadBits64 added in v0.15.0

func (br *BitReader) ReadBits64(n uint) (r uint64, err error)

@param n: 取值范围 [1, 64]

func (*BitReader) ReadBits8 added in v0.12.0

func (br *BitReader) ReadBits8(n uint) (r uint8, err error)

@param n: 取值范围 [1, 8]

func (*BitReader) ReadBytes added in v0.12.1

func (br *BitReader) ReadBytes(n uint) (r []byte, err error)

@param n: 读取多少个字节

func (*BitReader) ReadGolomb added in v0.13.0

func (br *BitReader) ReadGolomb() (v uint32, err error)

func (*BitReader) ReadSeGolomb added in v0.20.1

func (br *BitReader) ReadSeGolomb() (v int32, err error)

ReadSeGolomb 哥伦布编码,有符号

func (*BitReader) ReadUeGolomb added in v0.20.1

func (br *BitReader) ReadUeGolomb() (v uint32, err error)

ReadUeGolomb 0阶指数哥伦布编码,无符号

func (*BitReader) SkipBits added in v0.18.3

func (br *BitReader) SkipBits(n uint) error

func (*BitReader) SkipBytes added in v0.18.3

func (br *BitReader) SkipBytes(n uint) error

type BitWriter added in v0.11.0

type BitWriter struct {
	// contains filtered or unexported fields
}

func NewBitWriter added in v0.11.0

func NewBitWriter(b []byte) BitWriter

func (*BitWriter) WriteBit added in v0.11.0

func (bw *BitWriter) WriteBit(b uint8)

@param b: 当b不为0和1时,取b的最低位

func (*BitWriter) WriteBits16 added in v0.12.0

func (bw *BitWriter) WriteBits16(n uint, v uint16)

func (*BitWriter) WriteBits8 added in v0.12.0

func (bw *BitWriter) WriteBits8(n uint, v uint8)

将<v>的低<n>位写入 @param n: 取值范围 [1, 8]

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL