Mercurial > mplayer.hg
annotate libmpcodecs/vf_mirror.c @ 23388:f607bb147a88
r23325: dv does not support YVU9
r23367: little alignment fixes
r23370: (does not apply)
author | kraymer |
---|---|
date | Tue, 29 May 2007 08:45:47 +0000 |
parents | f8d4f8eff72b |
children | 00fff9a3b735 |
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 | |
13 | |
8748 | 14 static void mirror(unsigned char* dst,unsigned char* src,int dststride,int srcstride,int w,int h,int bpp,unsigned int fmt){ |
5772 | 15 int y; |
16 for(y=0;y<h;y++){ | |
17 int x; | |
5763 | 18 switch(bpp){ |
19 case 1: | |
5772 | 20 for(x=0;x<w;x++) dst[x]=src[w-x-1]; |
5763 | 21 break; |
22 case 2: | |
8748 | 23 switch(fmt){ |
24 case IMGFMT_UYVY: { | |
25 // packed YUV is tricky. U,V are 32bpp while Y is 16bpp: | |
26 int w2=w>>1; | |
27 for(x=0;x<w2;x++){ | |
28 // TODO: optimize this... | |
29 dst[x*4+0]=src[0+(w2-x-1)*4]; | |
30 dst[x*4+1]=src[3+(w2-x-1)*4]; | |
31 dst[x*4+2]=src[2+(w2-x-1)*4]; | |
32 dst[x*4+3]=src[1+(w2-x-1)*4]; | |
33 } | |
34 break; } | |
35 case IMGFMT_YUY2: | |
36 case IMGFMT_YVYU: { | |
37 // packed YUV is tricky. U,V are 32bpp while Y is 16bpp: | |
38 int w2=w>>1; | |
39 for(x=0;x<w2;x++){ | |
40 // TODO: optimize this... | |
41 dst[x*4+0]=src[2+(w2-x-1)*4]; | |
42 dst[x*4+1]=src[1+(w2-x-1)*4]; | |
43 dst[x*4+2]=src[0+(w2-x-1)*4]; | |
44 dst[x*4+3]=src[3+(w2-x-1)*4]; | |
45 } | |
46 break; } | |
47 default: | |
48 for(x=0;x<w;x++) *((short*)(dst+x*2))=*((short*)(src+(w-x-1)*2)); | |
49 } | |
5763 | 50 break; |
51 case 3: | |
5772 | 52 for(x=0;x<w;x++){ |
53 dst[x*3+0]=src[0+(w-x-1)*3]; | |
54 dst[x*3+1]=src[1+(w-x-1)*3]; | |
55 dst[x*3+2]=src[2+(w-x-1)*3]; | |
5763 | 56 } |
57 break; | |
58 case 4: | |
5772 | 59 for(x=0;x<w;x++) *((int*)(dst+x*4))=*((int*)(src+(w-x-1)*4)); |
5763 | 60 } |
5772 | 61 src+=srcstride; |
5763 | 62 dst+=dststride; |
63 } | |
64 } | |
65 | |
66 //===========================================================================// | |
67 | |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17012
diff
changeset
|
68 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ |
5763 | 69 mp_image_t *dmpi; |
70 | |
71 // hope we'll get DR buffer: | |
72 dmpi=vf_get_image(vf->next,mpi->imgfmt, | |
73 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, | |
74 mpi->w, mpi->h); | |
75 | |
76 if(mpi->flags&MP_IMGFLAG_PLANAR){ | |
77 mirror(dmpi->planes[0],mpi->planes[0], | |
78 dmpi->stride[0],mpi->stride[0], | |
8748 | 79 dmpi->w,dmpi->h,1,mpi->imgfmt); |
5763 | 80 mirror(dmpi->planes[1],mpi->planes[1], |
81 dmpi->stride[1],mpi->stride[1], | |
8748 | 82 dmpi->w>>mpi->chroma_x_shift,dmpi->h>>mpi->chroma_y_shift,1,mpi->imgfmt); |
5763 | 83 mirror(dmpi->planes[2],mpi->planes[2], |
84 dmpi->stride[2],mpi->stride[2], | |
8748 | 85 dmpi->w>>mpi->chroma_x_shift,dmpi->h>>mpi->chroma_y_shift,1,mpi->imgfmt); |
5763 | 86 } else { |
87 mirror(dmpi->planes[0],mpi->planes[0], | |
88 dmpi->stride[0],mpi->stride[0], | |
8748 | 89 dmpi->w,dmpi->h,dmpi->bpp>>3,mpi->imgfmt); |
9279 | 90 dmpi->planes[1]=mpi->planes[1]; // passthrough rgb8 palette |
5763 | 91 } |
92 | |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17012
diff
changeset
|
93 return vf_next_put_image(vf,dmpi, pts); |
5763 | 94 } |
95 | |
96 //===========================================================================// | |
97 | |
98 static int open(vf_instance_t *vf, char* args){ | |
99 //vf->config=config; | |
100 vf->put_image=put_image; | |
101 return 1; | |
102 } | |
103 | |
104 vf_info_t vf_info_mirror = { | |
5772 | 105 "horizontal mirror", |
5763 | 106 "mirror", |
107 "Eyck", | |
108 "", | |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9279
diff
changeset
|
109 open, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9279
diff
changeset
|
110 NULL |
5763 | 111 }; |
112 | |
113 //===========================================================================// |