annotate libmpcodecs/vf_mirror.c @ 6506:f0788e0f7475

SVQ1 added
author arpi
date Sat, 22 Jun 2002 23:09:40 +0000
parents cfb787b821a0
children 79b536a37e40
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){
5772
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
18 int y;
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
19 for(y=0;y<h;y++){
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
20 int x;
5763
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
21 switch(bpp){
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
22 case 1:
5772
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
23 for(x=0;x<w;x++) dst[x]=src[w-x-1];
5763
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
24 break;
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
25 case 2:
5772
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
26 for(x=0;x<w;x++) *((short*)(dst+x*2))=*((short*)(src+(w-x-1)*2));
5763
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
27 break;
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
28 case 3:
5772
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
29 for(x=0;x<w;x++){
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
30 dst[x*3+0]=src[0+(w-x-1)*3];
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
31 dst[x*3+1]=src[1+(w-x-1)*3];
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
32 dst[x*3+2]=src[2+(w-x-1)*3];
5763
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
33 }
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
34 break;
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
35 case 4:
5772
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
36 for(x=0;x<w;x++) *((int*)(dst+x*4))=*((int*)(src+(w-x-1)*4));
5763
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
37 }
5772
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
38 src+=srcstride;
5763
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
39 dst+=dststride;
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
40 }
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 static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
46 mp_image_t *dmpi;
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
47
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
48 // hope we'll get DR buffer:
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
49 dmpi=vf_get_image(vf->next,mpi->imgfmt,
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
50 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
51 mpi->w, mpi->h);
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
52
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
53 if(mpi->flags&MP_IMGFLAG_PLANAR){
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
54 mirror(dmpi->planes[0],mpi->planes[0],
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
55 dmpi->stride[0],mpi->stride[0],
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
56 dmpi->w,dmpi->h,1);
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
57 mirror(dmpi->planes[1],mpi->planes[1],
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
58 dmpi->stride[1],mpi->stride[1],
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
59 dmpi->w>>1,dmpi->h>>1,1);
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
60 mirror(dmpi->planes[2],mpi->planes[2],
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
61 dmpi->stride[2],mpi->stride[2],
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
62 dmpi->w>>1,dmpi->h>>1,1);
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
63 } else {
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
64 mirror(dmpi->planes[0],mpi->planes[0],
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
65 dmpi->stride[0],mpi->stride[0],
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
66 dmpi->w,dmpi->h,dmpi->bpp>>3);
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
67 }
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
68
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
69 vf_next_put_image(vf,dmpi);
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
70 }
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
71
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 static int open(vf_instance_t *vf, char* args){
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
75 //vf->config=config;
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
76 vf->put_image=put_image;
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
77 return 1;
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
78 }
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
79
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
80 vf_info_t vf_info_mirror = {
5772
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
81 "horizontal mirror",
5763
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
82 "mirror",
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
83 "Eyck",
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
84 "",
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
85 open
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
86 };
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
87
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
88 //===========================================================================//