changeset 30441:9c15719d8769

Fix -vf tfields=1 so it does not read out of bounds or leave parts of the output frame uninitialized.
author reimar
date Mon, 01 Feb 2010 19:14:01 +0000
parents 7eba91101a46
children 8d7a061d427b
files libmpcodecs/vf_tfields.c
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/vf_tfields.c	Mon Feb 01 18:20:22 2010 +0000
+++ b/libmpcodecs/vf_tfields.c	Mon Feb 01 19:14:01 2010 +0000
@@ -43,13 +43,16 @@
 	int x, y;
 	src += ss;
 	dest += ds;
+	h--;
 	if (field) {
+		fast_memcpy(dest - ds, src - ss, w);
 		src += ss;
 		dest += ds;
-		h -= 2;
+		h--;
 	}
-	for (y=h/2; y; y--) {
-		for (x=0; x<w; x++) {
+	for (y=h/2; y > 0; y--) {
+		dest[0] = src[0];
+		for (x=1; x<w-1; x++) {
 			if (((src[x-ss] < src[x]) && (src[x+ss] < src[x])) ||
 				((src[x-ss] > src[x]) && (src[x+ss] > src[x]))) {
 				//dest[x] = (src[x+ss] + src[x-ss])>>1;
@@ -59,9 +62,12 @@
 			}
 			else dest[x] = src[x];
 		}
+		dest[w-1] = src[w-1];
 		dest += ds<<1;
 		src += ss<<1;
 	}
+	if (h & 1)
+		fast_memcpy(dest, src, w);
 }
 
 #if HAVE_AMD3DNOW