format

package
v1.10.1 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DataTypeEndOfMedia marks the last entry.
	DataTypeEndOfMedia = DataType(0)
	// DataTypeLowResVideo for low resolution (low compression) video.
	DataTypeLowResVideo = DataType(0x21)
	// DataTypeHighResVideo for high resolution (high compression) video.
	DataTypeHighResVideo = DataType(0x79)
	// DataTypeAudio marks an audio entry.
	DataTypeAudio = DataType(2)
	// DataTypeSubtitle control for subtitle entries.
	DataTypeSubtitle = DataType(3)
	// DataTypePalette describes a color palette.
	DataTypePalette = DataType(4)
	// DataTypePaletteReset is a zero-byte entry immediately before a Palette entry.
	DataTypePaletteReset = DataType(0x4C)
	// DataTypePaletteLookupList for high compression video.
	DataTypePaletteLookupList = DataType(5)
	// DataTypeControlDictionary for high compression video.
	DataTypeControlDictionary = DataType(0x0D)
)
View Source
const (
	EntryBucketPriorityAudio           = 0
	EntryBucketPriorityVideoControl    = 1
	EntryBucketPrioritySubtitleControl = 2
	EntryBucketPrioritySubtitle        = 3
	EntryBucketPriorityFrame           = 4
)

List of entry bucket priorities.

View Source
const (
	SubtitleArea    = SubtitleControl(0x41455241)
	SubtitleTextStd = SubtitleControl(0x20445453)
	SubtitleTextFrn = SubtitleControl(0x204E5246)
	SubtitleTextGer = SubtitleControl(0x20524547)
)

Subtitle constants are based on four-letter ASCII sequences.

View Source
const HeaderSize = 256

HeaderSize specifies the length of a serialized Header in bytes.

View Source
const IndexTableEntrySize = 8

IndexTableEntrySize specifies how many bytes a serialized IndexTableEntry uses.

View Source
const SubtitleDefaultTextOffset = 16

SubtitleDefaultTextOffset is the typical offset, in bytes, to text content.

View Source
const Tag string = "MOVI"

Tag is the identifier key of a MOVI container.

Variables

This section is empty.

Functions

func IndexTableSizeFor added in v1.8.0

func IndexTableSizeFor(entryCount int) int

IndexTableSizeFor returns the number of bytes reserved for given amount of table entries.

Types

type AudioEntryData

type AudioEntryData struct {
	Samples []byte
}

AudioEntryData is an entry with audio samples.

func AudioEntryFrom

func AudioEntryFrom(r io.Reader, dataSize int) (AudioEntryData, error)

AudioEntryFrom decodes an entry from given data.

func (AudioEntryData) Bytes

func (data AudioEntryData) Bytes() []byte

Bytes returns the raw bytes of the entry.

func (AudioEntryData) Type

func (data AudioEntryData) Type() DataType

Type describes the entry.

type ControlDictionaryEntryData

type ControlDictionaryEntryData struct {
	Words []compression.ControlWord
}

ControlDictionaryEntryData contains control words for compression.

func ControlDictionaryEntryFrom

func ControlDictionaryEntryFrom(r io.Reader, dataSize int) (ControlDictionaryEntryData, error)

ControlDictionaryEntryFrom decodes an entry from given data.

func (ControlDictionaryEntryData) Bytes

func (data ControlDictionaryEntryData) Bytes() []byte

Bytes serializes the entry.

func (ControlDictionaryEntryData) Type

Type describes the entry.

type DataType

type DataType byte

DataType classifies entries.

type Entry

type Entry struct {
	// Timestamp marks the beginning time of the entry.
	Timestamp Timestamp
	// Data is a type specific information of a movie.
	Data EntryData
}

Entry describes a timestamped block from a MOVI container.

type EntryBucket

type EntryBucket struct {
	// Priority helps in merging content from multiple buckets.
	Priority EntryBucketPriority
	// Timestamp specifies at which time the bucket should be inserted into the stream.
	// This is typically derived from one of the timestamps of the contained entries.
	Timestamp Timestamp
	// Entries is the list of entries within this bucket.
	Entries []Entry
}

EntryBucket is a set of entries that need to be together within the stream. This exists mainly to cover special cases of entries within a stream that have no valid timestamp.

type EntryBucketPriority

type EntryBucketPriority int

EntryBucketPriority describes the general priority of the bucket. Lower numbers are put before higher numbers if the bucket has the same timestamp.

type EntryData

type EntryData interface {
	// Type describes the content type of the data.
	Type() DataType
	// Bytes returns the raw bytes of the entry.
	Bytes() []byte
}

EntryData describes one entry in a MOVI container.

type Fix

type Fix struct {
	Fraction uint16
	Number   int16
}

Fix represents a fixed-point number, with 16 bits of fraction and 15 bits of integer number.

func FixFromFloat

func FixFromFloat(value float32) Fix

FixFromFloat returns a fixed-point number from given floating-point number.

func (Fix) ToFloat

func (f Fix) ToFloat() float32

ToFloat returns the equivalent floating-point number.

type Header struct {
	// Tag is the identifier key of a MOVI container
	Tag [4]byte
	// IndexEntryCount specifies how many index entries are in the index.
	IndexEntryCount int32
	// IndexSize specifies how long the index is.
	IndexSize int32
	// ContentSize specifies the length of the content.
	ContentSize int32
	// Duration is the length of the media in seconds.
	Duration Fix

	// VideoFrameRate gives a hint on number of frames per second.
	VideoFrameRate Fix
	// VideoWidth specifies the width of the video.
	VideoWidth uint16
	// VideoHeight specifies the height of the video.
	VideoHeight uint16
	// VideoBitsPerPixel specifies bit count for color information: 8, 15, 24.
	VideoBitsPerPixel int16
	// VideoPalettePresent specifies whether a palette is set.
	VideoPalettePresent int16

	// AudioChannelCount specifies whether there is audio, and how many channels to use. 0 = no audio, 1 = mono, 2 = stereo.
	AudioChannelCount int16
	// AudioBytesPerSample specifies how many bytes one audio sample has. 1 = 8-bit, 2 = 16-bit.
	AudioBytesPerSample int16
	// AudioSampleRate specifies the sample rate of the audio.
	AudioSampleRate Fix
	// contains filtered or unexported fields
}

Header is the first entry of a MOVI container.

func (*Header) String

func (header *Header) String() (result string)

type HighResVideoEntryData

type HighResVideoEntryData struct {
	Bitstream  []byte
	Maskstream []byte
}

HighResVideoEntryData is a compressed high-resolution video frame.

func HighResVideoEntryFrom

func HighResVideoEntryFrom(r io.Reader, dataSize int) (HighResVideoEntryData, error)

HighResVideoEntryFrom decodes an entry from given data.

func (HighResVideoEntryData) Bytes

func (data HighResVideoEntryData) Bytes() []byte

Bytes returns the raw bytes of the entry.

func (HighResVideoEntryData) Type

func (data HighResVideoEntryData) Type() DataType

Type describes the entry.

type IndexTableEntry

type IndexTableEntry struct {
	TimestampFraction uint16
	TimestampSecond   byte
	Type              byte
	DataOffset        int32
}

IndexTableEntry describes one data entry of a MOVI container.

type LowResVideoEntryData

type LowResVideoEntryData struct {
	BoundingBox [4]uint16
	Packed      []byte
}

LowResVideoEntryData is a compressed low-resolution video frame.

func LowResVideoEntryFrom

func LowResVideoEntryFrom(r io.Reader, dataSize int) (LowResVideoEntryData, error)

LowResVideoEntryFrom decodes an entry from given data.

func (LowResVideoEntryData) Bytes

func (data LowResVideoEntryData) Bytes() []byte

Bytes returns the raw bytes of the entry.

func (LowResVideoEntryData) Type

func (data LowResVideoEntryData) Type() DataType

Type describes the entry.

type PaletteEntryData

type PaletteEntryData struct {
	Colors bitmap.Palette
}

PaletteEntryData is an entry with a palette.

func PaletteEntryFrom

func PaletteEntryFrom(r io.Reader) (PaletteEntryData, error)

PaletteEntryFrom decodes an entry from given data.

func (PaletteEntryData) Bytes

func (data PaletteEntryData) Bytes() []byte

Bytes returns the raw bytes of the entry.

func (PaletteEntryData) Type

func (data PaletteEntryData) Type() DataType

Type describes the entry.

type PaletteLookupEntryData

type PaletteLookupEntryData struct {
	List []byte
}

PaletteLookupEntryData contains a list of palette indices.

func PaletteLookupEntryFrom

func PaletteLookupEntryFrom(r io.Reader, dataSize int) (PaletteLookupEntryData, error)

PaletteLookupEntryFrom decodes an entry from given data.

func (PaletteLookupEntryData) Bytes

func (data PaletteLookupEntryData) Bytes() []byte

Bytes serializes the entry.

func (PaletteLookupEntryData) Type

func (data PaletteLookupEntryData) Type() DataType

Type describes the entry.

type PaletteResetEntryData

type PaletteResetEntryData struct {
}

PaletteResetEntryData marks a reset of the palette.

func PaletteResetEntryFrom

func PaletteResetEntryFrom() (PaletteResetEntryData, error)

PaletteResetEntryFrom decodes an entry from given data.

func (PaletteResetEntryData) Bytes

func (data PaletteResetEntryData) Bytes() []byte

Bytes serializes the entry.

func (PaletteResetEntryData) Type

func (data PaletteResetEntryData) Type() DataType

Type describes the entry.

type SubtitleControl

type SubtitleControl uint32

SubtitleControl specifies how to interpret a subtitle entry.

func SubtitleControlForLanguage

func SubtitleControlForLanguage(lang resource.Language) SubtitleControl

SubtitleControlForLanguage returns the corresponding subtitle control for given language.

func (SubtitleControl) String

func (ctrl SubtitleControl) String() string

String returns the string presentation of the control value.

type SubtitleEntryData

type SubtitleEntryData struct {
	Control SubtitleControl
	Text    []byte
}

SubtitleEntryData is an entry with Subtitle samples.

func SubtitleEntryFrom

func SubtitleEntryFrom(r io.Reader, dataSize int) (SubtitleEntryData, error)

SubtitleEntryFrom decodes an entry from given data.

func (SubtitleEntryData) Bytes

func (data SubtitleEntryData) Bytes() []byte

Bytes returns the raw bytes of the entry.

func (SubtitleEntryData) Type

func (data SubtitleEntryData) Type() DataType

Type describes the entry.

type SubtitleHeader

type SubtitleHeader struct {
	// Control specifies how to interpret the string content
	Control SubtitleControl
	// TextOffset specifies the offset, in bytes from beginning of entry data, where the text starts.
	TextOffset uint32
}

SubtitleHeader is the header structure of a subtitle data.

type Timestamp

type Timestamp struct {
	Second   uint8
	Fraction uint16
}

Timestamp represents a point in time using fixed resolution.

func TimestampFromDuration

func TimestampFromDuration(d time.Duration) Timestamp

TimestampFromDuration creates a timestamp instance from given duration value.

func TimestampFromSeconds

func TimestampFromSeconds(value float32) Timestamp

TimestampFromSeconds creates a timestamp instance from given floating point value.

func TimestampLimit

func TimestampLimit() Timestamp

TimestampLimit returns the highest possible timestamp value.

func (Timestamp) IsAfter

func (ts Timestamp) IsAfter(other Timestamp) bool

IsAfter returns true if this timestamp is later than the given one.

func (Timestamp) IsBefore

func (ts Timestamp) IsBefore(other Timestamp) bool

IsBefore returns true if this timestamp is before the given one.

func (Timestamp) Minus

func (ts Timestamp) Minus(other Timestamp) Timestamp

Minus returns a timestamp with given one removed from the current one. The result is clipped to 0 if subtraction would result in a negative number.

func (Timestamp) Plus

func (ts Timestamp) Plus(other Timestamp) Timestamp

Plus returns a timestamp with the given one added to the current one. The result is saturated if the addition is larger than the timestamp can hold.

func (Timestamp) ToDuration

func (ts Timestamp) ToDuration() time.Duration

ToDuration returns the equivalent duration for this timestamp.

type UnknownEntryData

type UnknownEntryData struct {
	DataType DataType
	Raw      []byte
}

UnknownEntryData is an entry that is not know to this codebase.

func UnknownEntryFrom

func UnknownEntryFrom(dataType DataType, r io.Reader, dataSize int) (UnknownEntryData, error)

UnknownEntryFrom decodes an entry from given data.

func (UnknownEntryData) Bytes

func (data UnknownEntryData) Bytes() []byte

Bytes returns the raw bytes of the entry.

func (UnknownEntryData) Type

func (data UnknownEntryData) Type() DataType

Type describes the entry.

Jump to

Keyboard shortcuts

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