Documentation ¶
Overview ¶
Package reader provides the stream readers used by the jbig2 segments decoder. It defines the StreamReader interface that allows to read bit, bits, byte, bytes, integers change and get the stream position, align the bits.
Index ¶
- type Reader
- func (r *Reader) Align() (skipped byte)
- func (r *Reader) BitPosition() int
- func (r *Reader) ConsumeRemainingBits()
- func (r *Reader) Length() uint64
- func (r *Reader) Mark()
- func (r *Reader) Read(p []byte) (n int, err error)
- func (r *Reader) ReadBit() (bit int, err error)
- func (r *Reader) ReadBits(n byte) (u uint64, err error)
- func (r *Reader) ReadBool() (bool, error)
- func (r *Reader) ReadByte() (byte, error)
- func (r *Reader) ReadUint32() (uint32, error)
- func (r *Reader) Reset()
- func (r *Reader) Seek(offset int64, whence int) (int64, error)
- func (r *Reader) StreamPosition() int64
- type StreamReader
- type SubstreamReader
- func (s *SubstreamReader) Align() (skipped byte)
- func (s *SubstreamReader) BitPosition() int
- func (s *SubstreamReader) Length() uint64
- func (s *SubstreamReader) Mark()
- func (s *SubstreamReader) Offset() uint64
- func (s *SubstreamReader) Read(b []byte) (n int, err error)
- func (s *SubstreamReader) ReadBit() (bit int, err error)
- func (s *SubstreamReader) ReadBits(n byte) (u uint64, err error)
- func (s *SubstreamReader) ReadBool() (bool, error)
- func (s *SubstreamReader) ReadByte() (byte, error)
- func (s *SubstreamReader) ReadUint32() (uint32, error)
- func (s *SubstreamReader) Reset()
- func (s *SubstreamReader) Seek(offset int64, whence int) (int64, error)
- func (s *SubstreamReader) StreamPosition() int64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader is the bit reader implementation. Implements io.Reader, io.ByteReader, io.Seeker interfaces.
func (*Reader) BitPosition ¶
BitPosition implements StreamReader inteface.
func (*Reader) ConsumeRemainingBits ¶
func (r *Reader) ConsumeRemainingBits()
ConsumeRemainingBits consumes the remaining bits from the given reader.
func (*Reader) ReadUint32 ¶
ReadUint32 implements StreamReader interface.
func (*Reader) StreamPosition ¶
StreamPosition implements StreamReader interface.
type StreamReader ¶
type StreamReader interface { io.Reader io.ByteReader io.Seeker // Align resets the bits position of the given reader. // It returns how many bits left were skipped. Align() byte // BitPosition gets the current bit position. BitPosition() int // Mark marks a position in the stream to be returned to by a subsequent call to 'Reset'. Mark() // Length returns the length of the total data used by the reader. Length() uint64 // ReadBit reads the next binary value from the current cache. // Equivalent of ReadBool method but returns an integer. ReadBit() (int, error) // ReadBits reads the bits of size 'n' from the reader. ReadBits(n byte) (uint64, error) // ReadBool reads the next binary value from the current cache. ReadBool() (bool, error) // ReadUint32 reads the unsigned uint32 from the reader. ReadUint32() (uint32, error) // Reset returns the stream pointer to its previous position, including the bit offset, // at the time of the most recent unmatched call to mark. Reset() // StreamPosition gets the stream position of the stream reader. StreamPosition() int64 }
StreamReader is the interface that allows to read bit, bits, byte, bytes, integers change and get the stream position, align the bits.
type SubstreamReader ¶
type SubstreamReader struct {
// contains filtered or unexported fields
}
SubstreamReader is the wrapper over the Reader's parts that is allowed only to operate on the selected data space.
func NewSubstreamReader ¶
func NewSubstreamReader(r StreamReader, offset, length uint64) (*SubstreamReader, error)
NewSubstreamReader creates new SubStreamReader for the provided wrapped StreamReader 'r' with defined 'offset' and 'length'.
func (*SubstreamReader) Align ¶
func (s *SubstreamReader) Align() (skipped byte)
Align implements StreamReader interface.
func (*SubstreamReader) BitPosition ¶
func (s *SubstreamReader) BitPosition() int
BitPosition implements StreamReader interface.
func (*SubstreamReader) Length ¶
func (s *SubstreamReader) Length() uint64
Length implements StreamReader interface.
func (*SubstreamReader) Mark ¶
func (s *SubstreamReader) Mark()
Mark implements StreamReader interface.
func (*SubstreamReader) Offset ¶
func (s *SubstreamReader) Offset() uint64
Offset returns current SubstreamReader offset.
func (*SubstreamReader) Read ¶
func (s *SubstreamReader) Read(b []byte) (n int, err error)
Read implements io.Reader interface.
func (*SubstreamReader) ReadBit ¶
func (s *SubstreamReader) ReadBit() (bit int, err error)
ReadBit implements StreamReader interface.
func (*SubstreamReader) ReadBits ¶
func (s *SubstreamReader) ReadBits(n byte) (u uint64, err error)
ReadBits implements StreamReader interface.
func (*SubstreamReader) ReadBool ¶
func (s *SubstreamReader) ReadBool() (bool, error)
ReadBool implements StreamReader interface.
func (*SubstreamReader) ReadByte ¶
func (s *SubstreamReader) ReadByte() (byte, error)
ReadByte implements io.ByteReader.
func (*SubstreamReader) ReadUint32 ¶
func (s *SubstreamReader) ReadUint32() (uint32, error)
ReadUint32 implements Streamreader interface.
func (*SubstreamReader) Reset ¶
func (s *SubstreamReader) Reset()
Reset implements StreamReader interface.
func (*SubstreamReader) Seek ¶
func (s *SubstreamReader) Seek(offset int64, whence int) (int64, error)
Seek implements the io.Seeker interface.
func (*SubstreamReader) StreamPosition ¶
func (s *SubstreamReader) StreamPosition() int64
StreamPosition implements StreamReader interface.