]> git.sesse.net Git - ffmpeg/commitdiff
avfilter/vf_bm3d: round values toward nearest integer
authorPaul B Mahol <onemda@gmail.com>
Sat, 19 Oct 2019 16:53:48 +0000 (18:53 +0200)
committerPaul B Mahol <onemda@gmail.com>
Sat, 19 Oct 2019 16:53:48 +0000 (18:53 +0200)
Instead of rounding toward zero and thus producing
darker output.

libavfilter/vf_bm3d.c

index f8d656c178d1a16559b8b501002fce32f8b2f56d..eb45a70bbdf4603d00c14f9604920e4eeebe8a3f 100644 (file)
@@ -660,7 +660,7 @@ static void do_output(BM3DContext *s, uint8_t *dst, int dst_linesize,
                 sum_den += den;
             }
 
-            dstp[j] = av_clip_uint8(sum_num / sum_den);
+            dstp[j] = av_clip_uint8(lrintf(sum_num / sum_den));
         }
     }
 }
@@ -688,7 +688,7 @@ static void do_output16(BM3DContext *s, uint8_t *dst, int dst_linesize,
                 sum_den += den;
             }
 
-            dstp[j] = av_clip_uintp2_c(sum_num / sum_den, depth);
+            dstp[j] = av_clip_uintp2_c(lrintf(sum_num / sum_den), depth);
         }
     }
 }