24 #include <emscripten/emscripten.h> 32 #define MOOSEFRAME_SIZE (MOOSEPIC_W * MOOSEPIC_H) 33 #define MOOSEFRAMES_COUNT 10 174 yuv[0] = (int)(0.299 * rgb[0] + 0.587 * rgb[1] + 0.114 * rgb[2]);
178 yuv[0] = (int)(0.257 * rgb[0]) + (0.504 * rgb[1]) + (0.098 * rgb[2]) + 16;
184 yuv[0] = (int)(0.299 * rgb[0] + 0.587 * rgb[1] + 0.114 * rgb[2]);
185 yuv[1] = (int)((rgb[2] - yuv[0]) * 0.565 + 128);
186 yuv[2] = (int)((rgb[0] - yuv[0]) * 0.713 + 128);
188 yuv[0] = (0.257 * rgb[0]) + (0.504 * rgb[1]) + (0.098 * rgb[2]) + 16;
189 yuv[1] = 128 - (0.148 * rgb[0]) - (0.291 * rgb[1]) + (0.439 * rgb[2]);
190 yuv[2] = 128 + (0.439 * rgb[0]) - (0.368 * rgb[1]) - (0.071 * rgb[2]);
194 if (luminance != 100) {
195 yuv[0] = yuv[0] * luminance / 100;
203 int monochrome,
int luminance)
211 op[2] = op[1] + w*h/4;
212 for (y = 0; y <
h; ++
y) {
213 for (x = 0; x <
w; ++
x) {
214 RGBtoYUV(rgb, yuv, monochrome, luminance);
216 if (x % 2 == 0 && y % 2 == 0) {
227 int monochrome,
int luminance)
235 for (y = 0; y <
h; ++
y) {
236 for (x = 0; x <
w; ++
x) {
237 RGBtoYUV(rgb, yuv, monochrome, luminance);
239 if (x % 2 == 0 && y % 2 == 0) {
251 SDL_Log(
"Usage: %s [arg] [arg] [arg] ...\n", argv0);
253 SDL_Log(
"Where 'arg' is any of the following options:\n");
255 SDL_Log(
" -fps <frames per second>\n");
257 SDL_Log(
" -format <fmt> (one of the: YV12, IYUV, YUY2, UYVY, YVYU)\n");
258 SDL_Log(
" -scale <scale factor> (initial scale of the overlay)\n");
259 SDL_Log(
" -help (shows this help)\n");
261 SDL_Log(
"Press ESC to exit, or SPACE to freeze the movie while application running.\n");
271 switch (event.
type) {
275 displayrect.
w =
window_w =
event.window.data1;
276 displayrect.
h =
window_h =
event.window.data2;
280 displayrect.
x =
event.button.x -
window_w / 2;
281 displayrect.
y =
event.button.y -
window_h / 2;
285 displayrect.
x =
event.motion.x -
window_w / 2;
286 displayrect.
y =
event.motion.y -
window_h / 2;
303 #ifndef __EMSCRIPTEN__ 316 #ifdef __EMSCRIPTEN__ 318 emscripten_cancel_main_loop();
349 if (strcmp(argv[1],
"-fps") == 0) {
354 "The -fps option requires an argument [from 1 to 1000], default is 12.\n");
357 if ((fps < 0) || (fps > 1000)) {
359 "The -fps option must be in range from 1 to 1000, default is 12.\n");
366 "The -fps option requires an argument [from 1 to 1000], default is 12.\n");
369 }
else if (strcmp(argv[1],
"-nodelay") == 0) {
373 }
else if (strcmp(argv[1],
"-scale") == 0) {
375 scale = atoi(argv[2]);
378 "The -scale option requires an argument [from 1 to 50], default is 5.\n");
381 if ((scale < 0) || (scale > 50)) {
383 "The -scale option must be in range from 1 to 50, default is 5.\n");
390 "The -fps option requires an argument [from 1 to 1000], default is 12.\n");
393 }
else if ((strcmp(argv[1],
"-help") == 0)
394 || (strcmp(argv[1],
"-h") == 0)) {
405 if (RawMooseData ==
NULL) {
413 if (handle ==
NULL) {
461 rgb[0] = MooseColors[frame[
j]].
r;
462 rgb[1] = MooseColors[frame[
j]].
g;
463 rgb[2] = MooseColors[frame[
j]].
b;
466 switch (pixel_format) {
486 fpsdelay = 1000 / fps;
498 #ifdef __EMSCRIPTEN__ 499 emscripten_set_main_loop(
loop, nodelay ? 0 : fps, 1);
#define SDL_CreateTexture
GLenum GLenum GLenum GLenum GLenum scale
#define SDL_RenderSetViewport
SDL_MouseMotionEvent motion
uint32_t Uint32
An unsigned 32-bit integer type.
void ConvertRGBtoNV12(Uint8 *rgb, Uint8 *out, int w, int h, int monochrome, int luminance)
SDL_Texture * MooseTexture
#define SDL_RWread(ctx, ptr, size, n)
#define SDL_BYTESPERPIXEL(X)
#define SDL_WINDOWPOS_UNDEFINED
GLint GLint GLint GLint GLint x
#define SDL_UpdateTexture
Uint8 MooseFrame[MOOSEFRAMES_COUNT][MOOSEFRAME_SIZE *2]
#define MOOSEFRAMES_COUNT
uint8_t Uint8
An unsigned 8-bit integer type.
#define SDL_LogSetPriority
GLint GLint GLint GLint GLint GLint y
The type used to identify a window.
SDL_Color MooseColors[84]
GLubyte GLubyte GLubyte GLubyte w
#define SDL_DestroyRenderer
int main(int argc, char **argv)
void RGBtoYUV(Uint8 *rgb, int *yuv, int monochrome, int luminance)
static void PrintUsage(char *argv0)
GLfloat GLfloat GLfloat GLfloat h
#define SDL_CreateRenderer
A rectangle, with the origin at the upper left.
#define SDL_RenderPresent
void ConvertRGBtoYV12(Uint8 *rgb, Uint8 *out, int w, int h, int monochrome, int luminance)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int in j)