From 4e90199d2ee19ecaab142ee6e34327ac5dda6166 Mon Sep 17 00:00:00 2001 From: reimar Date: Sat, 23 Jan 2010 23:50:25 +0000 Subject: Switch -vf halfpack to use only public API of libswscale. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30410 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpcodecs/vf_halfpack.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/libmpcodecs/vf_halfpack.c b/libmpcodecs/vf_halfpack.c index 246518e8e0..ed406bde89 100644 --- a/libmpcodecs/vf_halfpack.c +++ b/libmpcodecs/vf_halfpack.c @@ -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 *dst, unsigned char *src[3], 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_s* vf, mp_image_t *mpi, double pts) 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* vf, 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_instance_s* vf, unsigned int fmt) static void uninit(struct vf_instance_s* vf) { + sws_freeContext(vf->priv->ctx); free(vf->priv); } -- cgit v1.2.3