00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 #include <stdio.h>
00020 #include <stdlib.h>
00021 #include <string.h>
00022 
00023 #include "config.h"
00024 #include "mp_msg.h"
00025 
00026 #include "mp_image.h"
00027 #include "vf.h"
00028 
00029 struct vf_priv_s {
00030     int field;
00031 };
00032 
00033 
00034 
00035 static int config(struct vf_instance *vf,
00036         int width, int height, int d_width, int d_height,
00037         unsigned int flags, unsigned int outfmt){
00038     return vf_next_config(vf,width,height/2,d_width,d_height,flags,outfmt);
00039 }
00040 
00041 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
00042     vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
00043         MP_IMGTYPE_EXPORT, MP_IMGFLAG_ACCEPT_STRIDE,
00044         mpi->width, mpi->height/2);
00045 
00046     
00047     vf->dmpi->planes[0]=mpi->planes[0]+mpi->stride[0]*vf->priv->field;
00048     vf->dmpi->stride[0]=2*mpi->stride[0];
00049     if(vf->dmpi->flags&MP_IMGFLAG_PLANAR){
00050         vf->dmpi->planes[1]=mpi->planes[1]+
00051             mpi->stride[1]*vf->priv->field;
00052         vf->dmpi->stride[1]=2*mpi->stride[1];
00053         vf->dmpi->planes[2]=mpi->planes[2]+
00054             mpi->stride[2]*vf->priv->field;
00055         vf->dmpi->stride[2]=2*mpi->stride[2];
00056     } else
00057         vf->dmpi->planes[1]=mpi->planes[1]; 
00058 
00059     return vf_next_put_image(vf,vf->dmpi, pts);
00060 }
00061 
00062 
00063 
00064 static void uninit(struct vf_instance *vf)
00065 {
00066         free(vf->priv);
00067 }
00068 
00069 static int vf_open(vf_instance_t *vf, char *args){
00070     vf->config=config;
00071     vf->put_image=put_image;
00072     vf->uninit=uninit;
00073     vf->default_reqs=VFCAP_ACCEPT_STRIDE;
00074     vf->priv=calloc(1, sizeof(struct vf_priv_s));
00075     if (args) sscanf(args, "%d", &vf->priv->field);
00076     vf->priv->field &= 1;
00077     return 1;
00078 }
00079 
00080 const vf_info_t vf_info_field = {
00081     "extract single field",
00082     "field",
00083     "Rich Felker",
00084     "",
00085     vf_open,
00086     NULL
00087 };
00088 
00089