Mercurial > mplayer.hg
annotate libmpcodecs/vf_1bpp.c @ 30795:1001c606f94c
Make emulated Win32 critical sections thread safe.
Earlier, cs->locked was accessed outside the mutex to get around
the problem that default pthread mutexes are not recursive
(ie., you cannot do a double-lock from the same thread), causing
a thread-safety problem, as both detected by Helgrind and showing
up in some multithreaded codecs.
The ideal solution here would be to simply use recursive pthread
mutexes, but there were concerns about reduced debuggability and
possibly portability. Thus, instead, rewrite the critical sections
to be a simple lock count (with owner) protected by a regular mutex.
Whenever a thread wants to enter the critical section and lock_count
is not 0, it sleeps on a special event that tells it when the
critical section is available.
author | sesse |
---|---|
date | Thu, 04 Mar 2010 15:57:08 +0000 |
parents | a972c1a4a012 |
children | 92f88bb315c5 |
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 |
7755
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
19 #include <stdio.h> |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
20 #include <stdlib.h> |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
21 #include <string.h> |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
22 #include <inttypes.h> |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
23 |
17012 | 24 #include "config.h" |
25 #include "mp_msg.h" | |
7755
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
26 |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
27 #include "img_format.h" |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
28 #include "mp_image.h" |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
29 #include "vf.h" |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
30 |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
31 //===========================================================================// |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
32 |
24969
c2b7ba444ade
begin moving const filter data to .text/.rodata sections
rfelker
parents:
18746
diff
changeset
|
33 static const unsigned int bgr_list[]={ |
7755
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
34 IMGFMT_Y800, |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
35 IMGFMT_Y8, |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
36 IMGFMT_BGR8, |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
37 IMGFMT_RGB8, |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
38 |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
39 IMGFMT_YVU9, |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
40 IMGFMT_411P, |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
41 IMGFMT_YV12, |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
42 IMGFMT_I420, |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
43 IMGFMT_IYUV, |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
44 IMGFMT_422P, |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
45 IMGFMT_444P, |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
24969
diff
changeset
|
46 |
7755
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
47 IMGFMT_YUY2, |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
48 IMGFMT_BGR15, |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
49 IMGFMT_RGB15, |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
50 IMGFMT_BGR16, |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
51 IMGFMT_RGB16, |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
52 |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
53 IMGFMT_BGR32, |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
54 IMGFMT_RGB32, |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
55 |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
56 // IMGFMT_BGR24, |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
57 // IMGFMT_RGB24, |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
58 0 |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
59 }; |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
60 |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
61 static unsigned int find_best(struct vf_instance *vf){ |
7755
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
62 unsigned int best=0; |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
63 int ret; |
24969
c2b7ba444ade
begin moving const filter data to .text/.rodata sections
rfelker
parents:
18746
diff
changeset
|
64 const unsigned int* p=bgr_list; |
7755
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
65 while(*p){ |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
66 ret=vf->next->query_format(vf->next,*p); |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
67 mp_msg(MSGT_VFILTER,MSGL_V,"[%s] query(%s) -> %d\n",vf->info->name,vo_format_name(*p),ret&3); |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
68 if(ret&VFCAP_CSP_SUPPORTED_BY_HW){ best=*p; break;} // no conversion -> bingo! |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
69 if(ret&VFCAP_CSP_SUPPORTED && !best) best=*p; // best with conversion |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
70 ++p; |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
71 } |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
72 return best; |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
73 } |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
74 |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
75 //===========================================================================// |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
76 |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
77 struct vf_priv_s { |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
78 unsigned int fmt; |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
79 }; |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
80 |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
81 static int config(struct vf_instance *vf, |
7755
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
82 int width, int height, int d_width, int d_height, |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
83 unsigned int flags, unsigned int outfmt){ |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
84 if (!vf->priv->fmt) |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
85 vf->priv->fmt=find_best(vf); |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
86 if(!vf->priv->fmt){ |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
87 // no matching fmt, so force one... |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
88 if(outfmt==IMGFMT_RGB8) vf->priv->fmt=IMGFMT_RGB32; |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
89 else if(outfmt==IMGFMT_BGR8) vf->priv->fmt=IMGFMT_BGR32; |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
90 else return 0; |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
91 } |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
92 return vf_next_config(vf,width,height,d_width,d_height,flags,vf->priv->fmt); |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
93 } |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
94 |
24969
c2b7ba444ade
begin moving const filter data to .text/.rodata sections
rfelker
parents:
18746
diff
changeset
|
95 static const int bittab[8]={128,64,32,16,8,4,2,1}; |
7755
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
96 |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
97 static void convert(mp_image_t *mpi, mp_image_t *dmpi, int value0, int value1,int bpp){ |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
98 int y; |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
99 for(y=0;y<mpi->h;y++){ |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
100 unsigned char* src=mpi->planes[0]+mpi->stride[0]*y; |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
101 switch(bpp){ |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
102 case 1: { |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
103 unsigned char* dst=dmpi->planes[0]+dmpi->stride[0]*y; |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
104 int x; |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
105 for(x=0;x<mpi->w;x++) |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
106 dst[x]=(src[x>>3]&bittab[x&7]) ? value1 : value0; |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
107 break; } |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
108 case 2: { |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
109 uint16_t* dst=(uint16_t*)(dmpi->planes[0]+dmpi->stride[0]*y); |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
110 int x; |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
111 for(x=0;x<mpi->w;x++) |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
112 dst[x]=(src[x>>3]&bittab[x&7]) ? value1 : value0; |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
113 break; } |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
114 case 4: { |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
115 uint32_t* dst=(uint32_t*)(dmpi->planes[0]+dmpi->stride[0]*y); |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
116 int x; |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
117 for(x=0;x<mpi->w;x++) |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
118 dst[x]=(src[x>>3]&bittab[x&7]) ? value1 : value0; |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
119 break; } |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
120 } |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
121 } |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
122 } |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
123 |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
124 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){ |
7755
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
125 mp_image_t *dmpi; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
24969
diff
changeset
|
126 |
7755
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
127 // hope we'll get DR buffer: |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
128 dmpi=vf_get_image(vf->next,vf->priv->fmt, |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
129 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
130 mpi->w, mpi->h); |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
131 |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
132 switch(dmpi->imgfmt){ |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
133 case IMGFMT_Y800: |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
134 case IMGFMT_Y8: |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
135 case IMGFMT_BGR8: |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
136 case IMGFMT_RGB8: |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
137 convert(mpi,dmpi,0,255,1); |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
138 break; |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
139 case IMGFMT_YVU9: |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
140 case IMGFMT_411P: |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
141 case IMGFMT_YV12: |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
142 case IMGFMT_I420: |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
143 case IMGFMT_IYUV: |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
144 case IMGFMT_422P: |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
145 case IMGFMT_444P: |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
146 convert(mpi,dmpi,0,255,1); |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
147 memset(dmpi->planes[1],128,dmpi->stride[1]*dmpi->chroma_height); |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
148 memset(dmpi->planes[2],128,dmpi->stride[2]*dmpi->chroma_height); |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
149 break; |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
150 case IMGFMT_YUY2: |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
151 convert(mpi,dmpi,0x8000,0x80ff,2); |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
152 break; |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
153 case IMGFMT_BGR15: |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
154 case IMGFMT_RGB15: |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
155 convert(mpi,dmpi,0,0x7fff,2); |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
156 break; |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
157 case IMGFMT_BGR16: |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
158 case IMGFMT_RGB16: |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
159 convert(mpi,dmpi,0,0xffff,2); |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
160 break; |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
161 case IMGFMT_BGR32: |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
162 case IMGFMT_RGB32: |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
163 convert(mpi,dmpi,0,0x00ffffff,4); |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
164 break; |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
165 default: |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
166 mp_msg(MSGT_VFILTER,MSGL_ERR,"Unhandled format: 0x%X\n",dmpi->imgfmt); |
7848 | 167 return 0; |
7755
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
168 } |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
169 |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17012
diff
changeset
|
170 return vf_next_put_image(vf,dmpi, pts); |
7755
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
171 } |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
172 |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
173 //===========================================================================// |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
174 |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
175 static int query_format(struct vf_instance *vf, unsigned int fmt){ |
7755
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
176 int best; |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
177 if(fmt!=IMGFMT_RGB1 && fmt!=IMGFMT_BGR1) return 0; |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
178 best=find_best(vf); |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
179 if(!best) return 0; // no match |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
180 return vf->next->query_format(vf->next,best); |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
181 } |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
182 |
30638
a7b908875c14
Rename open() vf initialization function to vf_open().
diego
parents:
30421
diff
changeset
|
183 static int vf_open(vf_instance_t *vf, char *args){ |
7755
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
184 vf->config=config; |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
185 vf->put_image=put_image; |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
186 vf->query_format=query_format; |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
187 vf->priv=malloc(sizeof(struct vf_priv_s)); |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
188 memset(vf->priv, 0, sizeof(struct vf_priv_s)); |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
189 return 1; |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
190 } |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
191 |
24969
c2b7ba444ade
begin moving const filter data to .text/.rodata sections
rfelker
parents:
18746
diff
changeset
|
192 const vf_info_t vf_info_1bpp = { |
7755
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
193 "1bpp bitmap -> YUV/BGR 8/15/16/32 conversion", |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
194 "1bpp", |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
195 "A'rpi", |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
196 "", |
30638
a7b908875c14
Rename open() vf initialization function to vf_open().
diego
parents:
30421
diff
changeset
|
197 vf_open, |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
8123
diff
changeset
|
198 NULL |
7755
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
199 }; |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
200 |
7637b72ef1f9
new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff
changeset
|
201 //===========================================================================// |