-
Notifications
You must be signed in to change notification settings - Fork 19
vdxa_borderhandling
VirtualDub Plugin SDK 1.2
Border handling
Video processing algorithms frequently require accessing data in a neighborhood around the desired pixel position. This results in the need for border handling whenever the neighborhood goes outside of the bounds of the source image. VDXA specifies border handling and provides assistance to avoid having to code special cases around the edges of images.
By default, image borders are defined to clamp in VDXA. This means that any fetch outside of a source image returns the nearest pixel along the edge instead. As a result, all edges are effectively extended out infinitely, forming ribbons of color.
One other border mode is supported, wrap. This causes an image to repeat in both directions as if it were tiled indefinitely. This is only supported for filter-created textures, however, not video frame textures, and it can only be used when the texture width and height are both powers of two.
VDXA attempts to use hardware support in order to achieve clamping, but there are cases where an image must be stored within a subrect of a larger surface or texture. In this case overrendering is used to supply the clamping, by extending out the borders of the rendered image during rendering:

Because this requires additional rendering power, only the required
amount of border is generated. In order to take advantage of this, a
filter must specify the amount of border it requires on each source by
setting the mBorderWidth and mBorderHeight fields of the source
bitmap structure. A value of 4 means that the upstream filter will
render out four additional pixels beyond the edge of the image in either
horizontal or vertical direction.
For the most part, a video filter does not have to handle border extension because render targets are tagged with their border requirements and DrawQuad() automatically extends any primitive to supply the border. This is done by tesselating the quad geometry so that interpolator values clamp at the border, resulting in the rendered pixels matching the nearest edge. Border values can be specified when render targets are created in order to take advantage of this for intermediate buffers as well.
Note that bilinear filtering can read source pixels up to one-half pixel away from the sampling point, and thus the requested border should be extended by one pixel. This extension is automatically done for you, so you do not have to adjust the border width to account for bilinear filtering.
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