This article will be of interest primarily to those who for some reason prefer AVI and XVID, rather than MKV and H264. At the doom9 and ixbt forums, questions were raised about the use of different matrices, as well as the use of their own, but no one gave an intelligible answer, except for deepening the theory of discrete cosine transform. There is an article where good matrices are given, but their advantages and disadvantages are not explained there. So I will be glad if I find myself a pioneer. So, the task was as follows: to select the coefficients of the matrix in such a way as to remove the quadraticity when encoding with a constant quantizer> 2. At the same time, the file size should be smaller than with the same quantizer with the standard H263 matrix. In order not to torment you with a deepening in the nuances of the study, here is a photo of the resulting matrix, and below the explanation.
Red squares are the most important parts. They are responsible for macroblocks, which are almost entirely composed of the same color. Since most of these units are in the video stream, the file size and visual perception of quality depend on their packaging. Therefore, the task was reduced to the selection of such factors at which the ratio quality / size will be maximum. The remaining coefficients were set on the principle of "slightly more than the previous one", small details of the image were neglected. Especially important is the number 12 in the second square. With quantizer 4, if we increase this ratio, then there will be squares in the background, and a decrease will lead to a sharp increase in file size. ')
A little more about coding features. In order for this matrix to become effective, you need to keep some settings. First, it is necessarily a constant quantizer of 2, 3, or 4. Less than 2, there is no point, and more than 4, background distortions appear. No fractional quantizers! Photo 2.
Secondly, the additional quantizer settings that appear when you click on the upper “more” button.
Red outlined important settings. Quantizer ratio - the multiplier of the main quantizer specified earlier (photo 2), is mandatory 1. Quantizer offset - the quantizer increment for non-key frames is optimal 2. For quality maniacs, 0 is possible, for greater compression you can increase, but I do not advise. I also strongly recommend that you disable Adaptive quantization and Trellis quantization (lower “more” button).
For example, I took a small piece of the film with good quality, the resolution is 720x304, the original bitrate is 1300 (without audio). Encoding options and received bitrate: H263 matrix, quantizer 2 = bitrate 953 my matrix, quantizer 2 = 883 bitrate my matrix, quantizer 4 = bitrate 433
With quantizer 2, it is almost impossible to find differences in quality, while with quantizer 4 with my matrix, differences are visible in frame-by-frame viewing, and with quantizer 4 with matrix H263 - squares, squares.
Conclusion: the matrix is ​​usable at any resolutions, you can focus on quality or smaller size. Especially useful at low resolutions, since quadraticity is minimal, and at large ones with quantizer 4, it is enough to upload movies to the Internet. At low resolutions, you can slightly reduce the coefficients in the red square and it will be candy. And forget about two passes.
It is possible that someone is not satisfied that the details (all coefficients that are> 20) are too smoothed out in my matrix, but there are two reasons for this. First, it contributes to good compression and small size, and secondly, sharpness, in fact, is not lost forever. If the video is encoded with high quality, then during the viewing you can turn on the Sharpen sharpness filter. I prefer the msharpen from the K-Lite Codec Pack. There you can adjust the sharpness very smoothly and it works more correctly than others. In most cases, smoothed video with a sharpness filter produces a better impression than if you encode the sharpness into a video stream. This is due to the peculiarities of signal coding by quantization, which I will not discuss in detail.
Now about the useful filters VirtualDub'a smoother and temporal smoother, both built-in. The first is smoothed by the Gauss method, so the picture is more animated. If you use a value in the range of 1-5, then you can successfully smooth out quadraticity and noise at the borders of objects. Slows down coding by 10-20%. The second one does not actually smooth, but rather stabilizes the image, makes the current frame dependent on the previous one. The value sets the number of previous frames for the approximation. It is recommended 1 or 2. If you set> 4, then the wave of the hand will look like a fan. Indispensable for stabilizing the jerking background. Slows coding by 30-50%.
Finally, it remains to say only one thing: Le XVID Est Mort? Vive Le XVID! Encode on health.