Mercurial > mplayer.hg
annotate libmpcodecs/vf_rgb2bgr.c @ 31134:92755ba89e79
Ignore (but print out) offset with libtheora decoder.
Patch by Giorgio Vazzana, mywing81 gmail
author | cehoyos |
---|---|
date | Sat, 22 May 2010 16:32:39 +0000 |
parents | a972c1a4a012 |
children |
rev | line source |
---|---|
30421
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
1 /* |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
2 * This file is part of MPlayer. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
3 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
4 * MPlayer is free software; you can redistribute it and/or modify |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
6 * the Free Software Foundation; either version 2 of the License, or |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
7 * (at your option) any later version. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
8 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
9 * MPlayer is distributed in the hope that it will be useful, |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
12 * GNU General Public License for more details. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
13 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
14 * You should have received a copy of the GNU General Public License along |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
17 */ |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
18 |
5594 | 19 #include <stdio.h> |
20 #include <stdlib.h> | |
21 #include <string.h> | |
22 #include <inttypes.h> | |
23 | |
17012 | 24 #include "config.h" |
25 #include "mp_msg.h" | |
5594 | 26 |
5607 | 27 #include "img_format.h" |
28 #include "mp_image.h" | |
5594 | 29 #include "vf.h" |
30 | |
18861 | 31 #include "libswscale/rgb2rgb.h" |
5594 | 32 |
33 //===========================================================================// | |
34 | |
35 struct vf_priv_s { | |
36 unsigned int fmt; | |
37 int forced; | |
38 }; | |
39 | |
40 static unsigned int getfmt(unsigned int outfmt,int forced){ | |
41 if(forced) switch(outfmt){ | |
42 case IMGFMT_RGB24: | |
43 case IMGFMT_RGB32: | |
44 case IMGFMT_BGR24: | |
45 case IMGFMT_BGR32: | |
46 return outfmt; | |
47 } | |
48 switch(outfmt){ | |
49 case IMGFMT_RGB24: return IMGFMT_BGR24; | |
50 case IMGFMT_RGB32: return IMGFMT_BGR32; | |
51 case IMGFMT_BGR24: return IMGFMT_RGB24; | |
52 case IMGFMT_BGR32: return IMGFMT_RGB32; | |
53 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25221
diff
changeset
|
54 return 0; |
5594 | 55 } |
56 | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
57 static int config(struct vf_instance *vf, |
5594 | 58 int width, int height, int d_width, int d_height, |
59 unsigned int flags, unsigned int outfmt){ | |
60 vf->priv->fmt=getfmt(outfmt,vf->priv->forced); | |
61 return vf_next_config(vf,width,height,d_width,d_height,flags,vf->priv->fmt); | |
62 } | |
63 | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
64 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){ |
5594 | 65 mp_image_t *dmpi; |
66 | |
67 // hope we'll get DR buffer: | |
68 dmpi=vf_get_image(vf->next,vf->priv->fmt, | |
69 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, | |
70 mpi->w, mpi->h); | |
71 | |
5596 | 72 if(mpi->stride[0]!=dmpi->stride[0] || mpi->stride[0]!=mpi->w*(mpi->bpp/8)){ |
5594 | 73 int y; |
74 unsigned char* src=mpi->planes[0]; | |
75 unsigned char* dst=dmpi->planes[0]; | |
76 int srcsize=mpi->w*mpi->bpp/8; | |
77 for(y=0;y<mpi->h;y++){ | |
78 if(mpi->bpp==32) | |
79 rgb32tobgr32(src,dst,srcsize); | |
80 else | |
81 rgb24tobgr24(src,dst,srcsize); | |
5595 | 82 src+=mpi->stride[0]; |
83 dst+=dmpi->stride[0]; | |
5594 | 84 } |
85 } else { | |
86 if(mpi->bpp==32) | |
87 rgb32tobgr32(mpi->planes[0],dmpi->planes[0],mpi->w*mpi->h*4); | |
88 else | |
89 rgb24tobgr24(mpi->planes[0],dmpi->planes[0],mpi->w*mpi->h*3); | |
90 } | |
91 | |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17012
diff
changeset
|
92 return vf_next_put_image(vf,dmpi, pts); |
5594 | 93 } |
94 | |
95 //===========================================================================// | |
96 | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
97 static int query_format(struct vf_instance *vf, unsigned int outfmt){ |
5594 | 98 unsigned int fmt=getfmt(outfmt,vf->priv->forced); |
99 if(!fmt) return 0; | |
100 return vf_next_query_format(vf,fmt) & (~VFCAP_CSP_SUPPORTED_BY_HW); | |
101 } | |
102 | |
30638
a7b908875c14
Rename open() vf initialization function to vf_open().
diego
parents:
30421
diff
changeset
|
103 static int vf_open(vf_instance_t *vf, char *args){ |
5594 | 104 vf->config=config; |
105 vf->put_image=put_image; | |
106 vf->query_format=query_format; | |
107 vf->priv=malloc(sizeof(struct vf_priv_s)); | |
108 vf->priv->forced=args && !strcasecmp(args,"swap"); | |
109 return 1; | |
110 } | |
111 | |
25221 | 112 const vf_info_t vf_info_rgb2bgr = { |
5594 | 113 "fast 24/32bpp RGB<->BGR conversion", |
114 "rgb2bgr", | |
115 "A'rpi", | |
116 "", | |
30638
a7b908875c14
Rename open() vf initialization function to vf_open().
diego
parents:
30421
diff
changeset
|
117 vf_open, |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
7368
diff
changeset
|
118 NULL |
5594 | 119 }; |
120 | |
121 //===========================================================================// |