summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/yuv2rgb_mlib.c
Unidiff
Diffstat (limited to 'noncore/multimedia/opieplayer2/yuv2rgb_mlib.c') (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/yuv2rgb_mlib.c313
1 files changed, 0 insertions, 313 deletions
diff --git a/noncore/multimedia/opieplayer2/yuv2rgb_mlib.c b/noncore/multimedia/opieplayer2/yuv2rgb_mlib.c
deleted file mode 100644
index 908b439..0000000
--- a/noncore/multimedia/opieplayer2/yuv2rgb_mlib.c
+++ b/dev/null
@@ -1,313 +0,0 @@
1/*
2 * yuv2rgb_mlib.c
3 * Copyright (C) 2000-2001 Silicon Integrated System Corp.
4 * All Rights Reserved.
5 *
6 * Author: Juergen Keil <jk@tools.de>
7 *
8 * This file is part of xine, a free unix video player.
9 *
10 * xine is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * xine is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24
25
26#if HAVE_MLIB
27
28#include <stdio.h>
29#include <stdlib.h>
30#include <string.h>
31#include <inttypes.h>
32#include <mlib_video.h>
33
34#include "attributes.h"
35#include "yuv2rgb.h"
36
37
38static void scale_line (uint8_t *source, uint8_t *dest,
39 int width, int step) {
40
41 unsigned p1;
42 unsigned p2;
43 int dx;
44
45 p1 = *source++;
46 p2 = *source++;
47 dx = 0;
48
49 while (width) {
50
51 /*
52 printf ("scale_line, width = %d\n", width);
53 printf ("scale_line, dx = %d, p1 = %d, p2 = %d\n", dx, p1, p2);
54 */
55
56 *dest = (p1 * (32768 - dx) + p2 * dx) / 32768;
57
58 dx += step;
59 while (dx > 32768) {
60 dx -= 32768;
61 p1 = p2;
62 p2 = *source++;
63 }
64
65 dest ++;
66 width --;
67 }
68}
69
70
71
72static void mlib_yuv420_rgb24 (yuv2rgb_t *this,
73 uint8_t * image, uint8_t * py,
74 uint8_t * pu, uint8_t * pv)
75{
76 int dst_height;
77 int dy;
78 mlib_status mlib_stat;
79
80 if (this->do_scale) {
81 dy = 0;
82 dst_height = this->dest_height;
83
84 for (;;) {
85 scale_line (pu, this->u_buffer,
86 this->dest_width >> 1, this->step_dx);
87 pu += this->uv_stride;
88
89 scale_line (pv, this->v_buffer,
90 this->dest_width >> 1, this->step_dx);
91 pv += this->uv_stride;
92
93 scale_line (py, this->y_buffer,
94 this->dest_width, this->step_dx);
95 py += this->y_stride;
96 scale_line (py, this->y_buffer + this->dest_width,
97 this->dest_width, this->step_dx);
98 py += this->y_stride;
99
100 mlib_stat = mlib_VideoColorYUV2RGB420(image,
101 this->y_buffer,
102 this->u_buffer,
103 this->v_buffer,
104 this->dest_width & ~1, 2,
105 this->rgb_stride,
106 this->dest_width,
107 this->dest_width >> 1);
108 dy += this->step_dy;
109 image += this->rgb_stride;
110
111 while (--dst_height > 0 && dy < 32768) {
112 memcpy (image, (uint8_t*)image-this->rgb_stride, this->dest_width*6);
113 dy += this->step_dy;
114 image += this->rgb_stride;
115 }
116
117 if (dst_height <= 0)
118 break;
119
120 dy -= 32768;
121
122 dy += this->step_dy;
123 image += this->rgb_stride;
124
125 while (--dst_height > 0 && dy < 32768) {
126 memcpy (image, (uint8_t*)image-this->rgb_stride, this->dest_width*3);
127 dy += this->step_dy;
128 image += this->rgb_stride;
129 }
130
131 if (dst_height <= 0)
132 break;
133
134 dy -= 32768;
135 }
136 } else {
137 mlib_stat = mlib_VideoColorYUV2RGB420(image, py, pu, pv,
138 this->source_width,
139 this->source_height,
140 this->rgb_stride,
141 this->y_stride,
142 this->uv_stride);
143 }
144}
145
146static void mlib_yuv420_argb32 (yuv2rgb_t *this,
147 uint8_t * image, uint8_t * py,
148 uint8_t * pu, uint8_t * pv)
149{
150 int dst_height;
151 int dy;
152 mlib_status mlib_stat;
153
154 if (this->do_scale) {
155 dy = 0;
156 dst_height = this->dest_height;
157
158 for (;;) {
159 scale_line (pu, this->u_buffer,
160 this->dest_width >> 1, this->step_dx);
161 pu += this->uv_stride;
162
163 scale_line (pv, this->v_buffer,
164 this->dest_width >> 1, this->step_dx);
165 pv += this->uv_stride;
166
167 scale_line (py, this->y_buffer,
168 this->dest_width, this->step_dx);
169 py += this->y_stride;
170 scale_line (py, this->y_buffer + this->dest_width,
171 this->dest_width, this->step_dx);
172 py += this->y_stride;
173
174 mlib_stat = mlib_VideoColorYUV2ARGB420(image,
175 this->y_buffer,
176 this->u_buffer,
177 this->v_buffer,
178 this->dest_width & ~1, 2,
179 this->rgb_stride,
180 this->dest_width,
181 this->dest_width >> 1);
182 dy += this->step_dy;
183 image += this->rgb_stride;
184
185 while (--dst_height > 0 && dy < 32768) {
186 memcpy (image, (uint8_t*)image-this->rgb_stride, this->dest_width*8);
187 dy += this->step_dy;
188 image += this->rgb_stride;
189 }
190
191 if (dst_height <= 0)
192 break;
193
194 dy -= 32768;
195
196 dy += this->step_dy;
197 image += this->rgb_stride;
198
199 while (--dst_height > 0 && dy < 32768) {
200 memcpy (image, (uint8_t*)image-this->rgb_stride, this->dest_width*4);
201 dy += this->step_dy;
202 image += this->rgb_stride;
203 }
204
205 if (dst_height <= 0)
206 break;
207
208 dy -= 32768;
209 }
210 } else {
211 mlib_stat = mlib_VideoColorYUV2ARGB420(image, py, pu, pv,
212 this->source_width,
213 this->source_height,
214 this->rgb_stride,
215 this->y_stride,
216 this->uv_stride);
217 }
218}
219
220static void mlib_yuv420_abgr32 (yuv2rgb_t *this,
221 uint8_t * image, uint8_t * py,
222 uint8_t * pu, uint8_t * pv)
223{
224 int dst_height;
225 int dy;
226 mlib_status mlib_stat;
227
228 if (this->do_scale) {
229 dy = 0;
230 dst_height = this->dest_height;
231
232 for (;;) {
233 scale_line (pu, this->u_buffer,
234 this->dest_width >> 1, this->step_dx);
235 pu += this->uv_stride;
236
237 scale_line (pv, this->v_buffer,
238 this->dest_width >> 1, this->step_dx);
239 pv += this->uv_stride;
240
241 scale_line (py, this->y_buffer,
242 this->dest_width, this->step_dx);
243 py += this->y_stride;
244 scale_line (py, this->y_buffer + this->dest_width,
245 this->dest_width, this->step_dx);
246 py += this->y_stride;
247
248 mlib_stat = mlib_VideoColorYUV2ABGR420(image,
249 this->y_buffer,
250 this->u_buffer,
251 this->v_buffer,
252 this->dest_width & ~1, 2,
253 this->rgb_stride,
254 this->dest_width,
255 this->dest_width >> 1);
256 dy += this->step_dy;
257 image += this->rgb_stride;
258
259 while (--dst_height > 0 && dy < 32768) {
260 memcpy (image, (uint8_t*)image-this->rgb_stride, this->dest_width*8);
261 dy += this->step_dy;
262 image += this->rgb_stride;
263 }
264
265 if (dst_height <= 0)
266 break;
267
268 dy -= 32768;
269
270 dy += this->step_dy;
271 image += this->rgb_stride;
272
273 while (--dst_height > 0 && dy < 32768) {
274 memcpy (image, (uint8_t*)image-this->rgb_stride, this->dest_width*4);
275 dy += this->step_dy;
276 image += this->rgb_stride;
277 }
278
279 if (dst_height <= 0)
280 break;
281
282 dy -= 32768;
283 }
284 } else {
285 mlib_stat = mlib_VideoColorYUV2ABGR420(image, py, pu, pv,
286 this->source_width,
287 this->source_height,
288 this->rgb_stride,
289 this->y_stride,
290 this->uv_stride);
291 }
292}
293
294
295void yuv2rgb_init_mlib (yuv2rgb_factory_t *this) {
296
297 if (this->swapped) return; /*no swapped pixel output upto now*/
298
299 switch (this->mode) {
300 case MODE_24_RGB:
301 this->yuv2rgb_fun = mlib_yuv420_rgb24;
302 break;
303 case MODE_32_RGB:
304 this->yuv2rgb_fun = mlib_yuv420_argb32;
305 break;
306 case MODE_32_BGR:
307 this->yuv2rgb_fun = mlib_yuv420_abgr32;
308 break;
309 }
310}
311
312
313 #endif/* HAVE_MLIB */