2 * Copyright (C) 2002 Michael Niedermayer <michaelni@gmx.at>
4 * This file is part of MPlayer.
6 * MPlayer is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * MPlayer is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 #include "img_format.h"
31 #include "libvo/fastmemcpy.h"
34 //===========================================================================//
36 typedef struct FilterParam{
42 FilterParam lumaParam;
43 FilterParam chromaParam;
46 /***************************************************************************/
48 static void interleave(uint8_t *dst, uint8_t *src, int w, int h, int dstStride, int srcStride, int interleave, int swap){
57 fast_memcpy(dst + dstStride* y , src + srcStride*(y*2 + a), w);
58 fast_memcpy(dst + dstStride*(y + m), src + srcStride*(y*2 + b), w);
63 fast_memcpy(dst + dstStride* y*2 , src + srcStride*(y*2 + a), w);
64 fast_memcpy(dst + dstStride*(y*2+1), src + srcStride*(y*2 + b), w);
69 fast_memcpy(dst + dstStride*(y*2+a), src + srcStride* y , w);
70 fast_memcpy(dst + dstStride*(y*2+b), src + srcStride*(y + m), w);
76 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
78 FilterParam *luma = &vf->priv->lumaParam;
79 FilterParam *chroma= &vf->priv->chromaParam;
81 mp_image_t *dmpi=vf_get_image(vf->next,mpi->imgfmt,
82 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
85 if(mpi->flags&MP_IMGFLAG_PLANAR)
88 w= mpi->w * mpi->bpp/8;
90 interleave(dmpi->planes[0], mpi->planes[0],
91 w, mpi->h, dmpi->stride[0], mpi->stride[0], luma->interleave, luma->swap);
93 if(mpi->flags&MP_IMGFLAG_PLANAR){
94 int cw= mpi->w >> mpi->chroma_x_shift;
95 int ch= mpi->h >> mpi->chroma_y_shift;
97 interleave(dmpi->planes[1], mpi->planes[1], cw,ch,
98 dmpi->stride[1], mpi->stride[1], chroma->interleave, luma->swap);
99 interleave(dmpi->planes[2], mpi->planes[2], cw,ch,
100 dmpi->stride[2], mpi->stride[2], chroma->interleave, luma->swap);
103 return vf_next_put_image(vf,dmpi, pts);
106 //===========================================================================//
108 static void parse(FilterParam *fp, char* args){
110 char *max= strchr(args, ':');
112 if(!max) max= args + strlen(args);
114 pos= strchr(args, 's');
115 if(pos && pos<max) fp->swap=1;
116 pos= strchr(args, 'i');
117 if(pos && pos<max) fp->interleave=1;
118 pos= strchr(args, 'd');
119 if(pos && pos<max) fp->interleave=-1;
122 static int vf_open(vf_instance_t *vf, char *args){
124 vf->put_image=put_image;
125 // vf->get_image=get_image;
126 vf->priv=malloc(sizeof(struct vf_priv_s));
127 memset(vf->priv, 0, sizeof(struct vf_priv_s));
131 char *arg2= strchr(args,':');
132 if(arg2) parse(&vf->priv->chromaParam, arg2+1);
133 parse(&vf->priv->lumaParam, args);
139 const vf_info_t vf_info_il = {
142 "Michael Niedermayer",
148 //===========================================================================//