exr_chunkio.odin 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. package vendor_openexr
  2. when ODIN_OS == .Windows {
  3. foreign import lib "OpenEXRCore-3_1.lib"
  4. } else {
  5. foreign import lib "system:OpenEXRCore-3_1"
  6. }
  7. import "core:c"
  8. /**
  9. * Struct describing raw data information about a chunk.
  10. *
  11. * A chunk is the generic term for a pixel data block in an EXR file,
  12. * as described in the OpenEXR File Layout documentation. This is
  13. * common between all different forms of data that can be stored.
  14. */
  15. chunk_info_t :: struct {
  16. idx: i32,
  17. /** For tiles, this is the tilex; for scans it is the x. */
  18. start_x: i32,
  19. /** For tiles, this is the tiley; for scans it is the scanline y. */
  20. start_y: i32,
  21. height: i32, /**< For this chunk. */
  22. width: i32, /**< For this chunk. */
  23. level_x: u8, /**< For tiled files. */
  24. level_y: u8, /**< For tiled files. */
  25. type: u8,
  26. compression: u8,
  27. data_offset: u64,
  28. packed_size: u64,
  29. unpacked_size: u64,
  30. sample_count_data_offset: u64,
  31. sample_count_table_size: u64,
  32. }
  33. @(link_prefix="exr_", default_calling_convention="c")
  34. foreign lib {
  35. read_scanline_chunk_info :: proc(ctxt: const_context_t, part_index: c.int, y: c.int, cinfo: ^chunk_info_t) -> result_t ---
  36. read_tile_chunk_info :: proc(
  37. ctxt: const_context_t,
  38. part_index: c.int,
  39. tilex: c.int,
  40. tiley: c.int,
  41. levelx: c.int,
  42. levely: c.int,
  43. cinfo: ^chunk_info_t) -> result_t ---
  44. /** Read the packed data block for a chunk.
  45. *
  46. * This assumes that the buffer pointed to by @p packed_data is
  47. * large enough to hold the chunk block info packed_size bytes.
  48. */
  49. read_chunk :: proc(
  50. ctxt: const_context_t,
  51. part_index: c.int,
  52. cinfo: ^chunk_info_t,
  53. packed_data: rawptr) -> result_t ---
  54. /**
  55. * Read chunk for deep data.
  56. *
  57. * This allows one to read the packed data, the sample count data, or both.
  58. * \c exr_read_chunk also works to read deep data packed data,
  59. * but this is a routine to get the sample count table and the packed
  60. * data in one go, or if you want to pre-read the sample count data,
  61. * you can get just that buffer.
  62. */
  63. read_deep_chunk :: proc(
  64. ctxt: const_context_t,
  65. part_index: c.int,
  66. cinfo: ^chunk_info_t,
  67. packed_data: rawptr,
  68. sample_data: rawptr) -> result_t ---
  69. /**************************************/
  70. /** Initialize a \c chunk_info_t structure when encoding scanline
  71. * data (similar to read but does not do anything with a chunk
  72. * table).
  73. */
  74. write_scanline_chunk_info :: proc(ctxt: context_t, part_index: c.int, y: c.int, cinfo: ^chunk_info_t) -> result_t ---
  75. /** Initialize a \c chunk_info_t structure when encoding tiled data
  76. * (similar to read but does not do anything with a chunk table).
  77. */
  78. write_tile_chunk_info :: proc(
  79. ctxt: context_t,
  80. part_index: c.int,
  81. tilex: c.int,
  82. tiley: c.int,
  83. levelx: c.int,
  84. levely: c.int,
  85. cinfo: ^chunk_info_t) -> result_t ---
  86. /**
  87. * @p y must the appropriate starting y for the specified chunk.
  88. */
  89. write_scanline_chunk :: proc(
  90. ctxt: context_t,
  91. part_index: int,
  92. y: int,
  93. packed_data: rawptr,
  94. packed_size: u64) -> result_t ---
  95. /**
  96. * @p y must the appropriate starting y for the specified chunk.
  97. */
  98. write_deep_scanline_chunk :: proc(
  99. ctxt: context_t,
  100. part_index: c.int,
  101. y: c.int,
  102. packed_data: rawptr,
  103. packed_size: u64,
  104. unpacked_size: u64,
  105. sample_data: rawptr,
  106. sample_data_size: u64) -> result_t ---
  107. write_tile_chunk :: proc(
  108. ctxt: context_t,
  109. part_index: c.int,
  110. tilex: c.int,
  111. tiley: c.int,
  112. levelx: c.int,
  113. levely: c.int,
  114. packed_data: rawptr,
  115. packed_size: u64) -> result_t ---
  116. write_deep_tile_chunk :: proc(
  117. ctxt: context_t,
  118. part_index: c.int,
  119. tilex: c.int,
  120. tiley: c.int,
  121. levelx: c.int,
  122. levely: c.int,
  123. packed_data: rawptr,
  124. packed_size: u64,
  125. unpacked_size: u64,
  126. sample_data: rawptr,
  127. sample_data_size: u64) -> result_t ---
  128. }