[MPlayer-cvslog] CVS: main/libmpcodecs vf_tinterlace.c,1.5,1.6

Ivan Kalvachev CVS syncmail at mplayerhq.hu
Sat Apr 8 17:30:11 CEST 2006


CVS change done by Ivan Kalvachev CVS

Update of /cvsroot/mplayer/main/libmpcodecs
In directory mail:/var2/tmp/cvs-serv25022

Modified Files:
	vf_tinterlace.c 
Log Message:
New mode for tinterlace filter
patch by Walter Belhaven <wbelhaven at yahoo >


Index: vf_tinterlace.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_tinterlace.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- vf_tinterlace.c	21 Mar 2006 21:26:42 -0000	1.5
+++ vf_tinterlace.c	8 Apr 2006 15:30:09 -0000	1.6
@@ -35,6 +35,22 @@
 	mp_image_t *dmpi;
 };
 
+// Copied verbatim from vf_telecine.c:
+static inline void *my_memcpy_pic(void * dst, void * src, int bytesPerLine, int height, int dstStride, int srcStride)
+{
+	int i;
+	void *retval=dst;
+
+	for(i=0; i<height; i++)
+	{
+		memcpy(dst, src, bytesPerLine);
+		src+= srcStride;
+		dst+= dstStride;
+	}
+
+	return retval;
+}
+
 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
 {
 	int ret = 0;
@@ -116,6 +132,57 @@
 		}
 		ret = vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE);
 		break;
+	case 4:
+		// Interleave even lines (only) from Frame 'i' with odd
+		// lines (only) from Frame 'i+1', halving the Frame
+		// rate and preserving image height.
+
+		dmpi = vf->priv->dmpi;
+		
+		// @@ Need help:  Should I set dmpi->fields to indicate
+		// that the (new) frame will be interlaced!?  E.g. ...
+		// dmpi->fields |= MP_IMGFIELD_INTERLACED;
+		// dmpi->fields |= MP_IMGFIELD_TOP_FIRST;
+		// etc.
+		
+		if (dmpi == NULL) {
+			dmpi = vf_get_image(vf->next, mpi->imgfmt,
+					    MP_IMGTYPE_STATIC, MP_IMGFLAG_ACCEPT_STRIDE |
+					    MP_IMGFLAG_PRESERVE,
+					    mpi->width, mpi->height);
+
+			vf->priv->dmpi = dmpi;
+
+			my_memcpy_pic(dmpi->planes[0], mpi->planes[0], mpi->w, mpi->h/2,
+				      dmpi->stride[0]*2, mpi->stride[0]*2);
+			if (mpi->flags & MP_IMGFLAG_PLANAR) {
+				my_memcpy_pic(dmpi->planes[1], mpi->planes[1],
+					      mpi->chroma_width, mpi->chroma_height/2,
+					      dmpi->stride[1]*2, mpi->stride[1]*2);
+				my_memcpy_pic(dmpi->planes[2], mpi->planes[2],
+					      mpi->chroma_width, mpi->chroma_height/2,
+					      dmpi->stride[2]*2, mpi->stride[2]*2);
+			}
+		} else {
+			vf->priv->dmpi = NULL;
+
+			my_memcpy_pic(dmpi->planes[0]+dmpi->stride[0], 
+				      mpi->planes[0]+mpi->stride[0],
+				      mpi->w, mpi->h/2, 
+				      dmpi->stride[0]*2, mpi->stride[0]*2);
+			if (mpi->flags & MP_IMGFLAG_PLANAR) {
+				my_memcpy_pic(dmpi->planes[1]+dmpi->stride[1], 
+					      mpi->planes[1]+mpi->stride[1],
+					      mpi->chroma_width, mpi->chroma_height/2,
+					      dmpi->stride[1]*2, mpi->stride[1]*2);
+				my_memcpy_pic(dmpi->planes[2]+dmpi->stride[2], 
+					      mpi->planes[2]+mpi->stride[2],
+					      mpi->chroma_width, mpi->chroma_height/2,
+					      dmpi->stride[2]*2, mpi->stride[2]*2);
+			}
+			ret = vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE);
+		}
+		break;
 	}
 
 	vf->priv->frame++;
@@ -145,6 +212,7 @@
 		return vf_next_config(vf,width,height*2,d_width,d_height*2,flags,outfmt);
 	case 1:			/* odd frames */
 	case 2:			/* even frames */
+	case 4:			/* alternate frame (height-preserving) interlacing */
 		return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
 	}
 	return 0;




More information about the MPlayer-cvslog mailing list