Linux Game Programming for PC & Embedded Systems using SDL
Presented by
Fore June
Author of Windows Fan, Linux Fan

Sample program for converting RGB to YCbCr and vice versa.

common.h
rgb_ybr.h
encode.h
rgb_ybr.cpp
encode.cpp
typlayer.cpp
Makefile
sample_video.raw



common.h:
#ifndef COMMON_H
#define COMMON_H
//an RGB pixel
typedef struct {
  unsigned char R;	//[0, 255]
  unsigned char G;	//[0, 255]
  unsigned char B;	//[0, 255]
} RGB;

typedef struct {
  short Y;		//[0, 255]
  short Cb;		//[-127, 127]
  short Cr;		//[-127, 127]
} YCbCr;

//use 4:2:0 YCbCr
typedef struct {
  short Y[256];         //16x16 ( four 8x8 samples )
  short Cb[64];		//8x8 
  short Cr[64];		//8x8
} YCbCr_MACRO;
#endif