1 #include "pixfmt-rgb16.hpp"
4 pixel_format_rgb16
<uvswap
>::~pixel_format_rgb16() throw()
9 void pixel_format_rgb16
<uvswap
>::decode(uint8_t* target
, const uint8_t* src
, size_t width
) throw()
11 const uint16_t* _src
= reinterpret_cast<const uint16_t*>(src
);
12 for(size_t i
= 0; i
< width
; i
++) {
13 uint32_t word
= _src
[i
];
14 uint64_t r
= ((word
>> (uvswap
? 11 : 0)) & 0x1F);
15 uint64_t g
= ((word
>> 5) & 0x3F);
16 uint64_t b
= ((word
>> (uvswap
? 0 : 11)) & 0x1F);
17 target
[3 * i
+ 0] = ((r
<< 8) - r
+ 15) / 31;
18 target
[3 * i
+ 1] = ((g
<< 8) - g
+ 31) / 63;
19 target
[3 * i
+ 2] = ((b
<< 8) - b
+ 15) / 31;
24 void pixel_format_rgb16
<uvswap
>::decode(uint32_t* target
, const uint8_t* src
, size_t width
,
25 const pixel_format_aux_palette
<false>& auxp
) throw()
27 const uint16_t* _src
= reinterpret_cast<const uint16_t*>(src
);
28 for(size_t i
= 0; i
< width
; i
++)
29 target
[i
] = auxp
.pcache
[_src
[i
]];
33 void pixel_format_rgb16
<uvswap
>::decode(uint64_t* target
, const uint8_t* src
, size_t width
,
34 const pixel_format_aux_palette
<true>& auxp
) throw()
36 const uint16_t* _src
= reinterpret_cast<const uint16_t*>(src
);
37 for(size_t i
= 0; i
< width
; i
++)
38 target
[i
] = auxp
.pcache
[_src
[i
]];
42 void pixel_format_rgb16
<uvswap
>::set_palette(pixel_format_aux_palette
<false>& auxp
, uint8_t rshift
, uint8_t gshift
,
43 uint8_t bshift
) throw(std::bad_alloc
)
45 auxp
.pcache
.resize(0x10000);
46 for(size_t i
= 0; i
< 0x10000; i
++) {
47 uint32_t r
= ((i
>> (uvswap
? 11 : 0)) & 0x1F);
48 uint32_t g
= ((i
>> 5) & 0x3F);
49 uint32_t b
= ((i
>> (uvswap
? 0 : 11)) & 0x1F);
50 auxp
.pcache
[i
] = (((r
<< 8) - r
+ 15) / 31) << rshift
;
51 auxp
.pcache
[i
] += (((g
<< 8) - g
+ 31) / 63) << gshift
;
52 auxp
.pcache
[i
] += (((b
<< 8) - b
+ 15) / 31) << bshift
;
60 void pixel_format_rgb16
<uvswap
>::set_palette(pixel_format_aux_palette
<true>& auxp
, uint8_t rshift
, uint8_t gshift
,
61 uint8_t bshift
) throw(std::bad_alloc
)
63 auxp
.pcache
.resize(0x10000);
64 for(size_t i
= 0; i
< 0x10000; i
++) {
65 uint64_t r
= ((i
>> (uvswap
? 11 : 0)) & 0x1F);
66 uint64_t g
= ((i
>> 5) & 0x3F);
67 uint64_t b
= ((i
>> (uvswap
? 0 : 11)) & 0x1F);
68 auxp
.pcache
[i
] = (((r
<< 16) - r
+ 15) / 31) << rshift
;
69 auxp
.pcache
[i
] += (((g
<< 16) - g
+ 31) / 63) << gshift
;
70 auxp
.pcache
[i
] += (((b
<< 16) - b
+ 15) / 31) << bshift
;
78 uint8_t pixel_format_rgb16
<uvswap
>::get_bpp() throw()
84 uint8_t pixel_format_rgb16
<uvswap
>::get_ss_bpp() throw()
90 uint32_t pixel_format_rgb16
<uvswap
>::get_magic() throw()
98 pixel_format_rgb16
<false> _pixel_format_rgb16
;
99 pixel_format_rgb16
<true> _pixel_format_bgr16
;