exr_coding.odin 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. package vendor_openexr
  2. import "core:c"
  3. /**
  4. * Enum for use in a custom allocator in the encode/decode pipelines
  5. * (that is, so the implementor knows whether to allocate on which
  6. * device based on the buffer disposition).
  7. */
  8. transcoding_pipeline_buffer_id_t :: enum c.int {
  9. PACKED,
  10. UNPACKED,
  11. COMPRESSED,
  12. SCRATCH1,
  13. SCRATCH2,
  14. PACKED_SAMPLES,
  15. SAMPLES,
  16. }
  17. /** @brief Struct for negotiating buffers when decoding/encoding
  18. * chunks of data.
  19. *
  20. * This is generic and meant to negotiate exr data bi-directionally,
  21. * in that the same structure is used for both decoding and encoding
  22. * chunks for read and write, respectively.
  23. *
  24. * The first half of the structure will be filled by the library, and
  25. * the caller is expected to fill the second half appropriately.
  26. */
  27. coding_channel_info_t :: struct {
  28. /**************************************************
  29. * Elements below are populated by the library when
  30. * decoding is initialized/updated and must be left
  31. * untouched when using the default decoder routines.
  32. **************************************************/
  33. /** Channel name.
  34. *
  35. * This is provided as a convenient reference. Do not free, this
  36. * refers to the internal data structure in the context.
  37. */
  38. channel_name: cstring,
  39. /** Number of lines for this channel in this chunk.
  40. *
  41. * May be 0 or less than overall image height based on sampling
  42. * (i.e. when in 4:2:0 type sampling)
  43. */
  44. height: i32,
  45. /** Width in pixel count.
  46. *
  47. * May be 0 or less than overall image width based on sampling
  48. * (i.e. 4:2:2 will have some channels have fewer values).
  49. */
  50. width: i32,
  51. /** Horizontal subsampling information. */
  52. x_samples: i32,
  53. /** Vertical subsampling information. */
  54. y_samples: i32,
  55. /** Linear flag from channel definition (used by b44). */
  56. p_linear: u8,
  57. /** How many bytes per pixel this channel consumes (2 for float16,
  58. * 4 for float32/uint32).
  59. */
  60. bytes_per_element: i8,
  61. /** Small form of exr_pixel_type_t enum (EXR_PIXEL_UINT/HALF/FLOAT). */
  62. data_type: u16,
  63. /**************************************************
  64. * Elements below must be edited by the caller
  65. * to control encoding/decoding.
  66. **************************************************/
  67. /** How many bytes per pixel the input is or output should be
  68. * (2 for float16, 4 for float32/uint32). Defaults to same
  69. * size as input.
  70. */
  71. user_bytes_per_element: i16,
  72. /** Small form of exr_pixel_type_t enum
  73. * (EXR_PIXEL_UINT/HALF/FLOAT). Defaults to same type as input.
  74. */
  75. user_data_type: u16,
  76. /** Increment to get to next pixel.
  77. *
  78. * This is in bytes. Must be specified when the decode pointer is
  79. * specified (and always for encode).
  80. *
  81. * This is useful for implementing transcoding generically of
  82. * planar or interleaved data. For planar data, where the layout
  83. * is RRRRRGGGGGBBBBB, you can pass in 1 * bytes per component.
  84. */
  85. user_pixel_stride: i32,
  86. /** When \c lines > 1 for a chunk, this is the increment used to get
  87. * from beginning of line to beginning of next line.
  88. *
  89. * This is in bytes. Must be specified when the decode pointer is
  90. * specified (and always for encode).
  91. */
  92. user_line_stride: i32,
  93. /** This data member has different requirements reading vs
  94. * writing. When reading, if this is left as `NULL`, the channel
  95. * will be skipped during read and not filled in. During a write
  96. * operation, this pointer is considered const and not
  97. * modified. To make this more clear, a union is used here.
  98. */
  99. using _: struct #raw_union {
  100. decode_to_ptr: ^u8,
  101. encode_from_ptr: ^u8,
  102. },
  103. }