-
Notifications
You must be signed in to change notification settings - Fork 12
ref_struct_VDXFraction
VirtualDub Plugin SDK 1.2
VDXFraction structure
Declares a fraction of two 32-bit integers.
struct VDXFraction {
uint32 mNumerator;
uint32 mDenominator;
};
mNumerator
The numerator of the fraction. This normally may not be zero.
mDenominator
The denominator of the fraction. This normally may not be zero.
The value of the fraction is, as expected, equal to the numerator divided by the denominator. A fraction object is used instead of a floating-point number to exactly represent common frame rates, most notably NTSC's field rate of 60000/1001 = ~59.94 fields/sec.
A fraction need not be reduced to lowest terms, either on the host or
plugin side. 30/1 and 30000/1000 should always be treated exactly the
same. If you have a frame rate stored as a period in microseconds in
your plugin, feel free to return 1000000/period
as the fraction.
Unless specified otherwise in a structure or API, the denominator should never be zero, as that indicates a division by zero. A numerator of zero is less troublesome but should also not be used unless allowed; a frame rate of zero in a video stream is also nonsensical.
When a fraction must be multiplied or divided, one approach is to
attempt to multiply either the numerator or denominator as appropriate,
and if an overflow would occur, divide the other term instead as an
approximation. This should be done carefully, as the full range of
either term is possible — in particular, expect FFFFFFFF
to show up
occasionally in the numerator.
If you want to get fancy, you can use Euclid's algorithm to compute the greatest common denominator (GCD) for reducing fractions and continued fractions to determine the best possible approximation for fractions that don't reduce into 32/32 bits. This may be overkill for most cases, though. To convert a floating-point value to a fraction, simply break the floating-point representation into mantissa and exponent and reduce.
Copyright (C) 2007-2012 Avery Lee.
Setting up your development environment
Conventions
Plugin initialization
Dynamic loading
Reference counting
Using CPU extensions
Introduction
What's new
Breaking changes
Gotchas
Deprecated features
Migrating from the old Filter SDK
Programming model
Handling bitmaps
Creating a video filter
Setting filter parameters
Processing video frames
Managing filter data
Creating time-varying filters
Handling aspect ratio
Prefetching multiple source frames
Handling multiple sources
Making a filter configurable
Scripting support
CPU dependent optimization
VDXA index omitted
Getting started
Writing the module entry point
Creating a video filter
Adding configurability
Adding script support
Introduction
What's new
Autodetect
Direct mode
Video frames vs. samples
Video decodint model
Video decoder