VirtualDub's internal resize filter has a very powerful and fast resampling engine, but its user interface is primitive. For example, there is no way to scale the picture by a percentage; you have to hand calculate and enter both the new width and new height. The Smart Resize filter duplicates the internal resize functionality while greatly enhancing the user interface. The basic idea is that a size calculator is added to the filter's dialog box. When enabled, the configuration calculated is exported back into the main filter parameters, which work the same as the internal filter's parameters. Smart Resize supports adjustment of the aspect ratio, several scaling and fitting modes, and "snapping" to required pixel multiples for the output height and/or width. Batch processing is supported so that if the processing parameters are saved with the size calculator enabled, the filter will dynamically calculate the main filter settings based on the parameters of the input clips encountered while processing the batch files. They need not be calculated manually in advance.
This help file will first describe the calculator "pipeline". You'll need to understand this to properly use the filter. Then the configuration options will be described. Finally some usage examples will be presented.
--> Aspect ratio adjust --> Fitting/scaling --> Snapping -->
When the calculator is enabled by checking the Enable checkbox, the output values from the pipeline are calculated and transferred to the main filter configuration and the preview (if any) is refreshed. Any changes to the calculator settings cause an automatic recalculation and update of the main filter parameters. Let us now consider the three stages of the pipeline.
Aspect ratio adjust This stage allows for conversion of the aspect ratio. For example, you might have a source clip from DV that is 720x480 and you want to convert it to a 4/3 aspect ratio for display on the PC monitor. This stage works as follows. The source aspect ratio is SW/SH. The desired aspect ratio is DW/DH. The Input width value is now scaled as follows:
Input width' = Input width * (DW * SH) / (DH * SW)
The Input height is not changed. For example, in the DV case described above the source aspect ratio is 720/480 and the desired aspect ratio is 4/3. The adjustment factor is thus 8/9 and these are the values loaded into the Aspect ratio adjust edit boxes. The result from this stage for our example, then, is a width of 640 and a height of 480, which has the desired aspect ratio. (If you prefer to simply view these boxes as permitting a horizontal scaling, and then use them that way, that is fine! But the formula above tells you how to determine the desired scaling to convert between aspect ratios.)
Fitting/Scaling This stage takes the values from the previous stage and scales them according to the selected mode. For example, if the Percent mode is selected and 50 entered, the width and height will both be reduced to 50% of their incoming values. Refer to the description of the configuration options for details on the available modes.
Snapping Often we require that the output width and/or height are exact multiples of some number of pixels. For example, many MPEG encoders require the width to be a multiple of 4 pixels. The snapping controls allow this to be done automatically. Note that if both the width and height are snapped, it might occur that to satisfy this, either the aspect ratio must be changed slightly, or the borders of the frame must be padded. The controls allow for selecting the desired treatment in these cases. Refer to the description of the configuration options for details on the available modes.
Aspect ratio adjust Using the edit boxes, enter the scaling fraction by which the width is to be scaled (the height is left as is). For example, use 4/2 to double the width.
Fit width When this mode is selected, the picture will be scaled (maintaining the aspect ratio) so that the width is made equal to the specified value.
Fit height When this mode is selected, the picture will be scaled (maintaining the aspect ratio) so that the height is made equal to the specified value.
Percent When this mode is selected, the picture will be scaled (maintaining the aspect ratio) by the specified percentage value.
No enlarge This mode applies only to the Fit width and Fit height modes. When this mode is selected in Fit width mode, the picture will not be enlarged if its width is already equal to or less than the specified fit width value. When this mode is selected in Fit height mode, the picture will not be enlarged if its height is already equal to or less than the specified fit height value.
No reduce This mode applies only to the Fit width and Fit height modes. When this mode is selected in Fit width mode, the picture will not be reduced if its width is already equal to or greater than the specified fit width value. When this mode is selected in Fit height mode, the picture will not be reduced if its height is already equal to or greater than the specified fit height value.
Fix width to mult of This mode will cause the output width to be snapped to a multiple of the specified number of pixels.
Fix height to mult of This mode will cause the output height to be snapped to a multiple of the specified number of pixels.
Up/Down/Nearest This mode determines how to change the dimension when a snap is done. Use Up to round up. Use Down to round down. Use Nearest to round to the nearest multiple. Note that when both the width and the height are snapped, and the padding mode is not set to Adjust AR, only the rounding up mode is available (because the resize engine can only pad; it cannot crop).
Pad width/Pad height/Adjust AR These modes are active only when both the width and the height are snapped. These modes determine what to do if the two snaps cannot both be honored without padding or changing the aspect ratio. Use the Adjust AR mode to allow the calculator to change the aspect ratio in order to avoid padding. Use the Pad width mode to allow the calculator to letterbox the picture by padding the two sides. Use the Pad height mode to allow the calculator to letterbox the picture by padding the top and bottom. If padding is applied, it will be reflected in the Frame width and Frame height boxes in the main filter parameters.
Example 2 Suppose the user wants to convert a DV clip at a 3/2 aspect ratio for viewing on the 4/3 monitor and ensure an output width of 320 pixels. The clip is loaded and the filter added. The Aspect ratio adjust is set to 8/9. The Fit to width mode is selected and its value set to 320.
For additional information, version updates, and other filters, please go to the following web site:
Filters for VirtualDub
http://www.geocities.com/Colosseum/Pressbox/8699/index.html
Donald Graft
February 2, 2001
(C) Copyright 2001, All Rights Reserved