Mercurial > mplayer.hg
annotate libmpcodecs/vf_mirror.c @ 21555:ababf115f90d
Avoid deprecated _sleep, instead include windows.h and use Sleep just like
osdep/timer-win2.c does.
Patch by Zuxy Meng [zuxy meng (at) gmail com]
author | reimar |
---|---|
date | Sun, 10 Dec 2006 14:04:27 +0000 |
parents | 497ebe3ecc2b |
children | f8d4f8eff72b |
rev | line source |
---|---|
5763 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 #include <string.h> | |
4 #include <inttypes.h> | |
5 | |
17012 | 6 #include "config.h" |
7 #include "mp_msg.h" | |
5763 | 8 |
9 #include "img_format.h" | |
10 #include "mp_image.h" | |
11 #include "vf.h" | |
12 | |
17012 | 13 #include "libvo/fastmemcpy.h" |
5763 | 14 |
15 | |
8748 | 16 static void mirror(unsigned char* dst,unsigned char* src,int dststride,int srcstride,int w,int h,int bpp,unsigned int fmt){ |
5772 | 17 int y; |
18 for(y=0;y<h;y++){ | |
19 int x; | |
5763 | 20 switch(bpp){ |
21 case 1: | |
5772 | 22 for(x=0;x<w;x++) dst[x]=src[w-x-1]; |
5763 | 23 break; |
24 case 2: | |
8748 | 25 switch(fmt){ |
26 case IMGFMT_UYVY: { | |
27 // packed YUV is tricky. U,V are 32bpp while Y is 16bpp: | |
28 int w2=w>>1; | |
29 for(x=0;x<w2;x++){ | |
30 // TODO: optimize this... | |
31 dst[x*4+0]=src[0+(w2-x-1)*4]; | |
32 dst[x*4+1]=src[3+(w2-x-1)*4]; | |
33 dst[x*4+2]=src[2+(w2-x-1)*4]; | |
34 dst[x*4+3]=src[1+(w2-x-1)*4]; | |
35 } | |
36 break; } | |
37 case IMGFMT_YUY2: | |
38 case IMGFMT_YVYU: { | |
39 // packed YUV is tricky. U,V are 32bpp while Y is 16bpp: | |
40 int w2=w>>1; | |
41 for(x=0;x<w2;x++){ | |
42 // TODO: optimize this... | |
43 dst[x*4+0]=src[2+(w2-x-1)*4]; | |
44 dst[x*4+1]=src[1+(w2-x-1)*4]; | |
45 dst[x*4+2]=src[0+(w2-x-1)*4]; | |
46 dst[x*4+3]=src[3+(w2-x-1)*4]; | |
47 } | |
48 break; } | |
49 default: | |
50 for(x=0;x<w;x++) *((short*)(dst+x*2))=*((short*)(src+(w-x-1)*2)); | |
51 } | |
5763 | 52 break; |
53 case 3: | |
5772 | 54 for(x=0;x<w;x++){ |
55 dst[x*3+0]=src[0+(w-x-1)*3]; | |
56 dst[x*3+1]=src[1+(w-x-1)*3]; | |
57 dst[x*3+2]=src[2+(w-x-1)*3]; | |
5763 | 58 } |
59 break; | |
60 case 4: | |
5772 | 61 for(x=0;x<w;x++) *((int*)(dst+x*4))=*((int*)(src+(w-x-1)*4)); |
5763 | 62 } |
5772 | 63 src+=srcstride; |
5763 | 64 dst+=dststride; |
65 } | |
66 } | |
67 | |
68 //===========================================================================// | |
69 | |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17012
diff
changeset
|
70 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ |
5763 | 71 mp_image_t *dmpi; |
72 | |
73 // hope we'll get DR buffer: | |
74 dmpi=vf_get_image(vf->next,mpi->imgfmt, | |
75 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, | |
76 mpi->w, mpi->h); | |
77 | |
78 if(mpi->flags&MP_IMGFLAG_PLANAR){ | |
79 mirror(dmpi->planes[0],mpi->planes[0], | |
80 dmpi->stride[0],mpi->stride[0], | |
8748 | 81 dmpi->w,dmpi->h,1,mpi->imgfmt); |
5763 | 82 mirror(dmpi->planes[1],mpi->planes[1], |
83 dmpi->stride[1],mpi->stride[1], | |
8748 | 84 dmpi->w>>mpi->chroma_x_shift,dmpi->h>>mpi->chroma_y_shift,1,mpi->imgfmt); |
5763 | 85 mirror(dmpi->planes[2],mpi->planes[2], |
86 dmpi->stride[2],mpi->stride[2], | |
8748 | 87 dmpi->w>>mpi->chroma_x_shift,dmpi->h>>mpi->chroma_y_shift,1,mpi->imgfmt); |
5763 | 88 } else { |
89 mirror(dmpi->planes[0],mpi->planes[0], | |
90 dmpi->stride[0],mpi->stride[0], | |
8748 | 91 dmpi->w,dmpi->h,dmpi->bpp>>3,mpi->imgfmt); |
9279 | 92 dmpi->planes[1]=mpi->planes[1]; // passthrough rgb8 palette |
5763 | 93 } |
94 | |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17012
diff
changeset
|
95 return vf_next_put_image(vf,dmpi, pts); |
5763 | 96 } |
97 | |
98 //===========================================================================// | |
99 | |
100 static int open(vf_instance_t *vf, char* args){ | |
101 //vf->config=config; | |
102 vf->put_image=put_image; | |
103 return 1; | |
104 } | |
105 | |
106 vf_info_t vf_info_mirror = { | |
5772 | 107 "horizontal mirror", |
5763 | 108 "mirror", |
109 "Eyck", | |
110 "", | |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9279
diff
changeset
|
111 open, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9279
diff
changeset
|
112 NULL |
5763 | 113 }; |
114 | |
115 //===========================================================================// |