X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fplugins%2Fvideoscope%2Fvideoscope.C;h=e662dacbf65518e4ff5d947f2f3840122b334940;hb=HEAD;hp=76b7cf720740f5d9a1116a79b71d0c608c6ae664;hpb=7fd85fb66168f6b518c5f2d73e04036e87faa0e1;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/plugins/videoscope/videoscope.C b/cinelerra-5.1/plugins/videoscope/videoscope.C index 76b7cf72..4bd46678 100644 --- a/cinelerra-5.1/plugins/videoscope/videoscope.C +++ b/cinelerra-5.1/plugins/videoscope/videoscope.C @@ -39,11 +39,7 @@ #include - - - class VideoScopeEffect; -class VideoScopeEngine; class VideoScopeWindow; class VideoScopeConfig @@ -61,42 +57,10 @@ public: void create_objects(); void toggle_event(); int resize_event(int w, int h); - void update(); VideoScopeEffect *plugin; }; - - - - -class VideoScopePackage : public LoadPackage -{ -public: - VideoScopePackage(); - int row1, row2; -}; - - -class VideoScopeUnit : public LoadClient -{ -public: - VideoScopeUnit(VideoScopeEffect *plugin, VideoScopeEngine *server); - void process_package(LoadPackage *package); - VideoScopeEffect *plugin; -}; - -class VideoScopeEngine : public LoadServer -{ -public: - VideoScopeEngine(VideoScopeEffect *plugin, int cpus); - ~VideoScopeEngine(); - void init_packages(); - LoadClient* new_client(); - LoadPackage* new_package(); - VideoScopeEffect *plugin; -}; - class VideoScopeEffect : public PluginVClient { public: @@ -113,42 +77,20 @@ public: int use_hist, use_wave, use_vector; int use_hist_parade, use_wave_parade; + int use_wave_gain, use_vect_gain; + int use_smooth, use_graticule; + int w, h; VFrame *input; }; - - - - - - - - - - - - VideoScopeConfig::VideoScopeConfig() { } - - - - - - - - - - - VideoScopeWindow::VideoScopeWindow(VideoScopeEffect *plugin) - : ScopeGUI(plugin, - plugin->w, - plugin->h) + : ScopeGUI(plugin, plugin->w, plugin->h) { this->plugin = plugin; } @@ -164,6 +106,13 @@ void VideoScopeWindow::create_objects() use_vector = plugin->use_vector; use_hist_parade = plugin->use_hist_parade; use_wave_parade = plugin->use_wave_parade; + use_wave_gain = plugin->use_wave_gain; + use_vect_gain = plugin->use_vect_gain; + use_smooth = plugin->use_smooth; + use_refresh = -1; + use_release = 0; + use_graticule = plugin->use_graticule; + ScopeGUI::create_objects(); } @@ -174,6 +123,10 @@ void VideoScopeWindow::toggle_event() plugin->use_vector = use_vector; plugin->use_hist_parade = use_hist_parade; plugin->use_wave_parade = use_wave_parade; + plugin->use_wave_gain = use_wave_gain; + plugin->use_vect_gain = use_vect_gain; + plugin->use_smooth = use_smooth; + plugin->use_graticule = use_graticule; // Make it reprocess plugin->send_configure_change(); } @@ -189,32 +142,8 @@ int VideoScopeWindow::resize_event(int w, int h) return 1; } - - - - - - - - - - - - - - - - - - - REGISTER_PLUGIN(VideoScopeEffect) - - - - - VideoScopeEffect::VideoScopeEffect(PluginServer *server) : PluginVClient(server) { @@ -225,16 +154,16 @@ VideoScopeEffect::VideoScopeEffect(PluginServer *server) use_vector = 1; use_hist_parade = 1; use_wave_parade = 1; + use_wave_gain = 5; + use_vect_gain = 5; + use_smooth = 1; + use_graticule = 0; } VideoScopeEffect::~VideoScopeEffect() { - - } - - const char* VideoScopeEffect::plugin_title() { return N_("VideoScope"); } int VideoScopeEffect::is_realtime() { return 1; } @@ -250,10 +179,7 @@ void VideoScopeEffect::save_data(KeyFrame *keyframe) // cause data to be stored directly in text output.set_shared_output(keyframe->xbuf); output.tag.set_title("VIDEOSCOPE"); - - - if(is_defaults()) - { + if( is_defaults() ) { output.tag.set_property("W", w); output.tag.set_property("H", h); output.tag.set_property("USE_HIST", use_hist); @@ -261,8 +187,12 @@ void VideoScopeEffect::save_data(KeyFrame *keyframe) output.tag.set_property("USE_VECTOR", use_vector); output.tag.set_property("USE_HIST_PARADE", use_hist_parade); output.tag.set_property("USE_WAVE_PARADE", use_wave_parade); - } + output.tag.set_property("USE_WAVE_GAIN", use_wave_gain); + output.tag.set_property("USE_VECT_GAIN", use_vect_gain); + output.tag.set_property("USE_SMOOTH", use_smooth); + output.tag.set_property("USE_GRATICULE", use_graticule); + } output.append_tag(); output.tag.set_title("/VIDEOSCOPE"); output.append_tag(); @@ -274,373 +204,45 @@ void VideoScopeEffect::read_data(KeyFrame *keyframe) { FileXML input; input.set_shared_input(keyframe->xbuf); - int result = 0; - - while(!result) - { - result = input.read_tag(); - - if(!result) - { - if(input.tag.title_is("VIDEOSCOPE")) - { - if(is_defaults()) - { - w = input.tag.get_property("W", w); - h = input.tag.get_property("H", h); - use_hist = input.tag.get_property("USE_HIST", use_hist); - use_wave = input.tag.get_property("USE_WAVE", use_wave); - use_vector = input.tag.get_property("USE_VECTOR", use_vector); - use_hist_parade = input.tag.get_property("USE_HIST_PARADE", use_hist_parade); - use_wave_parade = input.tag.get_property("USE_WAVE_PARADE", use_wave_parade); - } + while( !(result = input.read_tag()) ) { + if( input.tag.title_is("VIDEOSCOPE") ) { + if( is_defaults() ) { + w = input.tag.get_property("W", w); + h = input.tag.get_property("H", h); + use_hist = input.tag.get_property("USE_HIST", use_hist); + use_wave = input.tag.get_property("USE_WAVE", use_wave); + use_vector = input.tag.get_property("USE_VECTOR", use_vector); + use_hist_parade = input.tag.get_property("USE_HIST_PARADE", use_hist_parade); + use_wave_parade = input.tag.get_property("USE_WAVE_PARADE", use_wave_parade); + use_wave_gain = input.tag.get_property("USE_WAVE_GAIN", use_wave_gain); + use_vect_gain = input.tag.get_property("USE_VECT_GAIN", use_vect_gain); + use_smooth = input.tag.get_property("USE_SMOOTH", use_smooth); + use_graticule = input.tag.get_property("USE_GRATICULE", use_graticule); } } } } - - - NEW_WINDOW_MACRO(VideoScopeEffect, VideoScopeWindow) - int VideoScopeEffect::process_realtime(VFrame *input, VFrame *output) { send_render_gui(input); -//printf("VideoScopeEffect::process_realtime 1\n"); - if(input->get_rows()[0] != output->get_rows()[0]) + if( input->get_rows()[0] != output->get_rows()[0] ) output->copy_from(input); return 1; } void VideoScopeEffect::render_gui(void *input) { - if(thread) - { - VideoScopeWindow *window = ((VideoScopeWindow*)thread->window); - window->lock_window(); - -//printf("VideoScopeEffect::process_realtime 1\n"); - this->input = (VFrame*)input; -//printf("VideoScopeEffect::process_realtime 1\n"); - window->process(this->input); - - - window->unlock_window(); - } -} - - - - - -VideoScopePackage::VideoScopePackage() - : LoadPackage() -{ -} - - - - - - -VideoScopeUnit::VideoScopeUnit(VideoScopeEffect *plugin, - VideoScopeEngine *server) - : LoadClient(server) -{ - this->plugin = plugin; -} - - -#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; - } -} - - - -#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++) \ - { \ - type *in_pixel = in_row + j * components; \ - 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) \ - { \ - YUV::yuv.yuv_to_rgb_16(r, g, b, \ - in_pixel[0], in_pixel[1], in_pixel[2]); \ - } \ - else \ - { \ - YUV::yuv.yuv_to_rgb_8(r, g, b, \ - in_pixel[0], in_pixel[1], in_pixel[2]); \ - } \ - } \ - 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); \ - \ -/* Calculate waveform */ \ - if(parade) \ - { \ -/* red */ \ - int x = j * waveform_w / w / 3; \ - int y = waveform_h - (int)(((float)r / max - FLOAT_MIN) / \ - (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; \ - y = waveform_h - (int)(((float)g / max - FLOAT_MIN) / \ - (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; \ - y = waveform_h - (int)(((float)b / max - FLOAT_MIN) / \ - (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); \ - } \ - 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); \ - } \ - \ -/* 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); \ - r = (int)(r_f * 255); \ - g = (int)(g_f * 255); \ - b = (int)(b_f * 255); \ - \ - /* float */ \ - if(sizeof(type) == 4) \ - { \ - 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); \ - \ - } \ - } \ -} - -void VideoScopeUnit::process_package(LoadPackage *package) -{ - VideoScopeWindow *window = (VideoScopeWindow*)plugin->thread->window; - VideoScopePackage *pkg = (VideoScopePackage*)package; - int w = plugin->input->get_w(); -// 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(); - 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; - - case BC_RGB_FLOAT: - VIDEOSCOPE(float, float, 1, 3, 0) - 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_YUV161616: - VIDEOSCOPE(uint16_t, int, 0xffff, 3, 1) - 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_YUVA8888: - VIDEOSCOPE(unsigned char, int, 0xff, 4, 1) - break; - - case BC_RGBA16161616: - VIDEOSCOPE(uint16_t, int, 0xffff, 4, 0) - break; - - case BC_YUVA16161616: - VIDEOSCOPE(uint16_t, int, 0xffff, 4, 1) - break; - } -} - - - - - - -VideoScopeEngine::VideoScopeEngine(VideoScopeEffect *plugin, int cpus) - : LoadServer(cpus, cpus) -{ - this->plugin = plugin; -} - -VideoScopeEngine::~VideoScopeEngine() -{ -} - -void VideoScopeEngine::init_packages() -{ - for(int i = 0; i < LoadServer::get_total_packages(); i++) - { - VideoScopePackage *pkg = (VideoScopePackage*)get_package(i); - pkg->row1 = plugin->input->get_h() * i / LoadServer::get_total_packages(); - pkg->row2 = plugin->input->get_h() * (i + 1) / LoadServer::get_total_packages(); - } -} - - -LoadClient* VideoScopeEngine::new_client() -{ - return new VideoScopeUnit(plugin, this); -} - -LoadPackage* VideoScopeEngine::new_package() -{ - return new VideoScopePackage; + if( !thread ) return; + VideoScopeWindow *window = ((VideoScopeWindow*)thread->window); + window->lock_window(); + this->input = (VFrame*)input; + window->process(this->input); + window->unlock_window(); }