Class AviReader

Namespace
CHDSharp.Encoder
Assembly
CHDSharpLib.dll

Minimal AVI container reader for laserdisc CHD creation (chdman's avi_file read path, src/lib/util/aviio.cpp). Parses RIFF/AVIX headers, stream descriptions ('strh'/ 'strf') and frame indexes ('idx1', or a sequential 'movi' scan when no index exists), and serves YUY-family video frames and PCM sound samples. Supported video: uncompressed YUY2/VYUY (bytes pass through unchanged) and UYVY (byte-swapped per pixel pair to YUY2 order), matching MAME's yuv_decompress_to_yuy16 output stored via put_u16be into the CHD video bitstream. On entry the encoder expects YUY2 byte order [Y0,Cb,Y1,Cr] per pixel pair so that Y occupies even byte offsets and Cb/Cr occupy the interleaved odd offsets. Supported audio: uncompressed PCM, 8 or 16 bits per sample.

public sealed class AviReader : IDisposable
Inheritance
AviReader
Implements
Inherited Members

Properties

Info

Gets the parsed movie information.

public AviReader.MovieInfo Info { get; }

Property Value

AviReader.MovieInfo

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Open(string)

Opens and parses an AVI file.

public static AviReader Open(string path)

Parameters

path string

Returns

AviReader

Exceptions

FileNotFoundException

The file does not exist.

InvalidDataException

The file is not a readable AVI movie.

ReadSoundSamples(int, uint, uint, Span<short>)

Reads PCM sound samples of one logical channel (MAME's avi_file::read_sound_samples). Channels are numbered across all audio streams.

public void ReadSoundSamples(int channel, uint firstSample, uint numSamples, Span<short> output)

Parameters

channel int

Logical channel index.

firstSample uint

First sample to read (per channel).

numSamples uint

Number of samples to read; clamped at the end of the stream.

output Span<short>

Destination array of numSamples entries.

Exceptions

ArgumentOutOfRangeException

The channel or first sample is out of range.

NotSupportedException

The audio format is not 8/16-bit PCM.

ReadVideoFrame(uint, Span<byte>)

Reads one video frame as YUY2-ordered bytes (Cb,Y,Cr,Y pixel pairs), the exact layout of the raw 'chav' video payload. For interlaced laserdisc sources the caller slices fields from the full-size frame.

public void ReadVideoFrame(uint frameNum, Span<byte> dest)

Parameters

frameNum uint

Zero-based frame number.

dest Span<byte>

Destination buffer of at least width * height * 2 bytes; short chunks leave the remainder untouched.

Exceptions

ArgumentOutOfRangeException

The frame number is out of range.

NotSupportedException

The video format is not YUY2/VYUY/UYVY.