X-Git-Url: https://git.libav.org/?p=libav.git;a=blobdiff_plain;f=libavfilter%2Fvf_slicify.c;h=d1c9fbc6ac353b55edc204141b20252d188f1be3;hp=40824cefdc668103d6842f91ed74677714cecc5a;hb=94a5218c108d078491aa69db72433f2918bdab5d;hpb=bc37ec923debca2647b086306d360341b2492bfe diff --git a/libavfilter/vf_slicify.c b/libavfilter/vf_slicify.c index 40824cefdc..d1c9fbc6ac 100644 --- a/libavfilter/vf_slicify.c +++ b/libavfilter/vf_slicify.c @@ -24,6 +24,7 @@ */ #include "avfilter.h" +#include "libavutil/pixdesc.h" typedef struct { int h; ///< output slice height @@ -44,9 +45,8 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) static int config_props(AVFilterLink *link) { SliceContext *slice = link->dst->priv; - int tmp; - avcodec_get_chroma_sub_sample(link->format, &tmp, &slice->vshift); + slice->vshift = av_pix_fmt_descriptors[link->format].log2_chroma_h; /* ensure that slices play nice with chroma subsampling, and enforce * a reasonable minimum size for the slices */ @@ -73,16 +73,24 @@ static void end_frame(AVFilterLink *link) avfilter_end_frame(link->dst->outputs[0]); } -static void draw_slice(AVFilterLink *link, int y, int h) +static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { SliceContext *slice = link->dst->priv; int y2; - for (y2 = y; y2 + slice->h <= y + h; y2 += slice->h) - avfilter_draw_slice(link->dst->outputs[0], y2, slice->h); + if (slice_dir == 1) { + for (y2 = y; y2 + slice->h <= y + h; y2 += slice->h) + avfilter_draw_slice(link->dst->outputs[0], y2, slice->h, slice_dir); - if (y2 < y + h) - avfilter_draw_slice(link->dst->outputs[0], y2, y + h - y2); + if (y2 < y + h) + avfilter_draw_slice(link->dst->outputs[0], y2, y + h - y2, slice_dir); + } else if (slice_dir == -1) { + for (y2 = y + h; y2 - slice->h >= y; y2 -= slice->h) + avfilter_draw_slice(link->dst->outputs[0], y2 - slice->h, slice->h, slice_dir); + + if (y2 > y) + avfilter_draw_slice(link->dst->outputs[0], y, y2 - y, slice_dir); + } } AVFilter avfilter_vf_slicify = {