author | sandman <sandman> | 2002-08-04 20:23:19 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-08-04 20:23:19 (UTC) |
commit | 57bd412cf973805fbe69ecfa8f168ad2e28311a9 (patch) (unidiff) | |
tree | 78d7bab924023bdf33a437447bb31fff52b51c32 | |
parent | 7bf26dd95a7bd434edc8dd5e001d8ac490f67dc3 (diff) | |
download | opie-57bd412cf973805fbe69ecfa8f168ad2e28311a9.zip opie-57bd412cf973805fbe69ecfa8f168ad2e28311a9.tar.gz opie-57bd412cf973805fbe69ecfa8f168ad2e28311a9.tar.bz2 |
- Removed the mlib and mmx yuv2rgb converters
- Added an optimized (non-scaling !) arm4l yuv2rgb (taken from bbplay)
-rw-r--r-- | noncore/multimedia/opieplayer2/nullvideo.c | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/opieplayer2.pro | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/yuv2rgb.c | 8 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/yuv2rgb_arm.c | 174 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/yuv2rgb_arm4l.S | 192 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/yuv2rgb_mlib.c | 313 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/yuv2rgb_mmx.c | 1047 |
7 files changed, 375 insertions, 1363 deletions
diff --git a/noncore/multimedia/opieplayer2/nullvideo.c b/noncore/multimedia/opieplayer2/nullvideo.c index 79337c2..bd52869 100644 --- a/noncore/multimedia/opieplayer2/nullvideo.c +++ b/noncore/multimedia/opieplayer2/nullvideo.c | |||
@@ -1,674 +1,672 @@ | |||
1 | 1 | ||
2 | /*#include <xine.h>*/ | 2 | /*#include <xine.h>*/ |
3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
4 | #include <stdio.h> | 4 | #include <stdio.h> |
5 | 5 | ||
6 | #include <math.h> | 6 | #include <math.h> |
7 | 7 | ||
8 | #include <xine/video_out.h> | 8 | #include <xine/video_out.h> |
9 | #include <xine/xine_internal.h> | 9 | #include <xine/xine_internal.h> |
10 | #include <xine/xineutils.h> | 10 | #include <xine/xineutils.h> |
11 | #include <xine/configfile.h> | 11 | #include <xine/configfile.h> |
12 | 12 | ||
13 | #include <pthread.h> | 13 | #include <pthread.h> |
14 | #include "alphablend.h" | 14 | #include "alphablend.h" |
15 | #include "yuv2rgb.h" | 15 | #include "yuv2rgb.h" |
16 | 16 | ||
17 | #define printf(x,...) | 17 | #define printf(x,...) |
18 | 18 | ||
19 | /* the caller for our event draw handler */ | 19 | /* the caller for our event draw handler */ |
20 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, | 20 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, |
21 | int width, int height,int bytes ); | 21 | int width, int height,int bytes ); |
22 | 22 | ||
23 | typedef struct null_driver_s null_driver_t; | 23 | typedef struct null_driver_s null_driver_t; |
24 | 24 | ||
25 | struct null_driver_s { | 25 | struct null_driver_s { |
26 | vo_driver_t vo_driver; | 26 | vo_driver_t vo_driver; |
27 | uint32_t m_capabilities; | 27 | uint32_t m_capabilities; |
28 | int m_show_video; | 28 | int m_show_video; |
29 | int m_video_fullscreen; | 29 | int m_video_fullscreen; |
30 | int m_is_scaling; | 30 | int m_is_scaling; |
31 | int depth, bpp, bytes_per_pixel; | 31 | int depth, bpp, bytes_per_pixel; |
32 | int yuv2rgb_mode; | 32 | int yuv2rgb_mode; |
33 | int yuv2rgb_swap; | 33 | int yuv2rgb_swap; |
34 | int zuv2rgb_gamma; | 34 | int zuv2rgb_gamma; |
35 | uint8_t *yuv2rgb_cmap; | 35 | uint8_t *yuv2rgb_cmap; |
36 | yuv2rgb_factory_t *yuv2rgb_factory; | 36 | yuv2rgb_factory_t *yuv2rgb_factory; |
37 | vo_overlay_t *overlay; | 37 | vo_overlay_t *overlay; |
38 | int user_ratio; | 38 | int user_ratio; |
39 | double output_scale_factor; | 39 | double output_scale_factor; |
40 | int last_frame_output_width; | 40 | int last_frame_output_width; |
41 | int last_frame_output_height; | 41 | int last_frame_output_height; |
42 | int gui_width; | 42 | int gui_width; |
43 | int gui_height; | 43 | int gui_height; |
44 | int gui_changed; | 44 | int gui_changed; |
45 | double display_ratio; | 45 | double display_ratio; |
46 | void* caller; | 46 | void* caller; |
47 | display_xine_frame_t frameDis; | 47 | display_xine_frame_t frameDis; |
48 | 48 | ||
49 | 49 | ||
50 | }; | 50 | }; |
51 | typedef struct opie_frame_s opie_frame_t; | 51 | typedef struct opie_frame_s opie_frame_t; |
52 | struct opie_frame_s { | 52 | struct opie_frame_s { |
53 | vo_frame_t frame; | 53 | vo_frame_t frame; |
54 | char* name; | 54 | char* name; |
55 | int version; | 55 | int version; |
56 | int width; | 56 | int width; |
57 | int height; | 57 | int height; |
58 | int ratio_code; | 58 | int ratio_code; |
59 | int format; | 59 | int format; |
60 | int flags; | 60 | int flags; |
61 | int user_ratio; | 61 | int user_ratio; |
62 | 62 | ||
63 | double ratio_factor; | 63 | double ratio_factor; |
64 | int ideal_width; | 64 | int ideal_width; |
65 | int ideal_height; | 65 | int ideal_height; |
66 | int output_width, output_height; | 66 | int output_width, output_height; |
67 | int gui_width, gui_height; | 67 | int gui_width, gui_height; |
68 | uint8_t *chunk[3]; | 68 | uint8_t *chunk[3]; |
69 | 69 | ||
70 | yuv2rgb_t *yuv2rgb; | 70 | yuv2rgb_t *yuv2rgb; |
71 | uint8_t *rgb_dst; | 71 | uint8_t *rgb_dst; |
72 | int yuv_stride; | 72 | int yuv_stride; |
73 | int stripe_height, stripe_inc; | 73 | int stripe_height, stripe_inc; |
74 | 74 | ||
75 | int bytes_per_line; | 75 | int bytes_per_line; |
76 | uint8_t *data; | 76 | uint8_t *data; |
77 | 77 | ||
78 | // int show_video; | 78 | // int show_video; |
79 | null_driver_t *output; | 79 | null_driver_t *output; |
80 | }; | 80 | }; |
81 | 81 | ||
82 | static uint32_t null_get_capabilities(vo_driver_t *self ){ | 82 | static uint32_t null_get_capabilities(vo_driver_t *self ){ |
83 | null_driver_t* this = (null_driver_t*)self; | 83 | null_driver_t* this = (null_driver_t*)self; |
84 | printf("capabilities\n"); | 84 | printf("capabilities\n"); |
85 | return this->m_capabilities; | 85 | return this->m_capabilities; |
86 | } | 86 | } |
87 | 87 | ||
88 | static void null_frame_copy (vo_frame_t *vo_img, uint8_t **src) { | 88 | static void null_frame_copy (vo_frame_t *vo_img, uint8_t **src) { |
89 | opie_frame_t *frame = (opie_frame_t *) vo_img ; | 89 | opie_frame_t *frame = (opie_frame_t *) vo_img ; |
90 | printf("frame copy\n"); | 90 | printf("frame copy\n"); |
91 | if(!frame->output->m_show_video ){ printf("no video\n"); return; } // no video | 91 | if(!frame->output->m_show_video ){ printf("no video\n"); return; } // no video |
92 | 92 | ||
93 | if (frame->format == IMGFMT_YV12) { | 93 | if (frame->format == IMGFMT_YV12) { |
94 | frame->yuv2rgb->yuv2rgb_fun (frame->yuv2rgb, frame->rgb_dst, | 94 | frame->yuv2rgb->yuv2rgb_fun (frame->yuv2rgb, frame->rgb_dst, |
95 | src[0], src[1], src[2]); | 95 | src[0], src[1], src[2]); |
96 | } else { | 96 | } else { |
97 | 97 | ||
98 | frame->yuv2rgb->yuy22rgb_fun (frame->yuv2rgb, frame->rgb_dst, | 98 | frame->yuv2rgb->yuy22rgb_fun (frame->yuv2rgb, frame->rgb_dst, |
99 | src[0]); | 99 | src[0]); |
100 | } | 100 | } |
101 | 101 | ||
102 | frame->rgb_dst += frame->stripe_inc; | 102 | frame->rgb_dst += frame->stripe_inc; |
103 | printf("returning\n"); | 103 | printf("returning\n"); |
104 | } | 104 | } |
105 | 105 | ||
106 | static void null_frame_field (vo_frame_t *vo_img, int which_field) { | 106 | static void null_frame_field (vo_frame_t *vo_img, int which_field) { |
107 | 107 | ||
108 | opie_frame_t *frame = (opie_frame_t *) vo_img ; | 108 | opie_frame_t *frame = (opie_frame_t *) vo_img ; |
109 | printf("field\n\n"); | 109 | printf("field\n\n"); |
110 | 110 | ||
111 | switch (which_field) { | 111 | switch (which_field) { |
112 | case VO_TOP_FIELD: | 112 | case VO_TOP_FIELD: |
113 | frame->rgb_dst = (uint8_t *)frame->data; | 113 | frame->rgb_dst = (uint8_t *)frame->data; |
114 | frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line; | 114 | frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line; |
115 | break; | 115 | break; |
116 | case VO_BOTTOM_FIELD: | 116 | case VO_BOTTOM_FIELD: |
117 | frame->rgb_dst = (uint8_t *)frame->data + frame->bytes_per_line ; | 117 | frame->rgb_dst = (uint8_t *)frame->data + frame->bytes_per_line ; |
118 | frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line; | 118 | frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line; |
119 | break; | 119 | break; |
120 | case VO_BOTH_FIELDS: | 120 | case VO_BOTH_FIELDS: |
121 | frame->rgb_dst = (uint8_t *)frame->data; | 121 | frame->rgb_dst = (uint8_t *)frame->data; |
122 | break; | 122 | break; |
123 | } | 123 | } |
124 | } | 124 | } |
125 | 125 | ||
126 | 126 | ||
127 | /* take care of the frame*/ | 127 | /* take care of the frame*/ |
128 | static void null_frame_dispose( vo_frame_t* vo_img){ | 128 | static void null_frame_dispose( vo_frame_t* vo_img){ |
129 | opie_frame_t* frame = (opie_frame_t*)vo_img; | 129 | opie_frame_t* frame = (opie_frame_t*)vo_img; |
130 | printf("frame_dispose\n"); | 130 | printf("frame_dispose\n"); |
131 | if( frame->data ) | 131 | if( frame->data ) |
132 | free( frame->data ); | 132 | free( frame->data ); |
133 | free (frame); | 133 | free (frame); |
134 | } | 134 | } |
135 | 135 | ||
136 | /* end take care of frames*/ | 136 | /* end take care of frames*/ |
137 | 137 | ||
138 | static vo_frame_t* null_alloc_frame( vo_driver_t* self ){ | 138 | static vo_frame_t* null_alloc_frame( vo_driver_t* self ){ |
139 | null_driver_t* this = (null_driver_t*)self; | 139 | null_driver_t* this = (null_driver_t*)self; |
140 | opie_frame_t* frame; | 140 | opie_frame_t* frame; |
141 | frame = (opie_frame_t*)malloc ( sizeof(opie_frame_t) ); | 141 | frame = (opie_frame_t*)malloc ( sizeof(opie_frame_t) ); |
142 | 142 | ||
143 | memset( frame, 0, sizeof( opie_frame_t) ); | 143 | memset( frame, 0, sizeof( opie_frame_t) ); |
144 | pthread_mutex_init (&frame->frame.mutex, NULL); | 144 | pthread_mutex_init (&frame->frame.mutex, NULL); |
145 | 145 | ||
146 | printf("alloc_frame\n"); | 146 | printf("alloc_frame\n"); |
147 | frame->name = "opie\0"; | 147 | frame->name = "opie\0"; |
148 | frame->version = 1; | 148 | frame->version = 1; |
149 | frame->output = this; | 149 | frame->output = this; |
150 | // frame->show_video = this->m_show_video; | 150 | // frame->show_video = this->m_show_video; |
151 | /* initialize the frame*/ | 151 | /* initialize the frame*/ |
152 | frame->frame.driver = self; | 152 | frame->frame.driver = self; |
153 | /*frame.frame.free = null_frame_free;*/ | 153 | /*frame.frame.free = null_frame_free;*/ |
154 | frame->frame.copy = null_frame_copy; | 154 | frame->frame.copy = null_frame_copy; |
155 | frame->frame.field = null_frame_field; | 155 | frame->frame.field = null_frame_field; |
156 | frame->frame.dispose = null_frame_dispose; | 156 | frame->frame.dispose = null_frame_dispose; |
157 | frame->yuv2rgb = 0; | 157 | frame->yuv2rgb = 0; |
158 | /* | 158 | /* |
159 | * colorspace converter for this frame | 159 | * colorspace converter for this frame |
160 | */ | 160 | */ |
161 | frame->yuv2rgb = this->yuv2rgb_factory->create_converter (this->yuv2rgb_factory); | 161 | frame->yuv2rgb = this->yuv2rgb_factory->create_converter (this->yuv2rgb_factory); |
162 | 162 | ||
163 | 163 | ||
164 | return (vo_frame_t*) frame; | 164 | return (vo_frame_t*) frame; |
165 | } | 165 | } |
166 | 166 | ||
167 | // size specific | 167 | // size specific |
168 | static void null_compute_ideal_size (null_driver_t *this, opie_frame_t *frame) { | 168 | static void null_compute_ideal_size (null_driver_t *this, opie_frame_t *frame) { |
169 | 169 | ||
170 | if (!this->m_is_scaling /*|| !this->m_show_video*/) { | 170 | if (!this->m_is_scaling /*|| !this->m_show_video*/) { |
171 | printf("Not scaling\n"); | 171 | printf("Not scaling\n"); |
172 | frame->ideal_width = frame->width; | 172 | frame->ideal_width = frame->width; |
173 | frame->ideal_height = frame->height; | 173 | frame->ideal_height = frame->height; |
174 | frame->ratio_factor = 1.0; | 174 | frame->ratio_factor = 1.0; |
175 | 175 | ||
176 | } else { | 176 | } else { |
177 | 177 | ||
178 | double image_ratio, desired_ratio, corr_factor; | 178 | double image_ratio, desired_ratio, corr_factor; |
179 | 179 | ||
180 | image_ratio = (double) frame->width / (double) frame->height; | 180 | image_ratio = (double) frame->width / (double) frame->height; |
181 | 181 | ||
182 | switch (frame->user_ratio) { | 182 | switch (frame->user_ratio) { |
183 | case ASPECT_AUTO: | 183 | case ASPECT_AUTO: |
184 | switch (frame->ratio_code) { | 184 | switch (frame->ratio_code) { |
185 | case XINE_ASPECT_RATIO_ANAMORPHIC: /* anamorphic */ | 185 | case XINE_ASPECT_RATIO_ANAMORPHIC: /* anamorphic */ |
186 | case XINE_ASPECT_RATIO_PAN_SCAN: | 186 | case XINE_ASPECT_RATIO_PAN_SCAN: |
187 | desired_ratio = 16.0 /9.0; | 187 | desired_ratio = 16.0 /9.0; |
188 | break; | 188 | break; |
189 | case XINE_ASPECT_RATIO_211_1: /* 2.11:1 */ | 189 | case XINE_ASPECT_RATIO_211_1: /* 2.11:1 */ |
190 | desired_ratio = 2.11/1.0; | 190 | desired_ratio = 2.11/1.0; |
191 | break; | 191 | break; |
192 | case XINE_ASPECT_RATIO_SQUARE: /* square pels */ | 192 | case XINE_ASPECT_RATIO_SQUARE: /* square pels */ |
193 | case XINE_ASPECT_RATIO_DONT_TOUCH: /* probably non-mpeg stream => don't touch aspect ratio */ | 193 | case XINE_ASPECT_RATIO_DONT_TOUCH: /* probably non-mpeg stream => don't touch aspect ratio */ |
194 | desired_ratio = image_ratio; | 194 | desired_ratio = image_ratio; |
195 | break; | 195 | break; |
196 | case 0: /* forbidden -> 4:3 */ | 196 | case 0: /* forbidden -> 4:3 */ |
197 | printf ("video_out_fb: invalid ratio, using 4:3\n"); | 197 | printf ("video_out_fb: invalid ratio, using 4:3\n"); |
198 | default: | 198 | default: |
199 | printf ("video_out_fb: unknown aspect ratio (%d) in stream => using 4:3\n", | 199 | printf ("video_out_fb: unknown aspect ratio (%d) in stream => using 4:3\n", |
200 | frame->ratio_code); | 200 | frame->ratio_code); |
201 | case XINE_ASPECT_RATIO_4_3: /* 4:3 */ | 201 | case XINE_ASPECT_RATIO_4_3: /* 4:3 */ |
202 | desired_ratio = 4.0 / 3.0; | 202 | desired_ratio = 4.0 / 3.0; |
203 | break; | 203 | break; |
204 | } | 204 | } |
205 | break; | 205 | break; |
206 | case ASPECT_ANAMORPHIC: | 206 | case ASPECT_ANAMORPHIC: |
207 | desired_ratio = 16.0 / 9.0; | 207 | desired_ratio = 16.0 / 9.0; |
208 | break; | 208 | break; |
209 | case ASPECT_DVB: | 209 | case ASPECT_DVB: |
210 | desired_ratio = 2.0 / 1.0; | 210 | desired_ratio = 2.0 / 1.0; |
211 | break; | 211 | break; |
212 | case ASPECT_SQUARE: | 212 | case ASPECT_SQUARE: |
213 | desired_ratio = image_ratio; | 213 | desired_ratio = image_ratio; |
214 | break; | 214 | break; |
215 | case ASPECT_FULL: | 215 | case ASPECT_FULL: |
216 | default: | 216 | default: |
217 | desired_ratio = 4.0 / 3.0; | 217 | desired_ratio = 4.0 / 3.0; |
218 | } | 218 | } |
219 | 219 | ||
220 | frame->ratio_factor = this->display_ratio * desired_ratio; | 220 | frame->ratio_factor = this->display_ratio * desired_ratio; |
221 | 221 | ||
222 | corr_factor = frame->ratio_factor / image_ratio ; | 222 | corr_factor = frame->ratio_factor / image_ratio ; |
223 | 223 | ||
224 | if (fabs(corr_factor - 1.0) < 0.005) { | 224 | if (fabs(corr_factor - 1.0) < 0.005) { |
225 | frame->ideal_width = frame->width; | 225 | frame->ideal_width = frame->width; |
226 | frame->ideal_height = frame->height; | 226 | frame->ideal_height = frame->height; |
227 | 227 | ||
228 | } else { | 228 | } else { |
229 | 229 | ||
230 | if (corr_factor >= 1.0) { | 230 | if (corr_factor >= 1.0) { |
231 | frame->ideal_width = frame->width * corr_factor + 0.5; | 231 | frame->ideal_width = frame->width * corr_factor + 0.5; |
232 | frame->ideal_height = frame->height; | 232 | frame->ideal_height = frame->height; |
233 | } else { | 233 | } else { |
234 | frame->ideal_width = frame->width; | 234 | frame->ideal_width = frame->width; |
235 | frame->ideal_height = frame->height / corr_factor + 0.5; | 235 | frame->ideal_height = frame->height / corr_factor + 0.5; |
236 | } | 236 | } |
237 | 237 | ||
238 | } | 238 | } |
239 | } | 239 | } |
240 | printf("return from helper\n"); | 240 | printf("return from helper\n"); |
241 | } | 241 | } |
242 | 242 | ||
243 | static void null_compute_rgb_size (null_driver_t *this, opie_frame_t *frame) { | 243 | static void null_compute_rgb_size (null_driver_t *this, opie_frame_t *frame) { |
244 | 244 | ||
245 | double x_factor, y_factor; | 245 | double x_factor, y_factor; |
246 | 246 | ||
247 | /* | 247 | /* |
248 | * make the frame fit into the given destination area | 248 | * make the frame fit into the given destination area |
249 | */ | 249 | */ |
250 | 250 | ||
251 | x_factor = (double) this->gui_width / (double) frame->ideal_width; | 251 | x_factor = (double) this->gui_width / (double) frame->ideal_width; |
252 | y_factor = (double) this->gui_height / (double) frame->ideal_height; | 252 | y_factor = (double) this->gui_height / (double) frame->ideal_height; |
253 | 253 | ||
254 | if ( x_factor < y_factor ) { | 254 | if ( x_factor < y_factor ) { |
255 | frame->output_width = (double) frame->ideal_width * x_factor ; | 255 | frame->output_width = (double) frame->ideal_width * x_factor ; |
256 | frame->output_height = (double) frame->ideal_height * x_factor ; | 256 | frame->output_height = (double) frame->ideal_height * x_factor ; |
257 | } else { | 257 | } else { |
258 | frame->output_width = (double) frame->ideal_width * y_factor ; | 258 | frame->output_width = (double) frame->ideal_width * y_factor ; |
259 | frame->output_height = (double) frame->ideal_height * y_factor ; | 259 | frame->output_height = (double) frame->ideal_height * y_factor ; |
260 | } | 260 | } |
261 | 261 | ||
262 | #define LOG 1 | 262 | #define LOG 1 |
263 | #ifdef LOG | 263 | #ifdef LOG |
264 | printf("video_out_fb: frame source %d x %d => screen output %d x %d%s\n", | 264 | printf("video_out_fb: frame source %d x %d => screen output %d x %d%s\n", |
265 | frame->width, frame->height, | 265 | frame->width, frame->height, |
266 | frame->output_width, frame->output_height, | 266 | frame->output_width, frame->output_height, |
267 | ( frame->width != frame->output_width | 267 | ( frame->width != frame->output_width |
268 | || frame->height != frame->output_height | 268 | || frame->height != frame->output_height |
269 | ? ", software scaling" | 269 | ? ", software scaling" |
270 | : "" ) | 270 | : "" ) |
271 | ); | 271 | ); |
272 | #endif | 272 | #endif |
273 | } | 273 | } |
274 | 274 | ||
275 | 275 | ||
276 | // size specific | 276 | // size specific |
277 | 277 | ||
278 | 278 | ||
279 | static void null_update_frame_format( vo_driver_t* self, vo_frame_t* img, | 279 | static void null_update_frame_format( vo_driver_t* self, vo_frame_t* img, |
280 | uint32_t width, uint32_t height, | 280 | uint32_t width, uint32_t height, |
281 | int ratio_code, int format, int flags ){ | 281 | int ratio_code, int format, int flags ){ |
282 | null_driver_t* this = (null_driver_t*) self; | 282 | null_driver_t* this = (null_driver_t*) self; |
283 | opie_frame_t* frame = (opie_frame_t*)img; | 283 | opie_frame_t* frame = (opie_frame_t*)img; |
284 | /* not needed now */ | 284 | /* not needed now */ |
285 | printf("update_frame_format\n"); | 285 | printf("update_frame_format\n"); |
286 | printf("al crash aye?\n"); | 286 | printf("al crash aye?\n"); |
287 | 287 | ||
288 | flags &= VO_BOTH_FIELDS; | 288 | flags &= VO_BOTH_FIELDS; |
289 | 289 | ||
290 | /* find out if we need to adapt this frame */ | 290 | /* find out if we need to adapt this frame */ |
291 | 291 | ||
292 | if ((width != frame->width) | 292 | if ((width != frame->width) |
293 | || (height != frame->height) | 293 | || (height != frame->height) |
294 | || (ratio_code != frame->ratio_code) | 294 | || (ratio_code != frame->ratio_code) |
295 | || (flags != frame->flags) | 295 | || (flags != frame->flags) |
296 | || (format != frame->format) | 296 | || (format != frame->format) |
297 | || (this->user_ratio != frame->user_ratio) | 297 | || (this->user_ratio != frame->user_ratio) |
298 | || (this->gui_width != frame-> gui_width ) | 298 | || (this->gui_width != frame-> gui_width ) |
299 | || (this-> gui_height != frame-> gui_height)) { | 299 | || (this-> gui_height != frame-> gui_height)) { |
300 | 300 | ||
301 | frame->width = width; | 301 | frame->width = width; |
302 | frame->height = height; | 302 | frame->height = height; |
303 | frame->ratio_code = ratio_code; | 303 | frame->ratio_code = ratio_code; |
304 | frame->flags = flags; | 304 | frame->flags = flags; |
305 | frame->format = format; | 305 | frame->format = format; |
306 | frame->user_ratio = this->user_ratio; | 306 | frame->user_ratio = this->user_ratio; |
307 | this->gui_changed = 0; | 307 | this->gui_changed = 0; |
308 | //frame->show_video = this->m_show_video; | 308 | //frame->show_video = this->m_show_video; |
309 | frame->gui_width = this->gui_width; | 309 | frame->gui_width = this->gui_width; |
310 | frame->gui_height = this->gui_height; | 310 | frame->gui_height = this->gui_height; |
311 | 311 | ||
312 | null_compute_ideal_size (this, frame); | 312 | null_compute_ideal_size (this, frame); |
313 | null_compute_rgb_size (this, frame); | 313 | null_compute_rgb_size (this, frame); |
314 | 314 | ||
315 | /* | 315 | /* |
316 | * (re-) allocate | 316 | * (re-) allocate |
317 | */ | 317 | */ |
318 | if( frame->data ) { | 318 | if( frame->data ) { |
319 | if(frame->chunk[0] ){ | 319 | if(frame->chunk[0] ){ |
320 | free( frame->chunk[0] ); | 320 | free( frame->chunk[0] ); |
321 | frame->chunk[0] = NULL; | 321 | frame->chunk[0] = NULL; |
322 | } | 322 | } |
323 | if(frame->chunk[1] ){ | 323 | if(frame->chunk[1] ){ |
324 | free ( frame->chunk[1] ); | 324 | free ( frame->chunk[1] ); |
325 | frame->chunk[1] = NULL; | 325 | frame->chunk[1] = NULL; |
326 | } | 326 | } |
327 | if(frame->chunk[2] ){ | 327 | if(frame->chunk[2] ){ |
328 | free ( frame->chunk[2] ); | 328 | free ( frame->chunk[2] ); |
329 | frame->chunk[2] = NULL; | 329 | frame->chunk[2] = NULL; |
330 | } | 330 | } |
331 | free ( frame->data ); | 331 | free ( frame->data ); |
332 | } | 332 | } |
333 | printf("after freeing\n"); | 333 | printf("after freeing\n"); |
334 | frame->data = xine_xmalloc (frame->output_width * frame->output_height * | 334 | frame->data = xine_xmalloc (frame->output_width * frame->output_height * |
335 | this->bytes_per_pixel ); | 335 | this->bytes_per_pixel ); |
336 | 336 | ||
337 | if( format == IMGFMT_YV12 ) { | 337 | if( format == IMGFMT_YV12 ) { |
338 | frame->frame.pitches[0] = 8*((width + 7) / 8); | 338 | frame->frame.pitches[0] = 8*((width + 7) / 8); |
339 | frame->frame.pitches[1] = 8*((width + 15) / 16); | 339 | frame->frame.pitches[1] = 8*((width + 15) / 16); |
340 | frame->frame.pitches[2] = 8*((width + 15) / 16); | 340 | frame->frame.pitches[2] = 8*((width + 15) / 16); |
341 | frame->frame.base[0] = xine_xmalloc_aligned (16, frame->frame.pitches[0] * height,(void **)&frame->chunk[0]); | 341 | frame->frame.base[0] = xine_xmalloc_aligned (16, frame->frame.pitches[0] * height,(void **)&frame->chunk[0]); |
342 | frame->frame.base[1] = xine_xmalloc_aligned (16, frame->frame.pitches[1] * ((height+ 1)/2), (void **)&frame->chunk[1]); | 342 | frame->frame.base[1] = xine_xmalloc_aligned (16, frame->frame.pitches[1] * ((height+ 1)/2), (void **)&frame->chunk[1]); |
343 | frame->frame.base[2] = xine_xmalloc_aligned (16, frame->frame.pitches[2] * ((height+ 1)/2), (void **)&frame->chunk[2]); | 343 | frame->frame.base[2] = xine_xmalloc_aligned (16, frame->frame.pitches[2] * ((height+ 1)/2), (void **)&frame->chunk[2]); |
344 | 344 | ||
345 | }else{ | 345 | }else{ |
346 | frame->frame.pitches[0] = 8*((width + 3) / 4); | 346 | frame->frame.pitches[0] = 8*((width + 3) / 4); |
347 | frame->frame.pitches[1] = 8*((width + 3) / 4); | ||
348 | frame->frame.pitches[2] = 8*((width + 3) / 4); | ||
349 | 347 | ||
350 | frame->frame.base[0] = xine_xmalloc_aligned (16, frame->frame.pitches[0] * height, | 348 | frame->frame.base[0] = xine_xmalloc_aligned (16, frame->frame.pitches[0] * height, |
351 | (void **)&frame->chunk[0]); | 349 | (void **)&frame->chunk[0]); |
352 | frame->chunk[1] = NULL; | 350 | frame->chunk[1] = NULL; |
353 | frame->chunk[2] = NULL; | 351 | frame->chunk[2] = NULL; |
354 | } | 352 | } |
355 | 353 | ||
356 | frame->format = format; | 354 | frame->format = format; |
357 | frame->width = width; | 355 | frame->width = width; |
358 | frame->height = height; | 356 | frame->height = height; |
359 | 357 | ||
360 | frame->stripe_height = 16 * frame->output_height / frame->height; | 358 | frame->stripe_height = 16 * frame->output_height / frame->height; |
361 | frame->bytes_per_line = frame->output_width * this->bytes_per_pixel; | 359 | frame->bytes_per_line = frame->output_width * this->bytes_per_pixel; |
362 | 360 | ||
363 | /* | 361 | /* |
364 | * set up colorspace converter | 362 | * set up colorspace converter |
365 | */ | 363 | */ |
366 | if(1 /*this->m_show_video*/ ){ | 364 | if(1 /*this->m_show_video*/ ){ |
367 | printf("showing video\n"); | 365 | printf("showing video\n"); |
368 | 366 | ||
369 | switch (flags) { | 367 | switch (flags) { |
370 | case VO_TOP_FIELD: | 368 | case VO_TOP_FIELD: |
371 | case VO_BOTTOM_FIELD: | 369 | case VO_BOTTOM_FIELD: |
372 | frame->yuv2rgb->configure (frame->yuv2rgb, | 370 | frame->yuv2rgb->configure (frame->yuv2rgb, |
373 | frame->width, | 371 | frame->width, |
374 | 16, | 372 | 16, |
375 | 2*frame->frame.pitches[0], | 373 | 2*frame->frame.pitches[0], |
376 | 2*frame->frame.pitches[1], | 374 | 2*frame->frame.pitches[1], |
377 | frame->output_width, | 375 | frame->output_width, |
378 | frame->stripe_height, | 376 | frame->stripe_height, |
379 | frame->bytes_per_line*2); | 377 | frame->bytes_per_line*2); |
380 | frame->yuv_stride = frame->bytes_per_line*2; | 378 | frame->yuv_stride = frame->bytes_per_line*2; |
381 | break; | 379 | break; |
382 | case VO_BOTH_FIELDS: | 380 | case VO_BOTH_FIELDS: |
383 | frame->yuv2rgb->configure (frame->yuv2rgb, | 381 | frame->yuv2rgb->configure (frame->yuv2rgb, |
384 | frame->width, | 382 | frame->width, |
385 | 16, | 383 | 16, |
386 | frame->frame.pitches[0], | 384 | frame->frame.pitches[0], |
387 | frame->frame.pitches[1], | 385 | frame->frame.pitches[1], |
388 | frame->output_width, | 386 | frame->output_width, |
389 | frame->stripe_height, | 387 | frame->stripe_height, |
390 | frame->bytes_per_line); | 388 | frame->bytes_per_line); |
391 | frame->yuv_stride = frame->bytes_per_line; | 389 | frame->yuv_stride = frame->bytes_per_line; |
392 | break; | 390 | break; |
393 | } | 391 | } |
394 | } | 392 | } |
395 | } | 393 | } |
396 | printf("after gui changed\n"); | 394 | printf("after gui changed\n"); |
397 | /* | 395 | /* |
398 | * reset dest pointers | 396 | * reset dest pointers |
399 | */ | 397 | */ |
400 | 398 | ||
401 | if (frame->data) { | 399 | if (frame->data) { |
402 | switch (flags) { | 400 | switch (flags) { |
403 | case VO_TOP_FIELD: | 401 | case VO_TOP_FIELD: |
404 | frame->rgb_dst = (uint8_t *)frame->data; | 402 | frame->rgb_dst = (uint8_t *)frame->data; |
405 | frame->stripe_inc = 2 * frame->stripe_height * frame->bytes_per_line; | 403 | frame->stripe_inc = 2 * frame->stripe_height * frame->bytes_per_line; |
406 | break; | 404 | break; |
407 | case VO_BOTTOM_FIELD: | 405 | case VO_BOTTOM_FIELD: |
408 | frame->rgb_dst = (uint8_t *)frame->data + frame->bytes_per_line ; | 406 | frame->rgb_dst = (uint8_t *)frame->data + frame->bytes_per_line ; |
409 | frame->stripe_inc = 2 * frame->stripe_height * frame->bytes_per_line; | 407 | frame->stripe_inc = 2 * frame->stripe_height * frame->bytes_per_line; |
410 | break; | 408 | break; |
411 | case VO_BOTH_FIELDS: | 409 | case VO_BOTH_FIELDS: |
412 | frame->rgb_dst = (uint8_t *)frame->data; | 410 | frame->rgb_dst = (uint8_t *)frame->data; |
413 | frame->stripe_inc = frame->stripe_height * frame->bytes_per_line; | 411 | frame->stripe_inc = frame->stripe_height * frame->bytes_per_line; |
414 | break; | 412 | break; |
415 | } | 413 | } |
416 | } | 414 | } |
417 | printf("done\n"); | 415 | printf("done\n"); |
418 | } | 416 | } |
419 | static void null_display_frame( vo_driver_t* self, vo_frame_t *frame_gen ){ | 417 | static void null_display_frame( vo_driver_t* self, vo_frame_t *frame_gen ){ |
420 | null_driver_t* this = (null_driver_t*) self; | 418 | null_driver_t* this = (null_driver_t*) self; |
421 | opie_frame_t* frame = (opie_frame_t*)frame_gen; | 419 | opie_frame_t* frame = (opie_frame_t*)frame_gen; |
422 | display_xine_frame_t display = this->frameDis; | 420 | display_xine_frame_t display = this->frameDis; |
423 | 421 | ||
424 | printf("display frame\n"); | 422 | printf("display frame\n"); |
425 | // if( this->m_show_video ) { // return if not displaying | 423 | // if( this->m_show_video ) { // return if not displaying |
426 | printf("calling home aye\n" ); | 424 | printf("calling home aye\n" ); |
427 | if( display != NULL ) { | 425 | if( display != NULL ) { |
428 | (*display)(this->caller, frame->data, | 426 | (*display)(this->caller, frame->data, |
429 | frame->output_width, frame->output_height, | 427 | frame->output_width, frame->output_height, |
430 | frame->bytes_per_line ); | 428 | frame->bytes_per_line ); |
431 | printf("display done hope you enyoyed the frame"); | 429 | printf("display done hope you enyoyed the frame"); |
432 | } | 430 | } |
433 | // } | 431 | // } |
434 | 432 | ||
435 | frame->frame.displayed (&frame->frame); | 433 | frame->frame.displayed (&frame->frame); |
436 | } | 434 | } |
437 | 435 | ||
438 | 436 | ||
439 | // blending related | 437 | // blending related |
440 | 438 | ||
441 | 439 | ||
442 | static void null_overlay_clut_yuv2rgb(null_driver_t *this, vo_overlay_t *overlay, | 440 | static void null_overlay_clut_yuv2rgb(null_driver_t *this, vo_overlay_t *overlay, |
443 | opie_frame_t *frame) { | 441 | opie_frame_t *frame) { |
444 | int i; | 442 | int i; |
445 | clut_t* clut = (clut_t*) overlay->color; | 443 | clut_t* clut = (clut_t*) overlay->color; |
446 | if (!overlay->rgb_clut) { | 444 | if (!overlay->rgb_clut) { |
447 | for (i = 0; i < sizeof(overlay->color)/sizeof(overlay->color[0]); i++) { | 445 | for (i = 0; i < sizeof(overlay->color)/sizeof(overlay->color[0]); i++) { |
448 | *((uint32_t *)&clut[i]) = | 446 | *((uint32_t *)&clut[i]) = |
449 | frame->yuv2rgb->yuv2rgb_single_pixel_fun (frame->yuv2rgb, | 447 | frame->yuv2rgb->yuv2rgb_single_pixel_fun (frame->yuv2rgb, |
450 | clut[i].y, clut[i].cb, clut[i].cr); | 448 | clut[i].y, clut[i].cb, clut[i].cr); |
451 | } | 449 | } |
452 | overlay->rgb_clut++; | 450 | overlay->rgb_clut++; |
453 | } | 451 | } |
454 | if (!overlay->clip_rgb_clut) { | 452 | if (!overlay->clip_rgb_clut) { |
455 | clut = (clut_t*) overlay->clip_color; | 453 | clut = (clut_t*) overlay->clip_color; |
456 | for (i = 0; i < sizeof(overlay->color)/sizeof(overlay->color[0]); i++) { | 454 | for (i = 0; i < sizeof(overlay->color)/sizeof(overlay->color[0]); i++) { |
457 | *((uint32_t *)&clut[i]) = | 455 | *((uint32_t *)&clut[i]) = |
458 | frame->yuv2rgb->yuv2rgb_single_pixel_fun(frame->yuv2rgb, | 456 | frame->yuv2rgb->yuv2rgb_single_pixel_fun(frame->yuv2rgb, |
459 | clut[i].y, clut[i].cb, clut[i].cr); | 457 | clut[i].y, clut[i].cb, clut[i].cr); |
460 | } | 458 | } |
461 | overlay->clip_rgb_clut++; | 459 | overlay->clip_rgb_clut++; |
462 | } | 460 | } |
463 | } | 461 | } |
464 | 462 | ||
465 | static void null_overlay_blend (vo_driver_t *this_gen, vo_frame_t *frame_gen, vo_overlay_t *overlay) { | 463 | static void null_overlay_blend (vo_driver_t *this_gen, vo_frame_t *frame_gen, vo_overlay_t *overlay) { |
466 | null_driver_t *this = (null_driver_t *) this_gen; | 464 | null_driver_t *this = (null_driver_t *) this_gen; |
467 | opie_frame_t *frame = (opie_frame_t *) frame_gen; | 465 | opie_frame_t *frame = (opie_frame_t *) frame_gen; |
468 | 466 | ||
469 | printf("overlay blend\n"); | 467 | printf("overlay blend\n"); |
470 | if(!this->m_show_video || frame->output_width == 0 || frame->output_height== 0) | 468 | if(!this->m_show_video || frame->output_width == 0 || frame->output_height== 0) |
471 | return; | 469 | return; |
472 | 470 | ||
473 | /* Alpha Blend here */ | 471 | /* Alpha Blend here */ |
474 | if (overlay->rle) { | 472 | if (overlay->rle) { |
475 | if( !overlay->rgb_clut || !overlay->clip_rgb_clut) | 473 | if( !overlay->rgb_clut || !overlay->clip_rgb_clut) |
476 | null_overlay_clut_yuv2rgb(this,overlay,frame); | 474 | null_overlay_clut_yuv2rgb(this,overlay,frame); |
477 | 475 | ||
478 | switch(this->bpp) { | 476 | switch(this->bpp) { |
479 | case 16: | 477 | case 16: |
480 | blend_rgb16( (uint8_t *)frame->data, overlay, | 478 | blend_rgb16( (uint8_t *)frame->data, overlay, |
481 | frame->output_width, frame->output_height, | 479 | frame->output_width, frame->output_height, |
482 | frame->width, frame->height); | 480 | frame->width, frame->height); |
483 | break; | 481 | break; |
484 | case 24: | 482 | case 24: |
485 | blend_rgb24( (uint8_t *)frame->data, overlay, | 483 | blend_rgb24( (uint8_t *)frame->data, overlay, |
486 | frame->output_width, frame->output_height, | 484 | frame->output_width, frame->output_height, |
487 | frame->width, frame->height); | 485 | frame->width, frame->height); |
488 | break; | 486 | break; |
489 | case 32: | 487 | case 32: |
490 | blend_rgb32( (uint8_t *)frame->data, overlay, | 488 | blend_rgb32( (uint8_t *)frame->data, overlay, |
491 | frame->output_width, frame->output_height, | 489 | frame->output_width, frame->output_height, |
492 | frame->width, frame->height); | 490 | frame->width, frame->height); |
493 | break; | 491 | break; |
494 | default: | 492 | default: |
495 | /* It should never get here */ | 493 | /* It should never get here */ |
496 | break; | 494 | break; |
497 | } | 495 | } |
498 | } | 496 | } |
499 | } | 497 | } |
500 | 498 | ||
501 | 499 | ||
502 | static int null_get_property( vo_driver_t* self, | 500 | static int null_get_property( vo_driver_t* self, |
503 | int property ){ | 501 | int property ){ |
504 | printf("property get\n"); | 502 | printf("property get\n"); |
505 | return 0; | 503 | return 0; |
506 | } | 504 | } |
507 | static int null_set_property( vo_driver_t* self, | 505 | static int null_set_property( vo_driver_t* self, |
508 | int property, | 506 | int property, |
509 | int value ){ | 507 | int value ){ |
510 | printf("set property\n"); | 508 | printf("set property\n"); |
511 | return value; | 509 | return value; |
512 | } | 510 | } |
513 | static void null_get_property_min_max( vo_driver_t* self, | 511 | static void null_get_property_min_max( vo_driver_t* self, |
514 | int property, int *min, | 512 | int property, int *min, |
515 | int *max ){ | 513 | int *max ){ |
516 | printf("min max\n"); | 514 | printf("min max\n"); |
517 | *max = 0; | 515 | *max = 0; |
518 | *min = 0; | 516 | *min = 0; |
519 | } | 517 | } |
520 | static int null_gui_data_exchange( vo_driver_t* self, | 518 | static int null_gui_data_exchange( vo_driver_t* self, |
521 | int data_type, | 519 | int data_type, |
522 | void *data ){ | 520 | void *data ){ |
523 | return 0; | 521 | return 0; |
524 | } | 522 | } |
525 | static void null_exit( vo_driver_t* self ){ | 523 | static void null_exit( vo_driver_t* self ){ |
526 | null_driver_t* this = (null_driver_t*)self; | 524 | null_driver_t* this = (null_driver_t*)self; |
527 | free ( this ); | 525 | free ( this ); |
528 | } | 526 | } |
529 | static int null_redraw_needed( vo_driver_t* self ){ | 527 | static int null_redraw_needed( vo_driver_t* self ){ |
530 | return 0; | 528 | return 0; |
531 | } | 529 | } |
532 | 530 | ||
533 | 531 | ||
534 | vo_driver_t* init_video_out_plugin( config_values_t* conf, | 532 | vo_driver_t* init_video_out_plugin( config_values_t* conf, |
535 | void* video ){ | 533 | void* video ){ |
536 | null_driver_t *vo; | 534 | null_driver_t *vo; |
537 | vo = (null_driver_t*)malloc( sizeof(null_driver_t ) ); | 535 | vo = (null_driver_t*)malloc( sizeof(null_driver_t ) ); |
538 | 536 | ||
539 | /* memset? */ | 537 | /* memset? */ |
540 | memset(vo,0, sizeof(null_driver_t ) ); | 538 | memset(vo,0, sizeof(null_driver_t ) ); |
541 | vo->m_show_video = 0; // false | 539 | vo->m_show_video = 0; // false |
542 | vo->m_video_fullscreen = 0; | 540 | vo->m_video_fullscreen = 0; |
543 | vo->m_is_scaling = 0; | 541 | vo->m_is_scaling = 0; |
544 | vo->user_ratio = ASPECT_AUTO; | 542 | vo->user_ratio = ASPECT_AUTO; |
545 | vo->display_ratio = 1.0; | 543 | vo->display_ratio = 1.0; |
546 | vo->gui_width = 16; | 544 | vo->gui_width = 16; |
547 | vo->gui_height = 8; | 545 | vo->gui_height = 8; |
548 | vo->frameDis = NULL; | 546 | vo->frameDis = NULL; |
549 | 547 | ||
550 | /* install callback handlers*/ | 548 | /* install callback handlers*/ |
551 | vo->vo_driver.get_capabilities = null_get_capabilities; | 549 | vo->vo_driver.get_capabilities = null_get_capabilities; |
552 | vo->vo_driver.alloc_frame = null_alloc_frame; | 550 | vo->vo_driver.alloc_frame = null_alloc_frame; |
553 | vo->vo_driver.update_frame_format = null_update_frame_format; | 551 | vo->vo_driver.update_frame_format = null_update_frame_format; |
554 | vo->vo_driver.display_frame = null_display_frame; | 552 | vo->vo_driver.display_frame = null_display_frame; |
555 | vo->vo_driver.overlay_blend = null_overlay_blend; | 553 | vo->vo_driver.overlay_blend = null_overlay_blend; |
556 | vo->vo_driver.get_property = null_get_property; | 554 | vo->vo_driver.get_property = null_get_property; |
557 | vo->vo_driver.set_property = null_set_property; | 555 | vo->vo_driver.set_property = null_set_property; |
558 | vo->vo_driver.get_property_min_max = null_get_property_min_max; | 556 | vo->vo_driver.get_property_min_max = null_get_property_min_max; |
559 | vo->vo_driver.gui_data_exchange = null_gui_data_exchange; | 557 | vo->vo_driver.gui_data_exchange = null_gui_data_exchange; |
560 | vo->vo_driver.exit = null_exit; | 558 | vo->vo_driver.exit = null_exit; |
561 | vo->vo_driver.redraw_needed = null_redraw_needed; | 559 | vo->vo_driver.redraw_needed = null_redraw_needed; |
562 | 560 | ||
563 | 561 | ||
564 | /* capabilities */ | 562 | /* capabilities */ |
565 | vo->m_capabilities = VO_CAP_COPIES_IMAGE | VO_CAP_YUY2 | VO_CAP_YV12; | 563 | vo->m_capabilities = VO_CAP_COPIES_IMAGE | VO_CAP_YUY2 | VO_CAP_YV12; |
566 | vo->yuv2rgb_factory = yuv2rgb_factory_init (MODE_16_RGB, vo->yuv2rgb_swap, | 564 | vo->yuv2rgb_factory = yuv2rgb_factory_init (MODE_16_RGB, vo->yuv2rgb_swap, |
567 | vo->yuv2rgb_cmap); | 565 | vo->yuv2rgb_cmap); |
568 | printf("done initialisation\n"); | 566 | printf("done initialisation\n"); |
569 | return (vo_driver_t*) vo; | 567 | return (vo_driver_t*) vo; |
570 | } | 568 | } |
571 | 569 | ||
572 | static vo_info_t vo_info_null = { | 570 | static vo_info_t vo_info_null = { |
573 | 5, | 571 | 5, |
574 | "null plugin", | 572 | "null plugin", |
575 | NULL, | 573 | NULL, |
576 | VISUAL_TYPE_FB, | 574 | VISUAL_TYPE_FB, |
577 | 5 | 575 | 5 |
578 | }; | 576 | }; |
579 | 577 | ||
580 | vo_info_t *get_video_out_plugin_info(){ | 578 | vo_info_t *get_video_out_plugin_info(){ |
581 | vo_info_null.description = _("xine video output plugin using null device"); | 579 | vo_info_null.description = _("xine video output plugin using null device"); |
582 | return &vo_info_null; | 580 | return &vo_info_null; |
583 | } | 581 | } |
584 | 582 | ||
585 | /* this is special for this device */ | 583 | /* this is special for this device */ |
586 | /** | 584 | /** |
587 | * We know that we will be controled by the XINE LIB++ | 585 | * We know that we will be controled by the XINE LIB++ |
588 | */ | 586 | */ |
589 | 587 | ||
590 | /** | 588 | /** |
591 | * | 589 | * |
592 | */ | 590 | */ |
593 | int null_is_showing_video( vo_driver_t* self ){ | 591 | int null_is_showing_video( vo_driver_t* self ){ |
594 | null_driver_t* this = (null_driver_t*)self; | 592 | null_driver_t* this = (null_driver_t*)self; |
595 | return this->m_show_video; | 593 | return this->m_show_video; |
596 | } | 594 | } |
597 | void null_set_show_video( vo_driver_t* self, int show ) { | 595 | void null_set_show_video( vo_driver_t* self, int show ) { |
598 | ((null_driver_t*)self)->m_show_video = show; | 596 | ((null_driver_t*)self)->m_show_video = show; |
599 | } | 597 | } |
600 | 598 | ||
601 | int null_is_fullscreen( vo_driver_t* self ){ | 599 | int null_is_fullscreen( vo_driver_t* self ){ |
602 | return ((null_driver_t*)self)->m_video_fullscreen; | 600 | return ((null_driver_t*)self)->m_video_fullscreen; |
603 | } | 601 | } |
604 | void null_set_fullscreen( vo_driver_t* self, int screen ){ | 602 | void null_set_fullscreen( vo_driver_t* self, int screen ){ |
605 | ((null_driver_t*)self)->m_video_fullscreen = screen; | 603 | ((null_driver_t*)self)->m_video_fullscreen = screen; |
606 | } | 604 | } |
607 | int null_is_scaling( vo_driver_t* self ){ | 605 | int null_is_scaling( vo_driver_t* self ){ |
608 | return ((null_driver_t*)self)->m_is_scaling; | 606 | return ((null_driver_t*)self)->m_is_scaling; |
609 | } | 607 | } |
610 | void null_set_scaling( vo_driver_t* self, int scale ){ | 608 | void null_set_scaling( vo_driver_t* self, int scale ){ |
611 | ((null_driver_t*)self)->m_is_scaling = scale; | 609 | ((null_driver_t*)self)->m_is_scaling = scale; |
612 | } | 610 | } |
613 | 611 | ||
614 | void null_set_gui_width( vo_driver_t* self, int width ){ | 612 | void null_set_gui_width( vo_driver_t* self, int width ){ |
615 | ((null_driver_t*)self)->gui_width = width; | 613 | ((null_driver_t*)self)->gui_width = width; |
616 | } | 614 | } |
617 | void null_set_gui_height( vo_driver_t* self, int height ){ | 615 | void null_set_gui_height( vo_driver_t* self, int height ){ |
618 | ((null_driver_t*)self)->gui_height = height; | 616 | ((null_driver_t*)self)->gui_height = height; |
619 | } | 617 | } |
620 | void null_set_mode( vo_driver_t* self, int depth, int rgb ){ | 618 | void null_set_mode( vo_driver_t* self, int depth, int rgb ){ |
621 | null_driver_t* this = (null_driver_t*)self; | 619 | null_driver_t* this = (null_driver_t*)self; |
622 | 620 | ||
623 | this->bytes_per_pixel = (depth + 7 ) / 8; | 621 | this->bytes_per_pixel = (depth + 7 ) / 8; |
624 | this->bpp = this->bytes_per_pixel * 8; | 622 | this->bpp = this->bytes_per_pixel * 8; |
625 | this->depth = depth; | 623 | this->depth = depth; |
626 | printf("depth %d %d\n", depth, this->bpp); | 624 | printf("depth %d %d\n", depth, this->bpp); |
627 | printf("pixeltype %d\n", rgb ); | 625 | printf("pixeltype %d\n", rgb ); |
628 | switch ( this->depth ){ | 626 | switch ( this->depth ){ |
629 | case 32: | 627 | case 32: |
630 | if( rgb == 0 ) | 628 | if( rgb == 0 ) |
631 | this->yuv2rgb_mode = MODE_32_RGB; | 629 | this->yuv2rgb_mode = MODE_32_RGB; |
632 | else | 630 | else |
633 | this->yuv2rgb_mode = MODE_32_BGR; | 631 | this->yuv2rgb_mode = MODE_32_BGR; |
634 | case 24: | 632 | case 24: |
635 | if( this->bpp == 32 ) { | 633 | if( this->bpp == 32 ) { |
636 | if(rgb == 0 ) | 634 | if(rgb == 0 ) |
637 | this->yuv2rgb_mode = MODE_32_RGB; | 635 | this->yuv2rgb_mode = MODE_32_RGB; |
638 | else | 636 | else |
639 | this->yuv2rgb_mode = MODE_32_BGR; | 637 | this->yuv2rgb_mode = MODE_32_BGR; |
640 | }else{ | 638 | }else{ |
641 | if( rgb == 0 ) | 639 | if( rgb == 0 ) |
642 | this->yuv2rgb_mode = MODE_24_RGB; | 640 | this->yuv2rgb_mode = MODE_24_RGB; |
643 | else | 641 | else |
644 | this->yuv2rgb_mode = MODE_24_BGR; | 642 | this->yuv2rgb_mode = MODE_24_BGR; |
645 | }; | 643 | }; |
646 | break; | 644 | break; |
647 | case 16: | 645 | case 16: |
648 | if( rgb == 0 ) | 646 | if( rgb == 0 ) |
649 | this->yuv2rgb_mode = MODE_16_RGB; | 647 | this->yuv2rgb_mode = MODE_16_RGB; |
650 | else | 648 | else |
651 | this->yuv2rgb_mode = MODE_16_BGR; | 649 | this->yuv2rgb_mode = MODE_16_BGR; |
652 | break; | 650 | break; |
653 | case 15: | 651 | case 15: |
654 | if( rgb == 0 ) | 652 | if( rgb == 0 ) |
655 | this->yuv2rgb_mode = MODE_15_RGB; | 653 | this->yuv2rgb_mode = MODE_15_RGB; |
656 | else | 654 | else |
657 | this->yuv2rgb_mode = MODE_15_BGR; | 655 | this->yuv2rgb_mode = MODE_15_BGR; |
658 | break; | 656 | break; |
659 | case 8: | 657 | case 8: |
660 | if( rgb == 0 ) | 658 | if( rgb == 0 ) |
661 | this->yuv2rgb_mode = MODE_8_RGB; | 659 | this->yuv2rgb_mode = MODE_8_RGB; |
662 | else | 660 | else |
663 | this->yuv2rgb_mode = MODE_8_BGR; | 661 | this->yuv2rgb_mode = MODE_8_BGR; |
664 | break; | 662 | break; |
665 | }; | 663 | }; |
666 | //free(this->yuv2rgb_factory ); | 664 | //free(this->yuv2rgb_factory ); |
667 | // this->yuv2rgb_factory = yuv2rgb_factory_init (this->yuv2rgb_mode, this->yuv2rgb_swap, | 665 | // this->yuv2rgb_factory = yuv2rgb_factory_init (this->yuv2rgb_mode, this->yuv2rgb_swap, |
668 | // this->yuv2rgb_cmap); | 666 | // this->yuv2rgb_cmap); |
669 | }; | 667 | }; |
670 | void null_display_handler(vo_driver_t* self, display_xine_frame_t t, void* user_data) { | 668 | void null_display_handler(vo_driver_t* self, display_xine_frame_t t, void* user_data) { |
671 | null_driver_t* this = (null_driver_t*) self; | 669 | null_driver_t* this = (null_driver_t*) self; |
672 | this->caller = user_data; | 670 | this->caller = user_data; |
673 | this->frameDis = t; | 671 | this->frameDis = t; |
674 | } | 672 | } |
diff --git a/noncore/multimedia/opieplayer2/opieplayer2.pro b/noncore/multimedia/opieplayer2/opieplayer2.pro index d8cacd0..fee9242 100644 --- a/noncore/multimedia/opieplayer2/opieplayer2.pro +++ b/noncore/multimedia/opieplayer2/opieplayer2.pro | |||
@@ -1,23 +1,23 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | CONFIG = qt warn_on release | 2 | CONFIG = qt warn_on release |
3 | #release | 3 | #release |
4 | DESTDIR = $(OPIEDIR)/bin | 4 | DESTDIR = $(OPIEDIR)/bin |
5 | HEADERS = playlistselection.h mediaplayerstate.h xinecontrol.h mediadetect.h\ | 5 | HEADERS = playlistselection.h mediaplayerstate.h xinecontrol.h mediadetect.h\ |
6 | videowidget.h audiowidget.h playlistwidget.h mediaplayer.h inputDialog.h \ | 6 | videowidget.h audiowidget.h playlistwidget.h mediaplayer.h inputDialog.h \ |
7 | frame.h lib.h xinevideowidget.h \ | 7 | frame.h lib.h xinevideowidget.h \ |
8 | alphablend.h yuv2rgb.h | 8 | alphablend.h yuv2rgb.h |
9 | SOURCES = main.cpp \ | 9 | SOURCES = main.cpp \ |
10 | playlistselection.cpp mediaplayerstate.cpp xinecontrol.cpp mediadetect.cpp\ | 10 | playlistselection.cpp mediaplayerstate.cpp xinecontrol.cpp mediadetect.cpp\ |
11 | videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp inputDialog.cpp \ | 11 | videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp inputDialog.cpp \ |
12 | frame.cpp lib.cpp nullvideo.c xinevideowidget.cpp \ | 12 | frame.cpp lib.cpp nullvideo.c xinevideowidget.cpp \ |
13 | alphablend.c yuv2rgb.c yuv2rgb_mlib.c yuv2rgb_mmx.c | 13 | alphablend.c yuv2rgb.c yuv2rgb_arm.c yuv2rgb_arm4l.S |
14 | TARGET = opieplayer2 | 14 | TARGET = opieplayer2 |
15 | INCLUDEPATH += $(OPIEDIR)/include | 15 | INCLUDEPATH += $(OPIEDIR)/include |
16 | DEPENDPATH += $(OPIEDIR)/include | 16 | DEPENDPATH += $(OPIEDIR)/include |
17 | LIBS += -lqpe -lpthread -lopie -lxine -lxineutils | 17 | LIBS += -lqpe -lpthread -lopie -lxine -lxineutils |
18 | MOC_DIR=qpeobj | 18 | MOC_DIR=qpeobj |
19 | OBJECTS_DIR=qpeobj | 19 | OBJECTS_DIR=qpeobj |
20 | 20 | ||
21 | INCLUDEPATH += $(OPIEDIR)/include | 21 | INCLUDEPATH += $(OPIEDIR)/include |
22 | DEPENDPATH += $(OPIEDIR)/include | 22 | DEPENDPATH += $(OPIEDIR)/include |
23 | 23 | ||
diff --git a/noncore/multimedia/opieplayer2/yuv2rgb.c b/noncore/multimedia/opieplayer2/yuv2rgb.c index d1d6627..22bb4cb 100644 --- a/noncore/multimedia/opieplayer2/yuv2rgb.c +++ b/noncore/multimedia/opieplayer2/yuv2rgb.c | |||
@@ -1092,2069 +1092,2077 @@ static void scale_line_5_8 (uint8_t *source, uint8_t *dest, | |||
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; |
1103 | done: | 1103 | done: |
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 | */ |
1113 | static void scale_line_3_4 (uint8_t *source, uint8_t *dest, | 1113 | static 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; |
1139 | done: | 1139 | done: |
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 | ||
1147 | static void scale_line_1_2 (uint8_t *source, uint8_t *dest, | 1147 | static 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 | */ |
1179 | static void scale_line_1_1 (uint8_t *source, uint8_t *dest, | 1179 | static 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 | ||
1188 | static scale_line_func_t find_scale_line_func(int step) { | 1188 | static 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 | ||
1220 | static void scale_line_2 (uint8_t *source, uint8_t *dest, | 1220 | static 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 | ||
1247 | static void scale_line_4 (uint8_t *source, uint8_t *dest, | 1247 | static 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 | ||
1330 | static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, | 1330 | static 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 */ |
1460 | static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, | 1460 | static 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 */ |
1591 | static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, | 1591 | static 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 */ |
1723 | static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, | 1723 | static 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 */ |
1853 | static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, | 1853 | static 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 */ |
1983 | static void yuv2rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, | 1983 | static 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 */ |
2028 | static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, | 2028 | static 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 | ||
2156 | static int div_round (int dividend, int divisor) | 2156 | static 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 | ||
2164 | static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped) | 2164 | static 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 | ||
2338 | static uint32_t yuv2rgb_single_pixel_32 (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v) | 2338 | static 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 | ||
2349 | static uint32_t yuv2rgb_single_pixel_24_rgb (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v) | 2349 | static 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 | ||
2362 | static uint32_t yuv2rgb_single_pixel_24_bgr (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v) | 2362 | static 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 | ||
2375 | static uint32_t yuv2rgb_single_pixel_16 (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v) | 2375 | static 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 | ||
2386 | static uint32_t yuv2rgb_single_pixel_8 (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v) | 2386 | static 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 | ||
2397 | static uint32_t yuv2rgb_single_pixel_gray (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v) | 2397 | static 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 | ||
2402 | static uint32_t yuv2rgb_single_pixel_palette (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v) | 2402 | static 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 | ||
2414 | static void yuv2rgb_c_init (yuv2rgb_factory_t *this) | 2414 | static 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 | ||
2457 | static void yuv2rgb_single_pixel_init (yuv2rgb_factory_t *this) { | 2457 | static 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 | ||
2504 | static void yuy22rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | 2504 | static 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 | ||
2583 | static void yuy22rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | 2583 | static 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 | ||
2661 | static void yuy22rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | 2661 | static 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 | ||
2735 | static void yuy22rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | 2735 | static 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, |
2751 | this->dest_width, this->step_dx); | 2751 | this->dest_width, this->step_dx); |
2752 | 2752 | ||
2753 | dy = 0; | 2753 | dy = 0; |
2754 | height = this->dest_height; | 2754 | height = this->dest_height; |
2755 | 2755 | ||
2756 | for (;;) { | 2756 | for (;;) { |
2757 | dst_1 = (uint16_t*)_dst; | 2757 | dst_1 = (uint16_t*)_dst; |
2758 | py_1 = this->y_buffer; | 2758 | py_1 = this->y_buffer; |
2759 | pu = this->u_buffer; | 2759 | pu = this->u_buffer; |
2760 | pv = this->v_buffer; | 2760 | pv = this->v_buffer; |
2761 | 2761 | ||
2762 | width = this->dest_width >> 3; | 2762 | width = this->dest_width >> 3; |
2763 | 2763 | ||
2764 | do { | 2764 | do { |
2765 | RGB(0); | 2765 | RGB(0); |
2766 | DST1(0); | 2766 | DST1(0); |
2767 | 2767 | ||
2768 | RGB(1); | 2768 | RGB(1); |
2769 | DST1(1); | 2769 | DST1(1); |
2770 | 2770 | ||
2771 | RGB(2); | 2771 | RGB(2); |
2772 | DST1(2); | 2772 | DST1(2); |
2773 | 2773 | ||
2774 | RGB(3); | 2774 | RGB(3); |
2775 | DST1(3); | 2775 | DST1(3); |
2776 | 2776 | ||
2777 | pu += 4; | 2777 | pu += 4; |
2778 | pv += 4; | 2778 | pv += 4; |
2779 | py_1 += 8; | 2779 | py_1 += 8; |
2780 | dst_1 += 8; | 2780 | dst_1 += 8; |
2781 | } while (--width); | 2781 | } while (--width); |
2782 | 2782 | ||
2783 | dy += this->step_dy; | 2783 | dy += this->step_dy; |
2784 | _dst += this->rgb_stride; | 2784 | _dst += this->rgb_stride; |
2785 | 2785 | ||
2786 | while (--height > 0 && dy < 32768) { | 2786 | while (--height > 0 && dy < 32768) { |
2787 | 2787 | ||
2788 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*2); | 2788 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*2); |
2789 | 2789 | ||
2790 | dy += this->step_dy; | 2790 | dy += this->step_dy; |
2791 | _dst += this->rgb_stride; | 2791 | _dst += this->rgb_stride; |
2792 | } | 2792 | } |
2793 | 2793 | ||
2794 | if (height <= 0) | 2794 | if (height <= 0) |
2795 | break; | 2795 | break; |
2796 | 2796 | ||
2797 | _p += this->y_stride*2*(dy>>15); | 2797 | _p += this->y_stride*2*(dy>>15); |
2798 | dy &= 32767; | 2798 | dy &= 32767; |
2799 | 2799 | ||
2800 | scale_line_4 (_p+1, this->u_buffer, | 2800 | scale_line_4 (_p+1, this->u_buffer, |
2801 | this->dest_width >> 1, this->step_dx); | 2801 | this->dest_width >> 1, this->step_dx); |
2802 | scale_line_4 (_p+3, this->v_buffer, | 2802 | scale_line_4 (_p+3, this->v_buffer, |
2803 | this->dest_width >> 1, this->step_dx); | 2803 | this->dest_width >> 1, this->step_dx); |
2804 | scale_line_2 (_p, this->y_buffer, | 2804 | scale_line_2 (_p, this->y_buffer, |
2805 | this->dest_width, this->step_dx); | 2805 | this->dest_width, this->step_dx); |
2806 | } | 2806 | } |
2807 | } | 2807 | } |
2808 | 2808 | ||
2809 | static void yuy22rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | 2809 | static void yuy22rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) |
2810 | { | 2810 | { |
2811 | int U, V, Y; | 2811 | int U, V, Y; |
2812 | uint8_t * py_1, * pu, * pv; | 2812 | uint8_t * py_1, * pu, * pv; |
2813 | uint8_t * r, * g, * b; | 2813 | uint8_t * r, * g, * b; |
2814 | uint8_t * dst_1; | 2814 | uint8_t * dst_1; |
2815 | int width, height; | 2815 | int width, height; |
2816 | int dy; | 2816 | int dy; |
2817 | 2817 | ||
2818 | /* FIXME: implement unscaled version */ | 2818 | /* FIXME: implement unscaled version */ |
2819 | 2819 | ||
2820 | scale_line_4 (_p+1, this->u_buffer, | 2820 | scale_line_4 (_p+1, this->u_buffer, |
2821 | this->dest_width >> 1, this->step_dx); | 2821 | this->dest_width >> 1, this->step_dx); |
2822 | scale_line_4 (_p+3, this->v_buffer, | 2822 | scale_line_4 (_p+3, this->v_buffer, |
2823 | this->dest_width >> 1, this->step_dx); | 2823 | this->dest_width >> 1, this->step_dx); |
2824 | scale_line_2 (_p, this->y_buffer, | 2824 | scale_line_2 (_p, this->y_buffer, |
2825 | this->dest_width, this->step_dx); | 2825 | this->dest_width, this->step_dx); |
2826 | 2826 | ||
2827 | dy = 0; | 2827 | dy = 0; |
2828 | height = this->dest_height; | 2828 | height = this->dest_height; |
2829 | 2829 | ||
2830 | for (;;) { | 2830 | for (;;) { |
2831 | dst_1 = _dst; | 2831 | dst_1 = _dst; |
2832 | py_1 = this->y_buffer; | 2832 | py_1 = this->y_buffer; |
2833 | pu = this->u_buffer; | 2833 | pu = this->u_buffer; |
2834 | pv = this->v_buffer; | 2834 | pv = this->v_buffer; |
2835 | 2835 | ||
2836 | width = this->dest_width >> 3; | 2836 | width = this->dest_width >> 3; |
2837 | 2837 | ||
2838 | do { | 2838 | do { |
2839 | RGB(0); | 2839 | RGB(0); |
2840 | DST1(0); | 2840 | DST1(0); |
2841 | 2841 | ||
2842 | RGB(1); | 2842 | RGB(1); |
2843 | DST1(1); | 2843 | DST1(1); |
2844 | 2844 | ||
2845 | RGB(2); | 2845 | RGB(2); |
2846 | DST1(2); | 2846 | DST1(2); |
2847 | 2847 | ||
2848 | RGB(3); | 2848 | RGB(3); |
2849 | DST1(3); | 2849 | DST1(3); |
2850 | 2850 | ||
2851 | pu += 4; | 2851 | pu += 4; |
2852 | pv += 4; | 2852 | pv += 4; |
2853 | py_1 += 8; | 2853 | py_1 += 8; |
2854 | dst_1 += 8; | 2854 | dst_1 += 8; |
2855 | } while (--width); | 2855 | } while (--width); |
2856 | 2856 | ||
2857 | dy += this->step_dy; | 2857 | dy += this->step_dy; |
2858 | _dst += this->rgb_stride; | 2858 | _dst += this->rgb_stride; |
2859 | 2859 | ||
2860 | while (--height > 0 && dy < 32768) { | 2860 | while (--height > 0 && dy < 32768) { |
2861 | 2861 | ||
2862 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width); | 2862 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width); |
2863 | 2863 | ||
2864 | dy += this->step_dy; | 2864 | dy += this->step_dy; |
2865 | _dst += this->rgb_stride; | 2865 | _dst += this->rgb_stride; |
2866 | } | 2866 | } |
2867 | 2867 | ||
2868 | if (height <= 0) | 2868 | if (height <= 0) |
2869 | break; | 2869 | break; |
2870 | 2870 | ||
2871 | _p += this->y_stride*2*(dy>>15); | 2871 | _p += this->y_stride*2*(dy>>15); |
2872 | dy &= 32767; | 2872 | dy &= 32767; |
2873 | 2873 | ||
2874 | scale_line_4 (_p+1, this->u_buffer, | 2874 | scale_line_4 (_p+1, this->u_buffer, |
2875 | this->dest_width >> 1, this->step_dx); | 2875 | this->dest_width >> 1, this->step_dx); |
2876 | scale_line_4 (_p+3, this->v_buffer, | 2876 | scale_line_4 (_p+3, this->v_buffer, |
2877 | this->dest_width >> 1, this->step_dx); | 2877 | this->dest_width >> 1, this->step_dx); |
2878 | scale_line_2 (_p, this->y_buffer, | 2878 | scale_line_2 (_p, this->y_buffer, |
2879 | this->dest_width, this->step_dx); | 2879 | this->dest_width, this->step_dx); |
2880 | } | 2880 | } |
2881 | } | 2881 | } |
2882 | 2882 | ||
2883 | static void yuy22rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | 2883 | static void yuy22rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) |
2884 | { | 2884 | { |
2885 | int width, height; | 2885 | int width, height; |
2886 | int dy; | 2886 | int dy; |
2887 | uint8_t * dst; | 2887 | uint8_t * dst; |
2888 | uint8_t * y; | 2888 | uint8_t * y; |
2889 | 2889 | ||
2890 | if (this->do_scale) { | 2890 | if (this->do_scale) { |
2891 | dy = 0; | 2891 | dy = 0; |
2892 | height = this->dest_height; | 2892 | height = this->dest_height; |
2893 | 2893 | ||
2894 | for (;;) { | 2894 | for (;;) { |
2895 | scale_line_2 (_p, _dst, this->dest_width, this->step_dx); | 2895 | scale_line_2 (_p, _dst, this->dest_width, this->step_dx); |
2896 | 2896 | ||
2897 | dy += this->step_dy; | 2897 | dy += this->step_dy; |
2898 | _dst += this->rgb_stride; | 2898 | _dst += this->rgb_stride; |
2899 | 2899 | ||
2900 | while (--height > 0 && dy < 32768) { | 2900 | while (--height > 0 && dy < 32768) { |
2901 | 2901 | ||
2902 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width); | 2902 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width); |
2903 | 2903 | ||
2904 | dy += this->step_dy; | 2904 | dy += this->step_dy; |
2905 | _dst += this->rgb_stride; | 2905 | _dst += this->rgb_stride; |
2906 | } | 2906 | } |
2907 | 2907 | ||
2908 | if (height <= 0) | 2908 | if (height <= 0) |
2909 | break; | 2909 | break; |
2910 | 2910 | ||
2911 | _p += this->y_stride*2*(dy>>15); | 2911 | _p += this->y_stride*2*(dy>>15); |
2912 | dy &= 32767; | 2912 | dy &= 32767; |
2913 | } | 2913 | } |
2914 | } else { | 2914 | } else { |
2915 | for (height = this->source_height; --height >= 0; ) { | 2915 | for (height = this->source_height; --height >= 0; ) { |
2916 | dst = _dst; | 2916 | dst = _dst; |
2917 | y = _p; | 2917 | y = _p; |
2918 | for (width = this->source_width; --width >= 0; ) { | 2918 | for (width = this->source_width; --width >= 0; ) { |
2919 | *dst++ = *y; | 2919 | *dst++ = *y; |
2920 | y += 2; | 2920 | y += 2; |
2921 | } | 2921 | } |
2922 | _dst += this->rgb_stride; | 2922 | _dst += this->rgb_stride; |
2923 | _p += this->y_stride*2; | 2923 | _p += this->y_stride*2; |
2924 | } | 2924 | } |
2925 | } | 2925 | } |
2926 | } | 2926 | } |
2927 | 2927 | ||
2928 | static void yuy22rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | 2928 | static void yuy22rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) |
2929 | { | 2929 | { |
2930 | int U, V, Y; | 2930 | int U, V, Y; |
2931 | uint8_t * py_1, * pu, * pv; | 2931 | uint8_t * py_1, * pu, * pv; |
2932 | uint16_t * r, * g, * b; | 2932 | uint16_t * r, * g, * b; |
2933 | uint8_t * dst_1; | 2933 | uint8_t * dst_1; |
2934 | int width, height; | 2934 | int width, height; |
2935 | int dy; | 2935 | int dy; |
2936 | 2936 | ||
2937 | scale_line_4 (_p+1, this->u_buffer, | 2937 | scale_line_4 (_p+1, this->u_buffer, |
2938 | this->dest_width >> 1, this->step_dx); | 2938 | this->dest_width >> 1, this->step_dx); |
2939 | scale_line_4 (_p+3, this->v_buffer, | 2939 | scale_line_4 (_p+3, this->v_buffer, |
2940 | this->dest_width >> 1, this->step_dx); | 2940 | this->dest_width >> 1, this->step_dx); |
2941 | scale_line_2 (_p, this->y_buffer, | 2941 | scale_line_2 (_p, this->y_buffer, |
2942 | this->dest_width, this->step_dx); | 2942 | this->dest_width, this->step_dx); |
2943 | 2943 | ||
2944 | dy = 0; | 2944 | dy = 0; |
2945 | height = this->dest_height; | 2945 | height = this->dest_height; |
2946 | 2946 | ||
2947 | for (;;) { | 2947 | for (;;) { |
2948 | dst_1 = _dst; | 2948 | dst_1 = _dst; |
2949 | py_1 = this->y_buffer; | 2949 | py_1 = this->y_buffer; |
2950 | pu = this->u_buffer; | 2950 | pu = this->u_buffer; |
2951 | pv = this->v_buffer; | 2951 | pv = this->v_buffer; |
2952 | 2952 | ||
2953 | width = this->dest_width >> 3; | 2953 | width = this->dest_width >> 3; |
2954 | 2954 | ||
2955 | do { | 2955 | do { |
2956 | RGB(0); | 2956 | RGB(0); |
2957 | DST1CMAP(0); | 2957 | DST1CMAP(0); |
2958 | 2958 | ||
2959 | RGB(1); | 2959 | RGB(1); |
2960 | DST1CMAP(1); | 2960 | DST1CMAP(1); |
2961 | 2961 | ||
2962 | RGB(2); | 2962 | RGB(2); |
2963 | DST1CMAP(2); | 2963 | DST1CMAP(2); |
2964 | 2964 | ||
2965 | RGB(3); | 2965 | RGB(3); |
2966 | DST1CMAP(3); | 2966 | DST1CMAP(3); |
2967 | 2967 | ||
2968 | pu += 4; | 2968 | pu += 4; |
2969 | pv += 4; | 2969 | pv += 4; |
2970 | py_1 += 8; | 2970 | py_1 += 8; |
2971 | dst_1 += 8; | 2971 | dst_1 += 8; |
2972 | } while (--width); | 2972 | } while (--width); |
2973 | 2973 | ||
2974 | dy += this->step_dy; | 2974 | dy += this->step_dy; |
2975 | _dst += this->rgb_stride; | 2975 | _dst += this->rgb_stride; |
2976 | 2976 | ||
2977 | while (--height > 0 && dy < 32768) { | 2977 | while (--height > 0 && dy < 32768) { |
2978 | 2978 | ||
2979 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width); | 2979 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width); |
2980 | 2980 | ||
2981 | dy += this->step_dy; | 2981 | dy += this->step_dy; |
2982 | _dst += this->rgb_stride; | 2982 | _dst += this->rgb_stride; |
2983 | } | 2983 | } |
2984 | 2984 | ||
2985 | if (height <= 0) | 2985 | if (height <= 0) |
2986 | break; | 2986 | break; |
2987 | 2987 | ||
2988 | _p += this->y_stride*2*(dy>>15); | 2988 | _p += this->y_stride*2*(dy>>15); |
2989 | dy &= 32767; | 2989 | dy &= 32767; |
2990 | 2990 | ||
2991 | scale_line_4 (_p+1, this->u_buffer, | 2991 | scale_line_4 (_p+1, this->u_buffer, |
2992 | this->dest_width >> 1, this->step_dx); | 2992 | this->dest_width >> 1, this->step_dx); |
2993 | scale_line_4 (_p+3, this->v_buffer, | 2993 | scale_line_4 (_p+3, this->v_buffer, |
2994 | this->dest_width >> 1, this->step_dx); | 2994 | this->dest_width >> 1, this->step_dx); |
2995 | scale_line_2 (_p, this->y_buffer, | 2995 | scale_line_2 (_p, this->y_buffer, |
2996 | this->dest_width, this->step_dx); | 2996 | this->dest_width, this->step_dx); |
2997 | } | 2997 | } |
2998 | } | 2998 | } |
2999 | 2999 | ||
3000 | static void yuy22rgb_c_init (yuv2rgb_factory_t *this) | 3000 | static void yuy22rgb_c_init (yuv2rgb_factory_t *this) |
3001 | { | 3001 | { |
3002 | switch (this->mode) { | 3002 | switch (this->mode) { |
3003 | case MODE_32_RGB: | 3003 | case MODE_32_RGB: |
3004 | case MODE_32_BGR: | 3004 | case MODE_32_BGR: |
3005 | this->yuy22rgb_fun = yuy22rgb_c_32; | 3005 | this->yuy22rgb_fun = yuy22rgb_c_32; |
3006 | break; | 3006 | break; |
3007 | 3007 | ||
3008 | case MODE_24_RGB: | 3008 | case MODE_24_RGB: |
3009 | case MODE_24_BGR: | 3009 | case MODE_24_BGR: |
3010 | this->yuy22rgb_fun = | 3010 | this->yuy22rgb_fun = |
3011 | (this->mode==MODE_24_RGB && !this->swapped) || (this->mode==MODE_24_BGR && this->swapped) | 3011 | (this->mode==MODE_24_RGB && !this->swapped) || (this->mode==MODE_24_BGR && this->swapped) |
3012 | ? yuy22rgb_c_24_rgb | 3012 | ? yuy22rgb_c_24_rgb |
3013 | : yuy22rgb_c_24_bgr; | 3013 | : yuy22rgb_c_24_bgr; |
3014 | break; | 3014 | break; |
3015 | case MODE_15_BGR: | 3015 | case MODE_15_BGR: |
3016 | case MODE_16_BGR: | 3016 | case MODE_16_BGR: |
3017 | case MODE_15_RGB: | 3017 | case MODE_15_RGB: |
3018 | case MODE_16_RGB: | 3018 | case MODE_16_RGB: |
3019 | this->yuy22rgb_fun = yuy22rgb_c_16; | 3019 | this->yuy22rgb_fun = yuy22rgb_c_16; |
3020 | break; | 3020 | break; |
3021 | 3021 | ||
3022 | case MODE_8_RGB: | 3022 | case MODE_8_RGB: |
3023 | case MODE_8_BGR: | 3023 | case MODE_8_BGR: |
3024 | this->yuy22rgb_fun = yuy22rgb_c_8; | 3024 | this->yuy22rgb_fun = yuy22rgb_c_8; |
3025 | break; | 3025 | break; |
3026 | 3026 | ||
3027 | case MODE_8_GRAY: | 3027 | case MODE_8_GRAY: |
3028 | this->yuy22rgb_fun = yuy22rgb_c_gray; | 3028 | this->yuy22rgb_fun = yuy22rgb_c_gray; |
3029 | break; | 3029 | break; |
3030 | 3030 | ||
3031 | case MODE_PALETTE: | 3031 | case MODE_PALETTE: |
3032 | this->yuy22rgb_fun = yuy22rgb_c_palette; | 3032 | this->yuy22rgb_fun = yuy22rgb_c_palette; |
3033 | break; | 3033 | break; |
3034 | 3034 | ||
3035 | default: | 3035 | default: |
3036 | printf ("yuv2rgb: mode %d not supported for yuy2\n", this->mode); | 3036 | printf ("yuv2rgb: mode %d not supported for yuy2\n", this->mode); |
3037 | } | 3037 | } |
3038 | } | 3038 | } |
3039 | 3039 | ||
3040 | yuv2rgb_t *yuv2rgb_create_converter (yuv2rgb_factory_t *factory) { | 3040 | yuv2rgb_t *yuv2rgb_create_converter (yuv2rgb_factory_t *factory) { |
3041 | 3041 | ||
3042 | yuv2rgb_t *this = xine_xmalloc (sizeof (yuv2rgb_t)); | 3042 | yuv2rgb_t *this = xine_xmalloc (sizeof (yuv2rgb_t)); |
3043 | 3043 | ||
3044 | this->cmap = factory->cmap; | 3044 | this->cmap = factory->cmap; |
3045 | 3045 | ||
3046 | this->y_chunk = this->y_buffer = NULL; | 3046 | this->y_chunk = this->y_buffer = NULL; |
3047 | this->u_chunk = this->u_buffer = NULL; | 3047 | this->u_chunk = this->u_buffer = NULL; |
3048 | this->v_chunk = this->v_buffer = NULL; | 3048 | this->v_chunk = this->v_buffer = NULL; |
3049 | 3049 | ||
3050 | this->table_rV = factory->table_rV; | 3050 | this->table_rV = factory->table_rV; |
3051 | this->table_gU = factory->table_gU; | 3051 | this->table_gU = factory->table_gU; |
3052 | this->table_gV = factory->table_gV; | 3052 | this->table_gV = factory->table_gV; |
3053 | this->table_bU = factory->table_bU; | 3053 | this->table_bU = factory->table_bU; |
3054 | 3054 | ||
3055 | this->yuv2rgb_fun = factory->yuv2rgb_fun; | 3055 | this->yuv2rgb_fun = factory->yuv2rgb_fun; |
3056 | this->yuy22rgb_fun = factory->yuy22rgb_fun; | 3056 | this->yuy22rgb_fun = factory->yuy22rgb_fun; |
3057 | this->yuv2rgb_single_pixel_fun = factory->yuv2rgb_single_pixel_fun; | 3057 | this->yuv2rgb_single_pixel_fun = factory->yuv2rgb_single_pixel_fun; |
3058 | 3058 | ||
3059 | this->configure = yuv2rgb_configure; | 3059 | this->configure = yuv2rgb_configure; |
3060 | return this; | 3060 | return this; |
3061 | } | 3061 | } |
3062 | 3062 | ||
3063 | /* | 3063 | /* |
3064 | * factory functions | 3064 | * factory functions |
3065 | */ | 3065 | */ |
3066 | 3066 | ||
3067 | void yuv2rgb_set_gamma (yuv2rgb_factory_t *this, int gamma) { | 3067 | void yuv2rgb_set_gamma (yuv2rgb_factory_t *this, int gamma) { |
3068 | 3068 | ||
3069 | int i; | 3069 | int i; |
3070 | 3070 | ||
3071 | for (i = 0; i < 256; i++) { | 3071 | for (i = 0; i < 256; i++) { |
3072 | (uint8_t *)this->table_rV[i] += this->entry_size*(gamma - this->gamma); | 3072 | (uint8_t *)this->table_rV[i] += this->entry_size*(gamma - this->gamma); |
3073 | (uint8_t *)this->table_gU[i] += this->entry_size*(gamma - this->gamma); | 3073 | (uint8_t *)this->table_gU[i] += this->entry_size*(gamma - this->gamma); |
3074 | (uint8_t *)this->table_bU[i] += this->entry_size*(gamma - this->gamma); | 3074 | (uint8_t *)this->table_bU[i] += this->entry_size*(gamma - this->gamma); |
3075 | } | 3075 | } |
3076 | #ifdef ARCH_X86 | 3076 | #ifdef ARCH_X86 |
3077 | mmx_yuv2rgb_set_gamma(gamma); | 3077 | mmx_yuv2rgb_set_gamma(gamma); |
3078 | #endif | 3078 | #endif |
3079 | this->gamma = gamma; | 3079 | this->gamma = gamma; |
3080 | } | 3080 | } |
3081 | 3081 | ||
3082 | int yuv2rgb_get_gamma (yuv2rgb_factory_t *this) { | 3082 | int yuv2rgb_get_gamma (yuv2rgb_factory_t *this) { |
3083 | 3083 | ||
3084 | return this->gamma; | 3084 | return this->gamma; |
3085 | } | 3085 | } |
3086 | 3086 | ||
3087 | yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped, | 3087 | yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped, |
3088 | uint8_t *cmap) { | 3088 | uint8_t *cmap) { |
3089 | 3089 | ||
3090 | yuv2rgb_factory_t *this; | 3090 | yuv2rgb_factory_t *this; |
3091 | 3091 | ||
3092 | #ifdef ARCH_X86 | 3092 | #ifdef ARCH_X86 |
3093 | uint32_t mm = xine_mm_accel(); | 3093 | uint32_t mm = xine_mm_accel(); |
3094 | #endif | 3094 | #endif |
3095 | 3095 | ||
3096 | this = malloc (sizeof (yuv2rgb_factory_t)); | 3096 | this = malloc (sizeof (yuv2rgb_factory_t)); |
3097 | 3097 | ||
3098 | this->mode = mode; | 3098 | this->mode = mode; |
3099 | this->swapped = swapped; | 3099 | this->swapped = swapped; |
3100 | this->cmap = cmap; | 3100 | this->cmap = cmap; |
3101 | this->create_converter = yuv2rgb_create_converter; | 3101 | this->create_converter = yuv2rgb_create_converter; |
3102 | this->set_gamma = yuv2rgb_set_gamma; | 3102 | this->set_gamma = yuv2rgb_set_gamma; |
3103 | this->get_gamma = yuv2rgb_get_gamma; | 3103 | this->get_gamma = yuv2rgb_get_gamma; |
3104 | this->matrix_coefficients = 6; | 3104 | this->matrix_coefficients = 6; |
3105 | 3105 | ||
3106 | 3106 | ||
3107 | yuv2rgb_setup_tables (this, mode, swapped); | 3107 | yuv2rgb_setup_tables (this, mode, swapped); |
3108 | 3108 | ||
3109 | /* | 3109 | /* |
3110 | * auto-probe for the best yuv2rgb function | 3110 | * auto-probe for the best yuv2rgb function |
3111 | */ | 3111 | */ |
3112 | 3112 | ||
3113 | this->yuv2rgb_fun = NULL; | 3113 | this->yuv2rgb_fun = NULL; |
3114 | #ifdef ARCH_X86 | 3114 | #ifdef ARCH_X86 |
3115 | if ((this->yuv2rgb_fun == NULL) && (mm & MM_ACCEL_X86_MMXEXT)) { | 3115 | if ((this->yuv2rgb_fun == NULL) && (mm & MM_ACCEL_X86_MMXEXT)) { |
3116 | 3116 | ||
3117 | yuv2rgb_init_mmxext (this); | 3117 | yuv2rgb_init_mmxext (this); |
3118 | 3118 | ||
3119 | if (this->yuv2rgb_fun != NULL) | 3119 | if (this->yuv2rgb_fun != NULL) |
3120 | printf ("yuv2rgb: using MMXEXT for colorspace transform\n"); | 3120 | printf ("yuv2rgb: using MMXEXT for colorspace transform\n"); |
3121 | } | 3121 | } |
3122 | 3122 | ||
3123 | if ((this->yuv2rgb_fun == NULL) && (mm & MM_ACCEL_X86_MMX)) { | 3123 | if ((this->yuv2rgb_fun == NULL) && (mm & MM_ACCEL_X86_MMX)) { |
3124 | 3124 | ||
3125 | yuv2rgb_init_mmx (this); | 3125 | yuv2rgb_init_mmx (this); |
3126 | 3126 | ||
3127 | if (this->yuv2rgb_fun != NULL) | 3127 | if (this->yuv2rgb_fun != NULL) |
3128 | printf ("yuv2rgb: using MMX for colorspace transform\n"); | 3128 | printf ("yuv2rgb: using MMX for colorspace transform\n"); |
3129 | } | 3129 | } |
3130 | #endif | 3130 | #endif |
3131 | #if HAVE_MLIB | 3131 | #if HAVE_MLIB |
3132 | if (this->yuv2rgb_fun == NULL) { | 3132 | if (this->yuv2rgb_fun == NULL) { |
3133 | 3133 | ||
3134 | yuv2rgb_init_mlib (this); | 3134 | yuv2rgb_init_mlib (this); |
3135 | 3135 | ||
3136 | if (this->yuv2rgb_fun != NULL) | 3136 | if (this->yuv2rgb_fun != NULL) |
3137 | printf ("yuv2rgb: using medialib for colorspace transform\n"); | 3137 | printf ("yuv2rgb: using medialib for colorspace transform\n"); |
3138 | } | 3138 | } |
3139 | #endif | 3139 | #endif |
3140 | #ifdef __arm__ | ||
3141 | if (this->yuv2rgb_fun == NULL) { | ||
3142 | yuv2rgb_init_arm ( this ); | ||
3143 | |||
3144 | if(this->yuv2rgb_fun != NULL) | ||
3145 | printf("yuv2rgb: using arm4l assembler for colorspace transform\n" ); | ||
3146 | } | ||
3147 | #endif | ||
3140 | if (this->yuv2rgb_fun == NULL) { | 3148 | if (this->yuv2rgb_fun == NULL) { |
3141 | printf ("yuv2rgb: no accelerated colorspace conversion found\n"); | 3149 | printf ("yuv2rgb: no accelerated colorspace conversion found\n"); |
3142 | yuv2rgb_c_init (this); | 3150 | yuv2rgb_c_init (this); |
3143 | } | 3151 | } |
3144 | 3152 | ||
3145 | /* | 3153 | /* |
3146 | * auto-probe for the best yuy22rgb function | 3154 | * auto-probe for the best yuy22rgb function |
3147 | */ | 3155 | */ |
3148 | 3156 | ||
3149 | /* FIXME: implement mmx/mlib functions */ | 3157 | /* FIXME: implement mmx/mlib functions */ |
3150 | yuy22rgb_c_init (this); | 3158 | yuy22rgb_c_init (this); |
3151 | 3159 | ||
3152 | /* | 3160 | /* |
3153 | * set up single pixel function | 3161 | * set up single pixel function |
3154 | */ | 3162 | */ |
3155 | 3163 | ||
3156 | yuv2rgb_single_pixel_init (this); | 3164 | yuv2rgb_single_pixel_init (this); |
3157 | 3165 | ||
3158 | return this; | 3166 | return this; |
3159 | } | 3167 | } |
3160 | 3168 | ||
diff --git a/noncore/multimedia/opieplayer2/yuv2rgb_arm.c b/noncore/multimedia/opieplayer2/yuv2rgb_arm.c new file mode 100644 index 0000000..699ee48 --- a/dev/null +++ b/noncore/multimedia/opieplayer2/yuv2rgb_arm.c | |||
@@ -0,0 +1,174 @@ | |||
1 | /* | ||
2 | * yuv2rgb_arm.c | ||
3 | * Copyright (C) 2000-2001 Project OPIE. | ||
4 | * All Rights Reserved. | ||
5 | * | ||
6 | * Author: Robert Griebl <sandman@handhelds.org> | ||
7 | * | ||
8 | * This file is part of OpiePlayer2. | ||
9 | * | ||
10 | * OpiePlayer2 is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * OpiePlayer2 is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
23 | */ | ||
24 | |||
25 | #ifdef __arm__ | ||
26 | |||
27 | #include <stdio.h> | ||
28 | #include <stdlib.h> | ||
29 | #include <string.h> | ||
30 | #include <inttypes.h> | ||
31 | |||
32 | #include "yuv2rgb.h" | ||
33 | #include <xine/xineutils.h> | ||
34 | |||
35 | #define RGB(i) \ | ||
36 | U = pu[i]; \ | ||
37 | V = pv[i]; \ | ||
38 | r = this->table_rV[V]; \ | ||
39 | g = (void *) (((uint8_t *)this->table_gU[U]) + this->table_gV[V]);\ | ||
40 | b = this->table_bU[U]; | ||
41 | |||
42 | #define DST1(i) \ | ||
43 | Y = py_1[2*i]; \ | ||
44 | dst_1[2*i] = r[Y] + g[Y] + b[Y];\ | ||
45 | Y = py_1[2*i+1]; \ | ||
46 | dst_1[2*i+1] = r[Y] + g[Y] + b[Y]; | ||
47 | |||
48 | |||
49 | struct dummy { | ||
50 | uint8_t *yuv [3]; | ||
51 | int stride [3]; | ||
52 | }; | ||
53 | |||
54 | extern void convert_yuv420_rgb565(struct dummy *picture, unsigned char *results, int w, int h) ; | ||
55 | |||
56 | |||
57 | static void arm_rgb16 (yuv2rgb_t *this, uint8_t * _dst, | ||
58 | uint8_t * _py, uint8_t * _pu, uint8_t * _pv) | ||
59 | { | ||
60 | if ( !this-> do_scale ) { | ||
61 | struct dummy d; | ||
62 | d. yuv [0] = _py; | ||
63 | d. yuv [1] = _pu; | ||
64 | d. yuv [2] = _pv; | ||
65 | d. stride [0] = this-> y_stride; | ||
66 | d. stride [1] = d. stride [2] = this-> uv_stride; | ||
67 | |||
68 | // printf( "calling arm (%dx%d)\n", this-> dest_width, this-> dest_height ); | ||
69 | |||
70 | convert_yuv420_rgb565 ( &d, _dst, this->dest_width, this->dest_height ); | ||
71 | |||
72 | // printf ( "arm done\n" ); | ||
73 | } | ||
74 | else { | ||
75 | int U, V, Y; | ||
76 | uint8_t * py_1, * py_2, * pu, * pv; | ||
77 | uint16_t * r, * g, * b; | ||
78 | uint16_t * dst_1, * dst_2; | ||
79 | int width, height, dst_height; | ||
80 | int dy; | ||
81 | |||
82 | scale_line_func_t scale_line = this->scale_line; | ||
83 | |||
84 | scale_line (_pu, this->u_buffer, | ||
85 | this->dest_width >> 1, this->step_dx); | ||
86 | scale_line (_pv, this->v_buffer, | ||
87 | this->dest_width >> 1, this->step_dx); | ||
88 | scale_line (_py, this->y_buffer, | ||
89 | this->dest_width, this->step_dx); | ||
90 | |||
91 | dy = 0; | ||
92 | dst_height = this->dest_height; | ||
93 | |||
94 | for (height = 0;; ) { | ||
95 | dst_1 = (uint16_t*)_dst; | ||
96 | py_1 = this->y_buffer; | ||
97 | pu = this->u_buffer; | ||
98 | pv = this->v_buffer; | ||
99 | |||
100 | width = this->dest_width >> 3; | ||
101 | |||
102 | do { | ||
103 | RGB(0); | ||
104 | DST1(0); | ||
105 | |||
106 | RGB(1); | ||
107 | DST1(1); | ||
108 | |||
109 | RGB(2); | ||
110 | DST1(2); | ||
111 | |||
112 | RGB(3); | ||
113 | DST1(3); | ||
114 | |||
115 | pu += 4; | ||
116 | pv += 4; | ||
117 | py_1 += 8; | ||
118 | dst_1 += 8; | ||
119 | } while (--width); | ||
120 | |||
121 | dy += this->step_dy; | ||
122 | _dst += this->rgb_stride; | ||
123 | |||
124 | while (--dst_height > 0 && dy < 32768) { | ||
125 | |||
126 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*2); | ||
127 | |||
128 | dy += this->step_dy; | ||
129 | _dst += this->rgb_stride; | ||
130 | } | ||
131 | |||
132 | if (dst_height <= 0) | ||
133 | break; | ||
134 | |||
135 | do { | ||
136 | dy -= 32768; | ||
137 | _py += this->y_stride; | ||
138 | |||
139 | scale_line (_py, this->y_buffer, | ||
140 | this->dest_width, this->step_dx); | ||
141 | |||
142 | if (height & 1) { | ||
143 | _pu += this->uv_stride; | ||
144 | _pv += this->uv_stride; | ||
145 | |||
146 | scale_line (_pu, this->u_buffer, | ||
147 | this->dest_width >> 1, this->step_dx); | ||
148 | scale_line (_pv, this->v_buffer, | ||
149 | this->dest_width >> 1, this->step_dx); | ||
150 | |||
151 | } | ||
152 | height++; | ||
153 | } while( dy>=32768); | ||
154 | } | ||
155 | } | ||
156 | } | ||
157 | |||
158 | |||
159 | |||
160 | void yuv2rgb_init_arm (yuv2rgb_factory_t *this) { | ||
161 | |||
162 | if (this->swapped) | ||
163 | return; /*no swapped pixel output upto now*/ | ||
164 | |||
165 | switch (this->mode) { | ||
166 | case MODE_16_RGB: | ||
167 | this->yuv2rgb_fun = arm_rgb16; | ||
168 | break; | ||
169 | } | ||
170 | } | ||
171 | |||
172 | |||
173 | |||
174 | #endif | ||
diff --git a/noncore/multimedia/opieplayer2/yuv2rgb_arm4l.S b/noncore/multimedia/opieplayer2/yuv2rgb_arm4l.S new file mode 100644 index 0000000..f4a3395 --- a/dev/null +++ b/noncore/multimedia/opieplayer2/yuv2rgb_arm4l.S | |||
@@ -0,0 +1,192 @@ | |||
1 | /* WARNING : this function only works when stride_U == stride_V (I use some hacks to | ||
2 | not have to do too many computations at line's end)... | ||
3 | |||
4 | C-like prototype : | ||
5 | void convert_yuv420_rgb565(AVPicture *picture, unsigned char *results, int w, int h) ; | ||
6 | |||
7 | */ | ||
8 | |||
9 | #ifdef __arm__ | ||
10 | |||
11 | .text | ||
12 | .align | ||
13 | |||
14 | .global convert_yuv420_rgb565 | ||
15 | convert_yuv420_rgb565: | ||
16 | stmdb sp!, { r4 - r12, lr } @ all callee saved regs | ||
17 | ldr r7, [r0, #0] @ Y ptr | ||
18 | ldr r9, [r0, #4] @ U ptr | ||
19 | ldr r10, [r0, #8] @ V ptr | ||
20 | subs r10, r10, r9 @ V ptr - U ptr | ||
21 | ldr r8, [r0, #12] | ||
22 | add r8, r8, r7 @ Y + stride_Y | ||
23 | ldr r4, [r0, #12] @ Stride_Y | ||
24 | mov r4, r4, lsl #1 | ||
25 | sub r4, r4, r2 @ (2 * Stride_Y) - width | ||
26 | ldr r5, [r0, #16] @ Stride_U | ||
27 | sub r5, r5, r2, lsr #1 @ Stride_U - (width / 2) | ||
28 | ldr r6, [r0, #20] @ Stride_V | ||
29 | sub r6, r6, r2, lsr #1 @ Stride_V - (width / 2) | ||
30 | add r0, r1, r2, lsl #1 @ RGB + 1 | ||
31 | stmdb sp!, { r0-r10 } | ||
32 | @ Stack description : | ||
33 | @ (sp+ 0) RGB + one line | ||
34 | @ (sp+ 4) RGB | ||
35 | @ (sp+ 8) width (save) | ||
36 | @ (sp+12) height | ||
37 | @ (sp+16) (2 * stride_Y) - width | ||
38 | @ (sp+20) stride_U - (width / 2) | ||
39 | @ (sp+24) stride_V - (width / 2) !!! UNUSED !!! | ||
40 | @ (sp+28) Y ptr | ||
41 | @ (sp+32) Y ptr + one line | ||
42 | @ (sp+36) U ptr | ||
43 | @ (sp+40) V - U | ||
44 | mov lr, r2 @ Initialize the width counter | ||
45 | add r0, pc, #(const_storage-.-8) @ r0 = base pointer to the constants array | ||
46 | ldr r8, [r0, #(4*4)] @ r8 = multy | ||
47 | yuv_loop: | ||
48 | add r0, pc, #(const_storage-.-8) @ r0 = base pointer to the constants array | ||
49 | ldr r10, [sp, #28] @ r10 = Y | ||
50 | ldr r1, [sp, #36] @ r1 = U | ||
51 | ldrb r9, [r10, #0] @ r9 = *Y | ||
52 | ldrb r11, [r1] @ r11 = *U | ||
53 | add r1, r1, #1 @ r1 = U++ | ||
54 | ldr r2, [sp, #40] @ r2 = V - U | ||
55 | str r1, [sp, #36] @ store U++ | ||
56 | add r2, r1, r2 @ r2 = V+1 | ||
57 | ldrb r12, [r2, #-1] @ r12 = *V | ||
58 | sub r11, r11, #128 @ r11 = *U - 128 | ||
59 | sub r12, r12, #128 @ r12 = *V - 128 | ||
60 | ldr r1, [r0, #(4*0)] @ r1 = crv | ||
61 | mov r7, #32768 @ r7 = 32768 (for additions in MLA) | ||
62 | ldr r2, [r0, #(4*3)] @ r2 = -cgv | ||
63 | mla r6, r1, r12, r7 @ r6 = nonyc_r = crv * (*V - 128) + 32768 | ||
64 | ldr r3, [r0, #(4*1)] @ r3 = cbu | ||
65 | mla r4, r2, r12, r7 @ r4 = - cgv * (*V - 128) + 32768 | ||
66 | sub r9, r9, #16 @ r9 = *Y - 16 | ||
67 | mla r5, r3, r11, r7 @ r5 = nonyc_b = cbu * (*U - 128) + 32768 | ||
68 | ldr r0, [r0, #(4*2)] @ r0 = -cgu | ||
69 | mla r7, r8, r9, r6 @ r7 = (*Y - 16) * multy + nonyc_r | ||
70 | add r10, r10, #2 @ r10 = Y + 2 | ||
71 | mla r4, r0, r11, r4 @ r4 = nonyc_g = - cgu * (*U - 128) + r4 = - cgu * (*U - 128) - cgv * (*V - 128) + 32768 | ||
72 | add r0, pc, #(rb_clip-.-8) @ r0 contains the pointer to the R and B clipping array | ||
73 | mla r12, r8, r9, r5 @ r12 = (*Y - 16) * multy + nonyc_b | ||
74 | ldrb r7, [r0, r7, asr #(16+3)] @ r7 = R composant | ||
75 | mla r1, r8, r9, r4 @ r1 = (*Y - 16) * multy + nonyc_g | ||
76 | ldrb r9, [r10, #-1] @ r9 = *(Y+1) | ||
77 | str r10, [sp, #28] @ save Y + 2 | ||
78 | ldrb r12, [r0, r12, asr #(16+3)] @ r12 = B composant (and the start of the RGB word) | ||
79 | add r11, pc, #(g_clip-.-8) @ r11 now contains the pointer to the G clipping array | ||
80 | ldrb r1, [r11, r1, asr #(16+2)] @ r1 contains the G part of the RGB triplet | ||
81 | sub r9, r9, #16 @ r9 = *(Y+1) - 16 | ||
82 | mla r10, r8, r9, r6 @ r10 is the Red part of the RGB triplet | ||
83 | add r12, r12, r7, lsl #11 @ r12 = .GB ... | ||
84 | mla r7, r8, r9, r5 @ r7 is the Blue part of the RGB triplet | ||
85 | add r12, r12, r1, lsl #5 @ r12 = RGB ... (ie the first pixel (half-word) is done) | ||
86 | mla r2, r8, r9, r4 @ r2 is the Green part of the RGB triplet | ||
87 | ldrb r10, [r0, r10, asr #(16+3)] @ r10 = R composant | ||
88 | ldrb r7, [r0, r7, asr #(16+3)] @ r7 = B composant | ||
89 | ldr r1, [sp, #32] @ r1 = Ynext | ||
90 | ldrb r2, [r11, r2, asr #(16+2)] @ r2 = G composant | ||
91 | ldrb r9, [r1] @ r9 = *Ynext | ||
92 | add r12, r12, r2, lsl #(5+16) @ r12 = RGB .G. | ||
93 | sub r9, r9, #16 @ r9 = *Ynext - 16 | ||
94 | mla r2, r8, r9, r4 @ r2 is the Green part of the RGB triplet | ||
95 | add r12, r12, r7, lsl #(0+16) @ r12 = RGB .GB | ||
96 | mla r7, r8, r9, r5 @ r7 is the Blue part of the RGB triplet | ||
97 | add r12, r12, r10, lsl #(11+16) @ r12 = RGB RGB | ||
98 | ldr r3, [sp, #4] @ r3 = RGB | ||
99 | mla r10, r8, r9, r6 @ r10 is the Red part of the RGB triplet | ||
100 | str r12, [r3] @ store the rgb pixel at *RGB | ||
101 | add r3, r3, #4 @ r3 = RGB++ (ie next double-pixel) | ||
102 | str r3, [sp, #4] @ store the RGB pointer | ||
103 | ldrb r9, [r1, #1] @ r9 = *(Ynext+1) | ||
104 | add r1, r1, #2 @ r1 = Ynext + 2 | ||
105 | sub r9, r9, #16 @ r9 = *(Ynext+1) - 16 | ||
106 | ldrb r12, [r0, r7, asr #(16+3)] @ r12 = ..B ... | ||
107 | ldrb r10, [r0, r10, asr #(16+3)] @ r10 = B composant | ||
108 | mla r7, r8, r9, r5 @ r7 is the Blue part of the RGB triplet | ||
109 | add r12, r12, r10, lsl #11 @ r12 = R.B ... | ||
110 | ldrb r2, [r11, r2, asr #(16+2)] @ r2 = G composant | ||
111 | mla r10, r8, r9, r6 @ r10 is the Red part of the RGB triplet | ||
112 | add r12, r12, r2, lsl #5 @ r12 = RGB ... | ||
113 | mla r2, r8, r9, r4 @ r2 is the Green part of the RGB triplet | ||
114 | ldrb r7, [r0, r7, asr #(16+3)] @ r7 = B composant | ||
115 | str r1, [sp, #32] @ store the increased Ynext pointer | ||
116 | add r12, r12, r7, lsl #(16+0) @ r12 = RGB ..B | ||
117 | ldrb r10, [r0, r10, asr #(16+3)] @ r10 = R composant | ||
118 | ldr r3, [sp, #0] @ r3 = RGBnext pointer | ||
119 | add r12, r12, r10, lsl #(16+11) @ r12 = RGB R.B | ||
120 | ldrb r2, [r11, r2, asr #(16+2)] @ r2 = G composant | ||
121 | add r3, r3, #4 @ r3 = next pixel on the RGBnext line | ||
122 | add r12, r12, r2, lsl #(16+5) @ r12 = RGB RGB | ||
123 | str r12, [r3, #-4] @ store the next pixel | ||
124 | str r3, [sp, #0] @ store the increased 'next line' pixel pointer | ||
125 | subs lr, lr, #2 @ decrement the line counter | ||
126 | bne yuv_loop @ and restart if not at the end of the line | ||
127 | |||
128 | ldr r0, [sp, #8] @ r0 = saved width | ||
129 | ldr r1, [sp, #0] @ r1 = RGBnext pointer | ||
130 | mov lr, r0 @ lr = saved width (to restart the line counter) | ||
131 | str r1, [sp, #4] @ current RGBnext pointer is next iteration RGB pointer | ||
132 | add r1, r1, r0, lsl #1 @ r1 = update RGBnext to next line | ||
133 | str r1, [sp, #0] @ store updated RGBnext pointer | ||
134 | |||
135 | ldr r3, [sp, #16] @ r3 = (2 * stride_Y) - width | ||
136 | ldr r4, [sp, #28] @ r4 = Y ptr | ||
137 | ldr r5, [sp, #32] @ r5 = Ynext ptr | ||
138 | add r4, r4, r3 @ r4 = Y ptr for the next two lines | ||
139 | add r5, r5, r3 @ r5 = Ynext ptr for the next two lines | ||
140 | str r4, [sp, #28] @ store updated Y pointer | ||
141 | str r5, [sp, #32] @ store update Ynext pointer | ||
142 | |||
143 | ldr r1, [sp, #20] @ r1 = stride_U - (width / 2) | ||
144 | ldr r2, [sp, #36] @ r2 = U ptr | ||
145 | |||
146 | ldr r6, [sp, #12] @ get height counter | ||
147 | |||
148 | add r2, r2, r1 @ update U ptr | ||
149 | str r2, [sp, #36] @ store updated U ptr (and update 'V' at the same time :-) ) | ||
150 | |||
151 | subs r6, r6, #2 | ||
152 | str r6, [sp, #12] | ||
153 | bne yuv_loop | ||
154 | |||
155 | @ Exit cleanly :-) | ||
156 | add sp, sp, #(11*4) @ remove all custom things from stack | ||
157 | ldmia sp!, { r4 - r12, pc } @ restore callee saved regs and return | ||
158 | |||
159 | |||
160 | const_storage: | ||
161 | @ In order : crv, cbu, - cgu, - cgv, multy | ||
162 | .word 0x00019895, 0x00020469, 0xffff9bb5, 0xffff2fe1, 0x00012A15 | ||
163 | rb_clip_dummy: | ||
164 | .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 | ||
165 | .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 | ||
166 | .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 | ||
167 | rb_clip: | ||
168 | .byte 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f | ||
169 | .byte 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f | ||
170 | .byte 0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f | ||
171 | .byte 0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f | ||
172 | .byte 0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f | ||
173 | g_clip_dummy: | ||
174 | .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 | ||
175 | .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 | ||
176 | .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 | ||
177 | .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 | ||
178 | .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 | ||
179 | .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 | ||
180 | g_clip: | ||
181 | .byte 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f | ||
182 | .byte 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f | ||
183 | .byte 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f | ||
184 | .byte 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f | ||
185 | .byte 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f | ||
186 | .byte 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f | ||
187 | .byte 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f | ||
188 | .byte 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f | ||
189 | .byte 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f | ||
190 | .byte 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f | ||
191 | |||
192 | #endif | ||
diff --git a/noncore/multimedia/opieplayer2/yuv2rgb_mlib.c b/noncore/multimedia/opieplayer2/yuv2rgb_mlib.c deleted file mode 100644 index 908b439..0000000 --- a/noncore/multimedia/opieplayer2/yuv2rgb_mlib.c +++ b/dev/null | |||
@@ -1,313 +0,0 @@ | |||
1 | /* | ||
2 | * yuv2rgb_mlib.c | ||
3 | * Copyright (C) 2000-2001 Silicon Integrated System Corp. | ||
4 | * All Rights Reserved. | ||
5 | * | ||
6 | * Author: Juergen Keil <jk@tools.de> | ||
7 | * | ||
8 | * This file is part of xine, a free unix video player. | ||
9 | * | ||
10 | * xine is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * xine is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
23 | */ | ||
24 | |||
25 | |||
26 | #if HAVE_MLIB | ||
27 | |||
28 | #include <stdio.h> | ||
29 | #include <stdlib.h> | ||
30 | #include <string.h> | ||
31 | #include <inttypes.h> | ||
32 | #include <mlib_video.h> | ||
33 | |||
34 | #include "attributes.h" | ||
35 | #include "yuv2rgb.h" | ||
36 | |||
37 | |||
38 | static void scale_line (uint8_t *source, uint8_t *dest, | ||
39 | int width, int step) { | ||
40 | |||
41 | unsigned p1; | ||
42 | unsigned p2; | ||
43 | int dx; | ||
44 | |||
45 | p1 = *source++; | ||
46 | p2 = *source++; | ||
47 | dx = 0; | ||
48 | |||
49 | while (width) { | ||
50 | |||
51 | /* | ||
52 | printf ("scale_line, width = %d\n", width); | ||
53 | printf ("scale_line, dx = %d, p1 = %d, p2 = %d\n", dx, p1, p2); | ||
54 | */ | ||
55 | |||
56 | *dest = (p1 * (32768 - dx) + p2 * dx) / 32768; | ||
57 | |||
58 | dx += step; | ||
59 | while (dx > 32768) { | ||
60 | dx -= 32768; | ||
61 | p1 = p2; | ||
62 | p2 = *source++; | ||
63 | } | ||
64 | |||
65 | dest ++; | ||
66 | width --; | ||
67 | } | ||
68 | } | ||
69 | |||
70 | |||
71 | |||
72 | static void mlib_yuv420_rgb24 (yuv2rgb_t *this, | ||
73 | uint8_t * image, uint8_t * py, | ||
74 | uint8_t * pu, uint8_t * pv) | ||
75 | { | ||
76 | int dst_height; | ||
77 | int dy; | ||
78 | mlib_status mlib_stat; | ||
79 | |||
80 | if (this->do_scale) { | ||
81 | dy = 0; | ||
82 | dst_height = this->dest_height; | ||
83 | |||
84 | for (;;) { | ||
85 | scale_line (pu, this->u_buffer, | ||
86 | this->dest_width >> 1, this->step_dx); | ||
87 | pu += this->uv_stride; | ||
88 | |||
89 | scale_line (pv, this->v_buffer, | ||
90 | this->dest_width >> 1, this->step_dx); | ||
91 | pv += this->uv_stride; | ||
92 | |||
93 | scale_line (py, this->y_buffer, | ||
94 | this->dest_width, this->step_dx); | ||
95 | py += this->y_stride; | ||
96 | scale_line (py, this->y_buffer + this->dest_width, | ||
97 | this->dest_width, this->step_dx); | ||
98 | py += this->y_stride; | ||
99 | |||
100 | mlib_stat = mlib_VideoColorYUV2RGB420(image, | ||
101 | this->y_buffer, | ||
102 | this->u_buffer, | ||
103 | this->v_buffer, | ||
104 | this->dest_width & ~1, 2, | ||
105 | this->rgb_stride, | ||
106 | this->dest_width, | ||
107 | this->dest_width >> 1); | ||
108 | dy += this->step_dy; | ||
109 | image += this->rgb_stride; | ||
110 | |||
111 | while (--dst_height > 0 && dy < 32768) { | ||
112 | memcpy (image, (uint8_t*)image-this->rgb_stride, this->dest_width*6); | ||
113 | dy += this->step_dy; | ||
114 | image += this->rgb_stride; | ||
115 | } | ||
116 | |||
117 | if (dst_height <= 0) | ||
118 | break; | ||
119 | |||
120 | dy -= 32768; | ||
121 | |||
122 | dy += this->step_dy; | ||
123 | image += this->rgb_stride; | ||
124 | |||
125 | while (--dst_height > 0 && dy < 32768) { | ||
126 | memcpy (image, (uint8_t*)image-this->rgb_stride, this->dest_width*3); | ||
127 | dy += this->step_dy; | ||
128 | image += this->rgb_stride; | ||
129 | } | ||
130 | |||
131 | if (dst_height <= 0) | ||
132 | break; | ||
133 | |||
134 | dy -= 32768; | ||
135 | } | ||
136 | } else { | ||
137 | mlib_stat = mlib_VideoColorYUV2RGB420(image, py, pu, pv, | ||
138 | this->source_width, | ||
139 | this->source_height, | ||
140 | this->rgb_stride, | ||
141 | this->y_stride, | ||
142 | this->uv_stride); | ||
143 | } | ||
144 | } | ||
145 | |||
146 | static void mlib_yuv420_argb32 (yuv2rgb_t *this, | ||
147 | uint8_t * image, uint8_t * py, | ||
148 | uint8_t * pu, uint8_t * pv) | ||
149 | { | ||
150 | int dst_height; | ||
151 | int dy; | ||
152 | mlib_status mlib_stat; | ||
153 | |||
154 | if (this->do_scale) { | ||
155 | dy = 0; | ||
156 | dst_height = this->dest_height; | ||
157 | |||
158 | for (;;) { | ||
159 | scale_line (pu, this->u_buffer, | ||
160 | this->dest_width >> 1, this->step_dx); | ||
161 | pu += this->uv_stride; | ||
162 | |||
163 | scale_line (pv, this->v_buffer, | ||
164 | this->dest_width >> 1, this->step_dx); | ||
165 | pv += this->uv_stride; | ||
166 | |||
167 | scale_line (py, this->y_buffer, | ||
168 | this->dest_width, this->step_dx); | ||
169 | py += this->y_stride; | ||
170 | scale_line (py, this->y_buffer + this->dest_width, | ||
171 | this->dest_width, this->step_dx); | ||
172 | py += this->y_stride; | ||
173 | |||
174 | mlib_stat = mlib_VideoColorYUV2ARGB420(image, | ||
175 | this->y_buffer, | ||
176 | this->u_buffer, | ||
177 | this->v_buffer, | ||
178 | this->dest_width & ~1, 2, | ||
179 | this->rgb_stride, | ||
180 | this->dest_width, | ||
181 | this->dest_width >> 1); | ||
182 | dy += this->step_dy; | ||
183 | image += this->rgb_stride; | ||
184 | |||
185 | while (--dst_height > 0 && dy < 32768) { | ||
186 | memcpy (image, (uint8_t*)image-this->rgb_stride, this->dest_width*8); | ||
187 | dy += this->step_dy; | ||
188 | image += this->rgb_stride; | ||
189 | } | ||
190 | |||
191 | if (dst_height <= 0) | ||
192 | break; | ||
193 | |||
194 | dy -= 32768; | ||
195 | |||
196 | dy += this->step_dy; | ||
197 | image += this->rgb_stride; | ||
198 | |||
199 | while (--dst_height > 0 && dy < 32768) { | ||
200 | memcpy (image, (uint8_t*)image-this->rgb_stride, this->dest_width*4); | ||
201 | dy += this->step_dy; | ||
202 | image += this->rgb_stride; | ||
203 | } | ||
204 | |||
205 | if (dst_height <= 0) | ||
206 | break; | ||
207 | |||
208 | dy -= 32768; | ||
209 | } | ||
210 | } else { | ||
211 | mlib_stat = mlib_VideoColorYUV2ARGB420(image, py, pu, pv, | ||
212 | this->source_width, | ||
213 | this->source_height, | ||
214 | this->rgb_stride, | ||
215 | this->y_stride, | ||
216 | this->uv_stride); | ||
217 | } | ||
218 | } | ||
219 | |||
220 | static void mlib_yuv420_abgr32 (yuv2rgb_t *this, | ||
221 | uint8_t * image, uint8_t * py, | ||
222 | uint8_t * pu, uint8_t * pv) | ||
223 | { | ||
224 | int dst_height; | ||
225 | int dy; | ||
226 | mlib_status mlib_stat; | ||
227 | |||
228 | if (this->do_scale) { | ||
229 | dy = 0; | ||
230 | dst_height = this->dest_height; | ||
231 | |||
232 | for (;;) { | ||
233 | scale_line (pu, this->u_buffer, | ||
234 | this->dest_width >> 1, this->step_dx); | ||
235 | pu += this->uv_stride; | ||
236 | |||
237 | scale_line (pv, this->v_buffer, | ||
238 | this->dest_width >> 1, this->step_dx); | ||
239 | pv += this->uv_stride; | ||
240 | |||
241 | scale_line (py, this->y_buffer, | ||
242 | this->dest_width, this->step_dx); | ||
243 | py += this->y_stride; | ||
244 | scale_line (py, this->y_buffer + this->dest_width, | ||
245 | this->dest_width, this->step_dx); | ||
246 | py += this->y_stride; | ||
247 | |||
248 | mlib_stat = mlib_VideoColorYUV2ABGR420(image, | ||
249 | this->y_buffer, | ||
250 | this->u_buffer, | ||
251 | this->v_buffer, | ||
252 | this->dest_width & ~1, 2, | ||
253 | this->rgb_stride, | ||
254 | this->dest_width, | ||
255 | this->dest_width >> 1); | ||
256 | dy += this->step_dy; | ||
257 | image += this->rgb_stride; | ||
258 | |||
259 | while (--dst_height > 0 && dy < 32768) { | ||
260 | memcpy (image, (uint8_t*)image-this->rgb_stride, this->dest_width*8); | ||
261 | dy += this->step_dy; | ||
262 | image += this->rgb_stride; | ||
263 | } | ||
264 | |||
265 | if (dst_height <= 0) | ||
266 | break; | ||
267 | |||
268 | dy -= 32768; | ||
269 | |||
270 | dy += this->step_dy; | ||
271 | image += this->rgb_stride; | ||
272 | |||
273 | while (--dst_height > 0 && dy < 32768) { | ||
274 | memcpy (image, (uint8_t*)image-this->rgb_stride, this->dest_width*4); | ||
275 | dy += this->step_dy; | ||
276 | image += this->rgb_stride; | ||
277 | } | ||
278 | |||
279 | if (dst_height <= 0) | ||
280 | break; | ||
281 | |||
282 | dy -= 32768; | ||
283 | } | ||
284 | } else { | ||
285 | mlib_stat = mlib_VideoColorYUV2ABGR420(image, py, pu, pv, | ||
286 | this->source_width, | ||
287 | this->source_height, | ||
288 | this->rgb_stride, | ||
289 | this->y_stride, | ||
290 | this->uv_stride); | ||
291 | } | ||
292 | } | ||
293 | |||
294 | |||
295 | void yuv2rgb_init_mlib (yuv2rgb_factory_t *this) { | ||
296 | |||
297 | if (this->swapped) return; /*no swapped pixel output upto now*/ | ||
298 | |||
299 | switch (this->mode) { | ||
300 | case MODE_24_RGB: | ||
301 | this->yuv2rgb_fun = mlib_yuv420_rgb24; | ||
302 | break; | ||
303 | case MODE_32_RGB: | ||
304 | this->yuv2rgb_fun = mlib_yuv420_argb32; | ||
305 | break; | ||
306 | case MODE_32_BGR: | ||
307 | this->yuv2rgb_fun = mlib_yuv420_abgr32; | ||
308 | break; | ||
309 | } | ||
310 | } | ||
311 | |||
312 | |||
313 | #endif/* HAVE_MLIB */ | ||
diff --git a/noncore/multimedia/opieplayer2/yuv2rgb_mmx.c b/noncore/multimedia/opieplayer2/yuv2rgb_mmx.c deleted file mode 100644 index f092e6f..0000000 --- a/noncore/multimedia/opieplayer2/yuv2rgb_mmx.c +++ b/dev/null | |||
@@ -1,1047 +0,0 @@ | |||
1 | /* | ||
2 | * yuv2rgb_mmx.c | ||
3 | * Copyright (C) 2000-2001 Silicon Integrated System Corp. | ||
4 | * All Rights Reserved. | ||
5 | * | ||
6 | * Author: Olie Lho <ollie@sis.com.tw> | ||
7 | * | ||
8 | * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. | ||
9 | * | ||
10 | * mpeg2dec is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * mpeg2dec is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
23 | */ | ||
24 | |||
25 | |||
26 | #ifdef ARCH_X86 | ||
27 | |||
28 | #include <stdio.h> | ||
29 | #include <stdlib.h> | ||
30 | #include <string.h> | ||
31 | #include <inttypes.h> | ||
32 | |||
33 | #include "yuv2rgb.h" | ||
34 | #include "xineutils.h" | ||
35 | |||
36 | #define CPU_MMXEXT 0 | ||
37 | #define CPU_MMX 1 | ||
38 | |||
39 | /* CPU_MMXEXT/CPU_MMX adaptation layer */ | ||
40 | |||
41 | #define movntq(src,dest)\ | ||
42 | do { \ | ||
43 | if (cpu == CPU_MMXEXT)\ | ||
44 | movntq_r2m (src, dest);\ | ||
45 | else \ | ||
46 | movq_r2m (src, dest);\ | ||
47 | } while (0) | ||
48 | |||
49 | static mmx_t mmx_subYw = {0x1010101010101010}; | ||
50 | static mmx_t mmx_addYw = {0x0000000000000000}; | ||
51 | |||
52 | void mmx_yuv2rgb_set_gamma(int gamma) | ||
53 | { | ||
54 | int a,s,i; | ||
55 | |||
56 | if( gamma <= 16 ) { | ||
57 | a = 0; | ||
58 | s = 16 - gamma; | ||
59 | } else { | ||
60 | a = gamma - 16; | ||
61 | s = 0; | ||
62 | } | ||
63 | |||
64 | for( i = 0; i < 8; i++ ) { | ||
65 | *((unsigned char *)&mmx_subYw + i) = s; | ||
66 | *((unsigned char *)&mmx_addYw + i) = a; | ||
67 | } | ||
68 | } | ||
69 | |||
70 | static inline void mmx_yuv2rgb (uint8_t * py, uint8_t * pu, uint8_t * pv) | ||
71 | { | ||
72 | static mmx_t mmx_80w = {0x0080008000800080}; | ||
73 | static mmx_t mmx_U_green = {0xf37df37df37df37d}; | ||
74 | static mmx_t mmx_U_blue = {0x4093409340934093}; | ||
75 | static mmx_t mmx_V_red = {0x3312331233123312}; | ||
76 | static mmx_t mmx_V_green = {0xe5fce5fce5fce5fc}; | ||
77 | static mmx_t mmx_00ffw = {0x00ff00ff00ff00ff}; | ||
78 | static mmx_t mmx_Y_coeff = {0x253f253f253f253f}; | ||
79 | |||
80 | movq_m2r (*py, mm6); // mm6 = Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 | ||
81 | pxor_r2r (mm4, mm4); // mm4 = 0 | ||
82 | |||
83 | psubusb_m2r (mmx_subYw, mm6);// Y -= 16 | ||
84 | paddusb_m2r (mmx_addYw, mm6); | ||
85 | |||
86 | movd_m2r (*pu, mm0); // mm0 = 00 00 00 00 u3 u2 u1 u0 | ||
87 | movq_r2r (mm6, mm7); // mm7 = Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 | ||
88 | |||
89 | pand_m2r (mmx_00ffw, mm6); // mm6 = Y6 Y4 Y2 Y0 | ||
90 | psrlw_i2r (8, mm7); // mm7 = Y7 Y5 Y3 Y1 | ||
91 | |||
92 | movd_m2r (*pv, mm1); // mm1 = 00 00 00 00 v3 v2 v1 v0 | ||
93 | psllw_i2r (3, mm6); // promote precision | ||
94 | |||
95 | pmulhw_m2r (mmx_Y_coeff, mm6);// mm6 = luma_rgb even | ||
96 | psllw_i2r (3, mm7); // promote precision | ||
97 | |||
98 | punpcklbw_r2r (mm4, mm0); // mm0 = u3 u2 u1 u0 | ||
99 | |||
100 | psubsw_m2r (mmx_80w, mm0); // u -= 128 | ||
101 | punpcklbw_r2r (mm4, mm1); // mm1 = v3 v2 v1 v0 | ||
102 | |||
103 | pmulhw_m2r (mmx_Y_coeff, mm7);// mm7 = luma_rgb odd | ||
104 | psllw_i2r (3, mm0); // promote precision | ||
105 | |||
106 | psubsw_m2r (mmx_80w, mm1); // v -= 128 | ||
107 | movq_r2r (mm0, mm2); // mm2 = u3 u2 u1 u0 | ||
108 | |||
109 | psllw_i2r (3, mm1); // promote precision | ||
110 | |||
111 | movq_r2r (mm1, mm4); // mm4 = v3 v2 v1 v0 | ||
112 | |||
113 | pmulhw_m2r (mmx_U_blue, mm0);// mm0 = chroma_b | ||
114 | |||
115 | |||
116 | // slot | ||
117 | |||
118 | |||
119 | // slot | ||
120 | |||
121 | |||
122 | pmulhw_m2r (mmx_V_red, mm1);// mm1 = chroma_r | ||
123 | movq_r2r (mm0, mm3); // mm3 = chroma_b | ||
124 | |||
125 | paddsw_r2r (mm6, mm0); // mm0 = B6 B4 B2 B0 | ||
126 | paddsw_r2r (mm7, mm3); // mm3 = B7 B5 B3 B1 | ||
127 | |||
128 | packuswb_r2r (mm0, mm0); // saturate to 0-255 | ||
129 | |||
130 | |||
131 | pmulhw_m2r (mmx_U_green, mm2);// mm2 = u * u_green | ||
132 | |||
133 | |||
134 | packuswb_r2r (mm3, mm3); // saturate to 0-255 | ||
135 | |||
136 | |||
137 | punpcklbw_r2r (mm3, mm0); // mm0 = B7 B6 B5 B4 B3 B2 B1 B0 | ||
138 | |||
139 | |||
140 | pmulhw_m2r (mmx_V_green, mm4);// mm4 = v * v_green | ||
141 | |||
142 | |||
143 | // slot | ||
144 | |||
145 | |||
146 | // slot | ||
147 | |||
148 | |||
149 | paddsw_r2r (mm4, mm2); // mm2 = chroma_g | ||
150 | movq_r2r (mm2, mm5); // mm5 = chroma_g | ||
151 | |||
152 | |||
153 | movq_r2r (mm1, mm4); // mm4 = chroma_r | ||
154 | paddsw_r2r (mm6, mm2); // mm2 = G6 G4 G2 G0 | ||
155 | |||
156 | |||
157 | packuswb_r2r (mm2, mm2); // saturate to 0-255 | ||
158 | paddsw_r2r (mm6, mm1); // mm1 = R6 R4 R2 R0 | ||
159 | |||
160 | packuswb_r2r (mm1, mm1); // saturate to 0-255 | ||
161 | paddsw_r2r (mm7, mm4); // mm4 = R7 R5 R3 R1 | ||
162 | |||
163 | packuswb_r2r (mm4, mm4); // saturate to 0-255 | ||
164 | paddsw_r2r (mm7, mm5); // mm5 = G7 G5 G3 G1 | ||
165 | |||
166 | |||
167 | packuswb_r2r (mm5, mm5); // saturate to 0-255 | ||
168 | |||
169 | |||
170 | punpcklbw_r2r (mm4, mm1); // mm1 = R7 R6 R5 R4 R3 R2 R1 R0 | ||
171 | |||
172 | |||
173 | punpcklbw_r2r (mm5, mm2); // mm2 = G7 G6 G5 G4 G3 G2 G1 G0 | ||
174 | } | ||
175 | |||
176 | // basic opt | ||
177 | static inline void mmx_unpack_16rgb (uint8_t * image, int cpu) | ||
178 | { | ||
179 | static mmx_t mmx_bluemask = {0xf8f8f8f8f8f8f8f8}; | ||
180 | static mmx_t mmx_greenmask = {0xfcfcfcfcfcfcfcfc}; | ||
181 | static mmx_t mmx_redmask = {0xf8f8f8f8f8f8f8f8}; | ||
182 | |||
183 | /* | ||
184 | * convert RGB plane to RGB 16 bits | ||
185 | * mm0 -> B, mm1 -> R, mm2 -> G | ||
186 | * mm4 -> GB, mm5 -> AR pixel 4-7 | ||
187 | * mm6 -> GB, mm7 -> AR pixel 0-3 | ||
188 | */ | ||
189 | |||
190 | pand_m2r (mmx_bluemask, mm0);// mm0 = b7b6b5b4b3______ | ||
191 | pxor_r2r (mm4, mm4); // mm4 = 0 | ||
192 | |||
193 | pand_m2r (mmx_greenmask, mm2);// mm2 = g7g6g5g4g3g2____ | ||
194 | psrlq_i2r (3, mm0); // mm0 = ______b7b6b5b4b3 | ||
195 | |||
196 | movq_r2r (mm2, mm7); // mm7 = g7g6g5g4g3g2____ | ||
197 | movq_r2r (mm0, mm5); // mm5 = ______b7b6b5b4b3 | ||
198 | |||
199 | pand_m2r (mmx_redmask, mm1);// mm1 = r7r6r5r4r3______ | ||
200 | punpcklbw_r2r (mm4, mm2); | ||
201 | |||
202 | punpcklbw_r2r (mm1, mm0); | ||
203 | |||
204 | psllq_i2r (3, mm2); | ||
205 | |||
206 | punpckhbw_r2r (mm4, mm7); | ||
207 | por_r2r (mm2, mm0); | ||
208 | |||
209 | psllq_i2r (3, mm7); | ||
210 | |||
211 | movntq (mm0, *image); | ||
212 | punpckhbw_r2r (mm1, mm5); | ||
213 | |||
214 | por_r2r (mm7, mm5); | ||
215 | |||
216 | // U | ||
217 | // V | ||
218 | |||
219 | movntq (mm5, *(image+8)); | ||
220 | } | ||
221 | |||
222 | static inline void mmx_unpack_15rgb (uint8_t * image, int cpu) | ||
223 | { | ||
224 | static mmx_t mmx_bluemask = {0xf8f8f8f8f8f8f8f8}; | ||
225 | static mmx_t mmx_greenmask = {0xf8f8f8f8f8f8f8f8}; | ||
226 | static mmx_t mmx_redmask = {0xf8f8f8f8f8f8f8f8}; | ||
227 | |||
228 | /* | ||
229 | * convert RGB plane to RGB 15 bits | ||
230 | * mm0 -> B, mm1 -> R, mm2 -> G | ||
231 | * mm4 -> GB, mm5 -> AR pixel 4-7 | ||
232 | * mm6 -> GB, mm7 -> AR pixel 0-3 | ||
233 | */ | ||
234 | |||
235 | pand_m2r (mmx_bluemask, mm0);// mm0 = b7b6b5b4b3______ | ||
236 | pxor_r2r (mm4, mm4); // mm4 = 0 | ||
237 | |||
238 | pand_m2r (mmx_greenmask, mm2);// mm2 = g7g6g5g4g3g2____ | ||
239 | psrlq_i2r (3, mm0); // mm0 = ______b7b6b5b4b3 | ||
240 | |||
241 | movq_r2r (mm2, mm7); // mm7 = g7g6g5g4g3g2____ | ||
242 | movq_r2r (mm0, mm5); // mm5 = ______b7b6b5b4b3 | ||
243 | |||
244 | pand_m2r (mmx_redmask, mm1);// mm1 = r7r6r5r4r3______ | ||
245 | punpcklbw_r2r (mm4, mm2); | ||
246 | |||
247 | psrlq_i2r (1, mm1); | ||
248 | punpcklbw_r2r (mm1, mm0); | ||
249 | |||
250 | psllq_i2r (2, mm2); | ||
251 | |||
252 | punpckhbw_r2r (mm4, mm7); | ||
253 | por_r2r (mm2, mm0); | ||
254 | |||
255 | psllq_i2r (2, mm7); | ||
256 | |||
257 | movntq (mm0, *image); | ||
258 | punpckhbw_r2r (mm1, mm5); | ||
259 | |||
260 | por_r2r (mm7, mm5); | ||
261 | |||
262 | // U | ||
263 | // V | ||
264 | |||
265 | movntq (mm5, *(image+8)); | ||
266 | } | ||
267 | |||
268 | static inline void mmx_unpack_32rgb (uint8_t * image, int cpu) | ||
269 | { | ||
270 | /* | ||
271 | * convert RGB plane to RGB packed format, | ||
272 | * mm0 -> B, mm1 -> R, mm2 -> G, mm3 -> 0, | ||
273 | * mm4 -> GB, mm5 -> AR pixel 4-7, | ||
274 | * mm6 -> GB, mm7 -> AR pixel 0-3 | ||
275 | */ | ||
276 | |||
277 | pxor_r2r (mm3, mm3); | ||
278 | movq_r2r (mm0, mm6); | ||
279 | |||
280 | punpcklbw_r2r (mm2, mm6); | ||
281 | movq_r2r (mm1, mm7); | ||
282 | |||
283 | punpcklbw_r2r (mm3, mm7); | ||
284 | movq_r2r (mm0, mm4); | ||
285 | |||
286 | punpcklwd_r2r (mm7, mm6); | ||
287 | movq_r2r (mm1, mm5); | ||
288 | |||
289 | /* scheduling: this is hopeless */ | ||
290 | movntq (mm6, *image); | ||
291 | movq_r2r (mm0, mm6); | ||
292 | punpcklbw_r2r (mm2, mm6); | ||
293 | punpckhwd_r2r (mm7, mm6); | ||
294 | movntq (mm6, *(image+8)); | ||
295 | punpckhbw_r2r (mm2, mm4); | ||
296 | punpckhbw_r2r (mm3, mm5); | ||
297 | punpcklwd_r2r (mm5, mm4); | ||
298 | movntq (mm4, *(image+16)); | ||
299 | movq_r2r (mm0, mm4); | ||
300 | punpckhbw_r2r (mm2, mm4); | ||
301 | punpckhwd_r2r (mm5, mm4); | ||
302 | movntq (mm4, *(image+24)); | ||
303 | } | ||
304 | |||
305 | static inline void mmx_unpack_32bgr (uint8_t * image, int cpu) | ||
306 | { | ||
307 | /* | ||
308 | * convert RGB plane to RGB packed format, | ||
309 | * mm0 -> B, mm1 -> R, mm2 -> G, mm3 -> 0, | ||
310 | * mm4 -> GB, mm5 -> AR pixel 4-7, | ||
311 | * mm6 -> GB, mm7 -> AR pixel 0-3 | ||
312 | */ | ||
313 | |||
314 | pxor_r2r (mm3, mm3); | ||
315 | movq_r2r (mm1, mm6); | ||
316 | |||
317 | punpcklbw_r2r (mm2, mm6); | ||
318 | movq_r2r (mm0, mm7); | ||
319 | |||
320 | punpcklbw_r2r (mm3, mm7); | ||
321 | movq_r2r (mm1, mm4); | ||
322 | |||
323 | punpcklwd_r2r (mm7, mm6); | ||
324 | movq_r2r (mm0, mm5); | ||
325 | |||
326 | /* scheduling: this is hopeless */ | ||
327 | movntq (mm6, *image); | ||
328 | movq_r2r (mm0, mm6); | ||
329 | punpcklbw_r2r (mm2, mm6); | ||
330 | punpckhwd_r2r (mm7, mm6); | ||
331 | movntq (mm6, *(image+8)); | ||
332 | punpckhbw_r2r (mm2, mm4); | ||
333 | punpckhbw_r2r (mm3, mm5); | ||
334 | punpcklwd_r2r (mm5, mm4); | ||
335 | movntq (mm4, *(image+16)); | ||
336 | movq_r2r (mm0, mm4); | ||
337 | punpckhbw_r2r (mm2, mm4); | ||
338 | punpckhwd_r2r (mm5, mm4); | ||
339 | movntq (mm4, *(image+24)); | ||
340 | } | ||
341 | |||
342 | static inline void mmx_unpack_24rgb (uint8_t * image, int cpu) | ||
343 | { | ||
344 | /* | ||
345 | * convert RGB plane to RGB packed format, | ||
346 | * mm0 -> B, mm1 -> R, mm2 -> G, mm3 -> 0, | ||
347 | * mm4 -> GB, mm5 -> AR pixel 4-7, | ||
348 | * mm6 -> GB, mm7 -> AR pixel 0-3 | ||
349 | */ | ||
350 | |||
351 | pxor_r2r (mm3, mm3); | ||
352 | movq_r2r (mm0, mm6); | ||
353 | |||
354 | punpcklbw_r2r (mm2, mm6); | ||
355 | movq_r2r (mm1, mm7); | ||
356 | |||
357 | punpcklbw_r2r (mm3, mm7); | ||
358 | movq_r2r (mm0, mm4); | ||
359 | |||
360 | punpcklwd_r2r (mm7, mm6); | ||
361 | movq_r2r (mm1, mm5); | ||
362 | |||
363 | /* scheduling: this is hopeless */ | ||
364 | movntq (mm6, *image); | ||
365 | movq_r2r (mm0, mm6); | ||
366 | punpcklbw_r2r (mm2, mm6); | ||
367 | punpckhwd_r2r (mm7, mm6); | ||
368 | movntq (mm6, *(image+8)); | ||
369 | punpckhbw_r2r (mm2, mm4); | ||
370 | punpckhbw_r2r (mm3, mm5); | ||
371 | punpcklwd_r2r (mm5, mm4); | ||
372 | movntq (mm4, *(image+16)); | ||
373 | } | ||
374 | |||
375 | static inline void yuv420_rgb16 (yuv2rgb_t *this, | ||
376 | uint8_t * image, | ||
377 | uint8_t * py, uint8_t * pu, uint8_t * pv, | ||
378 | int cpu) | ||
379 | { | ||
380 | int i; | ||
381 | int rgb_stride = this->rgb_stride; | ||
382 | int y_stride = this->y_stride; | ||
383 | int uv_stride = this->uv_stride; | ||
384 | int width = this->source_width; | ||
385 | int height = this->source_height; | ||
386 | int dst_height = this->dest_height; | ||
387 | uint8_t *img; | ||
388 | |||
389 | width >>= 3; | ||
390 | |||
391 | if (!this->do_scale) { | ||
392 | y_stride -= 8 * width; | ||
393 | uv_stride -= 4 * width; | ||
394 | |||
395 | do { | ||
396 | |||
397 | i = width; img = image; | ||
398 | do { | ||
399 | mmx_yuv2rgb (py, pu, pv); | ||
400 | mmx_unpack_16rgb (img, cpu); | ||
401 | py += 8; | ||
402 | pu += 4; | ||
403 | pv += 4; | ||
404 | img += 16; | ||
405 | } while (--i); | ||
406 | |||
407 | py += y_stride; | ||
408 | image += rgb_stride; | ||
409 | if (height & 1) { | ||
410 | pu += uv_stride; | ||
411 | pv += uv_stride; | ||
412 | } else { | ||
413 | pu -= 4 * width; | ||
414 | pv -= 4 * width; | ||
415 | } | ||
416 | } while (--height); | ||
417 | |||
418 | } else { | ||
419 | |||
420 | scale_line_func_t scale_line = this->scale_line; | ||
421 | uint8_t *y_buf, *u_buf, *v_buf; | ||
422 | int dy = 0; | ||
423 | |||
424 | scale_line (pu, this->u_buffer, | ||
425 | this->dest_width >> 1, this->step_dx); | ||
426 | scale_line (pv, this->v_buffer, | ||
427 | this->dest_width >> 1, this->step_dx); | ||
428 | scale_line (py, this->y_buffer, | ||
429 | this->dest_width, this->step_dx); | ||
430 | for (height = 0;; ) { | ||
431 | |||
432 | y_buf = this->y_buffer; | ||
433 | u_buf = this->u_buffer; | ||
434 | v_buf = this->v_buffer; | ||
435 | |||
436 | i = this->dest_width >> 3; img = image; | ||
437 | do { | ||
438 | /* printf ("i : %d\n",i); */ | ||
439 | |||
440 | mmx_yuv2rgb (y_buf, u_buf, v_buf); | ||
441 | mmx_unpack_16rgb (img, cpu); | ||
442 | y_buf += 8; | ||
443 | u_buf += 4; | ||
444 | v_buf += 4; | ||
445 | img += 16; | ||
446 | } while (--i); | ||
447 | |||
448 | dy += this->step_dy; | ||
449 | image += rgb_stride; | ||
450 | |||
451 | while (--dst_height > 0 && dy < 32768) { | ||
452 | |||
453 | xine_fast_memcpy (image, image-rgb_stride, this->dest_width*2); | ||
454 | |||
455 | dy += this->step_dy; | ||
456 | image += rgb_stride; | ||
457 | } | ||
458 | |||
459 | if (dst_height <= 0) | ||
460 | break; | ||
461 | |||
462 | do { | ||
463 | dy -= 32768; | ||
464 | |||
465 | py += y_stride; | ||
466 | |||
467 | scale_line (py, this->y_buffer, | ||
468 | this->dest_width, this->step_dx); | ||
469 | |||
470 | if (height & 1) { | ||
471 | pu += uv_stride; | ||
472 | pv += uv_stride; | ||
473 | |||
474 | scale_line (pu, this->u_buffer, | ||
475 | this->dest_width >> 1, this->step_dx); | ||
476 | scale_line (pv, this->v_buffer, | ||
477 | this->dest_width >> 1, this->step_dx); | ||
478 | |||
479 | } | ||
480 | height++; | ||
481 | } while( dy>=32768); | ||
482 | } | ||
483 | } | ||
484 | } | ||
485 | |||
486 | static inline void yuv420_rgb15 (yuv2rgb_t *this, | ||
487 | uint8_t * image, | ||
488 | uint8_t * py, uint8_t * pu, uint8_t * pv, | ||
489 | int cpu) | ||
490 | { | ||
491 | int i; | ||
492 | int rgb_stride = this->rgb_stride; | ||
493 | int y_stride = this->y_stride; | ||
494 | int uv_stride = this->uv_stride; | ||
495 | int width = this->source_width; | ||
496 | int height = this->source_height; | ||
497 | int dst_height = this->dest_height; | ||
498 | uint8_t *img; | ||
499 | |||
500 | width >>= 3; | ||
501 | |||
502 | if (!this->do_scale) { | ||
503 | y_stride -= 8 * width; | ||
504 | uv_stride -= 4 * width; | ||
505 | |||
506 | do { | ||
507 | |||
508 | i = width; img = image; | ||
509 | do { | ||
510 | mmx_yuv2rgb (py, pu, pv); | ||
511 | mmx_unpack_15rgb (img, cpu); | ||
512 | py += 8; | ||
513 | pu += 4; | ||
514 | pv += 4; | ||
515 | img += 16; | ||
516 | } while (--i); | ||
517 | |||
518 | py += y_stride; | ||
519 | image += rgb_stride; | ||
520 | if (height & 1) { | ||
521 | pu += uv_stride; | ||
522 | pv += uv_stride; | ||
523 | } else { | ||
524 | pu -= 4 * width; | ||
525 | pv -= 4 * width; | ||
526 | } | ||
527 | } while (--height); | ||
528 | |||
529 | } else { | ||
530 | |||
531 | scale_line_func_t scale_line = this->scale_line; | ||
532 | uint8_t *y_buf, *u_buf, *v_buf; | ||
533 | int dy = 0; | ||
534 | |||
535 | scale_line (pu, this->u_buffer, | ||
536 | this->dest_width >> 1, this->step_dx); | ||
537 | scale_line (pv, this->v_buffer, | ||
538 | this->dest_width >> 1, this->step_dx); | ||
539 | scale_line (py, this->y_buffer, | ||
540 | this->dest_width, this->step_dx); | ||
541 | for (height = 0;; ) { | ||
542 | |||
543 | y_buf = this->y_buffer; | ||
544 | u_buf = this->u_buffer; | ||
545 | v_buf = this->v_buffer; | ||
546 | |||
547 | i = this->dest_width >> 3; img = image; | ||
548 | do { | ||
549 | /* printf ("i : %d\n",i); */ | ||
550 | |||
551 | mmx_yuv2rgb (y_buf, u_buf, v_buf); | ||
552 | mmx_unpack_15rgb (img, cpu); | ||
553 | y_buf += 8; | ||
554 | u_buf += 4; | ||
555 | v_buf += 4; | ||
556 | img += 16; | ||
557 | } while (--i); | ||
558 | |||
559 | dy += this->step_dy; | ||
560 | image += rgb_stride; | ||
561 | |||
562 | while (--dst_height > 0 && dy < 32768) { | ||
563 | |||
564 | xine_fast_memcpy (image, image-rgb_stride, this->dest_width*2); | ||
565 | |||
566 | dy += this->step_dy; | ||
567 | image += rgb_stride; | ||
568 | } | ||
569 | |||
570 | if (dst_height <= 0) | ||
571 | break; | ||
572 | |||
573 | do { | ||
574 | dy -= 32768; | ||
575 | py += y_stride; | ||
576 | |||
577 | scale_line (py, this->y_buffer, | ||
578 | this->dest_width, this->step_dx); | ||
579 | |||
580 | if (height & 1) { | ||
581 | pu += uv_stride; | ||
582 | pv += uv_stride; | ||
583 | |||
584 | scale_line (pu, this->u_buffer, | ||
585 | this->dest_width >> 1, this->step_dx); | ||
586 | scale_line (pv, this->v_buffer, | ||
587 | this->dest_width >> 1, this->step_dx); | ||
588 | |||
589 | } | ||
590 | height++; | ||
591 | } while( dy>=32768 ); | ||
592 | } | ||
593 | } | ||
594 | } | ||
595 | |||
596 | static inline void yuv420_rgb24 (yuv2rgb_t *this, | ||
597 | uint8_t * image, uint8_t * py, | ||
598 | uint8_t * pu, uint8_t * pv, int cpu) | ||
599 | { | ||
600 | int i; | ||
601 | int rgb_stride = this->rgb_stride; | ||
602 | int y_stride = this->y_stride; | ||
603 | int uv_stride = this->uv_stride; | ||
604 | int width = this->source_width; | ||
605 | int height = this->source_height; | ||
606 | int dst_height = this->dest_height; | ||
607 | uint8_t *img; | ||
608 | |||
609 | /* rgb_stride -= 4 * this->dest_width; */ | ||
610 | width >>= 3; | ||
611 | |||
612 | if (!this->do_scale) { | ||
613 | y_stride -= 8 * width; | ||
614 | uv_stride -= 4 * width; | ||
615 | |||
616 | do { | ||
617 | i = width; img = image; | ||
618 | do { | ||
619 | mmx_yuv2rgb (py, pu, pv); | ||
620 | mmx_unpack_24rgb (img, cpu); | ||
621 | py += 8; | ||
622 | pu += 4; | ||
623 | pv += 4; | ||
624 | img += 24; | ||
625 | } while (--i); | ||
626 | |||
627 | py += y_stride; | ||
628 | image += rgb_stride; | ||
629 | if (height & 1) { | ||
630 | pu += uv_stride; | ||
631 | pv += uv_stride; | ||
632 | } else { | ||
633 | pu -= 4 * width; | ||
634 | pv -= 4 * width; | ||
635 | } | ||
636 | } while (--height); | ||
637 | } else { | ||
638 | |||
639 | scale_line_func_t scale_line = this->scale_line; | ||
640 | uint8_t *y_buf, *u_buf, *v_buf; | ||
641 | int dy = 0; | ||
642 | |||
643 | scale_line (pu, this->u_buffer, | ||
644 | this->dest_width >> 1, this->step_dx); | ||
645 | scale_line (pv, this->v_buffer, | ||
646 | this->dest_width >> 1, this->step_dx); | ||
647 | scale_line (py, this->y_buffer, | ||
648 | this->dest_width, this->step_dx); | ||
649 | |||
650 | for (height = 0;; ) { | ||
651 | |||
652 | y_buf = this->y_buffer; | ||
653 | u_buf = this->u_buffer; | ||
654 | v_buf = this->v_buffer; | ||
655 | |||
656 | |||
657 | i = this->dest_width >> 3; img=image; | ||
658 | do { | ||
659 | /* printf ("i : %d\n",i); */ | ||
660 | |||
661 | mmx_yuv2rgb (y_buf, u_buf, v_buf); | ||
662 | mmx_unpack_24rgb (img, cpu); | ||
663 | y_buf += 8; | ||
664 | u_buf += 4; | ||
665 | v_buf += 4; | ||
666 | img += 24; | ||
667 | } while (--i); | ||
668 | |||
669 | dy += this->step_dy; | ||
670 | image += rgb_stride; | ||
671 | |||
672 | while (--dst_height > 0 && dy < 32768) { | ||
673 | |||
674 | xine_fast_memcpy (image, image-rgb_stride, this->dest_width*3); | ||
675 | |||
676 | dy += this->step_dy; | ||
677 | image += rgb_stride; | ||
678 | } | ||
679 | |||
680 | if (dst_height <= 0) | ||
681 | break; | ||
682 | |||
683 | do { | ||
684 | dy -= 32768; | ||
685 | py += y_stride; | ||
686 | |||
687 | scale_line (py, this->y_buffer, | ||
688 | this->dest_width, this->step_dx); | ||
689 | |||
690 | if (height & 1) { | ||
691 | pu += uv_stride; | ||
692 | pv += uv_stride; | ||
693 | |||
694 | scale_line (pu, this->u_buffer, | ||
695 | this->dest_width >> 1, this->step_dx); | ||
696 | scale_line (pv, this->v_buffer, | ||
697 | this->dest_width >> 1, this->step_dx); | ||
698 | } | ||
699 | height++; | ||
700 | } while( dy>=32768 ); | ||
701 | |||
702 | } | ||
703 | |||
704 | } | ||
705 | } | ||
706 | |||
707 | static inline void yuv420_argb32 (yuv2rgb_t *this, | ||
708 | uint8_t * image, uint8_t * py, | ||
709 | uint8_t * pu, uint8_t * pv, int cpu) | ||
710 | { | ||
711 | int i; | ||
712 | int rgb_stride = this->rgb_stride; | ||
713 | int y_stride = this->y_stride; | ||
714 | int uv_stride = this->uv_stride; | ||
715 | int width = this->source_width; | ||
716 | int height = this->source_height; | ||
717 | int dst_height = this->dest_height; | ||
718 | uint8_t *img; | ||
719 | |||
720 | /* rgb_stride -= 4 * this->dest_width; */ | ||
721 | width >>= 3; | ||
722 | |||
723 | if (!this->do_scale) { | ||
724 | y_stride -= 8 * width; | ||
725 | uv_stride -= 4 * width; | ||
726 | |||
727 | do { | ||
728 | i = width; img = image; | ||
729 | do { | ||
730 | mmx_yuv2rgb (py, pu, pv); | ||
731 | mmx_unpack_32rgb (img, cpu); | ||
732 | py += 8; | ||
733 | pu += 4; | ||
734 | pv += 4; | ||
735 | img += 32; | ||
736 | } while (--i); | ||
737 | |||
738 | py += y_stride; | ||
739 | image += rgb_stride; | ||
740 | if (height & 1) { | ||
741 | pu += uv_stride; | ||
742 | pv += uv_stride; | ||
743 | } else { | ||
744 | pu -= 4 * width; | ||
745 | pv -= 4 * width; | ||
746 | } | ||
747 | } while (--height); | ||
748 | } else { | ||
749 | |||
750 | scale_line_func_t scale_line = this->scale_line; | ||
751 | uint8_t *y_buf, *u_buf, *v_buf; | ||
752 | int dy = 0; | ||
753 | |||
754 | scale_line (pu, this->u_buffer, | ||
755 | this->dest_width >> 1, this->step_dx); | ||
756 | scale_line (pv, this->v_buffer, | ||
757 | this->dest_width >> 1, this->step_dx); | ||
758 | scale_line (py, this->y_buffer, | ||
759 | this->dest_width, this->step_dx); | ||
760 | |||
761 | for (height = 0;; ) { | ||
762 | |||
763 | y_buf = this->y_buffer; | ||
764 | u_buf = this->u_buffer; | ||
765 | v_buf = this->v_buffer; | ||
766 | |||
767 | |||
768 | i = this->dest_width >> 3; img=image; | ||
769 | do { | ||
770 | /* printf ("i : %d\n",i); */ | ||
771 | |||
772 | mmx_yuv2rgb (y_buf, u_buf, v_buf); | ||
773 | mmx_unpack_32rgb (img, cpu); | ||
774 | y_buf += 8; | ||
775 | u_buf += 4; | ||
776 | v_buf += 4; | ||
777 | img += 32; | ||
778 | } while (--i); | ||
779 | |||
780 | dy += this->step_dy; | ||
781 | image += rgb_stride; | ||
782 | |||
783 | while (--dst_height > 0 && dy < 32768) { | ||
784 | |||
785 | xine_fast_memcpy (image, image-rgb_stride, this->dest_width*4); | ||
786 | |||
787 | dy += this->step_dy; | ||
788 | image += rgb_stride; | ||
789 | } | ||
790 | |||
791 | if (dst_height <= 0) | ||
792 | break; | ||
793 | |||
794 | do { | ||
795 | dy -= 32768; | ||
796 | py += y_stride; | ||
797 | |||
798 | scale_line (py, this->y_buffer, | ||
799 | this->dest_width, this->step_dx); | ||
800 | |||
801 | if (height & 1) { | ||
802 | pu += uv_stride; | ||
803 | pv += uv_stride; | ||
804 | |||
805 | scale_line (pu, this->u_buffer, | ||
806 | this->dest_width >> 1, this->step_dx); | ||
807 | scale_line (pv, this->v_buffer, | ||
808 | this->dest_width >> 1, this->step_dx); | ||
809 | } | ||
810 | height++; | ||
811 | } while( dy>=32768 ); | ||
812 | } | ||
813 | |||
814 | } | ||
815 | } | ||
816 | |||
817 | static inline void yuv420_abgr32 (yuv2rgb_t *this, | ||
818 | uint8_t * image, uint8_t * py, | ||
819 | uint8_t * pu, uint8_t * pv, int cpu) | ||
820 | { | ||
821 | int i; | ||
822 | int rgb_stride = this->rgb_stride; | ||
823 | int y_stride = this->y_stride; | ||
824 | int uv_stride = this->uv_stride; | ||
825 | int width = this->source_width; | ||
826 | int height = this->source_height; | ||
827 | int dst_height = this->dest_height; | ||
828 | uint8_t *img; | ||
829 | |||
830 | /* rgb_stride -= 4 * this->dest_width; */ | ||
831 | width >>= 3; | ||
832 | |||
833 | if (!this->do_scale) { | ||
834 | y_stride -= 8 * width; | ||
835 | uv_stride -= 4 * width; | ||
836 | |||
837 | do { | ||
838 | i = width; img = image; | ||
839 | do { | ||
840 | mmx_yuv2rgb (py, pu, pv); | ||
841 | mmx_unpack_32bgr (img, cpu); | ||
842 | py += 8; | ||
843 | pu += 4; | ||
844 | pv += 4; | ||
845 | img += 32; | ||
846 | } while (--i); | ||
847 | |||
848 | py += y_stride; | ||
849 | image += rgb_stride; | ||
850 | if (height & 1) { | ||
851 | pu += uv_stride; | ||
852 | pv += uv_stride; | ||
853 | } else { | ||
854 | pu -= 4 * width; | ||
855 | pv -= 4 * width; | ||
856 | } | ||
857 | } while (--height); | ||
858 | } else { | ||
859 | |||
860 | scale_line_func_t scale_line = this->scale_line; | ||
861 | uint8_t *y_buf, *u_buf, *v_buf; | ||
862 | int dy = 0; | ||
863 | |||
864 | scale_line (pu, this->u_buffer, | ||
865 | this->dest_width >> 1, this->step_dx); | ||
866 | scale_line (pv, this->v_buffer, | ||
867 | this->dest_width >> 1, this->step_dx); | ||
868 | scale_line (py, this->y_buffer, | ||
869 | this->dest_width, this->step_dx); | ||
870 | |||
871 | for (height = 0;; ) { | ||
872 | |||
873 | y_buf = this->y_buffer; | ||
874 | u_buf = this->u_buffer; | ||
875 | v_buf = this->v_buffer; | ||
876 | |||
877 | |||
878 | i = this->dest_width >> 3; img=image; | ||
879 | do { | ||
880 | /* printf ("i : %d\n",i); */ | ||
881 | |||
882 | mmx_yuv2rgb (y_buf, u_buf, v_buf); | ||
883 | mmx_unpack_32bgr (img, cpu); | ||
884 | y_buf += 8; | ||
885 | u_buf += 4; | ||
886 | v_buf += 4; | ||
887 | img += 32; | ||
888 | } while (--i); | ||
889 | |||
890 | dy += this->step_dy; | ||
891 | image += rgb_stride; | ||
892 | |||
893 | while (--dst_height > 0 && dy < 32768) { | ||
894 | |||
895 | xine_fast_memcpy (image, image-rgb_stride, this->dest_width*4); | ||
896 | |||
897 | dy += this->step_dy; | ||
898 | image += rgb_stride; | ||
899 | } | ||
900 | |||
901 | if (dst_height <= 0) | ||
902 | break; | ||
903 | |||
904 | do { | ||
905 | dy -= 32768; | ||
906 | py += y_stride; | ||
907 | |||
908 | scale_line (py, this->y_buffer, | ||
909 | this->dest_width, this->step_dx); | ||
910 | |||
911 | if (height & 1) { | ||
912 | pu += uv_stride; | ||
913 | pv += uv_stride; | ||
914 | |||
915 | scale_line (pu, this->u_buffer, | ||
916 | this->dest_width >> 1, this->step_dx); | ||
917 | scale_line (pv, this->v_buffer, | ||
918 | this->dest_width >> 1, this->step_dx); | ||
919 | } | ||
920 | height++; | ||
921 | } while( dy>=32768 ); | ||
922 | |||
923 | } | ||
924 | |||
925 | } | ||
926 | } | ||
927 | |||
928 | static void mmxext_rgb15 (yuv2rgb_t *this, uint8_t * image, | ||
929 | uint8_t * py, uint8_t * pu, uint8_t * pv) | ||
930 | { | ||
931 | yuv420_rgb15 (this, image, py, pu, pv, CPU_MMXEXT); | ||
932 | emms();/* re-initialize x86 FPU after MMX use */ | ||
933 | } | ||
934 | |||
935 | static void mmxext_rgb16 (yuv2rgb_t *this, uint8_t * image, | ||
936 | uint8_t * py, uint8_t * pu, uint8_t * pv) | ||
937 | { | ||
938 | yuv420_rgb16 (this, image, py, pu, pv, CPU_MMXEXT); | ||
939 | emms();/* re-initialize x86 FPU after MMX use */ | ||
940 | } | ||
941 | |||
942 | static void mmxext_rgb24 (yuv2rgb_t *this, uint8_t * image, | ||
943 | uint8_t * py, uint8_t * pu, uint8_t * pv) | ||
944 | { | ||
945 | yuv420_rgb24 (this, image, py, pu, pv, CPU_MMXEXT); | ||
946 | emms();/* re-initialize x86 FPU after MMX use */ | ||
947 | } | ||
948 | |||
949 | static void mmxext_argb32 (yuv2rgb_t *this, uint8_t * image, | ||
950 | uint8_t * py, uint8_t * pu, uint8_t * pv) | ||
951 | { | ||
952 | yuv420_argb32 (this, image, py, pu, pv, CPU_MMXEXT); | ||
953 | emms();/* re-initialize x86 FPU after MMX use */ | ||
954 | } | ||
955 | |||
956 | static void mmxext_abgr32 (yuv2rgb_t *this, uint8_t * image, | ||
957 | uint8_t * py, uint8_t * pu, uint8_t * pv) | ||
958 | { | ||
959 | yuv420_abgr32 (this, image, py, pu, pv, CPU_MMXEXT); | ||
960 | emms();/* re-initialize x86 FPU after MMX use */ | ||
961 | } | ||
962 | |||
963 | static void mmx_rgb15 (yuv2rgb_t *this, uint8_t * image, | ||
964 | uint8_t * py, uint8_t * pu, uint8_t * pv) | ||
965 | { | ||
966 | yuv420_rgb15 (this, image, py, pu, pv, CPU_MMX); | ||
967 | emms();/* re-initialize x86 FPU after MMX use */ | ||
968 | } | ||
969 | |||
970 | static void mmx_rgb16 (yuv2rgb_t *this, uint8_t * image, | ||
971 | uint8_t * py, uint8_t * pu, uint8_t * pv) | ||
972 | { | ||
973 | yuv420_rgb16 (this, image, py, pu, pv, CPU_MMX); | ||
974 | emms();/* re-initialize x86 FPU after MMX use */ | ||
975 | } | ||
976 | |||
977 | static void mmx_rgb24 (yuv2rgb_t *this, uint8_t * image, | ||
978 | uint8_t * py, uint8_t * pu, uint8_t * pv) | ||
979 | { | ||
980 | yuv420_rgb24 (this, image, py, pu, pv, CPU_MMX); | ||
981 | emms();/* re-initialize x86 FPU after MMX use */ | ||
982 | } | ||
983 | |||
984 | static void mmx_argb32 (yuv2rgb_t *this, uint8_t * image, | ||
985 | uint8_t * py, uint8_t * pu, uint8_t * pv) | ||
986 | { | ||
987 | yuv420_argb32 (this, image, py, pu, pv, CPU_MMX); | ||
988 | emms();/* re-initialize x86 FPU after MMX use */ | ||
989 | } | ||
990 | |||
991 | static void mmx_abgr32 (yuv2rgb_t *this, uint8_t * image, | ||
992 | uint8_t * py, uint8_t * pu, uint8_t * pv) | ||
993 | { | ||
994 | yuv420_abgr32 (this, image, py, pu, pv, CPU_MMX); | ||
995 | emms();/* re-initialize x86 FPU after MMX use */ | ||
996 | } | ||
997 | |||
998 | void yuv2rgb_init_mmxext (yuv2rgb_factory_t *this) { | ||
999 | |||
1000 | if (this->swapped) | ||
1001 | return; /*no swapped pixel output upto now*/ | ||
1002 | |||
1003 | switch (this->mode) { | ||
1004 | case MODE_15_RGB: | ||
1005 | this->yuv2rgb_fun = mmxext_rgb15; | ||
1006 | break; | ||
1007 | case MODE_16_RGB: | ||
1008 | this->yuv2rgb_fun = mmxext_rgb16; | ||
1009 | break; | ||
1010 | case MODE_24_RGB: | ||
1011 | this->yuv2rgb_fun = mmxext_rgb24; | ||
1012 | break; | ||
1013 | case MODE_32_RGB: | ||
1014 | this->yuv2rgb_fun = mmxext_argb32; | ||
1015 | break; | ||
1016 | case MODE_32_BGR: | ||
1017 | this->yuv2rgb_fun = mmxext_abgr32; | ||
1018 | break; | ||
1019 | } | ||
1020 | } | ||
1021 | |||
1022 | void yuv2rgb_init_mmx (yuv2rgb_factory_t *this) { | ||
1023 | |||
1024 | if (this->swapped) | ||
1025 | return; /*no swapped pixel output upto now*/ | ||
1026 | |||
1027 | switch (this->mode) { | ||
1028 | case MODE_15_RGB: | ||
1029 | this->yuv2rgb_fun = mmx_rgb15; | ||
1030 | break; | ||
1031 | case MODE_16_RGB: | ||
1032 | this->yuv2rgb_fun = mmx_rgb16; | ||
1033 | break; | ||
1034 | case MODE_24_RGB: | ||
1035 | this->yuv2rgb_fun = mmx_rgb24; | ||
1036 | break; | ||
1037 | case MODE_32_RGB: | ||
1038 | this->yuv2rgb_fun = mmx_argb32; | ||
1039 | break; | ||
1040 | case MODE_32_BGR: | ||
1041 | this->yuv2rgb_fun = mmx_abgr32; | ||
1042 | break; | ||
1043 | } | ||
1044 | } | ||
1045 | |||
1046 | |||
1047 | #endif | ||