# HG changeset patch # User reimar # Date 1264290625 0 # Node ID 9f69fbf5cae620e7be392fa002fdb22d2514493a # Parent 2db4c1158df99875e2eb2312abf03e99df89a059 Switch -vf halfpack to use only public API of libswscale. diff -r 2db4c1158df9 -r 9f69fbf5cae6 libmpcodecs/vf_halfpack.c --- a/libmpcodecs/vf_halfpack.c Sat Jan 23 19:00:09 2010 +0000 +++ b/libmpcodecs/vf_halfpack.c Sat Jan 23 23:50:25 2010 +0000 @@ -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 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 @@ 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 @@ 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 void uninit(struct vf_instance_s* vf) { + sws_freeContext(vf->priv->ctx); free(vf->priv); }