Mercurial > mplayer.hg
annotate libmpcodecs/vf_rgb2bgr.c @ 23464:1b1fdac4a68c
Align output pointer so that we can use movaps instead of movups in dct64_sse;
1.5% faster decode.
author | zuxy |
---|---|
date | Wed, 06 Jun 2007 05:13:13 +0000 |
parents | f8d4f8eff72b |
children | 00fff9a3b735 |
rev | line source |
---|---|
5594 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 #include <string.h> | |
4 #include <inttypes.h> | |
5 | |
17012 | 6 #include "config.h" |
7 #include "mp_msg.h" | |
5594 | 8 |
5607 | 9 #include "img_format.h" |
10 #include "mp_image.h" | |
5594 | 11 #include "vf.h" |
12 | |
18861 | 13 #include "libswscale/rgb2rgb.h" |
5594 | 14 |
15 //===========================================================================// | |
16 | |
17 struct vf_priv_s { | |
18 unsigned int fmt; | |
19 int forced; | |
20 }; | |
21 | |
22 static unsigned int getfmt(unsigned int outfmt,int forced){ | |
23 if(forced) switch(outfmt){ | |
24 case IMGFMT_RGB24: | |
25 case IMGFMT_RGB32: | |
26 case IMGFMT_BGR24: | |
27 case IMGFMT_BGR32: | |
28 return outfmt; | |
29 } | |
30 switch(outfmt){ | |
31 case IMGFMT_RGB24: return IMGFMT_BGR24; | |
32 case IMGFMT_RGB32: return IMGFMT_BGR32; | |
33 case IMGFMT_BGR24: return IMGFMT_RGB24; | |
34 case IMGFMT_BGR32: return IMGFMT_RGB32; | |
35 } | |
36 return 0; | |
37 } | |
38 | |
39 static int config(struct vf_instance_s* vf, | |
40 int width, int height, int d_width, int d_height, | |
41 unsigned int flags, unsigned int outfmt){ | |
42 vf->priv->fmt=getfmt(outfmt,vf->priv->forced); | |
43 return vf_next_config(vf,width,height,d_width,d_height,flags,vf->priv->fmt); | |
44 } | |
45 | |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17012
diff
changeset
|
46 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ |
5594 | 47 mp_image_t *dmpi; |
48 | |
49 // hope we'll get DR buffer: | |
50 dmpi=vf_get_image(vf->next,vf->priv->fmt, | |
51 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, | |
52 mpi->w, mpi->h); | |
53 | |
5596 | 54 if(mpi->stride[0]!=dmpi->stride[0] || mpi->stride[0]!=mpi->w*(mpi->bpp/8)){ |
5594 | 55 int y; |
56 unsigned char* src=mpi->planes[0]; | |
57 unsigned char* dst=dmpi->planes[0]; | |
58 int srcsize=mpi->w*mpi->bpp/8; | |
59 for(y=0;y<mpi->h;y++){ | |
60 if(mpi->bpp==32) | |
61 rgb32tobgr32(src,dst,srcsize); | |
62 else | |
63 rgb24tobgr24(src,dst,srcsize); | |
5595 | 64 src+=mpi->stride[0]; |
65 dst+=dmpi->stride[0]; | |
5594 | 66 } |
67 } else { | |
68 if(mpi->bpp==32) | |
69 rgb32tobgr32(mpi->planes[0],dmpi->planes[0],mpi->w*mpi->h*4); | |
70 else | |
71 rgb24tobgr24(mpi->planes[0],dmpi->planes[0],mpi->w*mpi->h*3); | |
72 } | |
73 | |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17012
diff
changeset
|
74 return vf_next_put_image(vf,dmpi, pts); |
5594 | 75 } |
76 | |
77 //===========================================================================// | |
78 | |
79 static int query_format(struct vf_instance_s* vf, unsigned int outfmt){ | |
80 unsigned int fmt=getfmt(outfmt,vf->priv->forced); | |
81 if(!fmt) return 0; | |
82 return vf_next_query_format(vf,fmt) & (~VFCAP_CSP_SUPPORTED_BY_HW); | |
83 } | |
84 | |
85 static int open(vf_instance_t *vf, char* args){ | |
86 vf->config=config; | |
87 vf->put_image=put_image; | |
88 vf->query_format=query_format; | |
89 vf->priv=malloc(sizeof(struct vf_priv_s)); | |
90 vf->priv->forced=args && !strcasecmp(args,"swap"); | |
91 return 1; | |
92 } | |
93 | |
94 vf_info_t vf_info_rgb2bgr = { | |
95 "fast 24/32bpp RGB<->BGR conversion", | |
96 "rgb2bgr", | |
97 "A'rpi", | |
98 "", | |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
7368
diff
changeset
|
99 open, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
7368
diff
changeset
|
100 NULL |
5594 | 101 }; |
102 | |
103 //===========================================================================// |