Live data from Hacker News

USB Cheat Sheet

fabiensanglard.net

131–140 of 174 posts

Re: USB Cheat Sheet

#131

Some of the entries seem incorrect: "USB 3.2 (USB 3.2 Gen 2x2) and "USB 4" (USB 4 USB4 Gen 2×2) should have the same nominal data rate of 2500MB/s, they're 2 lanes (x2) of 10GB/s. Though they are apparently coded differently electrically, so they're distinct protocols. The tables would benefit from mentioning the coding (8/10 or 128/132) as IMO it's one of the most confusing bits when you see the effective data rates…

Thank you for noticing these issues, I have updated the table. I would be happy to improve it and add encoding. I am surprised by some of the summary entries on Wikipedia ( https://en.wikipedia.org/wiki/USB4 ). Looks like USB4 "reverted" to 128b/132b. It is accurate?

128b/132b is the more efficient coding. The closer to 1 the fraction is, the less coding overhead it has, and 128/132 is larger than 8/10.

Re: USB Cheat Sheet

#132
post #87

Fun fact: USB 2.0 webcams have been existing for over 10 years. USB 2.0 is 60 MB/s. A pixel of an image is 3 Bytes. A 1920x1080 FullHD image is 6.2 MB. At 30 frames per second, second of a FullHD video is 186 MB. How did they do that? Answer: frames are transferred as JPEG files. Even a cheap $15 webcam is a tiny computer (with a CPU, RAM, etc), which runs a JPEG encoder program.

Hm. But then wouldn't it make more sense to just stream the raw sensor data, which is 1 byte per pixel (or up to 12 bits if you want to get fancy), and then demosaic it on the host? Full HD at 30 fps would be 59.33 MB/s, barely but still fitting into that limit. But then also I think some webcams use H264? I remember reading that somewhere.

The pixel density doesn't generally refer to the density of the Bayer pattern, which can be even denser. Generally a cluster of four Bayer pixels makes up one pixel (RG/GB), but like most things in computing, the cognitive complexity is borderline fractal and this is a massive simplification.

Re: USB Cheat Sheet

#133

Earlier quoted context omitted.

Surprised they don't use a hardware video encoder, is it because the well and efficiently supported formats are all MPEG, and thus have fairly high licensing cost on top of the hardware? Or because even efficient HVEs use more resources than webcams can afford? Or because inter-frame coding requires more storage, which (again) means higher costs, which (again) eats into the margin, which cheap webcam manufacturers co…

My older Logitech C920 has an on-board H.264 encoder. Newer revisions of the same model does not. I haven't figured out why they chose to remove it, but your point about licensing cost combined with them not advertising it much as a feature, and most of their competitors not including "proper" video encoding might explain it. Edit: Found an official explanation here: https://www.logitech.com/en-us/video-collaboration…

Unfortunately, this makes it much harder to use these as webcams on a Raspberry Pi (which even has H.264 hardware acceleration – the bottleneck is decoding the MJPEG stream from the camera, for which ffmpeg does not have hardware acceleration on the RPi).

Re: USB Cheat Sheet

#134
post #87

Earlier quoted context omitted.

Hm. But then wouldn't it make more sense to just stream the raw sensor data, which is 1 byte per pixel (or up to 12 bits if you want to get fancy), and then demosaic it on the host? Full HD at 30 fps would be 59.33 MB/s, barely but still fitting into that limit. But then also I think some webcams use H264? I remember reading that somewhere.

I don't know where you get "1 byte per pixel" from. At minimum, raw 4:2:0 video would be two bytes per pixel, and RGB would be three bytes per pixel with 8-bit color depth.

When talking about digital cameras, each "pixel" is a single color sensor. Blame marketing.

Also 4:2:0 is 6 values per 4 pixels. 1.5 bytes per pixel at 8-bit.

Re: USB Cheat Sheet

#135
post #87

Fun fact: USB 2.0 webcams have been existing for over 10 years. USB 2.0 is 60 MB/s. A pixel of an image is 3 Bytes. A 1920x1080 FullHD image is 6.2 MB. At 30 frames per second, second of a FullHD video is 186 MB. How did they do that? Answer: frames are transferred as JPEG files. Even a cheap $15 webcam is a tiny computer (with a CPU, RAM, etc), which runs a JPEG encoder program.

Hm. But then wouldn't it make more sense to just stream the raw sensor data, which is 1 byte per pixel (or up to 12 bits if you want to get fancy), and then demosaic it on the host? Full HD at 30 fps would be 59.33 MB/s, barely but still fitting into that limit. But then also I think some webcams use H264? I remember reading that somewhere.

> Full HD at 30 fps would be 59.33 MB/s, barely but still fitting into that limit.

That limit is too high even as a theoretical max.

You could do raw 720p.

Re: USB Cheat Sheet

#136

Earlier quoted context omitted.

Can be USB 3 [...] USB 2, so it is a bit hard to tell. ...or Thunderbolt, USB 4, DisplayPort (through Alt-mode or encapsulated in Thunderbolt), or HDMI (Alt-mode), or MHL (Alt-mode), USB Power Delivery... Unfortunately, not every cable with USB-C connectors can carry all of these. E.g. there are USB-C cables that can only carry USB 2. Or cables that can carry USB 3, but not Thunderbolt. Also, not all cables can carry…

Worse, there are no "best" cables longer than 0.5m: any longer than that, Thunderbolt 3 requires active cables which don't pass non-Thunderbolt data beyond, IIRC, 480 Mbps. As someone who spent many years using a mix of 25/50/68/80-pin fast/ultra/… single-ended, LVD and HVD parallel SCSI devices, however, USB-C/Thunderbolt cabling still feels like a breath of fresh air.

I think Thunderbolt 4 active cables are supposed to pass higher USB 3 speeds? At least the Apple Thunderbolt 4 cable claims to do so:

https://www.apple.com/shop/product/MN713AM/A/thunderbolt-4-p...

Re: USB Cheat Sheet

#137
post #87

Earlier quoted context omitted.

Hm. But then wouldn't it make more sense to just stream the raw sensor data, which is 1 byte per pixel (or up to 12 bits if you want to get fancy), and then demosaic it on the host? Full HD at 30 fps would be 59.33 MB/s, barely but still fitting into that limit. But then also I think some webcams use H264? I remember reading that somewhere.

I don't know where you get "1 byte per pixel" from. At minimum, raw 4:2:0 video would be two bytes per pixel, and RGB would be three bytes per pixel with 8-bit color depth.

You're talking about processed color frames. The GP was suggesting that the camera stream the raw sensor data, which doesn't have individual color channels, just a monochrome grid with 10 or 12 bits of usable data per pixel. A bayer filter[0] is placed in front of the sensor so that a given color of light falls on each cell. The USB host would be responsible for applying a demosaicing[0] algorithm to create the color channels from the raw sensor data.

If we take the AR0330 sensor used in the USB Camera C1[2] as an example, it has a native resolution of 2304H x 1296V and outputs 10 bits per native pixel after internal A-Law compression[3] for a total raw frame size of 3.56 MiB, assuming optimal packing. The corresponding image, demosaiced and downscaled to Full HD (1920x1080), in RGB with eight bits per channel would be 5.93 MiB.

[0] https://en.wikipedia.org/wiki/Bayer_filter

[1] https://en.wikipedia.org/wiki/Demosaicing

[2] https://www.kurokesu.com/shop/cameras/CAMUSB1

[3] https://www.onsemi.com/products/sensors/image-sensors/ar0330

Re: USB Cheat Sheet

#138
post #31

Earlier quoted context omitted.

There already exists some fiber-optic USB cables that come in lengths >50m and with support for USB 3.1 so it doesn't seem like a very unrealistic option.

That sounds more like fiber optic adapters/converters that fit into usb-ports and talk usb, rather than USB-cables that can be 50+ meters.

What's the difference between talking USB and being USB?

Re: USB Cheat Sheet

#139

Earlier quoted context omitted.

Not my area of expertise, but maybe some (unrealistic) options include using fiber optics for the data lines, or adding more data lines.

I guess at some point optical will be the only way forward. Having more data lines in a serial bus is interesting, as the whole reasoning to go from parallel lines (e.g. Centronics, ATA/SCSI or ISA/PCI buses) to serial (SATA/SAS, PCIe, USB) was that coordinating multiple data lines got impossible due to physical limitations where e.g. minimal differences in cable lengths started to matter).

> I guess at some point optical will be the only way forward.

Maybe. Though Infiniband's currently at 100Gbps per lane on a 1.5 meter passive cable. And active cables can give you a moderate boost while still on copper.

Re: USB Cheat Sheet

#140
post #112

Earlier quoted context omitted.

Apple just released a €159 cable

3m is beyond the max cable length specified by Thunderbolt, so it requires active extenders (they're hidden in the plugs) and tight manufacturing and shielding. You're paying extra for the ability to break that max length spec, and it's one of only a handful of products that do it. The only other one I'm aware of is the Corning Active Optical Cable series which costs $360 for a 10m Thunderbolt 3 cable or $479 for a 3…

> 3m is beyond the max cable length specified by Thunderbolt, so it requires active extenders (they're hidden in the plugs) and tight manufacturing and shielding. You're paying extra for the ability to break that max length spec, and it's one of only a handful of products that do it.

I'm pretty sure it's not breaking the spec. Are you sure about that claim?

And the main factor is almost always decibels of signal loss rather than length, isn't it?

> Also those Corning cables have a reputation for failing barely out of warranty even if they are treated very delicately. Amazon reviews are full of "my cable failed 1 year and 1 month after purchase and Corning told me to go eat a dick" type reviews.

My understanding is that the thunderbolt 2 ones reliably self-destruct but the thunderbolt 3 ones probably fixed it? At the very least they can take a lot of physical abuse.

> 10gbps half-duplex USB 3.1 cable

I don't think any of the high speed wires are ever half duplex?

Post reply on HN