adding the code documentation guide lines
[mplayer/glamo.git] / libmpcodecs / vf_field.c
blob86a3fc87dee1cbce36b39785ae0ad154049b292e
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 #include "../libvo/fastmemcpy.h"
13 struct vf_priv_s {
14 int field;
17 //===========================================================================//
19 static int config(struct vf_instance_s* vf,
20 int width, int height, int d_width, int d_height,
21 unsigned int flags, unsigned int outfmt){
22 return vf_next_config(vf,width,height/2,d_width,d_height,flags,outfmt);
25 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
26 if(mpi->flags&MP_IMGFLAG_DIRECT){
27 // we've used DR, so we're ready...
28 return vf_next_put_image(vf,(mp_image_t*)mpi->priv);
31 vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
32 MP_IMGTYPE_EXPORT, MP_IMGFLAG_ACCEPT_STRIDE,
33 mpi->width, mpi->height/2);
35 // set up mpi as a double-stride image of dmpi:
36 vf->dmpi->planes[0]=mpi->planes[0]+mpi->stride[0]*vf->priv->field;
37 vf->dmpi->stride[0]=2*mpi->stride[0];
38 if(vf->dmpi->flags&MP_IMGFLAG_PLANAR){
39 vf->dmpi->planes[1]=mpi->planes[1]+
40 mpi->stride[1]*vf->priv->field;
41 vf->dmpi->stride[1]=2*mpi->stride[1];
42 vf->dmpi->planes[2]=mpi->planes[2]+
43 mpi->stride[2]*vf->priv->field;
44 vf->dmpi->stride[2]=2*mpi->stride[2];
45 } else
46 vf->dmpi->planes[1]=mpi->planes[1]; // passthru bgr8 palette!!!
48 return vf_next_put_image(vf,vf->dmpi);
51 //===========================================================================//
53 static void uninit(struct vf_instance_s* vf)
55 free(vf->priv);
58 static int open(vf_instance_t *vf, char* args){
59 vf->config=config;
60 vf->put_image=put_image;
61 vf->uninit=uninit;
62 vf->default_reqs=VFCAP_ACCEPT_STRIDE;
63 vf->priv=calloc(1, sizeof(struct vf_priv_s));
64 if (args) sscanf(args, "%d", &vf->priv->field);
65 vf->priv->field &= 1;
66 return 1;
69 vf_info_t vf_info_field = {
70 "extract single field",
71 "field",
72 "Rich Felker",
73 "",
74 open,
75 NULL
78 //===========================================================================//