ImfMultiView.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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_MULTIVIEW_H
  6. #define INCLUDED_IMF_MULTIVIEW_H
  7. #include "ImfExport.h"
  8. #include "ImfNamespace.h"
  9. #include "ImfChannelList.h"
  10. #include "ImfStringVectorAttribute.h"
  11. //-----------------------------------------------------------------------------
  12. //
  13. // Functions related to accessing channels and views in multi-view
  14. // OpenEXR files.
  15. //
  16. // A multi-view image file contains two or more views of the same
  17. // scene, as seen from different viewpoints, for example, a left-eye
  18. // and a right-eye view for stereo displays. Each view has its own
  19. // set of image channels. A naming convention identifies the channels
  20. // that belong to a given view.
  21. //
  22. // A "multiView" attribute in the file header lists the names of the
  23. // views in an image (see ImfStandardAttributes.h), and channel names
  24. // of the form
  25. //
  26. // layer.view.channel
  27. //
  28. // allow channels to be matched with views.
  29. //
  30. // For compatibility with singe-view images, the first view listed in
  31. // the multiView attribute is the "default view", and channels that
  32. // have no periods in their names are considered part of the default
  33. // view.
  34. //
  35. // For example, if a file's multiView attribute lists the views
  36. // "left" and "right", in that order, then "left" is the default
  37. // view. Channels
  38. //
  39. // "R", "left.Z", "diffuse.left.R"
  40. //
  41. // are part of the "left" view; channels
  42. //
  43. // "right.R", "right.Z", "diffuse.right.R"
  44. //
  45. // are part of the "right" view; and channels
  46. //
  47. // "tmp.R", "right.diffuse.R", "diffuse.tmp.R"
  48. //
  49. // belong to no view at all.
  50. //
  51. //-----------------------------------------------------------------------------
  52. OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
  53. //
  54. // Return the name of the default view given a multi-view string vector,
  55. // that is, return the first element of the string vector. If the string
  56. // vector is empty, return "".
  57. //
  58. IMF_EXPORT
  59. std::string defaultViewName (const StringVector &multiView);
  60. //
  61. // Given the name of a channel, return the name of the view to
  62. // which it belongs. Returns the empty string ("") if the channel
  63. // is not a member of any named view.
  64. //
  65. IMF_EXPORT
  66. std::string viewFromChannelName (const std::string &channel,
  67. const StringVector &multiView);
  68. //
  69. // Return whether channel1 and channel2 are the same channel but
  70. // viewed in different views. (Return false if either channel
  71. // belongs to no view or if both channels belong to the same view.)
  72. //
  73. IMF_EXPORT
  74. bool areCounterparts (const std::string &channel1,
  75. const std::string &channel2,
  76. const StringVector &multiView);
  77. //
  78. // Return a list of all channels belonging to view viewName.
  79. //
  80. IMF_EXPORT
  81. ChannelList channelsInView (const std::string &viewName,
  82. const ChannelList &channelList,
  83. const StringVector &multiView);
  84. //
  85. // Return a list of channels not associated with any view.
  86. //
  87. IMF_EXPORT
  88. ChannelList channelsInNoView (const ChannelList &channelList,
  89. const StringVector &multiView);
  90. //
  91. // Given the name of a channel, return a list of the same channel
  92. // in all views (for example, given X.left.Y return X.left.Y,
  93. // X.right.Y, X.centre.Y, etc.).
  94. //
  95. IMF_EXPORT
  96. ChannelList channelInAllViews (const std::string &channame,
  97. const ChannelList &channelList,
  98. const StringVector &multiView);
  99. //
  100. // Given the name of a channel in one view, return the corresponding
  101. // channel name for view otherViewName. Return "" if no corresponding
  102. // channel exists in view otherViewName, or if view otherViewName doesn't
  103. // exist.
  104. //
  105. IMF_EXPORT
  106. std::string channelInOtherView (const std::string &channel,
  107. const ChannelList &channelList,
  108. const StringVector &multiView,
  109. const std::string &otherViewName);
  110. //
  111. // Given a channel name that does not include a view name, insert
  112. // multiView[i] into the channel name at the appropriate location.
  113. // If i is zero and the channel name contains no periods, then do
  114. // not insert the view name.
  115. //
  116. IMF_EXPORT
  117. std::string insertViewName (const std::string &channel,
  118. const StringVector &multiView,
  119. int i);
  120. //
  121. // Given a channel name that does may include a view name, return
  122. // string without the view name. If the string does not contain
  123. // the view name, return the string unaltered.
  124. // (Will only remove the viewname if it is in the correct position
  125. // in the string)
  126. //
  127. IMF_EXPORT
  128. std::string removeViewName (const std::string &channel,
  129. const std::string &view);
  130. OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
  131. #endif