Mercurial > mplayer.hg
comparison libmpcodecs/vf_mirror.c @ 32702:7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
author | cehoyos |
---|---|
date | Fri, 14 Jan 2011 22:10:21 +0000 |
parents | a972c1a4a012 |
children |
comparison
equal
deleted
inserted
replaced
32701:02bc7c860503 | 32702:7af3e6f901fd |
---|---|
30 | 30 |
31 | 31 |
32 static void mirror(unsigned char* dst,unsigned char* src,int dststride,int srcstride,int w,int h,int bpp,unsigned int fmt){ | 32 static void mirror(unsigned char* dst,unsigned char* src,int dststride,int srcstride,int w,int h,int bpp,unsigned int fmt){ |
33 int y; | 33 int y; |
34 for(y=0;y<h;y++){ | 34 for(y=0;y<h;y++){ |
35 int x; | 35 int x; |
36 switch(bpp){ | 36 switch(bpp){ |
37 case 1: | 37 case 1: |
38 for(x=0;x<w;x++) dst[x]=src[w-x-1]; | 38 for(x=0;x<w;x++) dst[x]=src[w-x-1]; |
39 break; | 39 break; |
40 case 2: | 40 case 2: |
41 switch(fmt){ | 41 switch(fmt){ |
42 case IMGFMT_UYVY: { | 42 case IMGFMT_UYVY: { |
43 // packed YUV is tricky. U,V are 32bpp while Y is 16bpp: | 43 // packed YUV is tricky. U,V are 32bpp while Y is 16bpp: |
44 int w2=w>>1; | 44 int w2=w>>1; |
45 for(x=0;x<w2;x++){ | 45 for(x=0;x<w2;x++){ |
46 // TODO: optimize this... | 46 // TODO: optimize this... |
47 dst[x*4+0]=src[0+(w2-x-1)*4]; | 47 dst[x*4+0]=src[0+(w2-x-1)*4]; |
48 dst[x*4+1]=src[3+(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]; | 49 dst[x*4+2]=src[2+(w2-x-1)*4]; |
50 dst[x*4+3]=src[1+(w2-x-1)*4]; | 50 dst[x*4+3]=src[1+(w2-x-1)*4]; |
51 } | 51 } |
52 break; } | 52 break; } |
53 case IMGFMT_YUY2: | 53 case IMGFMT_YUY2: |
54 case IMGFMT_YVYU: { | 54 case IMGFMT_YVYU: { |
55 // packed YUV is tricky. U,V are 32bpp while Y is 16bpp: | 55 // packed YUV is tricky. U,V are 32bpp while Y is 16bpp: |
56 int w2=w>>1; | 56 int w2=w>>1; |
57 for(x=0;x<w2;x++){ | 57 for(x=0;x<w2;x++){ |
58 // TODO: optimize this... | 58 // TODO: optimize this... |
59 dst[x*4+0]=src[2+(w2-x-1)*4]; | 59 dst[x*4+0]=src[2+(w2-x-1)*4]; |
60 dst[x*4+1]=src[1+(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]; | 61 dst[x*4+2]=src[0+(w2-x-1)*4]; |
62 dst[x*4+3]=src[3+(w2-x-1)*4]; | 62 dst[x*4+3]=src[3+(w2-x-1)*4]; |
63 } | 63 } |
64 break; } | 64 break; } |
65 default: | 65 default: |
66 for(x=0;x<w;x++) *((short*)(dst+x*2))=*((short*)(src+(w-x-1)*2)); | 66 for(x=0;x<w;x++) *((short*)(dst+x*2))=*((short*)(src+(w-x-1)*2)); |
67 } | 67 } |
68 break; | 68 break; |
69 case 3: | 69 case 3: |
70 for(x=0;x<w;x++){ | 70 for(x=0;x<w;x++){ |
71 dst[x*3+0]=src[0+(w-x-1)*3]; | 71 dst[x*3+0]=src[0+(w-x-1)*3]; |
72 dst[x*3+1]=src[1+(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]; | 73 dst[x*3+2]=src[2+(w-x-1)*3]; |
74 } | 74 } |
75 break; | 75 break; |
76 case 4: | 76 case 4: |
77 for(x=0;x<w;x++) *((int*)(dst+x*4))=*((int*)(src+(w-x-1)*4)); | 77 for(x=0;x<w;x++) *((int*)(dst+x*4))=*((int*)(src+(w-x-1)*4)); |
78 } | 78 } |
79 src+=srcstride; | 79 src+=srcstride; |
80 dst+=dststride; | 80 dst+=dststride; |
81 } | 81 } |
82 } | 82 } |
83 | 83 |
84 //===========================================================================// | 84 //===========================================================================// |
85 | 85 |
86 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){ | 86 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){ |
87 mp_image_t *dmpi; | 87 mp_image_t *dmpi; |
88 | 88 |
89 // hope we'll get DR buffer: | 89 // hope we'll get DR buffer: |
90 dmpi=vf_get_image(vf->next,mpi->imgfmt, | 90 dmpi=vf_get_image(vf->next,mpi->imgfmt, |
91 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, | 91 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, |
92 mpi->w, mpi->h); | 92 mpi->w, mpi->h); |
93 | 93 |
94 if(mpi->flags&MP_IMGFLAG_PLANAR){ | 94 if(mpi->flags&MP_IMGFLAG_PLANAR){ |
95 mirror(dmpi->planes[0],mpi->planes[0], | 95 mirror(dmpi->planes[0],mpi->planes[0], |
96 dmpi->stride[0],mpi->stride[0], | 96 dmpi->stride[0],mpi->stride[0], |
97 dmpi->w,dmpi->h,1,mpi->imgfmt); | 97 dmpi->w,dmpi->h,1,mpi->imgfmt); |
98 mirror(dmpi->planes[1],mpi->planes[1], | 98 mirror(dmpi->planes[1],mpi->planes[1], |
99 dmpi->stride[1],mpi->stride[1], | 99 dmpi->stride[1],mpi->stride[1], |
100 dmpi->w>>mpi->chroma_x_shift,dmpi->h>>mpi->chroma_y_shift,1,mpi->imgfmt); | 100 dmpi->w>>mpi->chroma_x_shift,dmpi->h>>mpi->chroma_y_shift,1,mpi->imgfmt); |
101 mirror(dmpi->planes[2],mpi->planes[2], | 101 mirror(dmpi->planes[2],mpi->planes[2], |
102 dmpi->stride[2],mpi->stride[2], | 102 dmpi->stride[2],mpi->stride[2], |
103 dmpi->w>>mpi->chroma_x_shift,dmpi->h>>mpi->chroma_y_shift,1,mpi->imgfmt); | 103 dmpi->w>>mpi->chroma_x_shift,dmpi->h>>mpi->chroma_y_shift,1,mpi->imgfmt); |
104 } else { | 104 } else { |
105 mirror(dmpi->planes[0],mpi->planes[0], | 105 mirror(dmpi->planes[0],mpi->planes[0], |
106 dmpi->stride[0],mpi->stride[0], | 106 dmpi->stride[0],mpi->stride[0], |
107 dmpi->w,dmpi->h,dmpi->bpp>>3,mpi->imgfmt); | 107 dmpi->w,dmpi->h,dmpi->bpp>>3,mpi->imgfmt); |
108 dmpi->planes[1]=mpi->planes[1]; // passthrough rgb8 palette | 108 dmpi->planes[1]=mpi->planes[1]; // passthrough rgb8 palette |
109 } | 109 } |
110 | 110 |
111 return vf_next_put_image(vf,dmpi, pts); | 111 return vf_next_put_image(vf,dmpi, pts); |
112 } | 112 } |
113 | 113 |