2 * This file is part of MPlayer.
4 * MPlayer 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 * MPlayer 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 along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #include "img_format.h"
32 static void mirror(unsigned char* dst,unsigned char* src,int dststride,int srcstride,int w,int h,int bpp,unsigned int fmt){
38 for(x=0;x<w;x++) dst[x]=src[w-x-1];
43 // packed YUV is tricky. U,V are 32bpp while Y is 16bpp:
46 // TODO: optimize this...
47 dst[x*4+0]=src[0+(w2-x-1)*4];
48 dst[x*4+1]=src[3+(w2-x-1)*4];
49 dst[x*4+2]=src[2+(w2-x-1)*4];
50 dst[x*4+3]=src[1+(w2-x-1)*4];
55 // packed YUV is tricky. U,V are 32bpp while Y is 16bpp:
58 // TODO: optimize this...
59 dst[x*4+0]=src[2+(w2-x-1)*4];
60 dst[x*4+1]=src[1+(w2-x-1)*4];
61 dst[x*4+2]=src[0+(w2-x-1)*4];
62 dst[x*4+3]=src[3+(w2-x-1)*4];
66 for(x=0;x<w;x++) *((short*)(dst+x*2))=*((short*)(src+(w-x-1)*2));
71 dst[x*3+0]=src[0+(w-x-1)*3];
72 dst[x*3+1]=src[1+(w-x-1)*3];
73 dst[x*3+2]=src[2+(w-x-1)*3];
77 for(x=0;x<w;x++) *((int*)(dst+x*4))=*((int*)(src+(w-x-1)*4));
84 //===========================================================================//
86 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
89 // hope we'll get DR buffer:
90 dmpi=vf_get_image(vf->next,mpi->imgfmt,
91 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
94 if(mpi->flags&MP_IMGFLAG_PLANAR){
95 mirror(dmpi->planes[0],mpi->planes[0],
96 dmpi->stride[0],mpi->stride[0],
97 dmpi->w,dmpi->h,1,mpi->imgfmt);
98 mirror(dmpi->planes[1],mpi->planes[1],
99 dmpi->stride[1],mpi->stride[1],
100 dmpi->w>>mpi->chroma_x_shift,dmpi->h>>mpi->chroma_y_shift,1,mpi->imgfmt);
101 mirror(dmpi->planes[2],mpi->planes[2],
102 dmpi->stride[2],mpi->stride[2],
103 dmpi->w>>mpi->chroma_x_shift,dmpi->h>>mpi->chroma_y_shift,1,mpi->imgfmt);
105 mirror(dmpi->planes[0],mpi->planes[0],
106 dmpi->stride[0],mpi->stride[0],
107 dmpi->w,dmpi->h,dmpi->bpp>>3,mpi->imgfmt);
108 dmpi->planes[1]=mpi->planes[1]; // passthrough rgb8 palette
111 return vf_next_put_image(vf,dmpi, pts);
114 //===========================================================================//
116 static int vf_open(vf_instance_t *vf, char *args){
118 vf->put_image=put_image;
122 const vf_info_t vf_info_mirror = {
131 //===========================================================================//