FFMPEG Sws_scale Algorithm Performance test

Source: Internet
Author: User
Tags relative

The Sws_scale in FFmpeg is often used for image scaling and format conversion, and the function can use a variety of different algorithms to process the image. Used to be lazy, lazy to test and identify which algorithm should be used, the most recent work time, many times need to wait for others. Sneak in, the ffmpeg of this set of functions were encapsulated, by the way, testing a variety of algorithms.

Briefly speaking about the test environment, I am using the Dell brand machine, i5 CPU. FFmpeg was compiled from the latest version around August 2010, and I used its static library version.

The Sws_scale algorithm has the following options.[CPP]  View plain copy #define  SWS_FAST_BILINEAR     1   #define  sws_ bilinear          2   #define  sws_bicubic            4   #define  SWS_X                  8   #define  SWS_POINT          0x10   #define  sws_ area           0x20   #define  sws_ bicublin       0x40   #define  SWS_GAUSS           0x80   #define  SWS_SINC           0x100   #define  SWS_LANCZOS        0x200 &nbsP #define  SWS_SPLINE        0x400  

First, a 1920*1080 landscape image is scaled to the 400*300 24-bit RGB, and the following frame rate refers to the number of times per second scaled and rendered. (After my tests, the rendering time is negligible, and the main time is spent on the scaling algorithm.) )

algorithm

Frame rate

subjective perception of images

Sws_fast_bilinear

228

The image has no obvious distortion and feels very good.

Sws_bilinear

95

It feels good, smoother than the edge of the previous algorithm.

Sws_bicubic

80

Feel the same, more than the algorithm edge to smooth, than the previous algorithm to be sharp.

Sws_x

91

With the previous image, I don't see the difference.

Sws_point

427

The details are sharper and the image effect is slightly less than the above figure.

Sws_area

116

I don't see the difference with the algorithm.

Sws_bicublin

87

Ditto.

Sws_gauss

80

In relation to the previous algorithm, some of the smoothing (or blurring) is possible.

Sws_sinc

30

The details should be clearer relative to the previous algorithm.

Sws_lanczos

70

For the previous algorithm, to be smooth (or fuzzy) a little bit, almost no difference.

Sws_spline

47

And the previous algorithm, I do not see the difference.


Overall, the above various algorithms, the image after the effect seems to be good. If you are not looking at the contrast, you can hardly see the effect of scaling. The above-mentioned clarity (sharpness) and smoothing (blurring), is an objective feeling, not clear is better than smooth, and not smooth than clear good. The point algorithm, the efficiency of high, let me shock, but the effect is not bad. In addition, I compared the use of CImage drawing when the zoom, its frame rate can be 190, but the effect is terrible, color serious distortion.


The second experiment, the image of a 1024x768 landscape, zoom to 1920*1080, and rendering (at this time, although not negligible, but not more than 5ms rendering time, does not affect the relative accuracy of the following conclusions).

algorithm

Frame rate

subjective perception of images

Sws_fast_bilinear

103

The image has no obvious distortion and feels very good.

Sws_bilinear

100

There is no difference from the above figure.

Sws_bicubic

78

Relative to the picture, feel the details a little bit clearer.

Sws_x

106

No difference from the picture above.

Sws_point

112

The edges are visibly jagged.

Sws_area

114

The edges have no obvious sawtooth.

Sws_bicublin

95

There is almost no difference from the above picture.

Sws_gauss

86

A little clearer than the edge of the above picture.

Sws_sinc

20

No difference from the picture above.

Sws_lanczos

64

No difference from the above figure.

Sws_spline

40

No difference from the above figure.


Overall, the point algorithm has obvious sawtooth, area algorithm sawtooth is not obvious, the rest of the algorithm, the naked eye does not appear to be significantly different. In addition, when rendering with CImage, the frame rate can be scaled up to 105, and the effect is similar to point.

Personal advice, if the image of the scaling, to pursue efficient, for example, video image processing, in the unclear is to zoom in or zoom out, directly using the sws_fast_bilinear algorithm can be. If you explicitly want to zoom out and display, it is recommended to use the point algorithm, if it is clear to zoom in and display, in fact, the use of CImage strech more efficient.


Of course, if the speed of the pursuit of picture quality. In the above algorithm, the selection of the lowest frame rate, the screen effect is generally the best.


But overall, the ffmpeg scale algorithm, the speed is very fast, after all, I choose the material is high-definition pictures.


(I would like to upload a picture, but the different groups of pictures are actually very small, I am afraid that when the upload format conversion caused by the loss of image details, has exceeded the details of each picture itself, so here do not upload pictures.) )

Note: Test the resize efficiency of the OPENCV, and the same situation above, OPENCV in the above amplification test, can be carried out 52 times per second, reduce the test, can be carried out 458 times per second.


Original address: http://www.cnblogs.com/acloud/archive/2011/10/29/sws_scale.html


FFmpeg Command Example (Bilinear,bicubic,neighbor) using a different Sws_scale () scaling algorithm:

[Plain]   View plain copy ffmpeg -s 480x272 -pix_fmt yuv420p -i  src01_480x272.yuv -s 1280x720 -sws_flags bilinear -pix_fmt yuv420p  src01_bilinear_1280x720.yuv   ffmpeg -s 480x272 -pix_fmt yuv420p -i  Src01_480x272.yuv -s 1280x720 -sws_flags bicubic -pix_fmt yuv420p src01_ bicubic_1280x720.yuv   ffmpeg -s 480x272 -pix_fmt yuv420p -i src01_ 480x272.yuv -s 1280x720 -sws_flags neighbor -pix_fmt yuv420p src01_neighbor _1280X720.YUV  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.