Mercurial > mplayer.hg
comparison postproc/rgb2rgb.c @ 17586:65b39a32a7c4
Fix big-endian color permutation problems.
patch by Alan Curry, pacman_at_TheWorld_dot_com
author | diego |
---|---|
date | Sat, 11 Feb 2006 13:35:46 +0000 |
parents | 08cac43f1e38 |
children | e1108996497c |
comparison
equal
deleted
inserted
replaced
17585:03829916a1c3 | 17586:65b39a32a7c4 |
---|---|
444 { | 444 { |
445 long i; | 445 long i; |
446 long num_pixels = src_size >> 2; | 446 long num_pixels = src_size >> 2; |
447 for(i=0; i<num_pixels; i++) | 447 for(i=0; i<num_pixels; i++) |
448 { | 448 { |
449 #ifdef WORDS_BIGENDIAN | |
450 /* RGB32 (= A,B,G,R) -> BGR24 (= B,G,R) */ | |
451 dst[3*i + 0] = src[4*i + 1]; | |
452 dst[3*i + 1] = src[4*i + 2]; | |
453 dst[3*i + 2] = src[4*i + 3]; | |
454 #else | |
449 dst[3*i + 0] = src[4*i + 2]; | 455 dst[3*i + 0] = src[4*i + 2]; |
450 dst[3*i + 1] = src[4*i + 1]; | 456 dst[3*i + 1] = src[4*i + 1]; |
451 dst[3*i + 2] = src[4*i + 0]; | 457 dst[3*i + 2] = src[4*i + 0]; |
458 #endif | |
452 } | 459 } |
453 } | 460 } |
454 | 461 |
455 void rgb24tobgr32(const uint8_t *src, uint8_t *dst, long src_size) | 462 void rgb24tobgr32(const uint8_t *src, uint8_t *dst, long src_size) |
456 { | 463 { |
457 long i; | 464 long i; |
458 for(i=0; 3*i<src_size; i++) | 465 for(i=0; 3*i<src_size; i++) |
459 { | 466 { |
467 #ifdef WORDS_BIGENDIAN | |
468 /* RGB24 (= R,G,B) -> BGR32 (= A,R,G,B) */ | |
469 dst[4*i + 0] = 0; | |
470 dst[4*i + 1] = src[3*i + 0]; | |
471 dst[4*i + 2] = src[3*i + 1]; | |
472 dst[4*i + 3] = src[3*i + 2]; | |
473 #else | |
460 dst[4*i + 0] = src[3*i + 2]; | 474 dst[4*i + 0] = src[3*i + 2]; |
461 dst[4*i + 1] = src[3*i + 1]; | 475 dst[4*i + 1] = src[3*i + 1]; |
462 dst[4*i + 2] = src[3*i + 0]; | 476 dst[4*i + 2] = src[3*i + 0]; |
463 dst[4*i + 3] = 0; | 477 dst[4*i + 3] = 0; |
478 #endif | |
464 } | 479 } |
465 } | 480 } |
466 | 481 |
467 void rgb16tobgr32(const uint8_t *src, uint8_t *dst, long src_size) | 482 void rgb16tobgr32(const uint8_t *src, uint8_t *dst, long src_size) |
468 { | 483 { |
472 end = s + src_size/2; | 487 end = s + src_size/2; |
473 while(s < end) | 488 while(s < end) |
474 { | 489 { |
475 register uint16_t bgr; | 490 register uint16_t bgr; |
476 bgr = *s++; | 491 bgr = *s++; |
492 #ifdef WORDS_BIGENDIAN | |
493 *d++ = 0; | |
494 *d++ = (bgr&0x1F)<<3; | |
495 *d++ = (bgr&0x7E0)>>3; | |
496 *d++ = (bgr&0xF800)>>8; | |
497 #else | |
477 *d++ = (bgr&0xF800)>>8; | 498 *d++ = (bgr&0xF800)>>8; |
478 *d++ = (bgr&0x7E0)>>3; | 499 *d++ = (bgr&0x7E0)>>3; |
479 *d++ = (bgr&0x1F)<<3; | 500 *d++ = (bgr&0x1F)<<3; |
480 *d++ = 0; | 501 *d++ = 0; |
502 #endif | |
481 } | 503 } |
482 } | 504 } |
483 | 505 |
484 void rgb16tobgr24(const uint8_t *src, uint8_t *dst, long src_size) | 506 void rgb16tobgr24(const uint8_t *src, uint8_t *dst, long src_size) |
485 { | 507 { |
539 end = s + src_size/2; | 561 end = s + src_size/2; |
540 while(s < end) | 562 while(s < end) |
541 { | 563 { |
542 register uint16_t bgr; | 564 register uint16_t bgr; |
543 bgr = *s++; | 565 bgr = *s++; |
566 #ifdef WORDS_BIGENDIAN | |
567 *d++ = 0; | |
568 *d++ = (bgr&0x1F)<<3; | |
569 *d++ = (bgr&0x3E0)>>2; | |
570 *d++ = (bgr&0x7C00)>>7; | |
571 #else | |
544 *d++ = (bgr&0x7C00)>>7; | 572 *d++ = (bgr&0x7C00)>>7; |
545 *d++ = (bgr&0x3E0)>>2; | 573 *d++ = (bgr&0x3E0)>>2; |
546 *d++ = (bgr&0x1F)<<3; | 574 *d++ = (bgr&0x1F)<<3; |
547 *d++ = 0; | 575 *d++ = 0; |
576 #endif | |
548 } | 577 } |
549 } | 578 } |
550 | 579 |
551 void rgb15tobgr24(const uint8_t *src, uint8_t *dst, long src_size) | 580 void rgb15tobgr24(const uint8_t *src, uint8_t *dst, long src_size) |
552 { | 581 { |