go4.org: go4.org/media/heif/bmff Index | Files

package bmff

import "go4.org/media/heif/bmff"

Package bmff reads ISO BMFF boxes, as used by HEIF, etc.

This is not so much as a generic BMFF reader as it is a BMFF reader as needed by HEIF, though that may change in time. For now, only boxes necessary for the go4.org/media/heif package have explicit parsers.

This package makes no API compatibility promises; it exists primarily for use by the go4.org/media/heif package.

Index

Package Files

bmff.go

Variables

var (
    TypeFtyp = BoxType{'f', 't', 'y', 'p'}
    TypeMeta = BoxType{'m', 'e', 't', 'a'}
)

Common box types.

var ErrUnknownBox = errors.New("heif: unknown box")

ErrUnknownBox is returned by Box.Parse for unrecognized box types.

type Box Uses

type Box interface {
    Size() int64 // 0 means unknown (will read to end of file)
    Type() BoxType

    // Parses parses the box, populating the fields
    // in the returned concrete type.
    //
    // If Parse has already been called, Parse returns nil.
    // If the box type is unknown, the returned error is ErrUnknownBox
    // and it's guaranteed that no bytes have been read from the box.
    Parse() (Box, error)

    // Body returns the inner bytes of the box, ignoring the header.
    // The body may start with the 4 byte header of a "Full Box" if the
    // box's type derives from a full box. Most users will use Parse
    // instead.
    // Body will return a new reader at the beginning of the box if the
    // outer box has already been parsed.
    Body() io.Reader
}

Box represents a BMFF box.

type BoxType Uses

type BoxType [4]byte

func (BoxType) EqualString Uses

func (t BoxType) EqualString(s string) bool

func (BoxType) String Uses

func (t BoxType) String() string

type DataInformationBox Uses

type DataInformationBox struct {
    Children []Box
    // contains filtered or unexported fields
}

a "dinf" box

func (DataInformationBox) Body Uses

func (b DataInformationBox) Body() io.Reader

func (DataInformationBox) Parse Uses

func (b DataInformationBox) Parse() (Box, error)

func (DataInformationBox) Size Uses

func (b DataInformationBox) Size() int64

func (DataInformationBox) Type Uses

func (b DataInformationBox) Type() BoxType

type DataReferenceBox Uses

type DataReferenceBox struct {
    FullBox
    EntryCount uint32
    Children   []Box
}

a "dref" box.

func (DataReferenceBox) Body Uses

func (b DataReferenceBox) Body() io.Reader

func (DataReferenceBox) Parse Uses

func (b DataReferenceBox) Parse() (Box, error)

func (DataReferenceBox) Size Uses

func (b DataReferenceBox) Size() int64

func (DataReferenceBox) Type Uses

func (b DataReferenceBox) Type() BoxType

type FileTypeBox Uses

type FileTypeBox struct {
    MajorBrand   string   // 4 bytes
    MinorVersion string   // 4 bytes
    Compatible   []string // all 4 bytes
    // contains filtered or unexported fields
}

func (FileTypeBox) Body Uses

func (b FileTypeBox) Body() io.Reader

func (FileTypeBox) Parse Uses

func (b FileTypeBox) Parse() (Box, error)

func (FileTypeBox) Size Uses

func (b FileTypeBox) Size() int64

func (FileTypeBox) Type Uses

func (b FileTypeBox) Type() BoxType

type FullBox Uses

type FullBox struct {
    Version uint8
    Flags   uint32 // 24 bits
    // contains filtered or unexported fields
}

func (FullBox) Body Uses

func (b FullBox) Body() io.Reader

func (FullBox) Parse Uses

func (b FullBox) Parse() (Box, error)

func (FullBox) Size Uses

func (b FullBox) Size() int64

func (FullBox) Type Uses

func (b FullBox) Type() BoxType

type HandlerBox Uses

type HandlerBox struct {
    FullBox
    HandlerType string // always 4 bytes; usually "pict" for iOS Camera images
    Name        string
}

a "hdlr" box.

func (HandlerBox) Body Uses

func (b HandlerBox) Body() io.Reader

func (HandlerBox) Parse Uses

func (b HandlerBox) Parse() (Box, error)

func (HandlerBox) Size Uses

func (b HandlerBox) Size() int64

func (HandlerBox) Type Uses

func (b HandlerBox) Type() BoxType

type ImageRotation Uses

type ImageRotation struct {
    Angle uint8 // 1 means 90 degrees counter-clockwise, 2 means 180 counter-clockwise
    // contains filtered or unexported fields
}

ImageRotation is a HEIF "irot" rotation property.

func (ImageRotation) Body Uses

func (b ImageRotation) Body() io.Reader

func (ImageRotation) Parse Uses

func (b ImageRotation) Parse() (Box, error)

func (ImageRotation) Size Uses

func (b ImageRotation) Size() int64

func (ImageRotation) Type Uses

func (b ImageRotation) Type() BoxType

type ImageSpatialExtentsProperty Uses

type ImageSpatialExtentsProperty struct {
    FullBox
    ImageWidth  uint32
    ImageHeight uint32
}

func (ImageSpatialExtentsProperty) Body Uses

func (b ImageSpatialExtentsProperty) Body() io.Reader

func (ImageSpatialExtentsProperty) Parse Uses

func (b ImageSpatialExtentsProperty) Parse() (Box, error)

func (ImageSpatialExtentsProperty) Size Uses

func (b ImageSpatialExtentsProperty) Size() int64

func (ImageSpatialExtentsProperty) Type Uses

func (b ImageSpatialExtentsProperty) Type() BoxType

type ItemInfoBox Uses

type ItemInfoBox struct {
    FullBox
    Count     uint16
    ItemInfos []*ItemInfoEntry
}

ItemInfoBox represents an "iinf" box.

func (ItemInfoBox) Body Uses

func (b ItemInfoBox) Body() io.Reader

func (ItemInfoBox) Parse Uses

func (b ItemInfoBox) Parse() (Box, error)

func (ItemInfoBox) Size Uses

func (b ItemInfoBox) Size() int64

func (ItemInfoBox) Type Uses

func (b ItemInfoBox) Type() BoxType

type ItemInfoEntry Uses

type ItemInfoEntry struct {
    FullBox

    ItemID          uint16
    ProtectionIndex uint16
    ItemType        string // always 4 bytes

    Name string

    // If Type == "mime":
    ContentType     string
    ContentEncoding string

    // If Type == "uri ":
    ItemURIType string
}

ItemInfoEntry represents an "infe" box.

TODO: currently only parses Version 2 boxes.

func (ItemInfoEntry) Body Uses

func (b ItemInfoEntry) Body() io.Reader

func (ItemInfoEntry) Parse Uses

func (b ItemInfoEntry) Parse() (Box, error)

func (ItemInfoEntry) Size Uses

func (b ItemInfoEntry) Size() int64

func (ItemInfoEntry) Type Uses

func (b ItemInfoEntry) Type() BoxType

type ItemLocationBox Uses

type ItemLocationBox struct {
    FullBox

    ItemCount uint16
    Items     []ItemLocationBoxEntry
    // contains filtered or unexported fields
}

box "iloc"

func (ItemLocationBox) Body Uses

func (b ItemLocationBox) Body() io.Reader

func (ItemLocationBox) Parse Uses

func (b ItemLocationBox) Parse() (Box, error)

func (ItemLocationBox) Size Uses

func (b ItemLocationBox) Size() int64

func (ItemLocationBox) Type Uses

func (b ItemLocationBox) Type() BoxType

type ItemLocationBoxEntry Uses

type ItemLocationBoxEntry struct {
    ItemID             uint16
    ConstructionMethod uint8 // actually uint4
    DataReferenceIndex uint16
    BaseOffset         uint64 // uint32 or uint64, depending on encoding
    ExtentCount        uint16
    Extents            []OffsetLength
}

not a box

type ItemPropertiesBox Uses

type ItemPropertiesBox struct {
    PropertyContainer *ItemPropertyContainerBox
    Associations      []*ItemPropertyAssociation // at least 1
    // contains filtered or unexported fields
}

HEIF: iprp

func (ItemPropertiesBox) Body Uses

func (b ItemPropertiesBox) Body() io.Reader

func (ItemPropertiesBox) Parse Uses

func (b ItemPropertiesBox) Parse() (Box, error)

func (ItemPropertiesBox) Size Uses

func (b ItemPropertiesBox) Size() int64

func (ItemPropertiesBox) Type Uses

func (b ItemPropertiesBox) Type() BoxType

type ItemProperty Uses

type ItemProperty struct {
    Essential bool
    Index     uint16
}

not a box

type ItemPropertyAssociation Uses

type ItemPropertyAssociation struct {
    FullBox
    EntryCount uint32
    Entries    []ItemPropertyAssociationItem
}

func (ItemPropertyAssociation) Body Uses

func (b ItemPropertyAssociation) Body() io.Reader

func (ItemPropertyAssociation) Parse Uses

func (b ItemPropertyAssociation) Parse() (Box, error)

func (ItemPropertyAssociation) Size Uses

func (b ItemPropertyAssociation) Size() int64

func (ItemPropertyAssociation) Type Uses

func (b ItemPropertyAssociation) Type() BoxType

type ItemPropertyAssociationItem Uses

type ItemPropertyAssociationItem struct {
    ItemID            uint32
    AssociationsCount int            // as declared
    Associations      []ItemProperty // as parsed
}

not a box

type ItemPropertyContainerBox Uses

type ItemPropertyContainerBox struct {
    Properties []Box // of ItemProperty or ItemFullProperty
    // contains filtered or unexported fields
}

HEIF: ipco

func (ItemPropertyContainerBox) Body Uses

func (b ItemPropertyContainerBox) Body() io.Reader

func (ItemPropertyContainerBox) Parse Uses

func (b ItemPropertyContainerBox) Parse() (Box, error)

func (ItemPropertyContainerBox) Size Uses

func (b ItemPropertyContainerBox) Size() int64

func (ItemPropertyContainerBox) Type Uses

func (b ItemPropertyContainerBox) Type() BoxType

type MetaBox Uses

type MetaBox struct {
    FullBox
    Children []Box
}

func (MetaBox) Body Uses

func (b MetaBox) Body() io.Reader

func (MetaBox) Parse Uses

func (b MetaBox) Parse() (Box, error)

func (MetaBox) Size Uses

func (b MetaBox) Size() int64

func (MetaBox) Type Uses

func (b MetaBox) Type() BoxType

type OffsetLength Uses

type OffsetLength struct {
    Offset, Length uint64
}

type PrimaryItemBox Uses

type PrimaryItemBox struct {
    FullBox
    ItemID uint16
}

"pitm" box

func (PrimaryItemBox) Body Uses

func (b PrimaryItemBox) Body() io.Reader

func (PrimaryItemBox) Parse Uses

func (b PrimaryItemBox) Parse() (Box, error)

func (PrimaryItemBox) Size Uses

func (b PrimaryItemBox) Size() int64

func (PrimaryItemBox) Type Uses

func (b PrimaryItemBox) Type() BoxType

type Reader Uses

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

func NewReader Uses

func NewReader(r io.Reader) *Reader

func (*Reader) ReadAndParseBox Uses

func (r *Reader) ReadAndParseBox(typ BoxType) (Box, error)

ReadAndParseBox wraps the ReadBox method, ensuring that the read box is of type typ and parses successfully. It returns the parsed box.

func (*Reader) ReadBox Uses

func (r *Reader) ReadBox() (Box, error)

ReadBox reads the next box.

If the previously read box was not read to completion, ReadBox consumes the rest of its data.

At the end, the error is io.EOF.

Package bmff imports 8 packages (graph) and is imported by 4 packages. Updated 2018-11-17. Refresh now. Tools for package owners.