참조 사이트: http://www.fourcc.org
YUV에도 여러 가지 종류가 있다. 그 중에서 YUV420(YV12)에 대해서 알아보도록 하겠다.
YUV420(YV12)
This is the format of choice for many software MPEG codecs. It comprises an NxM Y plane followed by (N/2)x(M/2) V and U planes.
Horizontal | Vertical | |
Y Sample Period | 1 | 1 |
V Sample Period | 2 | 2 |
U Sample Period | 2 | 2 |
Positive biHeight implies top-down image (top line first)
ATI says they have a download which contains this codec but I can't find it on their site. If you would like something similar for Quicktime, try here.
=======================================================================================
// 아래 코드는 YUV 바이트 스트림 배열에서의 YUV 각 값의 위치를 찾기위한 코드가 설명되어 있다.
Height = 16;
Width = 16;
Y'ArraySize = Height × Width; // (256)
Y' = Array[7 × Width + 5];
U = Array[(7/2) × (Width/2) + 5/2 + Y'ArraySize];
V = Array[(7/2) × (Width/2) + 5/2 + Y'ArraySize + Y'ArraySize/4];
RGB = Y'UV444toRGB888(Y', U, V);
위 예제 그림은 Y -> U -> V 순으로 바이트 스트림이 되어 있지만 항상 정해진 것은 아니다.
다른 바이트 스트림의 경우 Y -> V -> U 순으로 되어 있는 경우도 있다.
YUV420 <------> RGB 변환
참고 사이트 : http://www.fourcc.org/fccyvrgb.php
The following 2 sets of formulae are taken from information from Keith Jack's excellent book "Video Demystified" (ISBN 1-878707-09-4).
RGB to YUV Conversion
Y = (0.257 * R) + (0.504 * G) + (0.098 * B) + 16
Cr = V = (0.439 * R) - (0.368 * G) - (0.071 * B) + 128
Cb = U = -(0.148 * R) - (0.291 * G) + (0.439 * B) + 128
YUV to RGB Conversion
B = 1.164(Y - 16) + 2.018(U - 128)
G = 1.164(Y - 16) - 0.813(V - 128) - 0.391(U - 128)
R = 1.164(Y - 16) + 1.596(V - 128)
#define clip(var) ((var>=255)?255:(var<=0)?0:var)
변환을 하면서 위와 같이 각 값에 대하여 clip이 필요하다.
[출처] YUV420(YV12) (차니의 컴퓨터 마을) |작성자 newchany
'멀티미디어 > 이미지 프로세싱' 카테고리의 다른 글
YCbCr과 YPbPr (0) | 2009.03.18 |
---|---|
YUV420을 RGB로 변환하기 (0) | 2009.03.18 |
동영상 파일끼리 PSNR 비교하는 프로그램 (0) | 2009.03.18 |
DCT 프로그램 (0) | 2009.03.18 |
H.264 tutoroals (0) | 2009.03.18 |