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

libavfilter/libmpcodecs/vf_il.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2002 Michael Niedermayer <michaelni@gmx.at>
00003  *
00004  * This file is part of MPlayer.
00005  *
00006  * MPlayer is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * MPlayer is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License along
00017  * with MPlayer; if not, write to the Free Software Foundation, Inc.,
00018  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00019  */
00020 
00021 #include <stdio.h>
00022 #include <stdlib.h>
00023 #include <string.h>
00024 #include <inttypes.h>
00025 #include <assert.h>
00026 
00027 #include "mp_msg.h"
00028 #include "img_format.h"
00029 #include "mp_image.h"
00030 #include "vf.h"
00031 #include "libvo/fastmemcpy.h"
00032 
00033 
00034 //===========================================================================//
00035 
00036 typedef struct FilterParam{
00037     int interleave;
00038     int swap;
00039 }FilterParam;
00040 
00041 struct vf_priv_s {
00042     FilterParam lumaParam;
00043     FilterParam chromaParam;
00044 };
00045 
00046 /***************************************************************************/
00047 
00048 static void interleave(uint8_t *dst, uint8_t *src, int w, int h, int dstStride, int srcStride, int interleave, int swap){
00049     const int a= swap;
00050     const int b= 1-a;
00051     const int m= h>>1;
00052     int y;
00053 
00054     switch(interleave){
00055     case -1:
00056         for(y=0; y < m; y++){
00057             fast_memcpy(dst + dstStride* y     , src + srcStride*(y*2 + a), w);
00058             fast_memcpy(dst + dstStride*(y + m), src + srcStride*(y*2 + b), w);
00059         }
00060         break;
00061     case 0:
00062         for(y=0; y < m; y++){
00063             fast_memcpy(dst + dstStride* y*2   , src + srcStride*(y*2 + a), w);
00064             fast_memcpy(dst + dstStride*(y*2+1), src + srcStride*(y*2 + b), w);
00065         }
00066         break;
00067     case 1:
00068         for(y=0; y < m; y++){
00069             fast_memcpy(dst + dstStride*(y*2+a), src + srcStride* y     , w);
00070             fast_memcpy(dst + dstStride*(y*2+b), src + srcStride*(y + m), w);
00071         }
00072         break;
00073     }
00074 }
00075 
00076 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
00077     int w;
00078     FilterParam *luma  = &vf->priv->lumaParam;
00079     FilterParam *chroma= &vf->priv->chromaParam;
00080 
00081     mp_image_t *dmpi=vf_get_image(vf->next,mpi->imgfmt,
00082         MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
00083         mpi->w,mpi->h);
00084 
00085     if(mpi->flags&MP_IMGFLAG_PLANAR)
00086         w= mpi->w;
00087     else
00088         w= mpi->w * mpi->bpp/8;
00089 
00090     interleave(dmpi->planes[0], mpi->planes[0],
00091         w, mpi->h, dmpi->stride[0], mpi->stride[0], luma->interleave, luma->swap);
00092 
00093     if(mpi->flags&MP_IMGFLAG_PLANAR){
00094         int cw= mpi->w >> mpi->chroma_x_shift;
00095         int ch= mpi->h >> mpi->chroma_y_shift;
00096 
00097         interleave(dmpi->planes[1], mpi->planes[1], cw,ch,
00098             dmpi->stride[1], mpi->stride[1], chroma->interleave, luma->swap);
00099         interleave(dmpi->planes[2], mpi->planes[2], cw,ch,
00100             dmpi->stride[2], mpi->stride[2], chroma->interleave, luma->swap);
00101     }
00102 
00103     return vf_next_put_image(vf,dmpi, pts);
00104 }
00105 
00106 //===========================================================================//
00107 
00108 static void parse(FilterParam *fp, char* args){
00109     char *pos;
00110     char *max= strchr(args, ':');
00111 
00112     if(!max) max= args + strlen(args);
00113 
00114     pos= strchr(args, 's');
00115     if(pos && pos<max) fp->swap=1;
00116     pos= strchr(args, 'i');
00117     if(pos && pos<max) fp->interleave=1;
00118     pos= strchr(args, 'd');
00119     if(pos && pos<max) fp->interleave=-1;
00120 }
00121 
00122 static int vf_open(vf_instance_t *vf, char *args){
00123 
00124     vf->put_image=put_image;
00125 //    vf->get_image=get_image;
00126     vf->priv=malloc(sizeof(struct vf_priv_s));
00127     memset(vf->priv, 0, sizeof(struct vf_priv_s));
00128 
00129     if(args)
00130     {
00131         char *arg2= strchr(args,':');
00132         if(arg2) parse(&vf->priv->chromaParam, arg2+1);
00133         parse(&vf->priv->lumaParam, args);
00134     }
00135 
00136     return 1;
00137 }
00138 
00139 const vf_info_t vf_info_il = {
00140     "(de)interleave",
00141     "il",
00142     "Michael Niedermayer",
00143     "",
00144     vf_open,
00145     NULL
00146 };
00147 
00148 //===========================================================================//
Generated on Fri Feb 1 2013 14:34:49 for FFmpeg by doxygen 1.7.1