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);
|
5763
|
93 }
|
|
94
|
7368
|
95 return vf_next_put_image(vf,dmpi);
|
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 "",
|
|
111 open
|
|
112 };
|
|
113
|
|
114 //===========================================================================//
|