annotate libmpcodecs/vf_mirror.c @ 23223:dd98710c1e1d

document lavc's 'level' option
author cehoyos
date Sun, 06 May 2007 21:21:19 +0000
parents 497ebe3ecc2b
children f8d4f8eff72b
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
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 9593
diff changeset
6 #include "config.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 9593
diff changeset
7 #include "mp_msg.h"
5763
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
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 9593
diff changeset
13 #include "libvo/fastmemcpy.h"
5763
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
14
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
15
8748
30f7df2d1bed fixed 16bpp packed YUV formats
arpi
parents: 7368
diff changeset
16 static void mirror(unsigned char* dst,unsigned char* src,int dststride,int srcstride,int w,int h,int bpp,unsigned int fmt){
5772
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
17 int y;
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
18 for(y=0;y<h;y++){
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
19 int x;
5763
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
20 switch(bpp){
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
21 case 1:
5772
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
22 for(x=0;x<w;x++) dst[x]=src[w-x-1];
5763
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
23 break;
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
24 case 2:
8748
30f7df2d1bed fixed 16bpp packed YUV formats
arpi
parents: 7368
diff changeset
25 switch(fmt){
30f7df2d1bed fixed 16bpp packed YUV formats
arpi
parents: 7368
diff changeset
26 case IMGFMT_UYVY: {
30f7df2d1bed fixed 16bpp packed YUV formats
arpi
parents: 7368
diff changeset
27 // packed YUV is tricky. U,V are 32bpp while Y is 16bpp:
30f7df2d1bed fixed 16bpp packed YUV formats
arpi
parents: 7368
diff changeset
28 int w2=w>>1;
30f7df2d1bed fixed 16bpp packed YUV formats
arpi
parents: 7368
diff changeset
29 for(x=0;x<w2;x++){
30f7df2d1bed fixed 16bpp packed YUV formats
arpi
parents: 7368
diff changeset
30 // TODO: optimize this...
30f7df2d1bed fixed 16bpp packed YUV formats
arpi
parents: 7368
diff changeset
31 dst[x*4+0]=src[0+(w2-x-1)*4];
30f7df2d1bed fixed 16bpp packed YUV formats
arpi
parents: 7368
diff changeset
32 dst[x*4+1]=src[3+(w2-x-1)*4];
30f7df2d1bed fixed 16bpp packed YUV formats
arpi
parents: 7368
diff changeset
33 dst[x*4+2]=src[2+(w2-x-1)*4];
30f7df2d1bed fixed 16bpp packed YUV formats
arpi
parents: 7368
diff changeset
34 dst[x*4+3]=src[1+(w2-x-1)*4];
30f7df2d1bed fixed 16bpp packed YUV formats
arpi
parents: 7368
diff changeset
35 }
30f7df2d1bed fixed 16bpp packed YUV formats
arpi
parents: 7368
diff changeset
36 break; }
30f7df2d1bed fixed 16bpp packed YUV formats
arpi
parents: 7368
diff changeset
37 case IMGFMT_YUY2:
30f7df2d1bed fixed 16bpp packed YUV formats
arpi
parents: 7368
diff changeset
38 case IMGFMT_YVYU: {
30f7df2d1bed fixed 16bpp packed YUV formats
arpi
parents: 7368
diff changeset
39 // packed YUV is tricky. U,V are 32bpp while Y is 16bpp:
30f7df2d1bed fixed 16bpp packed YUV formats
arpi
parents: 7368
diff changeset
40 int w2=w>>1;
30f7df2d1bed fixed 16bpp packed YUV formats
arpi
parents: 7368
diff changeset
41 for(x=0;x<w2;x++){
30f7df2d1bed fixed 16bpp packed YUV formats
arpi
parents: 7368
diff changeset
42 // TODO: optimize this...
30f7df2d1bed fixed 16bpp packed YUV formats
arpi
parents: 7368
diff changeset
43 dst[x*4+0]=src[2+(w2-x-1)*4];
30f7df2d1bed fixed 16bpp packed YUV formats
arpi
parents: 7368
diff changeset
44 dst[x*4+1]=src[1+(w2-x-1)*4];
30f7df2d1bed fixed 16bpp packed YUV formats
arpi
parents: 7368
diff changeset
45 dst[x*4+2]=src[0+(w2-x-1)*4];
30f7df2d1bed fixed 16bpp packed YUV formats
arpi
parents: 7368
diff changeset
46 dst[x*4+3]=src[3+(w2-x-1)*4];
30f7df2d1bed fixed 16bpp packed YUV formats
arpi
parents: 7368
diff changeset
47 }
30f7df2d1bed fixed 16bpp packed YUV formats
arpi
parents: 7368
diff changeset
48 break; }
30f7df2d1bed fixed 16bpp packed YUV formats
arpi
parents: 7368
diff changeset
49 default:
30f7df2d1bed fixed 16bpp packed YUV formats
arpi
parents: 7368
diff changeset
50 for(x=0;x<w;x++) *((short*)(dst+x*2))=*((short*)(src+(w-x-1)*2));
30f7df2d1bed fixed 16bpp packed YUV formats
arpi
parents: 7368
diff changeset
51 }
5763
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
52 break;
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
53 case 3:
5772
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
54 for(x=0;x<w;x++){
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
55 dst[x*3+0]=src[0+(w-x-1)*3];
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
56 dst[x*3+1]=src[1+(w-x-1)*3];
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
57 dst[x*3+2]=src[2+(w-x-1)*3];
5763
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
58 }
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
59 break;
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
60 case 4:
5772
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
61 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
62 }
5772
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
63 src+=srcstride;
5763
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
64 dst+=dststride;
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
65 }
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
66 }
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
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17012
diff changeset
70 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
5763
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
71 mp_image_t *dmpi;
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
72
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
73 // hope we'll get DR buffer:
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
74 dmpi=vf_get_image(vf->next,mpi->imgfmt,
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
75 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
76 mpi->w, mpi->h);
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
77
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
78 if(mpi->flags&MP_IMGFLAG_PLANAR){
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
79 mirror(dmpi->planes[0],mpi->planes[0],
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
80 dmpi->stride[0],mpi->stride[0],
8748
30f7df2d1bed fixed 16bpp packed YUV formats
arpi
parents: 7368
diff changeset
81 dmpi->w,dmpi->h,1,mpi->imgfmt);
5763
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
82 mirror(dmpi->planes[1],mpi->planes[1],
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
83 dmpi->stride[1],mpi->stride[1],
8748
30f7df2d1bed fixed 16bpp packed YUV formats
arpi
parents: 7368
diff changeset
84 dmpi->w>>mpi->chroma_x_shift,dmpi->h>>mpi->chroma_y_shift,1,mpi->imgfmt);
5763
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
85 mirror(dmpi->planes[2],mpi->planes[2],
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
86 dmpi->stride[2],mpi->stride[2],
8748
30f7df2d1bed fixed 16bpp packed YUV formats
arpi
parents: 7368
diff changeset
87 dmpi->w>>mpi->chroma_x_shift,dmpi->h>>mpi->chroma_y_shift,1,mpi->imgfmt);
5763
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
88 } else {
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
89 mirror(dmpi->planes[0],mpi->planes[0],
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
90 dmpi->stride[0],mpi->stride[0],
8748
30f7df2d1bed fixed 16bpp packed YUV formats
arpi
parents: 7368
diff changeset
91 dmpi->w,dmpi->h,dmpi->bpp>>3,mpi->imgfmt);
9279
12741a866acd fixed palette support
arpi
parents: 8748
diff changeset
92 dmpi->planes[1]=mpi->planes[1]; // passthrough rgb8 palette
5763
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
93 }
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
94
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17012
diff changeset
95 return vf_next_put_image(vf,dmpi, pts);
5763
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
96 }
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
97
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
98 //===========================================================================//
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
99
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
100 static int open(vf_instance_t *vf, char* args){
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
101 //vf->config=config;
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
102 vf->put_image=put_image;
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
103 return 1;
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
104 }
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
105
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
106 vf_info_t vf_info_mirror = {
5772
cfb787b821a0 10l, >1bpp modes fixed..., x<->y swapped
arpi
parents: 5763
diff changeset
107 "horizontal mirror",
5763
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
108 "mirror",
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
109 "Eyck",
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
110 "",
9593
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 9279
diff changeset
111 open,
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 9279
diff changeset
112 NULL
5763
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
113 };
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
114
e9fb293c53d2 Complement existing filters - rotate and flip.
eyck
parents:
diff changeset
115 //===========================================================================//