ebml

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ebml contains low-level EBML primitives used by container packages.

The package intentionally stops at element framing: callers remain responsible for their schema, nesting rules, and media semantics.

Index

Constants

View Source
const (
	MaxIDWidth   = 4
	MaxSizeWidth = 8
)

Variables

View Source
var (
	ErrInvalidVINT       = errors.New("ebml: invalid variable-size integer")
	ErrVINTOverflow      = errors.New("ebml: variable-size integer overflow")
	ErrInvalidElementID  = errors.New("ebml: invalid element id")
	ErrInvalidSize       = errors.New("ebml: invalid element size")
	ErrUnknownSize       = errors.New("ebml: unknown element size")
	ErrElementTooLarge   = errors.New("ebml: element too large")
	ErrNonSeekableWriter = errors.New("ebml: writer is not seekable")
)

Functions

func CRC32

func CRC32(payload []byte) uint32

func DecodeUnsignedVINT

func DecodeUnsignedVINT(src []byte) (uint64, int, error)

func EncodeID

func EncodeID(dst []byte, id ID) (int, error)

func EncodeSizeVINT

func EncodeSizeVINT(dst []byte, value uint64) (int, error)

func EncodeSizeVINTWidth

func EncodeSizeVINTWidth(dst []byte, value uint64, width int) (int, error)

func EncodeUnknownSize

func EncodeUnknownSize(dst []byte, width int) (int, error)

func EncodeUnsignedVINT

func EncodeUnsignedVINT(dst []byte, value uint64) (int, error)

func EncodeUnsignedVINTWidth

func EncodeUnsignedVINTWidth(dst []byte, value uint64, width int) (int, error)

func IDWidth

func IDWidth(id ID) (int, error)

func PutCRC32

func PutCRC32(dst []byte, payload []byte) error

func ReadUnsignedVINT

func ReadUnsignedVINT(r io.Reader, scratch *[MaxSizeWidth]byte) (uint64, int, error)

func SizeVINTWidth

func SizeVINTWidth(value uint64) (int, error)

func UnsignedVINTWidth

func UnsignedVINTWidth(value uint64) (int, error)

func VINTWidth

func VINTWidth(first byte) (int, error)

func ValidateCRC32

func ValidateCRC32(stored []byte, payload []byte) bool

Types

type ElementError

type ElementError struct {
	ID     ID
	Offset int64
	Err    error
}

func (*ElementError) Error

func (e *ElementError) Error() string

func (*ElementError) Unwrap

func (e *ElementError) Unwrap() error
type Header struct {
	ID         ID
	Size       Size
	Offset     int64
	DataOffset int64
	HeaderSize int
}

func (Header) KnownSize

func (h Header) KnownSize() (uint64, error)

type ID

type ID uint64
const (
	CRC32ID ID = 0xbf
	VoidID  ID = 0xec
)

func DecodeIDVINT

func DecodeIDVINT(src []byte) (ID, int, error)

func ReadID

func ReadID(r io.Reader, scratch *[MaxSizeWidth]byte) (ID, int, error)

type Reader

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

func NewReader

func NewReader(r io.Reader, options ReaderOptions) *Reader

func (*Reader) Limited

func (r *Reader) Limited(size uint64) *io.LimitedReader

func (*Reader) Offset

func (r *Reader) Offset() int64

func (*Reader) Read

func (r *Reader) Read(p []byte) (int, error)

func (*Reader) ReadFull

func (r *Reader) ReadFull(dst []byte) error

func (*Reader) ReadHeader

func (r *Reader) ReadHeader() (Header, error)

func (*Reader) Remaining

func (r *Reader) Remaining() (uint64, bool)

func (*Reader) Reset

func (r *Reader) Reset(input io.Reader, options ReaderOptions)

func (*Reader) ResetAt

func (r *Reader) ResetAt(input io.Reader, options ReaderOptions, offset int64)

ResetAt resets the input and sets the logical offset reported by future reads.

func (*Reader) Skip

func (r *Reader) Skip(size uint64) error

type ReaderOptions

type ReaderOptions struct {
	MaxElementSize uint64
}

type Size

type Size struct {
	Value   uint64
	Unknown bool
	Width   int
}

func DecodeSizeVINT

func DecodeSizeVINT(src []byte) (Size, error)

func ReadSize

func ReadSize(r io.Reader, scratch *[MaxSizeWidth]byte) (Size, error)

type SizePatch

type SizePatch struct {
	Offset int64
	Width  int
	Start  int64
}

type Writer

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

func NewWriter

func NewWriter(w io.Writer) *Writer

func (*Writer) FinishSizedElement

func (w *Writer) FinishSizedElement(patch SizePatch) error

func (*Writer) Offset

func (w *Writer) Offset() int64

func (*Writer) StartSizedElement

func (w *Writer) StartSizedElement(id ID, width int) (SizePatch, error)

func (*Writer) Write

func (w *Writer) Write(p []byte) (int, error)

func (*Writer) WriteCRC32

func (w *Writer) WriteCRC32(payload []byte) error

func (*Writer) WriteElement

func (w *Writer) WriteElement(id ID, payload []byte) error

func (*Writer) WriteFloat64

func (w *Writer) WriteFloat64(id ID, value float64) error

func (*Writer) WriteHeader

func (w *Writer) WriteHeader(id ID, size uint64) error

func (*Writer) WriteInt

func (w *Writer) WriteInt(id ID, value int64) error

func (*Writer) WriteString

func (w *Writer) WriteString(id ID, value string) error

func (*Writer) WriteUInt

func (w *Writer) WriteUInt(id ID, value uint64) error

func (*Writer) WriteUnknownHeader

func (w *Writer) WriteUnknownHeader(id ID, sizeWidth int) error

func (*Writer) WriteVoid

func (w *Writer) WriteVoid(payloadSize uint64) error

Jump to

Keyboard shortcuts

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