]> git.sesse.net Git - ffmpeg/commitdiff
lavfi/deshake: fix deshake crash issue.
authorJun Zhao <mypopydev@gmail.com>
Tue, 18 Sep 2018 06:57:49 +0000 (14:57 +0800)
committerJun Zhao <jun.zhao@intel.com>
Sat, 6 Oct 2018 13:30:18 +0000 (21:30 +0800)
Fixes ticket #7441.

for block contrast calculate, the block is like this:

|<---------------- stride-----------------------|
+----------------------------------------------->  X
|
|            w = 16
|    (cx,cy)+------+
|           |      |
|h=blocksize|      |
|           |      |
|           +------+
V

Y

so we calc the block contrast use:
   (cy + y) * stride + (cx + x)

Signed-off-by: Jun Zhao <mypopydev@gmail.com>
libavfilter/vf_deshake.c

index 55ce5e18a1cdca1ab016cff860b18a1ccf450d6e..c8480e74dd028bcbc2820b66b657ccc96c4110d3 100644 (file)
@@ -196,7 +196,7 @@ static int block_contrast(uint8_t *src, int x, int y, int stride, int blocksize)
     for (i = 0; i <= blocksize * 2; i++) {
         // We use a width of 16 here to match the sad function
         for (j = 0; j <= 15; j++) {
-            pos = (y - i) * stride + (x - j);
+            pos = (y + i) * stride + (x + j);
             if (src[pos] < lowest)
                 lowest = src[pos];
             else if (src[pos] > highest) {