Goal: to unpack/pack to/from YUV to RGB24, so the data is then ready for the

equations below.

According to IEEE 1394 Digital Camera Specification 1.20 YUV formats are

defined as follows:

YUV 4:4:4 >>> What do the three numbers represent A:B:C?

Pn : Pixel number / packet >>> is this pixel per packet (0,1)(0,1)(0,1)...

>>> or is this (0,1)(2,3)(4,5)...

K : Pn x n (n=0..N-1) >>> What does K represent?

(Pn x N = Total pixel number / frame) >>> What is Pn x n/N?

U-(K+0) Y-(K+0) V-(K+0) U-(K+1)

Y-(K+1) V-(K+1) U-(K+2) Y-(K+2)

V-(K+2) U-(K+3) Y-(K+3) V-(K+3)

U-(K+Pn-4) Y-(K+Pn-4) V-(K+Pn-4) U-(K+Pn-3)

Y-(K+Pn-3) V-(K+Pn-3) U-(K+Pn-2) Y-(K+Pn-2)

V-(K+Pn-2) U-(K+Pn-1) Y-(K+Pn-1) V-(K+Pn-1)

An alternate representation for the IYU2 format is a 24 bit format used in

mode 0, which is the same as YUV (4:4:4), and is according to the following

pattern:

Byte 0 1 2 3 4

5

Sample U(K+0) Y(K+0) V(K+0) U(K+1) Y(K+1) V(K+1)

Horizontal Vertical

Y Sample Period 1 1

V Sample Period 1 1

U Sample Period 1 1

What do they mean by Sample Period?

For 4:4:4 it appears to be two consecutive pixels spread over 6 bytes along

horizontal lines that wrap down (or up?) to the next video line, with no

planer separation. Is this correct?

If the format is planer how do you determine the start position of each

plane?

Some of the other camera formats:

YUV 4:2:2

YUV 4:1:1

Y (mono)

IYUV/I420 (planar 4:2:0 or 4:1:1).

YV12 (planar 4:2:0 or 4:1:1).

YUY2 (packed 4:2:2).

UYVY (packed 4:2:2)

YVYU (packed 4:2:2)

YVU9 (planar 16:1:1)

Also when a signal stream comes in from a camera, using winmm.dll interface,

how do you determine which format the stream is in?

Thanks,

Tim

http://www.yqcomputer.com/

http://www.yqcomputer.com/

--------------

Conversion equations:

Floating point:

RGB to YUV (YCbCr)

Y = (0.299 * R) + (0.587 * G) + (0.114 * B)

U' = (B - Y) * 0.564 = (-0.169 * R) - (0.331 * G) + (0.500 * B)

V' = (R - Y) * 0.713 = (0.500 * R) - (0.419 * G) - (0.081 * B)

U' = Cr

V' = Cb

Luminance Y are encoded grayscale from 0 to 255

Chrominance U, V are encoded color information between -128 and +127

similar to color/hue and tint/saturation

Values saturate at ends of range

Average U,V values over 2x2 blocks of pixels

Human eye is less sensitive to variations in color than in brightness

YUV to RGB

R = Y + (1.403 * V')

G = Y - (0.344 * U') - (0.714 * V')

B = Y + (1.770 * U')

16 <= Y <= 235 [220 steps]

16 <= U'/Cr <= 239 [235 steps]

16 <= V'/Cb <= 239 [235 steps]

Fixed point:

Y = [(9798 R + 19235G + 3736 B) / 32768]

U = [(-4784 R - 9437 G + 4221 B) / 32768] + 128

V = [(20218R - 16941G - 3277 B) / 32768] + 128

Y should be clamped at 16 to prevent sub-black, the same way as it should be

clamped at 235 to prevent white>100%. This can be done by the use of a 256

entry lookup table.

--------------

http://www.yqcomputer.com/

Also check the specs on your DV camera, most consumer cameras only capture

either 4:1:1 or 4:2:2 YUV. You usually have to get fairly high-end before

you can get 4:4:4.

1. Question about blitting from RGB surface to YUV surface

3. YUV / RGB

4. How to make the video source filter generic for YUV,YUY and RGB formats?

5. how to get DShow to use accelerated YUV-to-RGB blits

6. YUV/RGB conversion and smooth WMV-HD playback

7. YUV, RGB and gamma correction

8. Need help on "How to read YUV data and convert it to RGB programaticaly"

9. Relation ship of constants in yuv<->rgb formula's ?

10. how can convert RGB TO HIS AND YUV IN MATLAB

11. YUV to RGB conversion in OV7620

12. YUV and RGB

13. I've found a capture card with RGB and YUV input...

14. drawing raw format (RGB/YUV) to Pocket PC

15. bliting RGB to YUV surface

4 post • Page:**1** of **1**