42 typedef unsigned char byte;
45 clamp (
const int &val,
const int &maxval,
const int &minval)
47 if(val > maxval)
return maxval;
48 if(val < minval)
return minval;
53 rgb_to_yuv (
int r,
int g,
int b, byte &y, byte &u, byte &v)
56 y = (byte)clamp((299 * r + 587 * g + 114 * b) / 1000, 235, 16);
57 v = (byte)clamp((500 * r - 419 * g - 81 * b) / 1000 + 127, 255, 0);
58 u = (byte)clamp((-169 * r - 331 * g + 500 * b) / 1000 + 127, 255, 0);
63 rgb_buffer_to_yuy2 (
unsigned char *in,
unsigned char *out)
65 for (uint i = 0; i < 320*240*2; i+=4)
68 const byte r0 = *(in++);
69 const byte g0 = *(in++);
70 const byte b0 = *(in++);
71 rgb_to_yuv(r0, g0, b0, y0, u0, v0);
74 const byte r1 = *(in++);
75 const byte g1 = *(in++);
76 const byte b1 = *(in++);
77 rgb_to_yuv(r1, g1, b1, y1, u1, v1);
91 DummyImageGenerator::DummyImageGenerator(uint fps)
103 if(frame_ > 2 * fps_)
106 if(frame_ < 1 * fps_)
109 for(
int i = 0; i < 320*240*3; i+=3)
111 byte value ( rand() );
119 typedef unsigned char Row[320 * 3];
121 unsigned char * row =
buf_;
124 for(
int x = 0; x < 320; ++x)
127 byte &g = row[x*3+1];
128 byte &b = row[x*3+2];
130 if (x < 1*320/7) r = 0xC0, g = 0xC0, b = 0xC0;
131 else if(x < 2*320/7) r = 0xC0, g = 0xC0, b = 0x00;
132 else if(x < 3*320/7) r = 0x00, g = 0xC0, b = 0xC0;
133 else if(x < 4*320/7) r = 0x00, g = 0xC0, b = 0x00;
134 else if(x < 5*320/7) r = 0xC0, g = 0x00, b = 0xC0;
135 else if(x < 6*320/7) r = 0xC0, g = 0x00, b = 0x00;
136 else r = 0x00, g = 0x00, b = 0xC0;
140 for(
int y = 1; y < 240; ++y)
141 memcpy(
buf_ + y*
sizeof(Row), row,
sizeof(Row));
146 LumieraDisplayFrame outBuff;
159 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 ...