annotate libmpcodecs/vf_mirror.c @ 5763:e9fb293c53d2

Complement existing filters - rotate and flip.
author eyck
date Sun, 21 Apr 2002 14:36:36 +0000
parents
children cfb787b821a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5763
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
1 #include <stdio.h>
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
2 #include <stdlib.h>
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
3 #include <string.h>
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
4 #include <inttypes.h>
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
5
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
6 #include "../config.h"
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
7 #include "../mp_msg.h"
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
8
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
9 #include "img_format.h"
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
10 #include "mp_image.h"
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
11 #include "vf.h"
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
12
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
13 #include "../libvo/fastmemcpy.h"
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
14 #include "../postproc/rgb2rgb.h"
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
15
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
16
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
17 static void mirror(unsigned char* dst,unsigned char* src,int dststride,int srcstride,int w,int h,int bpp){
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
18 int x;
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
19
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
20 //
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
21 for(x=0;x<h;x++){
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
22 int y;
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
23 switch(bpp){
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
24 case 1:
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
25 for(y=0;y<w;y++) dst[y]=src[w-y-1+x*srcstride];
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
26 break;
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
27 case 2:
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
28 for(y=0;y<w;y++) *((short*)(dst+y*2))=*((short*)(src+w-y*2-1+x*srcstride));
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
29 break;
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
30 case 3:
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
31 for(y=0;y<w;y++){
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
32 dst[y*3+0]=src[0+w-y*3-1+x*srcstride];
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
33 dst[y*3+1]=src[1+w-y*3-1+x*srcstride];
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
34 dst[y*3+2]=src[2+w-y*3-1+x*srcstride];
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
35 }
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
36 break;
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
37 case 4:
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
38 for(y=0;y<w;y++) *((int*)(dst+y*4))=*((int*)(src+w-y*4-1+x*srcstride));
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
39 }
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
40 dst+=dststride;
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
41 }
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
42
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
43 //
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
44
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
45 }
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
46
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
47 //===========================================================================//
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
48
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
49 static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
50 mp_image_t *dmpi;
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
51
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
52 // hope we'll get DR buffer:
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
53 dmpi=vf_get_image(vf->next,mpi->imgfmt,
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
54 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
55 mpi->w, mpi->h);
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
56 //mpi->h, mpi->w);
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
57
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
58 if(mpi->flags&MP_IMGFLAG_PLANAR){
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
59 mirror(dmpi->planes[0],mpi->planes[0],
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
60 dmpi->stride[0],mpi->stride[0],
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
61 dmpi->w,dmpi->h,1);
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
62 mirror(dmpi->planes[1],mpi->planes[1],
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
63 dmpi->stride[1],mpi->stride[1],
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
64 dmpi->w>>1,dmpi->h>>1,1);
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
65 mirror(dmpi->planes[2],mpi->planes[2],
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
66 dmpi->stride[2],mpi->stride[2],
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
67 dmpi->w>>1,dmpi->h>>1,1);
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
68 } else {
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
69 mirror(dmpi->planes[0],mpi->planes[0],
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
70 dmpi->stride[0],mpi->stride[0],
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
71 dmpi->w,dmpi->h,dmpi->bpp>>3);
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
72 }
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
73
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
74 vf_next_put_image(vf,dmpi);
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
75 }
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
76
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
77 //===========================================================================//
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
78
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
79 static int open(vf_instance_t *vf, char* args){
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
80 //vf->config=config;
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
81 vf->put_image=put_image;
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
82 return 1;
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
83 }
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
84
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
85 vf_info_t vf_info_mirror = {
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
86 "mirror",
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
87 "mirror",
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
88 "Eyck",
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
89 "",
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
90 open
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
91 };
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
92
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
93 //===========================================================================//