diff options
author | Paul B Mahol <onemda@gmail.com> | 2018-05-01 14:50:48 +0200 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2018-05-01 14:50:48 +0200 |
commit | ddf844d17c40fd6053f06d67d8973c302e01b61c (patch) | |
tree | 6c0b36b7bfc0d22cbdc088e9803d3565230cbf12 /libavfilter | |
parent | 273edb2fe45a8f3805085f879ad4717d87247aeb (diff) | |
download | ffmpeg-ddf844d17c40fd6053f06d67d8973c302e01b61c.tar.gz |
avfilter/vf_neighbor: simplify code little
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/vf_neighbor.c | 66 |
1 files changed, 32 insertions, 34 deletions
diff --git a/libavfilter/vf_neighbor.c b/libavfilter/vf_neighbor.c index bd69c9e77f..1eb89c208d 100644 --- a/libavfilter/vf_neighbor.c +++ b/libavfilter/vf_neighbor.c @@ -165,41 +165,39 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) for (plane = 0; plane < s->nb_planes; plane++) { const int threshold = s->threshold[plane]; + const int stride = in->linesize[plane]; + const int dstride = out->linesize[plane]; + const uint8_t *src = in->data[plane]; + uint8_t *dst = out->data[plane]; + const int height = s->planeheight[plane]; + const int width = s->planewidth[plane]; + + if (!threshold) { + av_image_copy_plane(dst, dstride, src, stride, width, height); + continue; + } - if (threshold) { - const int stride = in->linesize[plane]; - const int dstride = out->linesize[plane]; - const uint8_t *src = in->data[plane]; - uint8_t *dst = out->data[plane]; - const int height = s->planeheight[plane]; - const int width = s->planewidth[plane]; - - for (y = 0; y < height; y++) { - const int nh = y > 0; - const int ph = y < height - 1; - const uint8_t *coordinates[] = { src - nh * stride, src + 1 - nh * stride, src + 2 - nh * stride, - src, src + 2, - src + ph * stride, src + 1 + ph * stride, src + 2 + ph * stride}; - - const uint8_t *coordinateslb[] = { src - nh * stride, src - nh * stride, src + 1 - nh * stride, - src, src + 1, - src + ph * stride, src + ph * stride, src + 1 + ph * stride}; - - const uint8_t *coordinatesrb[] = { src + width - 2 - nh * stride, src + width - 1 - nh * stride, src + width - 1 - nh * stride, - src + width - 2, src + width - 1, - src + width - 2 + ph * stride, src + width - 1 + ph * stride, src + width - 1 + ph * stride}; - - s->filter(dst, src, 1, threshold, coordinateslb, s->coordinates); - s->filter(dst + 1, src + 1, width - 2, threshold, coordinates, s->coordinates); - s->filter(dst + width - 1, src + width - 1, 1, threshold, coordinatesrb, s->coordinates); - - src += stride; - dst += dstride; - } - } else { - av_image_copy_plane(out->data[plane], out->linesize[plane], - in->data[plane], in->linesize[plane], - s->planewidth[plane], s->planeheight[plane]); + for (y = 0; y < height; y++) { + const int nh = y > 0; + const int ph = y < height - 1; + const uint8_t *coordinates[] = { src - nh * stride, src + 1 - nh * stride, src + 2 - nh * stride, + src, src + 2, + src + ph * stride, src + 1 + ph * stride, src + 2 + ph * stride}; + + const uint8_t *coordinateslb[] = { src - nh * stride, src - nh * stride, src + 1 - nh * stride, + src, src + 1, + src + ph * stride, src + ph * stride, src + 1 + ph * stride}; + + const uint8_t *coordinatesrb[] = { src + width - 2 - nh * stride, src + width - 1 - nh * stride, src + width - 1 - nh * stride, + src + width - 2, src + width - 1, + src + width - 2 + ph * stride, src + width - 1 + ph * stride, src + width - 1 + ph * stride}; + + s->filter(dst, src, 1, threshold, coordinateslb, s->coordinates); + s->filter(dst + 1, src + 1, width - 2, threshold, coordinates, s->coordinates); + s->filter(dst + width - 1, src + width - 1, 1, threshold, coordinatesrb, s->coordinates); + + src += stride; + dst += dstride; } } |