Line data Source code
1 :
2 : /*
3 : * Copyright (c) 2010, Eyescale Software GmbH <info@eyescale.ch>
4 : * 2013, Stefan.Eilemann@epfl.ch
5 : *
6 : * This library is free software; you can redistribute it and/or modify it under
7 : * the terms of the GNU Lesser General Public License version 2.1 as published
8 : * by the Free Software Foundation.
9 : *
10 : * This library is distributed in the hope that it will be useful, but WITHOUT
11 : * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 : * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 : * details.
14 : *
15 : * You should have received a copy of the GNU Lesser General Public License
16 : * along with this library; if not, write to the Free Software Foundation, Inc.,
17 : * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 : */
19 :
20 : #ifndef LUNCHBOX_PLUGIN_COMPRESSORTURBOJPEG
21 : #define LUNCHBOX_PLUGIN_COMPRESSORTURBOJPEG
22 :
23 : #include "compressor.h"
24 : #include <turbojpeg.h>
25 : #undef max
26 :
27 : namespace lunchbox
28 : {
29 : namespace plugin
30 : {
31 :
32 : class CompressorTurboJPEG : public Compressor
33 : {
34 : public:
35 : explicit CompressorTurboJPEG( const unsigned name );
36 : virtual ~CompressorTurboJPEG();
37 :
38 : void compress( const void* const inData, const eq_uint64_t* inDims,
39 : const eq_uint64_t flags ) override;
40 :
41 : static void decompress( const void* const* inData,
42 : const eq_uint64_t* const inSizes,
43 : const unsigned nInputs, void* const outData,
44 : eq_uint64_t* const outDims, const eq_uint64_t flags,
45 : void* const );
46 :
47 0 : static Compressor* getNewCompressor( const unsigned name )
48 0 : { return new CompressorTurboJPEG( name ); }
49 :
50 : private:
51 : eq_uint64_t _quality;
52 : eq_uint64_t _tokenSize;
53 : eq_uint64_t _flags;
54 :
55 : void* _encoder;
56 : void* _decoder;
57 :
58 : void _decompress( const void* const* inData, const eq_uint64_t inSize,
59 : const unsigned nInputs, void* const outData,
60 : eq_uint64_t* const outDims, const bool useAlpha );
61 : void _extractAlpha( const unsigned char* inData,
62 : const eq_uint64_t nPixels );
63 : void _addAlpha( const void* const inAlpha, unsigned* out,
64 : const eq_uint64_t nPixels ) const;
65 : };
66 :
67 : }
68 : }
69 : #endif // LUNCHBOX_PLUGIN_COMPRESSORTURBOJPEG
|