changeset 12255:2eb20525825f

dr bugfix by zoli (author of the filter)
author rfelker
date Fri, 23 Apr 2004 01:37:43 +0000
parents 362cf8df665e
children 38bb4e2299ce
files libmpcodecs/vf_filmdint.c
diffstat 1 files changed, 21 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/vf_filmdint.c	Thu Apr 22 15:00:30 2004 +0000
+++ b/libmpcodecs/vf_filmdint.c	Fri Apr 23 01:37:43 2004 +0000
@@ -61,6 +61,7 @@
     unsigned long crop_x, crop_y, crop_cx, crop_cy;
     unsigned long export_count, merge_count;
     unsigned long num_breaks;
+    unsigned long num_copies;
     long in_inc, out_dec, iosync;
     long num_fields;
     long prev_fields;
@@ -943,11 +944,25 @@
 
     if (mpi->type == MP_IMGTYPE_TEMP ||
 	(mpi->type == MP_IMGTYPE_IPB && !(mpi->flags & MP_IMGFLAG_READABLE)))
-	planes_idx = 2 + (++p->temp_idx & 1);
+	planes_idx = NUM_STORED/2 + (++p->temp_idx % (NUM_STORED/2));
     else
-	planes_idx = ++p->static_idx & 1;
+	planes_idx = ++p->static_idx % (NUM_STORED/2);
     planes = p->planes[planes_idx];
     mpi->priv = p->planes[NUM_STORED + planes_idx];
+    if (mpi->priv == p->old_planes) {
+	unsigned char **old_planes =
+	    p->planes[NUM_STORED + 2 + (++p->temp_idx & 1)];
+	my_memcpy_pic(old_planes[0], p->old_planes[0],
+		      p->w, p->h, p->stride, p->stride);
+	if (mpi->flags & MP_IMGFLAG_PLANAR) {
+	    my_memcpy_pic(old_planes[1], p->old_planes[1],
+			  p->cw, p->ch, p->chroma_stride, p->chroma_stride);
+	    my_memcpy_pic(old_planes[2], p->old_planes[2],
+			  p->cw, p->ch, p->chroma_stride, p->chroma_stride);
+	}
+	p->old_planes = old_planes;
+	p->num_copies++;
+    }
     mpi->planes[0] = planes[0];
     mpi->stride[0] = p->stride;
     if (mpi->flags & MP_IMGFLAG_PLANAR) {
@@ -1142,7 +1157,7 @@
 
     old_planes = p->old_planes;
 
-    if (mpi->flags & MP_IMGFLAG_DIRECT) {
+    if ((mpi->flags & MP_IMGFLAG_DIRECT) && mpi->priv) {
 	planes = mpi->priv;
 	mpi->priv = 0;
     } else {
@@ -1157,6 +1172,7 @@
 	    my_memcpy_pic(planes[2],
 			  mpi->planes[2] + p->crop_cx + p->crop_cy * mpi->stride[2],
 			  p->cw, p->ch, p->chroma_stride, mpi->stride[2]);
+	    p->num_copies++;
 	}
     }
 
@@ -1383,8 +1399,8 @@
 {
     struct vf_priv_s *p = vf->priv;
     mp_msg(MSGT_VFILTER, MSGL_INFO, "diff_time: %.3f, merge_time: %.3f, "
-	   "export: %lu, merge: %lu\n", p->diff_time, p->merge_time,
-	   p->export_count, p->merge_count);
+	   "export: %lu, merge: %lu, copy: %lu\n", p->diff_time, p->merge_time,
+	   p->export_count, p->merge_count, p->num_copies);
     free(p->memory_allocated);
     free(p);
 }