open-simulation-interface icon indicating copy to clipboard operation
open-simulation-interface copied to clipboard

Clarification Needed: Byte Order for Multi-Byte Image Data

Open TimmRuppert opened this issue 2 months ago • 0 comments

Discussed in https://github.com/orgs/OpenSimulationInterface/discussions/884

Originally posted by TimmRuppert October 23, 2025 According to the CameraSensorViewConfiguration documentation, the image_data field stores raw repeated bytes, and various channel formats support 16-bit and 32-bit data types (UINT16, UINT32, F32).

For formats > 8 bit the data must be split across multiple bytes, the byte order becomes critical for interoperability between different implementations.

What is the specified byte order for multi-byte pixel values in image_data? For example, for CHANNEL_FORMAT_MONO_U16_LIN with a single pixel which has the value of 0x1234 the repeated image_data field could be one of the following:

Little-endian: [0x34, 0x12]
Big-endian: [0x12, 0x34]

Proposed additions/changes

  • Little-endian is generally more common on x86 architectures. Therefore, if this field has been used previously, it was likely interpreted as little-endian.
  • However, future formats might introduce their own endianness conventions. For example, one could theoretically store PNG image data directly, which uses big-endian byte order.
  • Given this, it may be reasonable to explicitly include the endianness as part of the format specification.
  • For reference, see the channel format documentation.

Assuming we adopt the format change with little-endian as the default

  • While it would add clarity, updating the Enumerator values (e.g., changing CHANNEL_FORMAT_MONO_U8_LIN to CHANNEL_FORMAT_MONO_U8_LIN_LE) would break backward compatibility, so this should be avoided.
  • Instead, we can update the documentation text to specify endianness, I see two ways to do this:
    • Changing almost each row of the channel description
      Single Luminance Channel UINT8 Linear.Single Luminance Channel UINT8 Linear Little-Endian.
      • This approach also leaves room to introduce non-default variants later, such as CHANNEL_FORMAT_MONO_U8_LIN_BE (BE = big-endian), if needed.
    • Changing the top enum/table description

Channel format. Multi-byte pixel values (UINT16, UINT32, F32) use little-endian byte order unless explicitly specified otherwise in the format.

TimmRuppert avatar Nov 06 '25 06:11 TimmRuppert