Home | History | Annotate | Download | only in IlmImf
      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 
     34 
     35 #ifndef INCLUDED_IMF_MULTIVIEW_H
     36 #define INCLUDED_IMF_MULTIVIEW_H
     37 
     38 #include <ImfChannelList.h>
     39 #include <ImfStringVectorAttribute.h>
     40 
     41 //-----------------------------------------------------------------------------
     42 //
     43 //	Functions related to accessing channels and views in multi-view
     44 //	OpenEXR files.
     45 //
     46 //	A multi-view image file contains two or more views of the same
     47 //	scene, as seen from different viewpoints, for example, a left-eye
     48 //	and a right-eye view for stereo displays.  Each view has its own
     49 //	set of image channels.  A naming convention identifies the channels
     50 //	that belong to a given view.
     51 //
     52 //	A "multiView" attribute in the file header lists the names of the
     53 //	views in an image (see ImfStandardAttributes.h), and channel names
     54 //	of the form
     55 //
     56 //		layer.view.channel
     57 //
     58 //	allow channels to be matched with views.
     59 //
     60 //	For compatibility with singe-view images, the first view listed in
     61 //	the multiView attribute is the "default view", and channels that
     62 //	have no periods in their names are considered part of the default
     63 //	view.
     64 //
     65 //	For example, if a file's multiView attribute lists the views
     66 //	"left" and "right", in that order, then "left" is the default
     67 //	view.  Channels
     68 //
     69 //		"R", "left.Z", "diffuse.left.R"
     70 //
     71 //	are part of the "left" view; channels
     72 //
     73 //		"right.R", "right.Z", "diffuse.right.R"
     74 //
     75 //	are part of the "right" view; and channels
     76 //
     77 //		"tmp.R", "right.diffuse.R", "diffuse.tmp.R"
     78 //
     79 //	belong to no view at all.
     80 //
     81 //-----------------------------------------------------------------------------
     82 
     83 namespace Imf {
     84 
     85 //
     86 // Return the name of the default view given a multi-view string vector,
     87 // that is, return the first element of the string vector.  If the string
     88 // vector is empty, return "".
     89 //
     90 
     91 std::string defaultViewName (const StringVector &multiView);
     92 
     93 
     94 //
     95 // Given the name of a channel, return the name of the view to
     96 // which it belongs.  Returns the empty string ("") if the channel
     97 // is not a member of any named view.
     98 //
     99 
    100 std::string viewFromChannelName (const std::string &channel,
    101                                  const StringVector &multiView);
    102 
    103 
    104 //
    105 // Return whether channel1 and channel2 are the same channel but
    106 // viewed in different views.  (Return false if either channel
    107 // belongs to no view or if both channels belong to the same view.)
    108 //
    109 
    110 bool areCounterparts (const std::string &channel1,
    111                       const std::string &channel2,
    112                       const StringVector &multiView);
    113 
    114 //
    115 // Return a list of all channels belonging to view viewName.
    116 //
    117 
    118 ChannelList channelsInView (const std::string &viewName,
    119                             const ChannelList &channelList,
    120                             const StringVector &multiView);
    121 
    122 //
    123 // Return a list of channels not associated with any view.
    124 //
    125 
    126 ChannelList channelsInNoView (const ChannelList &channelList,
    127                               const StringVector &multiView);
    128 
    129 //
    130 // Given the name of a channel, return a list of the same channel
    131 // in all views (for example, given X.left.Y return X.left.Y,
    132 // X.right.Y, X.centre.Y, etc.).
    133 //
    134 
    135 ChannelList channelInAllViews (const std::string &channame,
    136                                const ChannelList &channelList,
    137                                const StringVector &multiView);
    138 
    139 //
    140 // Given the name of a channel in one view, return the corresponding
    141 // channel name for view otherViewName.  Return "" if no corresponding
    142 // channel exists in view otherViewName, or if view otherViewName doesn't
    143 // exist.
    144 //
    145 
    146 std::string channelInOtherView (const std::string &channel,
    147                                 const ChannelList &channelList,
    148                                 const StringVector &multiView,
    149                                 const std::string &otherViewName);
    150 
    151 //
    152 // Given a channel name that does not include a view name, insert
    153 // multiView[i] into the channel name at the appropriate location.
    154 // If i is zero and the channel name contains no periods, then do
    155 // not insert the view name.
    156 //
    157 
    158 std::string insertViewName (const std::string &channel,
    159                 const StringVector &multiView,
    160                 int i);
    161 
    162 } // namespace Imf
    163 
    164 #endif
    165