ImfMultiView.h 5.75 KB
Newer Older
wester committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2007, Weta Digital Ltd
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// *       Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// *       Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// *       Neither the name of Weta Digital nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////


#ifndef INCLUDED_IMF_MULTIVIEW_H
#define INCLUDED_IMF_MULTIVIEW_H

#include <ImfChannelList.h>
#include <ImfStringVectorAttribute.h>

//-----------------------------------------------------------------------------
//
//	Functions related to accessing channels and views in multi-view
//	OpenEXR files.
//
//	A multi-view image file contains two or more views of the same
//	scene, as seen from different viewpoints, for example, a left-eye
//	and a right-eye view for stereo displays.  Each view has its own
//	set of image channels.  A naming convention identifies the channels
//	that belong to a given view.
//
//	A "multiView" attribute in the file header lists the names of the
//	views in an image (see ImfStandardAttributes.h), and channel names
//	of the form
//
//		layer.view.channel
//
//	allow channels to be matched with views.
//
//	For compatibility with singe-view images, the first view listed in
//	the multiView attribute is the "default view", and channels that
//	have no periods in their names are considered part of the default
//	view.
//
//	For example, if a file's multiView attribute lists the views
//	"left" and "right", in that order, then "left" is the default
//	view.  Channels
//
//		"R", "left.Z", "diffuse.left.R"
//
//	are part of the "left" view; channels
//
//		"right.R", "right.Z", "diffuse.right.R"
//
//	are part of the "right" view; and channels
//
//		"tmp.R", "right.diffuse.R", "diffuse.tmp.R"
//
//	belong to no view at all.
//
//-----------------------------------------------------------------------------

namespace Imf {

//
// Return the name of the default view given a multi-view string vector,
// that is, return the first element of the string vector.  If the string
// vector is empty, return "".
//

std::string defaultViewName (const StringVector &multiView);


//
// Given the name of a channel, return the name of the view to
// which it belongs.  Returns the empty string ("") if the channel
// is not a member of any named view.
//

std::string viewFromChannelName (const std::string &channel,
                                 const StringVector &multiView);


//
// Return whether channel1 and channel2 are the same channel but
// viewed in different views.  (Return false if either channel
// belongs to no view or if both channels belong to the same view.)
//

bool areCounterparts (const std::string &channel1,
                      const std::string &channel2,
                      const StringVector &multiView);

//
// Return a list of all channels belonging to view viewName.
//

ChannelList channelsInView (const std::string &viewName,
                            const ChannelList &channelList,
                            const StringVector &multiView);

//
// Return a list of channels not associated with any view.
//

ChannelList channelsInNoView (const ChannelList &channelList,
                              const StringVector &multiView);

//
// Given the name of a channel, return a list of the same channel
// in all views (for example, given X.left.Y return X.left.Y,
// X.right.Y, X.centre.Y, etc.).
//

ChannelList channelInAllViews (const std::string &channame,
                               const ChannelList &channelList,
                               const StringVector &multiView);

//
// Given the name of a channel in one view, return the corresponding
// channel name for view otherViewName.  Return "" if no corresponding
// channel exists in view otherViewName, or if view otherViewName doesn't
// exist.
//

std::string channelInOtherView (const std::string &channel,
                                const ChannelList &channelList,
                                const StringVector &multiView,
                                const std::string &otherViewName);

//
// Given a channel name that does not include a view name, insert
// multiView[i] into the channel name at the appropriate location.
// If i is zero and the channel name contains no periods, then do
// not insert the view name.
//

std::string insertViewName (const std::string &channel,
                const StringVector &multiView,
                int i);

} // namespace Imf

#endif