How does ImageSpec
handle images with non-byte-sized channels
#3087
-
How does |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
That's right. ImageSpec, and all in-memory operations in OIIO, make several simplifying assumptions, including that pixel data types are exactly 1, 2, 4, or 8 bytes per channel (and are either int, uint, or float, of those width). Remember that the core goal of OIIO is to allow apps to read and write images in a fairly generic way without regard to the disk file formats, and without apps needing a tangle of spaghetti code to handle every possible data representation that any format might possibly support, and especially for apps to need to change every time we add support for a new file format (which may come with a unique data representation). So we would consider something like R5G6B5 to be like a compression or encoding method -- something specific to the way it's stored in the file. The file format reader/writer is expected to treat it as if it was 3 channels of uint8, and handle the uint8[3] <-> R5G6B5 internally and hide it from the application that's using the OIIO API. The format reader may also have a custom metadata field that reveals what bit depth or encoding is used in the file itself, and as well, the writer may honor that metadata to request that the file be written as R5G6B5 or whatever. (I think our BMP reader, and maybe others, are already examples of handling encodings in this manner, and I think also TIFF doesn't combine channels but it does allow channels to have 1, 2, 4, 10, 12, 14 bit representations, which it reports as either 8 or 16 and alters the values accordingly as they go in and out of the OIIO APIs.) That said, the one place this approach (which was OIIO's original design over 13 years ago) falls down is if you WANT to directly get the compressed data -- for example, to directly transfer it to a GPU that supports on-card compressed texture formats. This is something we'll have to grapple with at some point, I suppose. We've kicked that can down the road for a long time because the core user base of OIIO is film VFX, and they don't use any of these lossy or low bit depth formats. |
Beta Was this translation helpful? Give feedback.
That's right. ImageSpec, and all in-memory operations in OIIO, make several simplifying assumptions, including that pixel data types are exactly 1, 2, 4, or 8 bytes per channel (and are either int, uint, or float, of those width).
Remember that the core goal of OIIO is to allow apps to read and write images in a fairly generic way without regard to the disk file formats, and without apps needing a tangle of spaghetti code to handle every possible data representation that any format might possibly support, and especially for apps to need to change every time we add support for a new file format (which may come with a unique data representation).
So we would consider something like R5G6B5 t…