[FFmpeg-devel] [PATCH] lavfi/scale: add nb_slices debug option

Clément Bœsch u at pkh.me
Mon Dec 21 10:37:53 CET 2015


On Sat, Dec 19, 2015 at 11:00:53AM +0100, Nicolas George wrote:
> L'octidi 28 frimaire, an CCXXIV, Clement Boesch a écrit :
> > +    }else if (scale->nb_slices) {
> > +        int i;
> > +        const int nb_slices = FFMIN(scale->nb_slices, link->h);
> > +        for (i = 0; i < nb_slices; i++) {
> > +            const int slice_start = (link->h *  i   ) / nb_slices;
> > +            const int slice_end   = (link->h * (i+1)) / nb_slices;
> > +            const int slice_h     = slice_end - slice_start;
> > +            scale_slice(link, out, in, scale->sws, slice_start, slice_h, 1, 0);
> > +        }
> 
> You can do simpler and more robust by computing the boundary only once
> (using av_rescale to also avoid overflows):
> 
> 	int i, slice_start, slice_end = slice_start;
> 	for (i = 0; i < nb_slices; i++) {
> 	    slice_start = slice_end;
> 	    slice_end = av_rescale(link->h, i + 1, nb_slices);
> 	    ...
> 	}
> 

Changed and applied. I didn't pick the av_rescale change though, since I'm
not exactly sure about the rounding. Also, such overflows are not handled
in so many part of lavfi that many things will explode before this if they
can be triggered.

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20151221/7461ec96/attachment.sig>


More information about the ffmpeg-devel mailing list