comparison 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
comparison
equal deleted inserted replaced
5762:26b3c8e7f6c8 5763:e9fb293c53d2
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
17 static void mirror(unsigned char* dst,unsigned char* src,int dststride,int srcstride,int w,int h,int bpp){
18 int x;
19
20 //
21 for(x=0;x<h;x++){
22 int y;
23 switch(bpp){
24 case 1:
25 for(y=0;y<w;y++) dst[y]=src[w-y-1+x*srcstride];
26 break;
27 case 2:
28 for(y=0;y<w;y++) *((short*)(dst+y*2))=*((short*)(src+w-y*2-1+x*srcstride));
29 break;
30 case 3:
31 for(y=0;y<w;y++){
32 dst[y*3+0]=src[0+w-y*3-1+x*srcstride];
33 dst[y*3+1]=src[1+w-y*3-1+x*srcstride];
34 dst[y*3+2]=src[2+w-y*3-1+x*srcstride];
35 }
36 break;
37 case 4:
38 for(y=0;y<w;y++) *((int*)(dst+y*4))=*((int*)(src+w-y*4-1+x*srcstride));
39 }
40 dst+=dststride;
41 }
42
43 //
44
45 }
46
47 //===========================================================================//
48
49 static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
50 mp_image_t *dmpi;
51
52 // hope we'll get DR buffer:
53 dmpi=vf_get_image(vf->next,mpi->imgfmt,
54 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
55 mpi->w, mpi->h);
56 //mpi->h, mpi->w);
57
58 if(mpi->flags&MP_IMGFLAG_PLANAR){
59 mirror(dmpi->planes[0],mpi->planes[0],
60 dmpi->stride[0],mpi->stride[0],
61 dmpi->w,dmpi->h,1);
62 mirror(dmpi->planes[1],mpi->planes[1],
63 dmpi->stride[1],mpi->stride[1],
64 dmpi->w>>1,dmpi->h>>1,1);
65 mirror(dmpi->planes[2],mpi->planes[2],
66 dmpi->stride[2],mpi->stride[2],
67 dmpi->w>>1,dmpi->h>>1,1);
68 } else {
69 mirror(dmpi->planes[0],mpi->planes[0],
70 dmpi->stride[0],mpi->stride[0],
71 dmpi->w,dmpi->h,dmpi->bpp>>3);
72 }
73
74 vf_next_put_image(vf,dmpi);
75 }
76
77 //===========================================================================//
78
79 static int open(vf_instance_t *vf, char* args){
80 //vf->config=config;
81 vf->put_image=put_image;
82 return 1;
83 }
84
85 vf_info_t vf_info_mirror = {
86 "mirror",
87 "mirror",
88 "Eyck",
89 "",
90 open
91 };
92
93 //===========================================================================//