Mercurial > mplayer.hg
comparison postproc/rgb2rgb_template.c @ 13423:7f5ea5da1765
lot of bigendian fixes
author | alex |
---|---|
date | Tue, 21 Sep 2004 17:23:49 +0000 |
parents | 8953c51668e1 |
children | 821f464b4d90 |
comparison
equal
deleted
inserted
replaced
13422:4971840361a5 | 13423:7f5ea5da1765 |
---|---|
4 * pluralize by Software PAL8 to RGB convertor | 4 * pluralize by Software PAL8 to RGB convertor |
5 * Software YUV to YUV convertor | 5 * Software YUV to YUV convertor |
6 * Software YUV to RGB convertor | 6 * Software YUV to RGB convertor |
7 * Written by Nick Kurshev. | 7 * Written by Nick Kurshev. |
8 * palette & yuv & runtime cpu stuff by Michael (michaelni@gmx.at) (under GPL) | 8 * palette & yuv & runtime cpu stuff by Michael (michaelni@gmx.at) (under GPL) |
9 * lot of big-endian byteorder fixes by Alex Beregszaszi | |
9 */ | 10 */ |
10 | 11 |
11 #include <stddef.h> | 12 #include <stddef.h> |
12 #include <inttypes.h> /* for __WORDSIZE */ | 13 #include <inttypes.h> /* for __WORDSIZE */ |
13 | 14 |
100 __asm __volatile(SFENCE:::"memory"); | 101 __asm __volatile(SFENCE:::"memory"); |
101 __asm __volatile(EMMS:::"memory"); | 102 __asm __volatile(EMMS:::"memory"); |
102 #endif | 103 #endif |
103 while(s < end) | 104 while(s < end) |
104 { | 105 { |
106 #ifdef WORDS_BIGENDIAN | |
107 *dest++ = 0; | |
108 *dest++ = *s++; | |
109 *dest++ = *s++; | |
110 *dest++ = *s++; | |
111 #else | |
105 *dest++ = *s++; | 112 *dest++ = *s++; |
106 *dest++ = *s++; | 113 *dest++ = *s++; |
107 *dest++ = *s++; | 114 *dest++ = *s++; |
108 *dest++ = 0; | 115 *dest++ = 0; |
116 #endif | |
109 } | 117 } |
110 } | 118 } |
111 | 119 |
112 static inline void RENAME(rgb32to24)(const uint8_t *src,uint8_t *dst,unsigned src_size) | 120 static inline void RENAME(rgb32to24)(const uint8_t *src,uint8_t *dst,unsigned src_size) |
113 { | 121 { |
177 __asm __volatile(SFENCE:::"memory"); | 185 __asm __volatile(SFENCE:::"memory"); |
178 __asm __volatile(EMMS:::"memory"); | 186 __asm __volatile(EMMS:::"memory"); |
179 #endif | 187 #endif |
180 while(s < end) | 188 while(s < end) |
181 { | 189 { |
190 #ifdef WORDS_BIGENDIAN | |
191 s++; | |
192 *dest++ = *s++; | |
193 *dest++ = *s++; | |
194 *dest++ = *s++; | |
195 #else | |
182 *dest++ = *s++; | 196 *dest++ = *s++; |
183 *dest++ = *s++; | 197 *dest++ = *s++; |
184 *dest++ = *s++; | 198 *dest++ = *s++; |
185 s++; | 199 s++; |
200 #endif | |
186 } | 201 } |
187 } | 202 } |
188 | 203 |
189 /* | 204 /* |
190 Original by Strepto/Astral | 205 Original by Strepto/Astral |
386 __asm __volatile(SFENCE:::"memory"); | 401 __asm __volatile(SFENCE:::"memory"); |
387 __asm __volatile(EMMS:::"memory"); | 402 __asm __volatile(EMMS:::"memory"); |
388 #endif | 403 #endif |
389 while(s < end) | 404 while(s < end) |
390 { | 405 { |
406 // FIXME on bigendian | |
391 const int src= *s; s += 4; | 407 const int src= *s; s += 4; |
392 *d++ = ((src&0xFF)>>3) + ((src&0xFC00)>>5) + ((src&0xF80000)>>8); | 408 *d++ = ((src&0xFF)>>3) + ((src&0xFC00)>>5) + ((src&0xF80000)>>8); |
393 // *d++ = ((src>>3)&0x1F) + ((src>>5)&0x7E0) + ((src>>8)&0xF800); | 409 // *d++ = ((src>>3)&0x1F) + ((src>>5)&0x7E0) + ((src>>8)&0xF800); |
394 } | 410 } |
395 } | 411 } |
448 __asm __volatile(SFENCE:::"memory"); | 464 __asm __volatile(SFENCE:::"memory"); |
449 __asm __volatile(EMMS:::"memory"); | 465 __asm __volatile(EMMS:::"memory"); |
450 #endif | 466 #endif |
451 while(s < end) | 467 while(s < end) |
452 { | 468 { |
469 // FIXME on bigendian | |
453 const int src= *s; s += 4; | 470 const int src= *s; s += 4; |
454 *d++ = ((src&0xF8)<<8) + ((src&0xFC00)>>5) + ((src&0xF80000)>>19); | 471 *d++ = ((src&0xF8)<<8) + ((src&0xFC00)>>5) + ((src&0xF80000)>>19); |
455 } | 472 } |
456 } | 473 } |
457 | 474 |
544 __asm __volatile(SFENCE:::"memory"); | 561 __asm __volatile(SFENCE:::"memory"); |
545 __asm __volatile(EMMS:::"memory"); | 562 __asm __volatile(EMMS:::"memory"); |
546 #endif | 563 #endif |
547 while(s < end) | 564 while(s < end) |
548 { | 565 { |
566 // FIXME on bigendian | |
549 const int src= *s; s += 4; | 567 const int src= *s; s += 4; |
550 *d++ = ((src&0xFF)>>3) + ((src&0xF800)>>6) + ((src&0xF80000)>>9); | 568 *d++ = ((src&0xFF)>>3) + ((src&0xF800)>>6) + ((src&0xF80000)>>9); |
551 } | 569 } |
552 } | 570 } |
553 | 571 |
605 __asm __volatile(SFENCE:::"memory"); | 623 __asm __volatile(SFENCE:::"memory"); |
606 __asm __volatile(EMMS:::"memory"); | 624 __asm __volatile(EMMS:::"memory"); |
607 #endif | 625 #endif |
608 while(s < end) | 626 while(s < end) |
609 { | 627 { |
628 // FIXME on bigendian | |
610 const int src= *s; s += 4; | 629 const int src= *s; s += 4; |
611 *d++ = ((src&0xF8)<<7) + ((src&0xF800)>>6) + ((src&0xF80000)>>19); | 630 *d++ = ((src&0xF8)<<7) + ((src&0xF800)>>6) + ((src&0xF80000)>>19); |
612 } | 631 } |
613 } | 632 } |
614 | 633 |
1231 *((uint32_t*)d)++ = ((bgr&0x1F)<<3) + ((bgr&0x3E0)<<6) + ((bgr&0x7C00)<<9); | 1250 *((uint32_t*)d)++ = ((bgr&0x1F)<<3) + ((bgr&0x3E0)<<6) + ((bgr&0x7C00)<<9); |
1232 #else | 1251 #else |
1233 //FIXME this is very likely wrong for bigendian (and the following converters too) | 1252 //FIXME this is very likely wrong for bigendian (and the following converters too) |
1234 register uint16_t bgr; | 1253 register uint16_t bgr; |
1235 bgr = *s++; | 1254 bgr = *s++; |
1255 #ifdef WORDS_BIGENDIAN | |
1256 *d++ = 0; | |
1257 *d++ = (bgr&0x1F)<<3; | |
1258 *d++ = (bgr&0x3E0)>>2; | |
1259 *d++ = (bgr&0x7C00)>>7; | |
1260 #else | |
1236 *d++ = (bgr&0x1F)<<3; | 1261 *d++ = (bgr&0x1F)<<3; |
1237 *d++ = (bgr&0x3E0)>>2; | 1262 *d++ = (bgr&0x3E0)>>2; |
1238 *d++ = (bgr&0x7C00)>>7; | 1263 *d++ = (bgr&0x7C00)>>7; |
1239 *d++ = 0; | 1264 *d++ = 0; |
1265 #endif | |
1266 | |
1240 #endif | 1267 #endif |
1241 } | 1268 } |
1242 } | 1269 } |
1243 | 1270 |
1244 static inline void RENAME(rgb16to32)(const uint8_t *src, uint8_t *dst, unsigned src_size) | 1271 static inline void RENAME(rgb16to32)(const uint8_t *src, uint8_t *dst, unsigned src_size) |
1297 #endif | 1324 #endif |
1298 while(s < end) | 1325 while(s < end) |
1299 { | 1326 { |
1300 register uint16_t bgr; | 1327 register uint16_t bgr; |
1301 bgr = *s++; | 1328 bgr = *s++; |
1329 #ifdef WORDS_BIGENDIAN | |
1330 *d++ = 0; | |
1331 *d++ = (bgr&0x1F)<<3; | |
1332 *d++ = (bgr&0x7E0)>>3; | |
1333 *d++ = (bgr&0xF800)>>8; | |
1334 #else | |
1302 *d++ = (bgr&0x1F)<<3; | 1335 *d++ = (bgr&0x1F)<<3; |
1303 *d++ = (bgr&0x7E0)>>3; | 1336 *d++ = (bgr&0x7E0)>>3; |
1304 *d++ = (bgr&0xF800)>>8; | 1337 *d++ = (bgr&0xF800)>>8; |
1305 *d++ = 0; | 1338 *d++ = 0; |
1339 #endif | |
1306 } | 1340 } |
1307 } | 1341 } |
1308 | 1342 |
1309 static inline void RENAME(rgb32tobgr32)(const uint8_t *src, uint8_t *dst, unsigned int src_size) | 1343 static inline void RENAME(rgb32tobgr32)(const uint8_t *src, uint8_t *dst, unsigned int src_size) |
1310 { | 1344 { |