pub struct VQAHeader {Show 21 fields
pub version: VQAVersion,
pub flags: u16,
pub num_frames: u16,
pub width: u16,
pub height: u16,
pub block_width: u8,
pub block_height: u8,
pub frame_rate: u8,
pub cbparts: u8,
pub colors: u16,
pub maxblocks: u16,
pub x_pos: u16,
pub y_pos: u16,
pub max_frame_size: u16,
pub freq: u16,
pub channels: u8,
pub bits: u8,
pub alt_freq: u16,
pub alt_channels: u8,
pub alt_bits: u8,
pub future_use: [u16; 5],
}Expand description
The fixed 42-byte VQHD header describing the whole movie.
The fields follow Westwood’s own VQAHeader (VQAFILE.H in the VQA
library in EA’s GPL release of the Red Alert source), named in
parentheses below, and hold the values as stored. v1 movies leave
several sound fields zeroed; the sample_rate, num_channels, and
bit_depth helpers apply the documented fallbacks, so prefer them over
reading freq, channels, and bits directly.
Fields§
§version: VQAVersionThe format version (Version).
flags: u16Flag bits (Flags). Bit 0 marks a soundtrack (see has_sound),
and bit 1 an alternate one, which no movie seen so far has. The
HiColor movies seen so far also set some of bits 2-4 (Blade Runner’s
bits 2 and 4, the others all three), whose meaning is unknown.
num_frames: u16The number of frames (Frames).
width: u16The movie’s width in pixels (ImageWidth).
height: u16The movie’s height in pixels (ImageHeight).
block_width: u8The width of each image block in pixels (BlockWidth).
block_height: u8The height of each image block in pixels (BlockHeight).
frame_rate: u8Frames per second (FPS).
cbparts: u8Frames per codebook (Groupsize): how many frames each bring a part
of the next codebook. 0 in movies whose codebooks come whole, and in
those whose CINF chunk schedules them
(VQA::codebook_starts).
colors: u16The number of colors solid-color blocks use (Num1Colors); 0 in
HiColor movies (see is_hicolor).
maxblocks: u16The number of codebook entries (CBentries), the most a codebook
holds; the decoder takes 0 to mean 0xff00.
x_pos: u16Where to draw the frames (Xpos): the left edge, or 0xffff
(Westwood’s -1) to center them. 0 in every movie seen so far except
Blade Runner’s overlays, which the game places by it.
y_pos: u16Where to draw the frames (Ypos): the top edge, or 0xffff to center
them; see x_pos.
max_frame_size: u16The size of the largest frame, in Westwood’s naming (MaxFramesize).
What encoders store varies: v2 HiColor movies (Dune 2000, Blade
Runner) store their largest VPRZ chunk’s size, while 8-bit and v3
movies store values smaller than their frame chunks, whose meaning is
unknown.
freq: u16The sound sampling rate in Hz (SampleRate); see
sample_rate.
channels: u8The number of sound channels (Channels); see
num_channels.
bits: u8The sound resolution in bits (BitsPerSample); see
bit_depth.
alt_freq: u16The alternate soundtrack’s sampling rate in Hz (AltSampleRate).
Westwood’s player could switch to an alternate soundtrack, carried
in SNA? chunks, which this crate doesn’t decode; the alternate
fields are 0 in every movie seen so far.
alt_channels: u8The alternate soundtrack’s channels (AltChannels).
alt_bits: u8The alternate soundtrack’s sound resolution in bits
(AltBitsPerSample).
future_use: [u16; 5]Five words Westwood reserved (FutureUse). Later encoders use some
of them: HiColor movies store 4 in the first, and HiColor, Lands of
Lore and some Red Alert movies store their largest compressed
codebook’s size in the next two
(max_cbfz_size).
Implementations§
Source§impl VQAHeader
impl VQAHeader
Sourcepub fn parse(vqhd: &[u8]) -> Result<VQAHeader, Error>
pub fn parse(vqhd: &[u8]) -> Result<VQAHeader, Error>
Parse the payload of a VQHD chunk, all of whose fields are
little-endian.
§Errors
ErrorKind::InvalidHeader, with no location, unless vqhd is
exactly 42 bytes long and holds version 1, 2 or 3.
Sourcepub fn sample_rate(&self) -> u32
pub fn sample_rate(&self) -> u32
The sound sampling rate in Hz, applying the documented v1 fallback (a stored 0 means 22050 Hz).
Sourcepub fn num_channels(&self) -> u8
pub fn num_channels(&self) -> u8
The number of sound channels (a stored 0 means mono).
Sourcepub fn max_cbfz_size(&self) -> u32
pub fn max_cbfz_size(&self) -> u32
The size of the movie’s largest compressed codebook, a CBFZ chunk or
CBPZ parts joined, where the encoder stored it: in the second and
third future_use words, low word first.
HiColor, Lands of Lore and some Red Alert movies store it; the other
movies seen so far store 0.
Sourcepub fn is_hicolor(&self) -> bool
pub fn is_hicolor(&self) -> bool
Whether the movie is HiColor (15-bit pixels) rather than 8-bit
palettized. HiColor movies store 0 in the colors field.