[FFmpeg-devel] [PATCH] Implement recursive avfilter_get_video_buffer()

Stefano Sabatini stefano.sabatini-lala
Sat Oct 17 18:49:50 CEST 2009


On date Friday 2009-10-16 14:58:20 +0200, Michael Niedermayer encoded:
> On Sat, Oct 10, 2009 at 11:40:10AM +0200, Stefano Sabatini wrote:
> > On date Saturday 2009-10-10 00:58:42 +0200, Michael Niedermayer encoded:
> > > On Fri, Oct 09, 2009 at 02:01:27AM +0200, Stefano Sabatini wrote:
> > [...]
> > > > I found this filterchain is somehow broken:
> > > > 
> > > > slicify=10,vflip,scale=20:20,scale=200:200
> > > 
> > > somehow?
> > > and i assume that this is a minimal chain ...
> > 
> > The last drawn slice, and only the last one (corresponding to the top
> > slice of the output image) results corrupted, or better it looks like
> > it isn't drawn at all (and so it may contain random data).
> > 
> > You can observe this behavior changing the slicify size, also the
> > first half part of the image looks always rendered correctly with
> > every slicify size.
> > 
> > Removing any of the filters in the chain (or increasing the slicify
> > value to X >= H) the problem doesn't show up, it looks like a glitch
> > in libswscale issued when dealing with negative linesizes, I still
> > didn't extensively investigated on it though so I may be wrong.
> > 
> > If that's not a problem I'll apply this patch anyway.
> 
> I would prefer if the bug is better understood before things are changed
> further

It's a bug in the scale filter.

Currently it assumes that the slices are passed in sequential order
from the top one to the bottom one, indeed it does this:

    outH = sws_scale(scale->sws, data, link->cur_pic->linesize, y, h,
                     link->dst->outputs[0]->outpic->data,
                     link->dst->outputs[0]->outpic->linesize);
    avfilter_draw_slice(link->dst->outputs[0], scale->sliceY, outH);
    scale->sliceY += outH;

scale->sliceY is inited to 0, so for example when passing the slice
y=100 h=100 it calls draw_slice on the slice y=0 h=outH, which is not
the current behavior.

My idea is to use a scale->h_ratio, and use it like this:

    outH = sws_scale(scale->sws, data, link->cur_pic->linesize, y, h,
                     link->dst->outputs[0]->outpic->data,
                     link->dst->outputs[0]->outpic->linesize);

    outY =  y * scale->h_ratio.num / scale->h_ratio.den;
    avfilter_draw_slice(link->dst->outputs[0], outY, outH);

Anyway this bug seems not related to the discussed patch, and we'll
try to fix it in the scale filter review.

So I'll apply it tomorrow if there are no further comments.

Regards.
-- 
FFmpeg = Friendly and Fundamentalist Merciful Philosophical Embarassing Gymnast



More information about the ffmpeg-devel mailing list