FFMPEG swscale 1920x1080 UYVY422 down to odd width produces incorrect colors

848 Views Asked by At

I am using libswscale (from FFMPEG) to scale a 1920x1080 UYVY422 image to a size that is decided programmatically, based on what size window we are rendering to.

When resizing my "canvas", I noticed that the color of the image would change back and forth between normal and invalid (incorrect colors).

After analyzing the dimensions at which the color would be invalid, I noticed that the image always appeared to be correct when the width is an even number of pixels.

1920x1080 scaled to 867x488
doesn't work

1920x1080 scaled to 1016x572
works

19280x1080 scaled to 975x548
doesn't work

19280x1080 scaled to 962x541
works

I have since updated my code to always scale to an even width.

if ((targetSize.cx % 2) != 0)
{
    targetSize.cx = targetSize.cx - 1;
}

It works with this code. However, I still don't understand why it does this. If I scale an image that is originally and odd width, do I have to ensure my width is also odd? I'd like to understand this.

0

There are 0 best solutions below