Revision b238eb2e postproc/rgb2rgb.c

View differences:

postproc/rgb2rgb.c
1 1
#include <inttypes.h>
2 2
#include "../config.h"
3 3
#include "rgb2rgb.h"
4
#include "mmx.h"
4 5

  
5 6
/* TODO: MMX optimization */
6 7

  
......
33 34
    s++;
34 35
  }
35 36
}
37

  
38
/* Original by Strepto/Astral
39
 ported to gcc & bugfixed : A'rpi */
40
void rgb15to16(uint8_t *src,uint8_t *dst,uint32_t src_size)
41
{
42
#ifdef HAVE_MMX
43
  static uint64_t mask_b  = 0x001F001F001F001FLL; // 00000000 00011111  xxB
44
  static uint64_t mask_rg = 0x7FE07FE07FE07FE0LL; // 01111111 11100000  RGx
45
  register char* s=src+src_size;
46
  register char* d=dst+src_size;
47
  register int offs=-src_size;
48
  movq_m2r (mask_b,  mm4);
49
  movq_m2r (mask_rg, mm5);
50
  while(offs<0){
51
    movq_m2r (*(s+offs), mm0);
52
    movq_r2r (mm0, mm1);
53

  
54
    movq_m2r (*(s+8+offs), mm2);
55
    movq_r2r (mm2, mm3);
56
    
57
    pand_r2r (mm4, mm0);
58
    pand_r2r (mm5, mm1);
59
    
60
    psllq_i2r(1,mm1);
61
    pand_r2r (mm4, mm2);
62

  
63
    pand_r2r (mm5, mm3);
64
    por_r2r  (mm1, mm0);
65

  
66
    psllq_i2r(1,mm3);
67
    movq_r2m (mm0,*(d+offs));
68

  
69
    por_r2r  (mm3,mm2);
70
    movq_r2m (mm2,*(d+8+offs));
71

  
72
    offs+=16;
73
  }
74
  emms();
75
#else
76
   uint16_t *s1=( uint16_t * )src;
77
   uint16_t *d1=( uint16_t * )dst;
78
   uint16_t *e=((uint8_t *)s1)+src_size;
79
   while( s1<e ){
80
     register int x=*( s1++ );
81
     /* rrrrrggggggbbbbb
82
        0rrrrrgggggbbbbb
83
        0111 1111 1110 0000=0x7FE0
84
        00000000000001 1111=0x001F */
85
     *( d1++ )=( x&0x001F )|( ( x&0x7FE0 )<<1 );
86
   }
87
#endif
88
}

Also available in: Unified diff