]> git.sesse.net Git - ffmpeg/commitdiff
avfilter/vf_nlmeans: round values toward nearest integer
authorPaul B Mahol <onemda@gmail.com>
Sun, 20 Oct 2019 19:53:11 +0000 (21:53 +0200)
committerPaul B Mahol <onemda@gmail.com>
Mon, 21 Oct 2019 07:26:41 +0000 (09:26 +0200)
Instead of rounding toward zero and thus producing
darker output.

libavfilter/vf_nlmeans.c

index dcb5a0395334565e798d730eebb1b932846df246..06233b0dd46a0cdbb9bc423bbc95467c728c68b9 100644 (file)
@@ -419,7 +419,7 @@ static void weight_averages(uint8_t *dst, ptrdiff_t dst_linesize,
             // Also weight the centered pixel
             wa[x].total_weight += 1.f;
             wa[x].sum += 1.f * src[x];
-            dst[x] = av_clip_uint8(wa[x].sum / wa[x].total_weight);
+            dst[x] = av_clip_uint8(wa[x].sum / wa[x].total_weight + 0.5f);
         }
         dst += dst_linesize;
         src += src_linesize;