Class VbiParse

Namespace
CHDSharp.Encoder
Assembly
CHDSharpLib.dll

Port of MAME's vbiparse (src/lib/util/vbiparse.cpp): parses Philips codes and the "white flag" from laserdisc VBI lines, and packs the per-frame results into the 16-byte form stored in 'AVLD' metadata. Input is a YUY2 frame in serialized byte order; each 16-bit pixel is read little-endian and shifted right by sourceShift (= 8 selects the luma byte), exactly like MAME reading its native bitmap.

public static class VbiParse
Inheritance
VbiParse
Inherited Members

Fields

PackedBytes

Size of one packed VBI record (VBI_PACKED_BYTES).

public const int PackedBytes = 16

Field Value

int

Methods

MetadataPack(Span<byte>, uint, VbiMetadata)

Packs the VBI data down into the 16-byte storage form (MAME's vbi_metadata_pack): u24be frame number, white flag, then four u24be codes.

public static void MetadataPack(Span<byte> dest, uint frameNum, VbiMetadata vbi)

Parameters

dest Span<byte>
frameNum uint
vbi VbiMetadata

ParseAll(byte[], int, int, int)

Parses everything from a video frame (MAME's vbi_parse_all): the white flag from line 11 and Manchester codes from lines 16/17/18, then reconciles lines 17/18.

public static VbiMetadata ParseAll(byte[] source, int sourceRowPixels, int sourceWidth, int sourceShift)

Parameters

source byte[]

Frame bytes (YUY2 order).

sourceRowPixels int

Row stride in pixels.

sourceWidth int

Visible width in pixels.

sourceShift int

Right-shift selecting the sample byte within each 16-bit pixel.

Returns

VbiMetadata

ParseManchesterCode(byte[], int, int, int, int, uint[])

Parses a Manchester code from a line of video data (MAME's vbi_parse_manchester_code). Returns the number of bits extracted (0 on failure); each result entry holds (confidence << 1) | bit.

public static int ParseManchesterCode(byte[] source, int sourceOffsetBytes, int sourceWidth, int sourceShift, int expectedBits, uint[] result)

Parameters

source byte[]
sourceOffsetBytes int
sourceWidth int
sourceShift int
expectedBits int
result uint[]

Returns

int

ParseWhiteFlag(byte[], int, int, int)

Computes the "white flag" from a line of video data (MAME's vbi_parse_white_flag): true when the histogram peak sits above 90% of the noise-trimmed dynamic range.

public static bool ParseWhiteFlag(byte[] source, int sourceOffsetBytes, int sourceWidth, int sourceShift)

Parameters

source byte[]
sourceOffsetBytes int
sourceWidth int
sourceShift int

Returns

bool