2 Copyright (C) 2002 Michael Niedermayer <michaelni@gmx.at>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
32 #include "img_format.h"
35 #include "libvo/fastmemcpy.h"
38 //===========================================================================//
40 typedef struct FilterParam
{
46 FilterParam lumaParam
;
47 FilterParam chromaParam
;
50 /***************************************************************************/
52 static void interleave(uint8_t *dst
, uint8_t *src
, int w
, int h
, int dstStride
, int srcStride
, int interleave
, int swap
){
61 fast_memcpy(dst
+ dstStride
* y
, src
+ srcStride
*(y
*2 + a
), w
);
62 fast_memcpy(dst
+ dstStride
*(y
+ m
), src
+ srcStride
*(y
*2 + b
), w
);
67 fast_memcpy(dst
+ dstStride
* y
*2 , src
+ srcStride
*(y
*2 + a
), w
);
68 fast_memcpy(dst
+ dstStride
*(y
*2+1), src
+ srcStride
*(y
*2 + b
), w
);
73 fast_memcpy(dst
+ dstStride
*(y
*2+a
), src
+ srcStride
* y
, w
);
74 fast_memcpy(dst
+ dstStride
*(y
*2+b
), src
+ srcStride
*(y
+ m
), w
);
80 static int put_image(struct vf_instance_s
* vf
, mp_image_t
*mpi
, double pts
){
82 FilterParam
*luma
= &vf
->priv
->lumaParam
;
83 FilterParam
*chroma
= &vf
->priv
->chromaParam
;
85 mp_image_t
*dmpi
=vf_get_image(vf
->next
,mpi
->imgfmt
,
86 MP_IMGTYPE_TEMP
, MP_IMGFLAG_ACCEPT_STRIDE
,
89 if(mpi
->flags
&MP_IMGFLAG_PLANAR
)
92 w
= mpi
->w
* mpi
->bpp
/8;
94 interleave(dmpi
->planes
[0], mpi
->planes
[0],
95 w
, mpi
->h
, dmpi
->stride
[0], mpi
->stride
[0], luma
->interleave
, luma
->swap
);
97 if(mpi
->flags
&MP_IMGFLAG_PLANAR
){
98 int cw
= mpi
->w
>> mpi
->chroma_x_shift
;
99 int ch
= mpi
->h
>> mpi
->chroma_y_shift
;
101 interleave(dmpi
->planes
[1], mpi
->planes
[1], cw
,ch
,
102 dmpi
->stride
[1], mpi
->stride
[1], chroma
->interleave
, luma
->swap
);
103 interleave(dmpi
->planes
[2], mpi
->planes
[2], cw
,ch
,
104 dmpi
->stride
[2], mpi
->stride
[2], chroma
->interleave
, luma
->swap
);
107 return vf_next_put_image(vf
,dmpi
, pts
);
110 //===========================================================================//
112 static void parse(FilterParam
*fp
, char* args
){
114 char *max
= strchr(args
, ':');
116 if(!max
) max
= args
+ strlen(args
);
118 pos
= strchr(args
, 's');
119 if(pos
&& pos
<max
) fp
->swap
=1;
120 pos
= strchr(args
, 'i');
121 if(pos
&& pos
<max
) fp
->interleave
=1;
122 pos
= strchr(args
, 'd');
123 if(pos
&& pos
<max
) fp
->interleave
=-1;
126 static int open(vf_instance_t
*vf
, char* args
){
128 vf
->put_image
=put_image
;
129 // vf->get_image=get_image;
130 vf
->priv
=malloc(sizeof(struct vf_priv_s
));
131 memset(vf
->priv
, 0, sizeof(struct vf_priv_s
));
135 char *arg2
= strchr(args
,':');
136 if(arg2
) parse(&vf
->priv
->chromaParam
, arg2
+1);
137 parse(&vf
->priv
->lumaParam
, args
);
143 const vf_info_t vf_info_il
= {
146 "Michael Niedermayer",
152 //===========================================================================//