yadif: Fix illegal memory access
authorVineeth TM <vineeth.tm@samsung.com>
Tue, 15 Dec 2015 23:25:19 +0000 (08:25 +0900)
committerSebastian Dröge <sebastian@centricular.com>
Wed, 16 Dec 2015 08:33:25 +0000 (09:33 +0100)
When applying the spatial prediction, there is an illegal access of -1 index of array.
Hence adding a condition to avoid this.

https://bugzilla.gnome.org/show_bug.cgi?id=759518

gst/yadif/vf_yadif.c

index 82e9e9e..a0bec4a 100644 (file)
         int temporal_diff2 =(FFABS(next[mrefs] - c) + FFABS(next[prefs] - e) )>>1; \
         int diff = FFMAX3(temporal_diff0 >> 1, temporal_diff1, temporal_diff2); \
         int spatial_pred = (c+e) >> 1; \
-        int spatial_score = FFABS(cur[mrefs - 1] - cur[prefs - 1]) + FFABS(c-e) \
-                          + FFABS(cur[mrefs + 1] - cur[prefs + 1]) - 1; \
+        int spatial_score = -1; \
  \
-        CHECK(-1) CHECK(-2) }} }} \
-        CHECK( 1) CHECK( 2) }} }} \
+        if (mrefs > 0 && prefs > 0) { \
+            spatial_score = FFABS(cur[mrefs - 1] - cur[prefs - 1]) + FFABS(c-e) \
+                            + FFABS(cur[mrefs + 1] - cur[prefs + 1]) - 1; \
  \
+            CHECK(-1) CHECK(-2) }} }} \
+            CHECK( 1) CHECK( 2) }} }} \
+        } \
         if (mode < 2) { \
             int b = (prev2[2 * mrefs] + next2[2 * mrefs])>>1; \
             int f = (prev2[2 * prefs] + next2[2 * prefs])>>1; \