V4l2 returning 14-bit raw instead of 12-bit. What is going on?

HI,

I am using FRAMOS IMX335 sensor with JetsonTX2. The camera supports RG10 and RG12 and v4l2 detects this. See below. The camera DOES NOT support 14-bit raw

$ v4l2-ctl -d /dev/video0 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
	Index       : 0
	Type        : Video Capture
	Pixel Format: 'RG10'
	Name        : 10-bit Bayer RGRG/GBGB
		Size: Discrete 2616x1964
			Interval: Discrete 0.017s (60.000 fps)
		Size: Discrete 1920x1080
			Interval: Discrete 0.008s (120.000 fps)
		Size: Discrete 1320x984
			Interval: Discrete 0.017s (60.000 fps)

	Index       : 1
	Type        : Video Capture
	Pixel Format: 'RG12'
	Name        : 12-bit Bayer RGRG/GBGB
		Size: Discrete 2616x1964
			Interval: Discrete 0.017s (60.000 fps)
		Size: Discrete 1920x1080
			Interval: Discrete 0.008s (120.000 fps)
		Size: Discrete 1320x984
			Interval: Discrete 0.017s (60.000 fps)

When I run the following command and then inspect the bits of the file i see that some of the HIGH are not padded with 4 zeroes.
$ V4l2-ctl -d /dev/video0 --set-ctrl bypass_mode=0 --stream-mmap --stream-count=1 --set-fmt-video=width=2616,height=1964,pixelformat=RG12 --stream-to=testRG12.raw

See:
$ xxd -b -len 200 testRG12.raw
00000000: 00101100 00001101 10101000 00001101 01001000 00001100 ,…H.
00000006: 00110100 00001111 11101000 00001100 01000000 00001011 4…@.
0000000c: 01000000 00001011 00000100 00001100 10111100 00001011 @…
00000012: 10010000 00001101 01000100 00001110 11111100 00001110 …D…
00000018: 11000100 00001100 01000000 00001100 10110100 00001110 …@…
0000001e: 11001100 00001010 01010000 00001100 10111000 00001110 …P…
00000024: 00111100 00001001 00111000 00001101 01101001 00010000 <.8.i.
0000002a: 00010100 00001110 00010100 00001110 11100000 00001101 …
00000030: 10001000 00001101 01111000 00001110 11001100 00001100 …x…
00000036: 10110101 00010000 01111000 00001100 10110100 00001101 …x…

Can anyone explain what is going on? thanks

NVIDIA’s raw memory for RAW12 uses 14-bits. The raw image modes either replicate MSBs (for T_R16 16-bit bpp widths) or truncate LSBs (for T_L8 8-bit bpp widths), as needed to fit pixels into the appropriate format.

See this thread for details:

So for RAW12 you get bits 15 and 14 zero’d and bits 1 and 0 are replications of the two MSBits (D11 and D10).

1 Like