Mercurial > mplayer.hg
annotate libmpcodecs/vf_mirror.c @ 11093:8be133777791
Errare humanum est. Buxfixes, now compile ok.
author | nauj27 |
---|---|
date | Sun, 12 Oct 2003 23:34:06 +0000 |
parents | e9a2af584986 |
children | 6ff3379a0862 |
rev | line source |
---|---|
5763 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 #include <string.h> | |
4 #include <inttypes.h> | |
5 | |
6 #include "../config.h" | |
7 #include "../mp_msg.h" | |
8 | |
9 #include "img_format.h" | |
10 #include "mp_image.h" | |
11 #include "vf.h" | |
12 | |
13 #include "../libvo/fastmemcpy.h" | |
14 #include "../postproc/rgb2rgb.h" | |
15 | |
16 | |
8748 | 17 static void mirror(unsigned char* dst,unsigned char* src,int dststride,int srcstride,int w,int h,int bpp,unsigned int fmt){ |
5772 | 18 int y; |
19 for(y=0;y<h;y++){ | |
20 int x; | |
5763 | 21 switch(bpp){ |
22 case 1: | |
5772 | 23 for(x=0;x<w;x++) dst[x]=src[w-x-1]; |
5763 | 24 break; |
25 case 2: | |
8748 | 26 switch(fmt){ |
27 case IMGFMT_UYVY: { | |
28 // packed YUV is tricky. U,V are 32bpp while Y is 16bpp: | |
29 int w2=w>>1; | |
30 for(x=0;x<w2;x++){ | |
31 // TODO: optimize this... | |
32 dst[x*4+0]=src[0+(w2-x-1)*4]; | |
33 dst[x*4+1]=src[3+(w2-x-1)*4]; | |
34 dst[x*4+2]=src[2+(w2-x-1)*4]; | |
35 dst[x*4+3]=src[1+(w2-x-1)*4]; | |
36 } | |
37 break; } | |
38 case IMGFMT_YUY2: | |
39 case IMGFMT_YVYU: { | |
40 // packed YUV is tricky. U,V are 32bpp while Y is 16bpp: | |
41 int w2=w>>1; | |
42 for(x=0;x<w2;x++){ | |
43 // TODO: optimize this... | |
44 dst[x*4+0]=src[2+(w2-x-1)*4]; | |
45 dst[x*4+1]=src[1+(w2-x-1)*4]; | |
46 dst[x*4+2]=src[0+(w2-x-1)*4]; | |
47 dst[x*4+3]=src[3+(w2-x-1)*4]; | |
48 } | |
49 break; } | |
50 default: | |
51 for(x=0;x<w;x++) *((short*)(dst+x*2))=*((short*)(src+(w-x-1)*2)); | |
52 } | |
5763 | 53 break; |
54 case 3: | |
5772 | 55 for(x=0;x<w;x++){ |
56 dst[x*3+0]=src[0+(w-x-1)*3]; | |
57 dst[x*3+1]=src[1+(w-x-1)*3]; | |
58 dst[x*3+2]=src[2+(w-x-1)*3]; | |
5763 | 59 } |
60 break; | |
61 case 4: | |
5772 | 62 for(x=0;x<w;x++) *((int*)(dst+x*4))=*((int*)(src+(w-x-1)*4)); |
5763 | 63 } |
5772 | 64 src+=srcstride; |
5763 | 65 dst+=dststride; |
66 } | |
67 } | |
68 | |
69 //===========================================================================// | |
70 | |
7368 | 71 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){ |
5763 | 72 mp_image_t *dmpi; |
73 | |
74 // hope we'll get DR buffer: | |
75 dmpi=vf_get_image(vf->next,mpi->imgfmt, | |
76 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, | |
77 mpi->w, mpi->h); | |
78 | |
79 if(mpi->flags&MP_IMGFLAG_PLANAR){ | |
80 mirror(dmpi->planes[0],mpi->planes[0], | |
81 dmpi->stride[0],mpi->stride[0], | |
8748 | 82 dmpi->w,dmpi->h,1,mpi->imgfmt); |
5763 | 83 mirror(dmpi->planes[1],mpi->planes[1], |
84 dmpi->stride[1],mpi->stride[1], | |
8748 | 85 dmpi->w>>mpi->chroma_x_shift,dmpi->h>>mpi->chroma_y_shift,1,mpi->imgfmt); |
5763 | 86 mirror(dmpi->planes[2],mpi->planes[2], |
87 dmpi->stride[2],mpi->stride[2], | |
8748 | 88 dmpi->w>>mpi->chroma_x_shift,dmpi->h>>mpi->chroma_y_shift,1,mpi->imgfmt); |
5763 | 89 } else { |
90 mirror(dmpi->planes[0],mpi->planes[0], | |
91 dmpi->stride[0],mpi->stride[0], | |
8748 | 92 dmpi->w,dmpi->h,dmpi->bpp>>3,mpi->imgfmt); |
9279 | 93 dmpi->planes[1]=mpi->planes[1]; // passthrough rgb8 palette |
5763 | 94 } |
95 | |
7368 | 96 return vf_next_put_image(vf,dmpi); |
5763 | 97 } |
98 | |
99 //===========================================================================// | |
100 | |
101 static int open(vf_instance_t *vf, char* args){ | |
102 //vf->config=config; | |
103 vf->put_image=put_image; | |
104 return 1; | |
105 } | |
106 | |
107 vf_info_t vf_info_mirror = { | |
5772 | 108 "horizontal mirror", |
5763 | 109 "mirror", |
110 "Eyck", | |
111 "", | |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9279
diff
changeset
|
112 open, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9279
diff
changeset
|
113 NULL |
5763 | 114 }; |
115 | |
116 //===========================================================================// |