Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is lib Swscale used for by ffmpeg programers?

Tags:

c

media

mpeg

What is lib Swscale used for by ffmpeg programers?

  • What benefits it gives for AV encoding/decoding?
  • What is its position relevantly to av* libs?
like image 818
Rella Avatar asked Jul 29 '10 21:07

Rella


2 Answers

Swscale is mainly used for players, not encoding/decoding. It's necessary if you want to display the video at a different pixel size/aspect ratio than it was encoded at and you don't have hardware video scaling support. Swscale also performs colorspace conversion between various RGB and YUV color formats, and conversion between packed (all channels in a single buffer) and planar (each channel has its own buffer) formats. All of these routines are highly optimized; as far as I know, no faster software implementation presently exists for any of them, at least on x86 and x86_64.

Swscale also may be needed for encoding video, if the source video is not already in the format needed by the encoder. For instance, if your source video is RGB, you'll probably need to convert it to the appropriate YUV planar format, since most codecs work on YUV. This entails both colorspace conversion (an affine transformation of the R,G,B vectors) and actual scaling (resampling), since most YUV formats use half-resolution U and V planes (color planes) compared to the Y plane (luma, i.e. intensity data).

like image 161
R.. GitHub STOP HELPING ICE Avatar answered Oct 04 '22 11:10

R.. GitHub STOP HELPING ICE


swscale can also do high quality resampling, ex: using the lanczos algorithm. So basically it converts between colorspaces, between "number of bits", and also does resizing. It also has options to use MMX etc. so can be fast.

like image 44
rogerdpack Avatar answered Oct 04 '22 12:10

rogerdpack