ImfMultiView.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. ///////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2007, Weta Digital Ltd
  4. //
  5. // All rights reserved.
  6. //
  7. // Redistribution and use in source and binary forms, with or without
  8. // modification, are permitted provided that the following conditions are
  9. // met:
  10. // * Redistributions of source code must retain the above copyright
  11. // notice, this list of conditions and the following disclaimer.
  12. // * Redistributions in binary form must reproduce the above
  13. // copyright notice, this list of conditions and the following disclaimer
  14. // in the documentation and/or other materials provided with the
  15. // distribution.
  16. // * Neither the name of Weta Digital nor the names of
  17. // its contributors may be used to endorse or promote products derived
  18. // from this software without specific prior written permission.
  19. //
  20. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. //
  32. ///////////////////////////////////////////////////////////////////////////
  33. #ifndef INCLUDED_IMF_MULTIVIEW_H
  34. #define INCLUDED_IMF_MULTIVIEW_H
  35. #include "ImfChannelList.h"
  36. #include "ImfStringVectorAttribute.h"
  37. #include "ImfExport.h"
  38. #include "ImfNamespace.h"
  39. //-----------------------------------------------------------------------------
  40. //
  41. // Functions related to accessing channels and views in multi-view
  42. // OpenEXR files.
  43. //
  44. // A multi-view image file contains two or more views of the same
  45. // scene, as seen from different viewpoints, for example, a left-eye
  46. // and a right-eye view for stereo displays. Each view has its own
  47. // set of image channels. A naming convention identifies the channels
  48. // that belong to a given view.
  49. //
  50. // A "multiView" attribute in the file header lists the names of the
  51. // views in an image (see ImfStandardAttributes.h), and channel names
  52. // of the form
  53. //
  54. // layer.view.channel
  55. //
  56. // allow channels to be matched with views.
  57. //
  58. // For compatibility with singe-view images, the first view listed in
  59. // the multiView attribute is the "default view", and channels that
  60. // have no periods in their names are considered part of the default
  61. // view.
  62. //
  63. // For example, if a file's multiView attribute lists the views
  64. // "left" and "right", in that order, then "left" is the default
  65. // view. Channels
  66. //
  67. // "R", "left.Z", "diffuse.left.R"
  68. //
  69. // are part of the "left" view; channels
  70. //
  71. // "right.R", "right.Z", "diffuse.right.R"
  72. //
  73. // are part of the "right" view; and channels
  74. //
  75. // "tmp.R", "right.diffuse.R", "diffuse.tmp.R"
  76. //
  77. // belong to no view at all.
  78. //
  79. //-----------------------------------------------------------------------------
  80. OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
  81. //
  82. // Return the name of the default view given a multi-view string vector,
  83. // that is, return the first element of the string vector. If the string
  84. // vector is empty, return "".
  85. //
  86. IMF_EXPORT
  87. std::string defaultViewName (const StringVector &multiView);
  88. //
  89. // Given the name of a channel, return the name of the view to
  90. // which it belongs. Returns the empty string ("") if the channel
  91. // is not a member of any named view.
  92. //
  93. IMF_EXPORT
  94. std::string viewFromChannelName (const std::string &channel,
  95. const StringVector &multiView);
  96. //
  97. // Return whether channel1 and channel2 are the same channel but
  98. // viewed in different views. (Return false if either channel
  99. // belongs to no view or if both channels belong to the same view.)
  100. //
  101. IMF_EXPORT
  102. bool areCounterparts (const std::string &channel1,
  103. const std::string &channel2,
  104. const StringVector &multiView);
  105. //
  106. // Return a list of all channels belonging to view viewName.
  107. //
  108. IMF_EXPORT
  109. ChannelList channelsInView (const std::string &viewName,
  110. const ChannelList &channelList,
  111. const StringVector &multiView);
  112. //
  113. // Return a list of channels not associated with any view.
  114. //
  115. IMF_EXPORT
  116. ChannelList channelsInNoView (const ChannelList &channelList,
  117. const StringVector &multiView);
  118. //
  119. // Given the name of a channel, return a list of the same channel
  120. // in all views (for example, given X.left.Y return X.left.Y,
  121. // X.right.Y, X.centre.Y, etc.).
  122. //
  123. IMF_EXPORT
  124. ChannelList channelInAllViews (const std::string &channame,
  125. const ChannelList &channelList,
  126. const StringVector &multiView);
  127. //
  128. // Given the name of a channel in one view, return the corresponding
  129. // channel name for view otherViewName. Return "" if no corresponding
  130. // channel exists in view otherViewName, or if view otherViewName doesn't
  131. // exist.
  132. //
  133. IMF_EXPORT
  134. std::string channelInOtherView (const std::string &channel,
  135. const ChannelList &channelList,
  136. const StringVector &multiView,
  137. const std::string &otherViewName);
  138. //
  139. // Given a channel name that does not include a view name, insert
  140. // multiView[i] into the channel name at the appropriate location.
  141. // If i is zero and the channel name contains no periods, then do
  142. // not insert the view name.
  143. //
  144. IMF_EXPORT
  145. std::string insertViewName (const std::string &channel,
  146. const StringVector &multiView,
  147. int i);
  148. //
  149. // Given a channel name that does may include a view name, return
  150. // string without the view name. If the string does not contain
  151. // the view name, return the string unaltered.
  152. // (Will only remove the viewname if it is in the correct position
  153. // in the string)
  154. //
  155. IMF_EXPORT
  156. std::string removeViewName (const std::string &channel,
  157. const std::string &view);
  158. OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
  159. #endif