raspiraw
raspiraw copied to clipboard
Raw10 unpacking is incorrect
I realise that you've probably dropped this project, but it's just been noticed by a colleague that your unpacking of the raw10 is wrong. Pixel 0 is in the lowest 2 bits of the 5th byte, with pixel 3 in the highest 2 bits, as described in the CSI2 spec or https://linuxtv.org/downloads/v4l-dvb-apis-new/uapi/v4l/pixfmt-srggb10p.html. The code at https://github.com/illes/raspiraw/blob/master/raspi_dng.c#L172 has them in reverse order. The same is true in @bablokb and @dword1511 forks of this tool.
thanks for pointing this out @6by9 !
I have an interest in this since my team is now maintaining a Python alternative to this at https://github.com/OsmoSystems/picamraw/ . We'd certainly like our implementation to be correct 😄
I see how the implementation is backwards compared to the spec you provided (bits 0 and 1 high would be 0b00000011
not 0b11000000
) .
It does seem plausible that this bug has gone uncaught through all implementations because in reality the little bits are often dominated by noise.
What makes you think the pi camera format conforms to the spec you provided?
OK, I at least partially answered my own question, through forum spelunking.
The raspberry pi driver for the pi camera mentions this format at https://github.com/raspberrypi/linux/blob/1e72a58ef45d0a1bb53441166e98491a40a52072/drivers/media/platform/bcm2835/bcm2835-unicam.c#L251 . https://github.com/raspberrypi/linux/blob/1e72a58ef45d0a1bb53441166e98491a40a52072/include/uapi/linux/videodev2.h also seems built around this format.
Also I finally recognized your handle... If you're the Raspbery Pi engineer who wrote the Pi side implementations, I think maybe I'll just take you at your word 😆
Yes, I work at Raspberry Pi.
Docs for V4L2 I had already linked to - https://linuxtv.org/downloads/v4l-dvb-apis-new/uapi/v4l/pixfmt-srggb10p.html
It's part of the CSI2 spec (I would link to it, but it's closed by the MIPI Alliance), and any CSI2 sensor will comply with it.
The CCP2 spec, predecessor to CSI2, can be found online (not sure if legitimately or not), and part 2 section 7.9 references exactly the same format.
P1[9:2] | P2[9:2] | P3[9:2] | P4[9:2] | P4[1:0] P3[1:0] P2[1:0] P1[1:0]