HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PXL_DeepCompressor.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: PXL_DeepCompressor.h (PXL Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __PXL_DeepCompressor__
12 #define __PXL_DeepCompressor__
13 
14 #include "PXL_API.h"
15 #include "PXL_DeepChannelList.h"
16 #include "PXL_DeepSampleList.h"
17 #include "PXL_Forward.h"
18 #include <UT/UT_NonCopyable.h>
19 #include <UT/UT_SharedPtr.h>
20 #include <UT/UT_Vector2.h>
21 #include <SYS/SYS_Types.h>
22 
23 class UT_Options;
24 
25 extern "C" {
26  /// DSO's should have this function declared. The function should call
27  /// PXL_DeepCompressor::registerCompressor.
29 };
30 
31 /// Combines a set of deep sample lists to create a single new deep sample list.
32 ///
33 /// Deep compressors take multiple sample lists and combine them, possibly
34 /// compressing them into a single deep sample list. The compressor may sit
35 /// between the renderer and a deep image writer. Or it may be used to create
36 /// MIP Maps for deep images.
37 ///
38 /// When used by a renderer, compressors have the ability to add or modify
39 /// channels.
40 ///
41 /// Factory compressors include:
42 ///
43 /// Name = "default
44 /// Options:
45 /// - zbias
46 ///
48 {
49 public:
51  {
52  public:
53  Factory() = default;
54  virtual ~Factory();
55 
57 
58  /// Method to construct a deep compressor given options.
59  /// The caller to the compressor will be passing pixel sample lists
60  virtual PXL_DeepCompressorPtr create(
61  const PXL_DeepChannelListPtr &c,
62  const UT_Options &options
63  ) const = 0;
64 
65  /// Load all compressor factories
66  static void initCompressors();
67 
68  /// Register a new compressor. This should be called during
69  /// initCompressors() only.
70  static void registerCompressor(const char *name,
71  const UT_SharedPtr<Factory> &factory);
72 
73  /// Create a pixel compressor. This will return NULL for an invalid
74  /// compressor.
75  /// Factory compressors include:
76  /// - "null" @n
77  /// No compression. Records are just merged with no combining.
78  /// - "simple" @n
79  /// Option: "float zbias" Controls zbias for compression @n
80  /// This compressor will peform simple compression, merging similar
81  /// records within a z-tolerance.
82  static PXL_DeepCompressorPtr create(const char *name,
83  const PXL_DeepChannelListPtr &c,
84  const UT_Options &options);
85 
86  /// Return the list of possible compressors
87  static void getCompressors(UT_StringArray &types);
88  };
89 
91  virtual ~PXL_DeepCompressor();
92 
94 
95  /// Return the channels as a result of the compress() operation
97 
98  /// Compress the samples provided into a single PXL_DeepSampleListPtr. The
99  /// @c samples array will contain <tt> pixel.myPixelResolution.x() *
100  /// pixel.myPixelResolution.y()</tt> entries.
102  int nsamples) const
103  {
104  return doMerge(slist, nsamples);
105  }
108  ) const
109  {
110  return doMerge(slist.array(), slist.entries());
111  }
112  /// Compress a single sample list, returning a new sample list.
114  {
115  return doCompress(slist);
116  }
117 
118  void dump(const char *msg="") const;
119 
120 protected:
121  virtual const char *className() const = 0;
122 
123  /// Merge multiple deep sample lists into a single deep sample list. For
124  /// example, this is done when creating MIP maps.
125  virtual PXL_DeepSampleListPtr doMerge(
126  const PXL_DeepSampleListPtr *slist,
127  int nsamples
128  ) const = 0;
129  /// Compress a single sample list, returning a new sample list.
130  virtual PXL_DeepSampleListPtr doCompress(
132  ) const = 0;
133 
134  /// Dump any optional information to stdout
135  virtual void doDump() const;
136 };
137 
138 #endif
#define SYS_VISIBILITY_EXPORT
T * array()
Definition: UT_Array.h:819
#define PXL_API
Definition: PXL_API.h:10
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:36
SYS_VISIBILITY_EXPORT void newPXLDeepCompressor()
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
GLuint const GLchar * name
Definition: glcorearb.h:786
GLsizei samples
Definition: glcorearb.h:1298
exint entries() const
Alias of size(). size() is preferred.
Definition: UT_Array.h:648
A map of string to various well defined value types.
Definition: UT_Options.h:84
PXL_DeepSampleListPtr merge(const UT_Array< PXL_DeepSampleListPtr > &slist) const
UT_SharedPtr< PXL_DeepCompressor > PXL_DeepCompressorPtr
Definition: PXL_Forward.h:26
GLsizei GLenum GLenum * types
Definition: glcorearb.h:2542
#define const
Definition: zconf.h:214
ImageBuf OIIO_API channels(const ImageBuf &src, int nchannels, cspan< int > channelorder, cspan< float > channelvalues={}, cspan< std::string > newchannelnames={}, bool shuffle_channel_names=false, int nthreads=0)
PXL_DeepSampleListPtr compress(const PXL_DeepSampleListPtr &slist) const
Compress a single sample list, returning a new sample list.