Mercurial > mplayer.hg
annotate libmpcodecs/vf_rgb2bgr.c @ 17929:6fe95ee39422
Fix osd_show_msg alignment and make sure msg strings
get properly 0 terminated. Thanks to Jonas Jermann
(jjermann _At_ gmx _Dot_ net) for the report.
author | albeu |
---|---|
date | Thu, 23 Mar 2006 15:17:23 +0000 |
parents | 20aca9baf5d8 |
children | 8579acff875e |
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 | |
17012 | 13 #include "libvo/fastmemcpy.h" |
14 #include "postproc/rgb2rgb.h" | |
5594 | 15 |
16 //===========================================================================// | |
17 | |
18 struct vf_priv_s { | |
19 unsigned int fmt; | |
20 int forced; | |
21 }; | |
22 | |
23 static unsigned int getfmt(unsigned int outfmt,int forced){ | |
24 if(forced) switch(outfmt){ | |
25 case IMGFMT_RGB24: | |
26 case IMGFMT_RGB32: | |
27 case IMGFMT_BGR24: | |
28 case IMGFMT_BGR32: | |
29 return outfmt; | |
30 } | |
31 switch(outfmt){ | |
32 case IMGFMT_RGB24: return IMGFMT_BGR24; | |
33 case IMGFMT_RGB32: return IMGFMT_BGR32; | |
34 case IMGFMT_BGR24: return IMGFMT_RGB24; | |
35 case IMGFMT_BGR32: return IMGFMT_RGB32; | |
36 } | |
37 return 0; | |
38 } | |
39 | |
40 static int config(struct vf_instance_s* vf, | |
41 int width, int height, int d_width, int d_height, | |
42 unsigned int flags, unsigned int outfmt){ | |
43 vf->priv->fmt=getfmt(outfmt,vf->priv->forced); | |
44 return vf_next_config(vf,width,height,d_width,d_height,flags,vf->priv->fmt); | |
45 } | |
46 | |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17012
diff
changeset
|
47 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ |
5594 | 48 mp_image_t *dmpi; |
49 | |
50 // hope we'll get DR buffer: | |
51 dmpi=vf_get_image(vf->next,vf->priv->fmt, | |
52 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, | |
53 mpi->w, mpi->h); | |
54 | |
5596 | 55 if(mpi->stride[0]!=dmpi->stride[0] || mpi->stride[0]!=mpi->w*(mpi->bpp/8)){ |
5594 | 56 int y; |
57 unsigned char* src=mpi->planes[0]; | |
58 unsigned char* dst=dmpi->planes[0]; | |
59 int srcsize=mpi->w*mpi->bpp/8; | |
60 for(y=0;y<mpi->h;y++){ | |
61 if(mpi->bpp==32) | |
62 rgb32tobgr32(src,dst,srcsize); | |
63 else | |
64 rgb24tobgr24(src,dst,srcsize); | |
5595 | 65 src+=mpi->stride[0]; |
66 dst+=dmpi->stride[0]; | |
5594 | 67 } |
68 } else { | |
69 if(mpi->bpp==32) | |
70 rgb32tobgr32(mpi->planes[0],dmpi->planes[0],mpi->w*mpi->h*4); | |
71 else | |
72 rgb24tobgr24(mpi->planes[0],dmpi->planes[0],mpi->w*mpi->h*3); | |
73 } | |
74 | |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17012
diff
changeset
|
75 return vf_next_put_image(vf,dmpi, pts); |
5594 | 76 } |
77 | |
78 //===========================================================================// | |
79 | |
80 static int query_format(struct vf_instance_s* vf, unsigned int outfmt){ | |
81 unsigned int fmt=getfmt(outfmt,vf->priv->forced); | |
82 if(!fmt) return 0; | |
83 return vf_next_query_format(vf,fmt) & (~VFCAP_CSP_SUPPORTED_BY_HW); | |
84 } | |
85 | |
86 static int open(vf_instance_t *vf, char* args){ | |
87 vf->config=config; | |
88 vf->put_image=put_image; | |
89 vf->query_format=query_format; | |
90 vf->priv=malloc(sizeof(struct vf_priv_s)); | |
91 vf->priv->forced=args && !strcasecmp(args,"swap"); | |
92 return 1; | |
93 } | |
94 | |
95 vf_info_t vf_info_rgb2bgr = { | |
96 "fast 24/32bpp RGB<->BGR conversion", | |
97 "rgb2bgr", | |
98 "A'rpi", | |
99 "", | |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
7368
diff
changeset
|
100 open, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
7368
diff
changeset
|
101 NULL |
5594 | 102 }; |
103 | |
104 //===========================================================================// |