x264 algorithm for changing output resolution

Source: Internet
Author: User

x264 algorithm for changing output resolution

In some scenarios, the input video resolution of the x264 is different from the video resolution of the receiving side output.
For example, the data captured by the coded end camera is 1280x720, while the receiving side Video display window is 640x480.
For this scenario, the general approach is:
Source: Capture, encode, transmit 720p of code stream
Receiver: Receive, decode 720p code stream, zoom to 480p to display.
The disadvantage of this approach lies in coding, which transmits a large resolution stream that is not available at the receiving end.

An improved way is to scale 720p of video input data on the source side:
Source: Capture 720p, zoom to 480p, input 480p encode to x264 encoder, transmit 480p bitstream
Receiver: Receive, decode, display 480p of code stream.
This approach has dealt with the problem of transmitting large-resolution streams, but is not the most efficient way. Because the scale itself also has the computation amount, simultaneously increased one frame data reads and writes the operation.

Studying x264 's code discovery, x264 implements the format conversion of the input source image to the prepared encoding frame by the following function:
int X264_frame_copy_picture (x264_t *h, x264_frame_t *dst, x264_picture_t *src);
There is the process of copying data from src->img.planet to Dst->plane to achieve the color space conversion between SRC and DST (the original data frame used in the x264, the reference frame is nv12/nv16 format, src if the YV12 need to turn into NV12). x264 here assumes that the resolution of SRC and DST is the same, just do color space conversion. Now that there is a data shift due to the conversion of the color space, the image scaling operation can be added together to achieve the need to change the output resolution.

FFmpeg's Sws_scale function enables the conversion of the resolution and color space between the input image and the output image at once. Here, if the input and output resolution is found to be different, replace the original Plane_copy,plane_copy_interleave function with the Sws_scale function. The ability to change the output resolution is perfectly achieved when the computational amount is almost constant (scaling calculation adds a bit of computation, but there is no increase in the read and write operation of a frame of data).

x264 algorithm for changing output resolution

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.