Static pthread support
[mplayer/kovensky.git] / libmpcodecs / vf_field.c
blob48e4cb0f2105f06c625803099836b513bff6c6d8
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
5 #include "config.h"
6 #include "mp_msg.h"
8 #include "mp_image.h"
9 #include "vf.h"
11 struct vf_priv_s {
12 int field;
15 //===========================================================================//
17 static int config(struct vf_instance* vf,
18 int width, int height, int d_width, int d_height,
19 unsigned int flags, unsigned int outfmt){
20 return vf_next_config(vf,width,height/2,d_width,d_height,flags,outfmt);
23 static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
24 vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
25 MP_IMGTYPE_EXPORT, MP_IMGFLAG_ACCEPT_STRIDE,
26 mpi->width, mpi->height/2);
28 // set up mpi as a double-stride image of dmpi:
29 vf->dmpi->planes[0]=mpi->planes[0]+mpi->stride[0]*vf->priv->field;
30 vf->dmpi->stride[0]=2*mpi->stride[0];
31 if(vf->dmpi->flags&MP_IMGFLAG_PLANAR){
32 vf->dmpi->planes[1]=mpi->planes[1]+
33 mpi->stride[1]*vf->priv->field;
34 vf->dmpi->stride[1]=2*mpi->stride[1];
35 vf->dmpi->planes[2]=mpi->planes[2]+
36 mpi->stride[2]*vf->priv->field;
37 vf->dmpi->stride[2]=2*mpi->stride[2];
38 } else
39 vf->dmpi->planes[1]=mpi->planes[1]; // passthru bgr8 palette!!!
41 return vf_next_put_image(vf,vf->dmpi, pts);
44 //===========================================================================//
46 static void uninit(struct vf_instance* vf)
48 free(vf->priv);
51 static int open(vf_instance_t *vf, char* args){
52 vf->config=config;
53 vf->put_image=put_image;
54 vf->uninit=uninit;
55 vf->default_reqs=VFCAP_ACCEPT_STRIDE;
56 vf->priv=calloc(1, sizeof(struct vf_priv_s));
57 if (args) sscanf(args, "%d", &vf->priv->field);
58 vf->priv->field &= 1;
59 return 1;
62 const vf_info_t vf_info_field = {
63 "extract single field",
64 "field",
65 "Rich Felker",
66 "",
67 open,
68 NULL
71 //===========================================================================//