ImfStandardAttributes.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. //
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. // Copyright (c) Contributors to the OpenEXR Project.
  4. //
  5. #ifndef INCLUDED_IMF_STANDARD_ATTRIBUTES_H
  6. #define INCLUDED_IMF_STANDARD_ATTRIBUTES_H
  7. //-----------------------------------------------------------------------------
  8. //
  9. // Optional Standard Attributes -- these attributes are "optional"
  10. // because not every image file header has them, but they define a
  11. // "standard" way to represent commonly used data in the file header.
  12. //
  13. // For each attribute, with name "foo", and type "T", the following
  14. // functions are automatically generated via macros:
  15. //
  16. // void addFoo (Header &header, const T &value);
  17. // bool hasFoo (const Header &header);
  18. // const TypedAttribute<T> & fooAttribute (const Header &header);
  19. // TypedAttribute<T> & fooAttribute (Header &header);
  20. // const T & foo (const Header &Header);
  21. // T & foo (Header &Header);
  22. //
  23. //-----------------------------------------------------------------------------
  24. #include "ImfHeader.h"
  25. #include "ImfBoxAttribute.h"
  26. #include "ImfChromaticitiesAttribute.h"
  27. #include "ImfEnvmapAttribute.h"
  28. #include "ImfDeepImageStateAttribute.h"
  29. #include "ImfFloatAttribute.h"
  30. #include "ImfKeyCodeAttribute.h"
  31. #include "ImfMatrixAttribute.h"
  32. #include "ImfRationalAttribute.h"
  33. #include "ImfStringAttribute.h"
  34. #include "ImfStringVectorAttribute.h"
  35. #include "ImfTimeCodeAttribute.h"
  36. #include "ImfVecAttribute.h"
  37. #include "ImfNamespace.h"
  38. #include "ImfExport.h"
  39. #include "ImfIDManifestAttribute.h"
  40. #define IMF_ADD_SUFFIX(suffix) add##suffix
  41. #define IMF_HAS_SUFFIX(suffix) has##suffix
  42. #define IMF_NAME_ATTRIBUTE(name) name##Attribute
  43. #define IMF_STD_ATTRIBUTE_DEF(name, suffix, object) \
  44. \
  45. OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER \
  46. IMF_EXPORT void IMF_ADD_SUFFIX (suffix) ( \
  47. Header & header, const object& v); \
  48. IMF_EXPORT bool IMF_HAS_SUFFIX (suffix) (const Header& header); \
  49. IMF_EXPORT const TypedAttribute<object>& IMF_NAME_ATTRIBUTE (name) ( \
  50. const Header& header); \
  51. IMF_EXPORT TypedAttribute<object>& IMF_NAME_ATTRIBUTE (name) ( \
  52. Header & header); \
  53. IMF_EXPORT const object& name (const Header& header); \
  54. IMF_EXPORT object& name (Header& header); \
  55. OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
  56. #define IMF_STD_ATTRIBUTE_DEF_DEPRECATED(name, suffix, object, msg) \
  57. \
  58. OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER \
  59. OPENEXR_DEPRECATED (msg) \
  60. IMF_EXPORT void IMF_ADD_SUFFIX (suffix) ( \
  61. Header & header, const object& v); \
  62. OPENEXR_DEPRECATED (msg) \
  63. IMF_EXPORT bool IMF_HAS_SUFFIX (suffix) (const Header& header); \
  64. OPENEXR_DEPRECATED (msg) \
  65. IMF_EXPORT const TypedAttribute<object>& IMF_NAME_ATTRIBUTE (name) ( \
  66. const Header& header); \
  67. OPENEXR_DEPRECATED (msg) \
  68. IMF_EXPORT TypedAttribute<object>& IMF_NAME_ATTRIBUTE (name) ( \
  69. Header & header); \
  70. OPENEXR_DEPRECATED (msg) \
  71. IMF_EXPORT const object& name (const Header& header); \
  72. OPENEXR_DEPRECATED (msg) IMF_EXPORT object& name (Header& header); \
  73. OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
  74. //
  75. // chromaticities -- for RGB images, specifies the CIE (x,y)
  76. // chromaticities of the primaries and the white point
  77. //
  78. IMF_STD_ATTRIBUTE_DEF (chromaticities, Chromaticities, Chromaticities)
  79. //
  80. // whiteLuminance -- for RGB images, defines the luminance, in Nits
  81. // (candelas per square meter) of the RGB value (1.0, 1.0, 1.0).
  82. //
  83. // If the chromaticities and the whiteLuminance of an RGB image are
  84. // known, then it is possible to convert the image's pixels from RGB
  85. // to CIE XYZ tristimulus values (see function RGBtoXYZ() in header
  86. // file ImfChromaticities.h).
  87. //
  88. //
  89. IMF_STD_ATTRIBUTE_DEF (whiteLuminance, WhiteLuminance, float)
  90. //
  91. // adoptedNeutral -- specifies the CIE (x,y) coordinates that should
  92. // be considered neutral during color rendering. Pixels in the image
  93. // file whose (x,y) coordinates match the adoptedNeutral value should
  94. // be mapped to neutral values on the display.
  95. //
  96. IMF_STD_ATTRIBUTE_DEF (adoptedNeutral, AdoptedNeutral, IMATH_NAMESPACE::V2f)
  97. //
  98. // renderingTransform, lookModTransform -- specify the names of the
  99. // CTL functions that implements the intended color rendering and look
  100. // modification transforms for this image.
  101. //
  102. IMF_STD_ATTRIBUTE_DEF (renderingTransform, RenderingTransform, std::string)
  103. IMF_STD_ATTRIBUTE_DEF (lookModTransform, LookModTransform, std::string)
  104. //
  105. // xDensity -- horizontal output density, in pixels per inch.
  106. // The image's vertical output density is xDensity * pixelAspectRatio.
  107. //
  108. IMF_STD_ATTRIBUTE_DEF (xDensity, XDensity, float)
  109. //
  110. // owner -- name of the owner of the image
  111. //
  112. IMF_STD_ATTRIBUTE_DEF (owner, Owner, std::string)
  113. //
  114. // comments -- additional image information in human-readable
  115. // form, for example a verbal description of the image
  116. //
  117. IMF_STD_ATTRIBUTE_DEF (comments, Comments, std::string)
  118. //
  119. // capDate -- the date when the image was created or captured,
  120. // in local time, and formatted as
  121. //
  122. // YYYY:MM:DD hh:mm:ss
  123. //
  124. // where YYYY is the year (4 digits, e.g. 2003), MM is the month
  125. // (2 digits, 01, 02, ... 12), DD is the day of the month (2 digits,
  126. // 01, 02, ... 31), hh is the hour (2 digits, 00, 01, ... 23), mm
  127. // is the minute, and ss is the second (2 digits, 00, 01, ... 59).
  128. //
  129. //
  130. IMF_STD_ATTRIBUTE_DEF (capDate, CapDate, std::string)
  131. //
  132. // utcOffset -- offset of local time at capDate from
  133. // Universal Coordinated Time (UTC), in seconds:
  134. //
  135. // UTC == local time + utcOffset
  136. //
  137. IMF_STD_ATTRIBUTE_DEF (utcOffset, UtcOffset, float)
  138. //
  139. // longitude, latitude, altitude -- for images of real objects, the
  140. // location where the image was recorded. Longitude and latitude are
  141. // in degrees east of Greenwich and north of the equator. Altitude
  142. // is in meters above sea level. For example, Kathmandu, Nepal is
  143. // at longitude 85.317, latitude 27.717, altitude 1305.
  144. //
  145. IMF_STD_ATTRIBUTE_DEF (longitude, Longitude, float)
  146. IMF_STD_ATTRIBUTE_DEF (latitude, Latitude, float)
  147. IMF_STD_ATTRIBUTE_DEF (altitude, Altitude, float)
  148. //
  149. // focus -- the camera's focus distance, in meters
  150. //
  151. IMF_STD_ATTRIBUTE_DEF (focus, Focus, float)
  152. //
  153. // exposure -- exposure time, in seconds
  154. //
  155. IMF_STD_ATTRIBUTE_DEF (expTime, ExpTime, float)
  156. //
  157. // aperture -- the camera's lens aperture, in f-stops (focal length
  158. // of the lens divided by the diameter of the iris opening)
  159. //
  160. IMF_STD_ATTRIBUTE_DEF (aperture, Aperture, float)
  161. //
  162. // isoSpeed -- the ISO speed of the film or image sensor
  163. // that was used to record the image
  164. //
  165. IMF_STD_ATTRIBUTE_DEF (isoSpeed, IsoSpeed, float)
  166. //
  167. // envmap -- if this attribute is present, the image represents
  168. // an environment map. The attribute's value defines how 3D
  169. // directions are mapped to 2D pixel locations. For details
  170. // see header file ImfEnvmap.h
  171. //
  172. IMF_STD_ATTRIBUTE_DEF (envmap, Envmap, Envmap)
  173. //
  174. // keyCode -- for motion picture film frames. Identifies film
  175. // manufacturer, film type, film roll and frame position within
  176. // the roll.
  177. //
  178. IMF_STD_ATTRIBUTE_DEF (keyCode, KeyCode, KeyCode)
  179. //
  180. // timeCode -- time and control code
  181. //
  182. IMF_STD_ATTRIBUTE_DEF (timeCode, TimeCode, TimeCode)
  183. //
  184. // wrapmodes -- determines how texture map images are extrapolated.
  185. // If an OpenEXR file is used as a texture map for 3D rendering,
  186. // texture coordinates (0.0, 0.0) and (1.0, 1.0) correspond to
  187. // the upper left and lower right corners of the data window.
  188. // If the image is mapped onto a surface with texture coordinates
  189. // outside the zero-to-one range, then the image must be extrapolated.
  190. // This attribute tells the renderer how to do this extrapolation.
  191. // The attribute contains either a pair of comma-separated keywords,
  192. // to specify separate extrapolation modes for the horizontal and
  193. // vertical directions; or a single keyword, to specify extrapolation
  194. // in both directions (e.g. "clamp,periodic" or "clamp"). Extra white
  195. // space surrounding the keywords is allowed, but should be ignored
  196. // by the renderer ("clamp, black " is equivalent to "clamp,black").
  197. // The keywords listed below are predefined; some renderers may support
  198. // additional extrapolation modes:
  199. //
  200. // black pixels outside the zero-to-one range are black
  201. //
  202. // clamp texture coordinates less than 0.0 and greater
  203. // than 1.0 are clamped to 0.0 and 1.0 respectively
  204. //
  205. // periodic the texture image repeats periodically
  206. //
  207. // mirror the texture image repeats periodically, but
  208. // every other instance is mirrored
  209. //
  210. IMF_STD_ATTRIBUTE_DEF (wrapmodes, Wrapmodes, std::string)
  211. //
  212. // framesPerSecond -- defines the nominal playback frame rate for image
  213. // sequences, in frames per second. Every image in a sequence should
  214. // have a framesPerSecond attribute, and the attribute value should be
  215. // the same for all images in the sequence. If an image sequence has
  216. // no framesPerSecond attribute, playback software should assume that
  217. // the frame rate for the sequence is 24 frames per second.
  218. //
  219. // In order to allow exact representation of NTSC frame and field rates,
  220. // framesPerSecond is stored as a rational number. A rational number is
  221. // a pair of integers, n and d, that represents the value n/d.
  222. //
  223. // For the exact values of commonly used frame rates, please see header
  224. // file ImfFramesPerSecond.h.
  225. //
  226. IMF_STD_ATTRIBUTE_DEF (framesPerSecond, FramesPerSecond, Rational)
  227. //
  228. // multiView -- defines the view names for multi-view image files.
  229. // A multi-view image contains two or more views of the same scene,
  230. // as seen from different viewpoints, for example a left-eye and
  231. // a right-eye view for stereo displays. The multiView attribute
  232. // lists the names of the views in an image, and a naming convention
  233. // identifies the channels that belong to each view.
  234. //
  235. // For details, please see header file ImfMultiView.h
  236. //
  237. IMF_STD_ATTRIBUTE_DEF (multiView , MultiView, StringVector)
  238. //
  239. // worldToCamera -- for images generated by 3D computer graphics rendering,
  240. // a matrix that transforms 3D points from the world to the camera coordinate
  241. // space of the renderer.
  242. //
  243. // The camera coordinate space is left-handed. Its origin indicates the
  244. // location of the camera. The positive x and y axes correspond to the
  245. // "right" and "up" directions in the rendered image. The positive z
  246. // axis indicates the camera's viewing direction. (Objects in front of
  247. // the camera have positive z coordinates.)
  248. //
  249. // Camera coordinate space in OpenEXR is the same as in Pixar's Renderman.
  250. //
  251. IMF_STD_ATTRIBUTE_DEF (worldToCamera, WorldToCamera, IMATH_NAMESPACE::M44f)
  252. //
  253. // worldToNDC -- for images generated by 3D computer graphics rendering, a
  254. // matrix that transforms 3D points from the world to the Normalized Device
  255. // Coordinate (NDC) space of the renderer.
  256. //
  257. // NDC is a 2D coordinate space that corresponds to the image plane, with
  258. // positive x and pointing to the right and y positive pointing down. The
  259. // coordinates (0, 0) and (1, 1) correspond to the upper left and lower right
  260. // corners of the OpenEXR display window.
  261. //
  262. // To transform a 3D point in word space into a 2D point in NDC space,
  263. // multiply the 3D point by the worldToNDC matrix and discard the z
  264. // coordinate.
  265. //
  266. // NDC space in OpenEXR is the same as in Pixar's Renderman.
  267. //
  268. IMF_STD_ATTRIBUTE_DEF (worldToNDC, WorldToNDC, IMATH_NAMESPACE::M44f)
  269. //
  270. // deepImageState -- specifies whether the pixels in a deep image are
  271. // sorted and non-overlapping.
  272. //
  273. // Note: this attribute can be set by application code that writes a file
  274. // in order to tell applications that read the file whether the pixel data
  275. // must be cleaned up prior to image processing operations such as flattening.
  276. // The OpenEXR library does not verify that the attribute is consistent with
  277. // the actual state of the pixels. Application software may assume that the
  278. // attribute is valid, as long as the software will not crash or lock up if
  279. // any pixels are inconsistent with the deepImageState attribute.
  280. //
  281. IMF_STD_ATTRIBUTE_DEF (deepImageState, DeepImageState, DeepImageState)
  282. //
  283. // originalDataWindow -- if application software crops an image, then it
  284. // should save the data window of the original, un-cropped image in the
  285. // originalDataWindow attribute.
  286. //
  287. IMF_STD_ATTRIBUTE_DEF
  288. (originalDataWindow, OriginalDataWindow, IMATH_NAMESPACE::Box2i)
  289. //
  290. // dwaCompressionLevel -- sets the quality level for images compressed
  291. // with the DWAA or DWAB method.
  292. //
  293. // DEPRECATED: use the methods directly in the header
  294. IMF_STD_ATTRIBUTE_DEF_DEPRECATED (
  295. dwaCompressionLevel,
  296. DwaCompressionLevel,
  297. float,
  298. "use compression method in ImfHeader")
  299. //
  300. // ID Manifest
  301. //
  302. IMF_STD_ATTRIBUTE_DEF( idManifest,IDManifest,CompressedIDManifest)
  303. #endif