ImfCRgbaFile.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  1. /*
  2. Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
  3. Digital Ltd. LLC
  4. All rights reserved.
  5. Redistribution and use in source and binary forms, with or without
  6. modification, are permitted provided that the following conditions are
  7. met:
  8. * Redistributions of source code must retain the above copyright
  9. notice, this list of conditions and the following disclaimer.
  10. * Redistributions in binary form must reproduce the above
  11. copyright notice, this list of conditions and the following disclaimer
  12. in the documentation and/or other materials provided with the
  13. distribution.
  14. * Neither the name of Industrial Light & Magic nor the names of
  15. its contributors may be used to endorse or promote products derived
  16. from this software without specific prior written permission.
  17. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  18. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  19. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  20. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  21. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  22. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  23. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  24. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  25. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  27. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. */
  29. #ifndef INCLUDED_IMF_C_RGBA_FILE_H
  30. #define INCLUDED_IMF_C_RGBA_FILE_H
  31. #include "ImfExport.h"
  32. #include <stdlib.h>
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. /*
  37. ** Interpreting unsigned shorts as 16-bit floating point numbers
  38. */
  39. typedef unsigned short ImfHalf;
  40. IMF_EXPORT
  41. void ImfFloatToHalf (float f,
  42. ImfHalf *h);
  43. IMF_EXPORT
  44. void ImfFloatToHalfArray (int n,
  45. const float f[/*n*/],
  46. ImfHalf h[/*n*/]);
  47. IMF_EXPORT
  48. float ImfHalfToFloat (ImfHalf h);
  49. IMF_EXPORT
  50. void ImfHalfToFloatArray (int n,
  51. const ImfHalf h[/*n*/],
  52. float f[/*n*/]);
  53. /*
  54. ** RGBA pixel; memory layout must be the same as struct Imf::Rgba.
  55. */
  56. struct ImfRgba
  57. {
  58. ImfHalf r;
  59. ImfHalf g;
  60. ImfHalf b;
  61. ImfHalf a;
  62. };
  63. typedef struct ImfRgba ImfRgba;
  64. /*
  65. ** Magic number; this must be the same as Imf::MAGIC
  66. */
  67. #define IMF_MAGIC 20000630
  68. /*
  69. ** Version number; this must be the same as Imf::EXR_VERSION
  70. */
  71. #define IMF_VERSION_NUMBER 2
  72. /*
  73. ** Line order; values must the the same as in Imf::LineOrder.
  74. */
  75. #define IMF_INCREASING_Y 0
  76. #define IMF_DECREASING_Y 1
  77. #define IMF_RANDOM_Y 2
  78. /*
  79. ** Compression types; values must be the same as in Imf::Compression.
  80. */
  81. #define IMF_NO_COMPRESSION 0
  82. #define IMF_RLE_COMPRESSION 1
  83. #define IMF_ZIPS_COMPRESSION 2
  84. #define IMF_ZIP_COMPRESSION 3
  85. #define IMF_PIZ_COMPRESSION 4
  86. #define IMF_PXR24_COMPRESSION 5
  87. #define IMF_B44_COMPRESSION 6
  88. #define IMF_B44A_COMPRESSION 7
  89. /*
  90. ** Channels; values must be the same as in Imf::RgbaChannels.
  91. */
  92. #define IMF_WRITE_R 0x01
  93. #define IMF_WRITE_G 0x02
  94. #define IMF_WRITE_B 0x04
  95. #define IMF_WRITE_A 0x08
  96. #define IMF_WRITE_Y 0x10
  97. #define IMF_WRITE_C 0x20
  98. #define IMF_WRITE_RGB 0x07
  99. #define IMF_WRITE_RGBA 0x0f
  100. #define IMF_WRITE_YC 0x30
  101. #define IMF_WRITE_YA 0x18
  102. #define IMF_WRITE_YCA 0x38
  103. /*
  104. ** Level modes; values must be the same as in Imf::LevelMode
  105. */
  106. #define IMF_ONE_LEVEL 0
  107. #define IMF_MIPMAP_LEVELS 1
  108. #define IMF_RIPMAP_LEVELS 2
  109. /*
  110. ** Level rounding modes; values must be the same as in Imf::LevelRoundingMode
  111. */
  112. #define IMF_ROUND_DOWN 0
  113. #define IMF_ROUND_UP 1
  114. /*
  115. ** RGBA file header
  116. */
  117. struct ImfHeader;
  118. typedef struct ImfHeader ImfHeader;
  119. IMF_EXPORT
  120. ImfHeader * ImfNewHeader (void);
  121. IMF_EXPORT
  122. void ImfDeleteHeader (ImfHeader *hdr);
  123. IMF_EXPORT
  124. ImfHeader * ImfCopyHeader (const ImfHeader *hdr);
  125. IMF_EXPORT
  126. void ImfHeaderSetDisplayWindow (ImfHeader *hdr,
  127. int xMin, int yMin,
  128. int xMax, int yMax);
  129. IMF_EXPORT
  130. void ImfHeaderDisplayWindow (const ImfHeader *hdr,
  131. int *xMin, int *yMin,
  132. int *xMax, int *yMax);
  133. IMF_EXPORT
  134. void ImfHeaderSetDataWindow (ImfHeader *hdr,
  135. int xMin, int yMin,
  136. int xMax, int yMax);
  137. IMF_EXPORT
  138. void ImfHeaderDataWindow (const ImfHeader *hdr,
  139. int *xMin, int *yMin,
  140. int *xMax, int *yMax);
  141. IMF_EXPORT
  142. void ImfHeaderSetPixelAspectRatio (ImfHeader *hdr,
  143. float pixelAspectRatio);
  144. IMF_EXPORT
  145. float ImfHeaderPixelAspectRatio (const ImfHeader *hdr);
  146. IMF_EXPORT
  147. void ImfHeaderSetScreenWindowCenter (ImfHeader *hdr,
  148. float x, float y);
  149. IMF_EXPORT
  150. void ImfHeaderScreenWindowCenter (const ImfHeader *hdr,
  151. float *x, float *y);
  152. IMF_EXPORT
  153. void ImfHeaderSetScreenWindowWidth (ImfHeader *hdr,
  154. float width);
  155. IMF_EXPORT
  156. float ImfHeaderScreenWindowWidth (const ImfHeader *hdr);
  157. IMF_EXPORT
  158. void ImfHeaderSetLineOrder (ImfHeader *hdr,
  159. int lineOrder);
  160. IMF_EXPORT
  161. int ImfHeaderLineOrder (const ImfHeader *hdr);
  162. IMF_EXPORT
  163. void ImfHeaderSetCompression (ImfHeader *hdr,
  164. int compression);
  165. IMF_EXPORT
  166. int ImfHeaderCompression (const ImfHeader *hdr);
  167. IMF_EXPORT
  168. int ImfHeaderSetIntAttribute (ImfHeader *hdr,
  169. const char name[],
  170. int value);
  171. IMF_EXPORT
  172. int ImfHeaderIntAttribute (const ImfHeader *hdr,
  173. const char name[],
  174. int *value);
  175. IMF_EXPORT
  176. int ImfHeaderSetFloatAttribute (ImfHeader *hdr,
  177. const char name[],
  178. float value);
  179. IMF_EXPORT
  180. int ImfHeaderSetDoubleAttribute (ImfHeader *hdr,
  181. const char name[],
  182. double value);
  183. IMF_EXPORT
  184. int ImfHeaderFloatAttribute (const ImfHeader *hdr,
  185. const char name[],
  186. float *value);
  187. IMF_EXPORT
  188. int ImfHeaderDoubleAttribute (const ImfHeader *hdr,
  189. const char name[],
  190. double *value);
  191. IMF_EXPORT
  192. int ImfHeaderSetStringAttribute (ImfHeader *hdr,
  193. const char name[],
  194. const char value[]);
  195. IMF_EXPORT
  196. int ImfHeaderStringAttribute (const ImfHeader *hdr,
  197. const char name[],
  198. const char **value);
  199. IMF_EXPORT
  200. int ImfHeaderSetBox2iAttribute (ImfHeader *hdr,
  201. const char name[],
  202. int xMin, int yMin,
  203. int xMax, int yMax);
  204. IMF_EXPORT
  205. int ImfHeaderBox2iAttribute (const ImfHeader *hdr,
  206. const char name[],
  207. int *xMin, int *yMin,
  208. int *xMax, int *yMax);
  209. IMF_EXPORT
  210. int ImfHeaderSetBox2fAttribute (ImfHeader *hdr,
  211. const char name[],
  212. float xMin, float yMin,
  213. float xMax, float yMax);
  214. IMF_EXPORT
  215. int ImfHeaderBox2fAttribute (const ImfHeader *hdr,
  216. const char name[],
  217. float *xMin, float *yMin,
  218. float *xMax, float *yMax);
  219. IMF_EXPORT
  220. int ImfHeaderSetV2iAttribute (ImfHeader *hdr,
  221. const char name[],
  222. int x, int y);
  223. IMF_EXPORT
  224. int ImfHeaderV2iAttribute (const ImfHeader *hdr,
  225. const char name[],
  226. int *x, int *y);
  227. IMF_EXPORT
  228. int ImfHeaderSetV2fAttribute (ImfHeader *hdr,
  229. const char name[],
  230. float x, float y);
  231. IMF_EXPORT
  232. int ImfHeaderV2fAttribute (const ImfHeader *hdr,
  233. const char name[],
  234. float *x, float *y);
  235. IMF_EXPORT
  236. int ImfHeaderSetV3iAttribute (ImfHeader *hdr,
  237. const char name[],
  238. int x, int y, int z);
  239. IMF_EXPORT
  240. int ImfHeaderV3iAttribute (const ImfHeader *hdr,
  241. const char name[],
  242. int *x, int *y, int *z);
  243. IMF_EXPORT
  244. int ImfHeaderSetV3fAttribute (ImfHeader *hdr,
  245. const char name[],
  246. float x, float y, float z);
  247. IMF_EXPORT
  248. int ImfHeaderV3fAttribute (const ImfHeader *hdr,
  249. const char name[],
  250. float *x, float *y, float *z);
  251. IMF_EXPORT
  252. int ImfHeaderSetM33fAttribute (ImfHeader *hdr,
  253. const char name[],
  254. const float m[3][3]);
  255. IMF_EXPORT
  256. int ImfHeaderM33fAttribute (const ImfHeader *hdr,
  257. const char name[],
  258. float m[3][3]);
  259. IMF_EXPORT
  260. int ImfHeaderSetM44fAttribute (ImfHeader *hdr,
  261. const char name[],
  262. const float m[4][4]);
  263. IMF_EXPORT
  264. int ImfHeaderM44fAttribute (const ImfHeader *hdr,
  265. const char name[],
  266. float m[4][4]);
  267. /*
  268. ** RGBA output file
  269. */
  270. struct ImfOutputFile;
  271. typedef struct ImfOutputFile ImfOutputFile;
  272. IMF_EXPORT
  273. ImfOutputFile * ImfOpenOutputFile (const char name[],
  274. const ImfHeader *hdr,
  275. int channels);
  276. IMF_EXPORT
  277. int ImfCloseOutputFile (ImfOutputFile *out);
  278. IMF_EXPORT
  279. int ImfOutputSetFrameBuffer (ImfOutputFile *out,
  280. const ImfRgba *base,
  281. size_t xStride,
  282. size_t yStride);
  283. IMF_EXPORT
  284. int ImfOutputWritePixels (ImfOutputFile *out,
  285. int numScanLines);
  286. IMF_EXPORT
  287. int ImfOutputCurrentScanLine (const ImfOutputFile *out);
  288. IMF_EXPORT
  289. const ImfHeader * ImfOutputHeader (const ImfOutputFile *out);
  290. IMF_EXPORT
  291. int ImfOutputChannels (const ImfOutputFile *out);
  292. /*
  293. ** Tiled RGBA output file
  294. */
  295. struct ImfTiledOutputFile;
  296. typedef struct ImfTiledOutputFile ImfTiledOutputFile;
  297. IMF_EXPORT
  298. ImfTiledOutputFile * ImfOpenTiledOutputFile (const char name[],
  299. const ImfHeader *hdr,
  300. int channels,
  301. int xSize, int ySize,
  302. int mode, int rmode);
  303. IMF_EXPORT
  304. int ImfCloseTiledOutputFile (ImfTiledOutputFile *out);
  305. IMF_EXPORT
  306. int ImfTiledOutputSetFrameBuffer (ImfTiledOutputFile *out,
  307. const ImfRgba *base,
  308. size_t xStride,
  309. size_t yStride);
  310. IMF_EXPORT
  311. int ImfTiledOutputWriteTile (ImfTiledOutputFile *out,
  312. int dx, int dy,
  313. int lx, int ly);
  314. IMF_EXPORT
  315. int ImfTiledOutputWriteTiles (ImfTiledOutputFile *out,
  316. int dxMin, int dxMax,
  317. int dyMin, int dyMax,
  318. int lx, int ly);
  319. IMF_EXPORT
  320. const ImfHeader * ImfTiledOutputHeader (const ImfTiledOutputFile *out);
  321. IMF_EXPORT
  322. int ImfTiledOutputChannels (const ImfTiledOutputFile *out);
  323. IMF_EXPORT
  324. int ImfTiledOutputTileXSize (const ImfTiledOutputFile *out);
  325. IMF_EXPORT
  326. int ImfTiledOutputTileYSize (const ImfTiledOutputFile *out);
  327. IMF_EXPORT
  328. int ImfTiledOutputLevelMode (const ImfTiledOutputFile *out);
  329. IMF_EXPORT
  330. int ImfTiledOutputLevelRoundingMode
  331. (const ImfTiledOutputFile *out);
  332. /*
  333. ** RGBA input file
  334. */
  335. struct ImfInputFile;
  336. typedef struct ImfInputFile ImfInputFile;
  337. ImfInputFile * ImfOpenInputFile (const char name[]);
  338. IMF_EXPORT
  339. int ImfCloseInputFile (ImfInputFile *in);
  340. IMF_EXPORT
  341. int ImfInputSetFrameBuffer (ImfInputFile *in,
  342. ImfRgba *base,
  343. size_t xStride,
  344. size_t yStride);
  345. IMF_EXPORT
  346. int ImfInputReadPixels (ImfInputFile *in,
  347. int scanLine1,
  348. int scanLine2);
  349. IMF_EXPORT
  350. const ImfHeader * ImfInputHeader (const ImfInputFile *in);
  351. IMF_EXPORT
  352. int ImfInputChannels (const ImfInputFile *in);
  353. IMF_EXPORT
  354. const char * ImfInputFileName (const ImfInputFile *in);
  355. /*
  356. ** Tiled RGBA input file
  357. */
  358. struct ImfTiledInputFile;
  359. typedef struct ImfTiledInputFile ImfTiledInputFile;
  360. IMF_EXPORT
  361. ImfTiledInputFile * ImfOpenTiledInputFile (const char name[]);
  362. IMF_EXPORT
  363. int ImfCloseTiledInputFile (ImfTiledInputFile *in);
  364. IMF_EXPORT
  365. int ImfTiledInputSetFrameBuffer (ImfTiledInputFile *in,
  366. ImfRgba *base,
  367. size_t xStride,
  368. size_t yStride);
  369. IMF_EXPORT
  370. int ImfTiledInputReadTile (ImfTiledInputFile *in,
  371. int dx, int dy,
  372. int lx, int ly);
  373. IMF_EXPORT
  374. int ImfTiledInputReadTiles (ImfTiledInputFile *in,
  375. int dxMin, int dxMax,
  376. int dyMin, int dyMax,
  377. int lx, int ly);
  378. IMF_EXPORT
  379. const ImfHeader * ImfTiledInputHeader (const ImfTiledInputFile *in);
  380. IMF_EXPORT
  381. int ImfTiledInputChannels (const ImfTiledInputFile *in);
  382. IMF_EXPORT
  383. const char * ImfTiledInputFileName (const ImfTiledInputFile *in);
  384. IMF_EXPORT
  385. int ImfTiledInputTileXSize (const ImfTiledInputFile *in);
  386. IMF_EXPORT
  387. int ImfTiledInputTileYSize (const ImfTiledInputFile *in);
  388. IMF_EXPORT
  389. int ImfTiledInputLevelMode (const ImfTiledInputFile *in);
  390. IMF_EXPORT
  391. int ImfTiledInputLevelRoundingMode
  392. (const ImfTiledInputFile *in);
  393. /*
  394. ** Lookup tables
  395. */
  396. struct ImfLut;
  397. typedef struct ImfLut ImfLut;
  398. IMF_EXPORT
  399. ImfLut * ImfNewRound12logLut (int channels);
  400. IMF_EXPORT
  401. ImfLut * ImfNewRoundNBitLut (unsigned int n, int channels);
  402. IMF_EXPORT
  403. void ImfDeleteLut (ImfLut *lut);
  404. IMF_EXPORT
  405. void ImfApplyLut (ImfLut *lut,
  406. ImfRgba *data,
  407. int nData,
  408. int stride);
  409. /*
  410. ** Most recent error message
  411. */
  412. IMF_EXPORT
  413. const char * ImfErrorMessage (void);
  414. #ifdef __cplusplus
  415. } /* extern "C" */
  416. #endif
  417. #endif