Line data Source code
1 :
2 : /* Copyright (c) 2010, Cedric Stalder <cedric.stalder@gmail.com>
3 : * 2013, Stefan.Eilemann@epfl.ch
4 : *
5 : * This library is free software; you can redistribute it and/or modify it under
6 : * the terms of the GNU Lesser General Public License version 2.1 as published
7 : * by the Free Software Foundation.
8 : *
9 : * This library is distributed in the hope that it will be useful, but WITHOUT
10 : * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 : * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 : * details.
13 : *
14 : * You should have received a copy of the GNU Lesser General Public License
15 : * along with this library; if not, write to the Free Software Foundation, Inc.,
16 : * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 : */
18 :
19 : #include "compressorRLE10A2.h"
20 :
21 : namespace
22 : {
23 : static const uint8_t _rleMarker = 0x42; // just a random number
24 : }
25 :
26 : #include "compressorRLE.ipp"
27 :
28 : namespace pression
29 : {
30 : namespace plugin
31 : {
32 : namespace
33 : {
34 3 : REGISTER_ENGINE( CompressorRLE10A2, DIFF_BGR10_A2, BGR10_A2, \
35 : 1., 0.57, 1., true );
36 :
37 : class SwizzleUInt32
38 : {
39 : public:
40 0 : static inline void swizzle( const uint32_t input, uint8_t& one,
41 : uint8_t& two, uint8_t& three, uint8_t& four )
42 : {
43 :
44 0 : one = ( input & 0xf ) | (( input &( LB_BIT14 | LB_BIT13 )) >> 8 ) |
45 0 : (( input &( LB_BIT24 | LB_BIT23 )) >> 16 );
46 :
47 0 : two = (( input &( LB_BIT26 | LB_BIT25 )) >> 24 ) |
48 0 : ( input &( LB_BIT6 | LB_BIT5 )) |
49 0 : (( input &( LB_BIT16 | LB_BIT15 )) >> 12 ) |
50 0 : (( input &( LB_BIT12 | LB_BIT11 )) >> 4 );
51 :
52 0 : three = (( input &( LB_BIT28 | LB_BIT27 )) >> 22 ) |
53 0 : (( input &( LB_BIT18 | LB_BIT17 )) >> 14 ) |
54 0 : ( input &( LB_BIT8 | LB_BIT7 )) |
55 0 : (( input &( LB_BIT22 | LB_BIT21 )) >> 20 );
56 :
57 0 : four = (( input &( LB_BIT32 | LB_BIT31 |
58 0 : LB_BIT30 | LB_BIT29 )) >> 24 ) |
59 0 : (( input &( LB_BIT20 | LB_BIT19 )) >> 16 ) |
60 0 : (( input &( LB_BIT10 | LB_BIT9 )) >> 8 );
61 0 : }
62 :
63 0 : static inline void swizzle( const uint32_t, uint8_t&, uint8_t&, uint8_t& )
64 0 : { assert( 0 ); }
65 :
66 0 : static inline uint32_t deswizzle( const uint8_t one, const uint8_t two,
67 : const uint8_t three, const uint8_t four )
68 : {
69 0 : return ( one & 0xf ) |
70 0 : (( one &( LB_BIT5 | LB_BIT6 )) << 8 ) |
71 0 : (( one &( LB_BIT7 | LB_BIT8 )) << 16 ) |
72 0 : (( two &( LB_BIT1 | LB_BIT2 )) << 24 ) |
73 0 : (( two &( LB_BIT3 | LB_BIT4 )) << 12 ) |
74 0 : ( two & 0x30 ) |
75 0 : (( two &( LB_BIT7 | LB_BIT8 )) << 4 )|
76 0 : ( three & 0xc0) |
77 0 : (( three &( LB_BIT6 | LB_BIT5 )) << 22 ) |
78 0 : (( three &( LB_BIT4 | LB_BIT3 )) << 14 ) |
79 0 : (( three &( LB_BIT2 | LB_BIT1 )) << 20 )|
80 0 : (( four & 0xf0 ) << 24 ) |
81 0 : (( four &( LB_BIT4 | LB_BIT3 )) << 16 ) |
82 0 : (( four &( LB_BIT2 | LB_BIT1 )) << 8 );
83 : }
84 :
85 0 : static inline uint32_t deswizzle( const uint8_t, const uint8_t,
86 0 : const uint8_t ) { assert( 0 ); return 0; }
87 : };
88 :
89 :
90 : }
91 :
92 0 : void CompressorRLE10A2::compress( const void* const inData,
93 : const eq_uint64_t nPixels,
94 : const bool /*alpha*/ )
95 : {
96 0 : _nResults = _compress< uint32_t, uint8_t, SwizzleUInt32,
97 0 : UseAlpha >( inData, nPixels, _results );
98 :
99 0 : }
100 :
101 0 : void CompressorRLE10A2::decompress( const void* const* inData,
102 : const eq_uint64_t* const inSizes,
103 : const unsigned numInputs,
104 : void* const outData,
105 : eq_uint64_t* const outDims,
106 : const eq_uint64_t flags, void* const )
107 : {
108 0 : const eq_uint64_t nPixels = ( flags & EQ_COMPRESSOR_DATA_1D) ?
109 0 : outDims[1] : outDims[1] * outDims[3];
110 : _decompress< uint32_t, uint8_t, SwizzleUInt32,
111 0 : UseAlpha >( inData, inSizes, numInputs, outData, nPixels );
112 0 : }
113 :
114 : }
115 3 : }
|