Pression  1.1.1
Compressor, decompressor, uploader and downloader plugins
plugins/compressor.h
Go to the documentation of this file.
1 
2 /* Copyright (c) 2009-2010, Cedric Stalder <cedric.stalder@gmail.com>
3  * 2009-2012, Stefan Eilemann <eile@equalizergraphics.com>
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 
167 #ifndef EQ_PLUGINS_COMPRESSOR
168 #define EQ_PLUGINS_COMPRESSOR
169 
171 #include <sys/types.h>
172 struct GLEWContextStruct;
173 struct WGLEWContextStruct;
174 typedef struct GLEWContextStruct GLEWContext;
175 typedef struct WGLEWContextStruct WGLEWContext;
176 typedef unsigned long long eq_uint64_t;
177 
178 #ifdef _MSC_VER
179 # ifdef EQ_PLUGIN_BUILD
180 # define EQ_PLUGIN_API __declspec(dllexport)
181 # else
182 # define EQ_PLUGIN_API __declspec(dllimport)
183 # endif
184 #else // _WIN32
185 # define EQ_PLUGIN_API __attribute__ ((visibility("default")))
186 #endif
187 
192 #define EQ_COMPRESSOR_VERSION 4
193 
194 #define EQ_COMPRESSOR_VERSION_1 1
195 
196 #define EQ_COMPRESSOR_VERSION_2 1
197 
198 #define EQ_COMPRESSOR_VERSION_3 1
199 
200 #define EQ_COMPRESSOR_VERSION_4 1
201 
203 #include "compressorTokens.h"
204 #include "compressorTypes.h"
205 
206 #ifdef __cplusplus
207 #include <iostream>
208 extern "C"
209 {
210 #endif
211 
223  #define EQ_COMPRESSOR_INPLACE 0x1
224 
229  #define EQ_COMPRESSOR_DATA_1D 0x2
230 
236  #define EQ_COMPRESSOR_DATA_2D 0x4
237 
254  #define EQ_COMPRESSOR_IGNORE_ALPHA 0x8
255 
256  #define EQ_COMPRESSOR_IGNORE_MSE EQ_COMPRESSOR_IGNORE_ALPHA
257 
264  #define EQ_COMPRESSOR_CPU 0
265 
272  #define EQ_COMPRESSOR_TRANSFER 0x10
273 
280  #define EQ_COMPRESSOR_USE_TEXTURE_RECT 0x20
281 
287  #define EQ_COMPRESSOR_USE_TEXTURE_2D 0x80
288 
294  #define EQ_COMPRESSOR_USE_FRAMEBUFFER 0x40
295 
302  #define EQ_COMPRESSOR_USE_ASYNC_DOWNLOAD 0x100
303 
304 #if 0 // Not implemented yet
305 
311  #define EQ_COMPRESSOR_USE_ASYNC_UPLOAD 0x200
312 #endif
313 
319  {
328  unsigned version;
329 
331  unsigned name;
332 
341  unsigned tokenType;
342 
344  eq_uint64_t capabilities;
345 
347  float quality;
348 
350  float ratio;
351 
353  float speed;
354 
367  unsigned outputTokenType;
368 
370  unsigned outputTokenSize;
371  };
372 
374  EQ_PLUGIN_API size_t EqCompressorGetNumCompressors();
375 
389  EQ_PLUGIN_API void EqCompressorGetInfo( const size_t n,
390  EqCompressorInfo* const info );
410  EQ_PLUGIN_API void* EqCompressorNewCompressor( const unsigned name );
411 
418  EQ_PLUGIN_API void EqCompressorDeleteCompressor( void* const compressor );
419 
433  EQ_PLUGIN_API void* EqCompressorNewDecompressor( const unsigned name );
434 
441  EQ_PLUGIN_API void EqCompressorDeleteDecompressor(void* const decompressor);
469  EQ_PLUGIN_API void EqCompressorCompress( void* const compressor,
470  const unsigned name,
471  void* const in,
472  const eq_uint64_t* inDims,
473  const eq_uint64_t flags );
474 
486  EQ_PLUGIN_API unsigned EqCompressorGetNumResults( void* const compressor,
487  const unsigned name );
488 
499  EQ_PLUGIN_API void EqCompressorGetResult( void* const compressor,
500  const unsigned name,
501  const unsigned i,
502  void** const out,
503  eq_uint64_t* const outSize );
504 
525  EQ_PLUGIN_API void EqCompressorDecompress( void* const decompressor,
526  const unsigned name,
527  const void* const* in,
528  const eq_uint64_t* const inSizes,
529  const unsigned numInputs,
530  void* const out,
531  eq_uint64_t* const outDims,
532  const eq_uint64_t flags );
551  EQ_PLUGIN_API bool EqCompressorIsCompatible( const unsigned name,
552  const GLEWContext* glewContext );
553 
602  EQ_PLUGIN_API void EqCompressorDownload( void* const compressor,
603  const unsigned name,
604  const GLEWContext* glewContext,
605  const eq_uint64_t inDims[4],
606  const unsigned source,
607  const eq_uint64_t flags,
608  eq_uint64_t outDims[4],
609  void** out );
610 
635  EQ_PLUGIN_API void EqCompressorStartDownload( void* const compressor,
636  const unsigned name,
637  const GLEWContext* glewContext,
638  const eq_uint64_t inDims[4],
639  const unsigned source,
640  const eq_uint64_t flags );
641 
659  EQ_PLUGIN_API void EqCompressorFinishDownload( void* const compressor,
660  const unsigned name,
661  const GLEWContext* glewContext,
662  const eq_uint64_t inDims[4],
663  const eq_uint64_t flags,
664  eq_uint64_t outDims[4],
665  void** out );
666 
709  EQ_PLUGIN_API void EqCompressorUpload( void* const decompressor,
710  const unsigned name,
711  const GLEWContext* glewContext,
712  const void* buffer,
713  const eq_uint64_t inDims[4],
714  const eq_uint64_t flags,
715  const eq_uint64_t outDims[4],
716  const unsigned destination );
717 #if 0
718  // TODO: add EqCompressorStart/FinishUpload and document operations and
719  // parameters
720 #endif
721 
722 #ifdef __cplusplus
723 } // extern "C"
724 
725 inline std::ostream& operator << ( std::ostream& os,
726  const EqCompressorInfo& info )
727 {
728  return os << std::hex << "name 0x" << info.name << " in 0x"
729  << info.tokenType << " out 0x" << info.outputTokenType
730  << " cap 0x" << info.capabilities << std::dec << " quality "
731  << info.quality <<" ratio " << info.ratio << " speed "
732  << info.speed << " v" << info.version;
733 }
734 #endif
735 #endif // EQ_PLUGINS_COMPRESSOR
unsigned outputTokenType
The output token type of a plugin.
EQ_PLUGIN_API void EqCompressorCompress(void *const compressor, const unsigned name, void *const in, const eq_uint64_t *inDims, const eq_uint64_t flags)
Compress data.
EQ_PLUGIN_API void EqCompressorGetResult(void *const compressor, const unsigned name, const unsigned i, void **const out, eq_uint64_t *const outSize)
Return the ith result of the last compression.
unsigned version
The compressor API version used.
unsigned outputTokenSize
The size of one output token in bytes.
EQ_PLUGIN_API void EqCompressorStartDownload(void *const compressor, const unsigned name, const GLEWContext *glewContext, const eq_uint64_t inDims[4], const unsigned source, const eq_uint64_t flags)
Start transferring frame buffer data into main memory.
float speed
Approximate compression speed relative to BYTE_RLE.
EQ_PLUGIN_API void * EqCompressorNewCompressor(const unsigned name)
Instantiate a new compressor or a new downloader.
Input and output token type definitions for compression plugins.
EQ_PLUGIN_API bool EqCompressorIsCompatible(const unsigned name, const GLEWContext *glewContext)
Check if the compressor may be used with the current OpenGL context.
unsigned tokenType
The input token type supported by the compressor.
Information about one compressor.
EQ_PLUGIN_API size_t EqCompressorGetNumCompressors()
EQ_PLUGIN_API void * EqCompressorNewDecompressor(const unsigned name)
Instantiate a new decompressor or a new uploader.
EQ_PLUGIN_API unsigned EqCompressorGetNumResults(void *const compressor, const unsigned name)
Return the number of results produced by the last compression.
float quality
Compression quality (1.0f: loss-less, <1.0f: lossy).
EQ_PLUGIN_API void EqCompressorGetInfo(const size_t n, EqCompressorInfo *const info)
Query information of the nth compressor in the DSO.
EQ_PLUGIN_API void EqCompressorDecompress(void *const decompressor, const unsigned name, const void *const *in, const eq_uint64_t *const inSizes, const unsigned numInputs, void *const out, eq_uint64_t *const outDims, const eq_uint64_t flags)
Decompress data.
EQ_PLUGIN_API void EqCompressorDeleteCompressor(void *const compressor)
Release a compressor or downloader instance.
EQ_PLUGIN_API void EqCompressorDeleteDecompressor(void *const decompressor)
Release a decompressor instance.
EQ_PLUGIN_API void EqCompressorUpload(void *const decompressor, const unsigned name, const GLEWContext *glewContext, const void *buffer, const eq_uint64_t inDims[4], const eq_uint64_t flags, const eq_uint64_t outDims[4], const unsigned destination)
Transfer data from main memory into GPU memory.
EQ_PLUGIN_API void EqCompressorFinishDownload(void *const compressor, const unsigned name, const GLEWContext *glewContext, const eq_uint64_t inDims[4], const eq_uint64_t flags, eq_uint64_t outDims[4], void **out)
Finish transferring frame buffer data into main memory.
unsigned name
The type name of the compressor.
EQ_PLUGIN_API void EqCompressorDownload(void *const compressor, const unsigned name, const GLEWContext *glewContext, const eq_uint64_t inDims[4], const unsigned source, const eq_uint64_t flags, eq_uint64_t outDims[4], void **out)
Transfer frame buffer data into main memory.
Compression plugin names.
eq_uint64_t capabilities
Capabilities supported by the compressor.
float ratio
Approximate compression ratio (sizeCompressed/sizeIn).