33 typedef unsigned char byte;
36 clamp (
const int &val,
const int &maxval,
const int &minval)
38 if(val > maxval)
return maxval;
39 if(val < minval)
return minval;
44 rgb_to_yuv (
int r,
int g,
int b, byte &y, byte &u, byte &v)
47 y = (byte)clamp((299 * r + 587 * g + 114 * b) / 1000, 235, 16);
48 v = (byte)clamp((500 * r - 419 * g - 81 * b) / 1000 + 127, 255, 0);
49 u = (byte)clamp((-169 * r - 331 * g + 500 * b) / 1000 + 127, 255, 0);
54 rgb_buffer_to_yuy2 (
unsigned char *in,
unsigned char *out)
56 for (uint i = 0; i < 320*240*2; i+=4)
59 const byte r0 = *(in++);
60 const byte g0 = *(in++);
61 const byte b0 = *(in++);
62 rgb_to_yuv(r0, g0, b0, y0, u0, v0);
65 const byte r1 = *(in++);
66 const byte g1 = *(in++);
67 const byte b1 = *(in++);
68 rgb_to_yuv(r1, g1, b1, y1, u1, v1);
82 DummyImageGenerator::DummyImageGenerator(uint fps)
100 for(
int i = 0; i < 320*240*3; i+=3)
102 byte value ( rand() );
110 typedef unsigned char Row[320 * 3];
112 unsigned char * row =
buf_;
115 for(
int x = 0; x < 320; ++x)
118 byte &g = row[x*3+1];
119 byte &b = row[x*3+2];
121 if (x < 1*320/7) r = 0xC0, g = 0xC0, b = 0xC0;
122 else if(x < 2*320/7) r = 0xC0, g = 0xC0, b = 0x00;
123 else if(x < 3*320/7) r = 0x00, g = 0xC0, b = 0xC0;
124 else if(x < 4*320/7) r = 0x00, g = 0xC0, b = 0x00;
125 else if(x < 5*320/7) r = 0xC0, g = 0x00, b = 0xC0;
126 else if(x < 6*320/7) r = 0xC0, g = 0x00, b = 0x00;
127 else r = 0x00, g = 0x00, b = 0xC0;
131 for(
int y = 1; y < 240; ++y)
132 memcpy(
buf_ + y*
sizeof(Row), row,
sizeof(Row));
137 LumieraDisplayFrame outBuff;
150 rgb_buffer_to_yuy2(
buf_, outBuff);
unsigned char buf_[320 *240 *3]
working buffer for next frame
Generator for test dummy video frames to simulate playback of rendered output.
Steam-Layer implementation namespace root.
LumieraDisplayFrame next()
generate the next frame and occupy the alternate buffer.
unsigned char outFrame_A_[320 *240 *4]
output frame 1
unsigned char outFrame_B_[320 *240 *4]
output frame 2
LumieraDisplayFrame current()
just re-return a pointer to the current frame without generating any new image data ...