Documentation ¶
Overview ¶
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 ¶
- Variables
- type Box
- type BoxType
- type DataInformationBox
- type DataReferenceBox
- type FileTypeBox
- type FullBox
- type HandlerBox
- type ImageRotation
- type ImageSpatialExtentsProperty
- type ItemInfoBox
- type ItemInfoEntry
- type ItemLocationBox
- type ItemLocationBoxEntry
- type ItemPropertiesBox
- type ItemProperty
- type ItemPropertyAssociation
- type ItemPropertyAssociationItem
- type ItemPropertyContainerBox
- type MetaBox
- type OffsetLength
- type PrimaryItemBox
- type Reader
Constants ¶
This section is empty.
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.
Functions ¶
This section is empty.
Types ¶
type Box ¶
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 DataInformationBox ¶
type DataInformationBox struct { Children []Box // contains filtered or unexported fields }
a "dinf" box
type DataReferenceBox ¶
a "dref" box.
type FileTypeBox ¶
type FullBox ¶
type HandlerBox ¶
type HandlerBox struct { FullBox HandlerType string // always 4 bytes; usually "pict" for iOS Camera images Name string }
a "hdlr" box.
type ImageRotation ¶
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.
type ImageSpatialExtentsProperty ¶
type ItemInfoBox ¶
type ItemInfoBox struct { FullBox Count uint16 ItemInfos []*ItemInfoEntry }
ItemInfoBox represents an "iinf" box.
type ItemInfoEntry ¶
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.
type ItemLocationBox ¶
type ItemLocationBox struct { FullBox ItemCount uint16 Items []ItemLocationBoxEntry // contains filtered or unexported fields }
box "iloc"
type ItemLocationBoxEntry ¶
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 ¶
type ItemPropertiesBox struct { PropertyContainer *ItemPropertyContainerBox Associations []*ItemPropertyAssociation // at least 1 // contains filtered or unexported fields }
HEIF: iprp
type ItemPropertyAssociation ¶
type ItemPropertyAssociation struct { FullBox EntryCount uint32 Entries []ItemPropertyAssociationItem }
type ItemPropertyAssociationItem ¶
type ItemPropertyAssociationItem struct { ItemID uint32 AssociationsCount int // as declared Associations []ItemProperty // as parsed }
not a box
type ItemPropertyContainerBox ¶
type ItemPropertyContainerBox struct { Properties []Box // of ItemProperty or ItemFullProperty // contains filtered or unexported fields }
HEIF: ipco
type OffsetLength ¶
type OffsetLength struct {
Offset, Length uint64
}
type PrimaryItemBox ¶
"pitm" box
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
func (*Reader) ReadAndParseBox ¶
ReadAndParseBox wraps the ReadBox method, ensuring that the read box is of type typ and parses successfully. It returns the parsed box.