• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

libavfilter/libmpcodecs/vf_fil.c

Go to the documentation of this file.
00001 /*
00002  * This file is part of MPlayer.
00003  *
00004  * MPlayer is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  *
00009  * MPlayer is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License along
00015  * with MPlayer; if not, write to the Free Software Foundation, Inc.,
00016  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
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 interleave;
00031     int height;
00032     int width;
00033     int stridefactor;
00034 };
00035 
00036 //===========================================================================//
00037 
00038 static int config(struct vf_instance *vf,
00039         int width, int height, int d_width, int d_height,
00040         unsigned int flags, unsigned int outfmt){
00041         int pixel_stride= (width+15)&~15; //FIXME this is ust a guess ... especially for non planar its somewhat bad one
00042 
00043 #if 0
00044     if(mpi->flags&MP_IMGFLAG_PLANAR)
00045         pixel_stride= mpi->stride[0];
00046     else
00047         pixel_stride= 8*mpi->stride[0] / mpi->bpp;
00048 
00049 #endif
00050 
00051     if(vf->priv->interleave){
00052         vf->priv->height= 2*height;
00053         vf->priv->width= width - (pixel_stride/2);
00054         vf->priv->stridefactor=1;
00055     }else{
00056         vf->priv->height= height/2;
00057         vf->priv->width= width + pixel_stride;
00058         vf->priv->stridefactor=4;
00059     }
00060 //printf("hX %d %d %d\n", vf->priv->width,vf->priv->height,vf->priv->stridefactor);
00061 
00062     return vf_next_config(vf, vf->priv->width, vf->priv->height,
00063         (d_width*vf->priv->stridefactor)>>1, 2*d_height/vf->priv->stridefactor, flags, outfmt);
00064 }
00065 
00066 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
00067     if(mpi->flags&MP_IMGFLAG_DIRECT){
00068         // we've used DR, so we're ready...
00069         return vf_next_put_image(vf,(mp_image_t*)mpi->priv, pts);
00070     }
00071 
00072     vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
00073         MP_IMGTYPE_EXPORT, MP_IMGFLAG_ACCEPT_STRIDE,
00074         vf->priv->width, vf->priv->height);
00075 
00076     // set up mpi as a double-stride image of dmpi:
00077     vf->dmpi->planes[0]=mpi->planes[0];
00078     vf->dmpi->stride[0]=(mpi->stride[0]*vf->priv->stridefactor)>>1;
00079     if(vf->dmpi->flags&MP_IMGFLAG_PLANAR){
00080         vf->dmpi->planes[1]=mpi->planes[1];
00081         vf->dmpi->stride[1]=(mpi->stride[1]*vf->priv->stridefactor)>>1;
00082         vf->dmpi->planes[2]=mpi->planes[2];
00083         vf->dmpi->stride[2]=(mpi->stride[2]*vf->priv->stridefactor)>>1;
00084     } else
00085         vf->dmpi->planes[1]=mpi->planes[1]; // passthru bgr8 palette!!!
00086 
00087     return vf_next_put_image(vf,vf->dmpi, pts);
00088 }
00089 
00090 //===========================================================================//
00091 
00092 static void uninit(struct vf_instance *vf)
00093 {
00094         free(vf->priv);
00095 }
00096 
00097 static int vf_open(vf_instance_t *vf, char *args){
00098     vf->config=config;
00099     vf->put_image=put_image;
00100     vf->uninit=uninit;
00101     vf->default_reqs=VFCAP_ACCEPT_STRIDE;
00102     vf->priv=calloc(1, sizeof(struct vf_priv_s));
00103     vf->priv->interleave= args && (*args == 'i');
00104     return 1;
00105 }
00106 
00107 const vf_info_t vf_info_fil = {
00108     "fast (de)interleaver",
00109     "fil",
00110     "Michael Niedermayer",
00111     "",
00112     vf_open,
00113     NULL
00114 };
00115 
00116 //===========================================================================//
Generated on Fri Feb 1 2013 14:34:48 for FFmpeg by doxygen 1.7.1