[MPlayer-cvslog] r30410 - trunk/libmpcodecs/vf_halfpack.c

reimar subversion at mplayerhq.hu
Sun Jan 24 00:50:25 CET 2010


Author: reimar
Date: Sun Jan 24 00:50:25 2010
New Revision: 30410

Log:
Switch -vf halfpack to use only public API of libswscale.

Modified:
   trunk/libmpcodecs/vf_halfpack.c

Modified: trunk/libmpcodecs/vf_halfpack.c
==============================================================================
--- trunk/libmpcodecs/vf_halfpack.c	Sat Jan 23 20:00:09 2010	(r30409)
+++ trunk/libmpcodecs/vf_halfpack.c	Sun Jan 24 00:50:25 2010	(r30410)
@@ -10,11 +10,14 @@
 #include "img_format.h"
 #include "mp_image.h"
 #include "vf.h"
+#include "vf_scale.h"
 
-#include "libswscale/rgb2rgb.h"
+#include "libswscale/swscale.h"
+#include "fmt-conversion.h"
 
 struct vf_priv_s {
 	int field;
+	struct SwsContext *ctx;
 };
 
 #if HAVE_MMX
@@ -144,6 +147,10 @@ static void (*halfpack)(unsigned char *d
 
 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
 {
+	const uint8_t *src[MP_MAX_PLANES] = {
+		mpi->planes[0] + mpi->stride[0]*vf->priv->field,
+		mpi->planes[1], mpi->planes[2], NULL};
+	int src_stride[MP_MAX_PLANES] = {mpi->stride[0]*2, mpi->stride[1], mpi->stride[2], 0};
 	mp_image_t *dmpi;
 
 	// hope we'll get DR buffer:
@@ -154,9 +161,8 @@ static int put_image(struct vf_instance_
 	switch(vf->priv->field) {
 	case 0:
 	case 1:
-		yuv422ptoyuy2(mpi->planes[0] + mpi->stride[0]*vf->priv->field,
-			mpi->planes[1], mpi->planes[2], dmpi->planes[0],
-			mpi->w, mpi->h/2, mpi->stride[0]*2, mpi->stride[1], dmpi->stride[0]);
+		sws_scale(vf->priv->ctx, src, src_stride,
+		          0, mpi->h/2, dmpi->planes, dmpi->stride);
 		break;
 	default:
 		halfpack(dmpi->planes[0], mpi->planes, dmpi->stride[0],
@@ -170,6 +176,15 @@ static int config(struct vf_instance_s* 
 		  int width, int height, int d_width, int d_height,
 		  unsigned int flags, unsigned int outfmt)
 {
+	if (vf->priv->field < 2) {
+		sws_freeContext(vf->priv->ctx);
+		// get unscaled 422p -> yuy2 conversion
+		vf->priv->ctx =
+			sws_getContext(width, height / 2, PIX_FMT_YUV422P,
+			               width, height / 2, PIX_FMT_YUYV422,
+			               SWS_POINT | SWS_PRINT_INFO | get_sws_cpuflags(),
+			               NULL, NULL, NULL);
+	}
 	/* FIXME - also support UYVY output? */
 	return vf_next_config(vf, width, height/2, d_width, d_height, flags, IMGFMT_YUY2);
 }
@@ -189,6 +204,7 @@ static int query_format(struct vf_instan
 
 static void uninit(struct vf_instance_s* vf)
 {
+	sws_freeContext(vf->priv->ctx);
 	free(vf->priv);
 }
 


More information about the MPlayer-cvslog mailing list