author | harlekin <harlekin> | 2002-09-24 20:26:17 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-09-24 20:26:17 (UTC) |
commit | 7a04855af4e042152a47e90192dc4c2c20858e8c (patch) (unidiff) | |
tree | cca4567d71b8210dc8905804cebc203b71fc4958 | |
parent | 02074fb65c5e879ef1d28e52cf4e1ec4a6727599 (diff) | |
download | opie-7a04855af4e042152a47e90192dc4c2c20858e8c.zip opie-7a04855af4e042152a47e90192dc4c2c20858e8c.tar.gz opie-7a04855af4e042152a47e90192dc4c2c20858e8c.tar.bz2 |
adapted to the new api
-rw-r--r-- | noncore/multimedia/opieplayer2/alphablend.c | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.cpp | 165 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.h | 28 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/nullvideo.c | 925 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/opieplayer2.pro | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidgetgui.cpp | 3 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 7 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.cpp | 1 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinevideowidget.cpp | 151 |
10 files changed, 622 insertions, 664 deletions
diff --git a/noncore/multimedia/opieplayer2/alphablend.c b/noncore/multimedia/opieplayer2/alphablend.c index 57f6013..cdd7b28 100644 --- a/noncore/multimedia/opieplayer2/alphablend.c +++ b/noncore/multimedia/opieplayer2/alphablend.c | |||
@@ -1,753 +1,755 @@ | |||
1 | //TOAST_SPU will define ALL spu entries - no matter the tranparency | 1 | //TOAST_SPU will define ALL spu entries - no matter the tranparency |
2 | //#define TOAST_SPU | 2 | //#define TOAST_SPU |
3 | /* #define PRIV_CLUT */ | 3 | /* #define PRIV_CLUT */ |
4 | /* Currently only blend_yuv(..) works */ | 4 | /* Currently only blend_yuv(..) works */ |
5 | /* | 5 | /* |
6 | * | 6 | * |
7 | * Copyright (C) James Courtier-Dutton James@superbug.demon.co.uk - July 2001 | 7 | * Copyright (C) James Courtier-Dutton James@superbug.demon.co.uk - July 2001 |
8 | * | 8 | * |
9 | * Copyright (C) 2000 Thomas Mirlacher | 9 | * Copyright (C) 2000 Thomas Mirlacher |
10 | * | 10 | * |
11 | * This program is free software; you can redistribute it and/or modify | 11 | * This program is free software; you can redistribute it and/or modify |
12 | * it under the terms of the GNU General Public License as published by | 12 | * it under the terms of the GNU General Public License as published by |
13 | * the Free Software Foundation; either version 2 of the License, or | 13 | * the Free Software Foundation; either version 2 of the License, or |
14 | * (at your option) any later version. | 14 | * (at your option) any later version. |
15 | * | 15 | * |
16 | * This program is distributed in the hope that it will be useful, | 16 | * This program is distributed in the hope that it will be useful, |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 | * GNU General Public License for more details. | 19 | * GNU General Public License for more details. |
20 | * | 20 | * |
21 | * You should have received a copy of the GNU General Public License | 21 | * You should have received a copy of the GNU General Public License |
22 | * along with this program; if not, write to the Free Software | 22 | * along with this program; if not, write to the Free Software |
23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
24 | * | 24 | * |
25 | * The author may be reached as <dent@linuxvideo.org> | 25 | * The author may be reached as <dent@linuxvideo.org> |
26 | * | 26 | * |
27 | *------------------------------------------------------------ | 27 | *------------------------------------------------------------ |
28 | * | 28 | * |
29 | */ | 29 | */ |
30 | 30 | ||
31 | /* | 31 | /* |
32 | #define LOG_BLEND_YUV | 32 | #define LOG_BLEND_YUV |
33 | */ | 33 | */ |
34 | 34 | ||
35 | #include <string.h> | 35 | #include <string.h> |
36 | #include <stdlib.h> | 36 | #include <stdlib.h> |
37 | #include <stdio.h> | 37 | #include <stdio.h> |
38 | #include <inttypes.h> | 38 | #include <inttypes.h> |
39 | 39 | ||
40 | #include <xine.h> | ||
41 | #include <xine/xine_internal.h> | ||
40 | #include <xine/video_out.h> | 42 | #include <xine/video_out.h> |
41 | #include "alphablend.h" | 43 | #include "alphablend.h" |
42 | 44 | ||
43 | 45 | ||
44 | #define BLEND_COLOR(dst, src, mask, o) ((((src&mask)*o + ((dst&mask)*(0x0f-o)))/0xf) & mask) | 46 | #define BLEND_COLOR(dst, src, mask, o) ((((src&mask)*o + ((dst&mask)*(0x0f-o)))/0xf) & mask) |
45 | 47 | ||
46 | #define BLEND_BYTE(dst, src, o) (((src)*o + ((dst)*(0xf-o)))/0xf) | 48 | #define BLEND_BYTE(dst, src, o) (((src)*o + ((dst)*(0xf-o)))/0xf) |
47 | 49 | ||
48 | static void mem_blend16(uint16_t *mem, uint16_t clr, uint8_t o, int len) { | 50 | static void mem_blend16(uint16_t *mem, uint16_t clr, uint8_t o, int len) { |
49 | uint16_t *limit = mem + len; | 51 | uint16_t *limit = mem + len; |
50 | while (mem < limit) { | 52 | while (mem < limit) { |
51 | *mem = | 53 | *mem = |
52 | BLEND_COLOR(*mem, clr, 0xf800, o) | | 54 | BLEND_COLOR(*mem, clr, 0xf800, o) | |
53 | BLEND_COLOR(*mem, clr, 0x07e0, o) | | 55 | BLEND_COLOR(*mem, clr, 0x07e0, o) | |
54 | BLEND_COLOR(*mem, clr, 0x001f, o); | 56 | BLEND_COLOR(*mem, clr, 0x001f, o); |
55 | mem++; | 57 | mem++; |
56 | } | 58 | } |
57 | } | 59 | } |
58 | 60 | ||
59 | static void mem_blend24(uint8_t *mem, uint8_t r, uint8_t g, uint8_t b, | 61 | static void mem_blend24(uint8_t *mem, uint8_t r, uint8_t g, uint8_t b, |
60 | uint8_t o, int len) { | 62 | uint8_t o, int len) { |
61 | uint8_t *limit = mem + len*3; | 63 | uint8_t *limit = mem + len*3; |
62 | while (mem < limit) { | 64 | while (mem < limit) { |
63 | *mem = BLEND_BYTE(*mem, r, o); | 65 | *mem = BLEND_BYTE(*mem, r, o); |
64 | mem++; | 66 | mem++; |
65 | *mem = BLEND_BYTE(*mem, g, o); | 67 | *mem = BLEND_BYTE(*mem, g, o); |
66 | mem++; | 68 | mem++; |
67 | *mem = BLEND_BYTE(*mem, b, o); | 69 | *mem = BLEND_BYTE(*mem, b, o); |
68 | mem++; | 70 | mem++; |
69 | } | 71 | } |
70 | } | 72 | } |
71 | 73 | ||
72 | static void mem_blend24_32(uint8_t *mem, uint8_t r, uint8_t g, uint8_t b, | 74 | static void mem_blend24_32(uint8_t *mem, uint8_t r, uint8_t g, uint8_t b, |
73 | uint8_t o, int len) { | 75 | uint8_t o, int len) { |
74 | uint8_t *limit = mem + len*4; | 76 | uint8_t *limit = mem + len*4; |
75 | while (mem < limit) { | 77 | while (mem < limit) { |
76 | *mem = BLEND_BYTE(*mem, r, o); | 78 | *mem = BLEND_BYTE(*mem, r, o); |
77 | mem++; | 79 | mem++; |
78 | *mem = BLEND_BYTE(*mem, g, o); | 80 | *mem = BLEND_BYTE(*mem, g, o); |
79 | mem++; | 81 | mem++; |
80 | *mem = BLEND_BYTE(*mem, b, o); | 82 | *mem = BLEND_BYTE(*mem, b, o); |
81 | mem += 2; | 83 | mem += 2; |
82 | } | 84 | } |
83 | } | 85 | } |
84 | 86 | ||
85 | static void mem_blend32(uint8_t *mem, uint8_t *src, uint8_t o, int len) { | 87 | static void mem_blend32(uint8_t *mem, uint8_t *src, uint8_t o, int len) { |
86 | uint8_t *limit = mem + len*4; | 88 | uint8_t *limit = mem + len*4; |
87 | while (mem < limit) { | 89 | while (mem < limit) { |
88 | *mem = BLEND_BYTE(*mem, src[0], o); | 90 | *mem = BLEND_BYTE(*mem, src[0], o); |
89 | mem++; | 91 | mem++; |
90 | *mem = BLEND_BYTE(*mem, src[1], o); | 92 | *mem = BLEND_BYTE(*mem, src[1], o); |
91 | mem++; | 93 | mem++; |
92 | *mem = BLEND_BYTE(*mem, src[2], o); | 94 | *mem = BLEND_BYTE(*mem, src[2], o); |
93 | mem++; | 95 | mem++; |
94 | *mem = BLEND_BYTE(*mem, src[3], o); | 96 | *mem = BLEND_BYTE(*mem, src[3], o); |
95 | mem++; | 97 | mem++; |
96 | } | 98 | } |
97 | } | 99 | } |
98 | 100 | ||
99 | 101 | ||
100 | /* | 102 | /* |
101 | * Some macros for fixed point arithmetic. | 103 | * Some macros for fixed point arithmetic. |
102 | * | 104 | * |
103 | * The blend_rgb* routines perform rle image scaling using | 105 | * The blend_rgb* routines perform rle image scaling using |
104 | * scale factors that are expressed as integers scaled with | 106 | * scale factors that are expressed as integers scaled with |
105 | * a factor of 2**16. | 107 | * a factor of 2**16. |
106 | * | 108 | * |
107 | * INT_TO_SCALED()/SCALED_TO_INT() converts from integer | 109 | * INT_TO_SCALED()/SCALED_TO_INT() converts from integer |
108 | * to scaled fixed point and back. | 110 | * to scaled fixed point and back. |
109 | */ | 111 | */ |
110 | #define SCALE_SHIFT 16 | 112 | #define SCALE_SHIFT 16 |
111 | #define SCALE_FACTOR (1<<SCALE_SHIFT) | 113 | #define SCALE_FACTOR (1<<SCALE_SHIFT) |
112 | #defineINT_TO_SCALED(i) ((i) << SCALE_SHIFT) | 114 | #defineINT_TO_SCALED(i) ((i) << SCALE_SHIFT) |
113 | #defineSCALED_TO_INT(sc) ((sc) >> SCALE_SHIFT) | 115 | #defineSCALED_TO_INT(sc) ((sc) >> SCALE_SHIFT) |
114 | 116 | ||
115 | 117 | ||
116 | static rle_elem_t * | 118 | static rle_elem_t * |
117 | rle_img_advance_line(rle_elem_t *rle, rle_elem_t *rle_limit, int w) | 119 | rle_img_advance_line(rle_elem_t *rle, rle_elem_t *rle_limit, int w) |
118 | { | 120 | { |
119 | int x; | 121 | int x; |
120 | 122 | ||
121 | for (x = 0; x < w && rle < rle_limit; ) { | 123 | for (x = 0; x < w && rle < rle_limit; ) { |
122 | x += rle->len; | 124 | x += rle->len; |
123 | rle++; | 125 | rle++; |
124 | } | 126 | } |
125 | return rle; | 127 | return rle; |
126 | } | 128 | } |
127 | 129 | ||
128 | 130 | ||
129 | void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, | 131 | void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, |
130 | int img_width, int img_height, | 132 | int img_width, int img_height, |
131 | int dst_width, int dst_height) | 133 | int dst_width, int dst_height) |
132 | { | 134 | { |
133 | uint8_t *trans; | 135 | uint8_t *trans; |
134 | clut_t* clut = (clut_t*) img_overl->clip_color; | 136 | clut_t* clut = (clut_t*) img_overl->clip_color; |
135 | 137 | ||
136 | int src_width = img_overl->width; | 138 | int src_width = img_overl->width; |
137 | int src_height = img_overl->height; | 139 | int src_height = img_overl->height; |
138 | rle_elem_t *rle = img_overl->rle; | 140 | rle_elem_t *rle = img_overl->rle; |
139 | rle_elem_t *rle_limit = rle + img_overl->num_rle; | 141 | rle_elem_t *rle_limit = rle + img_overl->num_rle; |
140 | int x, y, x1_scaled, x2_scaled; | 142 | int x, y, x1_scaled, x2_scaled; |
141 | int dy, dy_step, x_scale;/* scaled 2**SCALE_SHIFT */ | 143 | int dy, dy_step, x_scale;/* scaled 2**SCALE_SHIFT */ |
142 | int clip_right; | 144 | int clip_right; |
143 | uint16_t *img_pix; | 145 | uint16_t *img_pix; |
144 | 146 | ||
145 | dy_step = INT_TO_SCALED(dst_height) / img_height; | 147 | dy_step = INT_TO_SCALED(dst_height) / img_height; |
146 | x_scale = INT_TO_SCALED(img_width) / dst_width; | 148 | x_scale = INT_TO_SCALED(img_width) / dst_width; |
147 | 149 | ||
148 | img_pix = (uint16_t *) img | 150 | img_pix = (uint16_t *) img |
149 | + (img_overl->y * img_height / dst_height) * img_width | 151 | + (img_overl->y * img_height / dst_height) * img_width |
150 | + (img_overl->x * img_width / dst_width); | 152 | + (img_overl->x * img_width / dst_width); |
151 | 153 | ||
152 | trans = img_overl->clip_trans; | 154 | trans = img_overl->clip_trans; |
153 | 155 | ||
154 | /* avoid wraping overlay if drawing to small image */ | 156 | /* avoid wraping overlay if drawing to small image */ |
155 | if( (img_overl->x + img_overl->clip_right) < dst_width ) | 157 | if( (img_overl->x + img_overl->clip_right) < dst_width ) |
156 | clip_right = img_overl->clip_right; | 158 | clip_right = img_overl->clip_right; |
157 | else | 159 | else |
158 | clip_right = dst_width - 1 - img_overl->x; | 160 | clip_right = dst_width - 1 - img_overl->x; |
159 | 161 | ||
160 | /* avoid buffer overflow */ | 162 | /* avoid buffer overflow */ |
161 | if( (src_height + img_overl->y) >= dst_height ) | 163 | if( (src_height + img_overl->y) >= dst_height ) |
162 | src_height = dst_height - 1 - img_overl->y; | 164 | src_height = dst_height - 1 - img_overl->y; |
163 | 165 | ||
164 | for (y = dy = 0; y < src_height && rle < rle_limit;) { | 166 | for (y = dy = 0; y < src_height && rle < rle_limit;) { |
165 | int mask = !(img_overl->clip_top > y || img_overl->clip_bottom < y); | 167 | int mask = !(img_overl->clip_top > y || img_overl->clip_bottom < y); |
166 | rle_elem_t *rle_start = rle; | 168 | rle_elem_t *rle_start = rle; |
167 | 169 | ||
168 | for (x = x1_scaled = 0; x < src_width;) { | 170 | for (x = x1_scaled = 0; x < src_width;) { |
169 | uint8_t clr; | 171 | uint8_t clr; |
170 | uint16_t o; | 172 | uint16_t o; |
171 | int rlelen; | 173 | int rlelen; |
172 | 174 | ||
173 | clr = rle->color; | 175 | clr = rle->color; |
174 | o = trans[clr]; | 176 | o = trans[clr]; |
175 | rlelen = rle->len; | 177 | rlelen = rle->len; |
176 | 178 | ||
177 | if (o && mask) { | 179 | if (o && mask) { |
178 | /* threat cases where clipping border is inside rle->len pixels */ | 180 | /* threat cases where clipping border is inside rle->len pixels */ |
179 | if ( img_overl->clip_left > x ) { | 181 | if ( img_overl->clip_left > x ) { |
180 | if( img_overl->clip_left < x + rlelen ) { | 182 | if( img_overl->clip_left < x + rlelen ) { |
181 | x1_scaled = SCALED_TO_INT( img_overl->clip_left * x_scale ); | 183 | x1_scaled = SCALED_TO_INT( img_overl->clip_left * x_scale ); |
182 | rlelen -= img_overl->clip_left - x; | 184 | rlelen -= img_overl->clip_left - x; |
183 | x += img_overl->clip_left - x; | 185 | x += img_overl->clip_left - x; |
184 | } else { | 186 | } else { |
185 | o = 0; | 187 | o = 0; |
186 | } | 188 | } |
187 | } else if( clip_right < x + rlelen ) { | 189 | } else if( clip_right < x + rlelen ) { |
188 | if( clip_right > x ) { | 190 | if( clip_right > x ) { |
189 | x2_scaled = SCALED_TO_INT( clip_right * x_scale); | 191 | x2_scaled = SCALED_TO_INT( clip_right * x_scale); |
190 | mem_blend16(img_pix+x1_scaled, *((uint16_t *)&clut[clr]), o, | 192 | mem_blend16(img_pix+x1_scaled, *((uint16_t *)&clut[clr]), o, |
191 | x2_scaled-x1_scaled); | 193 | x2_scaled-x1_scaled); |
192 | o = 0; | 194 | o = 0; |
193 | } else { | 195 | } else { |
194 | o = 0; | 196 | o = 0; |
195 | } | 197 | } |
196 | } | 198 | } |
197 | } | 199 | } |
198 | 200 | ||
199 | x2_scaled = SCALED_TO_INT((x + rlelen) * x_scale); | 201 | x2_scaled = SCALED_TO_INT((x + rlelen) * x_scale); |
200 | if (o && mask) { | 202 | if (o && mask) { |
201 | mem_blend16(img_pix+x1_scaled, *((uint16_t *)&clut[clr]), o, x2_scaled-x1_scaled); | 203 | mem_blend16(img_pix+x1_scaled, *((uint16_t *)&clut[clr]), o, x2_scaled-x1_scaled); |
202 | } | 204 | } |
203 | 205 | ||
204 | x1_scaled = x2_scaled; | 206 | x1_scaled = x2_scaled; |
205 | x += rlelen; | 207 | x += rlelen; |
206 | rle++; | 208 | rle++; |
207 | if (rle >= rle_limit) break; | 209 | if (rle >= rle_limit) break; |
208 | } | 210 | } |
209 | 211 | ||
210 | img_pix += img_width; | 212 | img_pix += img_width; |
211 | dy += dy_step; | 213 | dy += dy_step; |
212 | if (dy >= INT_TO_SCALED(1)) { | 214 | if (dy >= INT_TO_SCALED(1)) { |
213 | dy -= INT_TO_SCALED(1); | 215 | dy -= INT_TO_SCALED(1); |
214 | ++y; | 216 | ++y; |
215 | while (dy >= INT_TO_SCALED(1)) { | 217 | while (dy >= INT_TO_SCALED(1)) { |
216 | rle = rle_img_advance_line(rle, rle_limit, src_width); | 218 | rle = rle_img_advance_line(rle, rle_limit, src_width); |
217 | dy -= INT_TO_SCALED(1); | 219 | dy -= INT_TO_SCALED(1); |
218 | ++y; | 220 | ++y; |
219 | } | 221 | } |
220 | } else { | 222 | } else { |
221 | rle = rle_start; /* y-scaling, reuse the last rle encoded line */ | 223 | rle = rle_start; /* y-scaling, reuse the last rle encoded line */ |
222 | } | 224 | } |
223 | } | 225 | } |
224 | } | 226 | } |
225 | 227 | ||
226 | void blend_rgb24 (uint8_t * img, vo_overlay_t * img_overl, | 228 | void blend_rgb24 (uint8_t * img, vo_overlay_t * img_overl, |
227 | int img_width, int img_height, | 229 | int img_width, int img_height, |
228 | int dst_width, int dst_height) | 230 | int dst_width, int dst_height) |
229 | { | 231 | { |
230 | clut_t* clut = (clut_t*) img_overl->clip_color; | 232 | clut_t* clut = (clut_t*) img_overl->clip_color; |
231 | uint8_t *trans; | 233 | uint8_t *trans; |
232 | int src_width = img_overl->width; | 234 | int src_width = img_overl->width; |
233 | int src_height = img_overl->height; | 235 | int src_height = img_overl->height; |
234 | rle_elem_t *rle = img_overl->rle; | 236 | rle_elem_t *rle = img_overl->rle; |
235 | rle_elem_t *rle_limit = rle + img_overl->num_rle; | 237 | rle_elem_t *rle_limit = rle + img_overl->num_rle; |
236 | int x, y, x1_scaled, x2_scaled; | 238 | int x, y, x1_scaled, x2_scaled; |
237 | int dy, dy_step, x_scale;/* scaled 2**SCALE_SHIFT */ | 239 | int dy, dy_step, x_scale;/* scaled 2**SCALE_SHIFT */ |
238 | int clip_right; | 240 | int clip_right; |
239 | uint8_t *img_pix; | 241 | uint8_t *img_pix; |
240 | 242 | ||
241 | dy_step = INT_TO_SCALED(dst_height) / img_height; | 243 | dy_step = INT_TO_SCALED(dst_height) / img_height; |
242 | x_scale = INT_TO_SCALED(img_width) / dst_width; | 244 | x_scale = INT_TO_SCALED(img_width) / dst_width; |
243 | 245 | ||
244 | img_pix = img + 3 * ( (img_overl->y * img_height / dst_height) * img_width | 246 | img_pix = img + 3 * ( (img_overl->y * img_height / dst_height) * img_width |
245 | + (img_overl->x * img_width / dst_width)); | 247 | + (img_overl->x * img_width / dst_width)); |
246 | 248 | ||
247 | trans = img_overl->clip_trans; | 249 | trans = img_overl->clip_trans; |
248 | 250 | ||
249 | /* avoid wraping overlay if drawing to small image */ | 251 | /* avoid wraping overlay if drawing to small image */ |
250 | if( (img_overl->x + img_overl->clip_right) < dst_width ) | 252 | if( (img_overl->x + img_overl->clip_right) < dst_width ) |
251 | clip_right = img_overl->clip_right; | 253 | clip_right = img_overl->clip_right; |
252 | else | 254 | else |
253 | clip_right = dst_width - 1 - img_overl->x; | 255 | clip_right = dst_width - 1 - img_overl->x; |
254 | 256 | ||
255 | /* avoid buffer overflow */ | 257 | /* avoid buffer overflow */ |
256 | if( (src_height + img_overl->y) >= dst_height ) | 258 | if( (src_height + img_overl->y) >= dst_height ) |
257 | src_height = dst_height - 1 - img_overl->y; | 259 | src_height = dst_height - 1 - img_overl->y; |
258 | 260 | ||
259 | for (dy = y = 0; y < src_height && rle < rle_limit; ) { | 261 | for (dy = y = 0; y < src_height && rle < rle_limit; ) { |
260 | int mask = !(img_overl->clip_top > y || img_overl->clip_bottom < y); | 262 | int mask = !(img_overl->clip_top > y || img_overl->clip_bottom < y); |
261 | rle_elem_t *rle_start = rle; | 263 | rle_elem_t *rle_start = rle; |
262 | 264 | ||
263 | for (x = x1_scaled = 0; x < src_width;) { | 265 | for (x = x1_scaled = 0; x < src_width;) { |
264 | uint8_t clr; | 266 | uint8_t clr; |
265 | uint16_t o; | 267 | uint16_t o; |
266 | int rlelen; | 268 | int rlelen; |
267 | 269 | ||
268 | clr = rle->color; | 270 | clr = rle->color; |
269 | o = trans[clr]; | 271 | o = trans[clr]; |
270 | rlelen = rle->len; | 272 | rlelen = rle->len; |
271 | 273 | ||
272 | if (o && mask) { | 274 | if (o && mask) { |
273 | /* threat cases where clipping border is inside rle->len pixels */ | 275 | /* threat cases where clipping border is inside rle->len pixels */ |
274 | if ( img_overl->clip_left > x ) { | 276 | if ( img_overl->clip_left > x ) { |
275 | if( img_overl->clip_left < x + rlelen ) { | 277 | if( img_overl->clip_left < x + rlelen ) { |
276 | x1_scaled = SCALED_TO_INT( img_overl->clip_left * x_scale ); | 278 | x1_scaled = SCALED_TO_INT( img_overl->clip_left * x_scale ); |
277 | rlelen -= img_overl->clip_left - x; | 279 | rlelen -= img_overl->clip_left - x; |
278 | x += img_overl->clip_left - x; | 280 | x += img_overl->clip_left - x; |
279 | } else { | 281 | } else { |
280 | o = 0; | 282 | o = 0; |
281 | } | 283 | } |
282 | } else if( clip_right < x + rlelen ) { | 284 | } else if( clip_right < x + rlelen ) { |
283 | if( clip_right > x ) { | 285 | if( clip_right > x ) { |
284 | x2_scaled = SCALED_TO_INT( clip_right * x_scale); | 286 | x2_scaled = SCALED_TO_INT( clip_right * x_scale); |
285 | mem_blend24(img_pix + x1_scaled*3, clut[clr].cb, | 287 | mem_blend24(img_pix + x1_scaled*3, clut[clr].cb, |
286 | clut[clr].cr, clut[clr].y, | 288 | clut[clr].cr, clut[clr].y, |
287 | o, x2_scaled-x1_scaled); | 289 | o, x2_scaled-x1_scaled); |
288 | o = 0; | 290 | o = 0; |
289 | } else { | 291 | } else { |
290 | o = 0; | 292 | o = 0; |
291 | } | 293 | } |
292 | } | 294 | } |
293 | } | 295 | } |
294 | 296 | ||
295 | x2_scaled = SCALED_TO_INT((x + rlelen) * x_scale); | 297 | x2_scaled = SCALED_TO_INT((x + rlelen) * x_scale); |
296 | if (o && mask) { | 298 | if (o && mask) { |
297 | mem_blend24(img_pix + x1_scaled*3, clut[clr].cb, | 299 | mem_blend24(img_pix + x1_scaled*3, clut[clr].cb, |
298 | clut[clr].cr, clut[clr].y, | 300 | clut[clr].cr, clut[clr].y, |
299 | o, x2_scaled-x1_scaled); | 301 | o, x2_scaled-x1_scaled); |
300 | } | 302 | } |
301 | 303 | ||
302 | x1_scaled = x2_scaled; | 304 | x1_scaled = x2_scaled; |
303 | x += rlelen; | 305 | x += rlelen; |
304 | rle++; | 306 | rle++; |
305 | if (rle >= rle_limit) break; | 307 | if (rle >= rle_limit) break; |
306 | } | 308 | } |
307 | 309 | ||
308 | img_pix += img_width * 3; | 310 | img_pix += img_width * 3; |
309 | dy += dy_step; | 311 | dy += dy_step; |
310 | if (dy >= INT_TO_SCALED(1)) { | 312 | if (dy >= INT_TO_SCALED(1)) { |
311 | dy -= INT_TO_SCALED(1); | 313 | dy -= INT_TO_SCALED(1); |
312 | ++y; | 314 | ++y; |
313 | while (dy >= INT_TO_SCALED(1)) { | 315 | while (dy >= INT_TO_SCALED(1)) { |
314 | rle = rle_img_advance_line(rle, rle_limit, src_width); | 316 | rle = rle_img_advance_line(rle, rle_limit, src_width); |
315 | dy -= INT_TO_SCALED(1); | 317 | dy -= INT_TO_SCALED(1); |
316 | ++y; | 318 | ++y; |
317 | } | 319 | } |
318 | } else { | 320 | } else { |
319 | rle = rle_start; /* y-scaling, reuse the last rle encoded line */ | 321 | rle = rle_start; /* y-scaling, reuse the last rle encoded line */ |
320 | } | 322 | } |
321 | } | 323 | } |
322 | } | 324 | } |
323 | 325 | ||
324 | void blend_rgb32 (uint8_t * img, vo_overlay_t * img_overl, | 326 | void blend_rgb32 (uint8_t * img, vo_overlay_t * img_overl, |
325 | int img_width, int img_height, | 327 | int img_width, int img_height, |
326 | int dst_width, int dst_height) | 328 | int dst_width, int dst_height) |
327 | { | 329 | { |
328 | clut_t* clut = (clut_t*) img_overl->clip_color; | 330 | clut_t* clut = (clut_t*) img_overl->clip_color; |
329 | uint8_t *trans; | 331 | uint8_t *trans; |
330 | int src_width = img_overl->width; | 332 | int src_width = img_overl->width; |
331 | int src_height = img_overl->height; | 333 | int src_height = img_overl->height; |
332 | rle_elem_t *rle = img_overl->rle; | 334 | rle_elem_t *rle = img_overl->rle; |
333 | rle_elem_t *rle_limit = rle + img_overl->num_rle; | 335 | rle_elem_t *rle_limit = rle + img_overl->num_rle; |
334 | int x, y, x1_scaled, x2_scaled; | 336 | int x, y, x1_scaled, x2_scaled; |
335 | int dy, dy_step, x_scale;/* scaled 2**SCALE_SHIFT */ | 337 | int dy, dy_step, x_scale;/* scaled 2**SCALE_SHIFT */ |
336 | int clip_right; | 338 | int clip_right; |
337 | uint8_t *img_pix; | 339 | uint8_t *img_pix; |
338 | 340 | ||
339 | dy_step = INT_TO_SCALED(dst_height) / img_height; | 341 | dy_step = INT_TO_SCALED(dst_height) / img_height; |
340 | x_scale = INT_TO_SCALED(img_width) / dst_width; | 342 | x_scale = INT_TO_SCALED(img_width) / dst_width; |
341 | 343 | ||
342 | img_pix = img + 4 * ( (img_overl->y * img_height / dst_height) * img_width | 344 | img_pix = img + 4 * ( (img_overl->y * img_height / dst_height) * img_width |
343 | + (img_overl->x * img_width / dst_width)); | 345 | + (img_overl->x * img_width / dst_width)); |
344 | 346 | ||
345 | trans = img_overl->clip_trans; | 347 | trans = img_overl->clip_trans; |
346 | 348 | ||
347 | /* avoid wraping overlay if drawing to small image */ | 349 | /* avoid wraping overlay if drawing to small image */ |
348 | if( (img_overl->x + img_overl->clip_right) < dst_width ) | 350 | if( (img_overl->x + img_overl->clip_right) < dst_width ) |
349 | clip_right = img_overl->clip_right; | 351 | clip_right = img_overl->clip_right; |
350 | else | 352 | else |
351 | clip_right = dst_width - 1 - img_overl->x; | 353 | clip_right = dst_width - 1 - img_overl->x; |
352 | 354 | ||
353 | /* avoid buffer overflow */ | 355 | /* avoid buffer overflow */ |
354 | if( (src_height + img_overl->y) >= dst_height ) | 356 | if( (src_height + img_overl->y) >= dst_height ) |
355 | src_height = dst_height - 1 - img_overl->y; | 357 | src_height = dst_height - 1 - img_overl->y; |
356 | 358 | ||
357 | for (y = dy = 0; y < src_height && rle < rle_limit; ) { | 359 | for (y = dy = 0; y < src_height && rle < rle_limit; ) { |
358 | int mask = !(img_overl->clip_top > y || img_overl->clip_bottom < y); | 360 | int mask = !(img_overl->clip_top > y || img_overl->clip_bottom < y); |
359 | rle_elem_t *rle_start = rle; | 361 | rle_elem_t *rle_start = rle; |
360 | 362 | ||
361 | for (x = x1_scaled = 0; x < src_width;) { | 363 | for (x = x1_scaled = 0; x < src_width;) { |
362 | uint8_t clr; | 364 | uint8_t clr; |
363 | uint16_t o; | 365 | uint16_t o; |
364 | int rlelen; | 366 | int rlelen; |
365 | 367 | ||
366 | clr = rle->color; | 368 | clr = rle->color; |
367 | o = trans[clr]; | 369 | o = trans[clr]; |
368 | rlelen = rle->len; | 370 | rlelen = rle->len; |
369 | 371 | ||
370 | if (o && mask) { | 372 | if (o && mask) { |
371 | /* threat cases where clipping border is inside rle->len pixels */ | 373 | /* threat cases where clipping border is inside rle->len pixels */ |
372 | if ( img_overl->clip_left > x ) { | 374 | if ( img_overl->clip_left > x ) { |
373 | if( img_overl->clip_left < x + rlelen ) { | 375 | if( img_overl->clip_left < x + rlelen ) { |
374 | x1_scaled = SCALED_TO_INT( img_overl->clip_left * x_scale ); | 376 | x1_scaled = SCALED_TO_INT( img_overl->clip_left * x_scale ); |
375 | rlelen -= img_overl->clip_left - x; | 377 | rlelen -= img_overl->clip_left - x; |
376 | x += img_overl->clip_left - x; | 378 | x += img_overl->clip_left - x; |
377 | } else { | 379 | } else { |
378 | o = 0; | 380 | o = 0; |
379 | } | 381 | } |
380 | } else if( clip_right < x + rlelen ) { | 382 | } else if( clip_right < x + rlelen ) { |
381 | if( clip_right > x ) { | 383 | if( clip_right > x ) { |
382 | x2_scaled = SCALED_TO_INT( clip_right * x_scale); | 384 | x2_scaled = SCALED_TO_INT( clip_right * x_scale); |
383 | mem_blend24_32(img_pix + x1_scaled*4, clut[clr].cb, | 385 | mem_blend24_32(img_pix + x1_scaled*4, clut[clr].cb, |
384 | clut[clr].cr, clut[clr].y, | 386 | clut[clr].cr, clut[clr].y, |
385 | o, x2_scaled-x1_scaled); | 387 | o, x2_scaled-x1_scaled); |
386 | o = 0; | 388 | o = 0; |
387 | } else { | 389 | } else { |
388 | o = 0; | 390 | o = 0; |
389 | } | 391 | } |
390 | } | 392 | } |
391 | } | 393 | } |
392 | 394 | ||
393 | x2_scaled = SCALED_TO_INT((x + rlelen) * x_scale); | 395 | x2_scaled = SCALED_TO_INT((x + rlelen) * x_scale); |
394 | if (o && mask) { | 396 | if (o && mask) { |
395 | mem_blend24_32(img_pix + x1_scaled*4, clut[clr].cb, | 397 | mem_blend24_32(img_pix + x1_scaled*4, clut[clr].cb, |
396 | clut[clr].cr, clut[clr].y, | 398 | clut[clr].cr, clut[clr].y, |
397 | o, x2_scaled-x1_scaled); | 399 | o, x2_scaled-x1_scaled); |
398 | } | 400 | } |
399 | 401 | ||
400 | x1_scaled = x2_scaled; | 402 | x1_scaled = x2_scaled; |
401 | x += rlelen; | 403 | x += rlelen; |
402 | rle++; | 404 | rle++; |
403 | if (rle >= rle_limit) break; | 405 | if (rle >= rle_limit) break; |
404 | } | 406 | } |
405 | 407 | ||
406 | img_pix += img_width * 4; | 408 | img_pix += img_width * 4; |
407 | dy += dy_step; | 409 | dy += dy_step; |
408 | if (dy >= INT_TO_SCALED(1)) { | 410 | if (dy >= INT_TO_SCALED(1)) { |
409 | dy -= INT_TO_SCALED(1); | 411 | dy -= INT_TO_SCALED(1); |
410 | ++y; | 412 | ++y; |
411 | while (dy >= INT_TO_SCALED(1)) { | 413 | while (dy >= INT_TO_SCALED(1)) { |
412 | rle = rle_img_advance_line(rle, rle_limit, src_width); | 414 | rle = rle_img_advance_line(rle, rle_limit, src_width); |
413 | dy -= INT_TO_SCALED(1); | 415 | dy -= INT_TO_SCALED(1); |
414 | ++y; | 416 | ++y; |
415 | } | 417 | } |
416 | } else { | 418 | } else { |
417 | rle = rle_start; /* y-scaling, reuse the last rle encoded line */ | 419 | rle = rle_start; /* y-scaling, reuse the last rle encoded line */ |
418 | } | 420 | } |
419 | } | 421 | } |
420 | } | 422 | } |
421 | 423 | ||
422 | static void mem_blend8(uint8_t *mem, uint8_t val, uint8_t o, size_t sz) | 424 | static void mem_blend8(uint8_t *mem, uint8_t val, uint8_t o, size_t sz) |
423 | { | 425 | { |
424 | uint8_t *limit = mem + sz; | 426 | uint8_t *limit = mem + sz; |
425 | while (mem < limit) { | 427 | while (mem < limit) { |
426 | *mem = BLEND_BYTE(*mem, val, o); | 428 | *mem = BLEND_BYTE(*mem, val, o); |
427 | mem++; | 429 | mem++; |
428 | } | 430 | } |
429 | } | 431 | } |
430 | 432 | ||
431 | void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, | 433 | void blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, |
432 | int dst_width, int dst_height) | 434 | int dst_width, int dst_height) |
433 | { | 435 | { |
434 | clut_t *my_clut; | 436 | clut_t *my_clut; |
435 | uint8_t *my_trans; | 437 | uint8_t *my_trans; |
436 | 438 | ||
437 | int src_width = img_overl->width; | 439 | int src_width = img_overl->width; |
438 | int src_height = img_overl->height; | 440 | int src_height = img_overl->height; |
439 | rle_elem_t *rle = img_overl->rle; | 441 | rle_elem_t *rle = img_overl->rle; |
440 | rle_elem_t *rle_limit = rle + img_overl->num_rle; | 442 | rle_elem_t *rle_limit = rle + img_overl->num_rle; |
441 | int x_off = img_overl->x; | 443 | int x_off = img_overl->x; |
442 | int y_off = img_overl->y; | 444 | int y_off = img_overl->y; |
443 | int ymask,xmask; | 445 | int ymask,xmask; |
444 | int rle_this_bite; | 446 | int rle_this_bite; |
445 | int rle_remainder; | 447 | int rle_remainder; |
446 | int rlelen; | 448 | int rlelen; |
447 | int x, y; | 449 | int x, y; |
448 | int clip_right; | 450 | int clip_right; |
449 | uint8_t clr=0; | 451 | uint8_t clr=0; |
450 | 452 | ||
451 | uint8_t *dst_y = dst_base[0] + dst_width * y_off + x_off; | 453 | uint8_t *dst_y = dst_base[0] + dst_width * y_off + x_off; |
452 | uint8_t *dst_cr = dst_base[2] + | 454 | uint8_t *dst_cr = dst_base[2] + |
453 | (y_off / 2) * (dst_width / 2) + (x_off / 2) + 1; | 455 | (y_off / 2) * (dst_width / 2) + (x_off / 2) + 1; |
454 | uint8_t *dst_cb = dst_base[1] + | 456 | uint8_t *dst_cb = dst_base[1] + |
455 | (y_off / 2) * (dst_width / 2) + (x_off / 2) + 1; | 457 | (y_off / 2) * (dst_width / 2) + (x_off / 2) + 1; |
456 | #ifdef LOG_BLEND_YUV | 458 | #ifdef LOG_BLEND_YUV |
457 | printf("overlay_blend started x=%d, y=%d, w=%d h=%d\n",img_overl->x,img_overl->y,img_overl->width,img_overl->height); | 459 | printf("overlay_blend started x=%d, y=%d, w=%d h=%d\n",img_overl->x,img_overl->y,img_overl->width,img_overl->height); |
458 | #endif | 460 | #endif |
459 | my_clut = (clut_t*) img_overl->clip_color; | 461 | my_clut = (clut_t*) img_overl->clip_color; |
460 | my_trans = img_overl->clip_trans; | 462 | my_trans = img_overl->clip_trans; |
461 | 463 | ||
462 | /* avoid wraping overlay if drawing to small image */ | 464 | /* avoid wraping overlay if drawing to small image */ |
463 | if( (x_off + img_overl->clip_right) < dst_width ) | 465 | if( (x_off + img_overl->clip_right) < dst_width ) |
464 | clip_right = img_overl->clip_right; | 466 | clip_right = img_overl->clip_right; |
465 | else | 467 | else |
466 | clip_right = dst_width - 1 - x_off; | 468 | clip_right = dst_width - 1 - x_off; |
467 | 469 | ||
468 | /* avoid buffer overflow */ | 470 | /* avoid buffer overflow */ |
469 | if( (src_height + y_off) >= dst_height ) | 471 | if( (src_height + y_off) >= dst_height ) |
470 | src_height = dst_height - 1 - y_off; | 472 | src_height = dst_height - 1 - y_off; |
471 | 473 | ||
472 | rlelen=rle_remainder=0; | 474 | rlelen=rle_remainder=0; |
473 | for (y = 0; y < src_height; y++) { | 475 | for (y = 0; y < src_height; y++) { |
474 | ymask = ((img_overl->clip_top > y) || (img_overl->clip_bottom < y)); | 476 | ymask = ((img_overl->clip_top > y) || (img_overl->clip_bottom < y)); |
475 | xmask = 0; | 477 | xmask = 0; |
476 | #ifdef LOG_BLEND_YUV | 478 | #ifdef LOG_BLEND_YUV |
477 | printf("X started ymask=%d y=%d src_height=%d\n",ymask, y, src_height); | 479 | printf("X started ymask=%d y=%d src_height=%d\n",ymask, y, src_height); |
478 | #endif | 480 | #endif |
479 | 481 | ||
480 | for (x = 0; x < src_width;) { | 482 | for (x = 0; x < src_width;) { |
481 | uint16_t o; | 483 | uint16_t o; |
482 | #ifdef LOG_BLEND_YUV | 484 | #ifdef LOG_BLEND_YUV |
483 | printf("1:rle_len=%d, remainder=%d, x=%d\n",rlelen, rle_remainder, x); | 485 | printf("1:rle_len=%d, remainder=%d, x=%d\n",rlelen, rle_remainder, x); |
484 | #endif | 486 | #endif |
485 | 487 | ||
486 | if ((rlelen < 0) || (rle_remainder < 0)) { | 488 | if ((rlelen < 0) || (rle_remainder < 0)) { |
487 | printf("alphablend: major bug in blend_yuv < 0\n"); | 489 | printf("alphablend: major bug in blend_yuv < 0\n"); |
488 | } | 490 | } |
489 | if (rlelen == 0) { | 491 | if (rlelen == 0) { |
490 | rle_remainder = rlelen = rle->len; | 492 | rle_remainder = rlelen = rle->len; |
491 | clr = rle->color; | 493 | clr = rle->color; |
492 | rle++; | 494 | rle++; |
493 | } | 495 | } |
494 | if (rle_remainder == 0) { | 496 | if (rle_remainder == 0) { |
495 | rle_remainder = rlelen; | 497 | rle_remainder = rlelen; |
496 | } | 498 | } |
497 | if ((rle_remainder + x) > src_width) { | 499 | if ((rle_remainder + x) > src_width) { |
498 | /* Do something for long rlelengths */ | 500 | /* Do something for long rlelengths */ |
499 | rle_remainder = src_width - x; | 501 | rle_remainder = src_width - x; |
500 | ; | 502 | ; |
501 | } | 503 | } |
502 | #ifdef LOG_BLEND_YUV | 504 | #ifdef LOG_BLEND_YUV |
503 | printf("2:rle_len=%d, remainder=%d, x=%d\n",rlelen, rle_remainder, x); | 505 | printf("2:rle_len=%d, remainder=%d, x=%d\n",rlelen, rle_remainder, x); |
504 | #endif | 506 | #endif |
505 | 507 | ||
506 | if (ymask == 0) { | 508 | if (ymask == 0) { |
507 | if (x <= img_overl->clip_left) { | 509 | if (x <= img_overl->clip_left) { |
508 | /* Starts outside clip area */ | 510 | /* Starts outside clip area */ |
509 | if ((x + rle_remainder - 1) > img_overl->clip_left ) { | 511 | if ((x + rle_remainder - 1) > img_overl->clip_left ) { |
510 | #ifdef LOG_BLEND_YUV | 512 | #ifdef LOG_BLEND_YUV |
511 | printf("Outside clip left %d, ending inside\n", img_overl->clip_left); | 513 | printf("Outside clip left %d, ending inside\n", img_overl->clip_left); |
512 | #endif | 514 | #endif |
513 | /* Cutting needed, starts outside, ends inside */ | 515 | /* Cutting needed, starts outside, ends inside */ |
514 | rle_this_bite = (img_overl->clip_left - x + 1); | 516 | rle_this_bite = (img_overl->clip_left - x + 1); |
515 | rle_remainder -= rle_this_bite; | 517 | rle_remainder -= rle_this_bite; |
516 | rlelen -= rle_this_bite; | 518 | rlelen -= rle_this_bite; |
517 | my_clut = (clut_t*) img_overl->color; | 519 | my_clut = (clut_t*) img_overl->color; |
518 | my_trans = img_overl->trans; | 520 | my_trans = img_overl->trans; |
519 | xmask = 0; | 521 | xmask = 0; |
520 | } else { | 522 | } else { |
521 | #ifdef LOG_BLEND_YUV | 523 | #ifdef LOG_BLEND_YUV |
522 | printf("Outside clip left %d, ending outside\n", img_overl->clip_left); | 524 | printf("Outside clip left %d, ending outside\n", img_overl->clip_left); |
523 | #endif | 525 | #endif |
524 | /* no cutting needed, starts outside, ends outside */ | 526 | /* no cutting needed, starts outside, ends outside */ |
525 | rle_this_bite = rle_remainder; | 527 | rle_this_bite = rle_remainder; |
526 | rle_remainder = 0; | 528 | rle_remainder = 0; |
527 | rlelen -= rle_this_bite; | 529 | rlelen -= rle_this_bite; |
528 | my_clut = (clut_t*) img_overl->color; | 530 | my_clut = (clut_t*) img_overl->color; |
529 | my_trans = img_overl->trans; | 531 | my_trans = img_overl->trans; |
530 | xmask = 0; | 532 | xmask = 0; |
531 | } | 533 | } |
532 | } else if (x < clip_right) { | 534 | } else if (x < clip_right) { |
533 | /* Starts inside clip area */ | 535 | /* Starts inside clip area */ |
534 | if ((x + rle_remainder) > clip_right ) { | 536 | if ((x + rle_remainder) > clip_right ) { |
535 | #ifdef LOG_BLEND_YUV | 537 | #ifdef LOG_BLEND_YUV |
536 | printf("Inside clip right %d, ending outside\n", clip_right); | 538 | printf("Inside clip right %d, ending outside\n", clip_right); |
537 | #endif | 539 | #endif |
538 | /* Cutting needed, starts inside, ends outside */ | 540 | /* Cutting needed, starts inside, ends outside */ |
539 | rle_this_bite = (clip_right - x); | 541 | rle_this_bite = (clip_right - x); |
540 | rle_remainder -= rle_this_bite; | 542 | rle_remainder -= rle_this_bite; |
541 | rlelen -= rle_this_bite; | 543 | rlelen -= rle_this_bite; |
542 | my_clut = (clut_t*) img_overl->clip_color; | 544 | my_clut = (clut_t*) img_overl->clip_color; |
543 | my_trans = img_overl->clip_trans; | 545 | my_trans = img_overl->clip_trans; |
544 | xmask++; | 546 | xmask++; |
545 | } else { | 547 | } else { |
546 | #ifdef LOG_BLEND_YUV | 548 | #ifdef LOG_BLEND_YUV |
547 | printf("Inside clip right %d, ending inside\n", clip_right); | 549 | printf("Inside clip right %d, ending inside\n", clip_right); |
548 | #endif | 550 | #endif |
549 | /* no cutting needed, starts inside, ends inside */ | 551 | /* no cutting needed, starts inside, ends inside */ |
550 | rle_this_bite = rle_remainder; | 552 | rle_this_bite = rle_remainder; |
551 | rle_remainder = 0; | 553 | rle_remainder = 0; |
552 | rlelen -= rle_this_bite; | 554 | rlelen -= rle_this_bite; |
553 | my_clut = (clut_t*) img_overl->clip_color; | 555 | my_clut = (clut_t*) img_overl->clip_color; |
554 | my_trans = img_overl->clip_trans; | 556 | my_trans = img_overl->clip_trans; |
555 | xmask++; | 557 | xmask++; |
556 | } | 558 | } |
557 | } else if (x >= clip_right) { | 559 | } else if (x >= clip_right) { |
558 | /* Starts outside clip area, ends outsite clip area */ | 560 | /* Starts outside clip area, ends outsite clip area */ |
559 | if ((x + rle_remainder ) > src_width ) { | 561 | if ((x + rle_remainder ) > src_width ) { |
560 | #ifdef LOG_BLEND_YUV | 562 | #ifdef LOG_BLEND_YUV |
561 | printf("Outside clip right %d, ending eol\n", clip_right); | 563 | printf("Outside clip right %d, ending eol\n", clip_right); |
562 | #endif | 564 | #endif |
563 | /* Cutting needed, starts outside, ends at right edge */ | 565 | /* Cutting needed, starts outside, ends at right edge */ |
564 | /* It should never reach here due to the earlier test of src_width */ | 566 | /* It should never reach here due to the earlier test of src_width */ |
565 | rle_this_bite = (src_width - x ); | 567 | rle_this_bite = (src_width - x ); |
566 | rle_remainder -= rle_this_bite; | 568 | rle_remainder -= rle_this_bite; |
567 | rlelen -= rle_this_bite; | 569 | rlelen -= rle_this_bite; |
568 | my_clut = (clut_t*) img_overl->color; | 570 | my_clut = (clut_t*) img_overl->color; |
569 | my_trans = img_overl->trans; | 571 | my_trans = img_overl->trans; |
570 | xmask = 0; | 572 | xmask = 0; |
571 | } else { | 573 | } else { |
572 | /* no cutting needed, starts outside, ends outside */ | 574 | /* no cutting needed, starts outside, ends outside */ |
573 | #ifdef LOG_BLEND_YUV | 575 | #ifdef LOG_BLEND_YUV |
574 | printf("Outside clip right %d, ending outside\n", clip_right); | 576 | printf("Outside clip right %d, ending outside\n", clip_right); |
575 | #endif | 577 | #endif |
576 | rle_this_bite = rle_remainder; | 578 | rle_this_bite = rle_remainder; |
577 | rle_remainder = 0; | 579 | rle_remainder = 0; |
578 | rlelen -= rle_this_bite; | 580 | rlelen -= rle_this_bite; |
579 | my_clut = (clut_t*) img_overl->color; | 581 | my_clut = (clut_t*) img_overl->color; |
580 | my_trans = img_overl->trans; | 582 | my_trans = img_overl->trans; |
581 | xmask = 0; | 583 | xmask = 0; |
582 | } | 584 | } |
583 | } | 585 | } |
584 | } else { | 586 | } else { |
585 | /* Outside clip are due to y */ | 587 | /* Outside clip are due to y */ |
586 | /* no cutting needed, starts outside, ends outside */ | 588 | /* no cutting needed, starts outside, ends outside */ |
587 | rle_this_bite = rle_remainder; | 589 | rle_this_bite = rle_remainder; |
588 | rle_remainder = 0; | 590 | rle_remainder = 0; |
589 | rlelen -= rle_this_bite; | 591 | rlelen -= rle_this_bite; |
590 | my_clut = (clut_t*) img_overl->color; | 592 | my_clut = (clut_t*) img_overl->color; |
591 | my_trans = img_overl->trans; | 593 | my_trans = img_overl->trans; |
592 | xmask = 0; | 594 | xmask = 0; |
593 | } | 595 | } |
594 | o = my_trans[clr]; | 596 | o = my_trans[clr]; |
595 | #ifdef LOG_BLEND_YUV | 597 | #ifdef LOG_BLEND_YUV |
596 | printf("Trans=%d clr=%d xmask=%d my_clut[clr]=%d\n",o, clr, xmask, my_clut[clr].y); | 598 | printf("Trans=%d clr=%d xmask=%d my_clut[clr]=%d\n",o, clr, xmask, my_clut[clr].y); |
597 | #endif | 599 | #endif |
598 | if (o) { | 600 | if (o) { |
599 | if(o >= 15) { | 601 | if(o >= 15) { |
600 | memset(dst_y + x, my_clut[clr].y, rle_this_bite); | 602 | memset(dst_y + x, my_clut[clr].y, rle_this_bite); |
601 | if (y & 1) { | 603 | if (y & 1) { |
602 | memset(dst_cr + (x >> 1), my_clut[clr].cr, (rle_this_bite+1) >> 1); | 604 | memset(dst_cr + (x >> 1), my_clut[clr].cr, (rle_this_bite+1) >> 1); |
603 | memset(dst_cb + (x >> 1), my_clut[clr].cb, (rle_this_bite+1) >> 1); | 605 | memset(dst_cb + (x >> 1), my_clut[clr].cb, (rle_this_bite+1) >> 1); |
604 | } | 606 | } |
605 | } else { | 607 | } else { |
606 | mem_blend8(dst_y + x, my_clut[clr].y, o, rle_this_bite); | 608 | mem_blend8(dst_y + x, my_clut[clr].y, o, rle_this_bite); |
607 | if (y & 1) { | 609 | if (y & 1) { |
608 | /* Blending cr and cb should use a different function, with pre -128 to each sample */ | 610 | /* Blending cr and cb should use a different function, with pre -128 to each sample */ |
609 | mem_blend8(dst_cr + (x >> 1), my_clut[clr].cr, o, (rle_this_bite+1) >> 1); | 611 | mem_blend8(dst_cr + (x >> 1), my_clut[clr].cr, o, (rle_this_bite+1) >> 1); |
610 | mem_blend8(dst_cb + (x >> 1), my_clut[clr].cb, o, (rle_this_bite+1) >> 1); | 612 | mem_blend8(dst_cb + (x >> 1), my_clut[clr].cb, o, (rle_this_bite+1) >> 1); |
611 | } | 613 | } |
612 | } | 614 | } |
613 | 615 | ||
614 | } | 616 | } |
615 | #ifdef LOG_BLEND_YUV | 617 | #ifdef LOG_BLEND_YUV |
616 | printf("rle_this_bite=%d, remainder=%d, x=%d\n",rle_this_bite, rle_remainder, x); | 618 | printf("rle_this_bite=%d, remainder=%d, x=%d\n",rle_this_bite, rle_remainder, x); |
617 | #endif | 619 | #endif |
618 | x += rle_this_bite; | 620 | x += rle_this_bite; |
619 | if (rle >= rle_limit) { | 621 | if (rle >= rle_limit) { |
620 | #ifdef LOG_BLEND_YUV | 622 | #ifdef LOG_BLEND_YUV |
621 | printf("x-rle_limit\n"); | 623 | printf("x-rle_limit\n"); |
622 | #endif | 624 | #endif |
623 | break; | 625 | break; |
624 | } | 626 | } |
625 | } | 627 | } |
626 | if (rle >= rle_limit) { | 628 | if (rle >= rle_limit) { |
627 | #ifdef LOG_BLEND_YUV | 629 | #ifdef LOG_BLEND_YUV |
628 | printf("x-rle_limit\n"); | 630 | printf("x-rle_limit\n"); |
629 | #endif | 631 | #endif |
630 | break; | 632 | break; |
631 | } | 633 | } |
632 | 634 | ||
633 | dst_y += dst_width; | 635 | dst_y += dst_width; |
634 | 636 | ||
635 | if (y & 1) { | 637 | if (y & 1) { |
636 | dst_cr += (dst_width + 1) / 2; | 638 | dst_cr += (dst_width + 1) / 2; |
637 | dst_cb += (dst_width + 1) / 2; | 639 | dst_cb += (dst_width + 1) / 2; |
638 | } | 640 | } |
639 | } | 641 | } |
640 | #ifdef LOG_BLEND_YUV | 642 | #ifdef LOG_BLEND_YUV |
641 | printf("overlay_blend ended\n"); | 643 | printf("overlay_blend ended\n"); |
642 | #endif | 644 | #endif |
643 | } | 645 | } |
644 | 646 | ||
645 | void blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl, | 647 | void blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl, |
646 | int dst_width, int dst_height) | 648 | int dst_width, int dst_height) |
647 | { | 649 | { |
648 | clut_t *my_clut; | 650 | clut_t *my_clut; |
649 | uint8_t *my_trans; | 651 | uint8_t *my_trans; |
650 | 652 | ||
651 | int src_width = img_overl->width; | 653 | int src_width = img_overl->width; |
652 | int src_height = img_overl->height; | 654 | int src_height = img_overl->height; |
653 | rle_elem_t *rle = img_overl->rle; | 655 | rle_elem_t *rle = img_overl->rle; |
654 | rle_elem_t *rle_limit = rle + img_overl->num_rle; | 656 | rle_elem_t *rle_limit = rle + img_overl->num_rle; |
655 | int x_off = img_overl->x; | 657 | int x_off = img_overl->x; |
656 | int y_off = img_overl->y; | 658 | int y_off = img_overl->y; |
657 | int mask; | 659 | int mask; |
658 | int x, y; | 660 | int x, y; |
659 | int l; | 661 | int l; |
660 | int clip_right; | 662 | int clip_right; |
661 | uint32_t yuy2; | 663 | uint32_t yuy2; |
662 | 664 | ||
663 | uint8_t *dst_y = dst_img + 2 * (dst_width * y_off + x_off); | 665 | uint8_t *dst_y = dst_img + 2 * (dst_width * y_off + x_off); |
664 | uint8_t *dst; | 666 | uint8_t *dst; |
665 | 667 | ||
666 | my_clut = (clut_t*) img_overl->clip_color; | 668 | my_clut = (clut_t*) img_overl->clip_color; |
667 | my_trans = img_overl->clip_trans; | 669 | my_trans = img_overl->clip_trans; |
668 | 670 | ||
669 | /* avoid wraping overlay if drawing to small image */ | 671 | /* avoid wraping overlay if drawing to small image */ |
670 | if( (x_off + img_overl->clip_right) < dst_width ) | 672 | if( (x_off + img_overl->clip_right) < dst_width ) |
671 | clip_right = img_overl->clip_right; | 673 | clip_right = img_overl->clip_right; |
672 | else | 674 | else |
673 | clip_right = dst_width - 1 - x_off; | 675 | clip_right = dst_width - 1 - x_off; |
674 | 676 | ||
675 | /* avoid buffer overflow */ | 677 | /* avoid buffer overflow */ |
676 | if( (src_height + y_off) >= dst_height ) | 678 | if( (src_height + y_off) >= dst_height ) |
677 | src_height = dst_height - 1 - y_off; | 679 | src_height = dst_height - 1 - y_off; |
678 | 680 | ||
679 | for (y = 0; y < src_height; y++) { | 681 | for (y = 0; y < src_height; y++) { |
680 | mask = !(img_overl->clip_top > y || img_overl->clip_bottom < y); | 682 | mask = !(img_overl->clip_top > y || img_overl->clip_bottom < y); |
681 | 683 | ||
682 | dst = dst_y; | 684 | dst = dst_y; |
683 | for (x = 0; x < src_width;) { | 685 | for (x = 0; x < src_width;) { |
684 | uint8_t clr; | 686 | uint8_t clr; |
685 | uint16_t o; | 687 | uint16_t o; |
686 | int rlelen; | 688 | int rlelen; |
687 | 689 | ||
688 | clr = rle->color; | 690 | clr = rle->color; |
689 | o = my_trans[clr]; | 691 | o = my_trans[clr]; |
690 | rlelen = rle->len; | 692 | rlelen = rle->len; |
691 | 693 | ||
692 | if (o && mask) { | 694 | if (o && mask) { |
693 | /* threat cases where clipping border is inside rle->len pixels */ | 695 | /* threat cases where clipping border is inside rle->len pixels */ |
694 | if ( img_overl->clip_left > x ) { | 696 | if ( img_overl->clip_left > x ) { |
695 | if( img_overl->clip_left < x + rlelen ) { | 697 | if( img_overl->clip_left < x + rlelen ) { |
696 | rlelen -= img_overl->clip_left - x; | 698 | rlelen -= img_overl->clip_left - x; |
697 | x += img_overl->clip_left - x; | 699 | x += img_overl->clip_left - x; |
698 | } else { | 700 | } else { |
699 | o = 0; | 701 | o = 0; |
700 | } | 702 | } |
701 | } else if( clip_right < x + rlelen ) { | 703 | } else if( clip_right < x + rlelen ) { |
702 | if( clip_right > x ) { | 704 | if( clip_right > x ) { |
703 | /* fixme: case not implemented */ | 705 | /* fixme: case not implemented */ |
704 | o = 0; | 706 | o = 0; |
705 | } else { | 707 | } else { |
706 | o = 0; | 708 | o = 0; |
707 | } | 709 | } |
708 | } | 710 | } |
709 | } | 711 | } |
710 | 712 | ||
711 | 713 | ||
712 | if (o && mask) { | 714 | if (o && mask) { |
713 | l = rlelen>>1; | 715 | l = rlelen>>1; |
714 | if( !(x & 1) ) { | 716 | if( !(x & 1) ) { |
715 | yuy2 = my_clut[clr].y + (my_clut[clr].cb << 8) + | 717 | yuy2 = my_clut[clr].y + (my_clut[clr].cb << 8) + |
716 | (my_clut[clr].y << 16) + (my_clut[clr].cr << 24); | 718 | (my_clut[clr].y << 16) + (my_clut[clr].cr << 24); |
717 | } else { | 719 | } else { |
718 | yuy2 = my_clut[clr].y + (my_clut[clr].cr << 8) + | 720 | yuy2 = my_clut[clr].y + (my_clut[clr].cr << 8) + |
719 | (my_clut[clr].y << 16) + (my_clut[clr].cb << 24); | 721 | (my_clut[clr].y << 16) + (my_clut[clr].cb << 24); |
720 | } | 722 | } |
721 | 723 | ||
722 | if (o >= 15) { | 724 | if (o >= 15) { |
723 | while(l--) { | 725 | while(l--) { |
724 | *((uint32_t *)dst)++ = yuy2; | 726 | *((uint32_t *)dst)++ = yuy2; |
725 | } | 727 | } |
726 | if(rlelen & 1) | 728 | if(rlelen & 1) |
727 | *((uint16_t *)dst)++ = yuy2 & 0xffff; | 729 | *((uint16_t *)dst)++ = yuy2 & 0xffff; |
728 | } else { | 730 | } else { |
729 | if( l ) { | 731 | if( l ) { |
730 | mem_blend32(dst, (uint8_t *)&yuy2, o, l); | 732 | mem_blend32(dst, (uint8_t *)&yuy2, o, l); |
731 | dst += 4*l; | 733 | dst += 4*l; |
732 | } | 734 | } |
733 | 735 | ||
734 | if(rlelen & 1) { | 736 | if(rlelen & 1) { |
735 | *dst = BLEND_BYTE(*dst, *((uint8_t *)&yuy2), o); | 737 | *dst = BLEND_BYTE(*dst, *((uint8_t *)&yuy2), o); |
736 | dst++; | 738 | dst++; |
737 | *dst = BLEND_BYTE(*dst, *((uint8_t *)&yuy2+1), o); | 739 | *dst = BLEND_BYTE(*dst, *((uint8_t *)&yuy2+1), o); |
738 | dst++; | 740 | dst++; |
739 | } | 741 | } |
740 | } | 742 | } |
741 | } else { | 743 | } else { |
742 | dst += rlelen*2; | 744 | dst += rlelen*2; |
743 | } | 745 | } |
744 | 746 | ||
745 | x += rlelen; | 747 | x += rlelen; |
746 | rle++; | 748 | rle++; |
747 | if (rle >= rle_limit) break; | 749 | if (rle >= rle_limit) break; |
748 | } | 750 | } |
749 | if (rle >= rle_limit) break; | 751 | if (rle >= rle_limit) break; |
750 | 752 | ||
751 | dst_y += dst_width*2; | 753 | dst_y += dst_width*2; |
752 | } | 754 | } |
753 | } | 755 | } |
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 45f301e..620c71f 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -1,599 +1,599 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <qpe/qpeapplication.h> | 34 | #include <qpe/qpeapplication.h> |
35 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | 37 | ||
38 | #include <qwidget.h> | 38 | #include <qwidget.h> |
39 | #include <qpixmap.h> | 39 | #include <qpixmap.h> |
40 | #include <qbutton.h> | 40 | #include <qbutton.h> |
41 | #include <qpainter.h> | 41 | #include <qpainter.h> |
42 | #include <qframe.h> | 42 | #include <qframe.h> |
43 | #include <qlayout.h> | 43 | #include <qlayout.h> |
44 | #include <qdir.h> | 44 | #include <qdir.h> |
45 | #include <stdlib.h> | 45 | #include <stdlib.h> |
46 | #include <stdio.h> | 46 | #include <stdio.h> |
47 | 47 | ||
48 | #include "audiowidget.h" | 48 | #include "audiowidget.h" |
49 | #include "mediaplayerstate.h" | 49 | #include "mediaplayerstate.h" |
50 | #include "playlistwidget.h" | 50 | #include "playlistwidget.h" |
51 | 51 | ||
52 | extern MediaPlayerState *mediaPlayerState; | 52 | extern MediaPlayerState *mediaPlayerState; |
53 | extern PlayListWidget *playList; | 53 | extern PlayListWidget *playList; |
54 | 54 | ||
55 | static const int xo = -2; // movable x offset | 55 | static const int xo = -2; // movable x offset |
56 | static const int yo = 22; // movable y offset | 56 | static const int yo = 22; // movable y offset |
57 | 57 | ||
58 | 58 | ||
59 | Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) { | 59 | Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) { |
60 | setFrameStyle( WinPanel | Sunken ); | 60 | setFrameStyle( WinPanel | Sunken ); |
61 | setText( "No Song" ); | 61 | setText( "No Song" ); |
62 | } | 62 | } |
63 | 63 | ||
64 | Ticker::~Ticker() { | 64 | Ticker::~Ticker() { |
65 | } | 65 | } |
66 | 66 | ||
67 | void Ticker::setText( const QString& text ) { | 67 | void Ticker::setText( const QString& text ) { |
68 | pos = 0; // reset it everytime the text is changed | 68 | pos = 0; // reset it everytime the text is changed |
69 | scrollText = text; | 69 | scrollText = text; |
70 | pixelLen = fontMetrics().width( scrollText ); | 70 | pixelLen = fontMetrics().width( scrollText ); |
71 | killTimers(); | 71 | killTimers(); |
72 | if ( pixelLen > width() ) { | 72 | if ( pixelLen > width() ) { |
73 | startTimer( 50 ); | 73 | startTimer( 50 ); |
74 | } | 74 | } |
75 | update(); | 75 | update(); |
76 | } | 76 | } |
77 | 77 | ||
78 | 78 | ||
79 | void Ticker::timerEvent( QTimerEvent * ) { | 79 | void Ticker::timerEvent( QTimerEvent * ) { |
80 | pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; | 80 | pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; |
81 | scroll( -1, 0, contentsRect() ); | 81 | scroll( -1, 0, contentsRect() ); |
82 | repaint( FALSE ); | 82 | repaint( FALSE ); |
83 | } | 83 | } |
84 | 84 | ||
85 | void Ticker::drawContents( QPainter *p ) { | 85 | void Ticker::drawContents( QPainter *p ) { |
86 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { | 86 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { |
87 | p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); | 87 | p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); |
88 | } | 88 | } |
89 | QPixmap pm( width(), height() ); | 89 | QPixmap pm( width(), height() ); |
90 | pm.fill( colorGroup().base() ); | 90 | pm.fill( colorGroup().base() ); |
91 | QPainter pmp( &pm ); | 91 | QPainter pmp( &pm ); |
92 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { | 92 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { |
93 | pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); | 93 | pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); |
94 | } | 94 | } |
95 | p->drawPixmap( 0, 0, pm ); | 95 | p->drawPixmap( 0, 0, pm ); |
96 | } | 96 | } |
97 | 97 | ||
98 | struct MediaButton { | 98 | struct MediaButton { |
99 | bool isToggle, isHeld, isDown; | 99 | bool isToggle, isHeld, isDown; |
100 | }; | 100 | }; |
101 | 101 | ||
102 | //Layout information for the audioButtons (and if it is a toggle button or not) | 102 | //Layout information for the audioButtons (and if it is a toggle button or not) |
103 | MediaButton audioButtons[] = { | 103 | MediaButton audioButtons[] = { |
104 | { TRUE, FALSE, FALSE }, // play | 104 | { TRUE, FALSE, FALSE }, // play |
105 | { FALSE, FALSE, FALSE }, // stop | 105 | { FALSE, FALSE, FALSE }, // stop |
106 | { FALSE, FALSE, FALSE }, // next | 106 | { FALSE, FALSE, FALSE }, // next |
107 | { FALSE, FALSE, FALSE }, // previous | 107 | { FALSE, FALSE, FALSE }, // previous |
108 | { FALSE, FALSE, FALSE }, // volume up | 108 | { FALSE, FALSE, FALSE }, // volume up |
109 | { FALSE, FALSE, FALSE }, // volume down | 109 | { FALSE, FALSE, FALSE }, // volume down |
110 | { TRUE, FALSE, FALSE }, // repeat/loop | 110 | { TRUE, FALSE, FALSE }, // repeat/loop |
111 | { FALSE, FALSE, FALSE }, // playlist | 111 | { FALSE, FALSE, FALSE }, // playlist |
112 | { FALSE, FALSE, FALSE }, // forward | 112 | { FALSE, FALSE, FALSE }, // forward |
113 | { FALSE, FALSE, FALSE } // back | 113 | { FALSE, FALSE, FALSE } // back |
114 | }; | 114 | }; |
115 | 115 | ||
116 | const char *skin_mask_file_names[10] = { | 116 | const char *skin_mask_file_names[10] = { |
117 | "play", "stop", "next", "prev", "up", | 117 | "play", "stop", "next", "prev", "up", |
118 | "down", "loop", "playlist", "forward", "back" | 118 | "down", "loop", "playlist", "forward", "back" |
119 | }; | 119 | }; |
120 | 120 | ||
121 | 121 | ||
122 | static void changeTextColor( QWidget *w ) { | 122 | static void changeTextColor( QWidget *w ) { |
123 | QPalette p = w->palette(); | 123 | QPalette p = w->palette(); |
124 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); | 124 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); |
125 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); | 125 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); |
126 | w->setPalette( p ); | 126 | w->setPalette( p ); |
127 | } | 127 | } |
128 | 128 | ||
129 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); | 129 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); |
130 | 130 | ||
131 | 131 | ||
132 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | 132 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : |
133 | 133 | ||
134 | QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { | 134 | QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { |
135 | 135 | ||
136 | setCaption( tr("OpiePlayer") ); | 136 | setCaption( tr("OpiePlayer") ); |
137 | 137 | ||
138 | Config cfg("OpiePlayer"); | 138 | Config cfg("OpiePlayer"); |
139 | cfg.setGroup("Options"); | 139 | cfg.setGroup("Options"); |
140 | skin = cfg.readEntry("Skin","default"); | 140 | skin = cfg.readEntry("Skin","default"); |
141 | //skin = "scaleTest"; | 141 | //skin = "scaleTest"; |
142 | // color of background, frame, degree of transparency | 142 | // color of background, frame, degree of transparency |
143 | 143 | ||
144 | QString skinPath = "opieplayer2/skins/" + skin; | 144 | QString skinPath = "opieplayer2/skins/" + skin; |
145 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 145 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
146 | imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); | 146 | imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); |
147 | imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); | 147 | imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); |
148 | 148 | ||
149 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); | 149 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); |
150 | imgButtonMask->fill( 0 ); | 150 | imgButtonMask->fill( 0 ); |
151 | 151 | ||
152 | for ( int i = 0; i < 10; i++ ) { | 152 | for ( int i = 0; i < 10; i++ ) { |
153 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" ); | 153 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" ); |
154 | masks[i] = new QBitmap( filename ); | 154 | masks[i] = new QBitmap( filename ); |
155 | 155 | ||
156 | if ( !masks[i]->isNull() ) { | 156 | if ( !masks[i]->isNull() ) { |
157 | QImage imgMask = masks[i]->convertToImage(); | 157 | QImage imgMask = masks[i]->convertToImage(); |
158 | uchar **dest = imgButtonMask->jumpTable(); | 158 | uchar **dest = imgButtonMask->jumpTable(); |
159 | for ( int y = 0; y < imgUp->height(); y++ ) { | 159 | for ( int y = 0; y < imgUp->height(); y++ ) { |
160 | uchar *line = dest[y]; | 160 | uchar *line = dest[y]; |
161 | for ( int x = 0; x < imgUp->width(); x++ ) | 161 | for ( int x = 0; x < imgUp->width(); x++ ) |
162 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 162 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
163 | line[x] = i + 1; | 163 | line[x] = i + 1; |
164 | } | 164 | } |
165 | } | 165 | } |
166 | 166 | ||
167 | } | 167 | } |
168 | 168 | ||
169 | for ( int i = 0; i < 10; i++ ) { | 169 | for ( int i = 0; i < 10; i++ ) { |
170 | buttonPixUp[i] = 0l; | 170 | buttonPixUp[i] = 0l; |
171 | buttonPixDown[i] = 0l; | 171 | buttonPixDown[i] = 0l; |
172 | } | 172 | } |
173 | 173 | ||
174 | setBackgroundPixmap( *pixBg ); | 174 | setBackgroundPixmap( *pixBg ); |
175 | 175 | ||
176 | songInfo.setFocusPolicy( QWidget::NoFocus ); | 176 | songInfo.setFocusPolicy( QWidget::NoFocus ); |
177 | changeTextColor( &songInfo ); | 177 | changeTextColor( &songInfo ); |
178 | 178 | ||
179 | slider.setFixedHeight( 20 ); | 179 | slider.setFixedHeight( 20 ); |
180 | slider.setMinValue( 0 ); | 180 | slider.setMinValue( 0 ); |
181 | slider.setMaxValue( 1 ); | 181 | slider.setMaxValue( 1 ); |
182 | slider.setFocusPolicy( QWidget::NoFocus ); | 182 | slider.setFocusPolicy( QWidget::NoFocus ); |
183 | slider.setBackgroundPixmap( *pixBg ); | 183 | slider.setBackgroundPixmap( *pixBg ); |
184 | 184 | ||
185 | time.setFocusPolicy( QWidget::NoFocus ); | 185 | time.setFocusPolicy( QWidget::NoFocus ); |
186 | time.setAlignment( Qt::AlignCenter ); | 186 | time.setAlignment( Qt::AlignCenter ); |
187 | time.setFrame(FALSE); | 187 | time.setFrame(FALSE); |
188 | changeTextColor( &time ); | 188 | changeTextColor( &time ); |
189 | 189 | ||
190 | resizeEvent( NULL ); | 190 | resizeEvent( NULL ); |
191 | 191 | ||
192 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 192 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
193 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 193 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
194 | 194 | ||
195 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 195 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
196 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 196 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
197 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); | 197 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); |
198 | // connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 198 | // connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
199 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 199 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
200 | 200 | ||
201 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); | 201 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); |
202 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); | 202 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); |
203 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); | 203 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); |
204 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); | 204 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); |
205 | 205 | ||
206 | 206 | ||
207 | 207 | ||
208 | // Intialise state | 208 | // Intialise state |
209 | setLength( mediaPlayerState->length() ); | 209 | setLength( mediaPlayerState->length() ); |
210 | setPosition( mediaPlayerState->position() ); | 210 | setPosition( mediaPlayerState->position() ); |
211 | setLooping( mediaPlayerState->fullscreen() ); | 211 | setLooping( mediaPlayerState->fullscreen() ); |
212 | // setPaused( mediaPlayerState->paused() ); | 212 | // setPaused( mediaPlayerState->paused() ); |
213 | setPlaying( mediaPlayerState->playing() ); | 213 | setPlaying( mediaPlayerState->playing() ); |
214 | 214 | ||
215 | } | 215 | } |
216 | 216 | ||
217 | AudioWidget::~AudioWidget() { | 217 | AudioWidget::~AudioWidget() { |
218 | 218 | ||
219 | for ( int i = 0; i < 10; i++ ) { | 219 | for ( int i = 0; i < 10; i++ ) { |
220 | delete buttonPixUp[i]; | 220 | delete buttonPixUp[i]; |
221 | delete buttonPixDown[i]; | 221 | delete buttonPixDown[i]; |
222 | } | 222 | } |
223 | delete pixBg; | 223 | delete pixBg; |
224 | delete imgUp; | 224 | delete imgUp; |
225 | delete imgDn; | 225 | delete imgDn; |
226 | delete imgButtonMask; | 226 | delete imgButtonMask; |
227 | for ( int i = 0; i < 10; i++ ) { | 227 | for ( int i = 0; i < 10; i++ ) { |
228 | delete masks[i]; | 228 | delete masks[i]; |
229 | } | 229 | } |
230 | // mediaPlayerState->setPlaying(false); | 230 | // mediaPlayerState->setPlaying(false); |
231 | } | 231 | } |
232 | 232 | ||
233 | namespace { | 233 | namespace { |
234 | 234 | ||
235 | QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 235 | QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
236 | QPixmap pix( img.width(), img.height() ); | 236 | QPixmap pix( img.width(), img.height() ); |
237 | QPainter p( &pix ); | 237 | QPainter p( &pix ); |
238 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 238 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
239 | p.drawImage( 0, 0, img ); | 239 | p.drawImage( 0, 0, img ); |
240 | return new QPixmap( pix ); | 240 | return new QPixmap( pix ); |
241 | } | 241 | } |
242 | 242 | ||
243 | 243 | ||
244 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { | 244 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { |
245 | QPixmap *pixmap = new QPixmap( pix ); | 245 | QPixmap *pixmap = new QPixmap( pix ); |
246 | pixmap->setMask( mask ); | 246 | pixmap->setMask( mask ); |
247 | return pixmap; | 247 | return pixmap; |
248 | } | 248 | } |
249 | 249 | ||
250 | }; | 250 | }; |
251 | 251 | ||
252 | void AudioWidget::resizeEvent( QResizeEvent * ) { | 252 | void AudioWidget::resizeEvent( QResizeEvent * ) { |
253 | int h = height(); | 253 | int h = height(); |
254 | int w = width(); | 254 | int w = width(); |
255 | 255 | ||
256 | songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); | 256 | songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); |
257 | slider.setFixedWidth( w - 110 ); | 257 | slider.setFixedWidth( w - 110 ); |
258 | slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); | 258 | slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); |
259 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); | 259 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); |
260 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); | 260 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); |
261 | 261 | ||
262 | xoff = ( w - imgUp->width() ) / 2; | 262 | xoff = ( w - imgUp->width() ) / 2; |
263 | yoff = (( h - imgUp->height() ) / 2) - 10; | 263 | yoff = (( h - imgUp->height() ) / 2) - 10; |
264 | QPoint p( xoff, yoff ); | 264 | QPoint p( xoff, yoff ); |
265 | 265 | ||
266 | QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); | 266 | QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); |
267 | QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); | 267 | QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); |
268 | 268 | ||
269 | for ( int i = 0; i < 10; i++ ) { | 269 | for ( int i = 0; i < 10; i++ ) { |
270 | if ( !masks[i]->isNull() ) { | 270 | if ( !masks[i]->isNull() ) { |
271 | delete buttonPixUp[i]; | 271 | delete buttonPixUp[i]; |
272 | delete buttonPixDown[i]; | 272 | delete buttonPixDown[i]; |
273 | buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); | 273 | buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); |
274 | buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); | 274 | buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); |
275 | } | 275 | } |
276 | } | 276 | } |
277 | 277 | ||
278 | delete pixUp; | 278 | delete pixUp; |
279 | delete pixDn; | 279 | delete pixDn; |
280 | } | 280 | } |
281 | 281 | ||
282 | static bool audioSliderBeingMoved = FALSE; | 282 | static bool audioSliderBeingMoved = FALSE; |
283 | 283 | ||
284 | 284 | ||
285 | void AudioWidget::sliderPressed() { | 285 | void AudioWidget::sliderPressed() { |
286 | audioSliderBeingMoved = TRUE; | 286 | audioSliderBeingMoved = TRUE; |
287 | } | 287 | } |
288 | 288 | ||
289 | 289 | ||
290 | void AudioWidget::sliderReleased() { | 290 | void AudioWidget::sliderReleased() { |
291 | audioSliderBeingMoved = FALSE; | 291 | audioSliderBeingMoved = FALSE; |
292 | if ( slider.width() == 0 ) | 292 | if ( slider.width() == 0 ) |
293 | return; | 293 | return; |
294 | long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); | 294 | long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); |
295 | mediaPlayerState->setPosition( val ); | 295 | mediaPlayerState->setPosition( val ); |
296 | } | 296 | } |
297 | 297 | ||
298 | void AudioWidget::setPosition( long i ) { | 298 | void AudioWidget::setPosition( long i ) { |
299 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); | 299 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); |
300 | updateSlider( i, mediaPlayerState->length() ); | 300 | updateSlider( i, mediaPlayerState->length() ); |
301 | } | 301 | } |
302 | 302 | ||
303 | 303 | ||
304 | void AudioWidget::setLength( long max ) { | 304 | void AudioWidget::setLength( long max ) { |
305 | updateSlider( mediaPlayerState->position(), max ); | 305 | updateSlider( mediaPlayerState->position(), max ); |
306 | } | 306 | } |
307 | 307 | ||
308 | 308 | ||
309 | void AudioWidget::setView( char view ) { | 309 | void AudioWidget::setView( char view ) { |
310 | 310 | ||
311 | // this isnt working for some reason | 311 | // this isnt working for some reason |
312 | 312 | ||
313 | if ( mediaPlayerState->streaming() ) { | 313 | if ( mediaPlayerState->streaming() ) { |
314 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); | 314 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); |
315 | if( !slider.isHidden()) { | 315 | if( !slider.isHidden()) { |
316 | slider.hide(); | 316 | slider.hide(); |
317 | } | 317 | } |
318 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 318 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
319 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 319 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
320 | } else { | 320 | } else { |
321 | // this stops the slider from being moved, thus | 321 | // this stops the slider from being moved, thus |
322 | // does not stop stream when it reaches the end | 322 | // does not stop stream when it reaches the end |
323 | slider.show(); | 323 | slider.show(); |
324 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 324 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
325 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 325 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
326 | } | 326 | } |
327 | 327 | ||
328 | if ( view == 'a' ) { | 328 | if ( view == 'a' ) { |
329 | // startTimer( 150 ); | 329 | // startTimer( 150 ); |
330 | showMaximized(); | 330 | showMaximized(); |
331 | } else { | 331 | } else { |
332 | killTimers(); | 332 | killTimers(); |
333 | hide(); | 333 | hide(); |
334 | } | 334 | } |
335 | qApp->processEvents(); | 335 | // qApp->processEvents(); |
336 | } | 336 | } |
337 | 337 | ||
338 | 338 | ||
339 | static QString timeAsString( long length ) { | 339 | static QString timeAsString( long length ) { |
340 | int minutes = length / 60; | 340 | int minutes = length / 60; |
341 | int seconds = length % 60; | 341 | int seconds = length % 60; |
342 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); | 342 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); |
343 | } | 343 | } |
344 | 344 | ||
345 | void AudioWidget::updateSlider( long i, long max ) { | 345 | void AudioWidget::updateSlider( long i, long max ) { |
346 | 346 | ||
347 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); | 347 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); |
348 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; | 348 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; |
349 | 349 | ||
350 | if ( max == 0 ) { | 350 | if ( max == 0 ) { |
351 | return; | 351 | return; |
352 | } | 352 | } |
353 | // Will flicker too much if we don't do this | 353 | // Will flicker too much if we don't do this |
354 | // Scale to something reasonable | 354 | // Scale to something reasonable |
355 | int width = slider.width(); | 355 | int width = slider.width(); |
356 | int val = int((double)i * width / max); | 356 | int val = int((double)i * width / max); |
357 | if ( !audioSliderBeingMoved ) { | 357 | if ( !audioSliderBeingMoved ) { |
358 | if ( slider.value() != val ) { | 358 | if ( slider.value() != val ) { |
359 | slider.setValue( val ); | 359 | slider.setValue( val ); |
360 | } | 360 | } |
361 | 361 | ||
362 | if ( slider.maxValue() != width ) { | 362 | if ( slider.maxValue() != width ) { |
363 | slider.setMaxValue( width ); | 363 | slider.setMaxValue( width ); |
364 | } | 364 | } |
365 | } | 365 | } |
366 | } | 366 | } |
367 | 367 | ||
368 | 368 | ||
369 | void AudioWidget::setToggleButton( int i, bool down ) { | 369 | void AudioWidget::setToggleButton( int i, bool down ) { |
370 | qDebug("setToggleButton %d", i); | 370 | qDebug("setToggleButton %d", i); |
371 | if ( down != audioButtons[i].isDown ) { | 371 | if ( down != audioButtons[i].isDown ) { |
372 | toggleButton( i ); | 372 | toggleButton( i ); |
373 | } | 373 | } |
374 | } | 374 | } |
375 | 375 | ||
376 | 376 | ||
377 | void AudioWidget::toggleButton( int i ) { | 377 | void AudioWidget::toggleButton( int i ) { |
378 | audioButtons[i].isDown = !audioButtons[i].isDown; | 378 | audioButtons[i].isDown = !audioButtons[i].isDown; |
379 | QPainter p(this); | 379 | QPainter p(this); |
380 | paintButton ( &p, i ); | 380 | paintButton ( &p, i ); |
381 | } | 381 | } |
382 | 382 | ||
383 | 383 | ||
384 | void AudioWidget::paintButton( QPainter *p, int i ) { | 384 | void AudioWidget::paintButton( QPainter *p, int i ) { |
385 | if ( audioButtons[i].isDown ) { | 385 | if ( audioButtons[i].isDown ) { |
386 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | 386 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); |
387 | } else { | 387 | } else { |
388 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | 388 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); |
389 | } | 389 | } |
390 | } | 390 | } |
391 | 391 | ||
392 | 392 | ||
393 | void AudioWidget::skipFor() { | 393 | void AudioWidget::skipFor() { |
394 | skipDirection = +1; | 394 | skipDirection = +1; |
395 | startTimer( 50 ); | 395 | startTimer( 50 ); |
396 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); | 396 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); |
397 | } | 397 | } |
398 | 398 | ||
399 | void AudioWidget::skipBack() { | 399 | void AudioWidget::skipBack() { |
400 | skipDirection = -1; | 400 | skipDirection = -1; |
401 | startTimer( 50 ); | 401 | startTimer( 50 ); |
402 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); | 402 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); |
403 | } | 403 | } |
404 | 404 | ||
405 | 405 | ||
406 | 406 | ||
407 | void AudioWidget::stopSkip() { | 407 | void AudioWidget::stopSkip() { |
408 | killTimers(); | 408 | killTimers(); |
409 | } | 409 | } |
410 | 410 | ||
411 | 411 | ||
412 | void AudioWidget::timerEvent( QTimerEvent * ) { | 412 | void AudioWidget::timerEvent( QTimerEvent * ) { |
413 | if ( skipDirection == +1 ) { | 413 | if ( skipDirection == +1 ) { |
414 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); | 414 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); |
415 | } else if ( skipDirection == -1 ) { | 415 | } else if ( skipDirection == -1 ) { |
416 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); | 416 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); |
417 | } | 417 | } |
418 | } | 418 | } |
419 | 419 | ||
420 | 420 | ||
421 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | 421 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { |
422 | for ( int i = 0; i < numButtons; i++ ) { | 422 | for ( int i = 0; i < numButtons; i++ ) { |
423 | if ( event->state() == QMouseEvent::LeftButton ) { | 423 | if ( event->state() == QMouseEvent::LeftButton ) { |
424 | // The test to see if the mouse click is inside the button or not | 424 | // The test to see if the mouse click is inside the button or not |
425 | int x = event->pos().x() - xoff; | 425 | int x = event->pos().x() - xoff; |
426 | int y = event->pos().y() - yoff; | 426 | int y = event->pos().y() - yoff; |
427 | 427 | ||
428 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() | 428 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() |
429 | && y < imgButtonMask->height() | 429 | && y < imgButtonMask->height() |
430 | && imgButtonMask->pixelIndex( x, y ) == i + 1 ); | 430 | && imgButtonMask->pixelIndex( x, y ) == i + 1 ); |
431 | 431 | ||
432 | if ( isOnButton && !audioButtons[i].isHeld ) { | 432 | if ( isOnButton && !audioButtons[i].isHeld ) { |
433 | audioButtons[i].isHeld = TRUE; | 433 | audioButtons[i].isHeld = TRUE; |
434 | toggleButton(i); | 434 | toggleButton(i); |
435 | switch (i) { | 435 | switch (i) { |
436 | case AudioVolumeUp: | 436 | case AudioVolumeUp: |
437 | emit moreClicked(); | 437 | emit moreClicked(); |
438 | return; | 438 | return; |
439 | case AudioVolumeDown: | 439 | case AudioVolumeDown: |
440 | emit lessClicked(); | 440 | emit lessClicked(); |
441 | return; | 441 | return; |
442 | case AudioForward: | 442 | case AudioForward: |
443 | emit forwardClicked(); | 443 | emit forwardClicked(); |
444 | return; | 444 | return; |
445 | case AudioBack: | 445 | case AudioBack: |
446 | emit backClicked(); | 446 | emit backClicked(); |
447 | return; | 447 | return; |
448 | } | 448 | } |
449 | } else if ( !isOnButton && audioButtons[i].isHeld ) { | 449 | } else if ( !isOnButton && audioButtons[i].isHeld ) { |
450 | audioButtons[i].isHeld = FALSE; | 450 | audioButtons[i].isHeld = FALSE; |
451 | toggleButton(i); | 451 | toggleButton(i); |
452 | } | 452 | } |
453 | } else { | 453 | } else { |
454 | if ( audioButtons[i].isHeld ) { | 454 | if ( audioButtons[i].isHeld ) { |
455 | audioButtons[i].isHeld = FALSE; | 455 | audioButtons[i].isHeld = FALSE; |
456 | if ( !audioButtons[i].isToggle ) { | 456 | if ( !audioButtons[i].isToggle ) { |
457 | setToggleButton( i, FALSE ); | 457 | setToggleButton( i, FALSE ); |
458 | } | 458 | } |
459 | qDebug("mouseEvent %d", i); | 459 | qDebug("mouseEvent %d", i); |
460 | switch (i) { | 460 | switch (i) { |
461 | case AudioPlay: | 461 | case AudioPlay: |
462 | if( mediaPlayerState->isPaused ) { | 462 | if( mediaPlayerState->isPaused ) { |
463 | // setToggleButton( i, FALSE ); | 463 | // setToggleButton( i, FALSE ); |
464 | mediaPlayerState->setPaused( FALSE ); | 464 | mediaPlayerState->setPaused( FALSE ); |
465 | return; | 465 | return; |
466 | } else if( !mediaPlayerState->isPaused ) { | 466 | } else if( !mediaPlayerState->isPaused ) { |
467 | // setToggleButton( i, TRUE ); | 467 | // setToggleButton( i, TRUE ); |
468 | mediaPlayerState->setPaused( TRUE ); | 468 | mediaPlayerState->setPaused( TRUE ); |
469 | return; | 469 | return; |
470 | } else { | 470 | } else { |
471 | // setToggleButton( i, TRUE ); | 471 | // setToggleButton( i, TRUE ); |
472 | // mediaPlayerState->setPlaying( videoButtons[i].isDown ); | 472 | // mediaPlayerState->setPlaying( videoButtons[i].isDown ); |
473 | } | 473 | } |
474 | case AudioStop: mediaPlayerState->setPlaying(FALSE); return; | 474 | case AudioStop: mediaPlayerState->setPlaying(FALSE); return; |
475 | case AudioNext: if(playList->whichList() ==0) mediaPlayerState->setNext(); return; | 475 | case AudioNext: if(playList->whichList() ==0) mediaPlayerState->setNext(); return; |
476 | case AudioPrevious: if(playList->whichList() ==0) mediaPlayerState->setPrev(); return; | 476 | case AudioPrevious: if(playList->whichList() ==0) mediaPlayerState->setPrev(); return; |
477 | case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; | 477 | case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; |
478 | case AudioVolumeUp: emit moreReleased(); return; | 478 | case AudioVolumeUp: emit moreReleased(); return; |
479 | case AudioVolumeDown: emit lessReleased(); return; | 479 | case AudioVolumeDown: emit lessReleased(); return; |
480 | case AudioPlayList: mediaPlayerState->setList(); return; | 480 | case AudioPlayList: mediaPlayerState->setList(); return; |
481 | case AudioForward: emit forwardReleased(); return; | 481 | case AudioForward: emit forwardReleased(); return; |
482 | case AudioBack: emit backReleased(); return; | 482 | case AudioBack: emit backReleased(); return; |
483 | } | 483 | } |
484 | } | 484 | } |
485 | } | 485 | } |
486 | } | 486 | } |
487 | } | 487 | } |
488 | 488 | ||
489 | 489 | ||
490 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { | 490 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { |
491 | mouseMoveEvent( event ); | 491 | mouseMoveEvent( event ); |
492 | } | 492 | } |
493 | 493 | ||
494 | 494 | ||
495 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { | 495 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { |
496 | mouseMoveEvent( event ); | 496 | mouseMoveEvent( event ); |
497 | } | 497 | } |
498 | 498 | ||
499 | 499 | ||
500 | void AudioWidget::showEvent( QShowEvent* ) { | 500 | void AudioWidget::showEvent( QShowEvent* ) { |
501 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 501 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
502 | mouseMoveEvent( &event ); | 502 | mouseMoveEvent( &event ); |
503 | } | 503 | } |
504 | 504 | ||
505 | 505 | ||
506 | void AudioWidget::closeEvent( QCloseEvent* ) { | 506 | void AudioWidget::closeEvent( QCloseEvent* ) { |
507 | mediaPlayerState->setList(); | 507 | mediaPlayerState->setList(); |
508 | } | 508 | } |
509 | 509 | ||
510 | 510 | ||
511 | void AudioWidget::paintEvent( QPaintEvent * pe) { | 511 | void AudioWidget::paintEvent( QPaintEvent * pe) { |
512 | if ( !pe->erased() ) { | 512 | if ( !pe->erased() ) { |
513 | // Combine with background and double buffer | 513 | // Combine with background and double buffer |
514 | QPixmap pix( pe->rect().size() ); | 514 | QPixmap pix( pe->rect().size() ); |
515 | QPainter p( &pix ); | 515 | QPainter p( &pix ); |
516 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 516 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
517 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); | 517 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); |
518 | for ( int i = 0; i < numButtons; i++ ) | 518 | for ( int i = 0; i < numButtons; i++ ) |
519 | paintButton( &p, i ); | 519 | paintButton( &p, i ); |
520 | QPainter p2( this ); | 520 | QPainter p2( this ); |
521 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 521 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
522 | } else { | 522 | } else { |
523 | QPainter p( this ); | 523 | QPainter p( this ); |
524 | for ( int i = 0; i < numButtons; i++ ) | 524 | for ( int i = 0; i < numButtons; i++ ) |
525 | paintButton( &p, i ); | 525 | paintButton( &p, i ); |
526 | } | 526 | } |
527 | } | 527 | } |
528 | 528 | ||
529 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { | 529 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { |
530 | switch ( e->key() ) { | 530 | switch ( e->key() ) { |
531 | ////////////////////////////// Zaurus keys | 531 | ////////////////////////////// Zaurus keys |
532 | case Key_Home: | 532 | case Key_Home: |
533 | break; | 533 | break; |
534 | case Key_F9: //activity | 534 | case Key_F9: //activity |
535 | hide(); | 535 | hide(); |
536 | // qDebug("Audio F9"); | 536 | // qDebug("Audio F9"); |
537 | break; | 537 | break; |
538 | case Key_F10: //contacts | 538 | case Key_F10: //contacts |
539 | break; | 539 | break; |
540 | case Key_F11: //menu | 540 | case Key_F11: //menu |
541 | mediaPlayerState->toggleBlank(); | 541 | mediaPlayerState->toggleBlank(); |
542 | break; | 542 | break; |
543 | case Key_F12: //home | 543 | case Key_F12: //home |
544 | break; | 544 | break; |
545 | case Key_F13: //mail | 545 | case Key_F13: //mail |
546 | mediaPlayerState->toggleBlank(); | 546 | mediaPlayerState->toggleBlank(); |
547 | break; | 547 | break; |
548 | case Key_Space: { | 548 | case Key_Space: { |
549 | if(mediaPlayerState->playing()) { | 549 | if(mediaPlayerState->playing()) { |
550 | // toggleButton(1); | 550 | // toggleButton(1); |
551 | mediaPlayerState->setPlaying(FALSE); | 551 | mediaPlayerState->setPlaying(FALSE); |
552 | // toggleButton(1); | 552 | // toggleButton(1); |
553 | } else { | 553 | } else { |
554 | // toggleButton(0); | 554 | // toggleButton(0); |
555 | mediaPlayerState->setPlaying(TRUE); | 555 | mediaPlayerState->setPlaying(TRUE); |
556 | // toggleButton(0); | 556 | // toggleButton(0); |
557 | } | 557 | } |
558 | } | 558 | } |
559 | break; | 559 | break; |
560 | case Key_Down: | 560 | case Key_Down: |
561 | // toggleButton(6); | 561 | // toggleButton(6); |
562 | emit lessClicked(); | 562 | emit lessClicked(); |
563 | emit lessReleased(); | 563 | emit lessReleased(); |
564 | // toggleButton(6); | 564 | // toggleButton(6); |
565 | break; | 565 | break; |
566 | case Key_Up: | 566 | case Key_Up: |
567 | // toggleButton(5); | 567 | // toggleButton(5); |
568 | emit moreClicked(); | 568 | emit moreClicked(); |
569 | emit moreReleased(); | 569 | emit moreReleased(); |
570 | // toggleButton(5); | 570 | // toggleButton(5); |
571 | break; | 571 | break; |
572 | case Key_Right: | 572 | case Key_Right: |
573 | // toggleButton(3); | 573 | // toggleButton(3); |
574 | mediaPlayerState->setNext(); | 574 | mediaPlayerState->setNext(); |
575 | // toggleButton(3); | 575 | // toggleButton(3); |
576 | break; | 576 | break; |
577 | case Key_Left: | 577 | case Key_Left: |
578 | // toggleButton(4); | 578 | // toggleButton(4); |
579 | mediaPlayerState->setPrev(); | 579 | mediaPlayerState->setPrev(); |
580 | // toggleButton(4); | 580 | // toggleButton(4); |
581 | break; | 581 | break; |
582 | case Key_Escape: { | 582 | case Key_Escape: { |
583 | /* | 583 | /* |
584 | * author pleas tell me where the i come from .-) | 584 | * author pleas tell me where the i come from .-) |
585 | #if defined(QT_QWS_IPAQ) | 585 | #if defined(QT_QWS_IPAQ) |
586 | if( mediaPlayerState->isPaused ) { | 586 | if( mediaPlayerState->isPaused ) { |
587 | setToggleButton( i, FALSE ); | 587 | setToggleButton( i, FALSE ); |
588 | mediaPlayerState->setPaused( FALSE ); | 588 | mediaPlayerState->setPaused( FALSE ); |
589 | } else if( !mediaPlayerState->isPaused ) { | 589 | } else if( !mediaPlayerState->isPaused ) { |
590 | setToggleButton( i, TRUE ); | 590 | setToggleButton( i, TRUE ); |
591 | mediaPlayerState->setPaused( TRUE ); | 591 | mediaPlayerState->setPaused( TRUE ); |
592 | } | 592 | } |
593 | #endif | 593 | #endif |
594 | */ | 594 | */ |
595 | } | 595 | } |
596 | break; | 596 | break; |
597 | 597 | ||
598 | }; | 598 | }; |
599 | } | 599 | } |
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp index d8a0694..4021d4a 100644 --- a/noncore/multimedia/opieplayer2/lib.cpp +++ b/noncore/multimedia/opieplayer2/lib.cpp | |||
@@ -1,232 +1,265 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 LJP <> | 5 | Copyright (c) 2002 LJP <> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <stdio.h> | 34 | #include <stdio.h> |
35 | #include <stdlib.h> | 35 | #include <stdlib.h> |
36 | #include <qimage.h> | 36 | #include <qimage.h> |
37 | #include <qtextstream.h> | 37 | #include <qtextstream.h> |
38 | #include <qpe/resource.h> | 38 | #include <qpe/resource.h> |
39 | 39 | ||
40 | #include <qfile.h> | 40 | #include <qfile.h> |
41 | 41 | ||
42 | #include <qgfx_qws.h> | 42 | #include <qgfx_qws.h> |
43 | #include <qdirectpainter_qws.h> | 43 | #include <qdirectpainter_qws.h> |
44 | 44 | ||
45 | #include "xinevideowidget.h" | 45 | #include "xinevideowidget.h" |
46 | #include "frame.h" | 46 | #include "frame.h" |
47 | #include "lib.h" | 47 | #include "lib.h" |
48 | 48 | ||
49 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, | 49 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, |
50 | int width, int height,int bytes ); | 50 | int width, int height,int bytes ); |
51 | 51 | ||
52 | extern "C" { | 52 | extern "C" { |
53 | vo_driver_t* init_video_out_plugin( config_values_t* conf, void* video); | 53 | xine_vo_driver_t* init_video_out_plugin( xine_cfg_entry_t* conf, void* video); |
54 | int null_is_showing_video( vo_driver_t* self ); | 54 | int null_is_showing_video( const xine_vo_driver_t* self ); |
55 | void null_set_show_video( vo_driver_t* self, int show ); | 55 | void null_set_show_video( const xine_vo_driver_t* self, int show ); |
56 | int null_is_fullscreen( vo_driver_t* self ); | 56 | int null_is_fullscreen( const xine_vo_driver_t* self ); |
57 | void null_set_fullscreen( vo_driver_t* self, int screen ); | 57 | void null_set_fullscreen( const xine_vo_driver_t* self, int screen ); |
58 | int null_is_scaling( vo_driver_t* self ); | 58 | int null_is_scaling( const xine_vo_driver_t* self ); |
59 | void null_set_scaling( vo_driver_t* self, int scale ); | 59 | void null_set_scaling( const xine_vo_driver_t* self, int scale ); |
60 | void null_set_gui_width( vo_driver_t* self, int width ); | 60 | void null_set_gui_width( const xine_vo_driver_t* self, int width ); |
61 | void null_set_gui_height( vo_driver_t* self, int height ); | 61 | void null_set_gui_height( const xine_vo_driver_t* self, int height ); |
62 | void null_set_mode( vo_driver_t* self, int depth, int rgb ); | 62 | void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb ); |
63 | void null_set_videoGamma( vo_driver_t* self , int value ); | 63 | void null_set_videoGamma( const xine_vo_driver_t* self , int value ); |
64 | void null_display_handler(vo_driver_t* self, display_xine_frame_t t, void* user_data); | 64 | void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data ); |
65 | } | 65 | } |
66 | 66 | ||
67 | using namespace XINE; | 67 | using namespace XINE; |
68 | 68 | ||
69 | Lib::Lib(XineVideoWidget* widget) { | 69 | Lib::Lib( XineVideoWidget* widget ) { |
70 | m_video = false; | 70 | m_video = false; |
71 | m_wid = widget; | 71 | m_wid = widget; |
72 | printf("Lib"); | 72 | printf("Lib"); |
73 | QCString str( getenv("HOME") ); | 73 | QCString str( getenv("HOME") ); |
74 | str += "/Settings/opiexine.cf"; | 74 | str += "/Settings/opiexine.cf"; |
75 | // get the configuration | 75 | // get the configuration |
76 | 76 | ||
77 | // not really OO, should be an extra class, later | 77 | // not really OO, should be an extra class, later |
78 | if ( !QFile(str).exists() ) { | 78 | if ( !QFile(str).exists() ) { |
79 | QFile f(str); | 79 | QFile f(str); |
80 | f.open(IO_WriteOnly); | 80 | f.open(IO_WriteOnly); |
81 | QTextStream ts( &f ); | 81 | QTextStream ts( &f ); |
82 | ts << "misc.memcpy_method:glibc\n"; | 82 | ts << "misc.memcpy_method:glibc\n"; |
83 | f.close(); | 83 | f.close(); |
84 | } | 84 | } |
85 | 85 | ||
86 | m_config = xine_config_file_init( str.data() ); | 86 | m_xine = xine_new( ); |
87 | |||
88 | xine_config_load( m_xine, str.data() ); | ||
89 | |||
87 | 90 | ||
88 | // allocate oss for sound | 91 | // allocate oss for sound |
89 | // and fb for framebuffer | 92 | // and fb for framebuffer |
90 | m_audioOutput= xine_load_audio_output_plugin( m_config, "oss") ; | 93 | m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); |
91 | m_videoOutput = ::init_video_out_plugin( m_config, NULL ); | 94 | m_videoOutput = ::init_video_out_plugin( m_config, NULL ); |
95 | |||
96 | |||
97 | //xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL); | ||
98 | |||
99 | |||
100 | null_display_handler( m_videoOutput, xine_display_frame, this ); | ||
101 | xine_init( m_xine, m_audioOutput, m_videoOutput ); | ||
102 | |||
92 | if (m_wid != 0 ) { | 103 | if (m_wid != 0 ) { |
93 | printf("!0\n" ); | 104 | printf( "!0\n" ); |
94 | resize ( m_wid-> size ( )); | 105 | resize ( m_wid-> size ( ) ); |
95 | ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); | 106 | ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); |
96 | m_wid-> setLogo ( new QImage ( Resource::loadImage(""))); | 107 | |
97 | m_wid->repaint(); | 108 | m_wid->repaint(); |
98 | } | 109 | } |
99 | null_display_handler( m_videoOutput, | ||
100 | xine_display_frame, | ||
101 | this ); | ||
102 | 110 | ||
103 | m_xine = xine_init( m_videoOutput, | ||
104 | m_audioOutput, m_config ); | ||
105 | // install the event handler | ||
106 | xine_register_event_listener( m_xine, xine_event_handler, this ); | 111 | xine_register_event_listener( m_xine, xine_event_handler, this ); |
107 | } | 112 | } |
108 | 113 | ||
109 | Lib::~Lib() { | 114 | Lib::~Lib() { |
110 | free( m_config ); | 115 | // free( m_config ); |
111 | xine_remove_event_listener( m_xine, xine_event_handler ); | 116 | xine_remove_event_listener( m_xine, xine_event_handler ); |
112 | xine_exit( m_xine ); | 117 | xine_exit( m_xine ); |
113 | /* FIXME either free or delete but valgrind bitches against both */ | 118 | /* FIXME either free or delete but valgrind bitches against both */ |
114 | //free( m_videoOutput ); | 119 | //free( m_videoOutput ); |
115 | //delete m_audioOutput; | 120 | //delete m_audioOutput; |
116 | |||
117 | } | 121 | } |
118 | 122 | ||
119 | void Lib::resize ( const QSize &s ) | 123 | void Lib::resize ( const QSize &s ) { |
120 | { | 124 | if ( s. width ( ) && s. height ( ) ) { |
121 | if ( s. width ( ) && s. height ( )) { | 125 | ::null_set_gui_width( m_videoOutput, s. width() ); |
122 | ::null_set_gui_width( m_videoOutput, s. width() ); | 126 | ::null_set_gui_height( m_videoOutput, s. height() ); |
123 | ::null_set_gui_height(m_videoOutput, s. height() ); | 127 | } |
124 | } | ||
125 | } | 128 | } |
126 | 129 | ||
127 | QCString Lib::version() { | 130 | QCString Lib::version() { |
128 | QCString str( xine_get_str_version() ); | 131 | // QCString str( xine_get_str_version() ); |
129 | return str; | 132 | // return str; |
130 | }; | 133 | return "test"; |
134 | } | ||
131 | 135 | ||
132 | int Lib::majorVersion() { | 136 | int Lib::majorVersion() { |
133 | return xine_get_major_version(); | 137 | xine_get_version ( &m_major_version, &m_minor_version, &m_sub_version ); |
138 | return m_major_version; | ||
134 | } | 139 | } |
140 | |||
135 | int Lib::minorVersion() { | 141 | int Lib::minorVersion() { |
136 | return xine_get_minor_version(); | 142 | xine_get_version ( &m_major_version, &m_minor_version, &m_sub_version ); |
137 | }; | 143 | return m_minor_version; |
144 | } | ||
138 | 145 | ||
139 | int Lib::subVersion() { | 146 | int Lib::subVersion() { |
140 | return xine_get_sub_version(); | 147 | xine_get_version ( &m_major_version, &m_minor_version, &m_sub_version ); |
148 | return m_sub_version; | ||
141 | } | 149 | } |
142 | int Lib::play( const QString& fileName, | 150 | |
143 | int startPos, | 151 | int Lib::play( const QString& fileName, int startPos, int start_time ) { |
144 | int start_time ) { | ||
145 | QString str = fileName.stripWhiteSpace(); | 152 | QString str = fileName.stripWhiteSpace(); |
146 | //workaround OpiePlayer bug | 153 | xine_open( m_xine, QFile::encodeName(str.utf8() ).data() ); |
147 | //f (str.right(1) == QString::fromLatin1("/") ) | 154 | return xine_play( m_xine, startPos, start_time); |
148 | // str = str.mid( str.length() -1 ); | ||
149 | return xine_play( m_xine, QFile::encodeName(str.utf8() ).data(), | ||
150 | startPos, start_time); | ||
151 | } | 155 | } |
156 | |||
152 | void Lib::stop() { | 157 | void Lib::stop() { |
153 | qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); | 158 | qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); |
154 | xine_stop(m_xine ); | 159 | xine_stop( m_xine ); |
155 | } | 160 | } |
156 | void Lib::pause(){ | 161 | |
157 | xine_set_speed( m_xine, SPEED_PAUSE ); | 162 | void Lib::pause() { |
163 | xine_set_param( m_xine, XINE_PARAM_SPEED, XINE_SPEED_PAUSE ); | ||
158 | } | 164 | } |
165 | |||
159 | int Lib::speed() { | 166 | int Lib::speed() { |
160 | return xine_get_speed( m_xine ); | 167 | return xine_get_param ( m_xine, XINE_PARAM_SPEED ); |
161 | } | 168 | } |
169 | |||
162 | void Lib::setSpeed( int speed ) { | 170 | void Lib::setSpeed( int speed ) { |
163 | xine_set_speed( m_xine, speed ); | 171 | xine_set_param ( m_xine, XINE_PARAM_SPEED, speed ); |
164 | } | 172 | } |
165 | int Lib::status(){ | 173 | |
174 | int Lib::status() { | ||
166 | return xine_get_status( m_xine ); | 175 | return xine_get_status( m_xine ); |
167 | } | 176 | } |
168 | int Lib::currentPosition(){ | 177 | |
169 | return xine_get_current_position( m_xine ); | 178 | int Lib::currentPosition() { |
179 | xine_get_pos_length( m_xine, &m_pos, &m_time, &m_length ); | ||
180 | return m_pos; | ||
181 | } | ||
182 | |||
183 | int Lib::currentTime() { | ||
184 | xine_get_pos_length( m_xine, &m_pos, &m_time, &m_length ); | ||
185 | return m_time/1000; | ||
170 | } | 186 | } |
171 | int Lib::currentTime() { | 187 | |
172 | return xine_get_current_time( m_xine ); | ||
173 | }; | ||
174 | int Lib::length() { | 188 | int Lib::length() { |
175 | return xine_get_stream_length( m_xine ); | 189 | xine_get_pos_length( m_xine, &m_pos, &m_time, &m_length ); |
190 | return m_length/1000; | ||
176 | } | 191 | } |
192 | |||
177 | bool Lib::isSeekable() { | 193 | bool Lib::isSeekable() { |
178 | return xine_is_stream_seekable(m_xine); | 194 | return xine_get_stream_info ( m_xine, XINE_STREAM_INFO_SEEKABLE ); |
179 | } | 195 | } |
196 | |||
180 | Frame Lib::currentFrame() { | 197 | Frame Lib::currentFrame() { |
181 | Frame frame; | 198 | Frame frame; |
182 | return frame; | 199 | return frame; |
183 | }; | 200 | }; |
201 | |||
202 | QString Lib::metaInfo() { | ||
203 | xine_get_meta_info( m_xine, 0 ); | ||
204 | } | ||
205 | |||
184 | int Lib::error() { | 206 | int Lib::error() { |
185 | return xine_get_error( m_xine ); | 207 | return xine_get_error( m_xine ); |
186 | }; | 208 | }; |
209 | |||
187 | void Lib::handleXineEvent( xine_event_t* t ) { | 210 | void Lib::handleXineEvent( xine_event_t* t ) { |
188 | if ( t->type == XINE_EVENT_PLAYBACK_FINISHED ) | 211 | if ( t->type == XINE_EVENT_PLAYBACK_FINISHED ) { |
189 | emit stopped(); | 212 | emit stopped(); |
213 | } | ||
190 | } | 214 | } |
215 | |||
216 | |||
191 | void Lib::setShowVideo( bool video ) { | 217 | void Lib::setShowVideo( bool video ) { |
192 | m_video = video; | 218 | m_video = video; |
193 | ::null_set_show_video( m_videoOutput, video ); | 219 | ::null_set_show_video( m_videoOutput, video ); |
194 | } | 220 | } |
221 | |||
195 | bool Lib::isShowingVideo() { | 222 | bool Lib::isShowingVideo() { |
196 | return ::null_is_showing_video( m_videoOutput ); | 223 | return ::null_is_showing_video( m_videoOutput ); |
197 | } | 224 | } |
225 | |||
198 | void Lib::showVideoFullScreen( bool fullScreen ) { | 226 | void Lib::showVideoFullScreen( bool fullScreen ) { |
199 | ::null_set_fullscreen( m_videoOutput, fullScreen ); | 227 | ::null_set_fullscreen( m_videoOutput, fullScreen ); |
200 | } | 228 | } |
229 | |||
201 | bool Lib::isVideoFullScreen() { | 230 | bool Lib::isVideoFullScreen() { |
202 | return ::null_is_fullscreen( m_videoOutput ); | 231 | return ::null_is_fullscreen( m_videoOutput ); |
203 | } | 232 | } |
233 | |||
204 | void Lib::setScaling( bool scale ) { | 234 | void Lib::setScaling( bool scale ) { |
205 | ::null_set_scaling( m_videoOutput, scale ); | 235 | ::null_set_scaling( m_videoOutput, scale ); |
206 | } | 236 | } |
207 | 237 | ||
208 | void Lib::setGamma( int value ) { | 238 | void Lib::setGamma( int value ) { |
209 | //qDebug( QString( "%1").arg(value) ); | 239 | //qDebug( QString( "%1").arg(value) ); |
210 | ::null_set_videoGamma( m_videoOutput, value ); | 240 | ::null_set_videoGamma( m_videoOutput, value ); |
211 | } | 241 | } |
212 | 242 | ||
213 | bool Lib::isScaling() { | 243 | bool Lib::isScaling() { |
214 | return ::null_is_scaling( m_videoOutput ); | 244 | return ::null_is_scaling( m_videoOutput ); |
215 | } | 245 | } |
246 | |||
216 | void Lib::xine_event_handler( void* user_data, xine_event_t* t ) { | 247 | void Lib::xine_event_handler( void* user_data, xine_event_t* t ) { |
217 | ((Lib*)user_data)->handleXineEvent( t ); | 248 | ( (Lib*)user_data)->handleXineEvent( t ); |
218 | } | 249 | } |
250 | |||
219 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, | 251 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, |
220 | int width, int height, int bytes ) { | 252 | int width, int height, int bytes ) { |
221 | 253 | ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); | |
222 | ((Lib*)user_data)->drawFrame( frame, width, height, bytes ); | ||
223 | } | 254 | } |
255 | |||
224 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { | 256 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { |
225 | if (!m_video ) { | 257 | if ( !m_video ) { |
226 | qWarning("not showing video now"); | 258 | qWarning("not showing video now"); |
227 | return; | 259 | return; |
228 | } | 260 | } |
261 | |||
229 | // qWarning( "called draw frame %d %d", width, height ); | 262 | // qWarning( "called draw frame %d %d", width, height ); |
230 | 263 | ||
231 | m_wid-> setVideoFrame ( frame, width, height, bytes ); | 264 | m_wid-> setVideoFrame ( frame, width, height, bytes ); |
232 | } | 265 | } |
diff --git a/noncore/multimedia/opieplayer2/lib.h b/noncore/multimedia/opieplayer2/lib.h index b9d0a8a..29adc4d 100644 --- a/noncore/multimedia/opieplayer2/lib.h +++ b/noncore/multimedia/opieplayer2/lib.h | |||
@@ -1,153 +1,173 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 LJP <> | 5 | Copyright (c) 2002 LJP <> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifndef ZECKEXINELIB_H | 34 | #ifndef ZECKEXINELIB_H |
35 | #define ZECKEXINELIB_H | 35 | #define ZECKEXINELIB_H |
36 | 36 | ||
37 | #include <qcstring.h> | 37 | #include <qcstring.h> |
38 | #include <qstring.h> | 38 | #include <qstring.h> |
39 | #include <qobject.h> | 39 | #include <qobject.h> |
40 | 40 | ||
41 | #include <xine.h> | 41 | #include <xine.h> |
42 | //#include "xine.h" | ||
42 | 43 | ||
43 | class XineVideoWidget; | 44 | class XineVideoWidget; |
44 | 45 | ||
45 | namespace XINE { | 46 | namespace XINE { |
46 | 47 | ||
47 | /** | 48 | /** |
48 | * Lib wrapps the simple interface | 49 | * Lib wrapps the simple interface |
49 | * of libxine for easy every day use | 50 | * of libxine for easy every day use |
50 | * This will become a full C++ Wrapper | 51 | * This will become a full C++ Wrapper |
51 | * It supports playing, pausing, info, | 52 | * It supports playing, pausing, info, |
52 | * stooping, seeking. | 53 | * stooping, seeking. |
53 | */ | 54 | */ |
54 | class Frame; | 55 | class Frame; |
55 | class Lib : public QObject { | 56 | class Lib : public QObject { |
56 | Q_OBJECT | 57 | Q_OBJECT |
57 | public: | 58 | public: |
58 | Lib(XineVideoWidget* = 0); | 59 | Lib(XineVideoWidget* = 0); |
59 | ~Lib(); | 60 | ~Lib(); |
60 | QCString version(); | 61 | QCString version(); |
61 | int majorVersion()/*const*/; | 62 | int majorVersion()/*const*/; |
62 | int minorVersion()/*const*/; | 63 | int minorVersion()/*const*/; |
63 | int subVersion()/*const*/; | 64 | int subVersion()/*const*/; |
64 | 65 | ||
65 | 66 | ||
66 | void resize ( const QSize &s ); | 67 | void resize ( const QSize &s ); |
67 | 68 | ||
68 | int play( const QString& fileName, | 69 | int play( const QString& fileName, |
69 | int startPos = 0, | 70 | int startPos = 0, |
70 | int start_time = 0 ); | 71 | int start_time = 0 ); |
71 | void stop() /*const*/; | 72 | void stop() /*const*/; |
72 | void pause()/*const*/; | 73 | void pause()/*const*/; |
73 | 74 | ||
74 | int speed() /*const*/; | 75 | int speed() /*const*/; |
75 | void setSpeed( int speed = SPEED_PAUSE ); | 76 | |
77 | /** | ||
78 | * Set the speed of the stream, if codec supports it | ||
79 | * XINE_SPEED_PAUSE 0 | ||
80 | * XINE_SPEED_SLOW_4 1 | ||
81 | * XINE_SPEED_SLOW_2 2 | ||
82 | * XINE_SPEED_NORMAL 4 | ||
83 | * XINE_SPEED_FAST_2 8 | ||
84 | *XINE_SPEED_FAST_4 16 | ||
85 | */ | ||
86 | void setSpeed( int speed = XINE_SPEED_PAUSE ); | ||
76 | 87 | ||
77 | int status() /*const*/; | 88 | int status() /*const*/; |
78 | 89 | ||
79 | int currentPosition()/*const*/; | 90 | int currentPosition()/*const*/; |
80 | //in seconds | 91 | //in seconds |
81 | int currentTime()/*const*/; | 92 | int currentTime()/*const*/; |
82 | int length() /*const*/; | 93 | int length() /*const*/; |
83 | 94 | ||
84 | bool isSeekable()/*const*/; | 95 | bool isSeekable()/*const*/; |
85 | 96 | ||
86 | /** | 97 | /** |
87 | * Whether or not to show video output | 98 | * Whether or not to show video output |
88 | */ | 99 | */ |
89 | void setShowVideo(bool video); | 100 | void setShowVideo(bool video); |
90 | 101 | ||
91 | /** | 102 | /** |
92 | * is we show video | 103 | * is we show video |
93 | */ | 104 | */ |
94 | bool isShowingVideo() /*const*/; | 105 | bool isShowingVideo() /*const*/; |
95 | 106 | ||
96 | /** | 107 | /** |
97 | * | 108 | * |
98 | */ | 109 | */ |
99 | void showVideoFullScreen( bool fullScreen ); | 110 | void showVideoFullScreen( bool fullScreen ); |
100 | 111 | ||
101 | /** | 112 | /** |
102 | * | 113 | * |
103 | */ | 114 | */ |
104 | bool isVideoFullScreen()/*const*/ ; | 115 | bool isVideoFullScreen()/*const*/ ; |
105 | 116 | ||
117 | |||
118 | /** | ||
119 | * Get the meta info (like author etc) from the stream | ||
120 | * | ||
121 | */ | ||
122 | QString metaInfo() ; | ||
123 | |||
106 | /** | 124 | /** |
107 | * | 125 | * |
108 | */ | 126 | */ |
109 | bool isScaling(); | 127 | bool isScaling(); |
110 | 128 | ||
111 | /** | 129 | /** |
112 | * | 130 | * |
113 | */ | 131 | */ |
114 | void setScaling( bool ); | 132 | void setScaling( bool ); |
115 | 133 | ||
116 | /** | 134 | /** |
117 | * Set the Gamma value for video output | 135 | * Set the Gamma value for video output |
118 | * @param int the value between -100 and 100, 0 is original | 136 | * @param int the value between -100 and 100, 0 is original |
119 | */ | 137 | */ |
120 | void setGamma( int ); | 138 | void setGamma( int ); |
121 | 139 | ||
122 | /** | 140 | /** |
123 | * test | 141 | * test |
124 | */ | 142 | */ |
125 | Frame currentFrame()/*const*/; | 143 | Frame currentFrame()/*const*/; |
126 | 144 | ||
127 | /** | 145 | /** |
128 | * Returns the error code | 146 | * Returns the error code |
129 | */ | 147 | */ |
130 | int error() /*const*/; | 148 | int error() /*const*/; |
131 | 149 | ||
132 | signals: | 150 | signals: |
133 | void stopped(); | 151 | void stopped(); |
134 | private: | 152 | private: |
135 | int m_bytes_per_pixel; | 153 | int m_bytes_per_pixel; |
154 | int m_length, m_pos, m_time; | ||
155 | int m_major_version, m_minor_version, m_sub_version; | ||
136 | bool m_video:1; | 156 | bool m_video:1; |
137 | XineVideoWidget *m_wid; | 157 | XineVideoWidget *m_wid; |
138 | xine_t *m_xine; | 158 | xine_t *m_xine; |
139 | config_values_t *m_config; | 159 | xine_cfg_entry_t *m_config; |
140 | vo_driver_t *m_videoOutput; | 160 | xine_vo_driver_t *m_videoOutput; |
141 | ao_driver_t* m_audioOutput; | 161 | xine_ao_driver_t* m_audioOutput; |
142 | 162 | ||
143 | void handleXineEvent( xine_event_t* t ); | 163 | void handleXineEvent( xine_event_t* t ); |
144 | void drawFrame( uint8_t* frame, int width, int height, int bytes ); | 164 | void drawFrame( uint8_t* frame, int width, int height, int bytes ); |
145 | // C -> C++ bridge for the event system | 165 | // C -> C++ bridge for the event system |
146 | static void xine_event_handler( void* user_data, xine_event_t* t); | 166 | static void xine_event_handler( void* user_data, xine_event_t* t); |
147 | static void xine_display_frame( void* user_data, uint8_t* frame , | 167 | static void xine_display_frame( void* user_data, uint8_t* frame , |
148 | int width, int height, int bytes ); | 168 | int width, int height, int bytes ); |
149 | }; | 169 | }; |
150 | }; | 170 | }; |
151 | 171 | ||
152 | 172 | ||
153 | #endif | 173 | #endif |
diff --git a/noncore/multimedia/opieplayer2/nullvideo.c b/noncore/multimedia/opieplayer2/nullvideo.c index ceda333..dcdfae6 100644 --- a/noncore/multimedia/opieplayer2/nullvideo.c +++ b/noncore/multimedia/opieplayer2/nullvideo.c | |||
@@ -1,713 +1,608 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 LJP <> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | /*#include <xine.h>*/ | ||
35 | #include <stdlib.h> | 34 | #include <stdlib.h> |
36 | #include <stdio.h> | 35 | #include <stdio.h> |
37 | 36 | ||
38 | #include <math.h> | 37 | #include <math.h> |
39 | 38 | ||
39 | #include <xine.h> | ||
40 | #include <xine/video_out.h> | 40 | #include <xine/video_out.h> |
41 | #include <xine/xine_internal.h> | 41 | #include <xine/xine_internal.h> |
42 | #include <xine/xineutils.h> | 42 | #include <xine/xineutils.h> |
43 | #include <xine/configfile.h> | 43 | #include <xine/vo_scale.h> |
44 | 44 | ||
45 | #include <pthread.h> | 45 | #include <pthread.h> |
46 | #include "alphablend.h" | 46 | #include "alphablend.h" |
47 | #include "yuv2rgb.h" | 47 | #include "yuv2rgb.h" |
48 | 48 | ||
49 | #define printf(x,...) | 49 | #define printf(x,...) |
50 | 50 | ||
51 | /* | ||
52 | #define LOG | ||
53 | */ | ||
54 | |||
51 | /* the caller for our event draw handler */ | 55 | /* the caller for our event draw handler */ |
52 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, | 56 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, |
53 | int width, int height,int bytes ); | 57 | int width, int height,int bytes ); |
54 | 58 | ||
55 | typedef struct null_driver_s null_driver_t; | 59 | typedef struct null_driver_s null_driver_t; |
56 | 60 | ||
57 | struct null_driver_s { | 61 | struct null_driver_s { |
58 | vo_driver_t vo_driver; | 62 | xine_vo_driver_t vo_driver; |
59 | uint32_t m_capabilities; | 63 | |
60 | int m_show_video; | 64 | uint32_t m_capabilities; |
61 | int m_video_fullscreen; | 65 | int m_show_video; |
62 | int m_is_scaling; | 66 | int m_video_fullscreen; |
63 | int depth, bpp, bytes_per_pixel; | 67 | int m_is_scaling; |
64 | int yuv2rgb_mode; | 68 | |
65 | int yuv2rgb_swap; | 69 | int depth, bpp, bytes_per_pixel; |
66 | int yuv2rgb_gamma; | 70 | int yuv2rgb_mode; |
67 | uint8_t *yuv2rgb_cmap; | 71 | int yuv2rgb_swap; |
68 | yuv2rgb_factory_t *yuv2rgb_factory; | 72 | int yuv2rgb_gamma; |
69 | vo_overlay_t *overlay; | 73 | uint8_t *yuv2rgb_cmap; |
70 | int user_ratio; | 74 | yuv2rgb_factory_t *yuv2rgb_factory; |
71 | double output_scale_factor; | 75 | |
72 | int last_frame_output_width; | 76 | vo_overlay_t *overlay; |
73 | int last_frame_output_height; | 77 | vo_scale_t sc; |
74 | int gui_width; | 78 | |
75 | int gui_height; | 79 | int gui_width; |
76 | int gui_changed; | 80 | int gui_height; |
77 | double display_ratio; | 81 | int gui_changed; |
78 | void* caller; | 82 | |
79 | display_xine_frame_t frameDis; | 83 | double display_ratio; |
80 | 84 | void* caller; | |
81 | 85 | display_xine_frame_t frameDis; | |
82 | }; | 86 | }; |
87 | |||
83 | typedef struct opie_frame_s opie_frame_t; | 88 | typedef struct opie_frame_s opie_frame_t; |
84 | struct opie_frame_s { | 89 | struct opie_frame_s { |
85 | vo_frame_t frame; | 90 | vo_frame_t frame; |
86 | char* name; | 91 | |
87 | int version; | 92 | int format; |
88 | int width; | 93 | int flags; |
89 | int height; | 94 | |
90 | int ratio_code; | 95 | vo_scale_t sc; |
91 | int format; | 96 | |
92 | int flags; | 97 | uint8_t *chunk[3]; |
93 | int user_ratio; | ||
94 | |||
95 | double ratio_factor; | ||
96 | int ideal_width; | ||
97 | int ideal_height; | ||
98 | int output_width, output_height; | ||
99 | int gui_width, gui_height; | ||
100 | uint8_t *chunk[3]; | ||
101 | |||
102 | yuv2rgb_t *yuv2rgb; | ||
103 | uint8_t *rgb_dst; | ||
104 | int yuv_stride; | ||
105 | int stripe_height, stripe_inc; | ||
106 | |||
107 | int bytes_per_line; | ||
108 | uint8_t *data; | ||
109 | 98 | ||
110 | // int show_video; | 99 | uint8_t *data; /* rgb */ |
111 | null_driver_t *output; | 100 | int bytes_per_line; |
101 | |||
102 | yuv2rgb_t *yuv2rgb; | ||
103 | uint8_t *rgb_dst; | ||
104 | int yuv_stride; | ||
105 | int stripe_height, stripe_inc; | ||
106 | |||
107 | null_driver_t *output; | ||
112 | }; | 108 | }; |
113 | 109 | ||
114 | static uint32_t null_get_capabilities(vo_driver_t *self ){ | 110 | static uint32_t null_get_capabilities( xine_vo_driver_t *self ){ |
115 | null_driver_t* this = (null_driver_t*)self; | 111 | null_driver_t* this = (null_driver_t*)self; |
116 | printf("capabilities\n"); | 112 | return this->m_capabilities; |
117 | return this->m_capabilities; | ||
118 | } | 113 | } |
119 | 114 | ||
120 | static void null_frame_copy (vo_frame_t *vo_img, uint8_t **src) { | 115 | static void null_frame_copy (vo_frame_t *vo_img, uint8_t **src) { |
121 | opie_frame_t *frame = (opie_frame_t *) vo_img ; | 116 | opie_frame_t *frame = (opie_frame_t *) vo_img ; |
122 | printf("frame copy\n"); | ||
123 | if(!frame->output->m_show_video ){ printf("no video\n"); return; } // no video | ||
124 | 117 | ||
125 | if (frame->format == IMGFMT_YV12) { | 118 | if (!frame->output->m_show_video) { |
126 | frame->yuv2rgb->yuv2rgb_fun (frame->yuv2rgb, frame->rgb_dst, | 119 | /* printf("nullvideo: no video\n"); */ |
127 | src[0], src[1], src[2]); | 120 | return; |
121 | } | ||
122 | |||
123 | if (frame->format == XINE_IMGFMT_YV12) { | ||
124 | frame->yuv2rgb->yuv2rgb_fun (frame->yuv2rgb, frame->rgb_dst, | ||
125 | src[0], src[1], src[2]); | ||
128 | } else { | 126 | } else { |
129 | 127 | ||
130 | frame->yuv2rgb->yuy22rgb_fun (frame->yuv2rgb, frame->rgb_dst, | 128 | frame->yuv2rgb->yuy22rgb_fun (frame->yuv2rgb, frame->rgb_dst, |
131 | src[0]); | 129 | src[0]); |
132 | } | 130 | } |
133 | 131 | ||
134 | frame->rgb_dst += frame->stripe_inc; | 132 | frame->rgb_dst += frame->stripe_inc; |
135 | printf("returning\n"); | ||
136 | } | 133 | } |
137 | 134 | ||
138 | static void null_frame_field (vo_frame_t *vo_img, int which_field) { | 135 | static void null_frame_field (vo_frame_t *vo_img, int which_field) { |
139 | 136 | ||
140 | opie_frame_t *frame = (opie_frame_t *) vo_img ; | 137 | opie_frame_t *frame = (opie_frame_t *) vo_img ; |
141 | printf("field\n\n"); | ||
142 | 138 | ||
143 | switch (which_field) { | 139 | switch (which_field) { |
144 | case VO_TOP_FIELD: | 140 | case VO_TOP_FIELD: |
145 | frame->rgb_dst = (uint8_t *)frame->data; | 141 | frame->rgb_dst = (uint8_t *)frame->data; |
146 | frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line; | 142 | frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line; |
147 | break; | 143 | break; |
148 | case VO_BOTTOM_FIELD: | 144 | case VO_BOTTOM_FIELD: |
149 | frame->rgb_dst = (uint8_t *)frame->data + frame->bytes_per_line ; | 145 | frame->rgb_dst = (uint8_t *)frame->data + frame->bytes_per_line ; |
150 | frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line; | 146 | frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line; |
151 | break; | 147 | break; |
152 | case VO_BOTH_FIELDS: | 148 | case VO_BOTH_FIELDS: |
153 | frame->rgb_dst = (uint8_t *)frame->data; | 149 | frame->rgb_dst = (uint8_t *)frame->data; |
154 | break; | 150 | break; |
155 | } | 151 | } |
156 | } | 152 | } |
157 | 153 | ||
158 | 154 | ||
159 | /* take care of the frame*/ | 155 | /* take care of the frame*/ |
160 | static void null_frame_dispose( vo_frame_t* vo_img){ | 156 | static void null_frame_dispose( vo_frame_t* vo_img){ |
161 | opie_frame_t* frame = (opie_frame_t*)vo_img; | 157 | opie_frame_t* frame = (opie_frame_t*)vo_img; |
162 | printf("frame_dispose\n"); | ||
163 | if( frame->data ) | ||
164 | free( frame->data ); | ||
165 | free (frame); | ||
166 | } | ||
167 | |||
168 | /* end take care of frames*/ | ||
169 | |||
170 | static vo_frame_t* null_alloc_frame( vo_driver_t* self ){ | ||
171 | null_driver_t* this = (null_driver_t*)self; | ||
172 | opie_frame_t* frame; | ||
173 | frame = (opie_frame_t*)malloc ( sizeof(opie_frame_t) ); | ||
174 | |||
175 | memset( frame, 0, sizeof( opie_frame_t) ); | ||
176 | pthread_mutex_init (&frame->frame.mutex, NULL); | ||
177 | |||
178 | printf("alloc_frame\n"); | ||
179 | frame->name = "opie\0"; | ||
180 | frame->version = 1; | ||
181 | frame->output = this; | ||
182 | // frame->show_video = this->m_show_video; | ||
183 | /* initialize the frame*/ | ||
184 | frame->frame.driver = self; | ||
185 | /*frame.frame.free = null_frame_free;*/ | ||
186 | frame->frame.copy = null_frame_copy; | ||
187 | frame->frame.field = null_frame_field; | ||
188 | frame->frame.dispose = null_frame_dispose; | ||
189 | frame->yuv2rgb = 0; | ||
190 | /* | ||
191 | * colorspace converter for this frame | ||
192 | */ | ||
193 | frame->yuv2rgb = this->yuv2rgb_factory->create_converter (this->yuv2rgb_factory); | ||
194 | |||
195 | 158 | ||
196 | return (vo_frame_t*) frame; | 159 | if (frame->data) |
160 | free( frame->data ); | ||
161 | free (frame); | ||
197 | } | 162 | } |
198 | 163 | ||
199 | // size specific | 164 | /* end take care of frames*/ |
200 | static void null_compute_ideal_size (null_driver_t *this, opie_frame_t *frame) { | ||
201 | 165 | ||
202 | if (!this->m_is_scaling /*|| !this->m_show_video*/) { | 166 | static vo_frame_t* null_alloc_frame( xine_vo_driver_t* self ){ |
203 | printf("Not scaling\n"); | ||
204 | frame->ideal_width = frame->width; | ||
205 | frame->ideal_height = frame->height; | ||
206 | frame->ratio_factor = 1.0; | ||
207 | 167 | ||
208 | } else { | 168 | null_driver_t* this = (null_driver_t*)self; |
209 | 169 | opie_frame_t* frame; | |
210 | double image_ratio, desired_ratio, corr_factor; | ||
211 | |||
212 | image_ratio = (double) frame->width / (double) frame->height; | ||
213 | |||
214 | switch (frame->user_ratio) { | ||
215 | case ASPECT_AUTO: | ||
216 | switch (frame->ratio_code) { | ||
217 | case XINE_ASPECT_RATIO_ANAMORPHIC: /* anamorphic */ | ||
218 | case XINE_ASPECT_RATIO_PAN_SCAN: | ||
219 | desired_ratio = 16.0 /9.0; | ||
220 | break; | ||
221 | case XINE_ASPECT_RATIO_211_1: /* 2.11:1 */ | ||
222 | desired_ratio = 2.11/1.0; | ||
223 | break; | ||
224 | case XINE_ASPECT_RATIO_SQUARE: /* square pels */ | ||
225 | case XINE_ASPECT_RATIO_DONT_TOUCH: /* probably non-mpeg stream => don't touch aspect ratio */ | ||
226 | desired_ratio = image_ratio; | ||
227 | break; | ||
228 | case 0: /* forbidden -> 4:3 */ | ||
229 | printf ("video_out_fb: invalid ratio, using 4:3\n"); | ||
230 | default: | ||
231 | printf ("video_out_fb: unknown aspect ratio (%d) in stream => using 4:3\n", | ||
232 | frame->ratio_code); | ||
233 | case XINE_ASPECT_RATIO_4_3: /* 4:3 */ | ||
234 | desired_ratio = 4.0 / 3.0; | ||
235 | break; | ||
236 | } | ||
237 | break; | ||
238 | case ASPECT_ANAMORPHIC: | ||
239 | desired_ratio = 16.0 / 9.0; | ||
240 | break; | ||
241 | case ASPECT_DVB: | ||
242 | desired_ratio = 2.0 / 1.0; | ||
243 | break; | ||
244 | case ASPECT_SQUARE: | ||
245 | desired_ratio = image_ratio; | ||
246 | break; | ||
247 | case ASPECT_FULL: | ||
248 | default: | ||
249 | desired_ratio = 4.0 / 3.0; | ||
250 | } | ||
251 | |||
252 | frame->ratio_factor = this->display_ratio * desired_ratio; | ||
253 | |||
254 | corr_factor = frame->ratio_factor / image_ratio ; | ||
255 | |||
256 | if (fabs(corr_factor - 1.0) < 0.005) { | ||
257 | frame->ideal_width = frame->width; | ||
258 | frame->ideal_height = frame->height; | ||
259 | |||
260 | } else { | ||
261 | |||
262 | if (corr_factor >= 1.0) { | ||
263 | frame->ideal_width = frame->width * corr_factor + 0.5; | ||
264 | frame->ideal_height = frame->height; | ||
265 | } else { | ||
266 | frame->ideal_width = frame->width; | ||
267 | frame->ideal_height = frame->height / corr_factor + 0.5; | ||
268 | } | ||
269 | |||
270 | } | ||
271 | } | ||
272 | printf("return from helper\n"); | ||
273 | } | ||
274 | 170 | ||
275 | static void null_compute_rgb_size (null_driver_t *this, opie_frame_t *frame) { | 171 | #ifdef LOG |
172 | fprintf (stderr, "nullvideo: alloc_frame\n"); | ||
173 | #endif | ||
276 | 174 | ||
277 | double x_factor, y_factor; | 175 | frame = (opie_frame_t*)malloc ( sizeof(opie_frame_t) ); |
278 | |||
279 | /* | ||
280 | * make the frame fit into the given destination area | ||
281 | */ | ||
282 | 176 | ||
283 | x_factor = (double) this->gui_width / (double) frame->ideal_width; | 177 | memset( frame, 0, sizeof( opie_frame_t) ); |
284 | y_factor = (double) this->gui_height / (double) frame->ideal_height; | 178 | memcpy (&frame->sc, &this->sc, sizeof(vo_scale_t)); |
285 | 179 | ||
286 | if ( x_factor < y_factor ) { | 180 | pthread_mutex_init (&frame->frame.mutex, NULL); |
287 | frame->output_width = (double) frame->ideal_width * x_factor ; | 181 | |
288 | frame->output_height = (double) frame->ideal_height * x_factor ; | 182 | frame->output = this; |
289 | } else { | 183 | |
290 | frame->output_width = (double) frame->ideal_width * y_factor ; | 184 | /* initialize the frame*/ |
291 | frame->output_height = (double) frame->ideal_height * y_factor ; | 185 | frame->frame.driver = self; |
292 | } | 186 | frame->frame.copy = null_frame_copy; |
187 | frame->frame.field = null_frame_field; | ||
188 | frame->frame.dispose = null_frame_dispose; | ||
189 | |||
190 | /* | ||
191 | * colorspace converter for this frame | ||
192 | */ | ||
193 | frame->yuv2rgb = this->yuv2rgb_factory->create_converter (this->yuv2rgb_factory); | ||
194 | |||
195 | return (vo_frame_t*) frame; | ||
196 | } | ||
197 | |||
198 | static void null_update_frame_format( xine_vo_driver_t* self, vo_frame_t* img, | ||
199 | uint32_t width, uint32_t height, | ||
200 | int ratio_code, int format, int flags ){ | ||
201 | null_driver_t* this = (null_driver_t*) self; | ||
202 | opie_frame_t* frame = (opie_frame_t*)img; | ||
203 | /* not needed now */ | ||
293 | 204 | ||
294 | #define LOG 1 | ||
295 | #ifdef LOG | 205 | #ifdef LOG |
296 | printf("video_out_fb: frame source %d x %d => screen output %d x %d%s\n", | 206 | fprintf (stderr, "nullvideo: update_frame_format\n"); |
297 | frame->width, frame->height, | ||
298 | frame->output_width, frame->output_height, | ||
299 | ( frame->width != frame->output_width | ||
300 | || frame->height != frame->output_height | ||
301 | ? ", software scaling" | ||
302 | : "" ) | ||
303 | ); | ||
304 | #endif | 207 | #endif |
305 | } | ||
306 | 208 | ||
209 | flags &= VO_BOTH_FIELDS; | ||
210 | |||
211 | /* find out if we need to adapt this frame */ | ||
212 | |||
213 | if ((width != frame->sc.delivered_width) | ||
214 | || (height != frame->sc.delivered_height) | ||
215 | || (ratio_code != frame->sc.delivered_ratio_code) | ||
216 | || (flags != frame->flags) | ||
217 | || (format != frame->format) | ||
218 | || (this->sc.user_ratio != frame->sc.user_ratio) | ||
219 | || (this->gui_width != frame->sc.gui_width) | ||
220 | || (this->gui_height != frame->sc.gui_height)) { | ||
221 | |||
222 | frame->sc.delivered_width = width; | ||
223 | frame->sc.delivered_height = height; | ||
224 | frame->sc.delivered_ratio_code = ratio_code; | ||
225 | frame->flags = flags; | ||
226 | frame->format = format; | ||
227 | frame->sc.user_ratio = this->sc.user_ratio; | ||
228 | frame->sc.gui_width = this->gui_width; | ||
229 | frame->sc.gui_height = this->gui_height; | ||
230 | frame->sc.gui_pixel_aspect = 1.0; | ||
231 | |||
232 | vo_scale_compute_ideal_size ( &frame->sc ); | ||
233 | vo_scale_compute_output_size( &frame->sc ); | ||
234 | |||
235 | #ifdef LOG | ||
236 | fprintf (stderr, "nullvideo: gui %dx%d delivered %dx%d output %dx%d\n", | ||
237 | frame->sc.gui_width, frame->sc.gui_height, | ||
238 | frame->sc.delivered_width, frame->sc.delivered_height, | ||
239 | frame->sc.output_width, frame->sc.output_height); | ||
240 | #endif | ||
241 | |||
242 | /* | ||
243 | * (re-) allocate | ||
244 | */ | ||
245 | if( frame->data ) { | ||
246 | if( frame->chunk[0] ){ | ||
247 | free( frame->chunk[0] ); | ||
248 | frame->chunk[0] = NULL; | ||
249 | } | ||
250 | if( frame->chunk[1] ){ | ||
251 | free ( frame->chunk[1] ); | ||
252 | frame->chunk[1] = NULL; | ||
253 | } | ||
254 | if( frame->chunk[2] ){ | ||
255 | free ( frame->chunk[2] ); | ||
256 | frame->chunk[2] = NULL; | ||
257 | } | ||
258 | free ( frame->data ); | ||
259 | } | ||
307 | 260 | ||
308 | // size specific | 261 | frame->data = xine_xmalloc (frame->sc.output_width |
262 | * frame->sc.output_height | ||
263 | * this->bytes_per_pixel ); | ||
309 | 264 | ||
265 | if( format == XINE_IMGFMT_YV12 ) { | ||
266 | frame->frame.pitches[0] = 8*((width + 7) / 8); | ||
267 | frame->frame.pitches[1] = 8*((width + 15) / 16); | ||
268 | frame->frame.pitches[2] = 8*((width + 15) / 16); | ||
269 | frame->frame.base[0] = xine_xmalloc_aligned (16, frame->frame.pitches[0] * height,(void **)&frame->chunk[0]); | ||
270 | frame->frame.base[1] = xine_xmalloc_aligned (16, frame->frame.pitches[1] * ((height+ 1)/2), (void **)&frame->chunk[1]); | ||
271 | frame->frame.base[2] = xine_xmalloc_aligned (16, frame->frame.pitches[2] * ((height+ 1)/2), (void **)&frame->chunk[2]); | ||
310 | 272 | ||
311 | static void null_update_frame_format( vo_driver_t* self, vo_frame_t* img, | 273 | }else{ |
312 | uint32_t width, uint32_t height, | 274 | frame->frame.pitches[0] = 8*((width + 3) / 4); |
313 | int ratio_code, int format, int flags ){ | ||
314 | null_driver_t* this = (null_driver_t*) self; | ||
315 | opie_frame_t* frame = (opie_frame_t*)img; | ||
316 | /* not needed now */ | ||
317 | printf("update_frame_format\n"); | ||
318 | printf("al crash aye?\n"); | ||
319 | |||
320 | flags &= VO_BOTH_FIELDS; | ||
321 | |||
322 | /* find out if we need to adapt this frame */ | ||
323 | |||
324 | if ((width != frame->width) | ||
325 | || (height != frame->height) | ||
326 | || (ratio_code != frame->ratio_code) | ||
327 | || (flags != frame->flags) | ||
328 | || (format != frame->format) | ||
329 | || (this->user_ratio != frame->user_ratio) | ||
330 | || (this->gui_width != frame-> gui_width ) | ||
331 | || (this-> gui_height != frame-> gui_height)) { | ||
332 | |||
333 | frame->width = width; | ||
334 | frame->height = height; | ||
335 | frame->ratio_code = ratio_code; | ||
336 | frame->flags = flags; | ||
337 | frame->format = format; | ||
338 | frame->user_ratio = this->user_ratio; | ||
339 | this->gui_changed = 0; | ||
340 | //frame->show_video = this->m_show_video; | ||
341 | frame->gui_width = this->gui_width; | ||
342 | frame->gui_height = this->gui_height; | ||
343 | |||
344 | null_compute_ideal_size (this, frame); | ||
345 | null_compute_rgb_size (this, frame); | ||
346 | |||
347 | /* | ||
348 | * (re-) allocate | ||
349 | */ | ||
350 | if( frame->data ) { | ||
351 | if(frame->chunk[0] ){ | ||
352 | free( frame->chunk[0] ); | ||
353 | frame->chunk[0] = NULL; | ||
354 | } | ||
355 | if(frame->chunk[1] ){ | ||
356 | free ( frame->chunk[1] ); | ||
357 | frame->chunk[1] = NULL; | ||
358 | } | ||
359 | if(frame->chunk[2] ){ | ||
360 | free ( frame->chunk[2] ); | ||
361 | frame->chunk[2] = NULL; | ||
362 | } | ||
363 | free ( frame->data ); | ||
364 | } | ||
365 | printf("after freeing\n"); | ||
366 | frame->data = xine_xmalloc (frame->output_width * frame->output_height * | ||
367 | this->bytes_per_pixel ); | ||
368 | |||
369 | if( format == IMGFMT_YV12 ) { | ||
370 | frame->frame.pitches[0] = 8*((width + 7) / 8); | ||
371 | frame->frame.pitches[1] = 8*((width + 15) / 16); | ||
372 | frame->frame.pitches[2] = 8*((width + 15) / 16); | ||
373 | frame->frame.base[0] = xine_xmalloc_aligned (16, frame->frame.pitches[0] * height,(void **)&frame->chunk[0]); | ||
374 | frame->frame.base[1] = xine_xmalloc_aligned (16, frame->frame.pitches[1] * ((height+ 1)/2), (void **)&frame->chunk[1]); | ||
375 | frame->frame.base[2] = xine_xmalloc_aligned (16, frame->frame.pitches[2] * ((height+ 1)/2), (void **)&frame->chunk[2]); | ||
376 | |||
377 | }else{ | ||
378 | frame->frame.pitches[0] = 8*((width + 3) / 4); | ||
379 | 275 | ||
380 | frame->frame.base[0] = xine_xmalloc_aligned (16, frame->frame.pitches[0] * height, | 276 | frame->frame.base[0] = xine_xmalloc_aligned (16, frame->frame.pitches[0] * height, |
381 | (void **)&frame->chunk[0]); | 277 | (void **)&frame->chunk[0]); |
382 | frame->chunk[1] = NULL; | 278 | frame->chunk[1] = NULL; |
383 | frame->chunk[2] = NULL; | 279 | frame->chunk[2] = NULL; |
384 | } | ||
385 | |||
386 | frame->format = format; | ||
387 | frame->width = width; | ||
388 | frame->height = height; | ||
389 | |||
390 | frame->stripe_height = 16 * frame->output_height / frame->height; | ||
391 | frame->bytes_per_line = frame->output_width * this->bytes_per_pixel; | ||
392 | |||
393 | /* | ||
394 | * set up colorspace converter | ||
395 | */ | ||
396 | if(1 /*this->m_show_video*/ ){ | ||
397 | printf("showing video\n"); | ||
398 | |||
399 | switch (flags) { | ||
400 | case VO_TOP_FIELD: | ||
401 | case VO_BOTTOM_FIELD: | ||
402 | frame->yuv2rgb->configure (frame->yuv2rgb, | ||
403 | frame->width, | ||
404 | 16, | ||
405 | 2*frame->frame.pitches[0], | ||
406 | 2*frame->frame.pitches[1], | ||
407 | frame->output_width, | ||
408 | frame->stripe_height, | ||
409 | frame->bytes_per_line*2); | ||
410 | frame->yuv_stride = frame->bytes_per_line*2; | ||
411 | break; | ||
412 | case VO_BOTH_FIELDS: | ||
413 | frame->yuv2rgb->configure (frame->yuv2rgb, | ||
414 | frame->width, | ||
415 | 16, | ||
416 | frame->frame.pitches[0], | ||
417 | frame->frame.pitches[1], | ||
418 | frame->output_width, | ||
419 | frame->stripe_height, | ||
420 | frame->bytes_per_line); | ||
421 | frame->yuv_stride = frame->bytes_per_line; | ||
422 | break; | ||
423 | } | ||
424 | } | ||
425 | } | 280 | } |
426 | printf("after gui changed\n"); | 281 | |
427 | /* | 282 | frame->stripe_height = 16 * frame->sc.output_height / frame->sc.delivered_height; |
428 | * reset dest pointers | 283 | frame->bytes_per_line = frame->sc.output_width * this->bytes_per_pixel; |
284 | |||
285 | /* | ||
286 | * set up colorspace converter | ||
429 | */ | 287 | */ |
430 | 288 | ||
431 | if (frame->data) { | 289 | switch (flags) { |
432 | switch (flags) { | 290 | case VO_TOP_FIELD: |
433 | case VO_TOP_FIELD: | 291 | case VO_BOTTOM_FIELD: |
434 | frame->rgb_dst = (uint8_t *)frame->data; | 292 | frame->yuv2rgb->configure (frame->yuv2rgb, |
435 | frame->stripe_inc = 2 * frame->stripe_height * frame->bytes_per_line; | 293 | frame->sc.delivered_width, |
436 | break; | 294 | 16, |
437 | case VO_BOTTOM_FIELD: | 295 | 2*frame->frame.pitches[0], |
438 | frame->rgb_dst = (uint8_t *)frame->data + frame->bytes_per_line ; | 296 | 2*frame->frame.pitches[1], |
439 | frame->stripe_inc = 2 * frame->stripe_height * frame->bytes_per_line; | 297 | frame->sc.output_width, |
440 | break; | 298 | frame->stripe_height, |
441 | case VO_BOTH_FIELDS: | 299 | frame->bytes_per_line*2); |
442 | frame->rgb_dst = (uint8_t *)frame->data; | 300 | frame->yuv_stride = frame->bytes_per_line*2; |
443 | frame->stripe_inc = frame->stripe_height * frame->bytes_per_line; | 301 | break; |
444 | break; | 302 | case VO_BOTH_FIELDS: |
445 | } | 303 | frame->yuv2rgb->configure (frame->yuv2rgb, |
446 | } | 304 | frame->sc.delivered_width, |
447 | printf("done\n"); | 305 | 16, |
448 | } | 306 | frame->frame.pitches[0], |
449 | static void null_display_frame( vo_driver_t* self, vo_frame_t *frame_gen ){ | 307 | frame->frame.pitches[1], |
450 | null_driver_t* this = (null_driver_t*) self; | 308 | frame->sc.output_width, |
451 | opie_frame_t* frame = (opie_frame_t*)frame_gen; | 309 | frame->stripe_height, |
452 | display_xine_frame_t display = this->frameDis; | 310 | frame->bytes_per_line); |
453 | 311 | frame->yuv_stride = frame->bytes_per_line; | |
454 | printf("display frame\n"); | 312 | break; |
455 | // if( this->m_show_video ) { // return if not displaying | 313 | } |
456 | printf("calling home aye\n" ); | 314 | #ifdef LOG |
457 | if( display != NULL ) { | 315 | fprintf (stderr, "nullvideo: colorspace converter configured.\n"); |
458 | (*display)(this->caller, frame->data, | 316 | #endif |
459 | frame->output_width, frame->output_height, | 317 | } |
460 | frame->bytes_per_line ); | 318 | |
461 | printf("display done hope you enyoyed the frame"); | 319 | /* |
462 | } | 320 | * reset dest pointers |
463 | // } | 321 | */ |
464 | 322 | ||
465 | frame->frame.displayed (&frame->frame); | 323 | if (frame->data) { |
324 | switch (flags) { | ||
325 | case VO_TOP_FIELD: | ||
326 | frame->rgb_dst = (uint8_t *)frame->data; | ||
327 | frame->stripe_inc = 2 * frame->stripe_height * frame->bytes_per_line; | ||
328 | break; | ||
329 | case VO_BOTTOM_FIELD: | ||
330 | frame->rgb_dst = (uint8_t *)frame->data + frame->bytes_per_line ; | ||
331 | frame->stripe_inc = 2 * frame->stripe_height * frame->bytes_per_line; | ||
332 | break; | ||
333 | case VO_BOTH_FIELDS: | ||
334 | frame->rgb_dst = (uint8_t *)frame->data; | ||
335 | frame->stripe_inc = frame->stripe_height * frame->bytes_per_line; | ||
336 | break; | ||
337 | } | ||
338 | } | ||
466 | } | 339 | } |
467 | 340 | ||
341 | static void null_display_frame( xine_vo_driver_t* self, vo_frame_t *frame_gen ){ | ||
342 | null_driver_t* this = (null_driver_t*) self; | ||
343 | opie_frame_t* frame = (opie_frame_t*)frame_gen; | ||
344 | display_xine_frame_t display = this->frameDis; | ||
345 | |||
346 | if (!this->m_show_video) | ||
347 | return; | ||
468 | 348 | ||
469 | // blending related | 349 | if( display != NULL ) { |
350 | (*display)(this->caller, frame->data, | ||
351 | frame->sc.output_width, frame->sc.output_height, | ||
352 | frame->bytes_per_line ); | ||
353 | } | ||
354 | |||
355 | frame->frame.displayed (&frame->frame); | ||
356 | } | ||
470 | 357 | ||
471 | 358 | ||
472 | static void null_overlay_clut_yuv2rgb(null_driver_t *this, vo_overlay_t *overlay, | 359 | /* blending related */ |
473 | opie_frame_t *frame) { | 360 | static void null_overlay_clut_yuv2rgb (null_driver_t *this, |
361 | vo_overlay_t *overlay, | ||
362 | opie_frame_t *frame) { | ||
474 | int i; | 363 | int i; |
475 | clut_t* clut = (clut_t*) overlay->color; | 364 | clut_t* clut = (clut_t*) overlay->color; |
476 | if (!overlay->rgb_clut) { | 365 | if (!overlay->rgb_clut) { |
477 | for (i = 0; i < sizeof(overlay->color)/sizeof(overlay->color[0]); i++) { | 366 | for (i = 0; i < sizeof(overlay->color)/sizeof(overlay->color[0]); i++) { |
478 | *((uint32_t *)&clut[i]) = | 367 | *((uint32_t *)&clut[i]) = |
479 | frame->yuv2rgb->yuv2rgb_single_pixel_fun (frame->yuv2rgb, | 368 | frame->yuv2rgb->yuv2rgb_single_pixel_fun (frame->yuv2rgb, |
480 | clut[i].y, clut[i].cb, clut[i].cr); | 369 | clut[i].y, clut[i].cb, clut[i].cr); |
481 | } | 370 | } |
482 | overlay->rgb_clut++; | 371 | overlay->rgb_clut++; |
483 | } | 372 | } |
484 | if (!overlay->clip_rgb_clut) { | 373 | if (!overlay->clip_rgb_clut) { |
485 | clut = (clut_t*) overlay->clip_color; | 374 | clut = (clut_t*) overlay->clip_color; |
486 | for (i = 0; i < sizeof(overlay->color)/sizeof(overlay->color[0]); i++) { | 375 | for (i = 0; i < sizeof(overlay->color)/sizeof(overlay->color[0]); i++) { |
487 | *((uint32_t *)&clut[i]) = | 376 | *((uint32_t *)&clut[i]) = |
488 | frame->yuv2rgb->yuv2rgb_single_pixel_fun(frame->yuv2rgb, | 377 | frame->yuv2rgb->yuv2rgb_single_pixel_fun(frame->yuv2rgb, |
489 | clut[i].y, clut[i].cb, clut[i].cr); | 378 | clut[i].y, clut[i].cb, clut[i].cr); |
490 | } | 379 | } |
491 | overlay->clip_rgb_clut++; | 380 | overlay->clip_rgb_clut++; |
492 | } | 381 | } |
493 | } | 382 | } |
494 | 383 | ||
495 | static void null_overlay_blend (vo_driver_t *this_gen, vo_frame_t *frame_gen, vo_overlay_t *overlay) { | 384 | static void null_overlay_blend ( xine_vo_driver_t *this_gen, vo_frame_t *frame_gen, vo_overlay_t *overlay) { |
496 | null_driver_t *this = (null_driver_t *) this_gen; | 385 | null_driver_t *this = (null_driver_t *) this_gen; |
497 | opie_frame_t *frame = (opie_frame_t *) frame_gen; | 386 | opie_frame_t *frame = (opie_frame_t *) frame_gen; |
498 | 387 | ||
499 | printf("overlay blend\n"); | 388 | if(!this->m_show_video || frame->sc.output_width == 0 |
500 | if(!this->m_show_video || frame->output_width == 0 || frame->output_height== 0) | 389 | || frame->sc.output_height== 0) |
501 | return; | 390 | return; |
502 | 391 | ||
503 | /* Alpha Blend here */ | 392 | /* Alpha Blend here */ |
504 | if (overlay->rle) { | 393 | if (overlay->rle) { |
505 | if( !overlay->rgb_clut || !overlay->clip_rgb_clut) | 394 | if( !overlay->rgb_clut || !overlay->clip_rgb_clut) |
506 | null_overlay_clut_yuv2rgb(this,overlay,frame); | 395 | null_overlay_clut_yuv2rgb(this,overlay,frame); |
507 | 396 | ||
508 | switch(this->bpp) { | 397 | switch(this->bpp) { |
509 | case 16: | 398 | case 16: |
510 | blend_rgb16( (uint8_t *)frame->data, overlay, | 399 | blend_rgb16( (uint8_t *)frame->data, overlay, |
511 | frame->output_width, frame->output_height, | 400 | frame->sc.output_width, frame->sc.output_height, |
512 | frame->width, frame->height); | 401 | frame->sc.delivered_width, frame->sc.delivered_height); |
513 | break; | 402 | break; |
514 | case 24: | 403 | case 24: |
515 | blend_rgb24( (uint8_t *)frame->data, overlay, | 404 | blend_rgb24( (uint8_t *)frame->data, overlay, |
516 | frame->output_width, frame->output_height, | 405 | frame->sc.output_width, frame->sc.output_height, |
517 | frame->width, frame->height); | 406 | frame->sc.delivered_width, frame->sc.delivered_height); |
518 | break; | 407 | break; |
519 | case 32: | 408 | case 32: |
520 | blend_rgb32( (uint8_t *)frame->data, overlay, | 409 | blend_rgb32( (uint8_t *)frame->data, overlay, |
521 | frame->output_width, frame->output_height, | 410 | frame->sc.output_width, frame->sc.output_height, |
522 | frame->width, frame->height); | 411 | frame->sc.delivered_width, frame->sc.delivered_height); |
523 | break; | 412 | break; |
524 | default: | 413 | default: |
525 | /* It should never get here */ | 414 | /* It should never get here */ |
526 | break; | 415 | break; |
527 | } | 416 | } |
528 | } | 417 | } |
529 | } | 418 | } |
530 | 419 | ||
531 | 420 | ||
532 | static int null_get_property( vo_driver_t* self, | 421 | static int null_get_property( xine_vo_driver_t* self, |
533 | int property ){ | 422 | int property ){ |
534 | printf("property get\n"); | 423 | return 0; |
535 | return 0; | ||
536 | } | 424 | } |
537 | static int null_set_property( vo_driver_t* self, | 425 | static int null_set_property( xine_vo_driver_t* self, |
538 | int property, | 426 | int property, |
539 | int value ){ | 427 | int value ){ |
540 | printf("set property\n"); | 428 | return value; |
541 | return value; | ||
542 | } | 429 | } |
543 | static void null_get_property_min_max( vo_driver_t* self, | 430 | static void null_get_property_min_max( xine_vo_driver_t* self, |
544 | int property, int *min, | 431 | int property, int *min, |
545 | int *max ){ | 432 | int *max ){ |
546 | printf("min max\n"); | 433 | *max = 0; |
547 | *max = 0; | 434 | *min = 0; |
548 | *min = 0; | ||
549 | } | 435 | } |
550 | static int null_gui_data_exchange( vo_driver_t* self, | 436 | static int null_gui_data_exchange( xine_vo_driver_t* self, |
551 | int data_type, | 437 | int data_type, |
552 | void *data ){ | 438 | void *data ){ |
553 | return 0; | 439 | return 0; |
554 | } | 440 | } |
555 | static void null_exit( vo_driver_t* self ){ | 441 | |
556 | null_driver_t* this = (null_driver_t*)self; | 442 | static void null_exit( xine_vo_driver_t* self ){ |
557 | free ( this ); | 443 | null_driver_t* this = (null_driver_t*)self; |
444 | free ( this ); | ||
558 | } | 445 | } |
559 | static int null_redraw_needed( vo_driver_t* self ){ | 446 | static int null_redraw_needed( xine_vo_driver_t* self ){ |
560 | return 0; | 447 | return 0; |
561 | } | 448 | } |
562 | 449 | ||
563 | 450 | ||
564 | vo_driver_t* init_video_out_plugin( config_values_t* conf, | 451 | xine_vo_driver_t* init_video_out_plugin( config_values_t* conf, |
565 | void* video ){ | 452 | void* video ){ |
566 | null_driver_t *vo; | 453 | null_driver_t *vo; |
567 | vo = (null_driver_t*)malloc( sizeof(null_driver_t ) ); | 454 | vo = (null_driver_t*)malloc( sizeof(null_driver_t ) ); |
568 | 455 | ||
569 | /* memset? */ | 456 | /* memset? */ |
570 | memset(vo,0, sizeof(null_driver_t ) ); | 457 | memset(vo,0, sizeof(null_driver_t ) ); |
571 | vo->m_show_video = 0; // false | 458 | |
572 | vo->m_video_fullscreen = 0; | 459 | vo_scale_init (&vo->sc, 0, 0); |
573 | vo->m_is_scaling = 0; | 460 | |
574 | vo->user_ratio = ASPECT_AUTO; | 461 | vo->sc.gui_pixel_aspect = 1.0; |
575 | vo->display_ratio = 1.0; | 462 | |
576 | vo->gui_width = 16; | 463 | vo->m_show_video = 0; // false |
577 | vo->gui_height = 8; | 464 | vo->m_video_fullscreen = 0; |
578 | vo->frameDis = NULL; | 465 | vo->m_is_scaling = 0; |
579 | 466 | vo->display_ratio = 1.0; | |
580 | /* install callback handlers*/ | 467 | vo->gui_width = 16; |
581 | vo->vo_driver.get_capabilities = null_get_capabilities; | 468 | vo->gui_height = 8; |
582 | vo->vo_driver.alloc_frame = null_alloc_frame; | 469 | vo->frameDis = NULL; |
583 | vo->vo_driver.update_frame_format = null_update_frame_format; | 470 | |
584 | vo->vo_driver.display_frame = null_display_frame; | 471 | /* install callback handlers*/ |
585 | vo->vo_driver.overlay_blend = null_overlay_blend; | 472 | vo->vo_driver.get_capabilities = null_get_capabilities; |
586 | vo->vo_driver.get_property = null_get_property; | 473 | vo->vo_driver.alloc_frame = null_alloc_frame; |
587 | vo->vo_driver.set_property = null_set_property; | 474 | vo->vo_driver.update_frame_format = null_update_frame_format; |
588 | vo->vo_driver.get_property_min_max = null_get_property_min_max; | 475 | vo->vo_driver.display_frame = null_display_frame; |
589 | vo->vo_driver.gui_data_exchange = null_gui_data_exchange; | 476 | vo->vo_driver.overlay_blend = null_overlay_blend; |
590 | vo->vo_driver.exit = null_exit; | 477 | vo->vo_driver.get_property = null_get_property; |
591 | vo->vo_driver.redraw_needed = null_redraw_needed; | 478 | vo->vo_driver.set_property = null_set_property; |
479 | vo->vo_driver.get_property_min_max = null_get_property_min_max; | ||
480 | vo->vo_driver.gui_data_exchange = null_gui_data_exchange; | ||
481 | vo->vo_driver.exit = null_exit; | ||
482 | vo->vo_driver.redraw_needed = null_redraw_needed; | ||
592 | 483 | ||
593 | 484 | ||
594 | /* capabilities */ | 485 | /* capabilities */ |
595 | vo->m_capabilities = VO_CAP_COPIES_IMAGE | VO_CAP_YUY2 | VO_CAP_YV12; | 486 | vo->m_capabilities = VO_CAP_COPIES_IMAGE | VO_CAP_YUY2 | VO_CAP_YV12; |
596 | vo->yuv2rgb_factory = yuv2rgb_factory_init (MODE_16_RGB, vo->yuv2rgb_swap, | 487 | vo->yuv2rgb_factory = yuv2rgb_factory_init (MODE_16_RGB, vo->yuv2rgb_swap, |
597 | vo->yuv2rgb_cmap); | 488 | vo->yuv2rgb_cmap); |
598 | printf("done initialisation\n"); | 489 | |
599 | return (vo_driver_t*) vo; | 490 | return ( xine_vo_driver_t*) vo; |
600 | } | 491 | } |
601 | 492 | ||
602 | static vo_info_t vo_info_null = { | 493 | static vo_info_t vo_info_null = { |
603 | 5, | 494 | 5, |
604 | "null plugin", | 495 | "null plugin", |
605 | NULL, | 496 | XINE_VISUAL_TYPE_FB |
606 | VISUAL_TYPE_FB, | ||
607 | 5 | ||
608 | }; | 497 | }; |
609 | 498 | ||
610 | vo_info_t *get_video_out_plugin_info(){ | 499 | vo_info_t *get_video_out_plugin_info(){ |
611 | vo_info_null.description = _("xine video output plugin using null device"); | 500 | vo_info_null.description = _("xine video output plugin using null device"); |
612 | return &vo_info_null; | 501 | return &vo_info_null; |
613 | } | 502 | } |
614 | 503 | ||
615 | /* this is special for this device */ | 504 | /* this is special for this device */ |
616 | /** | 505 | /** |
617 | * We know that we will be controled by the XINE LIB++ | 506 | * We know that we will be controled by the XINE LIB++ |
618 | */ | 507 | */ |
619 | 508 | ||
620 | /** | 509 | /** |
621 | * | 510 | * |
622 | */ | 511 | */ |
623 | int null_is_showing_video( vo_driver_t* self ){ | 512 | int null_is_showing_video( xine_vo_driver_t* self ){ |
624 | null_driver_t* this = (null_driver_t*)self; | 513 | null_driver_t* this = (null_driver_t*)self; |
625 | return this->m_show_video; | 514 | return this->m_show_video; |
626 | } | 515 | } |
627 | void null_set_show_video( vo_driver_t* self, int show ) { | 516 | void null_set_show_video( xine_vo_driver_t* self, int show ) { |
628 | ((null_driver_t*)self)->m_show_video = show; | 517 | ((null_driver_t*)self)->m_show_video = show; |
629 | } | 518 | } |
630 | 519 | ||
631 | int null_is_fullscreen( vo_driver_t* self ){ | 520 | int null_is_fullscreen( xine_vo_driver_t* self ){ |
632 | return ((null_driver_t*)self)->m_video_fullscreen; | 521 | return ((null_driver_t*)self)->m_video_fullscreen; |
633 | } | 522 | } |
634 | void null_set_fullscreen( vo_driver_t* self, int screen ){ | 523 | void null_set_fullscreen( xine_vo_driver_t* self, int screen ){ |
635 | ((null_driver_t*)self)->m_video_fullscreen = screen; | 524 | ((null_driver_t*)self)->m_video_fullscreen = screen; |
636 | } | 525 | } |
637 | int null_is_scaling( vo_driver_t* self ){ | 526 | int null_is_scaling( xine_vo_driver_t* self ){ |
638 | return ((null_driver_t*)self)->m_is_scaling; | 527 | return ((null_driver_t*)self)->m_is_scaling; |
639 | } | 528 | } |
640 | 529 | ||
641 | void null_set_videoGamma( vo_driver_t* self , int value ) { | 530 | void null_set_videoGamma( xine_vo_driver_t* self , int value ) { |
642 | ((null_driver_t*) self) ->yuv2rgb_gamma = value; | 531 | ((null_driver_t*) self) ->yuv2rgb_gamma = value; |
643 | ((null_driver_t*) self) ->yuv2rgb_factory->set_gamma( ((null_driver_t*) self) ->yuv2rgb_factory, value ); | 532 | ((null_driver_t*) self) ->yuv2rgb_factory->set_gamma( ((null_driver_t*) self) ->yuv2rgb_factory, value ); |
644 | } | 533 | } |
645 | 534 | ||
646 | void null_set_scaling( vo_driver_t* self, int scale ){ | 535 | void null_set_scaling( xine_vo_driver_t* self, int scale ) { |
647 | ((null_driver_t*)self)->m_is_scaling = scale; | 536 | ((null_driver_t*)self)->m_is_scaling = scale; |
648 | } | 537 | } |
649 | 538 | ||
650 | void null_set_gui_width( vo_driver_t* self, int width ){ | 539 | void null_set_gui_width( xine_vo_driver_t* self, int width ) { |
651 | ((null_driver_t*)self)->gui_width = width; | 540 | ((null_driver_t*)self)->gui_width = width; |
652 | } | 541 | } |
653 | void null_set_gui_height( vo_driver_t* self, int height ){ | 542 | void null_set_gui_height( xine_vo_driver_t* self, int height ) { |
654 | ((null_driver_t*)self)->gui_height = height; | 543 | ((null_driver_t*)self)->gui_height = height; |
655 | } | 544 | } |
656 | 545 | ||
657 | 546 | ||
658 | void null_set_mode( vo_driver_t* self, int depth, int rgb ){ | 547 | void null_set_mode( xine_vo_driver_t* self, int depth, int rgb ) { |
659 | null_driver_t* this = (null_driver_t*)self; | 548 | null_driver_t* this = (null_driver_t*)self; |
660 | 549 | ||
661 | this->bytes_per_pixel = (depth + 7 ) / 8; | 550 | this->bytes_per_pixel = (depth + 7 ) / 8; |
662 | this->bpp = this->bytes_per_pixel * 8; | 551 | this->bpp = this->bytes_per_pixel * 8; |
663 | this->depth = depth; | 552 | this->depth = depth; |
664 | printf("depth %d %d\n", depth, this->bpp); | 553 | printf("depth %d %d\n", depth, this->bpp); |
665 | printf("pixeltype %d\n", rgb ); | 554 | printf("pixeltype %d\n", rgb ); |
666 | switch ( this->depth ){ | 555 | switch ( this->depth ) { |
667 | case 32: | 556 | case 32: |
668 | if( rgb == 0 ) | 557 | if( rgb == 0 ) |
669 | this->yuv2rgb_mode = MODE_32_RGB; | 558 | this->yuv2rgb_mode = MODE_32_RGB; |
670 | else | 559 | else |
671 | this->yuv2rgb_mode = MODE_32_BGR; | 560 | this->yuv2rgb_mode = MODE_32_BGR; |
672 | case 24: | 561 | case 24: |
673 | if( this->bpp == 32 ) { | 562 | if( this->bpp == 32 ) { |
674 | if(rgb == 0 ) | 563 | if( rgb == 0 ) { |
675 | this->yuv2rgb_mode = MODE_32_RGB; | 564 | this->yuv2rgb_mode = MODE_32_RGB; |
676 | else | 565 | } else { |
677 | this->yuv2rgb_mode = MODE_32_BGR; | 566 | this->yuv2rgb_mode = MODE_32_BGR; |
678 | }else{ | 567 | } |
679 | if( rgb == 0 ) | 568 | }else{ |
680 | this->yuv2rgb_mode = MODE_24_RGB; | 569 | if( rgb == 0 ) |
681 | else | 570 | this->yuv2rgb_mode = MODE_24_RGB; |
682 | this->yuv2rgb_mode = MODE_24_BGR; | 571 | else |
683 | }; | 572 | this->yuv2rgb_mode = MODE_24_BGR; |
684 | break; | ||
685 | case 16: | ||
686 | if( rgb == 0 ) | ||
687 | this->yuv2rgb_mode = MODE_16_RGB; | ||
688 | else | ||
689 | this->yuv2rgb_mode = MODE_16_BGR; | ||
690 | break; | ||
691 | case 15: | ||
692 | if( rgb == 0 ) | ||
693 | this->yuv2rgb_mode = MODE_15_RGB; | ||
694 | else | ||
695 | this->yuv2rgb_mode = MODE_15_BGR; | ||
696 | break; | ||
697 | case 8: | ||
698 | if( rgb == 0 ) | ||
699 | this->yuv2rgb_mode = MODE_8_RGB; | ||
700 | else | ||
701 | this->yuv2rgb_mode = MODE_8_BGR; | ||
702 | break; | ||
703 | }; | 573 | }; |
704 | //free(this->yuv2rgb_factory ); | 574 | break; |
705 | // this->yuv2rgb_factory = yuv2rgb_factory_init (this->yuv2rgb_mode, this->yuv2rgb_swap, | 575 | case 16: |
706 | // this->yuv2rgb_cmap); | 576 | if( rgb == 0 ) { |
577 | this->yuv2rgb_mode = MODE_16_RGB; | ||
578 | } else { | ||
579 | this->yuv2rgb_mode = MODE_16_BGR; | ||
580 | } | ||
581 | break; | ||
582 | case 15: | ||
583 | if( rgb == 0 ) { | ||
584 | this->yuv2rgb_mode = MODE_15_RGB; | ||
585 | } else { | ||
586 | this->yuv2rgb_mode = MODE_15_BGR; | ||
587 | } | ||
588 | break; | ||
589 | case 8: | ||
590 | if( rgb == 0 ) { | ||
591 | this->yuv2rgb_mode = MODE_8_RGB; | ||
592 | } else { | ||
593 | this->yuv2rgb_mode = MODE_8_BGR; | ||
594 | } | ||
595 | break; | ||
596 | }; | ||
597 | //free(this->yuv2rgb_factory ); | ||
598 | // this->yuv2rgb_factory = yuv2rgb_factory_init (this->yuv2rgb_mode, this->yuv2rgb_swap, | ||
599 | // this->yuv2rgb_cmap); | ||
707 | }; | 600 | }; |
708 | void null_display_handler(vo_driver_t* self, display_xine_frame_t t, void* user_data) { | 601 | |
709 | null_driver_t* this = (null_driver_t*) self; | 602 | void null_display_handler( xine_vo_driver_t* self, display_xine_frame_t t, |
710 | this->caller = user_data; | 603 | void* user_data ) { |
711 | this->frameDis = t; | 604 | null_driver_t* this = (null_driver_t*) self; |
605 | this->caller = user_data; | ||
606 | this->frameDis = t; | ||
712 | } | 607 | } |
713 | 608 | ||
diff --git a/noncore/multimedia/opieplayer2/opieplayer2.pro b/noncore/multimedia/opieplayer2/opieplayer2.pro index a83a624..1b687a3 100644 --- a/noncore/multimedia/opieplayer2/opieplayer2.pro +++ b/noncore/multimedia/opieplayer2/opieplayer2.pro | |||
@@ -1,24 +1,24 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | #CONFIG = qt warn_on release | 2 | #CONFIG = qt warn_on release |
3 | CONFIG = qt warn_on debug | 3 | CONFIG = qt warn_on debug |
4 | DESTDIR = $(OPIEDIR)/bin | 4 | DESTDIR = $(OPIEDIR)/bin |
5 | HEADERS = playlistselection.h mediaplayerstate.h xinecontrol.h mediadetect.h\ | 5 | HEADERS = playlistselection.h mediaplayerstate.h xinecontrol.h mediadetect.h\ |
6 | videowidget.h audiowidget.h playlistwidget.h mediaplayer.h inputDialog.h \ | 6 | videowidget.h audiowidget.h playlistwidget.h mediaplayer.h inputDialog.h \ |
7 | frame.h lib.h xinevideowidget.h volumecontrol.h playlistwidgetgui.h\ | 7 | frame.h lib.h xinevideowidget.h volumecontrol.h playlistwidgetgui.h\ |
8 | alphablend.h yuv2rgb.h | 8 | alphablend.h yuv2rgb.h |
9 | SOURCES = main.cpp \ | 9 | SOURCES = main.cpp \ |
10 | playlistselection.cpp mediaplayerstate.cpp xinecontrol.cpp mediadetect.cpp\ | 10 | playlistselection.cpp mediaplayerstate.cpp xinecontrol.cpp mediadetect.cpp\ |
11 | videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp inputDialog.cpp \ | 11 | videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp inputDialog.cpp \ |
12 | frame.cpp lib.cpp nullvideo.c xinevideowidget.cpp volumecontrol.cpp \ | 12 | frame.cpp lib.cpp nullvideo.c xinevideowidget.cpp volumecontrol.cpp \ |
13 | playlistwidgetgui.cpp\ | 13 | playlistwidgetgui.cpp\ |
14 | alphablend.c yuv2rgb.c yuv2rgb_arm.c yuv2rgb_arm4l.S | 14 | alphablend.c yuv2rgb.c yuv2rgb_arm.c yuv2rgb_arm4l.S |
15 | TARGET = opieplayer2 | 15 | TARGET = opieplayer2 |
16 | INCLUDEPATH += $(OPIEDIR)/include | 16 | INCLUDEPATH += $(OPIEDIR)/include |
17 | DEPENDPATH += $(OPIEDIR)/include | 17 | DEPENDPATH += $(OPIEDIR)/include |
18 | LIBS += -lqpe -lpthread -lopie -lxine -lxineutils | 18 | LIBS += -lqpe -lpthread -lopie -lxine |
19 | MOC_DIR = qpeobj | 19 | MOC_DIR = qpeobj |
20 | OBJECTS_DIR = qpeobj | 20 | OBJECTS_DIR = qpeobj |
21 | 21 | ||
22 | #INCLUDEPATH += $(OPIEDIR)/include | 22 | #INCLUDEPATH += $(OPIEDIR)/include |
23 | #DEPENDPATH += $(OPIEDIR)/include | 23 | #DEPENDPATH += $(OPIEDIR)/include |
24 | 24 | ||
diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp index ce472f1..1042a0c 100644 --- a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp | |||
@@ -1,228 +1,227 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; General Public License for more | 22 | ..}^=.= = ; General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = General Public License along with | 26 | -_. . . )=. = General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <qpe/qpemenubar.h> | 34 | #include <qpe/qpemenubar.h> |
35 | #include <qpe/qpetoolbar.h> | 35 | #include <qpe/qpetoolbar.h> |
36 | #include <qpe/fileselector.h> | 36 | #include <qpe/fileselector.h> |
37 | #include <qpe/qpeapplication.h> | 37 | #include <qpe/qpeapplication.h> |
38 | #include <qpe/storage.h> | 38 | #include <qpe/storage.h> |
39 | #include <qpe/mimetype.h> | 39 | #include <qpe/mimetype.h> |
40 | #include <qpe/config.h> | 40 | #include <qpe/config.h> |
41 | #include <qpe/global.h> | 41 | #include <qpe/global.h> |
42 | #include <qpe/resource.h> | 42 | #include <qpe/resource.h> |
43 | 43 | ||
44 | #include <qpopupmenu.h> | 44 | #include <qpopupmenu.h> |
45 | #include <qaction.h> | 45 | #include <qaction.h> |
46 | #include <qcursor.h> | 46 | #include <qcursor.h> |
47 | #include <qdir.h> | 47 | #include <qdir.h> |
48 | #include <qlayout.h> | 48 | #include <qlayout.h> |
49 | 49 | ||
50 | #include "playlistselection.h" | 50 | #include "playlistselection.h" |
51 | #include "playlistwidget.h" | 51 | #include "playlistwidget.h" |
52 | #include "mediaplayerstate.h" | 52 | #include "mediaplayerstate.h" |
53 | #include "inputDialog.h" | 53 | #include "inputDialog.h" |
54 | 54 | ||
55 | //only needed for the random play | 55 | //only needed for the random play |
56 | #include <stdlib.h> | 56 | #include <stdlib.h> |
57 | 57 | ||
58 | #include "audiowidget.h" | 58 | #include "audiowidget.h" |
59 | #include "videowidget.h" | 59 | #include "videowidget.h" |
60 | #include "mediaplayerstate.h" | 60 | #include "mediaplayerstate.h" |
61 | 61 | ||
62 | extern MediaPlayerState *mediaPlayerState; | 62 | extern MediaPlayerState *mediaPlayerState; |
63 | 63 | ||
64 | PlayListWidgetGui::PlayListWidgetGui( QWidget* parent, const char* name, WFlags fl ) | 64 | PlayListWidgetGui::PlayListWidgetGui( QWidget* parent, const char* name, WFlags fl ) |
65 | : QMainWindow( parent, name, fl ) { | 65 | : QMainWindow( parent, name, fl ) { |
66 | 66 | ||
67 | d = new PlayListWidgetPrivate; | 67 | d = new PlayListWidgetPrivate; |
68 | d->setDocumentUsed = FALSE; | 68 | d->setDocumentUsed = FALSE; |
69 | d->current = NULL; | 69 | d->current = NULL; |
70 | 70 | ||
71 | setBackgroundMode( PaletteButton ); | 71 | setBackgroundMode( PaletteButton ); |
72 | setToolBarsMovable( FALSE ); | 72 | setToolBarsMovable( FALSE ); |
73 | 73 | ||
74 | // Create Toolbar | 74 | // Create Toolbar |
75 | QPEToolBar *toolbar = new QPEToolBar( this ); | 75 | QPEToolBar *toolbar = new QPEToolBar( this ); |
76 | toolbar->setHorizontalStretchable( TRUE ); | 76 | toolbar->setHorizontalStretchable( TRUE ); |
77 | 77 | ||
78 | // Create Menubar | 78 | // Create Menubar |
79 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | 79 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); |
80 | menu->setMargin( 0 ); | 80 | menu->setMargin( 0 ); |
81 | 81 | ||
82 | bar = new QPEToolBar( this ); | 82 | bar = new QPEToolBar( this ); |
83 | bar->setLabel( tr( "Play Operations" ) ); | 83 | bar->setLabel( tr( "Play Operations" ) ); |
84 | 84 | ||
85 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet( "trash" ), "", bar, "close" ); | 85 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet( "trash" ), "", bar, "close" ); |
86 | tbDeletePlaylist->setFlat( TRUE ); | 86 | tbDeletePlaylist->setFlat( TRUE ); |
87 | tbDeletePlaylist->setFixedSize( 20, 20 ); | 87 | tbDeletePlaylist->setFixedSize( 20, 20 ); |
88 | 88 | ||
89 | tbDeletePlaylist->hide(); | 89 | tbDeletePlaylist->hide(); |
90 | 90 | ||
91 | pmPlayList = new QPopupMenu( this ); | 91 | pmPlayList = new QPopupMenu( this ); |
92 | menu->insertItem( tr( "File" ), pmPlayList ); | 92 | menu->insertItem( tr( "File" ), pmPlayList ); |
93 | 93 | ||
94 | pmView = new QPopupMenu( this ); | 94 | pmView = new QPopupMenu( this ); |
95 | menu->insertItem( tr( "View" ), pmView ); | 95 | menu->insertItem( tr( "View" ), pmView ); |
96 | pmView->isCheckable(); | 96 | pmView->isCheckable(); |
97 | 97 | ||
98 | skinsMenu = new QPopupMenu( this ); | 98 | skinsMenu = new QPopupMenu( this ); |
99 | pmView->insertItem( tr( "Skins" ), skinsMenu ); | 99 | pmView->insertItem( tr( "Skins" ), skinsMenu ); |
100 | skinsMenu->isCheckable(); | 100 | skinsMenu->isCheckable(); |
101 | 101 | ||
102 | gammaMenu = new QPopupMenu( this ); | 102 | gammaMenu = new QPopupMenu( this ); |
103 | pmView->insertItem( tr( "Gamma" ), gammaMenu ); | 103 | pmView->insertItem( tr( "Gamma (Video)" ), gammaMenu ); |
104 | gammaMenu->setMinimumHeight( 50 ); | ||
105 | 104 | ||
106 | gammaSlider = new QSlider( QSlider::Vertical, gammaMenu ); | 105 | gammaSlider = new QSlider( QSlider::Vertical, gammaMenu ); |
107 | gammaSlider->setRange( -100, 100 ); | 106 | gammaSlider->setRange( -100, 100 ); |
108 | gammaSlider->setTickmarks( QSlider::Left ); | 107 | gammaSlider->setTickmarks( QSlider::Left ); |
109 | gammaSlider->setTickInterval( 20 ); | 108 | gammaSlider->setTickInterval( 20 ); |
110 | gammaSlider->setFocusPolicy( QWidget::NoFocus ); | 109 | gammaSlider->setFocusPolicy( QWidget::NoFocus ); |
111 | gammaSlider->setValue( 0 ); | 110 | gammaSlider->setValue( 0 ); |
112 | gammaSlider->setMinimumHeight( 50 ); | 111 | gammaSlider->setMinimumHeight( 50 ); |
113 | 112 | ||
114 | gammaLCD = new QLCDNumber( 3, gammaMenu ); | 113 | gammaLCD = new QLCDNumber( 3, gammaMenu ); |
115 | 114 | ||
116 | gammaMenu->insertItem( gammaSlider ); | 115 | gammaMenu->insertItem( gammaSlider ); |
117 | gammaMenu->insertItem( gammaLCD ); | 116 | gammaMenu->insertItem( gammaLCD ); |
118 | 117 | ||
119 | connect( gammaSlider, SIGNAL( valueChanged( int ) ), gammaLCD, SLOT( display( int ) ) ); | 118 | connect( gammaSlider, SIGNAL( valueChanged( int ) ), gammaLCD, SLOT( display( int ) ) ); |
120 | 119 | ||
121 | vbox5 = new QVBox( this ); | 120 | vbox5 = new QVBox( this ); |
122 | QVBox *vbox4 = new QVBox( vbox5 ); | 121 | QVBox *vbox4 = new QVBox( vbox5 ); |
123 | QHBox *hbox6 = new QHBox( vbox4 ); | 122 | QHBox *hbox6 = new QHBox( vbox4 ); |
124 | 123 | ||
125 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 124 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
126 | 125 | ||
127 | QWidget *pTab; | 126 | QWidget *pTab; |
128 | pTab = new QWidget( tabWidget, "pTab" ); | 127 | pTab = new QWidget( tabWidget, "pTab" ); |
129 | tabWidget->insertTab( pTab, "Playlist"); | 128 | tabWidget->insertTab( pTab, "Playlist"); |
130 | 129 | ||
131 | QGridLayout *Playout = new QGridLayout( pTab ); | 130 | QGridLayout *Playout = new QGridLayout( pTab ); |
132 | Playout->setSpacing( 2); | 131 | Playout->setSpacing( 2); |
133 | Playout->setMargin( 2); | 132 | Playout->setMargin( 2); |
134 | 133 | ||
135 | // Add the playlist area | 134 | // Add the playlist area |
136 | QVBox *vbox3 = new QVBox( pTab ); | 135 | QVBox *vbox3 = new QVBox( pTab ); |
137 | d->playListFrame = vbox3; | 136 | d->playListFrame = vbox3; |
138 | 137 | ||
139 | QHBox *hbox2 = new QHBox( vbox3 ); | 138 | QHBox *hbox2 = new QHBox( vbox3 ); |
140 | d->selectedFiles = new PlayListSelection( hbox2 ); | 139 | d->selectedFiles = new PlayListSelection( hbox2 ); |
141 | 140 | ||
142 | vbox1 = new QVBox( hbox2 ); | 141 | vbox1 = new QVBox( hbox2 ); |
143 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(), QPEApplication::RightOnHold ); | 142 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(), QPEApplication::RightOnHold ); |
144 | QVBox *stretch1 = new QVBox( vbox1 ); // add stretch | 143 | QVBox *stretch1 = new QVBox( vbox1 ); // add stretch |
145 | 144 | ||
146 | Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 ); | 145 | Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 ); |
147 | 146 | ||
148 | QWidget *aTab; | 147 | QWidget *aTab; |
149 | aTab = new QWidget( tabWidget, "aTab" ); | 148 | aTab = new QWidget( tabWidget, "aTab" ); |
150 | 149 | ||
151 | QGridLayout *Alayout = new QGridLayout( aTab ); | 150 | QGridLayout *Alayout = new QGridLayout( aTab ); |
152 | Alayout->setSpacing( 2 ); | 151 | Alayout->setSpacing( 2 ); |
153 | Alayout->setMargin( 2 ); | 152 | Alayout->setMargin( 2 ); |
154 | audioView = new QListView( aTab, "Audioview" ); | 153 | audioView = new QListView( aTab, "Audioview" ); |
155 | audioView->addColumn( tr( "Title" ), 140 ); | 154 | audioView->addColumn( tr( "Title" ), 140 ); |
156 | audioView->addColumn( tr( "Size" ), -1 ); | 155 | audioView->addColumn( tr( "Size" ), -1 ); |
157 | audioView->addColumn( tr( "Media" ), -1 ); | 156 | audioView->addColumn( tr( "Media" ), -1 ); |
158 | audioView->addColumn( tr( "Path" ), 0 ); | 157 | audioView->addColumn( tr( "Path" ), 0 ); |
159 | audioView->setColumnAlignment( 1, Qt::AlignRight ); | 158 | audioView->setColumnAlignment( 1, Qt::AlignRight ); |
160 | audioView->setColumnAlignment( 2, Qt::AlignRight ); | 159 | audioView->setColumnAlignment( 2, Qt::AlignRight ); |
161 | audioView->setAllColumnsShowFocus( TRUE ); | 160 | audioView->setAllColumnsShowFocus( TRUE ); |
162 | audioView->setSorting( 0, TRUE ); | 161 | audioView->setSorting( 0, TRUE ); |
163 | audioView->setMultiSelection( TRUE ); | 162 | audioView->setMultiSelection( TRUE ); |
164 | audioView->setSelectionMode( QListView::Extended ); | 163 | audioView->setSelectionMode( QListView::Extended ); |
165 | Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 ); | 164 | Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 ); |
166 | tabWidget->insertTab( aTab, tr( "Audio" ) ); | 165 | tabWidget->insertTab( aTab, tr( "Audio" ) ); |
167 | 166 | ||
168 | QPEApplication::setStylusOperation( audioView->viewport(), QPEApplication::RightOnHold ); | 167 | QPEApplication::setStylusOperation( audioView->viewport(), QPEApplication::RightOnHold ); |
169 | 168 | ||
170 | QWidget *vTab; | 169 | QWidget *vTab; |
171 | vTab = new QWidget( tabWidget, "vTab" ); | 170 | vTab = new QWidget( tabWidget, "vTab" ); |
172 | 171 | ||
173 | QGridLayout *Vlayout = new QGridLayout( vTab ); | 172 | QGridLayout *Vlayout = new QGridLayout( vTab ); |
174 | Vlayout->setSpacing( 2 ); | 173 | Vlayout->setSpacing( 2 ); |
175 | Vlayout->setMargin( 2 ); | 174 | Vlayout->setMargin( 2 ); |
176 | videoView = new QListView( vTab, "Videoview" ); | 175 | videoView = new QListView( vTab, "Videoview" ); |
177 | videoView->addColumn( tr( "Title" ), 140); | 176 | videoView->addColumn( tr( "Title" ), 140); |
178 | videoView->addColumn( tr( "Size" ), -1 ); | 177 | videoView->addColumn( tr( "Size" ), -1 ); |
179 | videoView->addColumn(tr( "Media" ), -1 ); | 178 | videoView->addColumn(tr( "Media" ), -1 ); |
180 | videoView->addColumn(tr( "Path" ), 0 ); | 179 | videoView->addColumn(tr( "Path" ), 0 ); |
181 | videoView->setColumnAlignment( 1, Qt::AlignRight ); | 180 | videoView->setColumnAlignment( 1, Qt::AlignRight ); |
182 | videoView->setColumnAlignment( 2, Qt::AlignRight ); | 181 | videoView->setColumnAlignment( 2, Qt::AlignRight ); |
183 | videoView->setAllColumnsShowFocus( TRUE ); | 182 | videoView->setAllColumnsShowFocus( TRUE ); |
184 | videoView->setSorting( 0, TRUE ); | 183 | videoView->setSorting( 0, TRUE ); |
185 | videoView->setMultiSelection( TRUE ); | 184 | videoView->setMultiSelection( TRUE ); |
186 | videoView->setSelectionMode( QListView::Extended ); | 185 | videoView->setSelectionMode( QListView::Extended ); |
187 | Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 ); | 186 | Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 ); |
188 | 187 | ||
189 | QPEApplication::setStylusOperation( videoView->viewport(), QPEApplication::RightOnHold ); | 188 | QPEApplication::setStylusOperation( videoView->viewport(), QPEApplication::RightOnHold ); |
190 | 189 | ||
191 | tabWidget->insertTab( vTab, tr( "Video" ) ); | 190 | tabWidget->insertTab( vTab, tr( "Video" ) ); |
192 | 191 | ||
193 | //playlists list | 192 | //playlists list |
194 | QWidget *LTab; | 193 | QWidget *LTab; |
195 | LTab = new QWidget( tabWidget, "LTab" ); | 194 | LTab = new QWidget( tabWidget, "LTab" ); |
196 | QGridLayout *Llayout = new QGridLayout( LTab ); | 195 | QGridLayout *Llayout = new QGridLayout( LTab ); |
197 | Llayout->setSpacing( 2 ); | 196 | Llayout->setSpacing( 2 ); |
198 | Llayout->setMargin( 2 ); | 197 | Llayout->setMargin( 2 ); |
199 | 198 | ||
200 | playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE ); | 199 | playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE ); |
201 | Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 ); | 200 | Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 ); |
202 | 201 | ||
203 | tabWidget->insertTab( LTab, tr( "Lists" ) ); | 202 | tabWidget->insertTab( LTab, tr( "Lists" ) ); |
204 | 203 | ||
205 | setCentralWidget( vbox5 ); | 204 | setCentralWidget( vbox5 ); |
206 | } | 205 | } |
207 | 206 | ||
208 | 207 | ||
209 | 208 | ||
210 | PlayListWidgetGui::~PlayListWidgetGui() { | 209 | PlayListWidgetGui::~PlayListWidgetGui() { |
211 | } | 210 | } |
212 | 211 | ||
213 | void PlayListWidgetGui::setView( char view ) { | 212 | void PlayListWidgetGui::setView( char view ) { |
214 | if ( view == 'l' ) | 213 | if ( view == 'l' ) |
215 | showMaximized(); | 214 | showMaximized(); |
216 | else | 215 | else |
217 | hide(); | 216 | hide(); |
218 | } | 217 | } |
219 | 218 | ||
220 | 219 | ||
221 | void PlayListWidgetGui::setActiveWindow() { | 220 | void PlayListWidgetGui::setActiveWindow() { |
222 | // qDebug("SETTING active window"); | 221 | // qDebug("SETTING active window"); |
223 | // When we get raised we need to ensure that it switches views | 222 | // When we get raised we need to ensure that it switches views |
224 | char origView = mediaPlayerState->view(); | 223 | char origView = mediaPlayerState->view(); |
225 | mediaPlayerState->setView( 'l' ); // invalidate | 224 | mediaPlayerState->setView( 'l' ); // invalidate |
226 | mediaPlayerState->setView( origView ); // now switch back | 225 | mediaPlayerState->setView( origView ); // now switch back |
227 | } | 226 | } |
228 | 227 | ||
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index b0ec673..f5f5c37 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -1,512 +1,511 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <qpe/qpeapplication.h> | 34 | #include <qpe/qpeapplication.h> |
35 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
36 | #include <qpe/mediaplayerplugininterface.h> | 36 | #include <qpe/mediaplayerplugininterface.h> |
37 | #include <qpe/config.h> | 37 | #include <qpe/config.h> |
38 | 38 | ||
39 | 39 | ||
40 | #include <qwidget.h> | 40 | #include <qwidget.h> |
41 | #include <qpainter.h> | 41 | #include <qpainter.h> |
42 | #include <qpixmap.h> | 42 | #include <qpixmap.h> |
43 | #include <qslider.h> | 43 | #include <qslider.h> |
44 | #include <qdrawutil.h> | 44 | #include <qdrawutil.h> |
45 | #include "videowidget.h" | 45 | #include "videowidget.h" |
46 | #include "mediaplayerstate.h" | 46 | #include "mediaplayerstate.h" |
47 | #include "playlistwidget.h" | 47 | #include "playlistwidget.h" |
48 | 48 | ||
49 | 49 | ||
50 | #ifdef Q_WS_QWS | 50 | #ifdef Q_WS_QWS |
51 | # define USE_DIRECT_PAINTER | 51 | # define USE_DIRECT_PAINTER |
52 | # include <qdirectpainter_qws.h> | 52 | # include <qdirectpainter_qws.h> |
53 | # include <qgfxraster_qws.h> | 53 | # include <qgfxraster_qws.h> |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | 56 | ||
57 | extern MediaPlayerState *mediaPlayerState; | 57 | extern MediaPlayerState *mediaPlayerState; |
58 | extern PlayListWidget *playList; | 58 | extern PlayListWidget *playList; |
59 | 59 | ||
60 | 60 | ||
61 | static const int xo = 2; // movable x offset | 61 | static const int xo = 2; // movable x offset |
62 | static const int yo = 0; // movable y offset | 62 | static const int yo = 0; // movable y offset |
63 | 63 | ||
64 | 64 | ||
65 | struct MediaButton { | 65 | struct MediaButton { |
66 | bool isToggle, isHeld, isDown; | 66 | bool isToggle, isHeld, isDown; |
67 | }; | 67 | }; |
68 | 68 | ||
69 | MediaButton videoButtons[] = { | 69 | MediaButton videoButtons[] = { |
70 | { FALSE, FALSE, FALSE }, // stop | 70 | { FALSE, FALSE, FALSE }, // stop |
71 | { TRUE, FALSE, FALSE }, // play | 71 | { TRUE, FALSE, FALSE }, // play |
72 | { FALSE, FALSE, FALSE }, // previous | 72 | { FALSE, FALSE, FALSE }, // previous |
73 | { FALSE, FALSE, FALSE }, // next | 73 | { FALSE, FALSE, FALSE }, // next |
74 | { FALSE, FALSE, FALSE }, // volUp | 74 | { FALSE, FALSE, FALSE }, // volUp |
75 | { FALSE, FALSE, FALSE }, // volDown | 75 | { FALSE, FALSE, FALSE }, // volDown |
76 | { TRUE, FALSE, FALSE } // fullscreen | 76 | { TRUE, FALSE, FALSE } // fullscreen |
77 | }; | 77 | }; |
78 | 78 | ||
79 | const char *skinV_mask_file_names[7] = { | 79 | const char *skinV_mask_file_names[7] = { |
80 | "stop","play","back","fwd","up","down","full" | 80 | "stop","play","back","fwd","up","down","full" |
81 | }; | 81 | }; |
82 | 82 | ||
83 | static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); | 83 | static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); |
84 | 84 | ||
85 | 85 | ||
86 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : | 86 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : |
87 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { | 87 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { |
88 | 88 | ||
89 | 89 | ||
90 | setCaption( tr("OpiePlayer - Video") ); | 90 | setCaption( tr("OpiePlayer - Video") ); |
91 | 91 | ||
92 | videoFrame = new XineVideoWidget ( this, "Video frame" ); | 92 | videoFrame = new XineVideoWidget ( this, "Video frame" ); |
93 | 93 | ||
94 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); | 94 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); |
95 | connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); | 95 | connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); |
96 | 96 | ||
97 | Config cfg("OpiePlayer"); | 97 | Config cfg("OpiePlayer"); |
98 | cfg.setGroup("Options"); | 98 | cfg.setGroup("Options"); |
99 | skin = cfg.readEntry("Skin","default"); | 99 | skin = cfg.readEntry("Skin","default"); |
100 | 100 | ||
101 | QString skinPath = "opieplayer2/skins/" + skin; | 101 | QString skinPath = "opieplayer2/skins/" + skin; |
102 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 102 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
103 | imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); | 103 | imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); |
104 | imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); | 104 | imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); |
105 | 105 | ||
106 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); | 106 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); |
107 | imgButtonMask->fill( 0 ); | 107 | imgButtonMask->fill( 0 ); |
108 | 108 | ||
109 | for ( int i = 0; i < 7; i++ ) { | 109 | for ( int i = 0; i < 7; i++ ) { |
110 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); | 110 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); |
111 | masks[i] = new QBitmap( filename ); | 111 | masks[i] = new QBitmap( filename ); |
112 | 112 | ||
113 | if ( !masks[i]->isNull() ) { | 113 | if ( !masks[i]->isNull() ) { |
114 | QImage imgMask = masks[i]->convertToImage(); | 114 | QImage imgMask = masks[i]->convertToImage(); |
115 | uchar **dest = imgButtonMask->jumpTable(); | 115 | uchar **dest = imgButtonMask->jumpTable(); |
116 | for ( int y = 0; y < imgUp->height(); y++ ) { | 116 | for ( int y = 0; y < imgUp->height(); y++ ) { |
117 | uchar *line = dest[y]; | 117 | uchar *line = dest[y]; |
118 | for ( int x = 0; x < imgUp->width(); x++ ) { | 118 | for ( int x = 0; x < imgUp->width(); x++ ) { |
119 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 119 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
120 | line[x] = i + 1; | 120 | line[x] = i + 1; |
121 | } | 121 | } |
122 | } | 122 | } |
123 | } | 123 | } |
124 | } | 124 | } |
125 | 125 | ||
126 | for ( int i = 0; i < 7; i++ ) { | 126 | for ( int i = 0; i < 7; i++ ) { |
127 | buttonPixUp[i] = NULL; | 127 | buttonPixUp[i] = NULL; |
128 | buttonPixDown[i] = NULL; | 128 | buttonPixDown[i] = NULL; |
129 | } | 129 | } |
130 | 130 | ||
131 | setBackgroundPixmap( *pixBg ); | 131 | setBackgroundPixmap( *pixBg ); |
132 | 132 | ||
133 | slider = new QSlider( Qt::Horizontal, this ); | 133 | slider = new QSlider( Qt::Horizontal, this ); |
134 | slider->setMinValue( 0 ); | 134 | slider->setMinValue( 0 ); |
135 | slider->setMaxValue( 1 ); | 135 | slider->setMaxValue( 1 ); |
136 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); | 136 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); |
137 | slider->setFocusPolicy( QWidget::NoFocus ); | 137 | slider->setFocusPolicy( QWidget::NoFocus ); |
138 | 138 | ||
139 | resizeEvent( NULL ); | 139 | resizeEvent( NULL ); |
140 | 140 | ||
141 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 141 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
142 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 142 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
143 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 143 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
144 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 144 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
145 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 145 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
146 | 146 | ||
147 | setLength( mediaPlayerState->length() ); | 147 | setLength( mediaPlayerState->length() ); |
148 | setPosition( mediaPlayerState->position() ); | 148 | setPosition( mediaPlayerState->position() ); |
149 | setFullscreen( mediaPlayerState->fullscreen() ); | 149 | setFullscreen( mediaPlayerState->fullscreen() ); |
150 | setPlaying( mediaPlayerState->playing() ); | 150 | setPlaying( mediaPlayerState->playing() ); |
151 | } | 151 | } |
152 | 152 | ||
153 | 153 | ||
154 | VideoWidget::~VideoWidget() { | 154 | VideoWidget::~VideoWidget() { |
155 | 155 | ||
156 | for ( int i = 0; i < 7; i++ ) { | 156 | for ( int i = 0; i < 7; i++ ) { |
157 | delete buttonPixUp[i]; | 157 | delete buttonPixUp[i]; |
158 | delete buttonPixDown[i]; | 158 | delete buttonPixDown[i]; |
159 | } | 159 | } |
160 | 160 | ||
161 | delete pixBg; | 161 | delete pixBg; |
162 | delete imgUp; | 162 | delete imgUp; |
163 | delete imgDn; | 163 | delete imgDn; |
164 | delete imgButtonMask; | 164 | delete imgButtonMask; |
165 | for ( int i = 0; i < 7; i++ ) { | 165 | for ( int i = 0; i < 7; i++ ) { |
166 | delete masks[i]; | 166 | delete masks[i]; |
167 | } | 167 | } |
168 | 168 | ||
169 | } | 169 | } |
170 | 170 | ||
171 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 171 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
172 | QPixmap pix( img.width(), img.height() ); | 172 | QPixmap pix( img.width(), img.height() ); |
173 | QPainter p( &pix ); | 173 | QPainter p( &pix ); |
174 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 174 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
175 | p.drawImage( 0, 0, img ); | 175 | p.drawImage( 0, 0, img ); |
176 | return new QPixmap( pix ); | 176 | return new QPixmap( pix ); |
177 | } | 177 | } |
178 | 178 | ||
179 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { | 179 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { |
180 | QPixmap *pixmap = new QPixmap( pix ); | 180 | QPixmap *pixmap = new QPixmap( pix ); |
181 | pixmap->setMask( mask ); | 181 | pixmap->setMask( mask ); |
182 | return pixmap; | 182 | return pixmap; |
183 | } | 183 | } |
184 | 184 | ||
185 | void VideoWidget::resizeEvent( QResizeEvent * ) { | 185 | void VideoWidget::resizeEvent( QResizeEvent * ) { |
186 | int h = height(); | 186 | int h = height(); |
187 | int w = width(); | 187 | int w = width(); |
188 | //int Vh = 160; | 188 | //int Vh = 160; |
189 | //int Vw = 220; | 189 | //int Vw = 220; |
190 | 190 | ||
191 | slider->setFixedWidth( w - 20 ); | 191 | slider->setFixedWidth( w - 20 ); |
192 | slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); | 192 | slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); |
193 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); | 193 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); |
194 | slider->setFocusPolicy( QWidget::NoFocus ); | 194 | slider->setFocusPolicy( QWidget::NoFocus ); |
195 | slider->setBackgroundPixmap( *pixBg ); | 195 | slider->setBackgroundPixmap( *pixBg ); |
196 | 196 | ||
197 | xoff = 0;// ( imgUp->width() ) / 2; | 197 | xoff = 0;// ( imgUp->width() ) / 2; |
198 | if(w>h) | 198 | if(w>h) |
199 | yoff = 0; | 199 | yoff = 0; |
200 | else | 200 | else |
201 | yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; | 201 | yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; |
202 | QPoint p( xoff, yoff ); | 202 | QPoint p( xoff, yoff ); |
203 | 203 | ||
204 | QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); | 204 | QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); |
205 | QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); | 205 | QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); |
206 | 206 | ||
207 | for ( int i = 0; i < 7; i++ ) { | 207 | for ( int i = 0; i < 7; i++ ) { |
208 | if ( !masks[i]->isNull() ) { | 208 | if ( !masks[i]->isNull() ) { |
209 | delete buttonPixUp[i]; | 209 | delete buttonPixUp[i]; |
210 | delete buttonPixDown[i]; | 210 | delete buttonPixDown[i]; |
211 | buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); | 211 | buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); |
212 | buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); | 212 | buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); |
213 | } | 213 | } |
214 | } | 214 | } |
215 | 215 | ||
216 | delete pixUp; | 216 | delete pixUp; |
217 | delete pixDn; | 217 | delete pixDn; |
218 | } | 218 | } |
219 | 219 | ||
220 | static bool videoSliderBeingMoved = FALSE; | 220 | static bool videoSliderBeingMoved = FALSE; |
221 | 221 | ||
222 | void VideoWidget::sliderPressed() { | 222 | void VideoWidget::sliderPressed() { |
223 | videoSliderBeingMoved = TRUE; | 223 | videoSliderBeingMoved = TRUE; |
224 | } | 224 | } |
225 | 225 | ||
226 | void VideoWidget::sliderReleased() { | 226 | void VideoWidget::sliderReleased() { |
227 | videoSliderBeingMoved = FALSE; | 227 | videoSliderBeingMoved = FALSE; |
228 | if ( slider->width() == 0 ) { | 228 | if ( slider->width() == 0 ) { |
229 | return; | 229 | return; |
230 | } | 230 | } |
231 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); | 231 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); |
232 | mediaPlayerState->setPosition( val ); | 232 | mediaPlayerState->setPosition( val ); |
233 | } | 233 | } |
234 | 234 | ||
235 | void VideoWidget::setPosition( long i ) { | 235 | void VideoWidget::setPosition( long i ) { |
236 | updateSlider( i, mediaPlayerState->length() ); | 236 | updateSlider( i, mediaPlayerState->length() ); |
237 | } | 237 | } |
238 | 238 | ||
239 | 239 | ||
240 | void VideoWidget::setLength( long max ) { | 240 | void VideoWidget::setLength( long max ) { |
241 | updateSlider( mediaPlayerState->position(), max ); | 241 | updateSlider( mediaPlayerState->position(), max ); |
242 | } | 242 | } |
243 | 243 | ||
244 | void VideoWidget::setView( char view ) { | 244 | void VideoWidget::setView( char view ) { |
245 | 245 | ||
246 | if ( view == 'v' ) { | 246 | if ( view == 'v' ) { |
247 | makeVisible(); | 247 | makeVisible(); |
248 | } else { | 248 | } else { |
249 | // Effectively blank the view next time we show it so it looks nicer | 249 | // Effectively blank the view next time we show it so it looks nicer |
250 | scaledWidth = 0; | 250 | scaledWidth = 0; |
251 | scaledHeight = 0; | 251 | scaledHeight = 0; |
252 | hide(); | 252 | hide(); |
253 | } | 253 | } |
254 | } | 254 | } |
255 | 255 | ||
256 | void VideoWidget::updateSlider( long i, long max ) { | 256 | void VideoWidget::updateSlider( long i, long max ) { |
257 | // Will flicker too much if we don't do this | 257 | // Will flicker too much if we don't do this |
258 | if ( max == 0 ) { | 258 | if ( max == 0 ) { |
259 | return; | 259 | return; |
260 | } | 260 | } |
261 | int width = slider->width(); | 261 | int width = slider->width(); |
262 | int val = int((double)i * width / max); | 262 | int val = int((double)i * width / max); |
263 | if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { | 263 | if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { |
264 | if ( slider->value() != val ) { | 264 | if ( slider->value() != val ) { |
265 | slider->setValue( val ); | 265 | slider->setValue( val ); |
266 | } | 266 | } |
267 | if ( slider->maxValue() != width ) { | 267 | if ( slider->maxValue() != width ) { |
268 | slider->setMaxValue( width ); | 268 | slider->setMaxValue( width ); |
269 | } | 269 | } |
270 | } | 270 | } |
271 | } | 271 | } |
272 | 272 | ||
273 | void VideoWidget::setToggleButton( int i, bool down ) { | 273 | void VideoWidget::setToggleButton( int i, bool down ) { |
274 | if ( down != videoButtons[i].isDown ) { | 274 | if ( down != videoButtons[i].isDown ) { |
275 | toggleButton( i ); | 275 | toggleButton( i ); |
276 | } | 276 | } |
277 | } | 277 | } |
278 | 278 | ||
279 | void VideoWidget::toggleButton( int i ) { | 279 | void VideoWidget::toggleButton( int i ) { |
280 | videoButtons[i].isDown = !videoButtons[i].isDown; | 280 | videoButtons[i].isDown = !videoButtons[i].isDown; |
281 | QPainter p(this); | 281 | QPainter p(this); |
282 | paintButton ( &p, i ); | 282 | paintButton ( &p, i ); |
283 | } | 283 | } |
284 | 284 | ||
285 | void VideoWidget::paintButton( QPainter *p, int i ) { | 285 | void VideoWidget::paintButton( QPainter *p, int i ) { |
286 | 286 | ||
287 | if ( videoButtons[i].isDown ) { | 287 | if ( videoButtons[i].isDown ) { |
288 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | 288 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); |
289 | } else { | 289 | } else { |
290 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | 290 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); |
291 | } | 291 | } |
292 | } | 292 | } |
293 | 293 | ||
294 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 294 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
295 | for ( int i = 0; i < numVButtons; i++ ) { | 295 | for ( int i = 0; i < numVButtons; i++ ) { |
296 | if ( event->state() == QMouseEvent::LeftButton ) { | 296 | if ( event->state() == QMouseEvent::LeftButton ) { |
297 | // The test to see if the mouse click is inside the button or not | 297 | // The test to see if the mouse click is inside the button or not |
298 | int x = event->pos().x() - xoff; | 298 | int x = event->pos().x() - xoff; |
299 | int y = event->pos().y() - yoff; | 299 | int y = event->pos().y() - yoff; |
300 | 300 | ||
301 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() | 301 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() |
302 | && y < imgButtonMask->height() | 302 | && y < imgButtonMask->height() |
303 | && imgButtonMask->pixelIndex( x, y ) == i + 1 ); | 303 | && imgButtonMask->pixelIndex( x, y ) == i + 1 ); |
304 | 304 | ||
305 | if ( isOnButton && !videoButtons[i].isHeld ) { | 305 | if ( isOnButton && !videoButtons[i].isHeld ) { |
306 | videoButtons[i].isHeld = TRUE; | 306 | videoButtons[i].isHeld = TRUE; |
307 | toggleButton(i); | 307 | toggleButton(i); |
308 | 308 | ||
309 | switch (i) { | 309 | switch (i) { |
310 | case VideoVolUp: | 310 | case VideoVolUp: |
311 | emit moreClicked(); | 311 | emit moreClicked(); |
312 | return; | 312 | return; |
313 | case VideoVolDown: | 313 | case VideoVolDown: |
314 | emit lessClicked(); | 314 | emit lessClicked(); |
315 | return; | 315 | return; |
316 | } | 316 | } |
317 | } else if ( !isOnButton && videoButtons[i].isHeld ) { | 317 | } else if ( !isOnButton && videoButtons[i].isHeld ) { |
318 | videoButtons[i].isHeld = FALSE; | 318 | videoButtons[i].isHeld = FALSE; |
319 | toggleButton(i); | 319 | toggleButton(i); |
320 | } | 320 | } |
321 | } else { | 321 | } else { |
322 | 322 | ||
323 | if ( videoButtons[i].isHeld ) { | 323 | if ( videoButtons[i].isHeld ) { |
324 | videoButtons[i].isHeld = FALSE; | 324 | videoButtons[i].isHeld = FALSE; |
325 | if ( !videoButtons[i].isToggle ) { | 325 | if ( !videoButtons[i].isToggle ) { |
326 | setToggleButton( i, FALSE ); | 326 | setToggleButton( i, FALSE ); |
327 | } | 327 | } |
328 | 328 | ||
329 | switch(i) { | 329 | switch(i) { |
330 | 330 | ||
331 | case VideoPlay: { | 331 | case VideoPlay: { |
332 | if( mediaPlayerState->isPaused ) { | 332 | if( mediaPlayerState->isPaused ) { |
333 | setToggleButton( i, FALSE ); | 333 | setToggleButton( i, FALSE ); |
334 | mediaPlayerState->setPaused( FALSE ); | 334 | mediaPlayerState->setPaused( FALSE ); |
335 | return; | 335 | return; |
336 | } else if( !mediaPlayerState->isPaused ) { | 336 | } else if( !mediaPlayerState->isPaused ) { |
337 | setToggleButton( i, TRUE ); | 337 | setToggleButton( i, TRUE ); |
338 | mediaPlayerState->setPaused( TRUE ); | 338 | mediaPlayerState->setPaused( TRUE ); |
339 | return; | 339 | return; |
340 | } else { | 340 | } else { |
341 | return; | 341 | return; |
342 | } | 342 | } |
343 | } | 343 | } |
344 | 344 | ||
345 | case VideoStop: mediaPlayerState->setPlaying( FALSE ); return; | 345 | case VideoStop: mediaPlayerState->setPlaying( FALSE ); return; |
346 | case VideoNext: if(playList->whichList() ==0) mediaPlayerState->setNext(); return; | 346 | case VideoNext: if(playList->whichList() ==0) mediaPlayerState->setNext(); return; |
347 | case VideoPrevious: if(playList->whichList() ==0) mediaPlayerState->setPrev(); return; | 347 | case VideoPrevious: if(playList->whichList() ==0) mediaPlayerState->setPrev(); return; |
348 | case VideoVolUp: emit moreReleased(); return; | 348 | case VideoVolUp: emit moreReleased(); return; |
349 | case VideoVolDown: emit lessReleased(); return; | 349 | case VideoVolDown: emit lessReleased(); return; |
350 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | 350 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; |
351 | } | 351 | } |
352 | } | 352 | } |
353 | } | 353 | } |
354 | } | 354 | } |
355 | } | 355 | } |
356 | 356 | ||
357 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { | 357 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { |
358 | mouseMoveEvent( event ); | 358 | mouseMoveEvent( event ); |
359 | } | 359 | } |
360 | 360 | ||
361 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 361 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
362 | if ( mediaPlayerState->fullscreen() ) { | 362 | if ( mediaPlayerState->fullscreen() ) { |
363 | mediaPlayerState->setFullscreen( FALSE ); | 363 | mediaPlayerState->setFullscreen( FALSE ); |
364 | makeVisible(); | 364 | makeVisible(); |
365 | } | 365 | } |
366 | mouseMoveEvent( event ); | 366 | mouseMoveEvent( event ); |
367 | } | 367 | } |
368 | 368 | ||
369 | void VideoWidget::showEvent( QShowEvent* ) { | 369 | void VideoWidget::showEvent( QShowEvent* ) { |
370 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 370 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
371 | mouseMoveEvent( &event ); | 371 | mouseMoveEvent( &event ); |
372 | } | 372 | } |
373 | 373 | ||
374 | 374 | ||
375 | void VideoWidget::backToNormal() { | 375 | void VideoWidget::backToNormal() { |
376 | mediaPlayerState->setFullscreen( FALSE ); | 376 | mediaPlayerState->setFullscreen( FALSE ); |
377 | makeVisible(); | 377 | makeVisible(); |
378 | } | 378 | } |
379 | 379 | ||
380 | void VideoWidget::makeVisible() { | 380 | void VideoWidget::makeVisible() { |
381 | if ( mediaPlayerState->fullscreen() ) { | 381 | if ( mediaPlayerState->fullscreen() ) { |
382 | setBackgroundMode( QWidget::NoBackground ); | 382 | setBackgroundMode( QWidget::NoBackground ); |
383 | showFullScreen(); | 383 | showFullScreen(); |
384 | resize( qApp->desktop()->size() ); | 384 | resize( qApp->desktop()->size() ); |
385 | slider->hide(); | 385 | slider->hide(); |
386 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); | 386 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); |
387 | qApp->processEvents(); | 387 | // qApp->processEvents(); |
388 | } else { | 388 | } else { |
389 | showNormal(); | 389 | showNormal(); |
390 | showMaximized(); | 390 | showMaximized(); |
391 | setBackgroundPixmap( *pixBg ); | 391 | setBackgroundPixmap( *pixBg ); |
392 | if ( mediaPlayerState->streaming() ) { | 392 | if ( mediaPlayerState->streaming() ) { |
393 | slider->hide(); | 393 | slider->hide(); |
394 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 394 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
395 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 395 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
396 | } else { | 396 | } else { |
397 | slider->show(); | 397 | slider->show(); |
398 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 398 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
399 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 399 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
400 | } | 400 | } |
401 | |||
402 | QWidget *d = QApplication::desktop(); | 401 | QWidget *d = QApplication::desktop(); |
403 | int w=d->width(); | 402 | int w=d->width(); |
404 | int h=d->height(); | 403 | int h=d->height(); |
405 | 404 | ||
406 | if(w>h) { | 405 | if(w>h) { |
407 | int newW=(w/2)-(246/2); //this will only work with 320x240 | 406 | int newW=(w/2)-(246/2); //this will only work with 320x240 |
408 | videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); | 407 | videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); |
409 | } else | 408 | } else |
410 | videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); | 409 | videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); |
411 | 410 | ||
412 | qApp->processEvents(); | 411 | // qApp->processEvents(); |
413 | } | 412 | } |
414 | } | 413 | } |
415 | 414 | ||
416 | 415 | ||
417 | void VideoWidget::paintEvent( QPaintEvent * pe) { | 416 | void VideoWidget::paintEvent( QPaintEvent * pe) { |
418 | QPainter p( this ); | 417 | QPainter p( this ); |
419 | 418 | ||
420 | if ( mediaPlayerState->fullscreen() ) { | 419 | if ( mediaPlayerState->fullscreen() ) { |
421 | // Clear the background | 420 | // Clear the background |
422 | p.setBrush( QBrush( Qt::black ) ); | 421 | p.setBrush( QBrush( Qt::black ) ); |
423 | } else { | 422 | } else { |
424 | if ( !pe->erased() ) { | 423 | if ( !pe->erased() ) { |
425 | // Combine with background and double buffer | 424 | // Combine with background and double buffer |
426 | QPixmap pix( pe->rect().size() ); | 425 | QPixmap pix( pe->rect().size() ); |
427 | QPainter p( &pix ); | 426 | QPainter p( &pix ); |
428 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 427 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
429 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); | 428 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); |
430 | for ( int i = 0; i < numVButtons; i++ ) { | 429 | for ( int i = 0; i < numVButtons; i++ ) { |
431 | paintButton( &p, i ); | 430 | paintButton( &p, i ); |
432 | } | 431 | } |
433 | QPainter p2( this ); | 432 | QPainter p2( this ); |
434 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 433 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
435 | } else { | 434 | } else { |
436 | QPainter p( this ); | 435 | QPainter p( this ); |
437 | for ( int i = 0; i < numVButtons; i++ ) | 436 | for ( int i = 0; i < numVButtons; i++ ) |
438 | paintButton( &p, i ); | 437 | paintButton( &p, i ); |
439 | } | 438 | } |
440 | slider->repaint( TRUE ); | 439 | slider->repaint( TRUE ); |
441 | } | 440 | } |
442 | } | 441 | } |
443 | 442 | ||
444 | 443 | ||
445 | void VideoWidget::closeEvent( QCloseEvent* ) { | 444 | void VideoWidget::closeEvent( QCloseEvent* ) { |
446 | mediaPlayerState->setList(); | 445 | mediaPlayerState->setList(); |
447 | } | 446 | } |
448 | 447 | ||
449 | 448 | ||
450 | 449 | ||
451 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { | 450 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { |
452 | switch ( e->key() ) { | 451 | switch ( e->key() ) { |
453 | ////////////////////////////// Zaurus keys | 452 | ////////////////////////////// Zaurus keys |
454 | case Key_Home: | 453 | case Key_Home: |
455 | break; | 454 | break; |
456 | case Key_F9: //activity | 455 | case Key_F9: //activity |
457 | break; | 456 | break; |
458 | case Key_F10: //contacts | 457 | case Key_F10: //contacts |
459 | // hide(); | 458 | // hide(); |
460 | break; | 459 | break; |
461 | case Key_F11: //menu | 460 | case Key_F11: //menu |
462 | break; | 461 | break; |
463 | case Key_F12: //home | 462 | case Key_F12: //home |
464 | break; | 463 | break; |
465 | case Key_F13: //mail | 464 | case Key_F13: //mail |
466 | break; | 465 | break; |
467 | case Key_Space: { | 466 | case Key_Space: { |
468 | if(mediaPlayerState->playing()) { | 467 | if(mediaPlayerState->playing()) { |
469 | mediaPlayerState->setPlaying(FALSE); | 468 | mediaPlayerState->setPlaying(FALSE); |
470 | } else { | 469 | } else { |
471 | mediaPlayerState->setPlaying(TRUE); | 470 | mediaPlayerState->setPlaying(TRUE); |
472 | } | 471 | } |
473 | } | 472 | } |
474 | break; | 473 | break; |
475 | case Key_Down: | 474 | case Key_Down: |
476 | // toggleButton(6); | 475 | // toggleButton(6); |
477 | emit lessClicked(); | 476 | emit lessClicked(); |
478 | emit lessReleased(); | 477 | emit lessReleased(); |
479 | // toggleButton(6); | 478 | // toggleButton(6); |
480 | break; | 479 | break; |
481 | case Key_Up: | 480 | case Key_Up: |
482 | // toggleButton(5); | 481 | // toggleButton(5); |
483 | emit moreClicked(); | 482 | emit moreClicked(); |
484 | emit moreReleased(); | 483 | emit moreReleased(); |
485 | // toggleButton(5); | 484 | // toggleButton(5); |
486 | break; | 485 | break; |
487 | case Key_Right: | 486 | case Key_Right: |
488 | mediaPlayerState->setNext(); | 487 | mediaPlayerState->setNext(); |
489 | break; | 488 | break; |
490 | case Key_Left: | 489 | case Key_Left: |
491 | mediaPlayerState->setPrev(); | 490 | mediaPlayerState->setPrev(); |
492 | break; | 491 | break; |
493 | case Key_Escape: | 492 | case Key_Escape: |
494 | break; | 493 | break; |
495 | 494 | ||
496 | }; | 495 | }; |
497 | } | 496 | } |
498 | 497 | ||
499 | XineVideoWidget* VideoWidget::vidWidget() { | 498 | XineVideoWidget* VideoWidget::vidWidget() { |
500 | return videoFrame; | 499 | return videoFrame; |
501 | } | 500 | } |
502 | 501 | ||
503 | 502 | ||
504 | void VideoWidget::setFullscreen ( bool b ) { | 503 | void VideoWidget::setFullscreen ( bool b ) { |
505 | setToggleButton( VideoFullscreen, b ); | 504 | setToggleButton( VideoFullscreen, b ); |
506 | } | 505 | } |
507 | 506 | ||
508 | 507 | ||
509 | void VideoWidget::setPlaying( bool b) { | 508 | void VideoWidget::setPlaying( bool b) { |
510 | setToggleButton( VideoPlay, b ); | 509 | setToggleButton( VideoPlay, b ); |
511 | } | 510 | } |
512 | 511 | ||
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp index 0137ae5..fabc9a5 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.cpp +++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp | |||
@@ -1,199 +1,200 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; General Public License for more | 22 | ..}^=.= = ; General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = General Public License along with | 26 | -_. . . )=. = General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | 34 | ||
35 | #include <qtimer.h> | 35 | #include <qtimer.h> |
36 | #include <qpe/qcopenvelope_qws.h> | 36 | #include <qpe/qcopenvelope_qws.h> |
37 | #include <qpe/qpeapplication.h> | 37 | #include <qpe/qpeapplication.h> |
38 | #include "xinecontrol.h" | 38 | #include "xinecontrol.h" |
39 | #include "mediaplayerstate.h" | 39 | #include "mediaplayerstate.h" |
40 | #include "videowidget.h" | 40 | #include "videowidget.h" |
41 | 41 | ||
42 | extern MediaPlayerState *mediaPlayerState; | 42 | extern MediaPlayerState *mediaPlayerState; |
43 | extern VideoWidget *videoUI; | 43 | extern VideoWidget *videoUI; |
44 | XineControl::XineControl( QObject *parent, const char *name ) | 44 | XineControl::XineControl( QObject *parent, const char *name ) |
45 | : QObject( parent, name ) { | 45 | : QObject( parent, name ) { |
46 | libXine = new XINE::Lib(videoUI->vidWidget() ); | 46 | libXine = new XINE::Lib(videoUI->vidWidget() ); |
47 | 47 | ||
48 | connect ( videoUI, SIGNAL( videoResized ( const QSize & )), this, SLOT( videoResized ( const QSize & ))); | 48 | connect ( videoUI, SIGNAL( videoResized ( const QSize & )), this, SLOT( videoResized ( const QSize & ))); |
49 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); | 49 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); |
50 | connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) ); | 50 | connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) ); |
51 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); | 51 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); |
52 | connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); | 52 | connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); |
53 | connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); | 53 | connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); |
54 | connect( mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) ); | 54 | connect( mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) ); |
55 | connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); | 55 | connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); |
56 | 56 | ||
57 | disabledSuspendScreenSaver = FALSE; | 57 | disabledSuspendScreenSaver = FALSE; |
58 | } | 58 | } |
59 | 59 | ||
60 | XineControl::~XineControl() { | 60 | XineControl::~XineControl() { |
61 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 61 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
62 | if ( disabledSuspendScreenSaver ) { | 62 | if ( disabledSuspendScreenSaver ) { |
63 | disabledSuspendScreenSaver = FALSE; | 63 | disabledSuspendScreenSaver = FALSE; |
64 | // Re-enable the suspend mode | 64 | // Re-enable the suspend mode |
65 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 65 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
66 | } | 66 | } |
67 | #endif | 67 | #endif |
68 | delete libXine; | 68 | delete libXine; |
69 | } | 69 | } |
70 | 70 | ||
71 | void XineControl::play( const QString& fileName ) { | 71 | void XineControl::play( const QString& fileName ) { |
72 | hasVideoChannel=FALSE; | 72 | hasVideoChannel=FALSE; |
73 | hasAudioChannel=FALSE; | 73 | hasAudioChannel=FALSE; |
74 | m_fileName = fileName; | 74 | m_fileName = fileName; |
75 | 75 | ||
76 | //qDebug("<<FILENAME: " + fileName + ">>>>"); | 76 | //qDebug("<<FILENAME: " + fileName + ">>>>"); |
77 | 77 | ||
78 | libXine->play( fileName ); | 78 | libXine->play( fileName ); |
79 | mediaPlayerState->setPlaying( true ); | 79 | mediaPlayerState->setPlaying( true ); |
80 | char whichGui = mdetect.videoOrAudio( fileName ); | 80 | char whichGui = mdetect.videoOrAudio( fileName ); |
81 | if (whichGui == 'f') { | 81 | if (whichGui == 'f') { |
82 | qDebug("Nicht erkannter Dateityp"); | 82 | qDebug("Nicht erkannter Dateityp"); |
83 | return; | 83 | return; |
84 | } | 84 | } |
85 | if (whichGui == 'a') { | 85 | if (whichGui == 'a') { |
86 | libXine->setShowVideo( false ); | 86 | libXine->setShowVideo( false ); |
87 | hasAudioChannel=TRUE; | 87 | hasAudioChannel=TRUE; |
88 | } else { | 88 | } else { |
89 | libXine->setShowVideo( true ); | 89 | libXine->setShowVideo( true ); |
90 | hasVideoChannel=TRUE; | 90 | hasVideoChannel=TRUE; |
91 | } | 91 | } |
92 | // determine if slider is shown | 92 | // determine if slider is shown |
93 | mediaPlayerState->setIsStreaming( !libXine->isSeekable() ); | 93 | mediaPlayerState->setIsStreaming( !libXine->isSeekable() ); |
94 | // which gui (video / audio) | 94 | // which gui (video / audio) |
95 | mediaPlayerState->setView( whichGui ); | 95 | mediaPlayerState->setView( whichGui ); |
96 | 96 | ||
97 | |||
97 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 98 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
98 | if ( !disabledSuspendScreenSaver ) { | 99 | if ( !disabledSuspendScreenSaver ) { |
99 | disabledSuspendScreenSaver = TRUE; | 100 | disabledSuspendScreenSaver = TRUE; |
100 | // Stop the screen from blanking and power saving state | 101 | // Stop the screen from blanking and power saving state |
101 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) | 102 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) |
102 | << ( whichGui == 'v' ? QPEApplication::Disable : QPEApplication::DisableSuspend ); | 103 | << ( whichGui == 'v' ? QPEApplication::Disable : QPEApplication::DisableSuspend ); |
103 | } | 104 | } |
104 | #endif | 105 | #endif |
105 | 106 | ||
106 | length(); | 107 | length(); |
107 | position(); | 108 | position(); |
108 | } | 109 | } |
109 | 110 | ||
110 | void XineControl::nextMedia() { | 111 | void XineControl::nextMedia() { |
111 | mediaPlayerState->setNext(); | 112 | mediaPlayerState->setNext(); |
112 | } | 113 | } |
113 | 114 | ||
114 | void XineControl::setGamma( int value ) { | 115 | void XineControl::setGamma( int value ) { |
115 | libXine->setGamma( value ); | 116 | libXine->setGamma( value ); |
116 | } | 117 | } |
117 | 118 | ||
118 | void XineControl::stop( bool isSet ) { | 119 | void XineControl::stop( bool isSet ) { |
119 | if ( !isSet) { | 120 | if ( !isSet) { |
120 | libXine->stop( ); | 121 | libXine->stop( ); |
121 | 122 | ||
122 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 123 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
123 | if ( disabledSuspendScreenSaver ) { | 124 | if ( disabledSuspendScreenSaver ) { |
124 | disabledSuspendScreenSaver = FALSE; | 125 | disabledSuspendScreenSaver = FALSE; |
125 | // Re-enable the suspend mode | 126 | // Re-enable the suspend mode |
126 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 127 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
127 | } | 128 | } |
128 | #endif | 129 | #endif |
129 | 130 | ||
130 | } | 131 | } |
131 | } | 132 | } |
132 | 133 | ||
133 | /** | 134 | /** |
134 | * Pause playback | 135 | * Pause playback |
135 | * @isSet | 136 | * @isSet |
136 | */ | 137 | */ |
137 | void XineControl::pause( bool isSet) { | 138 | void XineControl::pause( bool isSet) { |
138 | if (isSet) { | 139 | if (isSet) { |
139 | libXine->pause(); | 140 | libXine->pause(); |
140 | } else { | 141 | } else { |
141 | libXine->play( m_fileName, 0, m_currentTime); | 142 | libXine->play( m_fileName, 0, m_currentTime); |
142 | } | 143 | } |
143 | } | 144 | } |
144 | 145 | ||
145 | 146 | ||
146 | /** | 147 | /** |
147 | * get current time in playback | 148 | * get current time in playback |
148 | */ | 149 | */ |
149 | long XineControl::currentTime() { | 150 | long XineControl::currentTime() { |
150 | // todo: jede sekunde überprüfen | 151 | // todo: jede sekunde überprüfen |
151 | m_currentTime = libXine->currentTime(); | 152 | m_currentTime = libXine->currentTime(); |
152 | return m_currentTime; | 153 | return m_currentTime; |
153 | QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); | 154 | QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); |
154 | } | 155 | } |
155 | 156 | ||
156 | /** | 157 | /** |
157 | * Set the length of the media file | 158 | * Set the length of the media file |
158 | */ | 159 | */ |
159 | void XineControl::length() { | 160 | void XineControl::length() { |
160 | m_length = libXine->length(); | 161 | m_length = libXine->length(); |
161 | mediaPlayerState->setLength( m_length ); | 162 | mediaPlayerState->setLength( m_length ); |
162 | } | 163 | } |
163 | 164 | ||
164 | 165 | ||
165 | /** | 166 | /** |
166 | * Reports the position the xine backend is at right now | 167 | * Reports the position the xine backend is at right now |
167 | * @return long the postion in seconds | 168 | * @return long the postion in seconds |
168 | */ | 169 | */ |
169 | long XineControl::position() { | 170 | long XineControl::position() { |
170 | m_position = ( currentTime() ); | 171 | m_position = ( currentTime() ); |
171 | mediaPlayerState->updatePosition( m_position ); | 172 | mediaPlayerState->updatePosition( m_position ); |
172 | long emitPos = (long)m_position; | 173 | long emitPos = (long)m_position; |
173 | emit positionChanged( emitPos ); | 174 | emit positionChanged( emitPos ); |
174 | if(mediaPlayerState->isPlaying) | 175 | if(mediaPlayerState->isPlaying) |
175 | // needs to be stopped the media is stopped | 176 | // needs to be stopped the media is stopped |
176 | QTimer::singleShot( 1000, this, SLOT( position() ) ); | 177 | QTimer::singleShot( 1000, this, SLOT( position() ) ); |
177 | // qDebug("POSITION : %d", m_position); | 178 | // qDebug("POSITION : %d", m_position); |
178 | return m_position; | 179 | return m_position; |
179 | } | 180 | } |
180 | 181 | ||
181 | /** | 182 | /** |
182 | * Set videoplayback to fullscreen | 183 | * Set videoplayback to fullscreen |
183 | * @param isSet | 184 | * @param isSet |
184 | */ | 185 | */ |
185 | void XineControl::setFullscreen( bool isSet ) { | 186 | void XineControl::setFullscreen( bool isSet ) { |
186 | libXine->showVideoFullScreen( isSet); | 187 | libXine->showVideoFullScreen( isSet); |
187 | } | 188 | } |
188 | 189 | ||
189 | /** | 190 | /** |
190 | * Seek to a position in the track | 191 | * Seek to a position in the track |
191 | * @param second the second to jump to | 192 | * @param second the second to jump to |
192 | */ | 193 | */ |
193 | void XineControl::seekTo( long second ) { | 194 | void XineControl::seekTo( long second ) { |
194 | libXine->play( m_fileName , 0, (int)second ); | 195 | libXine->play( m_fileName , 0, (int)second ); |
195 | } | 196 | } |
196 | 197 | ||
197 | void XineControl::videoResized ( const QSize &s ) { | 198 | void XineControl::videoResized ( const QSize &s ) { |
198 | libXine-> resize ( s ); | 199 | libXine-> resize ( s ); |
199 | } | 200 | } |
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp index 9b26d41..1d88cea 100644 --- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp +++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp | |||
@@ -1,263 +1,272 @@ | |||
1 | 1 | ||
2 | /* | 2 | /* |
3 | This file is part of the Opie Project | 3 | This file is part of the Opie Project |
4 | 4 | ||
5 | Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> | 5 | Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <qimage.h> | 34 | #include <qimage.h> |
35 | #include <qpainter.h> | 35 | #include <qpainter.h> |
36 | #include <qgfx_qws.h> | 36 | #include <qgfx_qws.h> |
37 | #include <qdirectpainter_qws.h> | 37 | #include <qdirectpainter_qws.h> |
38 | #include <qgfx_qws.h> | 38 | #include <qgfx_qws.h> |
39 | #include <qsize.h> | 39 | #include <qsize.h> |
40 | #include <qapplication.h> | 40 | #include <qapplication.h> |
41 | #include <qpainter.h> | 41 | #include <qpainter.h> |
42 | 42 | ||
43 | #include <qpe/resource.h> | 43 | #include <qpe/resource.h> |
44 | 44 | ||
45 | #include "xinevideowidget.h" | 45 | #include "xinevideowidget.h" |
46 | 46 | ||
47 | |||
47 | // 0 deg rot: copy a line from src to dst (use libc memcpy) | 48 | // 0 deg rot: copy a line from src to dst (use libc memcpy) |
48 | 49 | ||
49 | // 180 deg rot: copy a line from src to dst reversed | 50 | // 180 deg rot: copy a line from src to dst reversed |
50 | 51 | ||
51 | static inline void memcpy_rev ( void *dst, void *src, size_t len ) | 52 | static inline void memcpy_rev ( void *dst, void *src, size_t len ) |
52 | { | 53 | { |
53 | ((char *) src) += len; | 54 | ((char *) src ) += len; |
54 | 55 | ||
55 | len >>= 1; | 56 | len >>= 1; |
56 | while ( len-- ) | 57 | while ( len-- ) |
57 | *((short int *) dst) ++ = *--((short int *) src); | 58 | *((short int *) dst )++ = *--((short int *) src ); |
58 | } | 59 | } |
59 | 60 | ||
60 | // 90 deg rot: copy a column from src to dst | 61 | // 90 deg rot: copy a column from src to dst |
61 | 62 | ||
62 | static inline void memcpy_step ( void *dst, void *src, size_t len, size_t linestep ) | 63 | static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step ) |
63 | { | 64 | { |
64 | len >>= 1; | 65 | len >>= 1; |
65 | while ( len-- ) { | 66 | while ( len-- ) { |
66 | *((short int *) dst) ++ = *((short int *) src); | 67 | *((short int *) dst )++ = *((short int *) src ); |
67 | ((char * ) src) += linestep; | 68 | ((char *) src ) += step; |
68 | } | 69 | } |
69 | } | 70 | } |
70 | 71 | ||
71 | // 270 deg rot: copy a column from src to dst reversed | 72 | // 270 deg rot: copy a column from src to dst reversed |
72 | 73 | ||
73 | static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t linestep ) | 74 | static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t step ) |
74 | { | 75 | { |
75 | len >>= 1; | 76 | len >>= 1; |
76 | 77 | ||
77 | ((char *) src) += ( len * linestep ); | 78 | ((char *) src ) += ( len * step ); |
78 | 79 | ||
79 | while ( len-- ) { | 80 | while ( len-- ) { |
80 | ((char *) src) -= linestep; | 81 | ((char *) src ) -= step; |
81 | *((short int *) dst) ++ = *((short int *) src); | 82 | *((short int *) dst )++ = *((short int *) src ); |
82 | } | 83 | } |
83 | } | 84 | } |
84 | 85 | ||
85 | 86 | ||
86 | XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name ) | 87 | XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name ) |
87 | : QWidget ( parent, name, WRepaintNoErase | WResizeNoErase ) | 88 | : QWidget ( parent, name, WRepaintNoErase | WResizeNoErase ) |
88 | { | 89 | { |
89 | setBackgroundMode ( NoBackground ); | 90 | setBackgroundMode ( NoBackground ); |
90 | 91 | ||
91 | m_logo = 0; | 92 | m_logo = 0; |
92 | m_buff = 0; | 93 | m_buff = 0; |
93 | m_bytes_per_line_fb = qt_screen-> linestep ( ); | 94 | m_bytes_per_line_fb = qt_screen-> linestep ( ); |
94 | m_bytes_per_pixel = ( qt_screen-> depth ( ) + 7 ) / 8; | 95 | m_bytes_per_pixel = ( qt_screen->depth() + 7 ) / 8; |
95 | m_rotation = 0; | 96 | m_rotation = 0; |
96 | } | 97 | } |
97 | 98 | ||
98 | 99 | ||
99 | XineVideoWidget::~XineVideoWidget ( ) | 100 | XineVideoWidget::~XineVideoWidget ( ) |
100 | { | 101 | { |
101 | delete m_logo; | 102 | delete m_logo; |
102 | } | 103 | } |
103 | 104 | ||
104 | void XineVideoWidget::clear ( ) | 105 | void XineVideoWidget::clear ( ) |
105 | { | 106 | { |
106 | m_buff = 0; | 107 | m_buff = 0; |
107 | repaint ( false ); | 108 | repaint ( false ); |
108 | } | 109 | } |
109 | 110 | ||
110 | void XineVideoWidget::paintEvent ( QPaintEvent * ) | 111 | void XineVideoWidget::paintEvent ( QPaintEvent * ) |
111 | { | 112 | { |
112 | if ( m_buff == 0 ) { | 113 | if ( m_buff == 0 ) { |
113 | QPainter p ( this ); | 114 | QPainter p ( this ); |
114 | p. fillRect ( rect ( ), black ); | 115 | p. fillRect ( rect ( ), black ); |
115 | if ( m_logo ) | 116 | if ( m_logo ) |
116 | p. drawImage ( 0, 0, *m_logo ); | 117 | p. drawImage ( 0, 0, *m_logo ); |
117 | } | 118 | } |
118 | else { | 119 | else { |
119 | // Qt needs to be notified which areas were really updated .. strange | 120 | // Qt needs to be notified which areas were really updated .. strange |
120 | QArray <QRect> qt_bug_workaround_clip_rects; | 121 | QArray <QRect> qt_bug_workaround_clip_rects; |
121 | 122 | ||
122 | { | 123 | { |
123 | QDirectPainter dp ( this ); | 124 | QDirectPainter dp ( this ); |
124 | 125 | ||
125 | int rot = dp. transformOrientation ( ) + m_rotation; // device rotation + custom rotation | 126 | int rot = dp. transformOrientation ( ) + m_rotation; // device rotation + custom rotation |
126 | 127 | ||
127 | uchar *fb = dp. frameBuffer ( ); | 128 | uchar *fb = dp. frameBuffer ( ); |
128 | uchar *frame = m_buff; | 129 | uchar *frame = m_buff; |
129 | 130 | ||
130 | // where is the video frame in fb coordinates | 131 | // where is the video frame in fb coordinates |
131 | QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); | 132 | QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); |
132 | 133 | ||
133 | qt_bug_workaround_clip_rects. resize ( dp. numRects ( )); | 134 | qt_bug_workaround_clip_rects. resize ( dp. numRects ( )); |
134 | 135 | ||
135 | for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) { | 136 | for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) { |
136 | const QRect &clip = dp. rect ( i ); | 137 | const QRect &clip = dp. rect ( i ); |
137 | 138 | ||
138 | qt_bug_workaround_clip_rects [ i ] = qt_screen-> mapFromDevice ( clip, QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); | 139 | qt_bug_workaround_clip_rects [ i ] = qt_screen-> mapFromDevice ( clip, QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); |
139 | 140 | ||
140 | uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb ); // clip x/y in the fb | 141 | uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb ); // clip x/y in the fb |
141 | uchar *src = frame; | 142 | uchar *src = frame; |
142 | 143 | ||
143 | // Adjust the start the source data based on the rotation (xine frame) | 144 | // Adjust the start the source data based on the rotation (xine frame) |
144 | switch ( rot ) { | 145 | switch ( rot ) { |
145 | case 0: src += ((( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame )); break; | 146 | case 0: src += ((( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame )); break; |
146 | case 1: src += ((( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_pixel )); break; | 147 | case 1: src += ((( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_pixel )); break; |
147 | case 2: src += ((( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_line_frame )); break; | 148 | case 2: src += ((( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_line_frame )); break; |
148 | case 3: src += ((( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame )); break; | 149 | case 3: src += ((( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame )); break; |
149 | default: break; | 150 | default: break; |
150 | } | 151 | } |
151 | 152 | ||
152 | // all of the following widths/heights are fb relative (0deg rotation) | 153 | // all of the following widths/heights are fb relative (0deg rotation) |
153 | 154 | ||
154 | uint leftfill = 0; // black border on the "left" side of the video frame | 155 | uint leftfill = 0; // black border on the "left" side of the video frame |
155 | uint framefill = 0; // "width" of the video frame | 156 | uint framefill = 0; // "width" of the video frame |
156 | uint rightfill = 0; // black border on the "right" side of the video frame | 157 | uint rightfill = 0; // black border on the "right" side of the video frame |
157 | uint clipwidth = clip. width ( ) * m_bytes_per_pixel; // "width" of the current clip rect | 158 | uint clipwidth = clip. width ( ) * m_bytes_per_pixel; // "width" of the current clip rect |
158 | 159 | ||
159 | if ( clip. left ( ) < framerect. left ( )) | 160 | if ( clip. left ( ) < framerect. left ( )) |
160 | leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) < ? clipwidth; | 161 | leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth; |
161 | if ( clip. right ( ) > framerect. right ( )) | 162 | if ( clip. right ( ) > framerect. right ( )) |
162 | rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) < ? clipwidth; | 163 | rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth; |
163 | 164 | ||
164 | framefill = clipwidth - ( leftfill + rightfill ); | 165 | framefill = clipwidth - ( leftfill + rightfill ); |
165 | 166 | ||
166 | for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) { | 167 | for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) { |
167 | if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) { | 168 | if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) { |
168 | // "above" or "below" the video -> black | 169 | // "above" or "below" the video -> black |
169 | memset ( dst, 0, clipwidth ); | 170 | memset ( dst, 0, clipwidth ); |
170 | } | 171 | } |
171 | else { | 172 | else { |
172 | if ( leftfill ) | 173 | if ( leftfill ) |
173 | memset ( dst, 0, leftfill ); // "left" border -> black | 174 | memset ( dst, 0, leftfill ); // "left" border -> black |
174 | 175 | ||
175 | if ( framefill ) { // blit in the video frame | 176 | if ( framefill ) { // blit in the video frame |
176 | // see above for an explanation of the different memcpys | 177 | // see above for an explanation of the different memcpys |
177 | 178 | ||
178 | switch ( rot ) { | 179 | switch ( rot ) { |
179 | case 0: memcpy ( dst + leftfill, src, framefill ); break; | 180 | case 0: memcpy ( dst + leftfill, src, framefill ); break; |
180 | case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; | 181 | case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; |
181 | case 2: memcpy_rev ( dst + leftfill, src, framefill ); break; | 182 | case 2: memcpy_rev ( dst + leftfill, src, framefill ); break; |
182 | case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; | 183 | case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; |
183 | default: break; | 184 | default: break; |
184 | } | 185 | } |
185 | if ( rightfill ) | ||
186 | memset ( dst + leftfill + framefill, 0, rightfill ); // "right" border -> black | ||
187 | } | 186 | } |
187 | if ( rightfill ) | ||
188 | memset ( dst + leftfill + framefill, 0, rightfill ); // "right" border -> black | ||
189 | } | ||
188 | 190 | ||
189 | dst += m_bytes_per_line_fb; // advance one line in the framebuffer | 191 | dst += m_bytes_per_line_fb; // advance one line in the framebuffer |
190 | 192 | ||
191 | // advance one "line" in the xine frame data | 193 | // advance one "line" in the xine frame data |
192 | switch ( rot ) { | 194 | switch ( rot ) { |
193 | case 0: src += m_bytes_per_line_frame;break; | 195 | case 0: src += m_bytes_per_line_frame;break; |
194 | case 1: src -= m_bytes_per_pixel; break; | 196 | case 1: src -= m_bytes_per_pixel; break; |
195 | case 2: src -= m_bytes_per_line_frame; break; | 197 | case 2: src -= m_bytes_per_line_frame; break; |
196 | case 3: src += m_bytes_per_pixel; break; | 198 | case 3: src += m_bytes_per_pixel; break; |
197 | default: break; | 199 | default: break; |
198 | } | ||
199 | } | 200 | } |
200 | } | 201 | } |
202 | } | ||
203 | } | ||
201 | 204 | ||
202 | { | 205 | { |
203 | // QVFB hack by Martin Jones | 206 | // QVFB hack by Martin Jones |
204 | // We need to "touch" all affected clip rects with a normal QPainter in addition to the QDirectPainter | 207 | // We need to "touch" all affected clip rects with a normal QPainter in addition to the QDirectPainter |
205 | 208 | ||
206 | QPainter p ( this ); | 209 | QPainter p ( this ); |
207 | 210 | ||
208 | for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) { | 211 | for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) { |
209 | p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [ i ]. topLeft ( )), qt_bug_workaround_clip_rects [ i ]. size ( )), QBrush ( NoBrush )); | 212 | p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [ i ]. topLeft ( )), qt_bug_workaround_clip_rects [ i ]. size ( )), QBrush ( NoBrush )); |
210 | } | ||
211 | } | ||
212 | } | 213 | } |
213 | } | 214 | } |
215 | } | ||
216 | } | ||
214 | 217 | ||
215 | QImage *XineVideoWidget::logo ( ) const { | ||
216 | return m_logo; | ||
217 | } | ||
218 | 218 | ||
219 | void XineVideoWidget::setLogo ( QImage * image ) { | 219 | QImage *XineVideoWidget::logo ( ) const |
220 | delete m_logo; | 220 | { |
221 | m_logo = image; | 221 | return m_logo; |
222 | } | 222 | } |
223 | 223 | ||
224 | void XineVideoWidget::setVideoFrame ( uchar * img, int w, int h, int bpl ) { | ||
225 | bool rot90 = (( -m_rotation ) & 1 ); | ||
226 | 224 | ||
227 | if ( rot90 ) { // if the rotation is 90 or 270 we have to swap width / height | 225 | void XineVideoWidget::setLogo ( QImage* logo ) |
228 | int d = w; | 226 | { |
229 | w = h; | 227 | delete m_logo; |
230 | h = d; | 228 | m_logo = logo; |
231 | } | 229 | } |
232 | 230 | ||
233 | m_lastframe = m_thisframe; | 231 | void XineVideoWidget::setVideoFrame ( uchar* img, int w, int h, int bpl ) |
234 | m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); | 232 | { |
233 | bool rot90 = (( -m_rotation ) & 1 ); | ||
235 | 234 | ||
236 | m_buff = img; | 235 | if ( rot90 ) { // if the rotation is 90 or 270 we have to swap width / height |
237 | m_bytes_per_line_frame = bpl; | 236 | int d = w; |
237 | w = h; | ||
238 | h = d; | ||
239 | } | ||
238 | 240 | ||
239 | // only repaint the area that *really* needs to be repainted | 241 | m_lastframe = m_thisframe; |
242 | m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); | ||
240 | 243 | ||
241 | repaint (( | 244 | m_buff = img; |
242 | } | 245 | m_bytes_per_line_frame = bpl; |
243 | 246 | ||
244 | void XineVideoWidget::resizeEvent ( QResizeEvent * ) { | 247 | // only repaint the area that *really* needs to be repainted |
245 | QSize s = size ( ); | ||
246 | bool fs = ( s == qApp-> desktop ( ) -> size ( )); | ||
247 | 248 | ||
248 | // if we are in fullscreen mode, do not rotate the video | 249 | repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false ); |
249 | // (!! the paint routine uses m_rotation + qt_screen-> transformOrientation() !!) | 250 | } |
251 | |||
252 | void XineVideoWidget::resizeEvent ( QResizeEvent * ) | ||
253 | { | ||
254 | QSize s = size ( ); | ||
255 | bool fs = ( s == qApp-> desktop ( )-> size ( )); | ||
250 | 256 | ||
251 | m_rotation = fs ? -qt_screen-> transformOrientation ( ) : 0; | 257 | // if we are in fullscreen mode, do not rotate the video |
258 | // (!! the paint routine uses m_rotation + qt_screen-> transformOrientation() !!) | ||
259 | m_rotation = fs ? -qt_screen-> transformOrientation ( ) : 0; | ||
252 | 260 | ||
253 | if ( fs && qt_screen-> isTransformed ( )) | 261 | if ( fs && qt_screen-> isTransformed ( )) |
254 | s = qt_screen-> mapToDevice ( s ); | 262 | s = qt_screen-> mapToDevice ( s ); |
255 | 263 | ||
256 | emit videoResized ( s ); | 264 | emit videoResized ( s ); |
257 | } | 265 | } |
258 | 266 | ||
259 | 267 | ||
260 | void XineVideoWidget::mouseReleaseEvent ( QMouseEvent * ) { | 268 | void XineVideoWidget::mouseReleaseEvent ( QMouseEvent * /*me*/ ) |
261 | emit clicked ( ); | 269 | { |
262 | } | 270 | emit clicked(); |
271 | } | ||
263 | 272 | ||