Mercurial > mplayer.hg
comparison libswscale/rgb2rgb.c @ 27487:31ac930fd1d4
Fix 4 of the unscaled rgb15/16 converters, each of these contained
2-3 bugs each of which made it fail completely, this code clearly
has never been tested and been written by somone who knows the
difference between a potato and a computer is that the first is round.
author | michael |
---|---|
date | Thu, 04 Sep 2008 19:49:13 +0000 |
parents | e05965c550fc |
children | fe28a794c04f |
comparison
equal
deleted
inserted
replaced
27486:e05965c550fc | 27487:31ac930fd1d4 |
---|---|
414 long i; | 414 long i; |
415 long num_pixels = src_size >> 1; | 415 long num_pixels = src_size >> 1; |
416 | 416 |
417 for (i=0; i<num_pixels; i++) | 417 for (i=0; i<num_pixels; i++) |
418 { | 418 { |
419 unsigned b,g,r; | 419 unsigned rgb = ((const uint16_t*)src)[i]; |
420 register uint16_t rgb; | 420 ((uint16_t*)dst)[i] = (rgb>>11) | (rgb&0x7E0) | (rgb<<11); |
421 rgb = src[2*i]; | |
422 r = rgb&0x1F; | |
423 g = (rgb&0x7E0)>>5; | |
424 b = (rgb&0xF800)>>11; | |
425 dst[2*i] = (b&0x1F) | ((g&0x3F)<<5) | ((r&0x1F)<<11); | |
426 } | 421 } |
427 } | 422 } |
428 | 423 |
429 void rgb16tobgr15(const uint8_t *src, uint8_t *dst, long src_size) | 424 void rgb16tobgr15(const uint8_t *src, uint8_t *dst, long src_size) |
430 { | 425 { |
431 long i; | 426 long i; |
432 long num_pixels = src_size >> 1; | 427 long num_pixels = src_size >> 1; |
433 | 428 |
434 for (i=0; i<num_pixels; i++) | 429 for (i=0; i<num_pixels; i++) |
435 { | 430 { |
436 unsigned b,g,r; | 431 unsigned rgb = ((const uint16_t*)src)[i]; |
437 register uint16_t rgb; | 432 ((uint16_t*)dst)[i] = (rgb>>11) | ((rgb&0x7C0)>>1) | ((rgb&0x1F)<<10); |
438 rgb = src[2*i]; | |
439 r = rgb&0x1F; | |
440 g = (rgb&0x7E0)>>5; | |
441 b = (rgb&0xF800)>>11; | |
442 dst[2*i] = (b&0x1F) | ((g&0x1F)<<5) | ((r&0x1F)<<10); | |
443 } | 433 } |
444 } | 434 } |
445 | 435 |
446 void rgb15tobgr32(const uint8_t *src, uint8_t *dst, long src_size) | 436 void rgb15tobgr32(const uint8_t *src, uint8_t *dst, long src_size) |
447 { | 437 { |
488 long i; | 478 long i; |
489 long num_pixels = src_size >> 1; | 479 long num_pixels = src_size >> 1; |
490 | 480 |
491 for (i=0; i<num_pixels; i++) | 481 for (i=0; i<num_pixels; i++) |
492 { | 482 { |
493 unsigned b,g,r; | 483 unsigned rgb = ((const uint16_t*)src)[i]; |
494 register uint16_t rgb; | 484 ((uint16_t*)dst)[i] = ((rgb&0x7C00)>>10) | ((rgb&0x3E0)<<1) | (rgb<<11); |
495 rgb = src[2*i]; | |
496 r = rgb&0x1F; | |
497 g = (rgb&0x3E0)>>5; | |
498 b = (rgb&0x7C00)>>10; | |
499 dst[2*i] = (b&0x1F) | ((g&0x3F)<<5) | ((r&0x1F)<<11); | |
500 } | 485 } |
501 } | 486 } |
502 | 487 |
503 void rgb15tobgr15(const uint8_t *src, uint8_t *dst, long src_size) | 488 void rgb15tobgr15(const uint8_t *src, uint8_t *dst, long src_size) |
504 { | 489 { |
505 long i; | 490 long i; |
506 long num_pixels = src_size >> 1; | 491 long num_pixels = src_size >> 1; |
507 | 492 |
508 for (i=0; i<num_pixels; i++) | 493 for (i=0; i<num_pixels; i++) |
509 { | 494 { |
510 unsigned b,g,r; | 495 unsigned br; |
511 register uint16_t rgb; | 496 unsigned rgb = ((const uint16_t*)src)[i]; |
512 rgb = src[2*i]; | 497 br = rgb&0x7c1F; |
513 r = rgb&0x1F; | 498 ((uint16_t*)dst)[i] = (br>>10) | (rgb&0x3E0) | (br<<10); |
514 g = (rgb&0x3E0)>>5; | |
515 b = (rgb&0x7C00)>>10; | |
516 dst[2*i] = (b&0x1F) | ((g&0x1F)<<5) | ((r&0x1F)<<10); | |
517 } | 499 } |
518 } | 500 } |
519 | 501 |
520 void bgr8torgb8(const uint8_t *src, uint8_t *dst, long src_size) | 502 void bgr8torgb8(const uint8_t *src, uint8_t *dst, long src_size) |
521 { | 503 { |