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
This commit is contained in:
reimar 2010-01-23 23:50:25 +00:00
parent cbcae4856c
commit 4e90199d2e
1 changed files with 20 additions and 4 deletions

View File

@ -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);
}