VirtualDub Filter


DCT-Q-IDCT

(click on the link to directly jump the filter)


DCT-Q-IDCT

Discrete Cosinus Transform (DCT) based coding and decoding with display of statistical information

Description:

This filter performs the folowing steps: color subsampling, blockwise forward DCT, matrix based quantization, source coding, inverse-DCT (IDCT), color upsampling. There is done a compression and decompression as in intraframe MPEG2 (I-Frames).
I have written this filter for testing purpose. You can use different quantization matrices and immediately see the effects on your video. Also you can check if your other filters in the chain improves the compression-ratio for a fixed quality (quantizer stepsize). It creates a compatible MPEG2 video sequence consisting of a single I-frame which can be saved in a file. Also statistical data about the input video is collected and a histogram can be created. This histogram shoes the distribution for each coefficient of the dct-transformed macroblocks, of the frames, which have been displayed.

Settings:

The settings correspond to the variables/definitions in the international standard ISO/IEC 13818-2 (MPEG2).

In the "intra_quantiser_matrix" the quantizer stepsizes after the DCT are defined for each coefficient. For I-frames, the dc-coefficient in the upper left is fixed and cannot be changed in this way. For the dc-coeff. the variable "intra_dc_precision" is responsible (only for I-frames). The matrix entries are saved in the file "matrix.ini" in your virtualdub folder and are reloaded on every start. So you don't have to retype then every time when using this filter.

"quantizer scale" is used as a factor for all quantizer coefficients, but not the dc coefficient. A value of 16 is neutral - in this case, the quatizer stepsize is exactly as defined in the matrix. Lower values result in better quality and less compression and vice versa. Because in MPEG2 there is a mapping of a 5 bit variable in the bitstream called "quantizer_scale_code" to the value "quantizer_scale", not all values in the range between 1 and 112 are allowed, so the nearest possible value is taken.

"intra_dc_precision" specifies the quantization of the dc component (only for I-frames). Starting with a 8 bit source (for each YUV color component) the DCT is performed, usally ending with 11 bit values. After that a requantization to 8,9 or 10 bit is applied.

In "chroma format" the subsampling of the color is defined. 4:2:0 is half color resolution in both direction, horizontal and vertical. 4:2:2 is half color resolution in the horizontal direction. 4:4:4 is full color resolution. Interpolation is done with respect to the video type, progressive or interlaced.

The button "interlaced" specifies the way in which the DCT/IDCT operations and the color subsampling is performed. When enabled all operations are done on a field basis. In principle first the fields are seperated, then subsampled, DCT-transformed, quantized, IDCT-transformed and recombined to a frame. The color subsampling is done with respect to the different vertical and temporal position of pixel-samples.

With the option "display statistics" enabled, statistical information about the variance of the DCT-coefficients and the compression is displayed in the output window. Also the number of frames which have been analyzed for the dct-histogram are displayed.

When enabled "create m2v-file" every frame which is actually displayed, is written out to harddisk in your VirtualDub-folder and overwritten when viewing another frame. This file is a MPEG2 compatible videosequence consisting of one frame or two fields. Maybe some MPEG2 decoder run into problems viewing this single-frame-sequence.

The option "save dct-histogram on OK" writes out the histogram data of the luma-DCT-coefficients, which have been collected since the filter have been applied to some video segment. You can see the number of frames the histogram is based on, when enabling "display statistics". When moving the VirtualDub-slider after playing some sequence, the data is reset. I recommend playing some segment of your video by using the play button and then saving the histogram. The created histogram file consists of 64 lines, where one line consists of 256 space-separeted numbers. The first line corresponds to the dc-coefficient, the second line to the second coefficient (row 1, column 2), the third line to coefficient in row 1 / column 3 and so on. The number of occurence is normalized to 1000, that is, the sum of all values in one line should be 1000. Because of rounding the sum is sometimes not exactly 1000. By dividing the number by 10, you get the percentage of occurence for this DCT-value. Internally for the histogram we are performing the DCT-operation on 8 bit luma-pixel-frames which results in 11 bit (signed) DCT-coefficients, i.e. in the range between -1024..1023. Because one line in the histogram consists of 256 number only, we have cut this range to -128..127. That means, the first value of a line is the number of occurence (from 1000 events) that a DCT-coefficient is less than -128, the second value is the number of occurence for a DCT-coefficient to be -127 and so on. The first line (dc-coefficient) is a special case. Here we are considering 8 bit precision data and only positive values (unsigned). So, the values in this line correponds to the number of occurence of values in the range 0..256.

Download:

dct_q_idct_1_1.zip (v1.1)
dct_q_idct_1_0.zip (v1.0)

 

 

 

 



2d Comb

Removes line flickering. Intended to replace the standard PAL-averaging chroma comb filter

Description:

This filter is for removing color/luma fluctuations between adjacent rows. It was intended to be a better chroma comb filter, which in most capture cards is simply averaging the chroma signal of consecutive lines and so is reducing the vertical color resolution. This filter does the same job of removing color phase artefacts but with less reducing the vertical resolution. I find it to be useful also for removing luma fluctuations.

Settings:

The setting "horizontal averaging" lets you specify how many pixel are considered for the measuring of the phase offset between adjacent lines. It does not do smoothing on the pixels, it is only for determing the phase offset. Use higher values when stribes-artefacts are independent of the horizontal position, e.g. there is a constant luma fluctuation. A value of one means, fluctuations are measured between two pixels.

"threshold" is the maximal offset, which is corrected. For heavy disturbances you have to increase this value in order to compensate the fluctuations. If you only want to process color, set the Y-threshold to zero. You get the standard chroma comb (as in your TV or your capture device) with the following settings: YUV-processing on, Y/RGB: 1; 0, UV: 1; 512.

"YUV-processing" means, the source is first transformed to the YUV-colorspace, then filtering is applied and then it is back-converted to RGB-colorspace. The conversion is done in higher precision (12 bit per component), so for that there is no degradation.

In "testmode" you can display the differences which are normally subracted by this filter.

Enable "interlaced" when your source is interlaced. Then the filter operation is done on a field basis. I recommend to use this option enabled also when you have progressive captured video because most fluctuations are due to noise/interference in your capture card and the signal you are receiving is always delivered in fields. For that reason (and because there is no need for a frame buffer) the chroma-comb in your TV processes fields and not frames. But of course try which option is better for your video.

Download:

2d_comb_1_0a.zip (v1.0a)
2d_comb_1_0.zip (v1.0)

 

 

 

 

 



General Rowfilter

A gerneral third order digital filter. Processes only in the horizontal

Description:

This filter is a general third order digital filter which processes only the rows and is apllied two times, from left to right and back.

Settings:

The values you can modify are the digital filter coefficients. For example, the following settings are used for a butterworth lowpass filter with the cut-off frequency 0.5 (1.0 corresponding to half the sample rate):
(a2,a3,a4) = (0, 0.3333, 0) and (b1,b2,b3,b4) = (0.1667,0.5000,0.5000,0.1667).

 

 

 

Download:

general_rowfilter_1_0a.zip (v1.0a)
general_rowfilter_1_0.zip (v1.0)

 

 

 

Virtualdub-Sync


VirtualDub Filter


Cedocida DV Codec