ImfCompositeDeepScanLine.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. //
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. // Copyright (c) Weta Digital, Ltd and Contributors to the OpenEXR Project.
  4. //
  5. #ifndef INCLUDED_IMF_COMPOSITEDEEPSCANLINE_H
  6. #define INCLUDED_IMF_COMPOSITEDEEPSCANLINE_H
  7. //-----------------------------------------------------------------------------
  8. //
  9. // Class to composite deep samples into a frame buffer
  10. // Initialise with a deep input part or deep inputfile
  11. // (also supports multiple files and parts, and will
  12. // composite them together, as long as their sizes and channelmaps agree)
  13. //
  14. // Then call setFrameBuffer, and readPixels, exactly as for reading
  15. // regular scanline images.
  16. //
  17. // Restrictions - source file(s) must contain at least Z and alpha channels
  18. // - if multiple files/parts are provided, sizes must match
  19. // - all requested channels will be composited as premultiplied
  20. // - only half and float channels can be requested
  21. //
  22. // This object should not be considered threadsafe
  23. //
  24. // The default compositing engine will give spurious results with overlapping
  25. // volumetric samples - you may derive from DeepCompositing class, override the
  26. // sort_pixel() and composite_pixel() functions, and pass an instance to
  27. // setCompositing().
  28. //
  29. //-----------------------------------------------------------------------------
  30. #include "ImfForward.h"
  31. #include <ImathBox.h>
  32. OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
  33. class IMF_EXPORT_TYPE CompositeDeepScanLine
  34. {
  35. public:
  36. IMF_EXPORT
  37. CompositeDeepScanLine ();
  38. IMF_EXPORT
  39. virtual ~CompositeDeepScanLine ();
  40. /// set the source data as a part
  41. ///@note all parts must remain valid until after last interaction with DeepComp
  42. IMF_EXPORT
  43. void addSource (DeepScanLineInputPart* part);
  44. /// set the source data as a file
  45. ///@note all file must remain valid until after last interaction with DeepComp
  46. IMF_EXPORT
  47. void addSource (DeepScanLineInputFile* file);
  48. /////////////////////////////////////////
  49. //
  50. // set the frame buffer for output values
  51. // the buffers specified must be large enough
  52. // to handle the dataWindow()
  53. //
  54. /////////////////////////////////////////
  55. IMF_EXPORT
  56. void setFrameBuffer (const FrameBuffer& fr);
  57. /////////////////////////////////////////
  58. //
  59. // retrieve frameBuffer
  60. //
  61. ////////////////////////////////////////
  62. IMF_EXPORT
  63. const FrameBuffer& frameBuffer () const;
  64. //////////////////////////////////////////////////
  65. //
  66. // read scanlines start to end from the source(s)
  67. // storing the result in the frame buffer provided
  68. //
  69. //////////////////////////////////////////////////
  70. IMF_EXPORT
  71. void readPixels (int start, int end);
  72. IMF_EXPORT
  73. int sources () const; // return number of sources
  74. /////////////////////////////////////////////////
  75. //
  76. // retrieve the datawindow
  77. // If multiple parts are specified, this will
  78. // be the union of the dataWindow of all parts
  79. //
  80. ////////////////////////////////////////////////
  81. IMF_EXPORT
  82. const IMATH_NAMESPACE::Box2i& dataWindow () const;
  83. //
  84. // override default sorting/compositing operation
  85. // (otherwise an instance of the base class will be used)
  86. //
  87. IMF_EXPORT
  88. void setCompositing (DeepCompositing*);
  89. struct IMF_HIDDEN Data;
  90. //
  91. // set the maximum number of samples that will be composited.
  92. // If a single scanline has more samples, readPixels will throw
  93. // an exception. This mechanism prevents the library allocating
  94. // excessive memory to composite deep scanline images.
  95. // A value of 0 will cause deep compositing to be disabled entirely
  96. // A negative value disables the limit, allowing images with
  97. // arbitrarily large sample counts to be composited
  98. //
  99. IMF_EXPORT
  100. static void setMaximumSampleCount(int64_t sampleCount);
  101. IMF_EXPORT
  102. static int64_t getMaximumSampleCount();
  103. private:
  104. struct Data* _Data;
  105. CompositeDeepScanLine (const CompositeDeepScanLine&) = delete;
  106. CompositeDeepScanLine& operator= (const CompositeDeepScanLine&) = delete;
  107. CompositeDeepScanLine (CompositeDeepScanLine&&) = delete;
  108. CompositeDeepScanLine& operator= (CompositeDeepScanLine&&) = delete;
  109. };
  110. OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
  111. #endif