}
-#define INTENSITY(p) ((unsigned int)(((p)[0]) * 77+ \
- ((p)[1] * 150) + \
- ((p)[2] * 29)) >> 8)
-
-
-static void draw_point(unsigned char **rows,
- int color_model,
- int x,
- int y,
- int r,
- int g,
- int b)
+#define INTENSITY(p) ((unsigned int)(((p)[0]) * 77+ ((p)[1] * 150) + ((p)[2] * 29)) >> 8)
+
+
+static void draw_point(unsigned char **rows, int color_model,
+ int x, int y, int r, int g, int b)
{
- switch(color_model)
- {
- case BC_BGR8888:
- {
- unsigned char *pixel = rows[y] + x * 4;
- pixel[0] = b;
- pixel[1] = g;
- pixel[2] = r;
- break;
- }
- case BC_BGR888:
- break;
- case BC_RGB565:
- {
- unsigned char *pixel = rows[y] + x * 2;
- pixel[0] = (r & 0xf8) | (g >> 5);
- pixel[1] = ((g & 0xfc) << 5) | (b >> 3);
- break;
- }
- case BC_BGR565:
- break;
- case BC_RGB8:
- break;
+ switch( color_model ) {
+ case BC_BGR8888: {
+ unsigned char *pixel = rows[y] + x * 4;
+ pixel[0] = b; pixel[1] = g; pixel[2] = r;
+ break;
+ }
+ case BC_BGR888: break;
+ case BC_RGB565: {
+ unsigned char *pixel = rows[y] + x * 2;
+ pixel[0] = (r & 0xf8) | (g >> 5);
+ pixel[1] = ((g & 0xfc) << 5) | (b >> 3);
+ break;
+ }
+ case BC_BGR565: break;
+ case BC_RGB8: break;
}
}
-
-
-#define VIDEOSCOPE(type, temp_type, max, components, use_yuv) \
-{ \
- for(int i = pkg->row1; i < pkg->row2; i++) \
- { \
+#define VIDEOSCOPE(type, temp_type, max, components, use_yuv) { \
+ for( int i=pkg->row1; i<pkg->row2; ++i ) { \
type *in_row = (type*)plugin->input->get_rows()[i]; \
- for(int j = 0; j < w; j++) \
- { \
+ for( int j=0; j<w; ++j ) { \
type *in_pixel = in_row + j * components; \
- float intensity; \
- \
-/* Analyze pixel */ \
+ float intensity; /* Analyze pixel */ \
if(use_yuv) intensity = (float)*in_pixel / max; \
- \
float h, s, v; \
temp_type r, g, b; \
- if(use_yuv) \
- { \
- if(sizeof(type) == 2) \
- { \
+ if( use_yuv ) { \
+ if( sizeof(type) == 2 ) { \
YUV::yuv.yuv_to_rgb_16(r, g, b, \
in_pixel[0], in_pixel[1], in_pixel[2]); \
} \
- else \
- { \
+ else { \
YUV::yuv.yuv_to_rgb_8(r, g, b, \
in_pixel[0], in_pixel[1], in_pixel[2]); \
} \
} \
- else \
- { \
+ else { \
r = in_pixel[0]; \
g = in_pixel[1]; \
b = in_pixel[2]; \
} \
- \
- HSV::rgb_to_hsv((float)r / max, \
- (float)g / max, \
- (float)b / max, \
- h, \
- s, \
- v); \
- \
+ HSV::rgb_to_hsv((float)r / max, (float)g / max, (float)b / max, \
+ h, s, v); \
/* Calculate waveform */ \
- if(parade) \
- { \
-/* red */ \
- int x = j * waveform_w / w / 3; \
+ if(parade) { \
+ int x = j * waveform_w / w / 3; /* red */ \
int y = waveform_h - (int)(((float)r / max - FLOAT_MIN) / \
- (FLOAT_MAX - FLOAT_MIN) * \
- waveform_h); \
+ (FLOAT_MAX - FLOAT_MIN) * waveform_h); \
if(x >= 0 && x < waveform_w / 3 && y >= 0 && y < waveform_h) \
- draw_point(waveform_rows, \
- waveform_cmodel, \
- x, \
- y, \
- 0xff, \
- 0x0, \
- 0x0); \
- \
-/* green */ \
- x = waveform_w / 3 + j * waveform_w / w / 3; \
+ draw_point(waveform_rows, waveform_cmodel, x, y, \
+ 0xff, 0x00, 0x00); \
+ x = waveform_w / 3 + j * waveform_w / w / 3; /* green */ \
y = waveform_h - (int)(((float)g / max - FLOAT_MIN) / \
- (FLOAT_MAX - FLOAT_MIN) * \
- waveform_h); \
+ (FLOAT_MAX - FLOAT_MIN) * waveform_h); \
if(x >= waveform_w / 3 && x < waveform_w * 2 / 3 && \
y >= 0 && y < waveform_h) \
- draw_point(waveform_rows, \
- waveform_cmodel, \
- x, \
- y, \
- 0x0, \
- 0xff, \
- 0x0); \
- \
-/* blue */ \
- x = waveform_w * 2 / 3 + j * waveform_w / w / 3; \
+ draw_point(waveform_rows, waveform_cmodel, x, y, \
+ 0x00, 0xff, 0x00); \
+ x = waveform_w * 2 / 3 + j * waveform_w / w / 3; /* blue */ \
y = waveform_h - (int)(((float)b / max - FLOAT_MIN) / \
- (FLOAT_MAX - FLOAT_MIN) * \
- waveform_h); \
+ (FLOAT_MAX - FLOAT_MIN) * waveform_h); \
if(x >= waveform_w * 2 / 3 && x < waveform_w && \
y >= 0 && y < waveform_h) \
- draw_point(waveform_rows, \
- waveform_cmodel, \
- x, \
- y, \
- 0x0, \
- 0x0, \
- 0xff); \
+ draw_point(waveform_rows, waveform_cmodel, x, y, \
+ 0x00, 0x00, 0xff); \
} \
- else \
- { \
+ else { \
if(!use_yuv) intensity = v; \
intensity = (intensity - FLOAT_MIN) / (FLOAT_MAX - FLOAT_MIN) * \
waveform_h; \
int y = waveform_h - (int)intensity; \
int x = j * waveform_w / w; \
if(x >= 0 && x < waveform_w && y >= 0 && y < waveform_h) \
- draw_point(waveform_rows, \
- waveform_cmodel, \
- x, \
- y, \
- 0xff, \
- 0xff, \
- 0xff); \
+ draw_point(waveform_rows, waveform_cmodel, x, y, \
+ 0xff, 0xff, 0xff); \
} \
- \
/* Calculate vectorscope */ \
float adjacent = cos((h + 90) / 360 * 2 * M_PI); \
float opposite = sin((h + 90) / 360 * 2 * M_PI); \
int x = (int)(vector_w / 2 + \
adjacent * (s - FLOAT_MIN) / (FLOAT_MAX - FLOAT_MIN) * radius); \
- \
int y = (int)(vector_h / 2 - \
opposite * (s - FLOAT_MIN) / (FLOAT_MAX - FLOAT_MIN) * radius); \
- \
- \
CLAMP(x, 0, vector_w - 1); \
CLAMP(y, 0, vector_h - 1); \
/* Get color with full saturation & value */ \
float r_f, g_f, b_f; \
- HSV::hsv_to_rgb(r_f, \
- g_f, \
- b_f, \
- h, \
- s, \
- 1); \
+ HSV::hsv_to_rgb(r_f, g_f, b_f, h, s, 1); \
r = (int)(r_f * 255); \
g = (int)(g_f * 255); \
b = (int)(b_f * 255); \
- \
- /* float */ \
- if(sizeof(type) == 4) \
- { \
+ if(sizeof(type) == 4) { /* float */ \
r = CLIP(r, 0, 0xff); \
g = CLIP(g, 0, 0xff); \
b = CLIP(b, 0, 0xff); \
} \
- \
- draw_point(vector_rows, \
- vector_cmodel, \
- x, \
- y, \
- (int)r, \
- (int)g, \
- (int)b); \
- \
+ draw_point(vector_rows, vector_cmodel, x, y, \
+ (int)r, (int)g, (int)b); \
} \
} \
}
// int h = plugin->input->get_h();
int waveform_h = window->wave_h;
int waveform_w = window->wave_w;
- int waveform_cmodel = window->waveform_bitmap->get_color_model();
- unsigned char **waveform_rows = window->waveform_bitmap->get_row_pointers();
- int vector_h = window->vector_bitmap->get_h();
- int vector_w = window->vector_bitmap->get_w();
- int vector_cmodel = window->vector_bitmap->get_color_model();
- unsigned char **vector_rows = window->vector_bitmap->get_row_pointers();
+ int waveform_cmodel = window->waveform_vframe->get_color_model();
+ unsigned char **waveform_rows = window->waveform_vframe->get_rows();
+ int vector_h = window->vector_vframe->get_h();
+ int vector_w = window->vector_vframe->get_w();
+ int vector_cmodel = window->vector_vframe->get_color_model();
+ unsigned char **vector_rows = window->vector_vframe->get_rows();
float radius = MIN(vector_w / 2, vector_h / 2);
int parade = 1;
- switch(plugin->input->get_color_model())
- {
- case BC_RGB888:
- VIDEOSCOPE(unsigned char, int, 0xff, 3, 0)
- break;
+ switch( plugin->input->get_color_model() ) {
+ case BC_RGB888:
+ VIDEOSCOPE(unsigned char, int, 0xff, 3, 0)
+ break;
- case BC_RGB_FLOAT:
- VIDEOSCOPE(float, float, 1, 3, 0)
- break;
+ case BC_RGB_FLOAT:
+ VIDEOSCOPE(float, float, 1, 3, 0)
+ break;
- case BC_YUV888:
- VIDEOSCOPE(unsigned char, int, 0xff, 3, 1)
- break;
+ case BC_YUV888:
+ VIDEOSCOPE(unsigned char, int, 0xff, 3, 1)
+ break;
- case BC_RGB161616:
- VIDEOSCOPE(uint16_t, int, 0xffff, 3, 0)
- break;
+ case BC_RGB161616:
+ VIDEOSCOPE(uint16_t, int, 0xffff, 3, 0)
+ break;
- case BC_YUV161616:
- VIDEOSCOPE(uint16_t, int, 0xffff, 3, 1)
- break;
+ case BC_YUV161616:
+ VIDEOSCOPE(uint16_t, int, 0xffff, 3, 1)
+ break;
- case BC_RGBA8888:
- VIDEOSCOPE(unsigned char, int, 0xff, 4, 0)
- break;
+ case BC_RGBA8888:
+ VIDEOSCOPE(unsigned char, int, 0xff, 4, 0)
+ break;
- case BC_RGBA_FLOAT:
- VIDEOSCOPE(float, float, 1, 4, 0)
- break;
+ case BC_RGBA_FLOAT:
+ VIDEOSCOPE(float, float, 1, 4, 0)
+ break;
- case BC_YUVA8888:
- VIDEOSCOPE(unsigned char, int, 0xff, 4, 1)
- break;
+ case BC_YUVA8888:
+ VIDEOSCOPE(unsigned char, int, 0xff, 4, 1)
+ break;
- case BC_RGBA16161616:
- VIDEOSCOPE(uint16_t, int, 0xffff, 4, 0)
- break;
+ case BC_RGBA16161616:
+ VIDEOSCOPE(uint16_t, int, 0xffff, 4, 0)
+ break;
- case BC_YUVA16161616:
- VIDEOSCOPE(uint16_t, int, 0xffff, 4, 1)
- break;
+ case BC_YUVA16161616:
+ VIDEOSCOPE(uint16_t, int, 0xffff, 4, 1)
+ break;
}
}
-
-
-
-
-
VideoScopeEngine::VideoScopeEngine(VideoScopeEffect *plugin, int cpus)
: LoadServer(cpus, cpus)
{