Skip to main content

VQAHeader

Struct VQAHeader 

Source
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: VQAVersion

The format version (Version).

§flags: u16

Flag 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: u16

The number of frames (Frames).

§width: u16

The movie’s width in pixels (ImageWidth).

§height: u16

The movie’s height in pixels (ImageHeight).

§block_width: u8

The width of each image block in pixels (BlockWidth).

§block_height: u8

The height of each image block in pixels (BlockHeight).

§frame_rate: u8

Frames per second (FPS).

§cbparts: u8

Frames 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: u16

The number of colors solid-color blocks use (Num1Colors); 0 in HiColor movies (see is_hicolor).

§maxblocks: u16

The number of codebook entries (CBentries), the most a codebook holds; the decoder takes 0 to mean 0xff00.

§x_pos: u16

Where 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: u16

Where to draw the frames (Ypos): the top edge, or 0xffff to center them; see x_pos.

§max_frame_size: u16

The 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: u16

The sound sampling rate in Hz (SampleRate); see sample_rate.

§channels: u8

The number of sound channels (Channels); see num_channels.

§bits: u8

The sound resolution in bits (BitsPerSample); see bit_depth.

§alt_freq: u16

The 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: u8

The alternate soundtrack’s channels (AltChannels).

§alt_bits: u8

The 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

Source

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.

Source

pub fn sample_rate(&self) -> u32

The sound sampling rate in Hz, applying the documented v1 fallback (a stored 0 means 22050 Hz).

Source

pub fn num_channels(&self) -> u8

The number of sound channels (a stored 0 means mono).

Source

pub fn bit_depth(&self) -> u8

The sound resolution in bits (a stored 0 means 8-bit).

Source

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.

Source

pub fn has_sound(&self) -> bool

Whether the movie carries a soundtrack (bit 0 of flags).

Source

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.

Trait Implementations§

Source§

impl Clone for VQAHeader

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for VQAHeader

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for VQAHeader

Source§

impl PartialEq for VQAHeader

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for VQAHeader

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.