summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-12-19 21:41:50 (UTC)
committer harlekin <harlekin>2002-12-19 21:41:50 (UTC)
commit5fd6636ba3d94b48dd543887316c47c5388a43c2 (patch) (unidiff)
treef750583ce4284ac226da90858751875a5404de6b
parentd73c08dacb1abd6e02e0ff803083985bd0ca791b (diff)
downloadopie-5fd6636ba3d94b48dd543887316c47c5388a43c2.zip
opie-5fd6636ba3d94b48dd543887316c47c5388a43c2.tar.gz
opie-5fd6636ba3d94b48dd543887316c47c5388a43c2.tar.bz2
adapted to todays xine cvs
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/nullvideo.c2
-rw-r--r--noncore/multimedia/opieplayer2/yuv2rgb.c4
2 files changed, 4 insertions, 2 deletions
diff --git a/noncore/multimedia/opieplayer2/nullvideo.c b/noncore/multimedia/opieplayer2/nullvideo.c
index a49f9d3..095f206 100644
--- a/noncore/multimedia/opieplayer2/nullvideo.c
+++ b/noncore/multimedia/opieplayer2/nullvideo.c
@@ -1,635 +1,637 @@
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 <stdlib.h> 34#include <stdlib.h>
35#include <stdio.h> 35#include <stdio.h>
36 36
37#include <math.h> 37#include <math.h>
38 38
39#include <xine.h> 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/vo_scale.h> 43#include <xine/vo_scale.h>
44#include <xine/buffer.h> 44#include <xine/buffer.h>
45 45
46#include <pthread.h> 46#include <pthread.h>
47#include "alphablend.h" 47#include "alphablend.h"
48#include "yuv2rgb.h" 48#include "yuv2rgb.h"
49 49
50#define printf(x,...) 50#define printf(x,...)
51 51
52/* 52/*
53#define LOG 53#define LOG
54*/ 54*/
55 55
56/* the caller for our event draw handler */ 56/* the caller for our event draw handler */
57typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, 57typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame,
58 int width, int height,int bytes ); 58 int width, int height,int bytes );
59 59
60typedef struct null_driver_s null_driver_t; 60typedef struct null_driver_s null_driver_t;
61 61
62struct null_driver_s { 62struct null_driver_s {
63 vo_driver_t vo_driver; 63 vo_driver_t vo_driver;
64 64
65 uint32_t m_capabilities; 65 uint32_t m_capabilities;
66 int m_show_video; 66 int m_show_video;
67 int m_video_fullscreen; 67 int m_video_fullscreen;
68 int m_is_scaling; 68 int m_is_scaling;
69 69
70 int depth, bpp, bytes_per_pixel; 70 int depth, bpp, bytes_per_pixel;
71 int yuv2rgb_mode; 71 int yuv2rgb_mode;
72 int yuv2rgb_swap; 72 int yuv2rgb_swap;
73 int yuv2rgb_gamma; 73 int yuv2rgb_gamma;
74 uint8_t *yuv2rgb_cmap; 74 uint8_t *yuv2rgb_cmap;
75 yuv2rgb_factory_t *yuv2rgb_factory; 75 yuv2rgb_factory_t *yuv2rgb_factory;
76 76
77 vo_overlay_t *overlay; 77 vo_overlay_t *overlay;
78 vo_scale_t sc; 78 vo_scale_t sc;
79 79
80 int gui_width; 80 int gui_width;
81 int gui_height; 81 int gui_height;
82 int gui_changed; 82 int gui_changed;
83 83
84 double display_ratio; 84 double display_ratio;
85 void* caller; 85 void* caller;
86 display_xine_frame_t frameDis; 86 display_xine_frame_t frameDis;
87}; 87};
88 88
89typedef struct opie_frame_s opie_frame_t; 89typedef struct opie_frame_s opie_frame_t;
90struct opie_frame_s { 90struct opie_frame_s {
91 vo_frame_t frame; 91 vo_frame_t frame;
92 92
93 int format; 93 int format;
94 int flags; 94 int flags;
95 95
96 vo_scale_t sc; 96 vo_scale_t sc;
97 97
98 uint8_t *chunk[3]; 98 uint8_t *chunk[3];
99 99
100 uint8_t *data; /* rgb */ 100 uint8_t *data; /* rgb */
101 int bytes_per_line; 101 int bytes_per_line;
102 102
103 yuv2rgb_t *yuv2rgb; 103 yuv2rgb_t *yuv2rgb;
104 uint8_t *rgb_dst; 104 uint8_t *rgb_dst;
105 int yuv_stride; 105 int yuv_stride;
106 int stripe_height, stripe_inc; 106 int stripe_height, stripe_inc;
107 107
108 null_driver_t *output; 108 null_driver_t *output;
109}; 109};
110 110
111static uint32_t null_get_capabilities( vo_driver_t *self ){ 111static uint32_t null_get_capabilities( vo_driver_t *self ){
112 null_driver_t* this = (null_driver_t*)self; 112 null_driver_t* this = (null_driver_t*)self;
113 return this->m_capabilities; 113 return this->m_capabilities;
114} 114}
115 115
116static void null_frame_copy (vo_frame_t *vo_img, uint8_t **src) { 116static void null_frame_copy (vo_frame_t *vo_img, uint8_t **src) {
117 opie_frame_t *frame = (opie_frame_t *) vo_img ; 117 opie_frame_t *frame = (opie_frame_t *) vo_img ;
118
119 vo_img->copy_called = 1;
118 120
119 if (!frame->output->m_show_video) { 121 if (!frame->output->m_show_video) {
120 /* printf("nullvideo: no video\n"); */ 122 /* printf("nullvideo: no video\n"); */
121 return; 123 return;
122 } 124 }
123 125
124 if (frame->format == XINE_IMGFMT_YV12) { 126 if (frame->format == XINE_IMGFMT_YV12) {
125 frame->yuv2rgb->yuv2rgb_fun (frame->yuv2rgb, frame->rgb_dst, 127 frame->yuv2rgb->yuv2rgb_fun (frame->yuv2rgb, frame->rgb_dst,
126 src[0], src[1], src[2]); 128 src[0], src[1], src[2]);
127 } else { 129 } else {
128 130
129 frame->yuv2rgb->yuy22rgb_fun (frame->yuv2rgb, frame->rgb_dst, 131 frame->yuv2rgb->yuy22rgb_fun (frame->yuv2rgb, frame->rgb_dst,
130 src[0]); 132 src[0]);
131 } 133 }
132 134
133 frame->rgb_dst += frame->stripe_inc; 135 frame->rgb_dst += frame->stripe_inc;
134} 136}
135 137
136static void null_frame_field (vo_frame_t *vo_img, int which_field) { 138static void null_frame_field (vo_frame_t *vo_img, int which_field) {
137 139
138 opie_frame_t *frame = (opie_frame_t *) vo_img ; 140 opie_frame_t *frame = (opie_frame_t *) vo_img ;
139 141
140 switch (which_field) { 142 switch (which_field) {
141 case VO_TOP_FIELD: 143 case VO_TOP_FIELD:
142 frame->rgb_dst = (uint8_t *)frame->data; 144 frame->rgb_dst = (uint8_t *)frame->data;
143 frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line; 145 frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line;
144 break; 146 break;
145 case VO_BOTTOM_FIELD: 147 case VO_BOTTOM_FIELD:
146 frame->rgb_dst = (uint8_t *)frame->data + frame->bytes_per_line ; 148 frame->rgb_dst = (uint8_t *)frame->data + frame->bytes_per_line ;
147 frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line; 149 frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line;
148 break; 150 break;
149 case VO_BOTH_FIELDS: 151 case VO_BOTH_FIELDS:
150 frame->rgb_dst = (uint8_t *)frame->data; 152 frame->rgb_dst = (uint8_t *)frame->data;
151 break; 153 break;
152 } 154 }
153} 155}
154 156
155 157
156/* take care of the frame*/ 158/* take care of the frame*/
157static void null_frame_dispose( vo_frame_t* vo_img){ 159static void null_frame_dispose( vo_frame_t* vo_img){
158 opie_frame_t* frame = (opie_frame_t*)vo_img; 160 opie_frame_t* frame = (opie_frame_t*)vo_img;
159 161
160 if (frame->data) 162 if (frame->data)
161 free( frame->data ); 163 free( frame->data );
162 free (frame); 164 free (frame);
163} 165}
164 166
165/* end take care of frames*/ 167/* end take care of frames*/
166 168
167static vo_frame_t* null_alloc_frame( vo_driver_t* self ){ 169static vo_frame_t* null_alloc_frame( vo_driver_t* self ){
168 170
169 null_driver_t* this = (null_driver_t*)self; 171 null_driver_t* this = (null_driver_t*)self;
170 opie_frame_t* frame; 172 opie_frame_t* frame;
171 173
172#ifdef LOG 174#ifdef LOG
173 fprintf (stderr, "nullvideo: alloc_frame\n"); 175 fprintf (stderr, "nullvideo: alloc_frame\n");
174#endif 176#endif
175 177
176 frame = (opie_frame_t*)malloc ( sizeof(opie_frame_t) ); 178 frame = (opie_frame_t*)malloc ( sizeof(opie_frame_t) );
177 179
178 memset( frame, 0, sizeof( opie_frame_t) ); 180 memset( frame, 0, sizeof( opie_frame_t) );
179 memcpy (&frame->sc, &this->sc, sizeof(vo_scale_t)); 181 memcpy (&frame->sc, &this->sc, sizeof(vo_scale_t));
180 182
181 pthread_mutex_init (&frame->frame.mutex, NULL); 183 pthread_mutex_init (&frame->frame.mutex, NULL);
182 184
183 frame->output = this; 185 frame->output = this;
184 186
185 /* initialize the frame*/ 187 /* initialize the frame*/
186 frame->frame.driver = self; 188 frame->frame.driver = self;
187 frame->frame.copy = null_frame_copy; 189 frame->frame.copy = null_frame_copy;
188 frame->frame.field = null_frame_field; 190 frame->frame.field = null_frame_field;
189 frame->frame.dispose = null_frame_dispose; 191 frame->frame.dispose = null_frame_dispose;
190 192
191 /* 193 /*
192 * colorspace converter for this frame 194 * colorspace converter for this frame
193 */ 195 */
194 frame->yuv2rgb = this->yuv2rgb_factory->create_converter (this->yuv2rgb_factory); 196 frame->yuv2rgb = this->yuv2rgb_factory->create_converter (this->yuv2rgb_factory);
195 197
196 return (vo_frame_t*) frame; 198 return (vo_frame_t*) frame;
197} 199}
198 200
199static void null_update_frame_format( vo_driver_t* self, vo_frame_t* img, 201static void null_update_frame_format( vo_driver_t* self, vo_frame_t* img,
200 uint32_t width, uint32_t height, 202 uint32_t width, uint32_t height,
201 int ratio_code, int format, int flags ){ 203 int ratio_code, int format, int flags ){
202 null_driver_t* this = (null_driver_t*) self; 204 null_driver_t* this = (null_driver_t*) self;
203 opie_frame_t* frame = (opie_frame_t*)img; 205 opie_frame_t* frame = (opie_frame_t*)img;
204 /* not needed now */ 206 /* not needed now */
205 207
206#ifdef LOG 208#ifdef LOG
207 fprintf (stderr, "nullvideo: update_frame_format\n"); 209 fprintf (stderr, "nullvideo: update_frame_format\n");
208#endif 210#endif
209 211
210 flags &= VO_BOTH_FIELDS; 212 flags &= VO_BOTH_FIELDS;
211 213
212 /* find out if we need to adapt this frame */ 214 /* find out if we need to adapt this frame */
213 215
214 if ((width != frame->sc.delivered_width) 216 if ((width != frame->sc.delivered_width)
215 || (height != frame->sc.delivered_height) 217 || (height != frame->sc.delivered_height)
216 || (ratio_code != frame->sc.delivered_ratio_code) 218 || (ratio_code != frame->sc.delivered_ratio_code)
217 || (flags != frame->flags) 219 || (flags != frame->flags)
218 || (format != frame->format) 220 || (format != frame->format)
219 || (this->sc.user_ratio != frame->sc.user_ratio) 221 || (this->sc.user_ratio != frame->sc.user_ratio)
220 || (this->gui_width != frame->sc.gui_width) 222 || (this->gui_width != frame->sc.gui_width)
221 || (this->gui_height != frame->sc.gui_height)) { 223 || (this->gui_height != frame->sc.gui_height)) {
222 224
223 frame->sc.delivered_width = width; 225 frame->sc.delivered_width = width;
224 frame->sc.delivered_height = height; 226 frame->sc.delivered_height = height;
225 frame->sc.delivered_ratio_code = ratio_code; 227 frame->sc.delivered_ratio_code = ratio_code;
226 frame->flags = flags; 228 frame->flags = flags;
227 frame->format = format; 229 frame->format = format;
228 frame->sc.user_ratio = this->sc.user_ratio; 230 frame->sc.user_ratio = this->sc.user_ratio;
229 frame->sc.gui_width = this->gui_width; 231 frame->sc.gui_width = this->gui_width;
230 frame->sc.gui_height = this->gui_height; 232 frame->sc.gui_height = this->gui_height;
231 frame->sc.gui_pixel_aspect = 1.0; 233 frame->sc.gui_pixel_aspect = 1.0;
232 234
233 vo_scale_compute_ideal_size ( &frame->sc ); 235 vo_scale_compute_ideal_size ( &frame->sc );
234 vo_scale_compute_output_size( &frame->sc ); 236 vo_scale_compute_output_size( &frame->sc );
235 237
236#ifdef LOG 238#ifdef LOG
237 fprintf (stderr, "nullvideo: gui %dx%d delivered %dx%d output %dx%d\n", 239 fprintf (stderr, "nullvideo: gui %dx%d delivered %dx%d output %dx%d\n",
238 frame->sc.gui_width, frame->sc.gui_height, 240 frame->sc.gui_width, frame->sc.gui_height,
239 frame->sc.delivered_width, frame->sc.delivered_height, 241 frame->sc.delivered_width, frame->sc.delivered_height,
240 frame->sc.output_width, frame->sc.output_height); 242 frame->sc.output_width, frame->sc.output_height);
241#endif 243#endif
242 244
243 /* 245 /*
244 * (re-) allocate 246 * (re-) allocate
245 */ 247 */
246 if( frame->data ) { 248 if( frame->data ) {
247 if( frame->chunk[0] ){ 249 if( frame->chunk[0] ){
248 free( frame->chunk[0] ); 250 free( frame->chunk[0] );
249 frame->chunk[0] = NULL; 251 frame->chunk[0] = NULL;
250 } 252 }
251 if( frame->chunk[1] ){ 253 if( frame->chunk[1] ){
252 free ( frame->chunk[1] ); 254 free ( frame->chunk[1] );
253 frame->chunk[1] = NULL; 255 frame->chunk[1] = NULL;
254 } 256 }
255 if( frame->chunk[2] ){ 257 if( frame->chunk[2] ){
256 free ( frame->chunk[2] ); 258 free ( frame->chunk[2] );
257 frame->chunk[2] = NULL; 259 frame->chunk[2] = NULL;
258 } 260 }
259 free ( frame->data ); 261 free ( frame->data );
260 } 262 }
261 263
262 frame->data = xine_xmalloc (frame->sc.output_width 264 frame->data = xine_xmalloc (frame->sc.output_width
263 * frame->sc.output_height 265 * frame->sc.output_height
264 * this->bytes_per_pixel ); 266 * this->bytes_per_pixel );
265 267
266 if( format == XINE_IMGFMT_YV12 ) { 268 if( format == XINE_IMGFMT_YV12 ) {
267 frame->frame.pitches[0] = 8*((width + 7) / 8); 269 frame->frame.pitches[0] = 8*((width + 7) / 8);
268 frame->frame.pitches[1] = 8*((width + 15) / 16); 270 frame->frame.pitches[1] = 8*((width + 15) / 16);
269 frame->frame.pitches[2] = 8*((width + 15) / 16); 271 frame->frame.pitches[2] = 8*((width + 15) / 16);
270 frame->frame.base[0] = xine_xmalloc_aligned (16, frame->frame.pitches[0] * height,(void **)&frame->chunk[0]); 272 frame->frame.base[0] = xine_xmalloc_aligned (16, frame->frame.pitches[0] * height,(void **)&frame->chunk[0]);
271 frame->frame.base[1] = xine_xmalloc_aligned (16, frame->frame.pitches[1] * ((height+ 1)/2), (void **)&frame->chunk[1]); 273 frame->frame.base[1] = xine_xmalloc_aligned (16, frame->frame.pitches[1] * ((height+ 1)/2), (void **)&frame->chunk[1]);
272 frame->frame.base[2] = xine_xmalloc_aligned (16, frame->frame.pitches[2] * ((height+ 1)/2), (void **)&frame->chunk[2]); 274 frame->frame.base[2] = xine_xmalloc_aligned (16, frame->frame.pitches[2] * ((height+ 1)/2), (void **)&frame->chunk[2]);
273 275
274 }else{ 276 }else{
275 frame->frame.pitches[0] = 8*((width + 3) / 4); 277 frame->frame.pitches[0] = 8*((width + 3) / 4);
276 278
277 frame->frame.base[0] = xine_xmalloc_aligned (16, frame->frame.pitches[0] * height, 279 frame->frame.base[0] = xine_xmalloc_aligned (16, frame->frame.pitches[0] * height,
278 (void **)&frame->chunk[0]); 280 (void **)&frame->chunk[0]);
279 frame->chunk[1] = NULL; 281 frame->chunk[1] = NULL;
280 frame->chunk[2] = NULL; 282 frame->chunk[2] = NULL;
281 } 283 }
282 284
283 frame->stripe_height = 16 * frame->sc.output_height / frame->sc.delivered_height; 285 frame->stripe_height = 16 * frame->sc.output_height / frame->sc.delivered_height;
284 frame->bytes_per_line = frame->sc.output_width * this->bytes_per_pixel; 286 frame->bytes_per_line = frame->sc.output_width * this->bytes_per_pixel;
285 287
286 /* 288 /*
287 * set up colorspace converter 289 * set up colorspace converter
288 */ 290 */
289 291
290 switch (flags) { 292 switch (flags) {
291 case VO_TOP_FIELD: 293 case VO_TOP_FIELD:
292 case VO_BOTTOM_FIELD: 294 case VO_BOTTOM_FIELD:
293 frame->yuv2rgb->configure (frame->yuv2rgb, 295 frame->yuv2rgb->configure (frame->yuv2rgb,
294 frame->sc.delivered_width, 296 frame->sc.delivered_width,
295 16, 297 16,
296 2*frame->frame.pitches[0], 298 2*frame->frame.pitches[0],
297 2*frame->frame.pitches[1], 299 2*frame->frame.pitches[1],
298 frame->sc.output_width, 300 frame->sc.output_width,
299 frame->stripe_height, 301 frame->stripe_height,
300 frame->bytes_per_line*2); 302 frame->bytes_per_line*2);
301 frame->yuv_stride = frame->bytes_per_line*2; 303 frame->yuv_stride = frame->bytes_per_line*2;
302 break; 304 break;
303 case VO_BOTH_FIELDS: 305 case VO_BOTH_FIELDS:
304 frame->yuv2rgb->configure (frame->yuv2rgb, 306 frame->yuv2rgb->configure (frame->yuv2rgb,
305 frame->sc.delivered_width, 307 frame->sc.delivered_width,
306 16, 308 16,
307 frame->frame.pitches[0], 309 frame->frame.pitches[0],
308 frame->frame.pitches[1], 310 frame->frame.pitches[1],
309 frame->sc.output_width, 311 frame->sc.output_width,
310 frame->stripe_height, 312 frame->stripe_height,
311 frame->bytes_per_line); 313 frame->bytes_per_line);
312 frame->yuv_stride = frame->bytes_per_line; 314 frame->yuv_stride = frame->bytes_per_line;
313 break; 315 break;
314 } 316 }
315#ifdef LOG 317#ifdef LOG
316 fprintf (stderr, "nullvideo: colorspace converter configured.\n"); 318 fprintf (stderr, "nullvideo: colorspace converter configured.\n");
317#endif 319#endif
318 } 320 }
319 321
320 /* 322 /*
321 * reset dest pointers 323 * reset dest pointers
322 */ 324 */
323 325
324 if (frame->data) { 326 if (frame->data) {
325 switch (flags) { 327 switch (flags) {
326 case VO_TOP_FIELD: 328 case VO_TOP_FIELD:
327 frame->rgb_dst = (uint8_t *)frame->data; 329 frame->rgb_dst = (uint8_t *)frame->data;
328 frame->stripe_inc = 2 * frame->stripe_height * frame->bytes_per_line; 330 frame->stripe_inc = 2 * frame->stripe_height * frame->bytes_per_line;
329 break; 331 break;
330 case VO_BOTTOM_FIELD: 332 case VO_BOTTOM_FIELD:
331 frame->rgb_dst = (uint8_t *)frame->data + frame->bytes_per_line ; 333 frame->rgb_dst = (uint8_t *)frame->data + frame->bytes_per_line ;
332 frame->stripe_inc = 2 * frame->stripe_height * frame->bytes_per_line; 334 frame->stripe_inc = 2 * frame->stripe_height * frame->bytes_per_line;
333 break; 335 break;
334 case VO_BOTH_FIELDS: 336 case VO_BOTH_FIELDS:
335 frame->rgb_dst = (uint8_t *)frame->data; 337 frame->rgb_dst = (uint8_t *)frame->data;
336 frame->stripe_inc = frame->stripe_height * frame->bytes_per_line; 338 frame->stripe_inc = frame->stripe_height * frame->bytes_per_line;
337 break; 339 break;
338 } 340 }
339 } 341 }
340} 342}
341 343
342static void null_display_frame( vo_driver_t* self, vo_frame_t *frame_gen ){ 344static void null_display_frame( vo_driver_t* self, vo_frame_t *frame_gen ){
343 null_driver_t* this = (null_driver_t*) self; 345 null_driver_t* this = (null_driver_t*) self;
344 opie_frame_t* frame = (opie_frame_t*)frame_gen; 346 opie_frame_t* frame = (opie_frame_t*)frame_gen;
345 display_xine_frame_t display = this->frameDis; 347 display_xine_frame_t display = this->frameDis;
346 348
347 if (!this->m_show_video) 349 if (!this->m_show_video)
348 return; 350 return;
349 351
350 if( display != NULL ) { 352 if( display != NULL ) {
351 (*display)(this->caller, frame->data, 353 (*display)(this->caller, frame->data,
352 frame->sc.output_width, frame->sc.output_height, 354 frame->sc.output_width, frame->sc.output_height,
353 frame->bytes_per_line ); 355 frame->bytes_per_line );
354 } 356 }
355 357
356 frame->frame.displayed (&frame->frame); 358 frame->frame.displayed (&frame->frame);
357} 359}
358 360
359 361
360/* blending related */ 362/* blending related */
361static void null_overlay_clut_yuv2rgb (null_driver_t *this, 363static void null_overlay_clut_yuv2rgb (null_driver_t *this,
362 vo_overlay_t *overlay, 364 vo_overlay_t *overlay,
363 opie_frame_t *frame) { 365 opie_frame_t *frame) {
364 int i; 366 int i;
365 clut_t* clut = (clut_t*) overlay->color; 367 clut_t* clut = (clut_t*) overlay->color;
366 if (!overlay->rgb_clut) { 368 if (!overlay->rgb_clut) {
367 for (i = 0; i < sizeof(overlay->color)/sizeof(overlay->color[0]); i++) { 369 for (i = 0; i < sizeof(overlay->color)/sizeof(overlay->color[0]); i++) {
368 *((uint32_t *)&clut[i]) = 370 *((uint32_t *)&clut[i]) =
369 frame->yuv2rgb->yuv2rgb_single_pixel_fun (frame->yuv2rgb, 371 frame->yuv2rgb->yuv2rgb_single_pixel_fun (frame->yuv2rgb,
370 clut[i].y, clut[i].cb, clut[i].cr); 372 clut[i].y, clut[i].cb, clut[i].cr);
371 } 373 }
372 overlay->rgb_clut++; 374 overlay->rgb_clut++;
373 } 375 }
374 if (!overlay->clip_rgb_clut) { 376 if (!overlay->clip_rgb_clut) {
375 clut = (clut_t*) overlay->clip_color; 377 clut = (clut_t*) overlay->clip_color;
376 for (i = 0; i < sizeof(overlay->color)/sizeof(overlay->color[0]); i++) { 378 for (i = 0; i < sizeof(overlay->color)/sizeof(overlay->color[0]); i++) {
377 *((uint32_t *)&clut[i]) = 379 *((uint32_t *)&clut[i]) =
378 frame->yuv2rgb->yuv2rgb_single_pixel_fun(frame->yuv2rgb, 380 frame->yuv2rgb->yuv2rgb_single_pixel_fun(frame->yuv2rgb,
379 clut[i].y, clut[i].cb, clut[i].cr); 381 clut[i].y, clut[i].cb, clut[i].cr);
380 } 382 }
381 overlay->clip_rgb_clut++; 383 overlay->clip_rgb_clut++;
382 } 384 }
383} 385}
384 386
385static void null_overlay_blend ( vo_driver_t *this_gen, vo_frame_t *frame_gen, vo_overlay_t *overlay) { 387static void null_overlay_blend ( vo_driver_t *this_gen, vo_frame_t *frame_gen, vo_overlay_t *overlay) {
386 null_driver_t *this = (null_driver_t *) this_gen; 388 null_driver_t *this = (null_driver_t *) this_gen;
387 opie_frame_t *frame = (opie_frame_t *) frame_gen; 389 opie_frame_t *frame = (opie_frame_t *) frame_gen;
388 390
389 if(!this->m_show_video || frame->sc.output_width == 0 391 if(!this->m_show_video || frame->sc.output_width == 0
390 || frame->sc.output_height== 0) 392 || frame->sc.output_height== 0)
391 return; 393 return;
392 394
393 /* Alpha Blend here */ 395 /* Alpha Blend here */
394 if (overlay->rle) { 396 if (overlay->rle) {
395 if( !overlay->rgb_clut || !overlay->clip_rgb_clut) 397 if( !overlay->rgb_clut || !overlay->clip_rgb_clut)
396 null_overlay_clut_yuv2rgb(this,overlay,frame); 398 null_overlay_clut_yuv2rgb(this,overlay,frame);
397 399
398 switch(this->bpp) { 400 switch(this->bpp) {
399 case 16: 401 case 16:
400 blend_rgb16( (uint8_t *)frame->data, overlay, 402 blend_rgb16( (uint8_t *)frame->data, overlay,
401 frame->sc.output_width, frame->sc.output_height, 403 frame->sc.output_width, frame->sc.output_height,
402 frame->sc.delivered_width, frame->sc.delivered_height); 404 frame->sc.delivered_width, frame->sc.delivered_height);
403 break; 405 break;
404 case 24: 406 case 24:
405 blend_rgb24( (uint8_t *)frame->data, overlay, 407 blend_rgb24( (uint8_t *)frame->data, overlay,
406 frame->sc.output_width, frame->sc.output_height, 408 frame->sc.output_width, frame->sc.output_height,
407 frame->sc.delivered_width, frame->sc.delivered_height); 409 frame->sc.delivered_width, frame->sc.delivered_height);
408 break; 410 break;
409 case 32: 411 case 32:
410 blend_rgb32( (uint8_t *)frame->data, overlay, 412 blend_rgb32( (uint8_t *)frame->data, overlay,
411 frame->sc.output_width, frame->sc.output_height, 413 frame->sc.output_width, frame->sc.output_height,
412 frame->sc.delivered_width, frame->sc.delivered_height); 414 frame->sc.delivered_width, frame->sc.delivered_height);
413 break; 415 break;
414 default: 416 default:
415 /* It should never get here */ 417 /* It should never get here */
416 break; 418 break;
417 } 419 }
418 } 420 }
419} 421}
420 422
421 423
422static int null_get_property( vo_driver_t* self, 424static int null_get_property( vo_driver_t* self,
423 int property ){ 425 int property ){
424 return 0; 426 return 0;
425} 427}
426static int null_set_property( vo_driver_t* self, 428static int null_set_property( vo_driver_t* self,
427 int property, 429 int property,
428 int value ){ 430 int value ){
429 return value; 431 return value;
430} 432}
431static void null_get_property_min_max( vo_driver_t* self, 433static void null_get_property_min_max( vo_driver_t* self,
432 int property, int *min, 434 int property, int *min,
433 int *max ){ 435 int *max ){
434 *max = 0; 436 *max = 0;
435 *min = 0; 437 *min = 0;
436} 438}
437static int null_gui_data_exchange( vo_driver_t* self, 439static int null_gui_data_exchange( vo_driver_t* self,
438 int data_type, 440 int data_type,
439 void *data ){ 441 void *data ){
440 return 0; 442 return 0;
441} 443}
442 444
443static void null_dispose ( vo_driver_t* self ){ 445static void null_dispose ( vo_driver_t* self ){
444 null_driver_t* this = (null_driver_t*)self; 446 null_driver_t* this = (null_driver_t*)self;
445 free ( this ); 447 free ( this );
446} 448}
447static int null_redraw_needed( vo_driver_t* self ){ 449static int null_redraw_needed( vo_driver_t* self ){
448 return 0; 450 return 0;
449} 451}
450 452
451 453
452xine_vo_driver_t* init_video_out_plugin( xine_t *xine, 454xine_vo_driver_t* init_video_out_plugin( xine_t *xine,
453 void* video, display_xine_frame_t frameDisplayFunc, void *userData ){ 455 void* video, display_xine_frame_t frameDisplayFunc, void *userData ){
454 null_driver_t *vo; 456 null_driver_t *vo;
455 vo = (null_driver_t*)malloc( sizeof(null_driver_t ) ); 457 vo = (null_driver_t*)malloc( sizeof(null_driver_t ) );
456 458
457 /* memset? */ 459 /* memset? */
458 memset(vo,0, sizeof(null_driver_t ) ); 460 memset(vo,0, sizeof(null_driver_t ) );
459 461
460 vo_scale_init (&vo->sc, 0, 0, xine->config); 462 vo_scale_init (&vo->sc, 0, 0, xine->config);
461 463
462 vo->sc.gui_pixel_aspect = 1.0; 464 vo->sc.gui_pixel_aspect = 1.0;
463 465
464 vo->m_show_video = 0; // false 466 vo->m_show_video = 0; // false
465 vo->m_video_fullscreen = 0; 467 vo->m_video_fullscreen = 0;
466 vo->m_is_scaling = 0; 468 vo->m_is_scaling = 0;
467 vo->display_ratio = 1.0; 469 vo->display_ratio = 1.0;
468 vo->gui_width = 16; 470 vo->gui_width = 16;
469 vo->gui_height = 8; 471 vo->gui_height = 8;
470 vo->frameDis = NULL; 472 vo->frameDis = NULL;
471 473
472 /* install callback handlers*/ 474 /* install callback handlers*/
473 vo->vo_driver.get_capabilities = null_get_capabilities; 475 vo->vo_driver.get_capabilities = null_get_capabilities;
474 vo->vo_driver.alloc_frame = null_alloc_frame; 476 vo->vo_driver.alloc_frame = null_alloc_frame;
475 vo->vo_driver.update_frame_format = null_update_frame_format; 477 vo->vo_driver.update_frame_format = null_update_frame_format;
476 vo->vo_driver.display_frame = null_display_frame; 478 vo->vo_driver.display_frame = null_display_frame;
477 vo->vo_driver.overlay_blend = null_overlay_blend; 479 vo->vo_driver.overlay_blend = null_overlay_blend;
478 vo->vo_driver.get_property = null_get_property; 480 vo->vo_driver.get_property = null_get_property;
479 vo->vo_driver.set_property = null_set_property; 481 vo->vo_driver.set_property = null_set_property;
480 vo->vo_driver.get_property_min_max = null_get_property_min_max; 482 vo->vo_driver.get_property_min_max = null_get_property_min_max;
481 vo->vo_driver.gui_data_exchange = null_gui_data_exchange; 483 vo->vo_driver.gui_data_exchange = null_gui_data_exchange;
482 vo->vo_driver.dispose = null_dispose; 484 vo->vo_driver.dispose = null_dispose;
483 vo->vo_driver.redraw_needed = null_redraw_needed; 485 vo->vo_driver.redraw_needed = null_redraw_needed;
484 486
485 487
486 /* capabilities */ 488 /* capabilities */
487 vo->m_capabilities = VO_CAP_COPIES_IMAGE | VO_CAP_YUY2 | VO_CAP_YV12; 489 vo->m_capabilities = VO_CAP_COPIES_IMAGE | VO_CAP_YUY2 | VO_CAP_YV12;
488 vo->yuv2rgb_factory = yuv2rgb_factory_init (MODE_16_RGB, vo->yuv2rgb_swap, 490 vo->yuv2rgb_factory = yuv2rgb_factory_init (MODE_16_RGB, vo->yuv2rgb_swap,
489 vo->yuv2rgb_cmap); 491 vo->yuv2rgb_cmap);
490 492
491 vo->caller = userData; 493 vo->caller = userData;
492 vo->frameDis = frameDisplayFunc; 494 vo->frameDis = frameDisplayFunc;
493 495
494 /* return ( vo_driver_t*) vo; */ 496 /* return ( vo_driver_t*) vo; */
495 return vo_new_port( xine, ( vo_driver_t* )vo ); 497 return vo_new_port( xine, ( vo_driver_t* )vo );
496} 498}
497 499
498#if 0 500#if 0
499static vo_info_t vo_info_null = { 501static vo_info_t vo_info_null = {
500 5, 502 5,
501 XINE_VISUAL_TYPE_FB 503 XINE_VISUAL_TYPE_FB
502}; 504};
503 505
504vo_info_t *get_video_out_plugin_info(){ 506vo_info_t *get_video_out_plugin_info(){
505 vo_info_null.description = ("xine video output plugin using null device"); 507 vo_info_null.description = ("xine video output plugin using null device");
506 return &vo_info_null; 508 return &vo_info_null;
507} 509}
508 510
509#endif 511#endif
510 512
511/* this is special for this device */ 513/* this is special for this device */
512/** 514/**
513 * We know that we will be controled by the XINE LIB++ 515 * We know that we will be controled by the XINE LIB++
514 */ 516 */
515 517
516/** 518/**
517 * 519 *
518 */ 520 */
519int null_is_showing_video( xine_vo_driver_t* self ){ 521int null_is_showing_video( xine_vo_driver_t* self ){
520 null_driver_t* this = (null_driver_t*)self->driver; 522 null_driver_t* this = (null_driver_t*)self->driver;
521 return this->m_show_video; 523 return this->m_show_video;
522} 524}
523void null_set_show_video( xine_vo_driver_t* self, int show ) { 525void null_set_show_video( xine_vo_driver_t* self, int show ) {
524 ((null_driver_t*)self->driver)->m_show_video = show; 526 ((null_driver_t*)self->driver)->m_show_video = show;
525} 527}
526 528
527int null_is_fullscreen( xine_vo_driver_t* self ){ 529int null_is_fullscreen( xine_vo_driver_t* self ){
528 return ((null_driver_t*)self->driver)->m_video_fullscreen; 530 return ((null_driver_t*)self->driver)->m_video_fullscreen;
529} 531}
530void null_set_fullscreen( xine_vo_driver_t* self, int screen ){ 532void null_set_fullscreen( xine_vo_driver_t* self, int screen ){
531 ((null_driver_t*)self->driver)->m_video_fullscreen = screen; 533 ((null_driver_t*)self->driver)->m_video_fullscreen = screen;
532} 534}
533int null_is_scaling( xine_vo_driver_t* self ){ 535int null_is_scaling( xine_vo_driver_t* self ){
534 return ((null_driver_t*)self->driver)->m_is_scaling; 536 return ((null_driver_t*)self->driver)->m_is_scaling;
535} 537}
536 538
537void null_set_videoGamma( xine_vo_driver_t* self , int value ) { 539void null_set_videoGamma( xine_vo_driver_t* self , int value ) {
538 ((null_driver_t*) self->driver) ->yuv2rgb_gamma = value; 540 ((null_driver_t*) self->driver) ->yuv2rgb_gamma = value;
539 ((null_driver_t*) self->driver) ->yuv2rgb_factory->set_gamma( ((null_driver_t*) self->driver) ->yuv2rgb_factory, value ); 541 ((null_driver_t*) self->driver) ->yuv2rgb_factory->set_gamma( ((null_driver_t*) self->driver) ->yuv2rgb_factory, value );
540} 542}
541 543
542void null_set_scaling( xine_vo_driver_t* self, int scale ) { 544void null_set_scaling( xine_vo_driver_t* self, int scale ) {
543 ((null_driver_t*)self->driver)->m_is_scaling = scale; 545 ((null_driver_t*)self->driver)->m_is_scaling = scale;
544} 546}
545 547
546void null_set_gui_width( xine_vo_driver_t* self, int width ) { 548void null_set_gui_width( xine_vo_driver_t* self, int width ) {
547 ((null_driver_t*)self->driver)->gui_width = width; 549 ((null_driver_t*)self->driver)->gui_width = width;
548} 550}
549void null_set_gui_height( xine_vo_driver_t* self, int height ) { 551void null_set_gui_height( xine_vo_driver_t* self, int height ) {
550 ((null_driver_t*)self->driver)->gui_height = height; 552 ((null_driver_t*)self->driver)->gui_height = height;
551} 553}
552 554
553 555
554void null_set_mode( xine_vo_driver_t* self, int depth, int rgb ) { 556void null_set_mode( xine_vo_driver_t* self, int depth, int rgb ) {
555 null_driver_t* this = (null_driver_t*)self->driver; 557 null_driver_t* this = (null_driver_t*)self->driver;
556 558
557 this->bytes_per_pixel = (depth + 7 ) / 8; 559 this->bytes_per_pixel = (depth + 7 ) / 8;
558 this->bpp = this->bytes_per_pixel * 8; 560 this->bpp = this->bytes_per_pixel * 8;
559 this->depth = depth; 561 this->depth = depth;
560 printf("depth %d %d\n", depth, this->bpp); 562 printf("depth %d %d\n", depth, this->bpp);
561 printf("pixeltype %d\n", rgb ); 563 printf("pixeltype %d\n", rgb );
562 switch ( this->depth ) { 564 switch ( this->depth ) {
563 case 32: 565 case 32:
564 if( rgb == 0 ) 566 if( rgb == 0 )
565 this->yuv2rgb_mode = MODE_32_RGB; 567 this->yuv2rgb_mode = MODE_32_RGB;
566 else 568 else
567 this->yuv2rgb_mode = MODE_32_BGR; 569 this->yuv2rgb_mode = MODE_32_BGR;
568 case 24: 570 case 24:
569 if( this->bpp == 32 ) { 571 if( this->bpp == 32 ) {
570 if( rgb == 0 ) { 572 if( rgb == 0 ) {
571 this->yuv2rgb_mode = MODE_32_RGB; 573 this->yuv2rgb_mode = MODE_32_RGB;
572 } else { 574 } else {
573 this->yuv2rgb_mode = MODE_32_BGR; 575 this->yuv2rgb_mode = MODE_32_BGR;
574 } 576 }
575 }else{ 577 }else{
576 if( rgb == 0 ) 578 if( rgb == 0 )
577 this->yuv2rgb_mode = MODE_24_RGB; 579 this->yuv2rgb_mode = MODE_24_RGB;
578 else 580 else
579 this->yuv2rgb_mode = MODE_24_BGR; 581 this->yuv2rgb_mode = MODE_24_BGR;
580 }; 582 };
581 break; 583 break;
582 case 16: 584 case 16:
583 if( rgb == 0 ) { 585 if( rgb == 0 ) {
584 this->yuv2rgb_mode = MODE_16_RGB; 586 this->yuv2rgb_mode = MODE_16_RGB;
585 } else { 587 } else {
586 this->yuv2rgb_mode = MODE_16_BGR; 588 this->yuv2rgb_mode = MODE_16_BGR;
587 } 589 }
588 break; 590 break;
589 case 15: 591 case 15:
590 if( rgb == 0 ) { 592 if( rgb == 0 ) {
591 this->yuv2rgb_mode = MODE_15_RGB; 593 this->yuv2rgb_mode = MODE_15_RGB;
592 } else { 594 } else {
593 this->yuv2rgb_mode = MODE_15_BGR; 595 this->yuv2rgb_mode = MODE_15_BGR;
594 } 596 }
595 break; 597 break;
596 case 8: 598 case 8:
597 if( rgb == 0 ) { 599 if( rgb == 0 ) {
598 this->yuv2rgb_mode = MODE_8_RGB; 600 this->yuv2rgb_mode = MODE_8_RGB;
599 } else { 601 } else {
600 this->yuv2rgb_mode = MODE_8_BGR; 602 this->yuv2rgb_mode = MODE_8_BGR;
601 } 603 }
602 break; 604 break;
603 }; 605 };
604 //free(this->yuv2rgb_factory ); 606 //free(this->yuv2rgb_factory );
605 // this->yuv2rgb_factory = yuv2rgb_factory_init (this->yuv2rgb_mode, this->yuv2rgb_swap, 607 // this->yuv2rgb_factory = yuv2rgb_factory_init (this->yuv2rgb_mode, this->yuv2rgb_swap,
606 // this->yuv2rgb_cmap); 608 // this->yuv2rgb_cmap);
607}; 609};
608 610
609void null_display_handler( xine_vo_driver_t* self, display_xine_frame_t t, 611void null_display_handler( xine_vo_driver_t* self, display_xine_frame_t t,
610 void* user_data ) { 612 void* user_data ) {
611 null_driver_t* this = (null_driver_t*) self->driver; 613 null_driver_t* this = (null_driver_t*) self->driver;
612 this->caller = user_data; 614 this->caller = user_data;
613 this->frameDis = t; 615 this->frameDis = t;
614} 616}
615 617
616void null_preload_decoders( xine_stream_t *stream ) 618void null_preload_decoders( xine_stream_t *stream )
617{ 619{
618 static const uint32_t preloadedAudioDecoders[] = { BUF_AUDIO_MPEG, BUF_AUDIO_VORBIS }; 620 static const uint32_t preloadedAudioDecoders[] = { BUF_AUDIO_MPEG, BUF_AUDIO_VORBIS };
619 static const uint8_t preloadedAudioDecoderCount = sizeof( preloadedAudioDecoders ) / sizeof( preloadedAudioDecoders[ 0 ] ); 621 static const uint8_t preloadedAudioDecoderCount = sizeof( preloadedAudioDecoders ) / sizeof( preloadedAudioDecoders[ 0 ] );
620 static const uint32_t preloadedVideoDecoders[] = { BUF_VIDEO_MPEG, BUF_VIDEO_MPEG4, BUF_VIDEO_DIVX5 }; 622 static const uint32_t preloadedVideoDecoders[] = { BUF_VIDEO_MPEG, BUF_VIDEO_MPEG4, BUF_VIDEO_DIVX5 };
621 static const uint8_t preloadedVideoDecoderCount = sizeof( preloadedVideoDecoders ) / sizeof( preloadedVideoDecoders[ 0 ] ); 623 static const uint8_t preloadedVideoDecoderCount = sizeof( preloadedVideoDecoders ) / sizeof( preloadedVideoDecoders[ 0 ] );
622 624
623 uint8_t i; 625 uint8_t i;
624 626
625 for ( i = 0; i < preloadedAudioDecoderCount; ++i ) { 627 for ( i = 0; i < preloadedAudioDecoderCount; ++i ) {
626 audio_decoder_t *decoder = get_audio_decoder( stream, ( preloadedAudioDecoders[ i ] >> 16 ) & 0xff ); 628 audio_decoder_t *decoder = get_audio_decoder( stream, ( preloadedAudioDecoders[ i ] >> 16 ) & 0xff );
627/* free_audio_decoder( stream, decoder ); */ 629/* free_audio_decoder( stream, decoder ); */
628 } 630 }
629 631
630 for ( i = 0; i < preloadedVideoDecoderCount; ++i ) { 632 for ( i = 0; i < preloadedVideoDecoderCount; ++i ) {
631 video_decoder_t *decoder = get_video_decoder( stream, ( preloadedVideoDecoders[ i ] >> 16 ) & 0xff ); 633 video_decoder_t *decoder = get_video_decoder( stream, ( preloadedVideoDecoders[ i ] >> 16 ) & 0xff );
632/* free_video_decoder( stream, decoder ); */ 634/* free_video_decoder( stream, decoder ); */
633 } 635 }
634} 636}
635 637
diff --git a/noncore/multimedia/opieplayer2/yuv2rgb.c b/noncore/multimedia/opieplayer2/yuv2rgb.c
index e8e86e6..8e34052 100644
--- a/noncore/multimedia/opieplayer2/yuv2rgb.c
+++ b/noncore/multimedia/opieplayer2/yuv2rgb.c
@@ -1,2750 +1,2750 @@
1/* 1/*
2 * yuv2rgb.c 2 * yuv2rgb.c
3 * 3 *
4 * This file is part of xine, a unix video player. 4 * This file is part of xine, a unix video player.
5 * 5 *
6 * based on work from mpeg2dec: 6 * based on work from mpeg2dec:
7 * Copyright (C) 1999-2001 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> 7 * Copyright (C) 1999-2001 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
8 * 8 *
9 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. 9 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
10 * 10 *
11 * mpeg2dec is free software; you can redistribute it and/or modify 11 * mpeg2dec 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 * mpeg2dec is distributed in the hope that it will be useful, 16 * mpeg2dec 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * 24 *
25 * $Id$ 25 * $Id$
26 */ 26 */
27 27
28#include <stdio.h> 28#include <stdio.h>
29#include <stdlib.h> 29#include <stdlib.h>
30#include <string.h> 30#include <string.h>
31#include <inttypes.h> 31#include <inttypes.h>
32 32
33#include "yuv2rgb.h" 33#include "yuv2rgb.h"
34#include <xine/xineutils.h> 34#include <xine/xineutils.h>
35 35
36 36
37static int prof_scale_line = -1; 37static int prof_scale_line = -1;
38 38
39static scale_line_func_t find_scale_line_func(int step); 39static scale_line_func_t find_scale_line_func(int step);
40 40
41 41
42const int32_t Inverse_Table_6_9[8][4] = { 42const int32_t Inverse_Table_6_9[8][4] = {
43 {117504, 138453, 13954, 34903}, /* no sequence_display_extension */ 43 {117504, 138453, 13954, 34903}, /* no sequence_display_extension */
44 {117504, 138453, 13954, 34903}, /* ITU-R Rec. 709 (1990) */ 44 {117504, 138453, 13954, 34903}, /* ITU-R Rec. 709 (1990) */
45 {104597, 132201, 25675, 53279}, /* unspecified */ 45 {104597, 132201, 25675, 53279}, /* unspecified */
46 {104597, 132201, 25675, 53279}, /* reserved */ 46 {104597, 132201, 25675, 53279}, /* reserved */
47 {104448, 132798, 24759, 53109}, /* FCC */ 47 {104448, 132798, 24759, 53109}, /* FCC */
48 {104597, 132201, 25675, 53279}, /* ITU-R Rec. 624-4 System B, G */ 48 {104597, 132201, 25675, 53279}, /* ITU-R Rec. 624-4 System B, G */
49 {104597, 132201, 25675, 53279}, /* SMPTE 170M */ 49 {104597, 132201, 25675, 53279}, /* SMPTE 170M */
50 {117579, 136230, 16907, 35559} /* SMPTE 240M (1987) */ 50 {117579, 136230, 16907, 35559} /* SMPTE 240M (1987) */
51}; 51};
52 52
53 53
54static void *my_malloc_aligned (size_t alignment, size_t size, void **chunk) { 54static void *my_malloc_aligned (size_t alignment, size_t size, void **chunk) {
55 55
56 char *pMem; 56 char *pMem;
57 57
58 pMem = xine_xmalloc (size+alignment); 58 pMem = xine_xmalloc (size+alignment);
59 59
60 *chunk = pMem; 60 *chunk = pMem;
61 61
62 while ((int) pMem % alignment) 62 while ((int) pMem % alignment)
63 pMem++; 63 pMem++;
64 64
65 return pMem; 65 return pMem;
66} 66}
67 67
68 68
69static int yuv2rgb_configure (yuv2rgb_t *this, 69static int yuv2rgb_configure (yuv2rgb_t *this,
70 int source_width, int source_height, 70 int source_width, int source_height,
71 int y_stride, int uv_stride, 71 int y_stride, int uv_stride,
72 int dest_width, int dest_height, 72 int dest_width, int dest_height,
73 int rgb_stride) { 73 int rgb_stride) {
74 /* 74 /*
75 printf ("yuv2rgb setup (%d x %d => %d x %d)\n", source_width, source_height, 75 printf ("yuv2rgb setup (%d x %d => %d x %d)\n", source_width, source_height,
76 dest_width, dest_height); 76 dest_width, dest_height);
77 */ 77 */
78 if (prof_scale_line == -1) 78 if (prof_scale_line == -1)
79 prof_scale_line = xine_profiler_allocate_slot("xshm scale line"); 79 prof_scale_line = xine_profiler_allocate_slot("xshm scale line");
80 80
81 this->source_width = source_width; 81 this->source_width = source_width;
82 this->source_height = source_height; 82 this->source_height = source_height;
83 this->y_stride = y_stride; 83 this->y_stride = y_stride;
84 this->uv_stride = uv_stride; 84 this->uv_stride = uv_stride;
85 this->dest_width = dest_width; 85 this->dest_width = dest_width;
86 this->dest_height = dest_height; 86 this->dest_height = dest_height;
87 this->rgb_stride = rgb_stride; 87 this->rgb_stride = rgb_stride;
88 88
89 if (this->y_chunk) { 89 if (this->y_chunk) {
90 free (this->y_chunk); 90 free (this->y_chunk);
91 this->y_buffer = this->y_chunk = NULL; 91 this->y_buffer = this->y_chunk = NULL;
92 } 92 }
93 if (this->u_chunk) { 93 if (this->u_chunk) {
94 free (this->u_chunk); 94 free (this->u_chunk);
95 this->u_buffer = this->u_chunk = NULL; 95 this->u_buffer = this->u_chunk = NULL;
96 } 96 }
97 if (this->v_chunk) { 97 if (this->v_chunk) {
98 free (this->v_chunk); 98 free (this->v_chunk);
99 this->v_buffer = this->v_chunk = NULL; 99 this->v_buffer = this->v_chunk = NULL;
100 } 100 }
101 101
102 102
103 this->step_dx = source_width * 32768 / dest_width; 103 this->step_dx = source_width * 32768 / dest_width;
104 this->step_dy = source_height * 32768 / dest_height; 104 this->step_dy = source_height * 32768 / dest_height;
105 105
106 this->scale_line = find_scale_line_func(this->step_dx); 106 this->scale_line = find_scale_line_func(this->step_dx);
107 107
108 if ((source_width == dest_width) && (source_height == dest_height)) { 108 if ((source_width == dest_width) && (source_height == dest_height)) {
109 this->do_scale = 0; 109 this->do_scale = 0;
110 110
111 /* 111 /*
112 * space for two y-lines (for yuv2rgb_mlib) 112 * space for two y-lines (for yuv2rgb_mlib)
113 * u,v subsampled 2:1 113 * u,v subsampled 2:1
114 */ 114 */
115 this->y_buffer = my_malloc_aligned (16, 2*dest_width, &this->y_chunk); 115 this->y_buffer = my_malloc_aligned (16, 2*dest_width, &this->y_chunk);
116 if (!this->y_buffer) 116 if (!this->y_buffer)
117 return 0; 117 return 0;
118 this->u_buffer = my_malloc_aligned (16, (dest_width+1)/2, &this->u_chunk); 118 this->u_buffer = my_malloc_aligned (16, (dest_width+1)/2, &this->u_chunk);
119 if (!this->u_buffer) 119 if (!this->u_buffer)
120 return 0; 120 return 0;
121 this->v_buffer = my_malloc_aligned (16, (dest_width+1)/2, &this->v_chunk); 121 this->v_buffer = my_malloc_aligned (16, (dest_width+1)/2, &this->v_chunk);
122 if (!this->v_buffer) 122 if (!this->v_buffer)
123 return 0; 123 return 0;
124 124
125 } else { 125 } else {
126 this->do_scale = 1; 126 this->do_scale = 1;
127 127
128 /* 128 /*
129 * space for two y-lines (for yuv2rgb_mlib) 129 * space for two y-lines (for yuv2rgb_mlib)
130 * u,v subsampled 2:1 130 * u,v subsampled 2:1
131 */ 131 */
132 this->y_buffer = my_malloc_aligned (16, 2*dest_width, &this->y_chunk); 132 this->y_buffer = my_malloc_aligned (16, 2*dest_width, &this->y_chunk);
133 if (!this->y_buffer) 133 if (!this->y_buffer)
134 return 0; 134 return 0;
135 this->u_buffer = my_malloc_aligned (16, (dest_width+1)/2, &this->u_chunk); 135 this->u_buffer = my_malloc_aligned (16, (dest_width+1)/2, &this->u_chunk);
136 if (!this->u_buffer) 136 if (!this->u_buffer)
137 return 0; 137 return 0;
138 this->v_buffer = my_malloc_aligned (16, (dest_width+1)/2, &this->v_chunk); 138 this->v_buffer = my_malloc_aligned (16, (dest_width+1)/2, &this->v_chunk);
139 if (!this->v_buffer) 139 if (!this->v_buffer)
140 return 0; 140 return 0;
141 } 141 }
142 return 1; 142 return 1;
143} 143}
144 144
145 145
146static void scale_line_gen (uint8_t *source, uint8_t *dest, 146static void scale_line_gen (uint8_t *source, uint8_t *dest,
147 int width, int step) { 147 int width, int step) {
148 148
149 /* 149 /*
150 * scales a yuv source row to a dest row, with interpolation 150 * scales a yuv source row to a dest row, with interpolation
151 * (good quality, but slow) 151 * (good quality, but slow)
152 */ 152 */
153 int p1; 153 int p1;
154 int p2; 154 int p2;
155 int dx; 155 int dx;
156 156
157 xine_profiler_start_count(prof_scale_line); 157 xine_profiler_start_count(prof_scale_line);
158 158
159 p1 = *source++; 159 p1 = *source++;
160 p2 = *source++; 160 p2 = *source++;
161 dx = 0; 161 dx = 0;
162 162
163 /* 163 /*
164 * the following code has been optimized by Scott Smith <ssmith@akamai.com>: 164 * the following code has been optimized by Scott Smith <ssmith@akamai.com>:
165 * 165 *
166 * ok now I have a meaningful optimization for yuv2rgb.c:scale_line_gen. 166 * ok now I have a meaningful optimization for yuv2rgb.c:scale_line_gen.
167 * it removes the loop from within the while() loop by separating it out 167 * it removes the loop from within the while() loop by separating it out
168 * into 3 cases: where you are enlarging the line (<32768), where you are 168 * into 3 cases: where you are enlarging the line (<32768), where you are
169 * between 50% and 100% of the original line (<=65536), and where you are 169 * between 50% and 100% of the original line (<=65536), and where you are
170 * shrinking it by a lot. anyways, I went from 200 delivered / 100+ 170 * shrinking it by a lot. anyways, I went from 200 delivered / 100+
171 * skipped to 200 delivered / 80 skipped for the enlarging case. I 171 * skipped to 200 delivered / 80 skipped for the enlarging case. I
172 * noticed when looking at the assembly that the compiler was able to 172 * noticed when looking at the assembly that the compiler was able to
173 * unroll these while(width) loops, whereas before it was trying to 173 * unroll these while(width) loops, whereas before it was trying to
174 * unroll the while(dx>32768) loops. so the compiler is better able to 174 * unroll the while(dx>32768) loops. so the compiler is better able to
175 * deal with this code. 175 * deal with this code.
176 */ 176 */
177 177
178 178
179 if (step < 32768) { 179 if (step < 32768) {
180 while (width) { 180 while (width) {
181 *dest = p1 + (((p2-p1) * dx)>>15); 181 *dest = p1 + (((p2-p1) * dx)>>15);
182 182
183 dx += step; 183 dx += step;
184 if (dx > 32768) { 184 if (dx > 32768) {
185 dx -= 32768; 185 dx -= 32768;
186 p1 = p2; 186 p1 = p2;
187 p2 = *source++; 187 p2 = *source++;
188 } 188 }
189 189
190 dest ++; 190 dest ++;
191 width --; 191 width --;
192 } 192 }
193 } else if (step <= 65536) { 193 } else if (step <= 65536) {
194 while (width) { 194 while (width) {
195 *dest = p1 + (((p2-p1) * dx)>>15); 195 *dest = p1 + (((p2-p1) * dx)>>15);
196 196
197 dx += step; 197 dx += step;
198 if (dx > 65536) { 198 if (dx > 65536) {
199 dx -= 65536; 199 dx -= 65536;
200 p1 = *source++; 200 p1 = *source++;
201 p2 = *source++; 201 p2 = *source++;
202 } else { 202 } else {
203 dx -= 32768; 203 dx -= 32768;
204 p1 = p2; 204 p1 = p2;
205 p2 = *source++; 205 p2 = *source++;
206 } 206 }
207 207
208 dest ++; 208 dest ++;
209 width --; 209 width --;
210 } 210 }
211 } else { 211 } else {
212 while (width) { 212 while (width) {
213 int offs; 213 int offs;
214 214
215 *dest = p1 + (((p2-p1) * dx)>>15); 215 *dest = p1 + (((p2-p1) * dx)>>15);
216 216
217 dx += step; 217 dx += step;
218 offs=((dx-1)>>15); 218 offs=((dx-1)>>15);
219 dx-=offs<<15; 219 dx-=offs<<15;
220 source+=offs-2; 220 source+=offs-2;
221 p1=*source++; 221 p1=*source++;
222 p2=*source++; 222 p2=*source++;
223 dest ++; 223 dest ++;
224 width --; 224 width --;
225 } 225 }
226 } 226 }
227 xine_profiler_stop_count(prof_scale_line); 227 xine_profiler_stop_count(prof_scale_line);
228 228
229 229
230 230
231 231
232} 232}
233 233
234/* 234/*
235 * Interpolates 16 output pixels from 15 source pixels using shifts. 235 * Interpolates 16 output pixels from 15 source pixels using shifts.
236 * Useful for scaling a PAL mpeg2 dvd input source to 4:3 format on 236 * Useful for scaling a PAL mpeg2 dvd input source to 4:3 format on
237 * a monitor using square pixels. 237 * a monitor using square pixels.
238 * (720 x 576 ==> 768 x 576) 238 * (720 x 576 ==> 768 x 576)
239 */ 239 */
240static void scale_line_15_16 (uint8_t *source, uint8_t *dest, 240static void scale_line_15_16 (uint8_t *source, uint8_t *dest,
241 int width, int step) { 241 int width, int step) {
242 242
243 int p1, p2; 243 int p1, p2;
244 244
245 xine_profiler_start_count(prof_scale_line); 245 xine_profiler_start_count(prof_scale_line);
246 246
247 while ((width -= 16) >= 0) { 247 while ((width -= 16) >= 0) {
248 p1 = source[0]; 248 p1 = source[0];
249 dest[0] = p1; 249 dest[0] = p1;
250 p2 = source[1]; 250 p2 = source[1];
251 dest[1] = (1*p1 + 7*p2) >> 3; 251 dest[1] = (1*p1 + 7*p2) >> 3;
252 p1 = source[2]; 252 p1 = source[2];
253 dest[2] = (1*p2 + 7*p1) >> 3; 253 dest[2] = (1*p2 + 7*p1) >> 3;
254 p2 = source[3]; 254 p2 = source[3];
255 dest[3] = (1*p1 + 3*p2) >> 2; 255 dest[3] = (1*p1 + 3*p2) >> 2;
256 p1 = source[4]; 256 p1 = source[4];
257 dest[4] = (1*p2 + 3*p1) >> 2; 257 dest[4] = (1*p2 + 3*p1) >> 2;
258 p2 = source[5]; 258 p2 = source[5];
259 dest[5] = (3*p1 + 5*p2) >> 3; 259 dest[5] = (3*p1 + 5*p2) >> 3;
260 p1 = source[6]; 260 p1 = source[6];
261 dest[6] = (3*p2 + 5*p1) >> 3; 261 dest[6] = (3*p2 + 5*p1) >> 3;
262 p2 = source[7]; 262 p2 = source[7];
263 dest[7] = (1*p1 + 1*p1) >> 1; 263 dest[7] = (1*p1 + 1*p1) >> 1;
264 p1 = source[8]; 264 p1 = source[8];
265 dest[8] = (1*p2 + 1*p1) >> 1; 265 dest[8] = (1*p2 + 1*p1) >> 1;
266 p2 = source[9]; 266 p2 = source[9];
267 dest[9] = (5*p1 + 3*p2) >> 3; 267 dest[9] = (5*p1 + 3*p2) >> 3;
268 p1 = source[10]; 268 p1 = source[10];
269 dest[10] = (5*p2 + 3*p1) >> 3; 269 dest[10] = (5*p2 + 3*p1) >> 3;
270 p2 = source[11]; 270 p2 = source[11];
271 dest[11] = (3*p1 + 1*p2) >> 2; 271 dest[11] = (3*p1 + 1*p2) >> 2;
272 p1 = source[12]; 272 p1 = source[12];
273 dest[12] = (3*p2 + 1*p1) >> 2; 273 dest[12] = (3*p2 + 1*p1) >> 2;
274 p2 = source[13]; 274 p2 = source[13];
275 dest[13] = (7*p1 + 1*p2) >> 3; 275 dest[13] = (7*p1 + 1*p2) >> 3;
276 p1 = source[14]; 276 p1 = source[14];
277 dest[14] = (7*p2 + 1*p1) >> 3; 277 dest[14] = (7*p2 + 1*p1) >> 3;
278 dest[15] = p1; 278 dest[15] = p1;
279 source += 15; 279 source += 15;
280 dest += 16; 280 dest += 16;
281 } 281 }
282 282
283 if ((width += 16) <= 0) goto done; 283 if ((width += 16) <= 0) goto done;
284 *dest++ = source[0]; 284 *dest++ = source[0];
285 if (--width <= 0) goto done; 285 if (--width <= 0) goto done;
286 *dest++ = (1*source[0] + 7*source[1]) >> 3; 286 *dest++ = (1*source[0] + 7*source[1]) >> 3;
287 if (--width <= 0) goto done; 287 if (--width <= 0) goto done;
288 *dest++ = (1*source[1] + 7*source[2]) >> 3; 288 *dest++ = (1*source[1] + 7*source[2]) >> 3;
289 if (--width <= 0) goto done; 289 if (--width <= 0) goto done;
290 *dest++ = (1*source[2] + 3*source[3]) >> 2; 290 *dest++ = (1*source[2] + 3*source[3]) >> 2;
291 if (--width <= 0) goto done; 291 if (--width <= 0) goto done;
292 *dest++ = (1*source[3] + 3*source[4]) >> 2; 292 *dest++ = (1*source[3] + 3*source[4]) >> 2;
293 if (--width <= 0) goto done; 293 if (--width <= 0) goto done;
294 *dest++ = (3*source[4] + 5*source[5]) >> 3; 294 *dest++ = (3*source[4] + 5*source[5]) >> 3;
295 if (--width <= 0) goto done; 295 if (--width <= 0) goto done;
296 *dest++ = (3*source[5] + 5*source[6]) >> 3; 296 *dest++ = (3*source[5] + 5*source[6]) >> 3;
297 if (--width <= 0) goto done; 297 if (--width <= 0) goto done;
298 *dest++ = (1*source[6] + 1*source[7]) >> 1; 298 *dest++ = (1*source[6] + 1*source[7]) >> 1;
299 if (--width <= 0) goto done; 299 if (--width <= 0) goto done;
300 *dest++ = (1*source[7] + 1*source[8]) >> 1; 300 *dest++ = (1*source[7] + 1*source[8]) >> 1;
301 if (--width <= 0) goto done; 301 if (--width <= 0) goto done;
302 *dest++ = (5*source[8] + 3*source[9]) >> 3; 302 *dest++ = (5*source[8] + 3*source[9]) >> 3;
303 if (--width <= 0) goto done; 303 if (--width <= 0) goto done;
304 *dest++ = (5*source[9] + 3*source[10]) >> 3; 304 *dest++ = (5*source[9] + 3*source[10]) >> 3;
305 if (--width <= 0) goto done; 305 if (--width <= 0) goto done;
306 *dest++ = (3*source[10] + 1*source[11]) >> 2; 306 *dest++ = (3*source[10] + 1*source[11]) >> 2;
307 if (--width <= 0) goto done; 307 if (--width <= 0) goto done;
308 *dest++ = (3*source[11] + 1*source[12]) >> 2; 308 *dest++ = (3*source[11] + 1*source[12]) >> 2;
309 if (--width <= 0) goto done; 309 if (--width <= 0) goto done;
310 *dest++ = (7*source[12] + 1*source[13]) >> 3; 310 *dest++ = (7*source[12] + 1*source[13]) >> 3;
311 if (--width <= 0) goto done; 311 if (--width <= 0) goto done;
312 *dest++ = (7*source[13] + 1*source[14]) >> 3; 312 *dest++ = (7*source[13] + 1*source[14]) >> 3;
313 done: 313 done:
314 xine_profiler_stop_count(prof_scale_line); 314 xine_profiler_stop_count(prof_scale_line);
315} 315}
316 316
317 317
318/* 318/*
319 * Interpolates 53 output pixels from 45 source pixels using shifts. 319 * Interpolates 53 output pixels from 45 source pixels using shifts.
320 * Useful for scaling a NTSC mpeg2 dvd input source to 16:9 display 320 * Useful for scaling a NTSC mpeg2 dvd input source to 16:9 display
321 * resulution 321 * resulution
322 * fullscreen resolution, or to 16:9 format on a monitor using square 322 * fullscreen resolution, or to 16:9 format on a monitor using square
323 * pixels. 323 * pixels.
324 * (720 x 480 ==> 848 x 480) 324 * (720 x 480 ==> 848 x 480)
325 */ 325 */
326static void scale_line_45_53 (uint8_t *source, uint8_t *dest, 326static void scale_line_45_53 (uint8_t *source, uint8_t *dest,
327 int width, int step) { 327 int width, int step) {
328 328
329 int p1, p2; 329 int p1, p2;
330 330
331 xine_profiler_start_count(prof_scale_line); 331 xine_profiler_start_count(prof_scale_line);
332 332
333 while ((width -= 53) >= 0) { 333 while ((width -= 53) >= 0) {
334 p1 = source[0]; 334 p1 = source[0];
335 p2 = source[1]; 335 p2 = source[1];
336 dest[0] = p1; 336 dest[0] = p1;
337 dest[1] = (1*p1 + 7*p2) >> 3; 337 dest[1] = (1*p1 + 7*p2) >> 3;
338 p1 = source[2]; 338 p1 = source[2];
339 dest[2] = (1*p2 + 3*p1) >> 2; 339 dest[2] = (1*p2 + 3*p1) >> 2;
340 p2 = source[3]; 340 p2 = source[3];
341 dest[3] = (1*p1 + 1*p2) >> 1; 341 dest[3] = (1*p1 + 1*p2) >> 1;
342 p1 = source[4]; 342 p1 = source[4];
343 dest[4] = (5*p2 + 3*p1) >> 3; 343 dest[4] = (5*p2 + 3*p1) >> 3;
344 p2 = source[5]; 344 p2 = source[5];
345 dest[5] = (3*p1 + 1*p2) >> 2; 345 dest[5] = (3*p1 + 1*p2) >> 2;
346 p1 = source[6]; 346 p1 = source[6];
347 dest[6] = (7*p2 + 1*p1) >> 3; 347 dest[6] = (7*p2 + 1*p1) >> 3;
348 dest[7] = p1; 348 dest[7] = p1;
349 p2 = source[7]; 349 p2 = source[7];
350 dest[8] = (1*p1 + 3*p2) >> 2; 350 dest[8] = (1*p1 + 3*p2) >> 2;
351 p1 = source[8]; 351 p1 = source[8];
352 dest[9] = (3*p2 + 5*p1) >> 3; 352 dest[9] = (3*p2 + 5*p1) >> 3;
353 p2 = source[9]; 353 p2 = source[9];
354 dest[10] = (1*p1 + 1*p2) >> 1; 354 dest[10] = (1*p1 + 1*p2) >> 1;
355 p1 = source[10]; 355 p1 = source[10];
356 dest[11] = (5*p2 + 3*p1) >> 3; 356 dest[11] = (5*p2 + 3*p1) >> 3;
357 p2 = source[11]; 357 p2 = source[11];
358 dest[12] = (3*p1 + 1*p2) >> 2; 358 dest[12] = (3*p1 + 1*p2) >> 2;
359 p1 = source[12]; 359 p1 = source[12];
360 dest[13] = p2; 360 dest[13] = p2;
361 dest[14] = (1*p2 + 7*p1) >> 3; 361 dest[14] = (1*p2 + 7*p1) >> 3;
362 p2 = source[13]; 362 p2 = source[13];
363 dest[15] = (1*p1 + 3*p2) >> 2; 363 dest[15] = (1*p1 + 3*p2) >> 2;
364 p1 = source[14]; 364 p1 = source[14];
365 dest[16] = (3*p2 + 5*p1) >> 3; 365 dest[16] = (3*p2 + 5*p1) >> 3;
366 p2 = source[15]; 366 p2 = source[15];
367 dest[17] = (5*p1 + 3*p2) >> 3; 367 dest[17] = (5*p1 + 3*p2) >> 3;
368 p1 = source[16]; 368 p1 = source[16];
369 dest[18] = (3*p2 + 1*p1) >> 2; 369 dest[18] = (3*p2 + 1*p1) >> 2;
370 p2 = source[17]; 370 p2 = source[17];
371 dest[19] = (7*p1 + 1*p2) >> 3; 371 dest[19] = (7*p1 + 1*p2) >> 3;
372 dest[20] = p2; 372 dest[20] = p2;
373 p1 = source[18]; 373 p1 = source[18];
374 dest[21] = (1*p2 + 7*p1) >> 3; 374 dest[21] = (1*p2 + 7*p1) >> 3;
375 p2 = source[19]; 375 p2 = source[19];
376 dest[22] = (3*p1 + 5*p2) >> 3; 376 dest[22] = (3*p1 + 5*p2) >> 3;
377 p1 = source[20]; 377 p1 = source[20];
378 dest[23] = (1*p2 + 1*p1) >> 1; 378 dest[23] = (1*p2 + 1*p1) >> 1;
379 p2 = source[21]; 379 p2 = source[21];
380 dest[24] = (5*p1 + 3*p2) >> 3; 380 dest[24] = (5*p1 + 3*p2) >> 3;
381 p1 = source[22]; 381 p1 = source[22];
382 dest[25] = (3*p2 + 1*p1) >> 2; 382 dest[25] = (3*p2 + 1*p1) >> 2;
383 p2 = source[23]; 383 p2 = source[23];
384 dest[26] = (7*p1 + 1*p2) >> 3; 384 dest[26] = (7*p1 + 1*p2) >> 3;
385 dest[27] = (1*p1 + 7*p2) >> 3; 385 dest[27] = (1*p1 + 7*p2) >> 3;
386 p1 = source[24]; 386 p1 = source[24];
387 dest[28] = (1*p2 + 3*p1) >> 2; 387 dest[28] = (1*p2 + 3*p1) >> 2;
388 p2 = source[25]; 388 p2 = source[25];
389 dest[29] = (3*p1 + 5*p2) >> 3; 389 dest[29] = (3*p1 + 5*p2) >> 3;
390 p1 = source[26]; 390 p1 = source[26];
391 dest[30] = (1*p2 + 1*p1) >> 1; 391 dest[30] = (1*p2 + 1*p1) >> 1;
392 p2 = source[27]; 392 p2 = source[27];
393 dest[31] = (5*p1 + 3*p2) >> 3; 393 dest[31] = (5*p1 + 3*p2) >> 3;
394 p1 = source[28]; 394 p1 = source[28];
395 dest[32] = (7*p2 + 1*p1) >> 3; 395 dest[32] = (7*p2 + 1*p1) >> 3;
396 p2 = source[29]; 396 p2 = source[29];
397 dest[33] = p1; 397 dest[33] = p1;
398 dest[34] = (1*p1 + 7*p2) >> 3; 398 dest[34] = (1*p1 + 7*p2) >> 3;
399 p1 = source[30]; 399 p1 = source[30];
400 dest[35] = (1*p2 + 3*p1) >> 2; 400 dest[35] = (1*p2 + 3*p1) >> 2;
401 p2 = source[31]; 401 p2 = source[31];
402 dest[36] = (3*p1 + 5*p2) >> 3; 402 dest[36] = (3*p1 + 5*p2) >> 3;
403 p1 = source[32]; 403 p1 = source[32];
404 dest[37] = (5*p2 + 3*p1) >> 3; 404 dest[37] = (5*p2 + 3*p1) >> 3;
405 p2 = source[33]; 405 p2 = source[33];
406 dest[38] = (3*p1 + 1*p2) >> 2; 406 dest[38] = (3*p1 + 1*p2) >> 2;
407 p1 = source[34]; 407 p1 = source[34];
408 dest[39] = (7*p2 + 1*p1) >> 3; 408 dest[39] = (7*p2 + 1*p1) >> 3;
409 dest[40] = p1; 409 dest[40] = p1;
410 p2 = source[35]; 410 p2 = source[35];
411 dest[41] = (1*p1 + 3*p2) >> 2; 411 dest[41] = (1*p1 + 3*p2) >> 2;
412 p1 = source[36]; 412 p1 = source[36];
413 dest[42] = (3*p2 + 5*p1) >> 3; 413 dest[42] = (3*p2 + 5*p1) >> 3;
414 p2 = source[37]; 414 p2 = source[37];
415 dest[43] = (1*p1 + 1*p2) >> 1; 415 dest[43] = (1*p1 + 1*p2) >> 1;
416 p1 = source[38]; 416 p1 = source[38];
417 dest[44] = (5*p2 + 3*p1) >> 3; 417 dest[44] = (5*p2 + 3*p1) >> 3;
418 p2 = source[39]; 418 p2 = source[39];
419 dest[45] = (3*p1 + 1*p2) >> 2; 419 dest[45] = (3*p1 + 1*p2) >> 2;
420 p1 = source[40]; 420 p1 = source[40];
421 dest[46] = p2; 421 dest[46] = p2;
422 dest[47] = (1*p2 + 7*p1) >> 3; 422 dest[47] = (1*p2 + 7*p1) >> 3;
423 p2 = source[41]; 423 p2 = source[41];
424 dest[48] = (1*p1 + 3*p2) >> 2; 424 dest[48] = (1*p1 + 3*p2) >> 2;
425 p1 = source[42]; 425 p1 = source[42];
426 dest[49] = (3*p2 + 5*p1) >> 3; 426 dest[49] = (3*p2 + 5*p1) >> 3;
427 p2 = source[43]; 427 p2 = source[43];
428 dest[50] = (1*p1 + 1*p2) >> 1; 428 dest[50] = (1*p1 + 1*p2) >> 1;
429 p1 = source[44]; 429 p1 = source[44];
430 dest[51] = (3*p2 + 1*p1) >> 2; 430 dest[51] = (3*p2 + 1*p1) >> 2;
431 p2 = source[45]; 431 p2 = source[45];
432 dest[52] = (7*p1 + 1*p2) >> 3; 432 dest[52] = (7*p1 + 1*p2) >> 3;
433 source += 45; 433 source += 45;
434 dest += 53; 434 dest += 53;
435 } 435 }
436 436
437 if ((width += 53) <= 0) goto done; 437 if ((width += 53) <= 0) goto done;
438 *dest++ = source[0]; 438 *dest++ = source[0];
439 if (--width <= 0) goto done; 439 if (--width <= 0) goto done;
440 *dest++ = (1*source[0] + 7*source[1]) >> 3; 440 *dest++ = (1*source[0] + 7*source[1]) >> 3;
441 if (--width <= 0) goto done; 441 if (--width <= 0) goto done;
442 *dest++ = (1*source[1] + 3*source[2]) >> 2; 442 *dest++ = (1*source[1] + 3*source[2]) >> 2;
443 if (--width <= 0) goto done; 443 if (--width <= 0) goto done;
444 *dest++ = (1*source[2] + 1*source[3]) >> 1; 444 *dest++ = (1*source[2] + 1*source[3]) >> 1;
445 if (--width <= 0) goto done; 445 if (--width <= 0) goto done;
446 *dest++ = (5*source[3] + 3*source[4]) >> 3; 446 *dest++ = (5*source[3] + 3*source[4]) >> 3;
447 if (--width <= 0) goto done; 447 if (--width <= 0) goto done;
448 *dest++ = (3*source[4] + 1*source[5]) >> 2; 448 *dest++ = (3*source[4] + 1*source[5]) >> 2;
449 if (--width <= 0) goto done; 449 if (--width <= 0) goto done;
450 *dest++ = (7*source[5] + 1*source[6]) >> 3; 450 *dest++ = (7*source[5] + 1*source[6]) >> 3;
451 if (--width <= 0) goto done; 451 if (--width <= 0) goto done;
452 *dest++ = source[6]; 452 *dest++ = source[6];
453 if (--width <= 0) goto done; 453 if (--width <= 0) goto done;
454 *dest++ = (1*source[6] + 3*source[7]) >> 2; 454 *dest++ = (1*source[6] + 3*source[7]) >> 2;
455 if (--width <= 0) goto done; 455 if (--width <= 0) goto done;
456 *dest++ = (3*source[7] + 5*source[8]) >> 3; 456 *dest++ = (3*source[7] + 5*source[8]) >> 3;
457 if (--width <= 0) goto done; 457 if (--width <= 0) goto done;
458 *dest++ = (1*source[8] + 1*source[9]) >> 1; 458 *dest++ = (1*source[8] + 1*source[9]) >> 1;
459 if (--width <= 0) goto done; 459 if (--width <= 0) goto done;
460 *dest++ = (5*source[9] + 3*source[10]) >> 3; 460 *dest++ = (5*source[9] + 3*source[10]) >> 3;
461 if (--width <= 0) goto done; 461 if (--width <= 0) goto done;
462 *dest++ = (3*source[10] + 1*source[11]) >> 2; 462 *dest++ = (3*source[10] + 1*source[11]) >> 2;
463 if (--width <= 0) goto done; 463 if (--width <= 0) goto done;
464 *dest++ = source[11]; 464 *dest++ = source[11];
465 if (--width <= 0) goto done; 465 if (--width <= 0) goto done;
466 *dest++ = (1*source[11] + 7*source[12]) >> 3; 466 *dest++ = (1*source[11] + 7*source[12]) >> 3;
467 if (--width <= 0) goto done; 467 if (--width <= 0) goto done;
468 *dest++ = (1*source[12] + 3*source[13]) >> 2; 468 *dest++ = (1*source[12] + 3*source[13]) >> 2;
469 if (--width <= 0) goto done; 469 if (--width <= 0) goto done;
470 *dest++ = (3*source[13] + 5*source[14]) >> 3; 470 *dest++ = (3*source[13] + 5*source[14]) >> 3;
471 if (--width <= 0) goto done; 471 if (--width <= 0) goto done;
472 *dest++ = (5*source[14] + 3*source[15]) >> 3; 472 *dest++ = (5*source[14] + 3*source[15]) >> 3;
473 if (--width <= 0) goto done; 473 if (--width <= 0) goto done;
474 *dest++ = (3*source[15] + 1*source[16]) >> 2; 474 *dest++ = (3*source[15] + 1*source[16]) >> 2;
475 if (--width <= 0) goto done; 475 if (--width <= 0) goto done;
476 *dest++ = (7*source[16] + 1*source[17]) >> 3; 476 *dest++ = (7*source[16] + 1*source[17]) >> 3;
477 if (--width <= 0) goto done; 477 if (--width <= 0) goto done;
478 *dest++ = source[17]; 478 *dest++ = source[17];
479 if (--width <= 0) goto done; 479 if (--width <= 0) goto done;
480 *dest++ = (1*source[17] + 7*source[18]) >> 3; 480 *dest++ = (1*source[17] + 7*source[18]) >> 3;
481 if (--width <= 0) goto done; 481 if (--width <= 0) goto done;
482 *dest++ = (3*source[18] + 5*source[19]) >> 3; 482 *dest++ = (3*source[18] + 5*source[19]) >> 3;
483 if (--width <= 0) goto done; 483 if (--width <= 0) goto done;
484 *dest++ = (1*source[19] + 1*source[20]) >> 1; 484 *dest++ = (1*source[19] + 1*source[20]) >> 1;
485 if (--width <= 0) goto done; 485 if (--width <= 0) goto done;
486 *dest++ = (5*source[20] + 3*source[21]) >> 3; 486 *dest++ = (5*source[20] + 3*source[21]) >> 3;
487 if (--width <= 0) goto done; 487 if (--width <= 0) goto done;
488 *dest++ = (3*source[21] + 1*source[22]) >> 2; 488 *dest++ = (3*source[21] + 1*source[22]) >> 2;
489 if (--width <= 0) goto done; 489 if (--width <= 0) goto done;
490 *dest++ = (7*source[22] + 1*source[23]) >> 3; 490 *dest++ = (7*source[22] + 1*source[23]) >> 3;
491 if (--width <= 0) goto done; 491 if (--width <= 0) goto done;
492 *dest++ = (1*source[22] + 7*source[23]) >> 3; 492 *dest++ = (1*source[22] + 7*source[23]) >> 3;
493 if (--width <= 0) goto done; 493 if (--width <= 0) goto done;
494 *dest++ = (1*source[23] + 3*source[24]) >> 2; 494 *dest++ = (1*source[23] + 3*source[24]) >> 2;
495 if (--width <= 0) goto done; 495 if (--width <= 0) goto done;
496 *dest++ = (3*source[24] + 5*source[25]) >> 3; 496 *dest++ = (3*source[24] + 5*source[25]) >> 3;
497 if (--width <= 0) goto done; 497 if (--width <= 0) goto done;
498 *dest++ = (1*source[25] + 1*source[26]) >> 1; 498 *dest++ = (1*source[25] + 1*source[26]) >> 1;
499 if (--width <= 0) goto done; 499 if (--width <= 0) goto done;
500 *dest++ = (5*source[26] + 3*source[27]) >> 3; 500 *dest++ = (5*source[26] + 3*source[27]) >> 3;
501 if (--width <= 0) goto done; 501 if (--width <= 0) goto done;
502 *dest++ = (7*source[27] + 1*source[28]) >> 3; 502 *dest++ = (7*source[27] + 1*source[28]) >> 3;
503 if (--width <= 0) goto done; 503 if (--width <= 0) goto done;
504 *dest++ = source[28]; 504 *dest++ = source[28];
505 if (--width <= 0) goto done; 505 if (--width <= 0) goto done;
506 *dest++ = (1*source[28] + 7*source[29]) >> 3; 506 *dest++ = (1*source[28] + 7*source[29]) >> 3;
507 if (--width <= 0) goto done; 507 if (--width <= 0) goto done;
508 *dest++ = (1*source[29] + 3*source[30]) >> 2; 508 *dest++ = (1*source[29] + 3*source[30]) >> 2;
509 if (--width <= 0) goto done; 509 if (--width <= 0) goto done;
510 *dest++ = (3*source[30] + 5*source[31]) >> 3; 510 *dest++ = (3*source[30] + 5*source[31]) >> 3;
511 if (--width <= 0) goto done; 511 if (--width <= 0) goto done;
512 *dest++ = (5*source[31] + 3*source[32]) >> 3; 512 *dest++ = (5*source[31] + 3*source[32]) >> 3;
513 if (--width <= 0) goto done; 513 if (--width <= 0) goto done;
514 *dest++ = (3*source[32] + 1*source[33]) >> 2; 514 *dest++ = (3*source[32] + 1*source[33]) >> 2;
515 if (--width <= 0) goto done; 515 if (--width <= 0) goto done;
516 *dest++ = (7*source[33] + 1*source[34]) >> 3; 516 *dest++ = (7*source[33] + 1*source[34]) >> 3;
517 if (--width <= 0) goto done; 517 if (--width <= 0) goto done;
518 *dest++ = source[34]; 518 *dest++ = source[34];
519 if (--width <= 0) goto done; 519 if (--width <= 0) goto done;
520 *dest++ = (1*source[34] + 3*source[35]) >> 2; 520 *dest++ = (1*source[34] + 3*source[35]) >> 2;
521 if (--width <= 0) goto done; 521 if (--width <= 0) goto done;
522 *dest++ = (3*source[35] + 5*source[36]) >> 3; 522 *dest++ = (3*source[35] + 5*source[36]) >> 3;
523 if (--width <= 0) goto done; 523 if (--width <= 0) goto done;
524 *dest++ = (1*source[36] + 1*source[37]) >> 1; 524 *dest++ = (1*source[36] + 1*source[37]) >> 1;
525 if (--width <= 0) goto done; 525 if (--width <= 0) goto done;
526 *dest++ = (5*source[37] + 3*source[38]) >> 3; 526 *dest++ = (5*source[37] + 3*source[38]) >> 3;
527 if (--width <= 0) goto done; 527 if (--width <= 0) goto done;
528 *dest++ = (3*source[38] + 1*source[39]) >> 2; 528 *dest++ = (3*source[38] + 1*source[39]) >> 2;
529 if (--width <= 0) goto done; 529 if (--width <= 0) goto done;
530 *dest++ = source[39]; 530 *dest++ = source[39];
531 if (--width <= 0) goto done; 531 if (--width <= 0) goto done;
532 *dest++ = (1*source[39] + 7*source[40]) >> 3; 532 *dest++ = (1*source[39] + 7*source[40]) >> 3;
533 if (--width <= 0) goto done; 533 if (--width <= 0) goto done;
534 *dest++ = (1*source[40] + 3*source[41]) >> 2; 534 *dest++ = (1*source[40] + 3*source[41]) >> 2;
535 if (--width <= 0) goto done; 535 if (--width <= 0) goto done;
536 *dest++ = (3*source[41] + 5*source[42]) >> 3; 536 *dest++ = (3*source[41] + 5*source[42]) >> 3;
537 if (--width <= 0) goto done; 537 if (--width <= 0) goto done;
538 *dest++ = (1*source[42] + 1*source[43]) >> 1; 538 *dest++ = (1*source[42] + 1*source[43]) >> 1;
539 if (--width <= 0) goto done; 539 if (--width <= 0) goto done;
540 *dest++ = (3*source[43] + 1*source[44]) >> 2; 540 *dest++ = (3*source[43] + 1*source[44]) >> 2;
541 done: 541 done:
542 542
543 xine_profiler_stop_count(prof_scale_line); 543 xine_profiler_stop_count(prof_scale_line);
544} 544}
545 545
546 546
547/* 547/*
548 * Interpolates 64 output pixels from 45 source pixels using shifts. 548 * Interpolates 64 output pixels from 45 source pixels using shifts.
549 * Useful for scaling a PAL mpeg2 dvd input source to 1024x768 549 * Useful for scaling a PAL mpeg2 dvd input source to 1024x768
550 * fullscreen resolution, or to 16:9 format on a monitor using square 550 * fullscreen resolution, or to 16:9 format on a monitor using square
551 * pixels. 551 * pixels.
552 * (720 x 576 ==> 1024 x 576) 552 * (720 x 576 ==> 1024 x 576)
553 */ 553 */
554static void scale_line_45_64 (uint8_t *source, uint8_t *dest, 554static void scale_line_45_64 (uint8_t *source, uint8_t *dest,
555 int width, int step) { 555 int width, int step) {
556 556
557 int p1, p2; 557 int p1, p2;
558 558
559 xine_profiler_start_count(prof_scale_line); 559 xine_profiler_start_count(prof_scale_line);
560 560
561 while ((width -= 64) >= 0) { 561 while ((width -= 64) >= 0) {
562 p1 = source[0]; 562 p1 = source[0];
563 p2 = source[1]; 563 p2 = source[1];
564 dest[0] = p1; 564 dest[0] = p1;
565 dest[1] = (1*p1 + 3*p2) >> 2; 565 dest[1] = (1*p1 + 3*p2) >> 2;
566 p1 = source[2]; 566 p1 = source[2];
567 dest[2] = (5*p2 + 3*p1) >> 3; 567 dest[2] = (5*p2 + 3*p1) >> 3;
568 p2 = source[3]; 568 p2 = source[3];
569 dest[3] = (7*p1 + 1*p2) >> 3; 569 dest[3] = (7*p1 + 1*p2) >> 3;
570 dest[4] = (1*p1 + 3*p2) >> 2; 570 dest[4] = (1*p1 + 3*p2) >> 2;
571 p1 = source[4]; 571 p1 = source[4];
572 dest[5] = (1*p2 + 1*p1) >> 1; 572 dest[5] = (1*p2 + 1*p1) >> 1;
573 p2 = source[5]; 573 p2 = source[5];
574 dest[6] = (3*p1 + 1*p2) >> 2; 574 dest[6] = (3*p1 + 1*p2) >> 2;
575 dest[7] = (1*p1 + 7*p2) >> 3; 575 dest[7] = (1*p1 + 7*p2) >> 3;
576 p1 = source[6]; 576 p1 = source[6];
577 dest[8] = (3*p2 + 5*p1) >> 3; 577 dest[8] = (3*p2 + 5*p1) >> 3;
578 p2 = source[7]; 578 p2 = source[7];
579 dest[9] = (5*p1 + 3*p2) >> 3; 579 dest[9] = (5*p1 + 3*p2) >> 3;
580 p1 = source[8]; 580 p1 = source[8];
581 dest[10] = p2; 581 dest[10] = p2;
582 dest[11] = (1*p2 + 3*p1) >> 2; 582 dest[11] = (1*p2 + 3*p1) >> 2;
583 p2 = source[9]; 583 p2 = source[9];
584 dest[12] = (5*p1 + 3*p2) >> 3; 584 dest[12] = (5*p1 + 3*p2) >> 3;
585 p1 = source[10]; 585 p1 = source[10];
586 dest[13] = (7*p2 + 1*p1) >> 3; 586 dest[13] = (7*p2 + 1*p1) >> 3;
587 dest[14] = (1*p2 + 7*p1) >> 3; 587 dest[14] = (1*p2 + 7*p1) >> 3;
588 p2 = source[11]; 588 p2 = source[11];
589 dest[15] = (1*p1 + 1*p2) >> 1; 589 dest[15] = (1*p1 + 1*p2) >> 1;
590 p1 = source[12]; 590 p1 = source[12];
591 dest[16] = (3*p2 + 1*p1) >> 2; 591 dest[16] = (3*p2 + 1*p1) >> 2;
592 dest[17] = p1; 592 dest[17] = p1;
593 p2 = source[13]; 593 p2 = source[13];
594 dest[18] = (3*p1 + 5*p2) >> 3; 594 dest[18] = (3*p1 + 5*p2) >> 3;
595 p1 = source[14]; 595 p1 = source[14];
596 dest[19] = (5*p2 + 3*p1) >> 3; 596 dest[19] = (5*p2 + 3*p1) >> 3;
597 p2 = source[15]; 597 p2 = source[15];
598 dest[20] = p1; 598 dest[20] = p1;
599 dest[21] = (1*p1 + 3*p2) >> 2; 599 dest[21] = (1*p1 + 3*p2) >> 2;
600 p1 = source[16]; 600 p1 = source[16];
601 dest[22] = (1*p2 + 1*p1) >> 1; 601 dest[22] = (1*p2 + 1*p1) >> 1;
602 p2 = source[17]; 602 p2 = source[17];
603 dest[23] = (7*p1 + 1*p2) >> 3; 603 dest[23] = (7*p1 + 1*p2) >> 3;
604 dest[24] = (1*p1 + 7*p2) >> 3; 604 dest[24] = (1*p1 + 7*p2) >> 3;
605 p1 = source[18]; 605 p1 = source[18];
606 dest[25] = (3*p2 + 5*p1) >> 3; 606 dest[25] = (3*p2 + 5*p1) >> 3;
607 p2 = source[19]; 607 p2 = source[19];
608 dest[26] = (3*p1 + 1*p2) >> 2; 608 dest[26] = (3*p1 + 1*p2) >> 2;
609 dest[27] = p2; 609 dest[27] = p2;
610 p1 = source[20]; 610 p1 = source[20];
611 dest[28] = (3*p2 + 5*p1) >> 3; 611 dest[28] = (3*p2 + 5*p1) >> 3;
612 p2 = source[21]; 612 p2 = source[21];
613 dest[29] = (5*p1 + 3*p2) >> 3; 613 dest[29] = (5*p1 + 3*p2) >> 3;
614 p1 = source[22]; 614 p1 = source[22];
615 dest[30] = (7*p2 + 1*p1) >> 3; 615 dest[30] = (7*p2 + 1*p1) >> 3;
616 dest[31] = (1*p2 + 3*p1) >> 2; 616 dest[31] = (1*p2 + 3*p1) >> 2;
617 p2 = source[23]; 617 p2 = source[23];
618 dest[32] = (1*p1 + 1*p2) >> 1; 618 dest[32] = (1*p1 + 1*p2) >> 1;
619 p1 = source[24]; 619 p1 = source[24];
620 dest[33] = (3*p2 + 1*p1) >> 2; 620 dest[33] = (3*p2 + 1*p1) >> 2;
621 dest[34] = (1*p2 + 7*p1) >> 3; 621 dest[34] = (1*p2 + 7*p1) >> 3;
622 p2 = source[25]; 622 p2 = source[25];
623 dest[35] = (3*p1 + 5*p2) >> 3; 623 dest[35] = (3*p1 + 5*p2) >> 3;
624 p1 = source[26]; 624 p1 = source[26];
625 dest[36] = (3*p2 + 1*p1) >> 2; 625 dest[36] = (3*p2 + 1*p1) >> 2;
626 p2 = source[27]; 626 p2 = source[27];
627 dest[37] = p1; 627 dest[37] = p1;
628 dest[38] = (1*p1 + 3*p2) >> 2; 628 dest[38] = (1*p1 + 3*p2) >> 2;
629 p1 = source[28]; 629 p1 = source[28];
630 dest[39] = (5*p2 + 3*p1) >> 3; 630 dest[39] = (5*p2 + 3*p1) >> 3;
631 p2 = source[29]; 631 p2 = source[29];
632 dest[40] = (7*p1 + 1*p2) >> 3; 632 dest[40] = (7*p1 + 1*p2) >> 3;
633 dest[41] = (1*p1 + 7*p2) >> 3; 633 dest[41] = (1*p1 + 7*p2) >> 3;
634 p1 = source[30]; 634 p1 = source[30];
635 dest[42] = (1*p2 + 1*p1) >> 1; 635 dest[42] = (1*p2 + 1*p1) >> 1;
636 p2 = source[31]; 636 p2 = source[31];
637 dest[43] = (3*p1 + 1*p2) >> 2; 637 dest[43] = (3*p1 + 1*p2) >> 2;
638 dest[44] = (1*p1 + 7*p2) >> 3; 638 dest[44] = (1*p1 + 7*p2) >> 3;
639 p1 = source[32]; 639 p1 = source[32];
640 dest[45] = (3*p2 + 5*p1) >> 3; 640 dest[45] = (3*p2 + 5*p1) >> 3;
641 p2 = source[33]; 641 p2 = source[33];
642 dest[46] = (5*p1 + 3*p2) >> 3; 642 dest[46] = (5*p1 + 3*p2) >> 3;
643 p1 = source[34]; 643 p1 = source[34];
644 dest[47] = p2; 644 dest[47] = p2;
645 dest[48] = (1*p2 + 3*p1) >> 2; 645 dest[48] = (1*p2 + 3*p1) >> 2;
646 p2 = source[35]; 646 p2 = source[35];
647 dest[49] = (1*p1 + 1*p2) >> 1; 647 dest[49] = (1*p1 + 1*p2) >> 1;
648 p1 = source[36]; 648 p1 = source[36];
649 dest[50] = (7*p2 + 1*p1) >> 3; 649 dest[50] = (7*p2 + 1*p1) >> 3;
650 dest[51] = (1*p2 + 7*p1) >> 3; 650 dest[51] = (1*p2 + 7*p1) >> 3;
651 p2 = source[37]; 651 p2 = source[37];
652 dest[52] = (1*p1 + 1*p2) >> 1; 652 dest[52] = (1*p1 + 1*p2) >> 1;
653 p1 = source[38]; 653 p1 = source[38];
654 dest[53] = (3*p2 + 1*p1) >> 2; 654 dest[53] = (3*p2 + 1*p1) >> 2;
655 dest[54] = p1; 655 dest[54] = p1;
656 p2 = source[39]; 656 p2 = source[39];
657 dest[55] = (3*p1 + 5*p2) >> 3; 657 dest[55] = (3*p1 + 5*p2) >> 3;
658 p1 = source[40]; 658 p1 = source[40];
659 dest[56] = (5*p2 + 3*p1) >> 3; 659 dest[56] = (5*p2 + 3*p1) >> 3;
660 p2 = source[41]; 660 p2 = source[41];
661 dest[57] = (7*p1 + 1*p2) >> 3; 661 dest[57] = (7*p1 + 1*p2) >> 3;
662 dest[58] = (1*p1 + 3*p2) >> 2; 662 dest[58] = (1*p1 + 3*p2) >> 2;
663 p1 = source[42]; 663 p1 = source[42];
664 dest[59] = (1*p2 + 1*p1) >> 1; 664 dest[59] = (1*p2 + 1*p1) >> 1;
665 p2 = source[43]; 665 p2 = source[43];
666 dest[60] = (7*p1 + 1*p2) >> 3; 666 dest[60] = (7*p1 + 1*p2) >> 3;
667 dest[61] = (1*p1 + 7*p2) >> 3; 667 dest[61] = (1*p1 + 7*p2) >> 3;
668 p1 = source[44]; 668 p1 = source[44];
669 dest[62] = (3*p2 + 5*p1) >> 3; 669 dest[62] = (3*p2 + 5*p1) >> 3;
670 p2 = source[45]; 670 p2 = source[45];
671 dest[63] = (3*p1 + 1*p2) >> 2; 671 dest[63] = (3*p1 + 1*p2) >> 2;
672 source += 45; 672 source += 45;
673 dest += 64; 673 dest += 64;
674 } 674 }
675 675
676 if ((width += 64) <= 0) goto done; 676 if ((width += 64) <= 0) goto done;
677 *dest++ = source[0]; 677 *dest++ = source[0];
678 if (--width <= 0) goto done; 678 if (--width <= 0) goto done;
679 *dest++ = (1*source[0] + 3*source[1]) >> 2; 679 *dest++ = (1*source[0] + 3*source[1]) >> 2;
680 if (--width <= 0) goto done; 680 if (--width <= 0) goto done;
681 *dest++ = (5*source[1] + 3*source[2]) >> 3; 681 *dest++ = (5*source[1] + 3*source[2]) >> 3;
682 if (--width <= 0) goto done; 682 if (--width <= 0) goto done;
683 *dest++ = (7*source[2] + 1*source[3]) >> 3; 683 *dest++ = (7*source[2] + 1*source[3]) >> 3;
684 if (--width <= 0) goto done; 684 if (--width <= 0) goto done;
685 *dest++ = (1*source[2] + 3*source[3]) >> 2; 685 *dest++ = (1*source[2] + 3*source[3]) >> 2;
686 if (--width <= 0) goto done; 686 if (--width <= 0) goto done;
687 *dest++ = (1*source[3] + 1*source[4]) >> 1; 687 *dest++ = (1*source[3] + 1*source[4]) >> 1;
688 if (--width <= 0) goto done; 688 if (--width <= 0) goto done;
689 *dest++ = (3*source[4] + 1*source[5]) >> 2; 689 *dest++ = (3*source[4] + 1*source[5]) >> 2;
690 if (--width <= 0) goto done; 690 if (--width <= 0) goto done;
691 *dest++ = (1*source[4] + 7*source[5]) >> 3; 691 *dest++ = (1*source[4] + 7*source[5]) >> 3;
692 if (--width <= 0) goto done; 692 if (--width <= 0) goto done;
693 *dest++ = (3*source[5] + 5*source[6]) >> 3; 693 *dest++ = (3*source[5] + 5*source[6]) >> 3;
694 if (--width <= 0) goto done; 694 if (--width <= 0) goto done;
695 *dest++ = (5*source[6] + 3*source[7]) >> 3; 695 *dest++ = (5*source[6] + 3*source[7]) >> 3;
696 if (--width <= 0) goto done; 696 if (--width <= 0) goto done;
697 *dest++ = source[7]; 697 *dest++ = source[7];
698 if (--width <= 0) goto done; 698 if (--width <= 0) goto done;
699 *dest++ = (1*source[7] + 3*source[8]) >> 2; 699 *dest++ = (1*source[7] + 3*source[8]) >> 2;
700 if (--width <= 0) goto done; 700 if (--width <= 0) goto done;
701 *dest++ = (5*source[8] + 3*source[9]) >> 3; 701 *dest++ = (5*source[8] + 3*source[9]) >> 3;
702 if (--width <= 0) goto done; 702 if (--width <= 0) goto done;
703 *dest++ = (7*source[9] + 1*source[10]) >> 3; 703 *dest++ = (7*source[9] + 1*source[10]) >> 3;
704 if (--width <= 0) goto done; 704 if (--width <= 0) goto done;
705 *dest++ = (1*source[9] + 7*source[10]) >> 3; 705 *dest++ = (1*source[9] + 7*source[10]) >> 3;
706 if (--width <= 0) goto done; 706 if (--width <= 0) goto done;
707 *dest++ = (1*source[10] + 1*source[11]) >> 1; 707 *dest++ = (1*source[10] + 1*source[11]) >> 1;
708 if (--width <= 0) goto done; 708 if (--width <= 0) goto done;
709 *dest++ = (3*source[11] + 1*source[12]) >> 2; 709 *dest++ = (3*source[11] + 1*source[12]) >> 2;
710 if (--width <= 0) goto done; 710 if (--width <= 0) goto done;
711 *dest++ = source[12]; 711 *dest++ = source[12];
712 if (--width <= 0) goto done; 712 if (--width <= 0) goto done;
713 *dest++ = (3*source[12] + 5*source[13]) >> 3; 713 *dest++ = (3*source[12] + 5*source[13]) >> 3;
714 if (--width <= 0) goto done; 714 if (--width <= 0) goto done;
715 *dest++ = (5*source[13] + 3*source[14]) >> 3; 715 *dest++ = (5*source[13] + 3*source[14]) >> 3;
716 if (--width <= 0) goto done; 716 if (--width <= 0) goto done;
717 *dest++ = source[14]; 717 *dest++ = source[14];
718 if (--width <= 0) goto done; 718 if (--width <= 0) goto done;
719 *dest++ = (1*source[14] + 3*source[15]) >> 2; 719 *dest++ = (1*source[14] + 3*source[15]) >> 2;
720 if (--width <= 0) goto done; 720 if (--width <= 0) goto done;
721 *dest++ = (1*source[15] + 1*source[16]) >> 1; 721 *dest++ = (1*source[15] + 1*source[16]) >> 1;
722 if (--width <= 0) goto done; 722 if (--width <= 0) goto done;
723 *dest++ = (7*source[16] + 1*source[17]) >> 3; 723 *dest++ = (7*source[16] + 1*source[17]) >> 3;
724 if (--width <= 0) goto done; 724 if (--width <= 0) goto done;
725 *dest++ = (1*source[16] + 7*source[17]) >> 3; 725 *dest++ = (1*source[16] + 7*source[17]) >> 3;
726 if (--width <= 0) goto done; 726 if (--width <= 0) goto done;
727 *dest++ = (3*source[17] + 5*source[18]) >> 3; 727 *dest++ = (3*source[17] + 5*source[18]) >> 3;
728 if (--width <= 0) goto done; 728 if (--width <= 0) goto done;
729 *dest++ = (3*source[18] + 1*source[19]) >> 2; 729 *dest++ = (3*source[18] + 1*source[19]) >> 2;
730 if (--width <= 0) goto done; 730 if (--width <= 0) goto done;
731 *dest++ = source[19]; 731 *dest++ = source[19];
732 if (--width <= 0) goto done; 732 if (--width <= 0) goto done;
733 *dest++ = (3*source[19] + 5*source[20]) >> 3; 733 *dest++ = (3*source[19] + 5*source[20]) >> 3;
734 if (--width <= 0) goto done; 734 if (--width <= 0) goto done;
735 *dest++ = (5*source[20] + 3*source[21]) >> 3; 735 *dest++ = (5*source[20] + 3*source[21]) >> 3;
736 if (--width <= 0) goto done; 736 if (--width <= 0) goto done;
737 *dest++ = (7*source[21] + 1*source[22]) >> 3; 737 *dest++ = (7*source[21] + 1*source[22]) >> 3;
738 if (--width <= 0) goto done; 738 if (--width <= 0) goto done;
739 *dest++ = (1*source[21] + 3*source[22]) >> 2; 739 *dest++ = (1*source[21] + 3*source[22]) >> 2;
740 if (--width <= 0) goto done; 740 if (--width <= 0) goto done;
741 *dest++ = (1*source[22] + 1*source[23]) >> 1; 741 *dest++ = (1*source[22] + 1*source[23]) >> 1;
742 if (--width <= 0) goto done; 742 if (--width <= 0) goto done;
743 *dest++ = (3*source[23] + 1*source[24]) >> 2; 743 *dest++ = (3*source[23] + 1*source[24]) >> 2;
744 if (--width <= 0) goto done; 744 if (--width <= 0) goto done;
745 *dest++ = (1*source[23] + 7*source[24]) >> 3; 745 *dest++ = (1*source[23] + 7*source[24]) >> 3;
746 if (--width <= 0) goto done; 746 if (--width <= 0) goto done;
747 *dest++ = (3*source[24] + 5*source[25]) >> 3; 747 *dest++ = (3*source[24] + 5*source[25]) >> 3;
748 if (--width <= 0) goto done; 748 if (--width <= 0) goto done;
749 *dest++ = (3*source[25] + 1*source[26]) >> 2; 749 *dest++ = (3*source[25] + 1*source[26]) >> 2;
750 if (--width <= 0) goto done; 750 if (--width <= 0) goto done;
751 *dest++ = source[26]; 751 *dest++ = source[26];
752 if (--width <= 0) goto done; 752 if (--width <= 0) goto done;
753 *dest++ = (1*source[26] + 3*source[27]) >> 2; 753 *dest++ = (1*source[26] + 3*source[27]) >> 2;
754 if (--width <= 0) goto done; 754 if (--width <= 0) goto done;
755 *dest++ = (5*source[27] + 3*source[28]) >> 3; 755 *dest++ = (5*source[27] + 3*source[28]) >> 3;
756 if (--width <= 0) goto done; 756 if (--width <= 0) goto done;
757 *dest++ = (7*source[28] + 1*source[29]) >> 3; 757 *dest++ = (7*source[28] + 1*source[29]) >> 3;
758 if (--width <= 0) goto done; 758 if (--width <= 0) goto done;
759 *dest++ = (1*source[28] + 7*source[29]) >> 3; 759 *dest++ = (1*source[28] + 7*source[29]) >> 3;
760 if (--width <= 0) goto done; 760 if (--width <= 0) goto done;
761 *dest++ = (1*source[29] + 1*source[30]) >> 1; 761 *dest++ = (1*source[29] + 1*source[30]) >> 1;
762 if (--width <= 0) goto done; 762 if (--width <= 0) goto done;
763 *dest++ = (3*source[30] + 1*source[31]) >> 2; 763 *dest++ = (3*source[30] + 1*source[31]) >> 2;
764 if (--width <= 0) goto done; 764 if (--width <= 0) goto done;
765 *dest++ = (1*source[30] + 7*source[31]) >> 3; 765 *dest++ = (1*source[30] + 7*source[31]) >> 3;
766 if (--width <= 0) goto done; 766 if (--width <= 0) goto done;
767 *dest++ = (3*source[31] + 5*source[32]) >> 3; 767 *dest++ = (3*source[31] + 5*source[32]) >> 3;
768 if (--width <= 0) goto done; 768 if (--width <= 0) goto done;
769 *dest++ = (5*source[32] + 3*source[33]) >> 3; 769 *dest++ = (5*source[32] + 3*source[33]) >> 3;
770 if (--width <= 0) goto done; 770 if (--width <= 0) goto done;
771 *dest++ = source[33]; 771 *dest++ = source[33];
772 if (--width <= 0) goto done; 772 if (--width <= 0) goto done;
773 *dest++ = (1*source[33] + 3*source[34]) >> 2; 773 *dest++ = (1*source[33] + 3*source[34]) >> 2;
774 if (--width <= 0) goto done; 774 if (--width <= 0) goto done;
775 *dest++ = (1*source[34] + 1*source[35]) >> 1; 775 *dest++ = (1*source[34] + 1*source[35]) >> 1;
776 if (--width <= 0) goto done; 776 if (--width <= 0) goto done;
777 *dest++ = (7*source[35] + 1*source[36]) >> 3; 777 *dest++ = (7*source[35] + 1*source[36]) >> 3;
778 if (--width <= 0) goto done; 778 if (--width <= 0) goto done;
779 *dest++ = (1*source[35] + 7*source[36]) >> 3; 779 *dest++ = (1*source[35] + 7*source[36]) >> 3;
780 if (--width <= 0) goto done; 780 if (--width <= 0) goto done;
781 *dest++ = (1*source[36] + 1*source[37]) >> 1; 781 *dest++ = (1*source[36] + 1*source[37]) >> 1;
782 if (--width <= 0) goto done; 782 if (--width <= 0) goto done;
783 *dest++ = (3*source[37] + 1*source[38]) >> 2; 783 *dest++ = (3*source[37] + 1*source[38]) >> 2;
784 if (--width <= 0) goto done; 784 if (--width <= 0) goto done;
785 *dest++ = source[38]; 785 *dest++ = source[38];
786 if (--width <= 0) goto done; 786 if (--width <= 0) goto done;
787 *dest++ = (3*source[38] + 5*source[39]) >> 3; 787 *dest++ = (3*source[38] + 5*source[39]) >> 3;
788 if (--width <= 0) goto done; 788 if (--width <= 0) goto done;
789 *dest++ = (5*source[39] + 3*source[40]) >> 3; 789 *dest++ = (5*source[39] + 3*source[40]) >> 3;
790 if (--width <= 0) goto done; 790 if (--width <= 0) goto done;
791 *dest++ = (7*source[40] + 1*source[41]) >> 3; 791 *dest++ = (7*source[40] + 1*source[41]) >> 3;
792 if (--width <= 0) goto done; 792 if (--width <= 0) goto done;
793 *dest++ = (1*source[40] + 3*source[41]) >> 2; 793 *dest++ = (1*source[40] + 3*source[41]) >> 2;
794 if (--width <= 0) goto done; 794 if (--width <= 0) goto done;
795 *dest++ = (1*source[41] + 1*source[42]) >> 1; 795 *dest++ = (1*source[41] + 1*source[42]) >> 1;
796 if (--width <= 0) goto done; 796 if (--width <= 0) goto done;
797 *dest++ = (7*source[42] + 1*source[43]) >> 3; 797 *dest++ = (7*source[42] + 1*source[43]) >> 3;
798 if (--width <= 0) goto done; 798 if (--width <= 0) goto done;
799 *dest++ = (1*source[42] + 7*source[43]) >> 3; 799 *dest++ = (1*source[42] + 7*source[43]) >> 3;
800 if (--width <= 0) goto done; 800 if (--width <= 0) goto done;
801 *dest++ = (3*source[43] + 5*source[44]) >> 3; 801 *dest++ = (3*source[43] + 5*source[44]) >> 3;
802 done: 802 done:
803 803
804 xine_profiler_stop_count(prof_scale_line); 804 xine_profiler_stop_count(prof_scale_line);
805} 805}
806 806
807 807
808/* 808/*
809 * Interpolates 16 output pixels from 9 source pixels using shifts. 809 * Interpolates 16 output pixels from 9 source pixels using shifts.
810 * Useful for scaling a PAL mpeg2 dvd input source to 1280x1024 fullscreen 810 * Useful for scaling a PAL mpeg2 dvd input source to 1280x1024 fullscreen
811 * (720 x 576 ==> 1280 x XXX) 811 * (720 x 576 ==> 1280 x XXX)
812 */ 812 */
813static void scale_line_9_16 (uint8_t *source, uint8_t *dest, 813static void scale_line_9_16 (uint8_t *source, uint8_t *dest,
814 int width, int step) { 814 int width, int step) {
815 815
816 int p1, p2; 816 int p1, p2;
817 817
818 xine_profiler_start_count(prof_scale_line); 818 xine_profiler_start_count(prof_scale_line);
819 819
820 while ((width -= 16) >= 0) { 820 while ((width -= 16) >= 0) {
821 p1 = source[0]; 821 p1 = source[0];
822 p2 = source[1]; 822 p2 = source[1];
823 dest[0] = p1; 823 dest[0] = p1;
824 dest[1] = (1*p1 + 1*p2) >> 1; 824 dest[1] = (1*p1 + 1*p2) >> 1;
825 p1 = source[2]; 825 p1 = source[2];
826 dest[2] = (7*p2 + 1*p1) >> 3; 826 dest[2] = (7*p2 + 1*p1) >> 3;
827 dest[3] = (3*p2 + 5*p1) >> 3; 827 dest[3] = (3*p2 + 5*p1) >> 3;
828 p2 = source[3]; 828 p2 = source[3];
829 dest[4] = (3*p1 + 1*p2) >> 2; 829 dest[4] = (3*p1 + 1*p2) >> 2;
830 dest[5] = (1*p1 + 3*p2) >> 2; 830 dest[5] = (1*p1 + 3*p2) >> 2;
831 p1 = source[4]; 831 p1 = source[4];
832 dest[6] = (5*p2 + 3*p1) >> 3; 832 dest[6] = (5*p2 + 3*p1) >> 3;
833 dest[7] = (1*p2 + 7*p1) >> 3; 833 dest[7] = (1*p2 + 7*p1) >> 3;
834 p2 = source[5]; 834 p2 = source[5];
835 dest[8] = (1*p1 + 1*p2) >> 1; 835 dest[8] = (1*p1 + 1*p2) >> 1;
836 p1 = source[6]; 836 p1 = source[6];
837 dest[9] = p2; 837 dest[9] = p2;
838 dest[10] = (3*p2 + 5*p1) >> 3; 838 dest[10] = (3*p2 + 5*p1) >> 3;
839 p2 = source[7]; 839 p2 = source[7];
840 dest[11] = (7*p1 + 1*p2) >> 3; 840 dest[11] = (7*p1 + 1*p2) >> 3;
841 dest[12] = (1*p1 + 3*p2) >> 2; 841 dest[12] = (1*p1 + 3*p2) >> 2;
842 p1 = source[8]; 842 p1 = source[8];
843 dest[13] = (3*p2 + 1*p1) >> 2; 843 dest[13] = (3*p2 + 1*p1) >> 2;
844 dest[14] = (1*p2 + 7*p1) >> 3; 844 dest[14] = (1*p2 + 7*p1) >> 3;
845 p2 = source[9]; 845 p2 = source[9];
846 dest[15] = (5*p1 + 3*p2) >> 3; 846 dest[15] = (5*p1 + 3*p2) >> 3;
847 source += 9; 847 source += 9;
848 dest += 16; 848 dest += 16;
849 } 849 }
850 850
851 if ((width += 16) <= 0) goto done; 851 if ((width += 16) <= 0) goto done;
852 *dest++ = source[0]; 852 *dest++ = source[0];
853 if (--width <= 0) goto done; 853 if (--width <= 0) goto done;
854 *dest++ = (1*source[0] + 1*source[1]) >> 1; 854 *dest++ = (1*source[0] + 1*source[1]) >> 1;
855 if (--width <= 0) goto done; 855 if (--width <= 0) goto done;
856 *dest++ = (7*source[1] + 1*source[2]) >> 3; 856 *dest++ = (7*source[1] + 1*source[2]) >> 3;
857 if (--width <= 0) goto done; 857 if (--width <= 0) goto done;
858 *dest++ = (3*source[1] + 5*source[2]) >> 3; 858 *dest++ = (3*source[1] + 5*source[2]) >> 3;
859 if (--width <= 0) goto done; 859 if (--width <= 0) goto done;
860 *dest++ = (3*source[2] + 1*source[3]) >> 2; 860 *dest++ = (3*source[2] + 1*source[3]) >> 2;
861 if (--width <= 0) goto done; 861 if (--width <= 0) goto done;
862 *dest++ = (1*source[2] + 3*source[3]) >> 2; 862 *dest++ = (1*source[2] + 3*source[3]) >> 2;
863 if (--width <= 0) goto done; 863 if (--width <= 0) goto done;
864 *dest++ = (5*source[3] + 3*source[4]) >> 3; 864 *dest++ = (5*source[3] + 3*source[4]) >> 3;
865 if (--width <= 0) goto done; 865 if (--width <= 0) goto done;
866 *dest++ = (1*source[3] + 7*source[4]) >> 3; 866 *dest++ = (1*source[3] + 7*source[4]) >> 3;
867 if (--width <= 0) goto done; 867 if (--width <= 0) goto done;
868 *dest++ = (1*source[4] + 1*source[5]) >> 1; 868 *dest++ = (1*source[4] + 1*source[5]) >> 1;
869 if (--width <= 0) goto done; 869 if (--width <= 0) goto done;
870 *dest++ = source[5]; 870 *dest++ = source[5];
871 if (--width <= 0) goto done; 871 if (--width <= 0) goto done;
872 *dest++ = (3*source[5] + 5*source[6]) >> 3; 872 *dest++ = (3*source[5] + 5*source[6]) >> 3;
873 if (--width <= 0) goto done; 873 if (--width <= 0) goto done;
874 *dest++ = (7*source[6] + 1*source[7]) >> 3; 874 *dest++ = (7*source[6] + 1*source[7]) >> 3;
875 if (--width <= 0) goto done; 875 if (--width <= 0) goto done;
876 *dest++ = (1*source[6] + 3*source[7]) >> 2; 876 *dest++ = (1*source[6] + 3*source[7]) >> 2;
877 if (--width <= 0) goto done; 877 if (--width <= 0) goto done;
878 *dest++ = (3*source[7] + 1*source[8]) >> 2; 878 *dest++ = (3*source[7] + 1*source[8]) >> 2;
879 if (--width <= 0) goto done; 879 if (--width <= 0) goto done;
880 *dest++ = (1*source[7] + 7*source[8]) >> 3; 880 *dest++ = (1*source[7] + 7*source[8]) >> 3;
881done: 881done:
882 xine_profiler_stop_count(prof_scale_line); 882 xine_profiler_stop_count(prof_scale_line);
883} 883}
884 884
885 885
886/* 886/*
887 * Interpolates 12 output pixels from 11 source pixels using shifts. 887 * Interpolates 12 output pixels from 11 source pixels using shifts.
888 * Useful for scaling a PAL vcd input source to 4:3 display format. 888 * Useful for scaling a PAL vcd input source to 4:3 display format.
889 */ 889 */
890static void scale_line_11_12 (uint8_t *source, uint8_t *dest, 890static void scale_line_11_12 (uint8_t *source, uint8_t *dest,
891 int width, int step) { 891 int width, int step) {
892 892
893 int p1, p2; 893 int p1, p2;
894 894
895 xine_profiler_start_count(prof_scale_line); 895 xine_profiler_start_count(prof_scale_line);
896 896
897 while ((width -= 12) >= 0) { 897 while ((width -= 12) >= 0) {
898 p1 = source[0]; 898 p1 = source[0];
899 p2 = source[1]; 899 p2 = source[1];
900 dest[0] = p1; 900 dest[0] = p1;
901 dest[1] = (1*p1 + 7*p2) >> 3; 901 dest[1] = (1*p1 + 7*p2) >> 3;
902 p1 = source[2]; 902 p1 = source[2];
903 dest[2] = (1*p2 + 7*p1) >> 3; 903 dest[2] = (1*p2 + 7*p1) >> 3;
904 p2 = source[3]; 904 p2 = source[3];
905 dest[3] = (1*p1 + 3*p2) >> 2; 905 dest[3] = (1*p1 + 3*p2) >> 2;
906 p1 = source[4]; 906 p1 = source[4];
907 dest[4] = (3*p2 + 5*p1) >> 3; 907 dest[4] = (3*p2 + 5*p1) >> 3;
908 p2 = source[5]; 908 p2 = source[5];
909 dest[5] = (3*p1 + 5*p2) >> 3; 909 dest[5] = (3*p1 + 5*p2) >> 3;
910 p1 = source[6]; 910 p1 = source[6];
911 dest[6] = (1*p2 + 1*p1) >> 1; 911 dest[6] = (1*p2 + 1*p1) >> 1;
912 p2 = source[7]; 912 p2 = source[7];
913 dest[7] = (5*p1 + 3*p2) >> 3; 913 dest[7] = (5*p1 + 3*p2) >> 3;
914 p1 = source[8]; 914 p1 = source[8];
915 dest[8] = (5*p2 + 3*p1) >> 3; 915 dest[8] = (5*p2 + 3*p1) >> 3;
916 p2 = source[9]; 916 p2 = source[9];
917 dest[9] = (3*p1 + 1*p2) >> 2; 917 dest[9] = (3*p1 + 1*p2) >> 2;
918 p1 = source[10]; 918 p1 = source[10];
919 dest[10] = (7*p2 + 1*p1) >> 3; 919 dest[10] = (7*p2 + 1*p1) >> 3;
920 p2 = source[11]; 920 p2 = source[11];
921 dest[11] = (7*p1 + 1*p2) >> 3; 921 dest[11] = (7*p1 + 1*p2) >> 3;
922 source += 11; 922 source += 11;
923 dest += 12; 923 dest += 12;
924 } 924 }
925 925
926 if ((width += 12) <= 0) goto done; 926 if ((width += 12) <= 0) goto done;
927 *dest++ = source[0]; 927 *dest++ = source[0];
928 if (--width <= 0) goto done; 928 if (--width <= 0) goto done;
929 *dest++ = (1*source[0] + 7*source[1]) >> 3; 929 *dest++ = (1*source[0] + 7*source[1]) >> 3;
930 if (--width <= 0) goto done; 930 if (--width <= 0) goto done;
931 *dest++ = (1*source[1] + 7*source[2]) >> 3; 931 *dest++ = (1*source[1] + 7*source[2]) >> 3;
932 if (--width <= 0) goto done; 932 if (--width <= 0) goto done;
933 *dest++ = (1*source[2] + 3*source[3]) >> 2; 933 *dest++ = (1*source[2] + 3*source[3]) >> 2;
934 if (--width <= 0) goto done; 934 if (--width <= 0) goto done;
935 *dest++ = (3*source[3] + 5*source[4]) >> 3; 935 *dest++ = (3*source[3] + 5*source[4]) >> 3;
936 if (--width <= 0) goto done; 936 if (--width <= 0) goto done;
937 *dest++ = (3*source[4] + 5*source[5]) >> 3; 937 *dest++ = (3*source[4] + 5*source[5]) >> 3;
938 if (--width <= 0) goto done; 938 if (--width <= 0) goto done;
939 *dest++ = (1*source[5] + 1*source[6]) >> 1; 939 *dest++ = (1*source[5] + 1*source[6]) >> 1;
940 if (--width <= 0) goto done; 940 if (--width <= 0) goto done;
941 *dest++ = (5*source[6] + 3*source[7]) >> 3; 941 *dest++ = (5*source[6] + 3*source[7]) >> 3;
942 if (--width <= 0) goto done; 942 if (--width <= 0) goto done;
943 *dest++ = (5*source[7] + 3*source[8]) >> 3; 943 *dest++ = (5*source[7] + 3*source[8]) >> 3;
944 if (--width <= 0) goto done; 944 if (--width <= 0) goto done;
945 *dest++ = (3*source[8] + 1*source[9]) >> 2; 945 *dest++ = (3*source[8] + 1*source[9]) >> 2;
946 if (--width <= 0) goto done; 946 if (--width <= 0) goto done;
947 *dest++ = (7*source[9] + 1*source[10]) >> 3; 947 *dest++ = (7*source[9] + 1*source[10]) >> 3;
948done: 948done:
949 949
950 xine_profiler_stop_count(prof_scale_line); 950 xine_profiler_stop_count(prof_scale_line);
951} 951}
952 952
953 953
954/* 954/*
955 * Interpolates 24 output pixels from 11 source pixels using shifts. 955 * Interpolates 24 output pixels from 11 source pixels using shifts.
956 * Useful for scaling a PAL vcd input source to 4:3 display format 956 * Useful for scaling a PAL vcd input source to 4:3 display format
957 * at 2*zoom. 957 * at 2*zoom.
958 */ 958 */
959static void scale_line_11_24 (uint8_t *source, uint8_t *dest, 959static void scale_line_11_24 (uint8_t *source, uint8_t *dest,
960 int width, int step) { 960 int width, int step) {
961 961
962 int p1, p2; 962 int p1, p2;
963 963
964 xine_profiler_start_count(prof_scale_line); 964 xine_profiler_start_count(prof_scale_line);
965 965
966 while ((width -= 24) >= 0) { 966 while ((width -= 24) >= 0) {
967 p1 = source[0]; 967 p1 = source[0];
968 p2 = source[1]; 968 p2 = source[1];
969 dest[0] = p1; 969 dest[0] = p1;
970 dest[1] = (1*p1 + 1*p2) >> 1; 970 dest[1] = (1*p1 + 1*p2) >> 1;
971 dest[2] = (1*p1 + 7*p2) >> 3; 971 dest[2] = (1*p1 + 7*p2) >> 3;
972 p1 = source[2]; 972 p1 = source[2];
973 dest[3] = (5*p2 + 3*p1) >> 3; 973 dest[3] = (5*p2 + 3*p1) >> 3;
974 dest[4] = (1*p2 + 7*p1) >> 3; 974 dest[4] = (1*p2 + 7*p1) >> 3;
975 p2 = source[3]; 975 p2 = source[3];
976 dest[5] = (3*p1 + 1*p2) >> 2; 976 dest[5] = (3*p1 + 1*p2) >> 2;
977 dest[6] = (1*p1 + 3*p2) >> 2; 977 dest[6] = (1*p1 + 3*p2) >> 2;
978 p1 = source[4]; 978 p1 = source[4];
979 dest[7] = (3*p2 + 1*p1) >> 2; 979 dest[7] = (3*p2 + 1*p1) >> 2;
980 dest[8] = (3*p2 + 5*p1) >> 3; 980 dest[8] = (3*p2 + 5*p1) >> 3;
981 p2 = source[5]; 981 p2 = source[5];
982 dest[9] = (7*p1 + 1*p2) >> 3; 982 dest[9] = (7*p1 + 1*p2) >> 3;
983 dest[10] = (3*p1 + 5*p2) >> 3; 983 dest[10] = (3*p1 + 5*p2) >> 3;
984 p1 = source[6]; 984 p1 = source[6];
985 dest[11] = p2; 985 dest[11] = p2;
986 dest[12] = (1*p2 + 1*p1) >> 1; 986 dest[12] = (1*p2 + 1*p1) >> 1;
987 dest[13] = p1; 987 dest[13] = p1;
988 p2 = source[7]; 988 p2 = source[7];
989 dest[14] = (5*p1 + 3*p2) >> 3; 989 dest[14] = (5*p1 + 3*p2) >> 3;
990 dest[15] = (1*p1 + 7*p2) >> 3; 990 dest[15] = (1*p1 + 7*p2) >> 3;
991 p1 = source[8]; 991 p1 = source[8];
992 dest[16] = (5*p2 + 3*p1) >> 3; 992 dest[16] = (5*p2 + 3*p1) >> 3;
993 dest[17] = (1*p2 + 3*p1) >> 2; 993 dest[17] = (1*p2 + 3*p1) >> 2;
994 p2 = source[9]; 994 p2 = source[9];
995 dest[18] = (3*p1 + 1*p2) >> 2; 995 dest[18] = (3*p1 + 1*p2) >> 2;
996 dest[19] = (1*p1 + 3*p2) >> 2; 996 dest[19] = (1*p1 + 3*p2) >> 2;
997 p1 = source[10]; 997 p1 = source[10];
998 dest[20] = (7*p2 + 1*p1) >> 3; 998 dest[20] = (7*p2 + 1*p1) >> 3;
999 dest[21] = (3*p2 + 5*p1) >> 3; 999 dest[21] = (3*p2 + 5*p1) >> 3;
1000 p2 = source[11]; 1000 p2 = source[11];
1001 dest[22] = (7*p1 + 1*p2) >> 3; 1001 dest[22] = (7*p1 + 1*p2) >> 3;
1002 dest[23] = (1*p1 + 1*p2) >> 1; 1002 dest[23] = (1*p1 + 1*p2) >> 1;
1003 source += 11; 1003 source += 11;
1004 dest += 24; 1004 dest += 24;
1005 } 1005 }
1006 1006
1007 if ((width += 24) <= 0) goto done; 1007 if ((width += 24) <= 0) goto done;
1008 *dest++ = source[0]; 1008 *dest++ = source[0];
1009 if (--width <= 0) goto done; 1009 if (--width <= 0) goto done;
1010 *dest++ = (1*source[0] + 1*source[1]) >> 1; 1010 *dest++ = (1*source[0] + 1*source[1]) >> 1;
1011 if (--width <= 0) goto done; 1011 if (--width <= 0) goto done;
1012 *dest++ = (1*source[0] + 7*source[1]) >> 3; 1012 *dest++ = (1*source[0] + 7*source[1]) >> 3;
1013 if (--width <= 0) goto done; 1013 if (--width <= 0) goto done;
1014 *dest++ = (5*source[1] + 3*source[2]) >> 3; 1014 *dest++ = (5*source[1] + 3*source[2]) >> 3;
1015 if (--width <= 0) goto done; 1015 if (--width <= 0) goto done;
1016 *dest++ = (1*source[1] + 7*source[2]) >> 3; 1016 *dest++ = (1*source[1] + 7*source[2]) >> 3;
1017 if (--width <= 0) goto done; 1017 if (--width <= 0) goto done;
1018 *dest++ = (3*source[2] + 1*source[3]) >> 2; 1018 *dest++ = (3*source[2] + 1*source[3]) >> 2;
1019 if (--width <= 0) goto done; 1019 if (--width <= 0) goto done;
1020 *dest++ = (1*source[2] + 3*source[3]) >> 2; 1020 *dest++ = (1*source[2] + 3*source[3]) >> 2;
1021 if (--width <= 0) goto done; 1021 if (--width <= 0) goto done;
1022 *dest++ = (3*source[3] + 1*source[4]) >> 2; 1022 *dest++ = (3*source[3] + 1*source[4]) >> 2;
1023 if (--width <= 0) goto done; 1023 if (--width <= 0) goto done;
1024 *dest++ = (3*source[3] + 5*source[4]) >> 3; 1024 *dest++ = (3*source[3] + 5*source[4]) >> 3;
1025 if (--width <= 0) goto done; 1025 if (--width <= 0) goto done;
1026 *dest++ = (7*source[4] + 1*source[5]) >> 3; 1026 *dest++ = (7*source[4] + 1*source[5]) >> 3;
1027 if (--width <= 0) goto done; 1027 if (--width <= 0) goto done;
1028 *dest++ = (3*source[4] + 5*source[5]) >> 3; 1028 *dest++ = (3*source[4] + 5*source[5]) >> 3;
1029 if (--width <= 0) goto done; 1029 if (--width <= 0) goto done;
1030 *dest++ = source[5]; 1030 *dest++ = source[5];
1031 if (--width <= 0) goto done; 1031 if (--width <= 0) goto done;
1032 *dest++ = (1*source[5] + 1*source[6]) >> 1; 1032 *dest++ = (1*source[5] + 1*source[6]) >> 1;
1033 if (--width <= 0) goto done; 1033 if (--width <= 0) goto done;
1034 *dest++ = source[6]; 1034 *dest++ = source[6];
1035 if (--width <= 0) goto done; 1035 if (--width <= 0) goto done;
1036 *dest++ = (5*source[6] + 3*source[7]) >> 3; 1036 *dest++ = (5*source[6] + 3*source[7]) >> 3;
1037 if (--width <= 0) goto done; 1037 if (--width <= 0) goto done;
1038 *dest++ = (1*source[6] + 7*source[7]) >> 3; 1038 *dest++ = (1*source[6] + 7*source[7]) >> 3;
1039 if (--width <= 0) goto done; 1039 if (--width <= 0) goto done;
1040 *dest++ = (5*source[7] + 3*source[8]) >> 3; 1040 *dest++ = (5*source[7] + 3*source[8]) >> 3;
1041 if (--width <= 0) goto done; 1041 if (--width <= 0) goto done;
1042 *dest++ = (1*source[7] + 3*source[8]) >> 2; 1042 *dest++ = (1*source[7] + 3*source[8]) >> 2;
1043 if (--width <= 0) goto done; 1043 if (--width <= 0) goto done;
1044 *dest++ = (3*source[8] + 1*source[9]) >> 2; 1044 *dest++ = (3*source[8] + 1*source[9]) >> 2;
1045 if (--width <= 0) goto done; 1045 if (--width <= 0) goto done;
1046 *dest++ = (1*source[8] + 3*source[9]) >> 2; 1046 *dest++ = (1*source[8] + 3*source[9]) >> 2;
1047 if (--width <= 0) goto done; 1047 if (--width <= 0) goto done;
1048 *dest++ = (7*source[9] + 1*source[10]) >> 3; 1048 *dest++ = (7*source[9] + 1*source[10]) >> 3;
1049 if (--width <= 0) goto done; 1049 if (--width <= 0) goto done;
1050 *dest++ = (3*source[9] + 5*source[10]) >> 3; 1050 *dest++ = (3*source[9] + 5*source[10]) >> 3;
1051 if (--width <= 0) goto done; 1051 if (--width <= 0) goto done;
1052 *dest++ = (7*source[10] + 1*source[11]) >> 3; 1052 *dest++ = (7*source[10] + 1*source[11]) >> 3;
1053done: 1053done:
1054 1054
1055 xine_profiler_stop_count(prof_scale_line); 1055 xine_profiler_stop_count(prof_scale_line);
1056} 1056}
1057 1057
1058 1058
1059/* 1059/*
1060 * Interpolates 8 output pixels from 5 source pixels using shifts. 1060 * Interpolates 8 output pixels from 5 source pixels using shifts.
1061 * Useful for scaling a PAL svcd input source to 4:3 display format. 1061 * Useful for scaling a PAL svcd input source to 4:3 display format.
1062 */ 1062 */
1063static void scale_line_5_8 (uint8_t *source, uint8_t *dest, 1063static void scale_line_5_8 (uint8_t *source, uint8_t *dest,
1064 int width, int step) { 1064 int width, int step) {
1065 1065
1066 int p1, p2; 1066 int p1, p2;
1067 1067
1068 xine_profiler_start_count(prof_scale_line); 1068 xine_profiler_start_count(prof_scale_line);
1069 1069
1070 while ((width -= 8) >= 0) { 1070 while ((width -= 8) >= 0) {
1071 p1 = source[0]; 1071 p1 = source[0];
1072 p2 = source[1]; 1072 p2 = source[1];
1073 dest[0] = p1; 1073 dest[0] = p1;
1074 dest[1] = (3*p1 + 5*p2) >> 3; 1074 dest[1] = (3*p1 + 5*p2) >> 3;
1075 p1 = source[2]; 1075 p1 = source[2];
1076 dest[2] = (3*p2 + 1*p1) >> 2; 1076 dest[2] = (3*p2 + 1*p1) >> 2;
1077 dest[3] = (1*p2 + 7*p1) >> 3; 1077 dest[3] = (1*p2 + 7*p1) >> 3;
1078 p2 = source[3]; 1078 p2 = source[3];
1079 dest[4] = (1*p1 + 1*p2) >> 1; 1079 dest[4] = (1*p1 + 1*p2) >> 1;
1080 p1 = source[4]; 1080 p1 = source[4];
1081 dest[5] = (7*p2 + 1*p1) >> 3; 1081 dest[5] = (7*p2 + 1*p1) >> 3;
1082 dest[6] = (1*p2 + 3*p1) >> 2; 1082 dest[6] = (1*p2 + 3*p1) >> 2;
1083 p2 = source[5]; 1083 p2 = source[5];
1084 dest[7] = (5*p1 + 3*p2) >> 3; 1084 dest[7] = (5*p1 + 3*p2) >> 3;
1085 source += 5; 1085 source += 5;
1086 dest += 8; 1086 dest += 8;
1087 } 1087 }
1088 1088
1089 if ((width += 8) <= 0) goto done; 1089 if ((width += 8) <= 0) goto done;
1090 *dest++ = source[0]; 1090 *dest++ = source[0];
1091 if (--width <= 0) goto done; 1091 if (--width <= 0) goto done;
1092 *dest++ = (3*source[0] + 5*source[1]) >> 3; 1092 *dest++ = (3*source[0] + 5*source[1]) >> 3;
1093 if (--width <= 0) goto done; 1093 if (--width <= 0) goto done;
1094 *dest++ = (3*source[1] + 1*source[2]) >> 2; 1094 *dest++ = (3*source[1] + 1*source[2]) >> 2;
1095 if (--width <= 0) goto done; 1095 if (--width <= 0) goto done;
1096 *dest++ = (1*source[1] + 7*source[2]) >> 3; 1096 *dest++ = (1*source[1] + 7*source[2]) >> 3;
1097 if (--width <= 0) goto done; 1097 if (--width <= 0) goto done;
1098 *dest++ = (1*source[2] + 1*source[3]) >> 1; 1098 *dest++ = (1*source[2] + 1*source[3]) >> 1;
1099 if (--width <= 0) goto done; 1099 if (--width <= 0) goto done;
1100 *dest++ = (7*source[3] + 1*source[4]) >> 3; 1100 *dest++ = (7*source[3] + 1*source[4]) >> 3;
1101 if (--width <= 0) goto done; 1101 if (--width <= 0) goto done;
1102 *dest++ = (1*source[3] + 3*source[4]) >> 2; 1102 *dest++ = (1*source[3] + 3*source[4]) >> 2;
1103done: 1103done:
1104 1104
1105 xine_profiler_stop_count(prof_scale_line); 1105 xine_profiler_stop_count(prof_scale_line);
1106} 1106}
1107 1107
1108 1108
1109/* 1109/*
1110 * Interpolates 4 output pixels from 3 source pixels using shifts. 1110 * Interpolates 4 output pixels from 3 source pixels using shifts.
1111 * Useful for scaling a NTSC svcd input source to 4:3 display format. 1111 * Useful for scaling a NTSC svcd input source to 4:3 display format.
1112 */ 1112 */
1113static void scale_line_3_4 (uint8_t *source, uint8_t *dest, 1113static void scale_line_3_4 (uint8_t *source, uint8_t *dest,
1114 int width, int step) { 1114 int width, int step) {
1115 1115
1116 int p1, p2; 1116 int p1, p2;
1117 1117
1118 xine_profiler_start_count(prof_scale_line); 1118 xine_profiler_start_count(prof_scale_line);
1119 1119
1120 while ((width -= 4) >= 0) { 1120 while ((width -= 4) >= 0) {
1121 p1 = source[0]; 1121 p1 = source[0];
1122 p2 = source[1]; 1122 p2 = source[1];
1123 dest[0] = p1; 1123 dest[0] = p1;
1124 dest[1] = (1*p1 + 3*p2) >> 2; 1124 dest[1] = (1*p1 + 3*p2) >> 2;
1125 p1 = source[2]; 1125 p1 = source[2];
1126 dest[2] = (1*p2 + 1*p1) >> 1; 1126 dest[2] = (1*p2 + 1*p1) >> 1;
1127 p2 = source[3]; 1127 p2 = source[3];
1128 dest[3] = (3*p1 + 1*p2) >> 2; 1128 dest[3] = (3*p1 + 1*p2) >> 2;
1129 source += 3; 1129 source += 3;
1130 dest += 4; 1130 dest += 4;
1131 } 1131 }
1132 1132
1133 if ((width += 4) <= 0) goto done; 1133 if ((width += 4) <= 0) goto done;
1134 *dest++ = source[0]; 1134 *dest++ = source[0];
1135 if (--width <= 0) goto done; 1135 if (--width <= 0) goto done;
1136 *dest++ = (1*source[0] + 3*source[1]) >> 2; 1136 *dest++ = (1*source[0] + 3*source[1]) >> 2;
1137 if (--width <= 0) goto done; 1137 if (--width <= 0) goto done;
1138 *dest++ = (1*source[1] + 1*source[2]) >> 1; 1138 *dest++ = (1*source[1] + 1*source[2]) >> 1;
1139done: 1139done:
1140 1140
1141 xine_profiler_stop_count(prof_scale_line); 1141 xine_profiler_stop_count(prof_scale_line);
1142} 1142}
1143 1143
1144 1144
1145/* Interpolate 2 output pixels from one source pixel. */ 1145/* Interpolate 2 output pixels from one source pixel. */
1146 1146
1147static void scale_line_1_2 (uint8_t *source, uint8_t *dest, 1147static void scale_line_1_2 (uint8_t *source, uint8_t *dest,
1148 int width, int step) { 1148 int width, int step) {
1149 int p1, p2; 1149 int p1, p2;
1150 1150
1151 xine_profiler_start_count(prof_scale_line); 1151 xine_profiler_start_count(prof_scale_line);
1152 1152
1153 p1 = *source; 1153 p1 = *source;
1154 while ((width -= 4) >= 0) { 1154 while ((width -= 4) >= 0) {
1155 *dest++ = p1; 1155 *dest++ = p1;
1156 p2 = *++source; 1156 p2 = *++source;
1157 *dest++ = (p1 + p2) >> 1; 1157 *dest++ = (p1 + p2) >> 1;
1158 *dest++ = p2; 1158 *dest++ = p2;
1159 p1 = *++source; 1159 p1 = *++source;
1160 *dest++ = (p2 + p1) >> 1; 1160 *dest++ = (p2 + p1) >> 1;
1161 } 1161 }
1162 1162
1163 if ((width += 4) <= 0) goto done; 1163 if ((width += 4) <= 0) goto done;
1164 *dest++ = source[0]; 1164 *dest++ = source[0];
1165 if (--width <= 0) goto done; 1165 if (--width <= 0) goto done;
1166 *dest++ = (source[0] + source[1]) >> 1; 1166 *dest++ = (source[0] + source[1]) >> 1;
1167 if (--width <= 0) goto done; 1167 if (--width <= 0) goto done;
1168 *dest++ = source[1]; 1168 *dest++ = source[1];
1169 done: 1169 done:
1170 1170
1171 xine_profiler_stop_count(prof_scale_line); 1171 xine_profiler_stop_count(prof_scale_line);
1172} 1172}
1173 1173
1174 1174
1175/* 1175/*
1176 * Scale line with no horizontal scaling. For NTSC mpeg2 dvd input in 1176 * Scale line with no horizontal scaling. For NTSC mpeg2 dvd input in
1177 * 4:3 output format (720x480 -> 720x540) 1177 * 4:3 output format (720x480 -> 720x540)
1178 */ 1178 */
1179static void scale_line_1_1 (uint8_t *source, uint8_t *dest, 1179static void scale_line_1_1 (uint8_t *source, uint8_t *dest,
1180 int width, int step) { 1180 int width, int step) {
1181 1181
1182 xine_profiler_start_count(prof_scale_line); 1182 xine_profiler_start_count(prof_scale_line);
1183 xine_fast_memcpy(dest, source, width); 1183 xine_fast_memcpy(dest, source, width);
1184 xine_profiler_stop_count(prof_scale_line); 1184 xine_profiler_stop_count(prof_scale_line);
1185} 1185}
1186 1186
1187 1187
1188static scale_line_func_t find_scale_line_func(int step) { 1188static scale_line_func_t find_scale_line_func(int step) {
1189 static struct { 1189 static struct {
1190 int src_step; 1190 int src_step;
1191 int dest_step; 1191 int dest_step;
1192 scale_line_func_tfunc; 1192 scale_line_func_tfunc;
1193 char *desc; 1193 char *desc;
1194 } scale_line[] = { 1194 } scale_line[] = {
1195 { 15, 16, scale_line_15_16, "dvd 4:3(pal)" }, 1195 { 15, 16, scale_line_15_16, "dvd 4:3(pal)" },
1196 { 45, 64, scale_line_45_64, "dvd 16:9(pal), fullscreen(1024x768)" }, 1196 { 45, 64, scale_line_45_64, "dvd 16:9(pal), fullscreen(1024x768)" },
1197 { 9, 16, scale_line_9_16, "dvd fullscreen(1280x1024)" }, 1197 { 9, 16, scale_line_9_16, "dvd fullscreen(1280x1024)" },
1198 { 45, 53, scale_line_45_53, "dvd 16:9(ntsc)" }, 1198 { 45, 53, scale_line_45_53, "dvd 16:9(ntsc)" },
1199 { 11, 12, scale_line_11_12, "vcd 4:3(pal)" }, 1199 { 11, 12, scale_line_11_12, "vcd 4:3(pal)" },
1200 { 11, 24, scale_line_11_24, "vcd 4:3(pal) 2*zoom" }, 1200 { 11, 24, scale_line_11_24, "vcd 4:3(pal) 2*zoom" },
1201 { 5, 8, scale_line_5_8, "svcd 4:3(pal)" }, 1201 { 5, 8, scale_line_5_8, "svcd 4:3(pal)" },
1202 { 3, 4, scale_line_3_4, "svcd 4:3(ntsc)" }, 1202 { 3, 4, scale_line_3_4, "svcd 4:3(ntsc)" },
1203 { 1, 2, scale_line_1_2, "2*zoom" }, 1203 { 1, 2, scale_line_1_2, "2*zoom" },
1204 { 1, 1, scale_line_1_1, "non-scaled" }, 1204 { 1, 1, scale_line_1_1, "non-scaled" },
1205 }; 1205 };
1206 int i; 1206 int i;
1207 1207
1208 for (i = 0; i < sizeof(scale_line)/sizeof(scale_line[0]); i++) { 1208 for (i = 0; i < sizeof(scale_line)/sizeof(scale_line[0]); i++) {
1209 if (step == scale_line[i].src_step*32768/scale_line[i].dest_step) { 1209 if (step == scale_line[i].src_step*32768/scale_line[i].dest_step) {
1210 printf("yuv2rgb: using %s optimized scale_line\n", scale_line[i].desc); 1210 //printf("yuv2rgb: using %s optimized scale_line\n", scale_line[i].desc);
1211 return scale_line[i].func; 1211 return scale_line[i].func;
1212 } 1212 }
1213 } 1213 }
1214 printf("yuv2rgb: using generic scale_line with interpolation\n"); 1214 //printf("yuv2rgb: using generic scale_line with interpolation\n");
1215 return scale_line_gen; 1215 return scale_line_gen;
1216 1216
1217} 1217}
1218 1218
1219 1219
1220static void scale_line_2 (uint8_t *source, uint8_t *dest, 1220static void scale_line_2 (uint8_t *source, uint8_t *dest,
1221 int width, int step) { 1221 int width, int step) {
1222 int p1; 1222 int p1;
1223 int p2; 1223 int p2;
1224 int dx; 1224 int dx;
1225 1225
1226 p1 = *source; source+=2; 1226 p1 = *source; source+=2;
1227 p2 = *source; source+=2; 1227 p2 = *source; source+=2;
1228 dx = 0; 1228 dx = 0;
1229 1229
1230 while (width) { 1230 while (width) {
1231 1231
1232 *dest = (p1 * (32768 - dx) + p2 * dx) / 32768; 1232 *dest = (p1 * (32768 - dx) + p2 * dx) / 32768;
1233 1233
1234 dx += step; 1234 dx += step;
1235 while (dx > 32768) { 1235 while (dx > 32768) {
1236 dx -= 32768; 1236 dx -= 32768;
1237 p1 = p2; 1237 p1 = p2;
1238 p2 = *source; 1238 p2 = *source;
1239 source+=2; 1239 source+=2;
1240 } 1240 }
1241 1241
1242 dest ++; 1242 dest ++;
1243 width --; 1243 width --;
1244 } 1244 }
1245} 1245}
1246 1246
1247static void scale_line_4 (uint8_t *source, uint8_t *dest, 1247static void scale_line_4 (uint8_t *source, uint8_t *dest,
1248 int width, int step) { 1248 int width, int step) {
1249 int p1; 1249 int p1;
1250 int p2; 1250 int p2;
1251 int dx; 1251 int dx;
1252 1252
1253 p1 = *source; source+=4; 1253 p1 = *source; source+=4;
1254 p2 = *source; source+=4; 1254 p2 = *source; source+=4;
1255 dx = 0; 1255 dx = 0;
1256 1256
1257 while (width) { 1257 while (width) {
1258 1258
1259 *dest = (p1 * (32768 - dx) + p2 * dx) / 32768; 1259 *dest = (p1 * (32768 - dx) + p2 * dx) / 32768;
1260 1260
1261 dx += step; 1261 dx += step;
1262 while (dx > 32768) { 1262 while (dx > 32768) {
1263 dx -= 32768; 1263 dx -= 32768;
1264 p1 = p2; 1264 p1 = p2;
1265 p2 = *source; 1265 p2 = *source;
1266 source+=4; 1266 source+=4;
1267 } 1267 }
1268 1268
1269 dest ++; 1269 dest ++;
1270 width --; 1270 width --;
1271 } 1271 }
1272} 1272}
1273 1273
1274 1274
1275 #define RGB(i) \ 1275 #define RGB(i) \
1276 U = pu[i]; \ 1276 U = pu[i]; \
1277 V = pv[i]; \ 1277 V = pv[i]; \
1278 r = this->table_rV[V]; \ 1278 r = this->table_rV[V]; \
1279 g = (void *) (((uint8_t *)this->table_gU[U]) + this->table_gV[V]);\ 1279 g = (void *) (((uint8_t *)this->table_gU[U]) + this->table_gV[V]);\
1280 b = this->table_bU[U]; 1280 b = this->table_bU[U];
1281 1281
1282 #define DST1(i) \ 1282 #define DST1(i) \
1283 Y = py_1[2*i]; \ 1283 Y = py_1[2*i]; \
1284 dst_1[2*i] = r[Y] + g[Y] + b[Y];\ 1284 dst_1[2*i] = r[Y] + g[Y] + b[Y];\
1285 Y = py_1[2*i+1]; \ 1285 Y = py_1[2*i+1]; \
1286 dst_1[2*i+1] = r[Y] + g[Y] + b[Y]; 1286 dst_1[2*i+1] = r[Y] + g[Y] + b[Y];
1287 1287
1288 #define DST2(i) \ 1288 #define DST2(i) \
1289 Y = py_2[2*i]; \ 1289 Y = py_2[2*i]; \
1290 dst_2[2*i] = r[Y] + g[Y] + b[Y];\ 1290 dst_2[2*i] = r[Y] + g[Y] + b[Y];\
1291 Y = py_2[2*i+1]; \ 1291 Y = py_2[2*i+1]; \
1292 dst_2[2*i+1] = r[Y] + g[Y] + b[Y]; 1292 dst_2[2*i+1] = r[Y] + g[Y] + b[Y];
1293 1293
1294 #define DST1RGB(i) \ 1294 #define DST1RGB(i) \
1295 Y = py_1[2*i]; \ 1295 Y = py_1[2*i]; \
1296 dst_1[6*i] = r[Y]; dst_1[6*i+1] = g[Y]; dst_1[6*i+2] = b[Y];\ 1296 dst_1[6*i] = r[Y]; dst_1[6*i+1] = g[Y]; dst_1[6*i+2] = b[Y];\
1297 Y = py_1[2*i+1]; \ 1297 Y = py_1[2*i+1]; \
1298 dst_1[6*i+3] = r[Y]; dst_1[6*i+4] = g[Y]; dst_1[6*i+5] = b[Y]; 1298 dst_1[6*i+3] = r[Y]; dst_1[6*i+4] = g[Y]; dst_1[6*i+5] = b[Y];
1299 1299
1300 #define DST2RGB(i) \ 1300 #define DST2RGB(i) \
1301 Y = py_2[2*i]; \ 1301 Y = py_2[2*i]; \
1302 dst_2[6*i] = r[Y]; dst_2[6*i+1] = g[Y]; dst_2[6*i+2] = b[Y];\ 1302 dst_2[6*i] = r[Y]; dst_2[6*i+1] = g[Y]; dst_2[6*i+2] = b[Y];\
1303 Y = py_2[2*i+1]; \ 1303 Y = py_2[2*i+1]; \
1304 dst_2[6*i+3] = r[Y]; dst_2[6*i+4] = g[Y]; dst_2[6*i+5] = b[Y]; 1304 dst_2[6*i+3] = r[Y]; dst_2[6*i+4] = g[Y]; dst_2[6*i+5] = b[Y];
1305 1305
1306 #define DST1BGR(i) \ 1306 #define DST1BGR(i) \
1307 Y = py_1[2*i]; \ 1307 Y = py_1[2*i]; \
1308 dst_1[6*i] = b[Y]; dst_1[6*i+1] = g[Y]; dst_1[6*i+2] = r[Y];\ 1308 dst_1[6*i] = b[Y]; dst_1[6*i+1] = g[Y]; dst_1[6*i+2] = r[Y];\
1309 Y = py_1[2*i+1]; \ 1309 Y = py_1[2*i+1]; \
1310 dst_1[6*i+3] = b[Y]; dst_1[6*i+4] = g[Y]; dst_1[6*i+5] = r[Y]; 1310 dst_1[6*i+3] = b[Y]; dst_1[6*i+4] = g[Y]; dst_1[6*i+5] = r[Y];
1311 1311
1312 #define DST2BGR(i) \ 1312 #define DST2BGR(i) \
1313 Y = py_2[2*i]; \ 1313 Y = py_2[2*i]; \
1314 dst_2[6*i] = b[Y]; dst_2[6*i+1] = g[Y]; dst_2[6*i+2] = r[Y];\ 1314 dst_2[6*i] = b[Y]; dst_2[6*i+1] = g[Y]; dst_2[6*i+2] = r[Y];\
1315 Y = py_2[2*i+1]; \ 1315 Y = py_2[2*i+1]; \
1316 dst_2[6*i+3] = b[Y]; dst_2[6*i+4] = g[Y]; dst_2[6*i+5] = r[Y]; 1316 dst_2[6*i+3] = b[Y]; dst_2[6*i+4] = g[Y]; dst_2[6*i+5] = r[Y];
1317 1317
1318 #define DST1CMAP(i) \ 1318 #define DST1CMAP(i) \
1319 Y = py_1[2*i]; \ 1319 Y = py_1[2*i]; \
1320 dst_1[2*i] = this->cmap[r[Y] + g[Y] + b[Y]]; \ 1320 dst_1[2*i] = this->cmap[r[Y] + g[Y] + b[Y]]; \
1321 Y = py_1[2*i+1]; \ 1321 Y = py_1[2*i+1]; \
1322 dst_1[2*i+1] = this->cmap[r[Y] + g[Y] + b[Y]]; 1322 dst_1[2*i+1] = this->cmap[r[Y] + g[Y] + b[Y]];
1323 1323
1324 #define DST2CMAP(i) \ 1324 #define DST2CMAP(i) \
1325 Y = py_2[2*i]; \ 1325 Y = py_2[2*i]; \
1326 dst_2[2*i] = this->cmap[r[Y] + g[Y] + b[Y]]; \ 1326 dst_2[2*i] = this->cmap[r[Y] + g[Y] + b[Y]]; \
1327 Y = py_2[2*i+1]; \ 1327 Y = py_2[2*i+1]; \
1328 dst_2[2*i+1] = this->cmap[r[Y] + g[Y] + b[Y]]; 1328 dst_2[2*i+1] = this->cmap[r[Y] + g[Y] + b[Y]];
1329 1329
1330static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, 1330static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst,
1331 uint8_t * _py, uint8_t * _pu, uint8_t * _pv) 1331 uint8_t * _py, uint8_t * _pu, uint8_t * _pv)
1332{ 1332{
1333 int U, V, Y; 1333 int U, V, Y;
1334 uint8_t * py_1, * py_2, * pu, * pv; 1334 uint8_t * py_1, * py_2, * pu, * pv;
1335 uint32_t * r, * g, * b; 1335 uint32_t * r, * g, * b;
1336 uint32_t * dst_1, * dst_2; 1336 uint32_t * dst_1, * dst_2;
1337 int width, height, dst_height; 1337 int width, height, dst_height;
1338 int dy; 1338 int dy;
1339 1339
1340 if (this->do_scale) { 1340 if (this->do_scale) {
1341 scale_line_func_t scale_line = this->scale_line; 1341 scale_line_func_t scale_line = this->scale_line;
1342 1342
1343 scale_line (_pu, this->u_buffer, 1343 scale_line (_pu, this->u_buffer,
1344 this->dest_width >> 1, this->step_dx); 1344 this->dest_width >> 1, this->step_dx);
1345 scale_line (_pv, this->v_buffer, 1345 scale_line (_pv, this->v_buffer,
1346 this->dest_width >> 1, this->step_dx); 1346 this->dest_width >> 1, this->step_dx);
1347 scale_line (_py, this->y_buffer, 1347 scale_line (_py, this->y_buffer,
1348 this->dest_width, this->step_dx); 1348 this->dest_width, this->step_dx);
1349 1349
1350 dy = 0; 1350 dy = 0;
1351 dst_height = this->dest_height; 1351 dst_height = this->dest_height;
1352 1352
1353 for (height = 0;; ) { 1353 for (height = 0;; ) {
1354 dst_1 = (uint32_t*)_dst; 1354 dst_1 = (uint32_t*)_dst;
1355 py_1 = this->y_buffer; 1355 py_1 = this->y_buffer;
1356 pu = this->u_buffer; 1356 pu = this->u_buffer;
1357 pv = this->v_buffer; 1357 pv = this->v_buffer;
1358 1358
1359 width = this->dest_width >> 3; 1359 width = this->dest_width >> 3;
1360 1360
1361 do { 1361 do {
1362 RGB(0); 1362 RGB(0);
1363 DST1(0); 1363 DST1(0);
1364 1364
1365 RGB(1); 1365 RGB(1);
1366 DST1(1); 1366 DST1(1);
1367 1367
1368 RGB(2); 1368 RGB(2);
1369 DST1(2); 1369 DST1(2);
1370 1370
1371 RGB(3); 1371 RGB(3);
1372 DST1(3); 1372 DST1(3);
1373 1373
1374 pu += 4; 1374 pu += 4;
1375 pv += 4; 1375 pv += 4;
1376 py_1 += 8; 1376 py_1 += 8;
1377 dst_1 += 8; 1377 dst_1 += 8;
1378 } while (--width); 1378 } while (--width);
1379 1379
1380 dy += this->step_dy; 1380 dy += this->step_dy;
1381 _dst += this->rgb_stride; 1381 _dst += this->rgb_stride;
1382 1382
1383 while (--dst_height > 0 && dy < 32768) { 1383 while (--dst_height > 0 && dy < 32768) {
1384 1384
1385 xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*4); 1385 xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*4);
1386 1386
1387 dy += this->step_dy; 1387 dy += this->step_dy;
1388 _dst += this->rgb_stride; 1388 _dst += this->rgb_stride;
1389 } 1389 }
1390 1390
1391 if (dst_height <= 0) 1391 if (dst_height <= 0)
1392 break; 1392 break;
1393 1393
1394 do { 1394 do {
1395 dy -= 32768; 1395 dy -= 32768;
1396 _py += this->y_stride; 1396 _py += this->y_stride;
1397 1397
1398 scale_line (_py, this->y_buffer, 1398 scale_line (_py, this->y_buffer,
1399 this->dest_width, this->step_dx); 1399 this->dest_width, this->step_dx);
1400 1400
1401 if (height & 1) { 1401 if (height & 1) {
1402 _pu += this->uv_stride; 1402 _pu += this->uv_stride;
1403 _pv += this->uv_stride; 1403 _pv += this->uv_stride;
1404 1404
1405 scale_line (_pu, this->u_buffer, 1405 scale_line (_pu, this->u_buffer,
1406 this->dest_width >> 1, this->step_dx); 1406 this->dest_width >> 1, this->step_dx);
1407 scale_line (_pv, this->v_buffer, 1407 scale_line (_pv, this->v_buffer,
1408 this->dest_width >> 1, this->step_dx); 1408 this->dest_width >> 1, this->step_dx);
1409 1409
1410 } 1410 }
1411 height++; 1411 height++;
1412 } while( dy>=32768); 1412 } while( dy>=32768);
1413 } 1413 }
1414 } else { 1414 } else {
1415 height = this->source_height >> 1; 1415 height = this->source_height >> 1;
1416 do { 1416 do {
1417 dst_1 = (uint32_t*)_dst; 1417 dst_1 = (uint32_t*)_dst;
1418 dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride ); 1418 dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride );
1419 py_1 = _py; 1419 py_1 = _py;
1420 py_2 = _py + this->y_stride; 1420 py_2 = _py + this->y_stride;
1421 pu = _pu; 1421 pu = _pu;
1422 pv = _pv; 1422 pv = _pv;
1423 1423
1424 width = this->source_width >> 3; 1424 width = this->source_width >> 3;
1425 do { 1425 do {
1426 RGB(0); 1426 RGB(0);
1427 DST1(0); 1427 DST1(0);
1428 DST2(0); 1428 DST2(0);
1429 1429
1430 RGB(1); 1430 RGB(1);
1431 DST2(1); 1431 DST2(1);
1432 DST1(1); 1432 DST1(1);
1433 1433
1434 RGB(2); 1434 RGB(2);
1435 DST1(2); 1435 DST1(2);
1436 DST2(2); 1436 DST2(2);
1437 1437
1438 RGB(3); 1438 RGB(3);
1439 DST2(3); 1439 DST2(3);
1440 DST1(3); 1440 DST1(3);
1441 1441
1442 pu += 4; 1442 pu += 4;
1443 pv += 4; 1443 pv += 4;
1444 py_1 += 8; 1444 py_1 += 8;
1445 py_2 += 8; 1445 py_2 += 8;
1446 dst_1 += 8; 1446 dst_1 += 8;
1447 dst_2 += 8; 1447 dst_2 += 8;
1448 } while (--width); 1448 } while (--width);
1449 1449
1450 _dst += 2 * this->rgb_stride; 1450 _dst += 2 * this->rgb_stride;
1451 _py += 2 * this->y_stride; 1451 _py += 2 * this->y_stride;
1452 _pu += this->uv_stride; 1452 _pu += this->uv_stride;
1453 _pv += this->uv_stride; 1453 _pv += this->uv_stride;
1454 1454
1455 } while (--height); 1455 } while (--height);
1456 } 1456 }
1457} 1457}
1458 1458
1459/* This is very near from the yuv2rgb_c_32 code */ 1459/* This is very near from the yuv2rgb_c_32 code */
1460static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, 1460static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst,
1461 uint8_t * _py, uint8_t * _pu, uint8_t * _pv) 1461 uint8_t * _py, uint8_t * _pu, uint8_t * _pv)
1462{ 1462{
1463 int U, V, Y; 1463 int U, V, Y;
1464 uint8_t * py_1, * py_2, * pu, * pv; 1464 uint8_t * py_1, * py_2, * pu, * pv;
1465 uint8_t * r, * g, * b; 1465 uint8_t * r, * g, * b;
1466 uint8_t * dst_1, * dst_2; 1466 uint8_t * dst_1, * dst_2;
1467 int width, height, dst_height; 1467 int width, height, dst_height;
1468 int dy; 1468 int dy;
1469 1469
1470 if (this->do_scale) { 1470 if (this->do_scale) {
1471 1471
1472 scale_line_func_t scale_line = this->scale_line; 1472 scale_line_func_t scale_line = this->scale_line;
1473 1473
1474 scale_line (_pu, this->u_buffer, 1474 scale_line (_pu, this->u_buffer,
1475 this->dest_width >> 1, this->step_dx); 1475 this->dest_width >> 1, this->step_dx);
1476 scale_line (_pv, this->v_buffer, 1476 scale_line (_pv, this->v_buffer,
1477 this->dest_width >> 1, this->step_dx); 1477 this->dest_width >> 1, this->step_dx);
1478 scale_line (_py, this->y_buffer, 1478 scale_line (_py, this->y_buffer,
1479 this->dest_width, this->step_dx); 1479 this->dest_width, this->step_dx);
1480 1480
1481 dy = 0; 1481 dy = 0;
1482 dst_height = this->dest_height; 1482 dst_height = this->dest_height;
1483 1483
1484 for (height = 0;; ) { 1484 for (height = 0;; ) {
1485 dst_1 = _dst; 1485 dst_1 = _dst;
1486 py_1 = this->y_buffer; 1486 py_1 = this->y_buffer;
1487 pu = this->u_buffer; 1487 pu = this->u_buffer;
1488 pv = this->v_buffer; 1488 pv = this->v_buffer;
1489 1489
1490 width = this->dest_width >> 3; 1490 width = this->dest_width >> 3;
1491 1491
1492 do { 1492 do {
1493 RGB(0); 1493 RGB(0);
1494 DST1RGB(0); 1494 DST1RGB(0);
1495 1495
1496 RGB(1); 1496 RGB(1);
1497 DST1RGB(1); 1497 DST1RGB(1);
1498 1498
1499 RGB(2); 1499 RGB(2);
1500 DST1RGB(2); 1500 DST1RGB(2);
1501 1501
1502 RGB(3); 1502 RGB(3);
1503 DST1RGB(3); 1503 DST1RGB(3);
1504 1504
1505 pu += 4; 1505 pu += 4;
1506 pv += 4; 1506 pv += 4;
1507 py_1 += 8; 1507 py_1 += 8;
1508 dst_1 += 24; 1508 dst_1 += 24;
1509 } while (--width); 1509 } while (--width);
1510 1510
1511 dy += this->step_dy; 1511 dy += this->step_dy;
1512 _dst += this->rgb_stride; 1512 _dst += this->rgb_stride;
1513 1513
1514 while (--dst_height > 0 && dy < 32768) { 1514 while (--dst_height > 0 && dy < 32768) {
1515 1515
1516 xine_fast_memcpy (_dst, _dst-this->rgb_stride, this->dest_width*3); 1516 xine_fast_memcpy (_dst, _dst-this->rgb_stride, this->dest_width*3);
1517 1517
1518 dy += this->step_dy; 1518 dy += this->step_dy;
1519 _dst += this->rgb_stride; 1519 _dst += this->rgb_stride;
1520 } 1520 }
1521 1521
1522 if (dst_height <= 0) 1522 if (dst_height <= 0)
1523 break; 1523 break;
1524 1524
1525 do { 1525 do {
1526 dy -= 32768; 1526 dy -= 32768;
1527 _py += this->y_stride; 1527 _py += this->y_stride;
1528 1528
1529 scale_line (_py, this->y_buffer, 1529 scale_line (_py, this->y_buffer,
1530 this->dest_width, this->step_dx); 1530 this->dest_width, this->step_dx);
1531 1531
1532 if (height & 1) { 1532 if (height & 1) {
1533 _pu += this->uv_stride; 1533 _pu += this->uv_stride;
1534 _pv += this->uv_stride; 1534 _pv += this->uv_stride;
1535 1535
1536 scale_line (_pu, this->u_buffer, 1536 scale_line (_pu, this->u_buffer,
1537 this->dest_width >> 1, this->step_dx); 1537 this->dest_width >> 1, this->step_dx);
1538 scale_line (_pv, this->v_buffer, 1538 scale_line (_pv, this->v_buffer,
1539 this->dest_width >> 1, this->step_dx); 1539 this->dest_width >> 1, this->step_dx);
1540 1540
1541 } 1541 }
1542 height++; 1542 height++;
1543 } while (dy>=32768); 1543 } while (dy>=32768);
1544 } 1544 }
1545 } else { 1545 } else {
1546 height = this->source_height >> 1; 1546 height = this->source_height >> 1;
1547 do { 1547 do {
1548 dst_1 = _dst; 1548 dst_1 = _dst;
1549 dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride ); 1549 dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride );
1550 py_1 = _py; 1550 py_1 = _py;
1551 py_2 = _py + this->y_stride; 1551 py_2 = _py + this->y_stride;
1552 pu = _pu; 1552 pu = _pu;
1553 pv = _pv; 1553 pv = _pv;
1554 1554
1555 width = this->source_width >> 3; 1555 width = this->source_width >> 3;
1556 do { 1556 do {
1557 RGB(0); 1557 RGB(0);
1558 DST1RGB(0); 1558 DST1RGB(0);
1559 DST2RGB(0); 1559 DST2RGB(0);
1560 1560
1561 RGB(1); 1561 RGB(1);
1562 DST2RGB(1); 1562 DST2RGB(1);
1563 DST1RGB(1); 1563 DST1RGB(1);
1564 1564
1565 RGB(2); 1565 RGB(2);
1566 DST1RGB(2); 1566 DST1RGB(2);
1567 DST2RGB(2); 1567 DST2RGB(2);
1568 1568
1569 RGB(3); 1569 RGB(3);
1570 DST2RGB(3); 1570 DST2RGB(3);
1571 DST1RGB(3); 1571 DST1RGB(3);
1572 1572
1573 pu += 4; 1573 pu += 4;
1574 pv += 4; 1574 pv += 4;
1575 py_1 += 8; 1575 py_1 += 8;
1576 py_2 += 8; 1576 py_2 += 8;
1577 dst_1 += 24; 1577 dst_1 += 24;
1578 dst_2 += 24; 1578 dst_2 += 24;
1579 } while (--width); 1579 } while (--width);
1580 1580
1581 _dst += 2 * this->rgb_stride; 1581 _dst += 2 * this->rgb_stride;
1582 _py += 2 * this->y_stride; 1582 _py += 2 * this->y_stride;
1583 _pu += this->uv_stride; 1583 _pu += this->uv_stride;
1584 _pv += this->uv_stride; 1584 _pv += this->uv_stride;
1585 1585
1586 } while (--height); 1586 } while (--height);
1587 } 1587 }
1588} 1588}
1589 1589
1590/* only trivial mods from yuv2rgb_c_24_rgb */ 1590/* only trivial mods from yuv2rgb_c_24_rgb */
1591static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, 1591static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst,
1592 uint8_t * _py, uint8_t * _pu, uint8_t * _pv) 1592 uint8_t * _py, uint8_t * _pu, uint8_t * _pv)
1593{ 1593{
1594 int U, V, Y; 1594 int U, V, Y;
1595 uint8_t * py_1, * py_2, * pu, * pv; 1595 uint8_t * py_1, * py_2, * pu, * pv;
1596 uint8_t * r, * g, * b; 1596 uint8_t * r, * g, * b;
1597 uint8_t * dst_1, * dst_2; 1597 uint8_t * dst_1, * dst_2;
1598 int width, height, dst_height; 1598 int width, height, dst_height;
1599 int dy; 1599 int dy;
1600 1600
1601 if (this->do_scale) { 1601 if (this->do_scale) {
1602 1602
1603 scale_line_func_t scale_line = this->scale_line; 1603 scale_line_func_t scale_line = this->scale_line;
1604 1604
1605 scale_line (_pu, this->u_buffer, 1605 scale_line (_pu, this->u_buffer,
1606 this->dest_width >> 1, this->step_dx); 1606 this->dest_width >> 1, this->step_dx);
1607 scale_line (_pv, this->v_buffer, 1607 scale_line (_pv, this->v_buffer,
1608 this->dest_width >> 1, this->step_dx); 1608 this->dest_width >> 1, this->step_dx);
1609 scale_line (_py, this->y_buffer, 1609 scale_line (_py, this->y_buffer,
1610 this->dest_width, this->step_dx); 1610 this->dest_width, this->step_dx);
1611 1611
1612 dy = 0; 1612 dy = 0;
1613 dst_height = this->dest_height; 1613 dst_height = this->dest_height;
1614 1614
1615 for (height = 0;; ) { 1615 for (height = 0;; ) {
1616 dst_1 = _dst; 1616 dst_1 = _dst;
1617 py_1 = this->y_buffer; 1617 py_1 = this->y_buffer;
1618 pu = this->u_buffer; 1618 pu = this->u_buffer;
1619 pv = this->v_buffer; 1619 pv = this->v_buffer;
1620 1620
1621 width = this->dest_width >> 3; 1621 width = this->dest_width >> 3;
1622 1622
1623 do { 1623 do {
1624 RGB(0); 1624 RGB(0);
1625 DST1BGR(0); 1625 DST1BGR(0);
1626 1626
1627 RGB(1); 1627 RGB(1);
1628 DST1BGR(1); 1628 DST1BGR(1);
1629 1629
1630 RGB(2); 1630 RGB(2);
1631 DST1BGR(2); 1631 DST1BGR(2);
1632 1632
1633 RGB(3); 1633 RGB(3);
1634 DST1BGR(3); 1634 DST1BGR(3);
1635 1635
1636 pu += 4; 1636 pu += 4;
1637 pv += 4; 1637 pv += 4;
1638 py_1 += 8; 1638 py_1 += 8;
1639 dst_1 += 24; 1639 dst_1 += 24;
1640 } while (--width); 1640 } while (--width);
1641 1641
1642 dy += this->step_dy; 1642 dy += this->step_dy;
1643 _dst += this->rgb_stride; 1643 _dst += this->rgb_stride;
1644 1644
1645 while (--dst_height > 0 && dy < 32768) { 1645 while (--dst_height > 0 && dy < 32768) {
1646 1646
1647 xine_fast_memcpy (_dst, _dst-this->rgb_stride, this->dest_width*3); 1647 xine_fast_memcpy (_dst, _dst-this->rgb_stride, this->dest_width*3);
1648 1648
1649 dy += this->step_dy; 1649 dy += this->step_dy;
1650 _dst += this->rgb_stride; 1650 _dst += this->rgb_stride;
1651 } 1651 }
1652 1652
1653 if (dst_height <= 0) 1653 if (dst_height <= 0)
1654 break; 1654 break;
1655 1655
1656 do { 1656 do {
1657 dy -= 32768; 1657 dy -= 32768;
1658 _py += this->y_stride; 1658 _py += this->y_stride;
1659 1659
1660 scale_line (_py, this->y_buffer, 1660 scale_line (_py, this->y_buffer,
1661 this->dest_width, this->step_dx); 1661 this->dest_width, this->step_dx);
1662 1662
1663 if (height & 1) { 1663 if (height & 1) {
1664 _pu += this->uv_stride; 1664 _pu += this->uv_stride;
1665 _pv += this->uv_stride; 1665 _pv += this->uv_stride;
1666 1666
1667 scale_line (_pu, this->u_buffer, 1667 scale_line (_pu, this->u_buffer,
1668 this->dest_width >> 1, this->step_dx); 1668 this->dest_width >> 1, this->step_dx);
1669 scale_line (_pv, this->v_buffer, 1669 scale_line (_pv, this->v_buffer,
1670 this->dest_width >> 1, this->step_dx); 1670 this->dest_width >> 1, this->step_dx);
1671 1671
1672 } 1672 }
1673 height++; 1673 height++;
1674 } while( dy>=32768 ); 1674 } while( dy>=32768 );
1675 } 1675 }
1676 1676
1677 } else { 1677 } else {
1678 height = this->source_height >> 1; 1678 height = this->source_height >> 1;
1679 do { 1679 do {
1680 dst_1 = _dst; 1680 dst_1 = _dst;
1681 dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride ); 1681 dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride );
1682 py_1 = _py; 1682 py_1 = _py;
1683 py_2 = _py + this->y_stride; 1683 py_2 = _py + this->y_stride;
1684 pu = _pu; 1684 pu = _pu;
1685 pv = _pv; 1685 pv = _pv;
1686 width = this->source_width >> 3; 1686 width = this->source_width >> 3;
1687 do { 1687 do {
1688 RGB(0); 1688 RGB(0);
1689 DST1BGR(0); 1689 DST1BGR(0);
1690 DST2BGR(0); 1690 DST2BGR(0);
1691 1691
1692 RGB(1); 1692 RGB(1);
1693 DST2BGR(1); 1693 DST2BGR(1);
1694 DST1BGR(1); 1694 DST1BGR(1);
1695 1695
1696 RGB(2); 1696 RGB(2);
1697 DST1BGR(2); 1697 DST1BGR(2);
1698 DST2BGR(2); 1698 DST2BGR(2);
1699 1699
1700 RGB(3); 1700 RGB(3);
1701 DST2BGR(3); 1701 DST2BGR(3);
1702 DST1BGR(3); 1702 DST1BGR(3);
1703 1703
1704 pu += 4; 1704 pu += 4;
1705 pv += 4; 1705 pv += 4;
1706 py_1 += 8; 1706 py_1 += 8;
1707 py_2 += 8; 1707 py_2 += 8;
1708 dst_1 += 24; 1708 dst_1 += 24;
1709 dst_2 += 24; 1709 dst_2 += 24;
1710 } while (--width); 1710 } while (--width);
1711 1711
1712 _dst += 2 * this->rgb_stride; 1712 _dst += 2 * this->rgb_stride;
1713 _py += 2 * this->y_stride; 1713 _py += 2 * this->y_stride;
1714 _pu += this->uv_stride; 1714 _pu += this->uv_stride;
1715 _pv += this->uv_stride; 1715 _pv += this->uv_stride;
1716 1716
1717 } while (--height); 1717 } while (--height);
1718 } 1718 }
1719} 1719}
1720 1720
1721/* This is exactly the same code as yuv2rgb_c_32 except for the types of */ 1721/* This is exactly the same code as yuv2rgb_c_32 except for the types of */
1722/* r, g, b, dst_1, dst_2 */ 1722/* r, g, b, dst_1, dst_2 */
1723static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, 1723static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst,
1724 uint8_t * _py, uint8_t * _pu, uint8_t * _pv) 1724 uint8_t * _py, uint8_t * _pu, uint8_t * _pv)
1725{ 1725{
1726 int U, V, Y; 1726 int U, V, Y;
1727 uint8_t * py_1, * py_2, * pu, * pv; 1727 uint8_t * py_1, * py_2, * pu, * pv;
1728 uint16_t * r, * g, * b; 1728 uint16_t * r, * g, * b;
1729 uint16_t * dst_1, * dst_2; 1729 uint16_t * dst_1, * dst_2;
1730 int width, height, dst_height; 1730 int width, height, dst_height;
1731 int dy; 1731 int dy;
1732 1732
1733 if (this->do_scale) { 1733 if (this->do_scale) {
1734 scale_line_func_t scale_line = this->scale_line; 1734 scale_line_func_t scale_line = this->scale_line;
1735 1735
1736 scale_line (_pu, this->u_buffer, 1736 scale_line (_pu, this->u_buffer,
1737 this->dest_width >> 1, this->step_dx); 1737 this->dest_width >> 1, this->step_dx);
1738 scale_line (_pv, this->v_buffer, 1738 scale_line (_pv, this->v_buffer,
1739 this->dest_width >> 1, this->step_dx); 1739 this->dest_width >> 1, this->step_dx);
1740 scale_line (_py, this->y_buffer, 1740 scale_line (_py, this->y_buffer,
1741 this->dest_width, this->step_dx); 1741 this->dest_width, this->step_dx);
1742 1742
1743 dy = 0; 1743 dy = 0;
1744 dst_height = this->dest_height; 1744 dst_height = this->dest_height;
1745 1745
1746 for (height = 0;; ) { 1746 for (height = 0;; ) {
1747 dst_1 = (uint16_t*)_dst; 1747 dst_1 = (uint16_t*)_dst;
1748 py_1 = this->y_buffer; 1748 py_1 = this->y_buffer;
1749 pu = this->u_buffer; 1749 pu = this->u_buffer;
1750 pv = this->v_buffer; 1750 pv = this->v_buffer;
1751 1751
1752 width = this->dest_width >> 3; 1752 width = this->dest_width >> 3;
1753 1753
1754 do { 1754 do {
1755 RGB(0); 1755 RGB(0);
1756 DST1(0); 1756 DST1(0);
1757 1757
1758 RGB(1); 1758 RGB(1);
1759 DST1(1); 1759 DST1(1);
1760 1760
1761 RGB(2); 1761 RGB(2);
1762 DST1(2); 1762 DST1(2);
1763 1763
1764 RGB(3); 1764 RGB(3);
1765 DST1(3); 1765 DST1(3);
1766 1766
1767 pu += 4; 1767 pu += 4;
1768 pv += 4; 1768 pv += 4;
1769 py_1 += 8; 1769 py_1 += 8;
1770 dst_1 += 8; 1770 dst_1 += 8;
1771 } while (--width); 1771 } while (--width);
1772 1772
1773 dy += this->step_dy; 1773 dy += this->step_dy;
1774 _dst += this->rgb_stride; 1774 _dst += this->rgb_stride;
1775 1775
1776 while (--dst_height > 0 && dy < 32768) { 1776 while (--dst_height > 0 && dy < 32768) {
1777 1777
1778 xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*2); 1778 xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*2);
1779 1779
1780 dy += this->step_dy; 1780 dy += this->step_dy;
1781 _dst += this->rgb_stride; 1781 _dst += this->rgb_stride;
1782 } 1782 }
1783 1783
1784 if (dst_height <= 0) 1784 if (dst_height <= 0)
1785 break; 1785 break;
1786 1786
1787 do { 1787 do {
1788 dy -= 32768; 1788 dy -= 32768;
1789 _py += this->y_stride; 1789 _py += this->y_stride;
1790 1790
1791 scale_line (_py, this->y_buffer, 1791 scale_line (_py, this->y_buffer,
1792 this->dest_width, this->step_dx); 1792 this->dest_width, this->step_dx);
1793 1793
1794 if (height & 1) { 1794 if (height & 1) {
1795 _pu += this->uv_stride; 1795 _pu += this->uv_stride;
1796 _pv += this->uv_stride; 1796 _pv += this->uv_stride;
1797 1797
1798 scale_line (_pu, this->u_buffer, 1798 scale_line (_pu, this->u_buffer,
1799 this->dest_width >> 1, this->step_dx); 1799 this->dest_width >> 1, this->step_dx);
1800 scale_line (_pv, this->v_buffer, 1800 scale_line (_pv, this->v_buffer,
1801 this->dest_width >> 1, this->step_dx); 1801 this->dest_width >> 1, this->step_dx);
1802 1802
1803 } 1803 }
1804 height++; 1804 height++;
1805 } while( dy>=32768); 1805 } while( dy>=32768);
1806 } 1806 }
1807 } else { 1807 } else {
1808 height = this->source_height >> 1; 1808 height = this->source_height >> 1;
1809 do { 1809 do {
1810 dst_1 = (uint16_t*)_dst; 1810 dst_1 = (uint16_t*)_dst;
1811 dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride ); 1811 dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride );
1812 py_1 = _py; 1812 py_1 = _py;
1813 py_2 = _py + this->y_stride; 1813 py_2 = _py + this->y_stride;
1814 pu = _pu; 1814 pu = _pu;
1815 pv = _pv; 1815 pv = _pv;
1816 width = this->source_width >> 3; 1816 width = this->source_width >> 3;
1817 do { 1817 do {
1818 RGB(0); 1818 RGB(0);
1819 DST1(0); 1819 DST1(0);
1820 DST2(0); 1820 DST2(0);
1821 1821
1822 RGB(1); 1822 RGB(1);
1823 DST2(1); 1823 DST2(1);
1824 DST1(1); 1824 DST1(1);
1825 1825
1826 RGB(2); 1826 RGB(2);
1827 DST1(2); 1827 DST1(2);
1828 DST2(2); 1828 DST2(2);
1829 1829
1830 RGB(3); 1830 RGB(3);
1831 DST2(3); 1831 DST2(3);
1832 DST1(3); 1832 DST1(3);
1833 1833
1834 pu += 4; 1834 pu += 4;
1835 pv += 4; 1835 pv += 4;
1836 py_1 += 8; 1836 py_1 += 8;
1837 py_2 += 8; 1837 py_2 += 8;
1838 dst_1 += 8; 1838 dst_1 += 8;
1839 dst_2 += 8; 1839 dst_2 += 8;
1840 } while (--width); 1840 } while (--width);
1841 1841
1842 _dst += 2 * this->rgb_stride; 1842 _dst += 2 * this->rgb_stride;
1843 _py += 2 * this->y_stride; 1843 _py += 2 * this->y_stride;
1844 _pu += this->uv_stride; 1844 _pu += this->uv_stride;
1845 _pv += this->uv_stride; 1845 _pv += this->uv_stride;
1846 1846
1847 } while (--height); 1847 } while (--height);
1848 } 1848 }
1849} 1849}
1850 1850
1851/* This is exactly the same code as yuv2rgb_c_32 except for the types of */ 1851/* This is exactly the same code as yuv2rgb_c_32 except for the types of */
1852/* r, g, b, dst_1, dst_2 */ 1852/* r, g, b, dst_1, dst_2 */
1853static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, 1853static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst,
1854 uint8_t * _py, uint8_t * _pu, uint8_t * _pv) 1854 uint8_t * _py, uint8_t * _pu, uint8_t * _pv)
1855{ 1855{
1856 int U, V, Y; 1856 int U, V, Y;
1857 uint8_t * py_1, * py_2, * pu, * pv; 1857 uint8_t * py_1, * py_2, * pu, * pv;
1858 uint8_t * r, * g, * b; 1858 uint8_t * r, * g, * b;
1859 uint8_t * dst_1, * dst_2; 1859 uint8_t * dst_1, * dst_2;
1860 int width, height, dst_height; 1860 int width, height, dst_height;
1861 int dy; 1861 int dy;
1862 1862
1863 if (this->do_scale) { 1863 if (this->do_scale) {
1864 scale_line_func_t scale_line = this->scale_line; 1864 scale_line_func_t scale_line = this->scale_line;
1865 1865
1866 scale_line (_pu, this->u_buffer, 1866 scale_line (_pu, this->u_buffer,
1867 this->dest_width >> 1, this->step_dx); 1867 this->dest_width >> 1, this->step_dx);
1868 scale_line (_pv, this->v_buffer, 1868 scale_line (_pv, this->v_buffer,
1869 this->dest_width >> 1, this->step_dx); 1869 this->dest_width >> 1, this->step_dx);
1870 scale_line (_py, this->y_buffer, 1870 scale_line (_py, this->y_buffer,
1871 this->dest_width, this->step_dx); 1871 this->dest_width, this->step_dx);
1872 1872
1873 dy = 0; 1873 dy = 0;
1874 dst_height = this->dest_height; 1874 dst_height = this->dest_height;
1875 1875
1876 for (height = 0;; ) { 1876 for (height = 0;; ) {
1877 dst_1 = (uint8_t*)_dst; 1877 dst_1 = (uint8_t*)_dst;
1878 py_1 = this->y_buffer; 1878 py_1 = this->y_buffer;
1879 pu = this->u_buffer; 1879 pu = this->u_buffer;
1880 pv = this->v_buffer; 1880 pv = this->v_buffer;
1881 1881
1882 width = this->dest_width >> 3; 1882 width = this->dest_width >> 3;
1883 1883
1884 do { 1884 do {
1885 RGB(0); 1885 RGB(0);
1886 DST1(0); 1886 DST1(0);
1887 1887
1888 RGB(1); 1888 RGB(1);
1889 DST1(1); 1889 DST1(1);
1890 1890
1891 RGB(2); 1891 RGB(2);
1892 DST1(2); 1892 DST1(2);
1893 1893
1894 RGB(3); 1894 RGB(3);
1895 DST1(3); 1895 DST1(3);
1896 1896
1897 pu += 4; 1897 pu += 4;
1898 pv += 4; 1898 pv += 4;
1899 py_1 += 8; 1899 py_1 += 8;
1900 dst_1 += 8; 1900 dst_1 += 8;
1901 } while (--width); 1901 } while (--width);
1902 1902
1903 dy += this->step_dy; 1903 dy += this->step_dy;
1904 _dst += this->rgb_stride; 1904 _dst += this->rgb_stride;
1905 1905
1906 while (--dst_height > 0 && dy < 32768) { 1906 while (--dst_height > 0 && dy < 32768) {
1907 1907
1908 xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width); 1908 xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width);
1909 1909
1910 dy += this->step_dy; 1910 dy += this->step_dy;
1911 _dst += this->rgb_stride; 1911 _dst += this->rgb_stride;
1912 } 1912 }
1913 1913
1914 if (dst_height <= 0) 1914 if (dst_height <= 0)
1915 break; 1915 break;
1916 1916
1917 do { 1917 do {
1918 dy -= 32768; 1918 dy -= 32768;
1919 _py += this->y_stride; 1919 _py += this->y_stride;
1920 1920
1921 scale_line (_py, this->y_buffer, 1921 scale_line (_py, this->y_buffer,
1922 this->dest_width, this->step_dx); 1922 this->dest_width, this->step_dx);
1923 1923
1924 if (height & 1) { 1924 if (height & 1) {
1925 _pu += this->uv_stride; 1925 _pu += this->uv_stride;
1926 _pv += this->uv_stride; 1926 _pv += this->uv_stride;
1927 1927
1928 scale_line (_pu, this->u_buffer, 1928 scale_line (_pu, this->u_buffer,
1929 this->dest_width >> 1, this->step_dx); 1929 this->dest_width >> 1, this->step_dx);
1930 scale_line (_pv, this->v_buffer, 1930 scale_line (_pv, this->v_buffer,
1931 this->dest_width >> 1, this->step_dx); 1931 this->dest_width >> 1, this->step_dx);
1932 1932
1933 } 1933 }
1934 height++; 1934 height++;
1935 } while( dy>=32768 ); 1935 } while( dy>=32768 );
1936 } 1936 }
1937 } else { 1937 } else {
1938 height = this->source_height >> 1; 1938 height = this->source_height >> 1;
1939 do { 1939 do {
1940 dst_1 = (uint8_t*)_dst; 1940 dst_1 = (uint8_t*)_dst;
1941 dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride ); 1941 dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride );
1942 py_1 = _py; 1942 py_1 = _py;
1943 py_2 = _py + this->y_stride; 1943 py_2 = _py + this->y_stride;
1944 pu = _pu; 1944 pu = _pu;
1945 pv = _pv; 1945 pv = _pv;
1946 1946
1947 width = this->source_width >> 3; 1947 width = this->source_width >> 3;
1948 do { 1948 do {
1949 RGB(0); 1949 RGB(0);
1950 DST1(0); 1950 DST1(0);
1951 DST2(0); 1951 DST2(0);
1952 1952
1953 RGB(1); 1953 RGB(1);
1954 DST2(1); 1954 DST2(1);
1955 DST1(1); 1955 DST1(1);
1956 1956
1957 RGB(2); 1957 RGB(2);
1958 DST1(2); 1958 DST1(2);
1959 DST2(2); 1959 DST2(2);
1960 1960
1961 RGB(3); 1961 RGB(3);
1962 DST2(3); 1962 DST2(3);
1963 DST1(3); 1963 DST1(3);
1964 1964
1965 pu += 4; 1965 pu += 4;
1966 pv += 4; 1966 pv += 4;
1967 py_1 += 8; 1967 py_1 += 8;
1968 py_2 += 8; 1968 py_2 += 8;
1969 dst_1 += 8; 1969 dst_1 += 8;
1970 dst_2 += 8; 1970 dst_2 += 8;
1971 } while (--width); 1971 } while (--width);
1972 1972
1973 _dst += 2 * this->rgb_stride; 1973 _dst += 2 * this->rgb_stride;
1974 _py += 2 * this->y_stride; 1974 _py += 2 * this->y_stride;
1975 _pu += this->uv_stride; 1975 _pu += this->uv_stride;
1976 _pv += this->uv_stride; 1976 _pv += this->uv_stride;
1977 1977
1978 } while (--height); 1978 } while (--height);
1979 } 1979 }
1980} 1980}
1981 1981
1982/* now for something different: 256 grayscale mode */ 1982/* now for something different: 256 grayscale mode */
1983static void yuv2rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, 1983static void yuv2rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst,
1984 uint8_t * _py, uint8_t * _pu, uint8_t * _pv) 1984 uint8_t * _py, uint8_t * _pu, uint8_t * _pv)
1985{ 1985{
1986 int height, dst_height; 1986 int height, dst_height;
1987 int dy; 1987 int dy;
1988 1988
1989 if (this->do_scale) { 1989 if (this->do_scale) {
1990 scale_line_func_t scale_line = this->scale_line; 1990 scale_line_func_t scale_line = this->scale_line;
1991 1991
1992 dy = 0; 1992 dy = 0;
1993 dst_height = this->dest_height; 1993 dst_height = this->dest_height;
1994 1994
1995 for (;;) { 1995 for (;;) {
1996 scale_line (_py, _dst, this->dest_width, this->step_dx); 1996 scale_line (_py, _dst, this->dest_width, this->step_dx);
1997 1997
1998 dy += this->step_dy; 1998 dy += this->step_dy;
1999 _dst += this->rgb_stride; 1999 _dst += this->rgb_stride;
2000 2000
2001 while (--dst_height > 0 && dy < 32768) { 2001 while (--dst_height > 0 && dy < 32768) {
2002 2002
2003 xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width); 2003 xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width);
2004 2004
2005 dy += this->step_dy; 2005 dy += this->step_dy;
2006 _dst += this->rgb_stride; 2006 _dst += this->rgb_stride;
2007 } 2007 }
2008 2008
2009 if (dst_height <= 0) 2009 if (dst_height <= 0)
2010 break; 2010 break;
2011 2011
2012 _py += this->y_stride*(dy>>15); 2012 _py += this->y_stride*(dy>>15);
2013 dy &= 32767; 2013 dy &= 32767;
2014 /* dy -= 32768; 2014 /* dy -= 32768;
2015 _py += this->y_stride; 2015 _py += this->y_stride;
2016 */ 2016 */
2017 } 2017 }
2018 } else { 2018 } else {
2019 for (height = this->source_height; --height >= 0; ) { 2019 for (height = this->source_height; --height >= 0; ) {
2020 xine_fast_memcpy(_dst, _py, this->dest_width); 2020 xine_fast_memcpy(_dst, _py, this->dest_width);
2021 _dst += this->rgb_stride; 2021 _dst += this->rgb_stride;
2022 _py += this->y_stride; 2022 _py += this->y_stride;
2023 } 2023 }
2024 } 2024 }
2025} 2025}
2026 2026
2027/* now for something different: 256 color mode */ 2027/* now for something different: 256 color mode */
2028static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, 2028static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst,
2029 uint8_t * _py, uint8_t * _pu, uint8_t * _pv) 2029 uint8_t * _py, uint8_t * _pu, uint8_t * _pv)
2030{ 2030{
2031 int U, V, Y; 2031 int U, V, Y;
2032 uint8_t * py_1, * py_2, * pu, * pv; 2032 uint8_t * py_1, * py_2, * pu, * pv;
2033 uint16_t * r, * g, * b; 2033 uint16_t * r, * g, * b;
2034 uint8_t * dst_1, * dst_2; 2034 uint8_t * dst_1, * dst_2;
2035 int width, height, dst_height; 2035 int width, height, dst_height;
2036 int dy; 2036 int dy;
2037 2037
2038 if (this->do_scale) { 2038 if (this->do_scale) {
2039 scale_line_func_t scale_line = this->scale_line; 2039 scale_line_func_t scale_line = this->scale_line;
2040 2040
2041 scale_line (_pu, this->u_buffer, 2041 scale_line (_pu, this->u_buffer,
2042 this->dest_width >> 1, this->step_dx); 2042 this->dest_width >> 1, this->step_dx);
2043 scale_line (_pv, this->v_buffer, 2043 scale_line (_pv, this->v_buffer,
2044 this->dest_width >> 1, this->step_dx); 2044 this->dest_width >> 1, this->step_dx);
2045 scale_line (_py, this->y_buffer, 2045 scale_line (_py, this->y_buffer,
2046 this->dest_width, this->step_dx); 2046 this->dest_width, this->step_dx);
2047 2047
2048 dy = 0; 2048 dy = 0;
2049 dst_height = this->dest_height; 2049 dst_height = this->dest_height;
2050 2050
2051 for (height = 0;; ) { 2051 for (height = 0;; ) {
2052 dst_1 = _dst; 2052 dst_1 = _dst;
2053 py_1 = this->y_buffer; 2053 py_1 = this->y_buffer;
2054 pu = this->u_buffer; 2054 pu = this->u_buffer;
2055 pv = this->v_buffer; 2055 pv = this->v_buffer;
2056 2056
2057 width = this->dest_width >> 3; 2057 width = this->dest_width >> 3;
2058 2058
2059 do { 2059 do {
2060 RGB(0); 2060 RGB(0);
2061 DST1CMAP(0); 2061 DST1CMAP(0);
2062 2062
2063 RGB(1); 2063 RGB(1);
2064 DST1CMAP(1); 2064 DST1CMAP(1);
2065 2065
2066 RGB(2); 2066 RGB(2);
2067 DST1CMAP(2); 2067 DST1CMAP(2);
2068 2068
2069 RGB(3); 2069 RGB(3);
2070 DST1CMAP(3); 2070 DST1CMAP(3);
2071 2071
2072 pu += 4; 2072 pu += 4;
2073 pv += 4; 2073 pv += 4;
2074 py_1 += 8; 2074 py_1 += 8;
2075 dst_1 += 8; 2075 dst_1 += 8;
2076 } while (--width); 2076 } while (--width);
2077 2077
2078 dy += this->step_dy; 2078 dy += this->step_dy;
2079 _dst += this->rgb_stride; 2079 _dst += this->rgb_stride;
2080 2080
2081 while (--dst_height > 0 && dy < 32768) { 2081 while (--dst_height > 0 && dy < 32768) {
2082 2082
2083 xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width); 2083 xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width);
2084 2084
2085 dy += this->step_dy; 2085 dy += this->step_dy;
2086 _dst += this->rgb_stride; 2086 _dst += this->rgb_stride;
2087 } 2087 }
2088 2088
2089 if (dst_height <= 0) 2089 if (dst_height <= 0)
2090 break; 2090 break;
2091 2091
2092 do { 2092 do {
2093 dy -= 32768; 2093 dy -= 32768;
2094 _py += this->y_stride; 2094 _py += this->y_stride;
2095 2095
2096 scale_line (_py, this->y_buffer, 2096 scale_line (_py, this->y_buffer,
2097 this->dest_width, this->step_dx); 2097 this->dest_width, this->step_dx);
2098 2098
2099 if (height & 1) { 2099 if (height & 1) {
2100 _pu += this->uv_stride; 2100 _pu += this->uv_stride;
2101 _pv += this->uv_stride; 2101 _pv += this->uv_stride;
2102 2102
2103 scale_line (_pu, this->u_buffer, 2103 scale_line (_pu, this->u_buffer,
2104 this->dest_width >> 1, this->step_dx); 2104 this->dest_width >> 1, this->step_dx);
2105 scale_line (_pv, this->v_buffer, 2105 scale_line (_pv, this->v_buffer,
2106 this->dest_width >> 1, this->step_dx); 2106 this->dest_width >> 1, this->step_dx);
2107 2107
2108 } 2108 }
2109 height++; 2109 height++;
2110 } while( dy>=32768 ); 2110 } while( dy>=32768 );
2111 } 2111 }
2112 } else { 2112 } else {
2113 height = this->source_height >> 1; 2113 height = this->source_height >> 1;
2114 do { 2114 do {
2115 dst_1 = _dst; 2115 dst_1 = _dst;
2116 dst_2 = _dst + this->rgb_stride; 2116 dst_2 = _dst + this->rgb_stride;
2117 py_1 = _py; 2117 py_1 = _py;
2118 py_2 = _py + this->y_stride; 2118 py_2 = _py + this->y_stride;
2119 pu = _pu; 2119 pu = _pu;
2120 pv = _pv; 2120 pv = _pv;
2121 width = this->source_width >> 3; 2121 width = this->source_width >> 3;
2122 do { 2122 do {
2123 RGB(0); 2123 RGB(0);
2124 DST1CMAP(0); 2124 DST1CMAP(0);
2125 DST2CMAP(0); 2125 DST2CMAP(0);
2126 2126
2127 RGB(1); 2127 RGB(1);
2128 DST2CMAP(1); 2128 DST2CMAP(1);
2129 DST1CMAP(1); 2129 DST1CMAP(1);
2130 2130
2131 RGB(2); 2131 RGB(2);
2132 DST1CMAP(2); 2132 DST1CMAP(2);
2133 DST2CMAP(2); 2133 DST2CMAP(2);
2134 2134
2135 RGB(3); 2135 RGB(3);
2136 DST2CMAP(3); 2136 DST2CMAP(3);
2137 DST1CMAP(3); 2137 DST1CMAP(3);
2138 2138
2139 pu += 4; 2139 pu += 4;
2140 pv += 4; 2140 pv += 4;
2141 py_1 += 8; 2141 py_1 += 8;
2142 py_2 += 8; 2142 py_2 += 8;
2143 dst_1 += 8; 2143 dst_1 += 8;
2144 dst_2 += 8; 2144 dst_2 += 8;
2145 } while (--width); 2145 } while (--width);
2146 2146
2147 _dst += 2 * this->rgb_stride; 2147 _dst += 2 * this->rgb_stride;
2148 _py += 2 * this->y_stride; 2148 _py += 2 * this->y_stride;
2149 _pu += this->uv_stride; 2149 _pu += this->uv_stride;
2150 _pv += this->uv_stride; 2150 _pv += this->uv_stride;
2151 2151
2152 } while (--height); 2152 } while (--height);
2153 } 2153 }
2154} 2154}
2155 2155
2156static int div_round (int dividend, int divisor) 2156static int div_round (int dividend, int divisor)
2157{ 2157{
2158 if (dividend > 0) 2158 if (dividend > 0)
2159 return (dividend + (divisor>>1)) / divisor; 2159 return (dividend + (divisor>>1)) / divisor;
2160 else 2160 else
2161 return -((-dividend + (divisor>>1)) / divisor); 2161 return -((-dividend + (divisor>>1)) / divisor);
2162} 2162}
2163 2163
2164static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped) 2164static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped)
2165{ 2165{
2166 int i; 2166 int i;
2167 uint8_t table_Y[1024]; 2167 uint8_t table_Y[1024];
2168 uint32_t * table_32 = 0; 2168 uint32_t * table_32 = 0;
2169 uint16_t * table_16 = 0; 2169 uint16_t * table_16 = 0;
2170 uint8_t * table_8 = 0; 2170 uint8_t * table_8 = 0;
2171 int entry_size = 0; 2171 int entry_size = 0;
2172 void *table_r = 0, *table_g = 0, *table_b = 0; 2172 void *table_r = 0, *table_g = 0, *table_b = 0;
2173 int shift_r = 0, shift_g = 0, shift_b = 0; 2173 int shift_r = 0, shift_g = 0, shift_b = 0;
2174 2174
2175 int crv = Inverse_Table_6_9[this->matrix_coefficients][0]; 2175 int crv = Inverse_Table_6_9[this->matrix_coefficients][0];
2176 int cbu = Inverse_Table_6_9[this->matrix_coefficients][1]; 2176 int cbu = Inverse_Table_6_9[this->matrix_coefficients][1];
2177 int cgu = -Inverse_Table_6_9[this->matrix_coefficients][2]; 2177 int cgu = -Inverse_Table_6_9[this->matrix_coefficients][2];
2178 int cgv = -Inverse_Table_6_9[this->matrix_coefficients][3]; 2178 int cgv = -Inverse_Table_6_9[this->matrix_coefficients][3];
2179 2179
2180 for (i = 0; i < 1024; i++) { 2180 for (i = 0; i < 1024; i++) {
2181 int j; 2181 int j;
2182 2182
2183 j = (76309 * (i - 384 - 16) + 32768) >> 16; 2183 j = (76309 * (i - 384 - 16) + 32768) >> 16;
2184 j = (j < 0) ? 0 : ((j > 255) ? 255 : j); 2184 j = (j < 0) ? 0 : ((j > 255) ? 255 : j);
2185 table_Y[i] = j; 2185 table_Y[i] = j;
2186 } 2186 }
2187 2187
2188 switch (mode) { 2188 switch (mode) {
2189 case MODE_32_RGB: 2189 case MODE_32_RGB:
2190 case MODE_32_BGR: 2190 case MODE_32_BGR:
2191 table_32 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint32_t)); 2191 table_32 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint32_t));
2192 2192
2193 entry_size = sizeof (uint32_t); 2193 entry_size = sizeof (uint32_t);
2194 table_r = table_32 + 197; 2194 table_r = table_32 + 197;
2195 table_b = table_32 + 197 + 685; 2195 table_b = table_32 + 197 + 685;
2196 table_g = table_32 + 197 + 2*682; 2196 table_g = table_32 + 197 + 2*682;
2197 2197
2198 if (swapped) { 2198 if (swapped) {
2199 switch (mode) { 2199 switch (mode) {
2200 case MODE_32_RGB: shift_r = 8; shift_g = 16; shift_b = 24; break; 2200 case MODE_32_RGB: shift_r = 8; shift_g = 16; shift_b = 24; break;
2201 case MODE_32_BGR:shift_r = 24; shift_g = 16; shift_b = 8; break; 2201 case MODE_32_BGR:shift_r = 24; shift_g = 16; shift_b = 8; break;
2202 } 2202 }
2203 } else { 2203 } else {
2204 switch (mode) { 2204 switch (mode) {
2205 case MODE_32_RGB:shift_r = 16; shift_g = 8; shift_b = 0; break; 2205 case MODE_32_RGB:shift_r = 16; shift_g = 8; shift_b = 0; break;
2206 case MODE_32_BGR:shift_r = 0; shift_g = 8; shift_b = 16; break; 2206 case MODE_32_BGR:shift_r = 0; shift_g = 8; shift_b = 16; break;
2207 } 2207 }
2208 } 2208 }
2209 2209
2210 for (i = -197; i < 256+197; i++) 2210 for (i = -197; i < 256+197; i++)
2211 ((uint32_t *) table_r)[i] = table_Y[i+384] << shift_r; 2211 ((uint32_t *) table_r)[i] = table_Y[i+384] << shift_r;
2212 for (i = -132; i < 256+132; i++) 2212 for (i = -132; i < 256+132; i++)
2213 ((uint32_t *) table_g)[i] = table_Y[i+384] << shift_g; 2213 ((uint32_t *) table_g)[i] = table_Y[i+384] << shift_g;
2214 for (i = -232; i < 256+232; i++) 2214 for (i = -232; i < 256+232; i++)
2215 ((uint32_t *) table_b)[i] = table_Y[i+384] << shift_b; 2215 ((uint32_t *) table_b)[i] = table_Y[i+384] << shift_b;
2216 break; 2216 break;
2217 2217
2218 case MODE_24_RGB: 2218 case MODE_24_RGB:
2219 case MODE_24_BGR: 2219 case MODE_24_BGR:
2220 table_8 = malloc ((256 + 2*232) * sizeof (uint8_t)); 2220 table_8 = malloc ((256 + 2*232) * sizeof (uint8_t));
2221 2221
2222 entry_size = sizeof (uint8_t); 2222 entry_size = sizeof (uint8_t);
2223 table_r = table_g = table_b = table_8 + 232; 2223 table_r = table_g = table_b = table_8 + 232;
2224 2224
2225 for (i = -232; i < 256+232; i++) 2225 for (i = -232; i < 256+232; i++)
2226 ((uint8_t * )table_b)[i] = table_Y[i+384]; 2226 ((uint8_t * )table_b)[i] = table_Y[i+384];
2227 break; 2227 break;
2228 2228
2229 case MODE_15_BGR: 2229 case MODE_15_BGR:
2230 case MODE_16_BGR: 2230 case MODE_16_BGR:
2231 case MODE_15_RGB: 2231 case MODE_15_RGB:
2232 case MODE_16_RGB: 2232 case MODE_16_RGB:
2233 table_16 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint16_t)); 2233 table_16 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint16_t));
2234 2234
2235 entry_size = sizeof (uint16_t); 2235 entry_size = sizeof (uint16_t);
2236 table_r = table_16 + 197; 2236 table_r = table_16 + 197;
2237 table_b = table_16 + 197 + 685; 2237 table_b = table_16 + 197 + 685;
2238 table_g = table_16 + 197 + 2*682; 2238 table_g = table_16 + 197 + 2*682;
2239 2239
2240 if (swapped) { 2240 if (swapped) {
2241 switch (mode) { 2241 switch (mode) {
2242 case MODE_15_BGR: shift_r = 8; shift_g = 5; shift_b = 2; break; 2242 case MODE_15_BGR: shift_r = 8; shift_g = 5; shift_b = 2; break;
2243 case MODE_16_BGR:shift_r = 8; shift_g = 5; shift_b = 3; break; 2243 case MODE_16_BGR:shift_r = 8; shift_g = 5; shift_b = 3; break;
2244 case MODE_15_RGB:shift_r = 2; shift_g = 5; shift_b = 8; break; 2244 case MODE_15_RGB:shift_r = 2; shift_g = 5; shift_b = 8; break;
2245 case MODE_16_RGB:shift_r = 3; shift_g = 5; shift_b = 8; break; 2245 case MODE_16_RGB:shift_r = 3; shift_g = 5; shift_b = 8; break;
2246 } 2246 }
2247 } else { 2247 } else {
2248 switch (mode) { 2248 switch (mode) {
2249 case MODE_15_BGR:shift_r = 0; shift_g = 5; shift_b = 10; break; 2249 case MODE_15_BGR:shift_r = 0; shift_g = 5; shift_b = 10; break;
2250 case MODE_16_BGR:shift_r = 0; shift_g = 5; shift_b = 11; break; 2250 case MODE_16_BGR:shift_r = 0; shift_g = 5; shift_b = 11; break;
2251 case MODE_15_RGB:shift_r = 10; shift_g = 5; shift_b = 0; break; 2251 case MODE_15_RGB:shift_r = 10; shift_g = 5; shift_b = 0; break;
2252 case MODE_16_RGB:shift_r = 11; shift_g = 5; shift_b = 0; break; 2252 case MODE_16_RGB:shift_r = 11; shift_g = 5; shift_b = 0; break;
2253 } 2253 }
2254 } 2254 }
2255 2255
2256 for (i = -197; i < 256+197; i++) 2256 for (i = -197; i < 256+197; i++)
2257 ((uint16_t *)table_r)[i] = (table_Y[i+384] >> 3) << shift_r; 2257 ((uint16_t *)table_r)[i] = (table_Y[i+384] >> 3) << shift_r;
2258 2258
2259 for (i = -132; i < 256+132; i++) { 2259 for (i = -132; i < 256+132; i++) {
2260 int j = table_Y[i+384] >> (((mode==MODE_16_RGB) || (mode==MODE_16_BGR)) ? 2 : 3); 2260 int j = table_Y[i+384] >> (((mode==MODE_16_RGB) || (mode==MODE_16_BGR)) ? 2 : 3);
2261 if (swapped) 2261 if (swapped)
2262 ((uint16_t *)table_g)[i] = (j&7) << 13 | (j>>3); 2262 ((uint16_t *)table_g)[i] = (j&7) << 13 | (j>>3);
2263 else 2263 else
2264 ((uint16_t *)table_g)[i] = j << 5; 2264 ((uint16_t *)table_g)[i] = j << 5;
2265 } 2265 }
2266 for (i = -232; i < 256+232; i++) 2266 for (i = -232; i < 256+232; i++)
2267 ((uint16_t *)table_b)[i] = (table_Y[i+384] >> 3) << shift_b; 2267 ((uint16_t *)table_b)[i] = (table_Y[i+384] >> 3) << shift_b;
2268 2268
2269 break; 2269 break;
2270 2270
2271 case MODE_8_RGB: 2271 case MODE_8_RGB:
2272 case MODE_8_BGR: 2272 case MODE_8_BGR:
2273 table_8 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint8_t)); 2273 table_8 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint8_t));
2274 2274
2275 entry_size = sizeof (uint8_t); 2275 entry_size = sizeof (uint8_t);
2276 table_r = table_8 + 197; 2276 table_r = table_8 + 197;
2277 table_b = table_8 + 197 + 685; 2277 table_b = table_8 + 197 + 685;
2278 table_g = table_8 + 197 + 2*682; 2278 table_g = table_8 + 197 + 2*682;
2279 2279
2280 switch (mode) { 2280 switch (mode) {
2281 case MODE_8_RGB: shift_r = 5; shift_g = 2; shift_b = 0; break; 2281 case MODE_8_RGB: shift_r = 5; shift_g = 2; shift_b = 0; break;
2282 case MODE_8_BGR: shift_r = 0; shift_g = 3; shift_b = 6; break; 2282 case MODE_8_BGR: shift_r = 0; shift_g = 3; shift_b = 6; break;
2283 } 2283 }
2284 2284
2285 for (i = -197; i < 256+197; i++) 2285 for (i = -197; i < 256+197; i++)
2286 ((uint8_t *) table_r)[i] = (table_Y[i+384] >> 5) << shift_r; 2286 ((uint8_t *) table_r)[i] = (table_Y[i+384] >> 5) << shift_r;
2287 for (i = -132; i < 256+132; i++) 2287 for (i = -132; i < 256+132; i++)
2288 ((uint8_t *) table_g)[i] = (table_Y[i+384] >> 5) << shift_g; 2288 ((uint8_t *) table_g)[i] = (table_Y[i+384] >> 5) << shift_g;
2289 for (i = -232; i < 256+232; i++) 2289 for (i = -232; i < 256+232; i++)
2290 ((uint8_t *) table_b)[i] = (table_Y[i+384] >> 6) << shift_b; 2290 ((uint8_t *) table_b)[i] = (table_Y[i+384] >> 6) << shift_b;
2291 break; 2291 break;
2292 2292
2293 case MODE_8_GRAY: 2293 case MODE_8_GRAY:
2294 return; 2294 return;
2295 2295
2296 case MODE_PALETTE: 2296 case MODE_PALETTE:
2297 table_16 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint16_t)); 2297 table_16 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint16_t));
2298 2298
2299 entry_size = sizeof (uint16_t); 2299 entry_size = sizeof (uint16_t);
2300 table_r = table_16 + 197; 2300 table_r = table_16 + 197;
2301 table_b = table_16 + 197 + 685; 2301 table_b = table_16 + 197 + 685;
2302 table_g = table_16 + 197 + 2*682; 2302 table_g = table_16 + 197 + 2*682;
2303 2303
2304 shift_r = 10; 2304 shift_r = 10;
2305 shift_g = 5; 2305 shift_g = 5;
2306 shift_b = 0; 2306 shift_b = 0;
2307 2307
2308 for (i = -197; i < 256+197; i++) 2308 for (i = -197; i < 256+197; i++)
2309 ((uint16_t *)table_r)[i] = (table_Y[i+384] >> 3) << 10; 2309 ((uint16_t *)table_r)[i] = (table_Y[i+384] >> 3) << 10;
2310 2310
2311 for (i = -132; i < 256+132; i++) 2311 for (i = -132; i < 256+132; i++)
2312 ((uint16_t *)table_g)[i] = (table_Y[i+384] >> 3) << 5; 2312 ((uint16_t *)table_g)[i] = (table_Y[i+384] >> 3) << 5;
2313 2313
2314 for (i = -232; i < 256+232; i++) 2314 for (i = -232; i < 256+232; i++)
2315 ((uint16_t *)table_b)[i] = (table_Y[i+384] >> 3) << 0; 2315 ((uint16_t *)table_b)[i] = (table_Y[i+384] >> 3) << 0;
2316 2316
2317 break; 2317 break;
2318 2318
2319 2319
2320 default: 2320 default:
2321 fprintf (stderr, "mode %d not supported by yuv2rgb\n", mode); 2321 fprintf (stderr, "mode %d not supported by yuv2rgb\n", mode);
2322 abort(); 2322 abort();
2323 } 2323 }
2324 2324
2325 for (i = 0; i < 256; i++) { 2325 for (i = 0; i < 256; i++) {
2326 this->table_rV[i] = (((uint8_t *) table_r) + 2326 this->table_rV[i] = (((uint8_t *) table_r) +
2327 entry_size * div_round (crv * (i-128), 76309)); 2327 entry_size * div_round (crv * (i-128), 76309));
2328 this->table_gU[i] = (((uint8_t *) table_g) + 2328 this->table_gU[i] = (((uint8_t *) table_g) +
2329 entry_size * div_round (cgu * (i-128), 76309)); 2329 entry_size * div_round (cgu * (i-128), 76309));
2330 this->table_gV[i] = entry_size * div_round (cgv * (i-128), 76309); 2330 this->table_gV[i] = entry_size * div_round (cgv * (i-128), 76309);
2331 this->table_bU[i] = (((uint8_t *)table_b) + 2331 this->table_bU[i] = (((uint8_t *)table_b) +
2332 entry_size * div_round (cbu * (i-128), 76309)); 2332 entry_size * div_round (cbu * (i-128), 76309));
2333 } 2333 }
2334 this->gamma = 0; 2334 this->gamma = 0;
2335 this->entry_size = entry_size; 2335 this->entry_size = entry_size;
2336} 2336}
2337 2337
2338static uint32_t yuv2rgb_single_pixel_32 (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v) 2338static uint32_t yuv2rgb_single_pixel_32 (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v)
2339{ 2339{
2340 uint32_t * r, * g, * b; 2340 uint32_t * r, * g, * b;
2341 2341
2342 r = this->table_rV[v]; 2342 r = this->table_rV[v];
2343 g = (void *) (((uint8_t *)this->table_gU[u]) + this->table_gV[v]); 2343 g = (void *) (((uint8_t *)this->table_gU[u]) + this->table_gV[v]);
2344 b = this->table_bU[u]; 2344 b = this->table_bU[u];
2345 2345
2346 return r[y] + g[y] + b[y]; 2346 return r[y] + g[y] + b[y];
2347} 2347}
2348 2348
2349static uint32_t yuv2rgb_single_pixel_24_rgb (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v) 2349static uint32_t yuv2rgb_single_pixel_24_rgb (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v)
2350{ 2350{
2351 uint8_t * r, * g, * b; 2351 uint8_t * r, * g, * b;
2352 2352
2353 r = this->table_rV[v]; 2353 r = this->table_rV[v];
2354 g = (void *) (((uint8_t *)this->table_gU[u]) + this->table_gV[v]); 2354 g = (void *) (((uint8_t *)this->table_gU[u]) + this->table_gV[v]);
2355 b = this->table_bU[u]; 2355 b = this->table_bU[u];
2356 2356
2357 return (uint32_t) r[y] + 2357 return (uint32_t) r[y] +
2358 ((uint32_t) g[y] << 8) + 2358 ((uint32_t) g[y] << 8) +
2359 ((uint32_t) b[y] << 16); 2359 ((uint32_t) b[y] << 16);
2360} 2360}
2361 2361
2362static uint32_t yuv2rgb_single_pixel_24_bgr (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v) 2362static uint32_t yuv2rgb_single_pixel_24_bgr (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v)
2363{ 2363{
2364 uint8_t * r, * g, * b; 2364 uint8_t * r, * g, * b;
2365 2365
2366 r = this->table_rV[v]; 2366 r = this->table_rV[v];
2367 g = (void *) (((uint8_t *)this->table_gU[u]) + this->table_gV[v]); 2367 g = (void *) (((uint8_t *)this->table_gU[u]) + this->table_gV[v]);
2368 b = this->table_bU[u]; 2368 b = this->table_bU[u];
2369 2369
2370 return (uint32_t) b[y] + 2370 return (uint32_t) b[y] +
2371 ((uint32_t) g[y] << 8) + 2371 ((uint32_t) g[y] << 8) +
2372 ((uint32_t) r[y] << 16); 2372 ((uint32_t) r[y] << 16);
2373} 2373}
2374 2374
2375static uint32_t yuv2rgb_single_pixel_16 (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v) 2375static uint32_t yuv2rgb_single_pixel_16 (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v)
2376{ 2376{
2377 uint16_t * r, * g, * b; 2377 uint16_t * r, * g, * b;
2378 2378
2379 r = this->table_rV[v]; 2379 r = this->table_rV[v];
2380 g = (void *) (((uint8_t *)this->table_gU[u]) + this->table_gV[v]); 2380 g = (void *) (((uint8_t *)this->table_gU[u]) + this->table_gV[v]);
2381 b = this->table_bU[u]; 2381 b = this->table_bU[u];
2382 2382
2383 return r[y] + g[y] + b[y]; 2383 return r[y] + g[y] + b[y];
2384} 2384}
2385 2385
2386static uint32_t yuv2rgb_single_pixel_8 (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v) 2386static uint32_t yuv2rgb_single_pixel_8 (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v)
2387{ 2387{
2388 uint8_t * r, * g, * b; 2388 uint8_t * r, * g, * b;
2389 2389
2390 r = this->table_rV[v]; 2390 r = this->table_rV[v];
2391 g = (void *) (((uint8_t *)this->table_gU[u]) + this->table_gV[v]); 2391 g = (void *) (((uint8_t *)this->table_gU[u]) + this->table_gV[v]);
2392 b = this->table_bU[u]; 2392 b = this->table_bU[u];
2393 2393
2394 return r[y] + g[y] + b[y]; 2394 return r[y] + g[y] + b[y];
2395} 2395}
2396 2396
2397static uint32_t yuv2rgb_single_pixel_gray (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v) 2397static uint32_t yuv2rgb_single_pixel_gray (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v)
2398{ 2398{
2399 return y; 2399 return y;
2400} 2400}
2401 2401
2402static uint32_t yuv2rgb_single_pixel_palette (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v) 2402static uint32_t yuv2rgb_single_pixel_palette (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v)
2403{ 2403{
2404 uint16_t * r, * g, * b; 2404 uint16_t * r, * g, * b;
2405 2405
2406 r = this->table_rV[v]; 2406 r = this->table_rV[v];
2407 g = (void *) (((uint8_t *)this->table_gU[u]) + this->table_gV[v]); 2407 g = (void *) (((uint8_t *)this->table_gU[u]) + this->table_gV[v]);
2408 b = this->table_bU[u]; 2408 b = this->table_bU[u];
2409 2409
2410 return this->cmap[r[y] + g[y] + b[y]]; 2410 return this->cmap[r[y] + g[y] + b[y]];
2411} 2411}
2412 2412
2413 2413
2414static void yuv2rgb_c_init (yuv2rgb_factory_t *this) 2414static void yuv2rgb_c_init (yuv2rgb_factory_t *this)
2415{ 2415{
2416 switch (this->mode) { 2416 switch (this->mode) {
2417 case MODE_32_RGB: 2417 case MODE_32_RGB:
2418 case MODE_32_BGR: 2418 case MODE_32_BGR:
2419 this->yuv2rgb_fun = yuv2rgb_c_32; 2419 this->yuv2rgb_fun = yuv2rgb_c_32;
2420 break; 2420 break;
2421 2421
2422 case MODE_24_RGB: 2422 case MODE_24_RGB:
2423 case MODE_24_BGR: 2423 case MODE_24_BGR:
2424 this->yuv2rgb_fun = 2424 this->yuv2rgb_fun =
2425 (this->mode==MODE_24_RGB && !this->swapped) || (this->mode==MODE_24_BGR && this->swapped) 2425 (this->mode==MODE_24_RGB && !this->swapped) || (this->mode==MODE_24_BGR && this->swapped)
2426 ? yuv2rgb_c_24_rgb 2426 ? yuv2rgb_c_24_rgb
2427 : yuv2rgb_c_24_bgr; 2427 : yuv2rgb_c_24_bgr;
2428 break; 2428 break;
2429 2429
2430 case MODE_15_BGR: 2430 case MODE_15_BGR:
2431 case MODE_16_BGR: 2431 case MODE_16_BGR:
2432 case MODE_15_RGB: 2432 case MODE_15_RGB:
2433 case MODE_16_RGB: 2433 case MODE_16_RGB:
2434 this->yuv2rgb_fun = yuv2rgb_c_16; 2434 this->yuv2rgb_fun = yuv2rgb_c_16;
2435 break; 2435 break;
2436 2436
2437 case MODE_8_RGB: 2437 case MODE_8_RGB:
2438 case MODE_8_BGR: 2438 case MODE_8_BGR:
2439 this->yuv2rgb_fun = yuv2rgb_c_8; 2439 this->yuv2rgb_fun = yuv2rgb_c_8;
2440 break; 2440 break;
2441 2441
2442 case MODE_8_GRAY: 2442 case MODE_8_GRAY:
2443 this->yuv2rgb_fun = yuv2rgb_c_gray; 2443 this->yuv2rgb_fun = yuv2rgb_c_gray;
2444 break; 2444 break;
2445 2445
2446 case MODE_PALETTE: 2446 case MODE_PALETTE:
2447 this->yuv2rgb_fun = yuv2rgb_c_palette; 2447 this->yuv2rgb_fun = yuv2rgb_c_palette;
2448 break; 2448 break;
2449 2449
2450 default: 2450 default:
2451 printf ("yuv2rgb: mode %d not supported by yuv2rgb\n", this->mode); 2451 printf ("yuv2rgb: mode %d not supported by yuv2rgb\n", this->mode);
2452 abort(); 2452 abort();
2453 } 2453 }
2454 2454
2455} 2455}
2456 2456
2457static void yuv2rgb_single_pixel_init (yuv2rgb_factory_t *this) { 2457static void yuv2rgb_single_pixel_init (yuv2rgb_factory_t *this) {
2458 2458
2459 switch (this->mode) { 2459 switch (this->mode) {
2460 case MODE_32_RGB: 2460 case MODE_32_RGB:
2461 case MODE_32_BGR: 2461 case MODE_32_BGR:
2462 this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_32; 2462 this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_32;
2463 break; 2463 break;
2464 2464
2465 case MODE_24_RGB: 2465 case MODE_24_RGB:
2466 case MODE_24_BGR: 2466 case MODE_24_BGR:
2467 this->yuv2rgb_single_pixel_fun = 2467 this->yuv2rgb_single_pixel_fun =
2468 (this->mode==MODE_24_RGB && !this->swapped) || (this->mode==MODE_24_BGR && this->swapped) 2468 (this->mode==MODE_24_RGB && !this->swapped) || (this->mode==MODE_24_BGR && this->swapped)
2469 ? yuv2rgb_single_pixel_24_rgb 2469 ? yuv2rgb_single_pixel_24_rgb
2470 : yuv2rgb_single_pixel_24_bgr; 2470 : yuv2rgb_single_pixel_24_bgr;
2471 break; 2471 break;
2472 2472
2473 case MODE_15_BGR: 2473 case MODE_15_BGR:
2474 case MODE_16_BGR: 2474 case MODE_16_BGR:
2475 case MODE_15_RGB: 2475 case MODE_15_RGB:
2476 case MODE_16_RGB: 2476 case MODE_16_RGB:
2477 this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_16; 2477 this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_16;
2478 break; 2478 break;
2479 2479
2480 case MODE_8_RGB: 2480 case MODE_8_RGB:
2481 case MODE_8_BGR: 2481 case MODE_8_BGR:
2482 this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_8; 2482 this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_8;
2483 break; 2483 break;
2484 2484
2485 case MODE_8_GRAY: 2485 case MODE_8_GRAY:
2486 this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_gray; 2486 this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_gray;
2487 break; 2487 break;
2488 2488
2489 case MODE_PALETTE: 2489 case MODE_PALETTE:
2490 this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_palette; 2490 this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_palette;
2491 break; 2491 break;
2492 2492
2493 default: 2493 default:
2494 printf ("yuv2rgb: mode %d not supported by yuv2rgb\n", this->mode); 2494 printf ("yuv2rgb: mode %d not supported by yuv2rgb\n", this->mode);
2495 abort(); 2495 abort();
2496 } 2496 }
2497} 2497}
2498 2498
2499 2499
2500/* 2500/*
2501 * yuy2 stuff 2501 * yuy2 stuff
2502 */ 2502 */
2503 2503
2504static void yuy22rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) 2504static void yuy22rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
2505{ 2505{
2506 int U, V, Y; 2506 int U, V, Y;
2507 uint8_t * py_1, * pu, * pv; 2507 uint8_t * py_1, * pu, * pv;
2508 uint32_t * r, * g, * b; 2508 uint32_t * r, * g, * b;
2509 uint32_t * dst_1; 2509 uint32_t * dst_1;
2510 int width, height; 2510 int width, height;
2511 int dy; 2511 int dy;
2512 2512
2513 /* FIXME: implement unscaled version */ 2513 /* FIXME: implement unscaled version */
2514 2514
2515 scale_line_4 (_p+1, this->u_buffer, 2515 scale_line_4 (_p+1, this->u_buffer,
2516 this->dest_width >> 1, this->step_dx); 2516 this->dest_width >> 1, this->step_dx);
2517 scale_line_4 (_p+3, this->v_buffer, 2517 scale_line_4 (_p+3, this->v_buffer,
2518 this->dest_width >> 1, this->step_dx); 2518 this->dest_width >> 1, this->step_dx);
2519 scale_line_2 (_p, this->y_buffer, 2519 scale_line_2 (_p, this->y_buffer,
2520 this->dest_width, this->step_dx); 2520 this->dest_width, this->step_dx);
2521 2521
2522 dy = 0; 2522 dy = 0;
2523 height = this->dest_height; 2523 height = this->dest_height;
2524 2524
2525 for (;;) { 2525 for (;;) {
2526 dst_1 = (uint32_t*)_dst; 2526 dst_1 = (uint32_t*)_dst;
2527 py_1 = this->y_buffer; 2527 py_1 = this->y_buffer;
2528 pu = this->u_buffer; 2528 pu = this->u_buffer;
2529 pv = this->v_buffer; 2529 pv = this->v_buffer;
2530 2530
2531 width = this->dest_width >> 3; 2531 width = this->dest_width >> 3;
2532 2532
2533 do { 2533 do {
2534 2534
2535 RGB(0); 2535 RGB(0);
2536 DST1(0); 2536 DST1(0);
2537 2537
2538 RGB(1); 2538 RGB(1);
2539 DST1(1); 2539 DST1(1);
2540 2540
2541 RGB(2); 2541 RGB(2);
2542 DST1(2); 2542 DST1(2);
2543 2543
2544 RGB(3); 2544 RGB(3);
2545 DST1(3); 2545 DST1(3);
2546 2546
2547 pu += 4; 2547 pu += 4;
2548 pv += 4; 2548 pv += 4;
2549 py_1 += 8; 2549 py_1 += 8;
2550 dst_1 += 8; 2550 dst_1 += 8;
2551 } while (--width); 2551 } while (--width);
2552 2552
2553 dy += this->step_dy; 2553 dy += this->step_dy;
2554 _dst += this->rgb_stride; 2554 _dst += this->rgb_stride;
2555 2555
2556 while (--height > 0 && dy < 32768) { 2556 while (--height > 0 && dy < 32768) {
2557 2557
2558 xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*4); 2558 xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*4);
2559 2559
2560 dy += this->step_dy; 2560 dy += this->step_dy;
2561 _dst += this->rgb_stride; 2561 _dst += this->rgb_stride;
2562 } 2562 }
2563 2563
2564 if (height <= 0) 2564 if (height <= 0)
2565 break; 2565 break;
2566 2566
2567 _p += this->y_stride*2*(dy>>15); 2567 _p += this->y_stride*2*(dy>>15);
2568 dy &= 32767; 2568 dy &= 32767;
2569 /* 2569 /*
2570 dy -= 32768; 2570 dy -= 32768;
2571 _p += this->y_stride*2; 2571 _p += this->y_stride*2;
2572 */ 2572 */
2573 2573
2574 scale_line_4 (_p+1, this->u_buffer, 2574 scale_line_4 (_p+1, this->u_buffer,
2575 this->dest_width >> 1, this->step_dx); 2575 this->dest_width >> 1, this->step_dx);
2576 scale_line_4 (_p+3, this->v_buffer, 2576 scale_line_4 (_p+3, this->v_buffer,
2577 this->dest_width >> 1, this->step_dx); 2577 this->dest_width >> 1, this->step_dx);
2578 scale_line_2 (_p, this->y_buffer, 2578 scale_line_2 (_p, this->y_buffer,
2579 this->dest_width, this->step_dx); 2579 this->dest_width, this->step_dx);
2580 } 2580 }
2581} 2581}
2582 2582
2583static void yuy22rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) 2583static void yuy22rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
2584{ 2584{
2585 int U, V, Y; 2585 int U, V, Y;
2586 uint8_t * py_1, * pu, * pv; 2586 uint8_t * py_1, * pu, * pv;
2587 uint8_t * r, * g, * b; 2587 uint8_t * r, * g, * b;
2588 uint8_t * dst_1; 2588 uint8_t * dst_1;
2589 int width, height; 2589 int width, height;
2590 int dy; 2590 int dy;
2591 2591
2592 /* FIXME: implement unscaled version */ 2592 /* FIXME: implement unscaled version */
2593 2593
2594 scale_line_4 (_p+1, this->u_buffer, 2594 scale_line_4 (_p+1, this->u_buffer,
2595 this->dest_width >> 1, this->step_dx); 2595 this->dest_width >> 1, this->step_dx);
2596 scale_line_4 (_p+3, this->v_buffer, 2596 scale_line_4 (_p+3, this->v_buffer,
2597 this->dest_width >> 1, this->step_dx); 2597 this->dest_width >> 1, this->step_dx);
2598 scale_line_2 (_p, this->y_buffer, 2598 scale_line_2 (_p, this->y_buffer,
2599 this->dest_width, this->step_dx); 2599 this->dest_width, this->step_dx);
2600 2600
2601 dy = 0; 2601 dy = 0;
2602 height = this->dest_height; 2602 height = this->dest_height;
2603 2603
2604 for (;;) { 2604 for (;;) {
2605 dst_1 = _dst; 2605 dst_1 = _dst;
2606 py_1 = this->y_buffer; 2606 py_1 = this->y_buffer;
2607 pu = this->u_buffer; 2607 pu = this->u_buffer;
2608 pv = this->v_buffer; 2608 pv = this->v_buffer;
2609 2609
2610 width = this->dest_width >> 3; 2610 width = this->dest_width >> 3;
2611 2611
2612 do { 2612 do {
2613 RGB(0); 2613 RGB(0);
2614 DST1RGB(0); 2614 DST1RGB(0);
2615 2615
2616 RGB(1); 2616 RGB(1);
2617 DST1RGB(1); 2617 DST1RGB(1);
2618 2618
2619 RGB(2); 2619 RGB(2);
2620 DST1RGB(2); 2620 DST1RGB(2);
2621 2621
2622 RGB(3); 2622 RGB(3);
2623 DST1RGB(3); 2623 DST1RGB(3);
2624 2624
2625 pu += 4; 2625 pu += 4;
2626 pv += 4; 2626 pv += 4;
2627 py_1 += 8; 2627 py_1 += 8;
2628 dst_1 += 24; 2628 dst_1 += 24;
2629 } while (--width); 2629 } while (--width);
2630 2630
2631 dy += this->step_dy; 2631 dy += this->step_dy;
2632 _dst += this->rgb_stride; 2632 _dst += this->rgb_stride;
2633 2633
2634 while (--height > 0 && dy < 32768) { 2634 while (--height > 0 && dy < 32768) {
2635 2635
2636 xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*3); 2636 xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*3);
2637 2637
2638 dy += this->step_dy; 2638 dy += this->step_dy;
2639 _dst += this->rgb_stride; 2639 _dst += this->rgb_stride;
2640 } 2640 }
2641 2641
2642 if (height <= 0) 2642 if (height <= 0)
2643 break; 2643 break;
2644 2644
2645 _p += this->y_stride*2*(dy>>15); 2645 _p += this->y_stride*2*(dy>>15);
2646 dy &= 32767; 2646 dy &= 32767;
2647 /* 2647 /*
2648 dy -= 32768; 2648 dy -= 32768;
2649 _p += this->y_stride*2; 2649 _p += this->y_stride*2;
2650 */ 2650 */
2651 2651
2652 scale_line_4 (_p+1, this->u_buffer, 2652 scale_line_4 (_p+1, this->u_buffer,
2653 this->dest_width >> 1, this->step_dx); 2653 this->dest_width >> 1, this->step_dx);
2654 scale_line_4 (_p+3, this->v_buffer, 2654 scale_line_4 (_p+3, this->v_buffer,
2655 this->dest_width >> 1, this->step_dx); 2655 this->dest_width >> 1, this->step_dx);
2656 scale_line_2 (_p, this->y_buffer, 2656 scale_line_2 (_p, this->y_buffer,
2657 this->dest_width, this->step_dx); 2657 this->dest_width, this->step_dx);
2658 } 2658 }
2659} 2659}
2660 2660
2661static void yuy22rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) 2661static void yuy22rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
2662{ 2662{
2663 int U, V, Y; 2663 int U, V, Y;
2664 uint8_t * py_1, * pu, * pv; 2664 uint8_t * py_1, * pu, * pv;
2665 uint8_t * r, * g, * b; 2665 uint8_t * r, * g, * b;
2666 uint8_t * dst_1; 2666 uint8_t * dst_1;
2667 int width, height; 2667 int width, height;
2668 int dy; 2668 int dy;
2669 2669
2670 /* FIXME: implement unscaled version */ 2670 /* FIXME: implement unscaled version */
2671 2671
2672 scale_line_4 (_p+1, this->u_buffer, 2672 scale_line_4 (_p+1, this->u_buffer,
2673 this->dest_width >> 1, this->step_dx); 2673 this->dest_width >> 1, this->step_dx);
2674 scale_line_4 (_p+3, this->v_buffer, 2674 scale_line_4 (_p+3, this->v_buffer,
2675 this->dest_width >> 1, this->step_dx); 2675 this->dest_width >> 1, this->step_dx);
2676 scale_line_2 (_p, this->y_buffer, 2676 scale_line_2 (_p, this->y_buffer,
2677 this->dest_width, this->step_dx); 2677 this->dest_width, this->step_dx);
2678 2678
2679 dy = 0; 2679 dy = 0;
2680 height = this->dest_height; 2680 height = this->dest_height;
2681 2681
2682 for (;;) { 2682 for (;;) {
2683 dst_1 = _dst; 2683 dst_1 = _dst;
2684 py_1 = this->y_buffer; 2684 py_1 = this->y_buffer;
2685 pu = this->u_buffer; 2685 pu = this->u_buffer;
2686 pv = this->v_buffer; 2686 pv = this->v_buffer;
2687 2687
2688 width = this->dest_width >> 3; 2688 width = this->dest_width >> 3;
2689 2689
2690 do { 2690 do {
2691 RGB(0); 2691 RGB(0);
2692 DST1BGR(0); 2692 DST1BGR(0);
2693 2693
2694 RGB(1); 2694 RGB(1);
2695 DST1BGR(1); 2695 DST1BGR(1);
2696 2696
2697 RGB(2); 2697 RGB(2);
2698 DST1BGR(2); 2698 DST1BGR(2);
2699 2699
2700 RGB(3); 2700 RGB(3);
2701 DST1BGR(3); 2701 DST1BGR(3);
2702 2702
2703 pu += 4; 2703 pu += 4;
2704 pv += 4; 2704 pv += 4;
2705 py_1 += 8; 2705 py_1 += 8;
2706 dst_1 += 24; 2706 dst_1 += 24;
2707 } while (--width); 2707 } while (--width);
2708 2708
2709 dy += this->step_dy; 2709 dy += this->step_dy;
2710 _dst += this->rgb_stride; 2710 _dst += this->rgb_stride;
2711 2711
2712 while (--height > 0 && dy < 32768) { 2712 while (--height > 0 && dy < 32768) {
2713 2713
2714 xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*3); 2714 xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*3);
2715 2715
2716 dy += this->step_dy; 2716 dy += this->step_dy;
2717 _dst += this->rgb_stride; 2717 _dst += this->rgb_stride;
2718 } 2718 }
2719 2719
2720 if (height <= 0) 2720 if (height <= 0)
2721 break; 2721 break;
2722 2722
2723 _p += this->y_stride*2*(dy>>15); 2723 _p += this->y_stride*2*(dy>>15);
2724 dy &= 32767; 2724 dy &= 32767;
2725 2725
2726 scale_line_4 (_p+1, this->u_buffer, 2726 scale_line_4 (_p+1, this->u_buffer,
2727 this->dest_width >> 1, this->step_dx); 2727 this->dest_width >> 1, this->step_dx);
2728 scale_line_4 (_p+3, this->v_buffer, 2728 scale_line_4 (_p+3, this->v_buffer,
2729 this->dest_width >> 1, this->step_dx); 2729 this->dest_width >> 1, this->step_dx);
2730 scale_line_2 (_p, this->y_buffer, 2730 scale_line_2 (_p, this->y_buffer,
2731 this->dest_width, this->step_dx); 2731 this->dest_width, this->step_dx);
2732 } 2732 }
2733} 2733}
2734 2734
2735static void yuy22rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) 2735static void yuy22rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
2736{ 2736{
2737 int U, V, Y; 2737 int U, V, Y;
2738 uint8_t * py_1, * pu, * pv; 2738 uint8_t * py_1, * pu, * pv;
2739 uint16_t * r, * g, * b; 2739 uint16_t * r, * g, * b;
2740 uint16_t * dst_1; 2740 uint16_t * dst_1;
2741 int width, height; 2741 int width, height;
2742 int dy; 2742 int dy;
2743 2743
2744 /* FIXME: implement unscaled version */ 2744 /* FIXME: implement unscaled version */
2745 2745
2746 scale_line_4 (_p+1, this->u_buffer, 2746 scale_line_4 (_p+1, this->u_buffer,
2747 this->dest_width >> 1, this->step_dx); 2747 this->dest_width >> 1, this->step_dx);
2748 scale_line_4 (_p+3, this->v_buffer, 2748 scale_line_4 (_p+3, this->v_buffer,
2749 this->dest_width >> 1, this->step_dx); 2749 this->dest_width >> 1, this->step_dx);
2750 scale_line_2 (_p, this->y_buffer, 2750 scale_line_2 (_p, this->y_buffer,