2

I have YUV422 10-bits SDI from camera, and I need to accurately convert it to 8-bits. Can I just shift right by 2 bits, or it is not good?

There is a lot of info: http://en.wikipedia.org/wiki/YUV and https://ru.wikipedia.org/wiki/YCbCr But there is no full clearness.

Mike I.
  • 91
  • 1
  • 2
  • 5
  • You can but make sure to correctly extract those 10-bit values. – Roman R. Sep 12 '14 at 09:10
  • Yes, but I send 8-bit YUV420 to video encoder, and standard decoders & players (like VLC) would perform back conversion to RGB. – Mike I. Sep 12 '14 at 09:18
  • Players don't necessarily need to convert to RGB. Anyway, it's their part, your correct stripping two lowest bits is all you need. – Roman R. Sep 12 '14 at 09:25
  • The fact, that minimal allowed value for "Y" is 64 for 10-bits and 16 for 8-bits, says, that truncating bits is correct enough. – Mike I. Sep 12 '14 at 09:46

1 Answers1

5

For 8 bit: Y range is [16..235] and U/V range is [16..240]

For 10 bit: Y range is [64..940] and U/V range is [64..960]

So shifting each component value 2 bits to right will provide correct conversion of black and white points: 64==>16, 940==>235 and 960==>240. Intermediate values also will correctly converted.

Ivan Uskov
  • 51
  • 1
  • 4
  • 3
    For correct rounding, add 2 before shifting: `b = (a+2) >> 2`. Example: `7 >> 1 = 1` but `7.0/4.0 = 1.75` and `round(7.0/4.0) = 2.0` and `(7+2) >> 2 = 2` – Rotem Feb 17 '18 at 21:41