Advertisement
Guest User

Untitled

a guest
Nov 8th, 2011
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 16.33 KB | None | 0 0
  1. From 4ad26efdc8b9dc6a393138bb62bf42ff48bf335e Mon Sep 17 00:00:00 2001
  2. From: Themaister <maister@archlinux.us>
  3. Date: Tue, 8 Nov 2011 16:16:59 +0100
  4. Subject: [PATCH] Use more accurate conversion for rgb15/16 to rgb24/32
  5.  (C/MMX).
  6.  
  7. ---
  8.  libswscale/rgb2rgb.c              |   36 ++++++------
  9.  libswscale/rgb2rgb_template.c     |   57 ++++++------------
  10.  libswscale/x86/rgb2rgb.c          |    2 +
  11.  libswscale/x86/rgb2rgb_template.c |  116 +++++++++++++++++++-----------------
  12.  4 files changed, 99 insertions(+), 112 deletions(-)
  13.  
  14. diff --git a/libswscale/rgb2rgb.c b/libswscale/rgb2rgb.c
  15. index 9a7f698..adb3005 100644
  16. --- a/libswscale/rgb2rgb.c
  17. +++ b/libswscale/rgb2rgb.c
  18. @@ -171,13 +171,13 @@ void rgb16tobgr32(const uint8_t *src, uint8_t *dst, int src_size)
  19.          bgr = *s++;
  20.  #if HAVE_BIGENDIAN
  21.          *d++ = 255;
  22. -        *d++ = (bgr&0x1F)<<3;
  23. -        *d++ = (bgr&0x7E0)>>3;
  24. -        *d++ = (bgr&0xF800)>>8;
  25. +        *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
  26. +        *d++ = ((bgr&0x7E0)>>3) | ((bgr&0x7E0)>>9);
  27. +        *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13);
  28.  #else
  29. -        *d++ = (bgr&0xF800)>>8;
  30. -        *d++ = (bgr&0x7E0)>>3;
  31. -        *d++ = (bgr&0x1F)<<3;
  32. +        *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13);
  33. +        *d++ = ((bgr&0x7E0)>>3) | ((bgr&0x7E0)>>9);
  34. +        *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
  35.          *d++ = 255;
  36.  #endif
  37.      }
  38. @@ -192,9 +192,9 @@ void rgb16to24(const uint8_t *src, uint8_t *dst, int src_size)
  39.      while (s < end) {
  40.          register uint16_t bgr;
  41.          bgr = *s++;
  42. -        *d++ = (bgr&0xF800)>>8;
  43. -        *d++ = (bgr&0x7E0)>>3;
  44. -        *d++ = (bgr&0x1F)<<3;
  45. +        *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13);
  46. +        *d++ = ((bgr&0x7E0)>>3) | ((bgr&0x7E0)>>9);
  47. +        *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
  48.      }
  49.  }
  50.  
  51. @@ -231,13 +231,13 @@ void rgb15tobgr32(const uint8_t *src, uint8_t *dst, int src_size)
  52.          bgr = *s++;
  53.  #if HAVE_BIGENDIAN
  54.          *d++ = 255;
  55. -        *d++ = (bgr&0x1F)<<3;
  56. -        *d++ = (bgr&0x3E0)>>2;
  57. -        *d++ = (bgr&0x7C00)>>7;
  58. +        *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
  59. +        *d++ = ((bgr&0x3E0)>>2) | ((bgr&0x3E0)>>7);
  60. +        *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12);
  61.  #else
  62. -        *d++ = (bgr&0x7C00)>>7;
  63. -        *d++ = (bgr&0x3E0)>>2;
  64. -        *d++ = (bgr&0x1F)<<3;
  65. +        *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12);
  66. +        *d++ = ((bgr&0x3E0)>>2) | ((bgr&0x3E0)>>7);
  67. +        *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
  68.          *d++ = 255;
  69.  #endif
  70.      }
  71. @@ -252,9 +252,9 @@ void rgb15to24(const uint8_t *src, uint8_t *dst, int src_size)
  72.      while (s < end) {
  73.          register uint16_t bgr;
  74.          bgr = *s++;
  75. -        *d++ = (bgr&0x7C00)>>7;
  76. -        *d++ = (bgr&0x3E0)>>2;
  77. -        *d++ = (bgr&0x1F)<<3;
  78. +        *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12);
  79. +        *d++ = ((bgr&0x3E0)>>2) | ((bgr&0x3E0)>>7);
  80. +        *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
  81.      }
  82.  }
  83.  
  84. diff --git a/libswscale/rgb2rgb_template.c b/libswscale/rgb2rgb_template.c
  85. index 0734e88..6363bc1 100644
  86. --- a/libswscale/rgb2rgb_template.c
  87. +++ b/libswscale/rgb2rgb_template.c
  88. @@ -227,27 +227,6 @@ static inline void rgb24to15_c(const uint8_t *src, uint8_t *dst, int src_size)
  89.      }
  90.  }
  91.  
  92. -/*
  93. -  I use less accurate approximation here by simply left-shifting the input
  94. -  value and filling the low order bits with zeroes. This method improves PNG
  95. -  compression but this scheme cannot reproduce white exactly, since it does
  96. -  not generate an all-ones maximum value; the net effect is to darken the
  97. -  image slightly.
  98. -
  99. -  The better method should be "left bit replication":
  100. -
  101. -   4 3 2 1 0
  102. -   ---------
  103. -   1 1 0 1 1
  104. -
  105. -   7 6 5 4 3  2 1 0
  106. -   ----------------
  107. -   1 1 0 1 1  1 1 0
  108. -   |=======|  |===|
  109. -       |      leftmost bits repeated to fill open bits
  110. -       |
  111. -   original bits
  112. -*/
  113.  static inline void rgb15tobgr24_c(const uint8_t *src, uint8_t *dst, int src_size)
  114.  {
  115.      const uint16_t *end;
  116. @@ -257,9 +236,9 @@ static inline void rgb15tobgr24_c(const uint8_t *src, uint8_t *dst, int src_size
  117.      while (s < end) {
  118.          register uint16_t bgr;
  119.          bgr = *s++;
  120. -        *d++ = (bgr&0x1F)<<3;
  121. -        *d++ = (bgr&0x3E0)>>2;
  122. -        *d++ = (bgr&0x7C00)>>7;
  123. +        *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
  124. +        *d++ = ((bgr&0x3E0)>>2) | ((bgr&0x3E0)>>7);
  125. +        *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12);
  126.      }
  127.  }
  128.  
  129. @@ -272,9 +251,9 @@ static inline void rgb16tobgr24_c(const uint8_t *src, uint8_t *dst, int src_size
  130.      while (s < end) {
  131.          register uint16_t bgr;
  132.          bgr = *s++;
  133. -        *d++ = (bgr&0x1F)<<3;
  134. -        *d++ = (bgr&0x7E0)>>3;
  135. -        *d++ = (bgr&0xF800)>>8;
  136. +        *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
  137. +        *d++ = ((bgr&0x7E0)>>3) | ((bgr&0x7E0)>>9);
  138. +        *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13);
  139.      }
  140.  }
  141.  
  142. @@ -289,13 +268,13 @@ static inline void rgb15to32_c(const uint8_t *src, uint8_t *dst, int src_size)
  143.          bgr = *s++;
  144.  #if HAVE_BIGENDIAN
  145.          *d++ = 255;
  146. -        *d++ = (bgr&0x7C00)>>7;
  147. -        *d++ = (bgr&0x3E0)>>2;
  148. -        *d++ = (bgr&0x1F)<<3;
  149. +        *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12);
  150. +        *d++ = ((bgr&0x3E0)>>2) | ((bgr&0x3E0)>>7);
  151. +        *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
  152.  #else
  153. -        *d++ = (bgr&0x1F)<<3;
  154. -        *d++ = (bgr&0x3E0)>>2;
  155. -        *d++ = (bgr&0x7C00)>>7;
  156. +        *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
  157. +        *d++ = ((bgr&0x3E0)>>2) | ((bgr&0x3E0)>>7);
  158. +        *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12);
  159.          *d++ = 255;
  160.  #endif
  161.      }
  162. @@ -312,13 +291,13 @@ static inline void rgb16to32_c(const uint8_t *src, uint8_t *dst, int src_size)
  163.          bgr = *s++;
  164.  #if HAVE_BIGENDIAN
  165.          *d++ = 255;
  166. -        *d++ = (bgr&0xF800)>>8;
  167. -        *d++ = (bgr&0x7E0)>>3;
  168. -        *d++ = (bgr&0x1F)<<3;
  169. +        *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13);
  170. +        *d++ = ((bgr&0x7E0)>>3) | ((bgr&0x7E0)>>9);
  171. +        *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
  172.  #else
  173. -        *d++ = (bgr&0x1F)<<3;
  174. -        *d++ = (bgr&0x7E0)>>3;
  175. -        *d++ = (bgr&0xF800)>>8;
  176. +        *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
  177. +        *d++ = ((bgr&0x7E0)>>3) | ((bgr&0x7E0)>>9);
  178. +        *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13);
  179.          *d++ = 255;
  180.  #endif
  181.      }
  182. diff --git a/libswscale/x86/rgb2rgb.c b/libswscale/x86/rgb2rgb.c
  183. index ed7f5ad..3fffc39 100644
  184. --- a/libswscale/x86/rgb2rgb.c
  185. +++ b/libswscale/x86/rgb2rgb.c
  186. @@ -68,6 +68,8 @@ DECLARE_ASM_CONST(8, uint64_t, blue_16mask)  = 0x0000001f0000001fULL;
  187.  DECLARE_ASM_CONST(8, uint64_t, red_15mask)   = 0x00007c0000007c00ULL;
  188.  DECLARE_ASM_CONST(8, uint64_t, green_15mask) = 0x000003e0000003e0ULL;
  189.  DECLARE_ASM_CONST(8, uint64_t, blue_15mask)  = 0x0000001f0000001fULL;
  190. +DECLARE_ASM_CONST(8, uint64_t, mul1524)      = 0x0021002100210021ULL; /* a + (a << 5) used in rgb{15,16} -> rgb{24,32} */
  191. +DECLARE_ASM_CONST(8, uint64_t, mul1624)      = 0x0041004100410041ULL; /* a + (a << 6) used in green channel for rgb16 -> rgb{24,32} */
  192.  
  193.  #define RGB2YUV_SHIFT 8
  194.  #define BY ((int)( 0.098*(1<<RGB2YUV_SHIFT)+0.5))
  195. diff --git a/libswscale/x86/rgb2rgb_template.c b/libswscale/x86/rgb2rgb_template.c
  196. index baef3f8..3acd5e9 100644
  197. --- a/libswscale/x86/rgb2rgb_template.c
  198. +++ b/libswscale/x86/rgb2rgb_template.c
  199. @@ -801,27 +801,6 @@ static inline void RENAME(rgb24to15)(const uint8_t *src, uint8_t *dst, int src_s
  200.      }
  201.  }
  202.  
  203. -/*
  204. -  I use less accurate approximation here by simply left-shifting the input
  205. -  value and filling the low order bits with zeroes. This method improves PNG
  206. -  compression but this scheme cannot reproduce white exactly, since it does
  207. -  not generate an all-ones maximum value; the net effect is to darken the
  208. -  image slightly.
  209. -
  210. -  The better method should be "left bit replication":
  211. -
  212. -   4 3 2 1 0
  213. -   ---------
  214. -   1 1 0 1 1
  215. -
  216. -   7 6 5 4 3  2 1 0
  217. -   ----------------
  218. -   1 1 0 1 1  1 1 0
  219. -   |=======|  |===|
  220. -       |      leftmost bits repeated to fill open bits
  221. -       |
  222. -   original bits
  223. -*/
  224.  static inline void RENAME(rgb15tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
  225.  {
  226.      const uint16_t *end;
  227. @@ -840,9 +819,13 @@ static inline void RENAME(rgb15tobgr24)(const uint8_t *src, uint8_t *dst, int sr
  228.              "pand          %2, %%mm0    \n\t"
  229.              "pand          %3, %%mm1    \n\t"
  230.              "pand          %4, %%mm2    \n\t"
  231. -            "psllq         $3, %%mm0    \n\t"
  232. -            "psrlq         $2, %%mm1    \n\t"
  233. -            "psrlq         $7, %%mm2    \n\t"
  234. +            "psrlq        $10, %%mm2    \n\t"
  235. +            "pmullw        %6, %%mm0    \n\t"
  236. +            "pmullw        %6, %%mm1    \n\t"
  237. +            "pmullw        %6, %%mm2    \n\t"
  238. +            "psrlw         $2, %%mm0    \n\t"
  239. +            "psrlw         $7, %%mm1    \n\t"
  240. +            "psrlw         $2, %%mm2    \n\t"
  241.              "movq       %%mm0, %%mm3    \n\t"
  242.              "movq       %%mm1, %%mm4    \n\t"
  243.              "movq       %%mm2, %%mm5    \n\t"
  244. @@ -870,9 +853,13 @@ static inline void RENAME(rgb15tobgr24)(const uint8_t *src, uint8_t *dst, int sr
  245.              "pand          %2, %%mm0    \n\t"
  246.              "pand          %3, %%mm1    \n\t"
  247.              "pand          %4, %%mm2    \n\t"
  248. -            "psllq         $3, %%mm0    \n\t"
  249. -            "psrlq         $2, %%mm1    \n\t"
  250. -            "psrlq         $7, %%mm2    \n\t"
  251. +            "psrlq        $10, %%mm2    \n\t"
  252. +            "pmullw        %6, %%mm0    \n\t"
  253. +            "pmullw        %6, %%mm1    \n\t"
  254. +            "pmullw        %6, %%mm2    \n\t"
  255. +            "psrlw         $2, %%mm0    \n\t"
  256. +            "psrlw         $7, %%mm1    \n\t"
  257. +            "psrlw         $2, %%mm2    \n\t"
  258.              "movq       %%mm0, %%mm3    \n\t"
  259.              "movq       %%mm1, %%mm4    \n\t"
  260.              "movq       %%mm2, %%mm5    \n\t"
  261. @@ -892,7 +879,7 @@ static inline void RENAME(rgb15tobgr24)(const uint8_t *src, uint8_t *dst, int sr
  262.              "por        %%mm5, %%mm3    \n\t"
  263.  
  264.              :"=m"(*d)
  265. -            :"m"(*s),"m"(mask15b),"m"(mask15g),"m"(mask15r), "m"(mmx_null)
  266. +            :"m"(*s),"m"(mask15b),"m"(mask15g),"m"(mask15r),"m"(mmx_null),"m"(mul1524)
  267.              :"memory");
  268.          /* borrowed 32 to 24 */
  269.          __asm__ volatile(
  270. @@ -919,9 +906,9 @@ static inline void RENAME(rgb15tobgr24)(const uint8_t *src, uint8_t *dst, int sr
  271.      while (s < end) {
  272.          register uint16_t bgr;
  273.          bgr = *s++;
  274. -        *d++ = (bgr&0x1F)<<3;
  275. -        *d++ = (bgr&0x3E0)>>2;
  276. -        *d++ = (bgr&0x7C00)>>7;
  277. +        *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
  278. +        *d++ = ((bgr&0x3E0)>>2) | ((bgr&0x3E0)>>7);
  279. +        *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12);
  280.      }
  281.  }
  282.  
  283. @@ -943,9 +930,14 @@ static inline void RENAME(rgb16tobgr24)(const uint8_t *src, uint8_t *dst, int sr
  284.              "pand          %2, %%mm0    \n\t"
  285.              "pand          %3, %%mm1    \n\t"
  286.              "pand          %4, %%mm2    \n\t"
  287. -            "psllq         $3, %%mm0    \n\t"
  288. -            "psrlq         $3, %%mm1    \n\t"
  289. -            "psrlq         $8, %%mm2    \n\t"
  290. +            "psrlq         $5, %%mm1    \n\t"
  291. +            "psrlq        $11, %%mm2    \n\t"
  292. +            "pmullw        %6, %%mm0    \n\t"
  293. +            "pmullw        %7, %%mm1    \n\t"
  294. +            "pmullw        %6, %%mm2    \n\t"
  295. +            "psrlw         $2, %%mm0    \n\t"
  296. +            "psrlw         $4, %%mm1    \n\t"
  297. +            "psrlw         $2, %%mm2    \n\t"
  298.              "movq       %%mm0, %%mm3    \n\t"
  299.              "movq       %%mm1, %%mm4    \n\t"
  300.              "movq       %%mm2, %%mm5    \n\t"
  301. @@ -973,9 +965,14 @@ static inline void RENAME(rgb16tobgr24)(const uint8_t *src, uint8_t *dst, int sr
  302.              "pand          %2, %%mm0    \n\t"
  303.              "pand          %3, %%mm1    \n\t"
  304.              "pand          %4, %%mm2    \n\t"
  305. -            "psllq         $3, %%mm0    \n\t"
  306. -            "psrlq         $3, %%mm1    \n\t"
  307. -            "psrlq         $8, %%mm2    \n\t"
  308. +            "psrlq         $5, %%mm1    \n\t"
  309. +            "psrlq        $11, %%mm2    \n\t"
  310. +            "pmullw        %6, %%mm0    \n\t"
  311. +            "pmullw        %7, %%mm1    \n\t"
  312. +            "pmullw        %6, %%mm2    \n\t"
  313. +            "psrlw         $2, %%mm0    \n\t"
  314. +            "psrlw         $4, %%mm1    \n\t"
  315. +            "psrlw         $2, %%mm2    \n\t"
  316.              "movq       %%mm0, %%mm3    \n\t"
  317.              "movq       %%mm1, %%mm4    \n\t"
  318.              "movq       %%mm2, %%mm5    \n\t"
  319. @@ -994,7 +991,7 @@ static inline void RENAME(rgb16tobgr24)(const uint8_t *src, uint8_t *dst, int sr
  320.              "por        %%mm4, %%mm3    \n\t"
  321.              "por        %%mm5, %%mm3    \n\t"
  322.              :"=m"(*d)
  323. -            :"m"(*s),"m"(mask16b),"m"(mask16g),"m"(mask16r),"m"(mmx_null)
  324. +            :"m"(*s),"m"(mask16b),"m"(mask16g),"m"(mask16r),"m"(mmx_null),"m"(mul1524),"m"(mul1624)
  325.              :"memory");
  326.          /* borrowed 32 to 24 */
  327.          __asm__ volatile(
  328. @@ -1021,9 +1018,9 @@ static inline void RENAME(rgb16tobgr24)(const uint8_t *src, uint8_t *dst, int sr
  329.      while (s < end) {
  330.          register uint16_t bgr;
  331.          bgr = *s++;
  332. -        *d++ = (bgr&0x1F)<<3;
  333. -        *d++ = (bgr&0x7E0)>>3;
  334. -        *d++ = (bgr&0xF800)>>8;
  335. +        *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
  336. +        *d++ = ((bgr&0x7E0)>>3) | ((bgr&0x7E0)>>9);
  337. +        *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13);
  338.      }
  339.  }
  340.  
  341. @@ -1066,12 +1063,16 @@ static inline void RENAME(rgb15to32)(const uint8_t *src, uint8_t *dst, int src_s
  342.              "pand          %2, %%mm0    \n\t"
  343.              "pand          %3, %%mm1    \n\t"
  344.              "pand          %4, %%mm2    \n\t"
  345. -            "psllq         $3, %%mm0    \n\t"
  346. -            "psrlq         $2, %%mm1    \n\t"
  347. -            "psrlq         $7, %%mm2    \n\t"
  348. +            "psrlq        $10, %%mm2    \n\t"
  349. +            "pmullw        %5, %%mm0    \n\t"
  350. +            "pmullw        %5, %%mm1    \n\t"
  351. +            "pmullw        %5, %%mm2    \n\t"
  352. +            "psrlw         $2, %%mm0    \n\t"
  353. +            "psrlw         $7, %%mm1    \n\t"
  354. +            "psrlw         $2, %%mm2    \n\t"
  355.              PACK_RGB32
  356.              :"=m"(*d)
  357. -            :"m"(*s),"m"(mask15b),"m"(mask15g),"m"(mask15r)
  358. +            :"m"(*s),"m"(mask15b),"m"(mask15g),"m"(mask15r),"m"(mul1524)
  359.              :"memory");
  360.          d += 16;
  361.          s += 4;
  362. @@ -1081,9 +1082,9 @@ static inline void RENAME(rgb15to32)(const uint8_t *src, uint8_t *dst, int src_s
  363.      while (s < end) {
  364.          register uint16_t bgr;
  365.          bgr = *s++;
  366. -        *d++ = (bgr&0x1F)<<3;
  367. -        *d++ = (bgr&0x3E0)>>2;
  368. -        *d++ = (bgr&0x7C00)>>7;
  369. +        *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
  370. +        *d++ = ((bgr&0x3E0)>>2) | ((bgr&0x3E0)>>7);
  371. +        *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12);
  372.          *d++ = 255;
  373.      }
  374.  }
  375. @@ -1108,12 +1109,17 @@ static inline void RENAME(rgb16to32)(const uint8_t *src, uint8_t *dst, int src_s
  376.              "pand          %2, %%mm0    \n\t"
  377.              "pand          %3, %%mm1    \n\t"
  378.              "pand          %4, %%mm2    \n\t"
  379. -            "psllq         $3, %%mm0    \n\t"
  380. -            "psrlq         $3, %%mm1    \n\t"
  381. -            "psrlq         $8, %%mm2    \n\t"
  382. +            "psrlq         $5, %%mm1    \n\t"
  383. +            "psrlq        $11, %%mm2    \n\t"
  384. +            "pmullw        %5, %%mm0    \n\t"
  385. +            "pmullw        %6, %%mm1    \n\t"
  386. +            "pmullw        %5, %%mm2    \n\t"
  387. +            "psrlw         $2, %%mm0    \n\t"
  388. +            "psrlw         $4, %%mm1    \n\t"
  389. +            "psrlw         $2, %%mm2    \n\t"
  390.              PACK_RGB32
  391.              :"=m"(*d)
  392. -            :"m"(*s),"m"(mask16b),"m"(mask16g),"m"(mask16r)
  393. +            :"m"(*s),"m"(mask16b),"m"(mask16g),"m"(mask16r),"m"(mul1524),"m"(mul1624)
  394.              :"memory");
  395.          d += 16;
  396.          s += 4;
  397. @@ -1123,9 +1129,9 @@ static inline void RENAME(rgb16to32)(const uint8_t *src, uint8_t *dst, int src_s
  398.      while (s < end) {
  399.          register uint16_t bgr;
  400.          bgr = *s++;
  401. -        *d++ = (bgr&0x1F)<<3;
  402. -        *d++ = (bgr&0x7E0)>>3;
  403. -        *d++ = (bgr&0xF800)>>8;
  404. +        *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
  405. +        *d++ = ((bgr&0x7E0)>>3) | ((bgr&0x7E0)>>9);
  406. +        *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13);
  407.          *d++ = 255;
  408.      }
  409.  }
  410. --
  411. 1.7.7.2
  412.  
  413.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement