Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use FourCC codes for image encodings #204

Open
christianrauch opened this issue Sep 4, 2022 · 2 comments
Open

use FourCC codes for image encodings #204

christianrauch opened this issue Sep 4, 2022 · 2 comments
Labels
more-information-needed Further information is required

Comments

@christianrauch
Copy link
Contributor

Feature request

The sensor_msgs/Image currently uses the encoding field to document how the raw data in the data field has to be interpreted. The fourcc (4 character code) is a 32bit integer formed by 4 ASCII characters, that uniquely describes the memory layout.

Feature description

The encoding field can contain an arbitrary text string, with some predefined strings in sensor_msgs::image_encodings. Those strings are not standardised and do not document the memory layout properly. The YUV formats even reference non-official documentation containing advertisements.

Instead of using these non-standard strings, I propose to rely on the fourcc widely used across the kernel and the userspace to uniquely and properly document the memory layout.

Implementation considerations

To support fourcc, either a uint32 or a char[4] field fourcc should be added to the sensor_msgs/Image message definition alongside the old encoding. To maintain backward compatibility, the logic could be that if encoding is empty, the fourcc would take the place as a definition of the memory layout.

Alternatively, the encoding string could also contain the fourcc alongside the "legacy" encodings. However, this would require an expensive string matching to test if encoding contains a fourcc or a "legacy" format encoding and it must be ensured that there are no collisions.

@clalancette
Copy link
Contributor

We had a short discussion about this today internally.

The most important point that came out of that discussion is that we aren't totally sure whether fourcc is the way to go for the encoding. That is, we aren't sure what pieces of software use fourcc, and what pieces of software use something else. In particular, we could use references to the kernel code, V4L2 code, OpenCV, and ROS code showing that this standard is actually widely used. That would allow us to make an easier decision about this. Thanks.

@clalancette clalancette added the more-information-needed Further information is required label Sep 22, 2022
@christianrauch
Copy link
Contributor Author

christianrauch commented Sep 22, 2022

FourCC is used all over the image/video/media stack to specify the memory layout. We should adapt this and use this specification instead of inventing custom formats that are not properly defined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more-information-needed Further information is required
Projects
None yet
Development

No branches or pull requests

2 participants