[FFmpeg-devel] [RFC] libswscale and non-chroma-aligned slices

Stefano Sabatini stefano.sabatini-lala
Sat Jan 9 23:22:10 CET 2010


On date Saturday 2010-01-09 18:20:03 +0100, Michael Niedermayer encoded:
> On Sat, Jan 09, 2010 at 05:40:36PM +0100, Stefano Sabatini wrote:
> > Hi all,
> > 
> > libswscale issues slices with weird heigth, for example:
> > y:100 h:9
> > y:119 h:9
> > y:128 h:10
> 
> try again, this doesnt look very likely

stefano at geppetto ~/s/l/ffmpeg> ffplay -loglevel debug -vfilters "slicify=12, scale=200:149, pad=300:200:20:20:blue" in.avi ^| grep "scale *->pad"
draw_slice      : link[0x9138b00 s:200x149 fmt:yuv420p          scale           ->pad             ] y:0 h:4 dir:1
draw_slice      : link[0x9138b00 s:200x149 fmt:yuv420p          scale           ->pad             ] y:4 h:4 dir:1
draw_slice      : link[0x9138b00 s:200x149 fmt:yuv420p          scale           ->pad             ] y:8 h:6 dir:1
draw_slice      : link[0x9138b00 s:200x149 fmt:yuv420p          scale           ->pad             ] y:14 h:4 dir:1
draw_slice      : link[0x9138b00 s:200x149 fmt:yuv420p          scale           ->pad             ] y:18 h:6 dir:1
draw_slice      : link[0x9138b00 s:200x149 fmt:yuv420p          scale           ->pad             ] y:24 h:6 dir:1
draw_slice      : link[0x9138b00 s:200x149 fmt:yuv420p          scale           ->pad             ] y:30 h:4 dir:1
draw_slice      : link[0x9138b00 s:200x149 fmt:yuv420p          scale           ->pad             ] y:34 h:6 dir:1
draw_slice      : link[0x9138b00 s:200x149 fmt:yuv420p          scale           ->pad             ] y:40 h:4 dir:1
draw_slice      : link[0x9138b00 s:200x149 fmt:yuv420p          scale           ->pad             ] y:44 h:6 dir:1
draw_slice      : link[0x9138b00 s:200x149 fmt:yuv420p          scale           ->pad             ] y:50 h:6 dir:1
draw_slice      : link[0x9138b00 s:200x149 fmt:yuv420p          scale           ->pad             ] y:56 h:4 dir:1
draw_slice      : link[0x9138b00 s:200x149 fmt:yuv420p          scale           ->pad             ] y:60 h:6 dir:1
draw_slice      : link[0x9138b00 s:200x149 fmt:yuv420p          scale           ->pad             ] y:66 h:4 dir:1
draw_slice      : link[0x9138b00 s:200x149 fmt:yuv420p          scale           ->pad             ] y:70 h:6 dir:1
draw_slice      : link[0x9138b00 s:200x149 fmt:yuv420p          scale           ->pad             ] y:76 h:4 dir:1
draw_slice      : link[0x9138b00 s:200x149 fmt:yuv420p          scale           ->pad             ] y:80 h:6 dir:1
draw_slice      : link[0x9138b00 s:200x149 fmt:yuv420p          scale           ->pad             ] y:86 h:6 dir:1
draw_slice      : link[0x9138b00 s:200x149 fmt:yuv420p          scale           ->pad             ] y:92 h:4 dir:1
draw_slice      : link[0x9138b00 s:200x149 fmt:yuv420p          scale           ->pad             ] y:96 h:6 dir:1
draw_slice      : link[0x9138b00 s:200x149 fmt:yuv420p          scale           ->pad             ] y:102 h:4 dir:1
draw_slice      : link[0x9138b00 s:200x149 fmt:yuv420p          scale           ->pad             ] y:106 h:6 dir:1
draw_slice      : link[0x9138b00 s:200x149 fmt:yuv420p          scale           ->pad             ] y:112 h:5 dir:1 <=
draw_slice      : link[0x9138b00 s:200x149 fmt:yuv420p          scale           ->pad             ] y:117 h:5 dir:1 <=
draw_slice      : link[0x9138b00 s:200x149 fmt:yuv420p          scale           ->pad             ] y:122 h:6 dir:1
draw_slice      : link[0x9138b00 s:200x149 fmt:yuv420p          scale           ->pad             ] y:128 h:4 dir:1
draw_slice      : link[0x9138b00 s:200x149 fmt:yuv420p          scale           ->pad             ] y:132 h:6 dir:1
draw_slice      : link[0x9138b00 s:200x149 fmt:yuv420p          scale           ->pad             ] y:138 h:4 dir:1
draw_slice      : link[0x9138b00 s:200x149 fmt:yuv420p          scale           ->pad             ] y:142 h:7 dir:1

This was "discovered" by the new test system with random height
slices, and results in a 2 lines gap in the pad output, since it
aligns the y/h values.

The problem seems to appear only with odd values for the output
height.

> > this with an yuv420p output, so I'd expect for each slice an height
> > which is a multiple of vsub^2, that is:
> > h == (h & ~((1 << vsub) - 1));
> > 
> > For example for the previous case I'd rather expect:
> > y:100 h:8
> > y:118 h:10
> > y:128 h:10
> > 
> > I suppose the chroma components lines associated to the last luminance
> > line is already filled, anyway it would be a lot simpler to make the
> > scaler always return already chroma-aligned h values, this would
> > simplify the logic required from each filter dealing with such slices,
> > which gets complicated especially with negative slice direction
> > values.
> 
> you have a video of yuv420p with vertical resolution of 9
> how exactly will you avoid outputing a slice of odd height?

Yes that's exactly the problem I'm trying to resolve, having only one
odd slice (either at the end either at the beginning of the slice
sequence) would be way simpler to manage.

Also another way to consider is to lose the information of the odd
line, in your example that would mean to output a single slice with
height 8.

Regards.
-- 
FFmpeg = Funny & Freak Moronic Peaceful Embarassing God



More information about the ffmpeg-devel mailing list