inputdrv_autodetect - shekh/VirtualDub2 GitHub Wiki

VirtualDub Plugin SDK 1.2

Autodetect

Every input driver exposes methods to support automatic format detection. This allows the host to automatically choose a viable input driver based on the data within a file and the filename. The most appropriate input driver is used to open the file.

Detection by signature

Each input driver has a signature associated with it that is used to perform signature matching against a file. This signature is described in the mpSignature and mSignatureLength fields of the input driver definition and consists of a pair of match/mask bytes. These pairs are applied starting at the beginning of the file. Each pair matches only if the bits in the file byte match those in the match byte, for all bits set in the mask byte. The highest priority signature that matches the file data wins.

The DetectBySignature() method is also used if the input driver definition has the CustomSignature bit set. This method receives the raw header and footer bytes as well as the file size and can do more complex matching. It can also flag a poor match, which wins only if there are no input drivers that find a solid match; this is useful for poorly detectable file formats. A downside to using a custom signature, though, is that it requires your input driver to be loaded in order to check the signature, which isn't required otherwise.

Detection by file name

For file formats that lack no distinctive signature or otherwise conflict with other file formats, a detection by filename is possible. The input driver definition can expose a pipe (|) delimited list of file name patterns to match against; a positive match makes the input driver eligible for handling the file.

A file name match is considered lower priority than a signature match.

Priority

Input drivers also have a priority associated with them. The default priority is zero; a higher priority gives an input driver a higher chance to claim a file than one with a lower priority. This is particularly important when writing an input driver that is meant to replace one of the host input drivers, such as VirtualDub's internal MPEG-1 driver. See the mPriority field of VDXInputDriverDefinition for more details.


Copyright (C) 2007-2012 Avery Lee.

⚠️ **GitHub.com Fallback** ⚠️