1 #include "pixfmt-rgb15.hpp"
4 pixel_format_rgb15
<uvswap
>::~pixel_format_rgb15() throw()
9 void pixel_format_rgb15
<uvswap
>::decode(uint8_t* target
, const uint8_t* src
, size_t width
)
12 const uint16_t* _src
= reinterpret_cast<const uint16_t*>(src
);
13 for(size_t i
= 0; i
< width
; i
++) {
14 uint32_t word
= _src
[i
];
15 uint64_t r
= ((word
>> (uvswap
? 10 : 0)) & 0x1F);
16 uint64_t g
= ((word
>> 5) & 0x1F);
17 uint64_t b
= ((word
>> (uvswap
? 0 : 10)) & 0x1F);
18 target
[3 * i
+ 0] = ((r
<< 8) - r
+ 15) / 31;
19 target
[3 * i
+ 1] = ((g
<< 8) - g
+ 15) / 31;
20 target
[3 * i
+ 2] = ((b
<< 8) - b
+ 15) / 31;
25 void pixel_format_rgb15
<uvswap
>::decode(uint32_t* target
, const uint8_t* src
, size_t width
,
26 const pixel_format_aux_palette
<false>& auxp
) throw()
28 const uint16_t* _src
= reinterpret_cast<const uint16_t*>(src
);
29 for(size_t i
= 0; i
< width
; i
++)
30 target
[i
] = auxp
.pcache
[_src
[i
] & 0x7FFF];
34 void pixel_format_rgb15
<uvswap
>::decode(uint64_t* target
, const uint8_t* src
, size_t width
,
35 const pixel_format_aux_palette
<true>& auxp
) throw()
37 const uint16_t* _src
= reinterpret_cast<const uint16_t*>(src
);
38 for(size_t i
= 0; i
< width
; i
++)
39 target
[i
] = auxp
.pcache
[_src
[i
] & 0x7FFF];
43 void pixel_format_rgb15
<uvswap
>::set_palette(pixel_format_aux_palette
<false>& auxp
, uint8_t rshift
, uint8_t gshift
,
44 uint8_t bshift
) throw(std::bad_alloc
)
46 auxp
.pcache
.resize(0x8000);
47 for(size_t i
= 0; i
< 0x8000; i
++) {
48 uint32_t r
= ((i
>> (uvswap
? 10 : 0)) & 0x1F);
49 uint32_t g
= ((i
>> 5) & 0x1F);
50 uint32_t b
= ((i
>> (uvswap
? 0 : 10)) & 0x1F);
51 auxp
.pcache
[i
] = (((r
<< 8) - r
+ 15) / 31) << rshift
;
52 auxp
.pcache
[i
] += (((g
<< 8) - g
+ 15) / 31) << gshift
;
53 auxp
.pcache
[i
] += (((b
<< 8) - b
+ 15) / 31) << bshift
;
61 void pixel_format_rgb15
<uvswap
>::set_palette(pixel_format_aux_palette
<true>& auxp
, uint8_t rshift
, uint8_t gshift
,
62 uint8_t bshift
) throw(std::bad_alloc
)
64 auxp
.pcache
.resize(0x8000);
65 for(size_t i
= 0; i
< 0x8000; i
++) {
66 uint64_t r
= ((i
>> (uvswap
? 10 : 0)) & 0x1F);
67 uint64_t g
= ((i
>> 5) & 0x1F);
68 uint64_t b
= ((i
>> (uvswap
? 0 : 10)) & 0x1F);
69 auxp
.pcache
[i
] = (((r
<< 16) - r
+ 15) / 31) << rshift
;
70 auxp
.pcache
[i
] += (((g
<< 16) - g
+ 15) / 31) << gshift
;
71 auxp
.pcache
[i
] += (((b
<< 16) - b
+ 15) / 31) << bshift
;
79 uint8_t pixel_format_rgb15
<uvswap
>::get_bpp() throw()
85 uint8_t pixel_format_rgb15
<uvswap
>::get_ss_bpp() throw()
91 uint32_t pixel_format_rgb15
<uvswap
>::get_magic() throw()
99 pixel_format_rgb15
<false> _pixel_format_rgb15
;
100 pixel_format_rgb15
<true> _pixel_format_bgr15
;