Documentation
¶
Overview ¶
Package smk implements decoding of Smacker video files.
File format reference:
https://wiki.multimedia.cx/index.php?title=Smacker
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct {
// File header.
FileHeader
// contains filtered or unexported fields
}
A File is a container of Smacker video and audio tracks.
func Parse ¶
Parse returns a new File for accessing the video and audio tracks of r.
It reads and parses the Smacker file header, the frame size and type information, and the Huffman decoding tables, but skips all frame data.
type FileHeader ¶
type FileHeader struct {
// File signature; "SMK2" or "SMK4".
Signature string `struc:"[4]byte"`
// Frame width.
Width int `struc:"uint32,little"`
// Frame height.
Height int `struc:"uint32,little"`
// Number of frames. Excluding "ring" frames.
NFrames int `struc:"uint32,little"`
// Frame rate.
FrameRate FrameRate `struc:"int32,little"`
// Video flags.
Flags Flag
// Size of the largest unpacked audio data buffer in bytes; one per track.
AudioSize [7]int `struc:"[7]uint32,little"`
// Total size in bytes of Huffman trees stored in file.
TreesSize int `struc:"uint32,little"`
// Allocation size for the mono blocks maps Huffman tree.
MMapSize int `struc:"uint32,little"`
// Allocation size for the mono blocks colours Huffman tree.
MClrSize int `struc:"uint32,little"`
// Allocation size for the full blocks Huffman tree.
FullSize int `struc:"uint32,little"`
// Allocation size for the block type descriptors Huffman tree.
TypeSize int `struc:"uint32,little"`
// Frequency and format information for each sound track; one per track.
// TODO: Verify if little or big endian encoding.
TrackInfo [7]TrackInfo `struc:"[7]uint32,little"`
// Frame size in number of bytes. Bit 0 determines if the frame is a key
// frame. The purpose of bit 1 is unknown. Note, to get the proper length,
// clear bit 0 and 1.
FrameSizes []int `struc:"[]uint32,little,sizefrom=NFrames"`
// Frame types.
FrameTypes []FrameType `struc:"sizefrom=NFrames"`
// contains filtered or unexported fields
}
FileHeader is a general file description header.
type FrameRate ¶
type FrameRate int32
FrameRate specifies the number of frames per second.
The frame rate can be determined as follows:
if (FrameRate > 0) {
fps = 1000 / FrameRate
} else if (FrameRate < 0) {
fps = 100000 / (-FrameRate)
} else {
fps = 10
}
type FrameType ¶
type FrameType uint8
FrameType describes the contents of the corresponding frame.
The 8 bits have the following meaning when set:
7 - frame contains audio data corresponding to track 6 6 - frame contains audio data corresponding to track 5 5 - frame contains audio data corresponding to track 4 4 - frame contains audio data corresponding to track 3 3 - frame contains audio data corresponding to track 2 2 - frame contains audio data corresponding to track 1 1 - frame contains audio data corresponding to track 0 0 - frame contains a palette record
type TrackInfo ¶
type TrackInfo uint32
TrackInfo describes the frequency and format information of a sound track.
The 32 constituent bits have the following meaning:
bit 31 - data is compressed bit 30 - indicates that audio data is present for this track bit 29 - 1 = 16-bit audio; 0 = 8-bit audio bit 28 - 1 = stereo audio; 0 = mono audio bits 27-26 - if both set to zero - use v2 sound decompression bits 25-24 - unused bits 23-0 - audio sample rate
func (TrackInfo) HasAudioData ¶
HasAudioData reports whether the audio data of the track is present.
func (TrackInfo) IsCompressed ¶
IsCompressed reports whether the audio data of the track is compressed.
func (TrackInfo) IsVersion2 ¶
IsVersion2 reports whether the audio data of the track is stored using v2 sound compression.
func (TrackInfo) SampleRate ¶
SampleRate returns the audio sample rate of the track.