Movie editor: Fix compilation on Win32
[lsnes.git] / src / library / pixfmt-lrgb.cpp
blob72acfa180ebff3cb6f52d1962172425cbe632b8f
1 #include "pixfmt-lrgb.hpp"
3 pixel_format_lrgb::~pixel_format_lrgb() throw()
7 void pixel_format_lrgb::decode(uint8_t* target, const uint8_t* src, size_t width)
8 throw()
10 const uint32_t* _src = reinterpret_cast<const uint32_t*>(src);
11 for(size_t i = 0; i < width; i++) {
12 uint32_t word = _src[i];
13 uint32_t l = 1 + ((word >> 15) & 0xF);
14 uint32_t r = l * ((word >> 0) & 0x1F);
15 uint32_t g = l * ((word >> 5) & 0x1F);
16 uint32_t b = l * ((word >> 10) & 0x1F);
17 target[3 * i + 0] = ((r << 8) - r + 248) / 496;
18 target[3 * i + 1] = ((g << 8) - g + 248) / 496;
19 target[3 * i + 2] = ((b << 8) - b + 248) / 496;
23 void pixel_format_lrgb::decode(uint32_t* target, const uint8_t* src, size_t width,
24 const pixel_format_aux_palette<false>& auxp) throw()
26 const uint32_t* _src = reinterpret_cast<const uint32_t*>(src);
27 for(size_t i = 0; i < width; i++)
28 target[i] = auxp.pcache[_src[i] & 0x7FFFF];
31 void pixel_format_lrgb::decode(uint64_t* target, const uint8_t* src, size_t width,
32 const pixel_format_aux_palette<true>& auxp) throw()
34 const uint32_t* _src = reinterpret_cast<const uint32_t*>(src);
35 for(size_t i = 0; i < width; i++)
36 target[i] = auxp.pcache[_src[i] & 0x7FFFF];
39 void pixel_format_lrgb::set_palette(pixel_format_aux_palette<false>& auxp, uint8_t rshift, uint8_t gshift,
40 uint8_t bshift) throw(std::bad_alloc)
42 auxp.pcache.resize(0x80000);
43 for(size_t i = 0; i < 0x80000; i++) {
44 uint32_t l = 1 + ((i >> 15) & 0xF);
45 uint32_t r = l * ((i >> 0) & 0x1F);
46 uint32_t g = l * ((i >> 5) & 0x1F);
47 uint32_t b = l * ((i >> 10) & 0x1F);
48 auxp.pcache[i] = (((r << 8) - r + 248) / 496) << rshift;
49 auxp.pcache[i] += (((g << 8) - g + 248) / 496) << gshift;
50 auxp.pcache[i] += (((b << 8) - b + 248) / 496) << bshift;
52 auxp.rshift = rshift;
53 auxp.gshift = gshift;
54 auxp.bshift = bshift;
57 void pixel_format_lrgb::set_palette(pixel_format_aux_palette<true>& auxp, uint8_t rshift, uint8_t gshift,
58 uint8_t bshift) throw(std::bad_alloc)
60 auxp.pcache.resize(0x80000);
61 for(size_t i = 0; i < 0x80000; i++) {
62 uint64_t l = 1 + ((i >> 15) & 0xF);
63 uint64_t r = l * ((i >> 0) & 0x1F);
64 uint64_t g = l * ((i >> 5) & 0x1F);
65 uint64_t b = l * ((i >> 10) & 0x1F);
66 auxp.pcache[i] = (((r << 16) - r + 248) / 496) << rshift;
67 auxp.pcache[i] += (((g << 16) - g + 248) / 496) << gshift;
68 auxp.pcache[i] += (((b << 16) - b + 248) / 496) << bshift;
70 auxp.rshift = rshift;
71 auxp.gshift = gshift;
72 auxp.bshift = bshift;
75 uint8_t pixel_format_lrgb::get_bpp() throw()
77 return 4;
80 uint8_t pixel_format_lrgb::get_ss_bpp() throw()
82 return 3;
85 uint32_t pixel_format_lrgb::get_magic() throw()
87 return 0;
90 pixel_format_lrgb _pixel_format_lrgb;