[Ffmpeg-devel] libswscale and vertically flipped images

Luca Abeni lucabe72
Tue Jan 9 17:33:26 CET 2007


Hi all,

as people who tried --enable-swscaler might have noticed, doing an YUV
<--> RGB conversion with ffmpeg can result in a vertically flipped image
(if an AVI file is involved, for example).

I finally had some time for looking at the problem, and I discovered
that this happens because sws_scale() does not honour negative line
sizes.
sws_scale_ordered(), however, behaves correctly even with negative line
sizes.

After some more investigation, I discovered that:
- sws_scale_ordered() was introduced in r9698. At that time, libswscale
could not cope with negative line sizes
- support for negative line sizes was introduced in r15249: "support for
both orderings of the slices (top->down / bottom->up)". But it was
introduced only in sws_scale_ordered().

My understanding is that the only difference between sws_scale() and
sws_scale_ordered() should be that the second one does not reorder the U
and V planes (but since mplayer always provides ordered planes to
libswscale, it should be useless to have both sws_scale() and
sws_scale_ordered()). So, I would be tempted to say that introducing
support for negative line sizes in sws_scale_ordered() only was an
error... And that such code should be copied in sws_scale() too.

If people agree, I'll provide a patch for coping with negative linesizes
in sws_scale(), and a second patch that removes sws_scale_ordered() and
always call sws_scale() in mplayer (I think this should not break
anything).


				Luca
-- 
_____________________________________________________________________________
Copy this in your signature, if you think it is important:
                               N O    W A R ! ! !





More information about the ffmpeg-devel mailing list