[Libav-user] Questions about ColorSpace conversion in swscale

wm4 nfxjfg at googlemail.com
Mon Aug 18 19:53:40 CEST 2014


On Mon, 18 Aug 2014 09:33:49 +0002
Markus Pfundstein <markuspfundstein86 at gmail.com> wrote:

> Hello,
> 
> I am currently developing a program that uses the libavcodec library 
> for decoding (not encoding) various movie formats. I have some 
> questions about color space conversion and how ffmpeg handles it.
> 
> Assume I have RGB input where I don't know if its FullRange or ITU-R 
> BT.709 and I want to have my output ITU-R BT.709. How can I configure 
> SwSContext properly?
> 
> Assume I have YUV422 BT 601 input and I want my output to be YUV444 
> FullRange. Is this possible without telling SwsContext that my input 
> source is BT 601?
> 
> I would also appreciate if someone could explain to me how swscale 
> works in terms of color space conversion. I did read through the source 
> and I think I understand a bit but I don't get the whole picture. Does 
> color space conversion work on 10bit and 12bit as well or does it 
> always downscale first to 8bit? (would be a big bummer). Also, does 
> swscale first transform the input color space to XYZ and then transform 
> it further into the target color space? And why is there no yuv2rgb 
> function but only a rgb2yuv function? If I want my output color space 
> to be rgb, such a function would be needed or not? 
> 
> Thanks a lot already for your answers. I hope my english is 
> understandable (not native)
> 
> With best regards, 
> Markus	

You have to set them with av_opt_*. Look at libavfilter/vf_scale for an
example. Yes, all this stuff is probably under-documented.

As for libswscale itself: it's mostly horrible, but with some luck and
if you provide the right flags (SWS_BITEXACT and others) it might
actually do what you want.


More information about the Libav-user mailing list