From: Good Guy Date: Sat, 14 Apr 2018 16:52:19 +0000 (-0600) Subject: x265 update 2.7, findobj upgrade, fix svg init, fix for dragchkbox buttonpress, add... X-Git-Url: http://git.cinelerra-gg.org/git/?p=goodguy%2Fhistory.git;a=commitdiff_plain;h=8aa6d71ebd2c65785a8b553fc6fc38ac19041ce0 x265 update 2.7, findobj upgrade, fix svg init, fix for dragchkbox buttonpress, add load filters, shmmax/shmmni min test --- diff --git a/cinelerra-5.1/cinelerra/affine.C b/cinelerra-5.1/cinelerra/affine.C index ff9c4709..2842f990 100644 --- a/cinelerra-5.1/cinelerra/affine.C +++ b/cinelerra-5.1/cinelerra/affine.C @@ -912,6 +912,40 @@ void AffineEngine::set_matrix(AffineMatrix *matrix) } } +// in x1,y1 - x2,y1 out x1,y1 - x2,y2 clockwise +// | | | | +// x1,y2 - x2,y2 x4,y4 - x3,y3 +void AffineEngine::set_matrix( + double in_x1, double in_y1, double in_x2, double in_y2, + double out_x1, double out_y1, double out_x2, double out_y2, + double out_x3, double out_y3, double out_x4, double out_y4) +{ + AffineMatrix m; + double in_w = in_x2 - in_x1, scalex = in_w > 0 ? 1./in_w : 1.0; + double in_h = in_y2 - in_y1, scaley = in_h > 0 ? 1./in_h : 1.0; + double dx1 = out_x2 - out_x3; + double dy1 = out_y2 - out_y3; + double dx2 = out_x4 - out_x3; + double dy2 = out_y4 - out_y3; + double dx3 = out_x1 - out_x2 + out_x3 - out_x4; + double dy3 = out_y1 - out_y2 + out_y3 - out_y4; + double det = dx1 * dy2 - dy1 * dx2; + m.values[2][0] = det ? (dx3 * dy2 - dy3 * dx2) / det : 0; + m.values[2][1] = det ? (dx1 * dy3 - dy1 * dx3) / det : 0; + m.values[2][2] = 1.0; + m.values[0][0] = out_x2 - out_x1 + matrix.values[2][0] * out_x2; + m.values[0][1] = out_x4 - out_x1 + matrix.values[2][1] * out_x4; + m.values[0][2] = out_x1; + m.values[1][0] = out_y2 - out_y1 + matrix.values[2][0] * out_y2; + m.values[1][1] = out_y4 - out_y1 + matrix.values[2][1] * out_y4; + m.values[1][2] = out_y1; + matrix.identity(); + matrix.translate(-in_x1, -in_y1); + matrix.scale(scalex, scaley); + m.multiply(&matrix); +} + + void AffineEngine::set_in_viewport(int x, int y, int w, int h) { this->in_x = x; this->in_y = y; diff --git a/cinelerra-5.1/cinelerra/affine.h b/cinelerra-5.1/cinelerra/affine.h index 339c8cbb..be74d572 100644 --- a/cinelerra-5.1/cinelerra/affine.h +++ b/cinelerra-5.1/cinelerra/affine.h @@ -94,6 +94,14 @@ public: // This removes some of the extremely faint artifacts in the trig rotation. void rotate(VFrame *output, VFrame *input, float angle); void set_matrix(AffineMatrix *matrix); +// set_matrix: +// in x1,y1 - x2,y1 out x1,y1 - x2,y2 clockwise +// | | | | +// x1,y2 - x2,y2 x4,y4 - x3,y3 +// + void set_matrix( double in_x1, double in_y1, double in_x2, double in_y2, + double out_x1, double out_y1, double out_x2, double out_y2, + double out_x3, double out_y3, double out_x4, double out_y4); // Set the viewport to transform. The transform is based on the input viewport. // The output viewport clips the transformed output. void set_in_viewport(int x, int y, int w, int h); diff --git a/cinelerra-5.1/cinelerra/dragcheckbox.C b/cinelerra-5.1/cinelerra/dragcheckbox.C index 559851eb..4db99b91 100644 --- a/cinelerra-5.1/cinelerra/dragcheckbox.C +++ b/cinelerra-5.1/cinelerra/dragcheckbox.C @@ -159,7 +159,9 @@ int DragCheckBox::grab_event(XEvent *event) fabs(drag_dy = cursor_y-y1) < r ) dragging = 8; else if( fabs(drag_dx = cursor_x-x1) < r && // x1,y1 fabs(drag_dy = cursor_y-y1) < r ) dragging = 9; + else return 0; + return 1; } int cur_x = cursor_x - drag_dx; int cur_y = cursor_y - drag_dy; diff --git a/cinelerra-5.1/cinelerra/gwindowgui.C b/cinelerra-5.1/cinelerra/gwindowgui.C index aaea761e..d7f639ed 100644 --- a/cinelerra-5.1/cinelerra/gwindowgui.C +++ b/cinelerra-5.1/cinelerra/gwindowgui.C @@ -71,7 +71,7 @@ const char *GWindowGUI::other_text[NON_AUTOMATION_TOTAL] = N_("Assets"), N_("Titles"), N_("Transitions"), - N_("Plugin Autos") + N_("Plugin Keyframes") }; const char *GWindowGUI::auto_text[AUTOMATION_TOTAL] = diff --git a/cinelerra-5.1/cinelerra/mwindow.C b/cinelerra-5.1/cinelerra/mwindow.C index 9731b4bb..202a7687 100644 --- a/cinelerra-5.1/cinelerra/mwindow.C +++ b/cinelerra-5.1/cinelerra/mwindow.C @@ -2263,32 +2263,38 @@ void MWindow::test_plugins(EDL *new_edl, char *path) } -void MWindow::init_shm() +void MWindow::init_shm(const char *pfn, int64_t min) { + int64_t result = 0; // Fix shared memory - FILE *fd = fopen("/proc/sys/kernel/shmmax", "w"); - if(fd) { - fprintf(fd, "0x7fffffff"); + FILE *fd = fopen(pfn, "r"); + if( fd ) { + fscanf(fd, "%jd", &result); fclose(fd); + if( result >= min ) return; } - fd = 0; - fd = fopen("/proc/sys/kernel/shmmax", "r"); - if(!fd) { - MainError::show_error("MWindow::init_shm: couldn't open /proc/sys/kernel/shmmax for reading.\n"); + fd = fopen(pfn, "w"); + if( fd ) { + fprintf(fd, "0x%jx", min); + fclose(fd); + } + + fd = fopen(pfn, "r"); + if( !fd ) { + eprintf(_("MWindow::init_shm: couldn't open %s for reading.\n"), pfn); return; } - int64_t result = 0; fscanf(fd, "%jd", &result); fclose(fd); - fd = 0; - if(result < 0x7fffffff) { - eprintf(_("MWindow::init_shm: /proc/sys/kernel/shmmax is %p.\n" + if( result < min ) { + eprintf(_("MWindow::init_shm: %s is %p.\n" "you probably need to be root, or:\n" - "as root, run: echo 0x7fffffff > /proc/sys/kernel/shmmax\n" + "as root, run: echo 0x%jx > %s\n" "before trying to start cinelerra.\n" - "It should be at least 0x7fffffff for Cinelerra.\n"), (void *)result); + "It should be at least 0x%jx for Cinelerra.\n"), + pfn, (void *)result, min, pfn, min); } } @@ -2473,7 +2479,8 @@ void MWindow::create_objects(int want_gui, &MWindowGUI::keyboard_listener); hide_splash(); - init_shm(); + init_shm("/proc/sys/kernel/shmmax", 0x7fffffff); + init_shm("/proc/sys/kernel/shmmni", 0x4000); if(debug) PRINT_TRACE BC_WindowBase::get_resources()->vframe_shm = 1; diff --git a/cinelerra-5.1/cinelerra/mwindow.h b/cinelerra-5.1/cinelerra/mwindow.h index 895314a2..24210e41 100644 --- a/cinelerra-5.1/cinelerra/mwindow.h +++ b/cinelerra-5.1/cinelerra/mwindow.h @@ -635,7 +635,7 @@ public: Mutex *brender_lock; // Initialize shared memory - void init_shm(); + void init_shm(const char *pfn, int64_t min); // Initialize channel DB's for playback void init_channeldb(); diff --git a/cinelerra-5.1/cinelerra/viewmenu.C b/cinelerra-5.1/cinelerra/viewmenu.C index b3d33d69..2478136e 100644 --- a/cinelerra-5.1/cinelerra/viewmenu.C +++ b/cinelerra-5.1/cinelerra/viewmenu.C @@ -138,7 +138,7 @@ void ShowAutomation::update_toggle() PluginAutomation::PluginAutomation(MWindow *mwindow, const char *hotkey) - : BC_MenuItem(_("Plugin Autos"), hotkey, hotkey[0]) + : BC_MenuItem(_("Plugin Keyframes"), hotkey, hotkey[0]) { this->mwindow = mwindow; } diff --git a/cinelerra-5.1/configure.ac b/cinelerra-5.1/configure.ac index 9159b78d..9e98a90f 100644 --- a/cinelerra-5.1/configure.ac +++ b/cinelerra-5.1/configure.ac @@ -314,7 +314,7 @@ PKG_3RD([x264],[auto], [ . ]) PKG_3RD([x265],[auto], - [x265_v2.6], + [x265_2.7], [ libx265.a ], [ . source ]) diff --git a/cinelerra-5.1/guicast/bcfilebox.C b/cinelerra-5.1/guicast/bcfilebox.C index 44671608..8ffafb81 100644 --- a/cinelerra-5.1/guicast/bcfilebox.C +++ b/cinelerra-5.1/guicast/bcfilebox.C @@ -561,10 +561,11 @@ void BC_FileBox::create_objects() if(!want_directory) { filter_list.append(new BC_ListBoxItem("*")); - filter_list.append(new BC_ListBoxItem("[*.mkv]")); + filter_list.append(new BC_ListBoxItem("[*.mkv][*.webm]")); filter_list.append(new BC_ListBoxItem("[*.mp4]")); filter_list.append(new BC_ListBoxItem("[*.mp2][*.mp3][*.wav]")); filter_list.append(new BC_ListBoxItem("[*.avi][*.mpg][*.m2v][*.m1v][*.mov]")); + filter_list.append(new BC_ListBoxItem("[*.jpg][*.png][*.gif][*.tiff]")); filter_list.append(new BC_ListBoxItem("*.xml")); fs->set_filter(get_resources()->filebox_filter); } diff --git a/cinelerra-5.1/plugins/findobj/findobj.C b/cinelerra-5.1/plugins/findobj/findobj.C index bc9f4f20..7909170a 100644 --- a/cinelerra-5.1/plugins/findobj/findobj.C +++ b/cinelerra-5.1/plugins/findobj/findobj.C @@ -38,6 +38,11 @@ REGISTER_PLUGIN(FindObjMain) FindObjConfig::FindObjConfig() +{ + reset(); +} + +void FindObjConfig::reset() { algorithm = NO_ALGORITHM; use_flann = 1; @@ -45,11 +50,16 @@ FindObjConfig::FindObjConfig() draw_scene_border = 0; replace_object = 0; draw_object_border = 0; + draw_replace_border = 0; object_x = 50; object_y = 50; object_w = 100; object_h = 100; drag_object = 0; scene_x = 50; scene_y = 50; scene_w = 100; scene_h = 100; + drag_replace = 0; + replace_x = 50; replace_y = 50; + replace_w = 100; replace_h = 100; + replace_dx = 0; replace_dy = 0; drag_scene = 0; scene_layer = 0; object_layer = 1; @@ -59,7 +69,6 @@ FindObjConfig::FindObjConfig() void FindObjConfig::boundaries() { - bclamp(drag_object, 0, 1); bclamp(drag_scene, 0, 1); bclamp(object_x, 0, 100); bclamp(object_y, 0, 100); bclamp(object_w, 0, 100); bclamp(object_h, 0, 100); bclamp(scene_x, 0, 100); bclamp(scene_y, 0, 100); @@ -79,12 +88,17 @@ int FindObjConfig::equivalent(FindObjConfig &that) draw_scene_border == that.draw_scene_border && replace_object == that.replace_object && draw_object_border == that.draw_object_border && + draw_replace_border == that.draw_replace_border && object_x == that.object_x && object_y == that.object_y && object_w == that.object_w && object_h == that.object_h && drag_object == that.drag_object && scene_x == that.scene_x && scene_y == that.scene_y && scene_w == that.scene_w && scene_h == that.scene_h && drag_scene == that.drag_scene && + replace_x == that.replace_x && replace_y == that.replace_y && + replace_w == that.replace_w && replace_h == that.replace_h && + replace_dx == that.replace_dx && replace_dy == that.replace_dy && + drag_replace == that.drag_replace && object_layer == that.object_layer && replace_layer == that.replace_layer && scene_layer == that.scene_layer && @@ -100,12 +114,17 @@ void FindObjConfig::copy_from(FindObjConfig &that) draw_scene_border = that.draw_scene_border; replace_object = that.replace_object; draw_object_border = that.draw_object_border; + draw_replace_border = that.draw_replace_border; object_x = that.object_x; object_y = that.object_y; object_w = that.object_w; object_h = that.object_h; drag_object = that.drag_object; scene_x = that.scene_x; scene_y = that.scene_y; scene_w = that.scene_w; scene_h = that.scene_h; drag_scene = that.drag_scene; + replace_x = that.replace_x; replace_y = that.replace_y; + replace_w = that.replace_w; replace_h = that.replace_h; + replace_dx = that.replace_dx; replace_dy = that.replace_dy; + drag_replace = that.drag_replace; object_layer = that.object_layer; replace_layer = that.replace_layer; scene_layer = that.scene_layer; @@ -168,34 +187,7 @@ void FindObjMain::update_gui() if( !load_configuration() ) return; FindObjWindow *window = (FindObjWindow*)thread->window; window->lock_window("FindObjMain::update_gui"); - window->algorithm->set_text(FindObjAlgorithm::to_text(config.algorithm)); - window->use_flann->update(config.use_flann); - window->drag_object->update(config.drag_object); - window->object_x->update(config.object_x); - window->object_x_text->update((float)config.object_x); - window->object_y->update(config.object_y); - window->object_y_text->update((float)config.object_y); - window->object_w->update(config.object_w); - window->object_w_text->update((float)config.object_w); - window->object_h->update(config.object_h); - window->object_h_text->update((float)config.object_h); - window->drag_scene->update(config.drag_scene); - window->scene_x->update(config.scene_x); - window->scene_x_text->update((float)config.scene_x); - window->scene_y->update(config.scene_y); - window->scene_y_text->update((float)config.scene_y); - window->scene_w->update(config.scene_w); - window->scene_w_text->update((float)config.scene_w); - window->scene_h->update(config.scene_h); - window->scene_h_text->update((float)config.scene_h); - window->draw_keypoints->update(config.draw_keypoints); - window->draw_scene_border->update(config.draw_scene_border); - window->replace_object->update(config.replace_object); - window->draw_object_border->update(config.draw_object_border); - window->object_layer->update( (int64_t)config.object_layer); - window->replace_layer->update( (int64_t)config.replace_layer); - window->scene_layer->update( (int64_t)config.scene_layer); - window->blend->update( (int64_t)config.blend); + window->update_gui(); window->flush(); window->unlock_window(); } @@ -219,10 +211,18 @@ void FindObjMain::save_data(KeyFrame *keyframe) output.tag.set_property("SCENE_Y", config.scene_y); output.tag.set_property("SCENE_W", config.scene_w); output.tag.set_property("SCENE_H", config.scene_h); + output.tag.set_property("DRAG_REPLACE", config.drag_replace); + output.tag.set_property("REPLACE_X", config.replace_x); + output.tag.set_property("REPLACE_Y", config.replace_y); + output.tag.set_property("REPLACE_W", config.replace_w); + output.tag.set_property("REPLACE_H", config.replace_h); + output.tag.set_property("REPLACE_DX", config.replace_dx); + output.tag.set_property("REPLACE_DY", config.replace_dy); output.tag.set_property("DRAW_KEYPOINTS", config.draw_keypoints); output.tag.set_property("DRAW_SCENE_BORDER", config.draw_scene_border); output.tag.set_property("REPLACE_OBJECT", config.replace_object); output.tag.set_property("DRAW_OBJECT_BORDER", config.draw_object_border); + output.tag.set_property("DRAW_REPLACE_BORDER", config.draw_replace_border); output.tag.set_property("OBJECT_LAYER", config.object_layer); output.tag.set_property("REPLACE_LAYER", config.replace_layer); output.tag.set_property("SCENE_LAYER", config.scene_layer); @@ -256,10 +256,18 @@ void FindObjMain::read_data(KeyFrame *keyframe) config.scene_w = input.tag.get_property("SCENE_W", config.scene_w); config.scene_h = input.tag.get_property("SCENE_H", config.scene_h); config.drag_scene = input.tag.get_property("DRAG_SCENE", config.drag_scene); + config.replace_x = input.tag.get_property("REPLACE_X", config.replace_x); + config.replace_y = input.tag.get_property("REPLACE_Y", config.replace_y); + config.replace_w = input.tag.get_property("REPLACE_W", config.replace_w); + config.replace_h = input.tag.get_property("REPLACE_H", config.replace_h); + config.replace_dx = input.tag.get_property("REPLACE_DX", config.replace_dx); + config.replace_dy = input.tag.get_property("REPLACE_DY", config.replace_dy); + config.drag_replace = input.tag.get_property("DRAG_REPLACE", config.drag_replace); config.draw_keypoints = input.tag.get_property("DRAW_KEYPOINTS", config.draw_keypoints); config.draw_scene_border = input.tag.get_property("DRAW_SCENE_BORDER", config.draw_scene_border); config.replace_object = input.tag.get_property("REPLACE_OBJECT", config.replace_object); config.draw_object_border = input.tag.get_property("DRAW_OBJECT_BORDER", config.draw_object_border); + config.draw_replace_border = input.tag.get_property("DRAW_REPLACE_BORDER", config.draw_replace_border); config.object_layer = input.tag.get_property("OBJECT_LAYER", config.object_layer); config.replace_layer = input.tag.get_property("REPLACE_LAYER", config.replace_layer); config.scene_layer = input.tag.get_property("SCENE_LAYER", config.scene_layer); @@ -474,10 +482,12 @@ void FindObjMain::process_match() src.push_back(Point2f(obj_x1,obj_y2)); perspectiveTransform(src, dst, H); - border_x1 = dst[0].x + scene_x; border_y1 = dst[0].y + scene_y; - border_x2 = dst[1].x + scene_x; border_y2 = dst[1].y + scene_y; - border_x3 = dst[2].x + scene_x; border_y3 = dst[2].y + scene_y; - border_x4 = dst[3].x + scene_x; border_y4 = dst[3].y + scene_y; + float dx = scene_x + replace_dx; + float dy = scene_y + replace_dy; + border_x1 = dst[0].x + dx; border_y1 = dst[0].y + dy; + border_x2 = dst[1].x + dx; border_y2 = dst[1].y + dy; + border_x3 = dst[2].x + dx; border_y3 = dst[2].y + dy; + border_x4 = dst[3].x + dx; border_y4 = dst[3].y + dy; //printf("src %f,%f %f,%f %f,%f %f,%f\n", // src[0].x,src[0].y, src[1].x,src[1].y, src[2].x,src[2].y, src[3].x,src[3].y); //printf("dst %f,%f %f,%f %f,%f %f,%f\n", @@ -532,6 +542,22 @@ int FindObjMain::process_buffer(VFrame **frame, int64_t start_position, double f bclamp(cfg_x2, 0, w); scene_w = cfg_x2 - cfg_x1; bclamp(cfg_y2, 0, h); scene_h = cfg_y2 - cfg_y1; + cfg_w = (int)(w * config.replace_w / 100.); + cfg_h = (int)(h * config.replace_h / 100.); + cfg_x1 = (int)(w * config.replace_x / 100. - cfg_w / 2); + cfg_y1 = (int)(h * config.replace_y / 100. - cfg_h / 2); + cfg_x2 = cfg_x1 + cfg_w; + cfg_y2 = cfg_y1 + cfg_h; + bclamp(cfg_x1, 0, w); replace_x = cfg_x1; + bclamp(cfg_y1, 0, h); replace_y = cfg_y1; + bclamp(cfg_x2, 0, w); replace_w = cfg_x2 - cfg_x1; + bclamp(cfg_y2, 0, h); replace_h = cfg_y2 - cfg_y1; + + int cfg_dx = (int)(w * config.replace_dx / 100.); + int cfg_dy = (int)(h * config.replace_dy / 100.); + bclamp(cfg_dx, -h, h); replace_dx = cfg_dx; + bclamp(cfg_dy, -w, w); replace_dy = cfg_dy; + // Read in the input frames for( int i = 0; i < PluginClient::get_total_buffers(); i++ ) { read_frame(frame[i], i, start_position, frame_rate, 0); @@ -563,16 +589,18 @@ int FindObjMain::process_buffer(VFrame **frame, int64_t start_position, double f affine = new AffineEngine(cpus1, cpus1); if( !overlayer ) overlayer = new OverlayFrame(cpus1); - - VFrame *temp = new_temp(scene->get_w(), scene->get_h(), scene->get_color_model()); + VFrame *temp = new_temp(w, h, scene->get_color_model()); temp->clear_frame(); - float sx = 100./w, sy = 100./h; - float x1 = sx * obj_x1, y1 = sy * obj_y1; - float x2 = sx * obj_x2, y2 = sy * obj_y2; - float x3 = sx * obj_x3, y3 = sy * obj_y3; - float x4 = sx * obj_x4, y4 = sy * obj_y4; - affine->process(temp, replace, 0, AffineEngine::PERSPECTIVE, - x1,y1, x2,y2, x3,y3, x4,y4, 1); + affine->set_in_viewport(replace_x, replace_y, replace_w, replace_h); + int x1 = obj_x1, x2 = obj_x2, x3 = obj_x3, x4 = obj_x4; + int y1 = obj_y1, y2 = obj_y2, y3 = obj_y3, y4 = obj_y4; + bclamp(x1, 0, w); bclamp(x2, 0, w); bclamp(x3, 0, w); bclamp(x4, 0, w); + bclamp(y1, 0, h); bclamp(y2, 0, h); bclamp(y3, 0, h); bclamp(y4, 0, h); + affine->set_matrix( + replace_x, replace_y, replace_x+replace_w, replace_y+replace_h, + x1,y1, x2,y2, x3,y3, x4,y4); + affine->process(temp, replace, 0, + AffineEngine::TRANSFORM, 0,0, 100,0, 100,100, 0,100, 1); overlayer->overlay(scene, temp, 0,0, w,h, 0,0, w,h, 1, TRANSFER_NORMAL, NEAREST_NEIGHBOR); @@ -588,6 +616,11 @@ int FindObjMain::process_buffer(VFrame **frame, int64_t start_position, double f scene->set_pixel_color(YELLOW); scene->set_stiple(ss*3); draw_rect(scene, object_x, object_y, object_x+object_w, object_y+object_h); } + if( config.draw_replace_border ) { + int wh = (w+h)>>8, ss = 1; while( wh>>=1 ) ss<<=1; + scene->set_pixel_color(GREEN); scene->set_stiple(ss*3); + draw_rect(scene, replace_x, replace_y, replace_x+replace_w, replace_y+replace_h); + } if( config.draw_keypoints ) { scene->set_pixel_color(RED); scene->set_stiple(0); for( int i=0,n=scn_keypts.size(); iset_pixel_color(YELLOW); DragCheckBox::draw_boundary(scene, object_x, object_y, object_w, object_h); } + if( config.drag_replace ) { + scene->set_pixel_color(GREEN); + DragCheckBox::draw_boundary(scene, replace_x, replace_y, replace_w, replace_h); + } } scene->set_pixel_color(BLACK); diff --git a/cinelerra-5.1/plugins/findobj/findobj.h b/cinelerra-5.1/plugins/findobj/findobj.h index 4a29b3c9..03b4fa88 100644 --- a/cinelerra-5.1/plugins/findobj/findobj.h +++ b/cinelerra-5.1/plugins/findobj/findobj.h @@ -95,6 +95,7 @@ class FindObjConfig public: FindObjConfig(); + void reset(); int equivalent(FindObjConfig &that); void copy_from(FindObjConfig &that); void interpolate(FindObjConfig &prev, FindObjConfig &next, @@ -102,14 +103,17 @@ public: void boundaries(); int algorithm, use_flann; - int drag_object, drag_scene; + int drag_object, drag_scene, drag_replace; float object_x, object_y, object_w, object_h; float scene_x, scene_y, scene_w, scene_h; + float replace_x, replace_y, replace_w, replace_h; + float replace_dx, replace_dy; int draw_keypoints; int draw_scene_border; int replace_object; int draw_object_border; + int draw_replace_border; int object_layer; int replace_layer; @@ -160,6 +164,8 @@ public: int object_x, object_y, object_w, object_h; int scene_x, scene_y, scene_w, scene_h; + int replace_x, replace_y, replace_w, replace_h; + int replace_dx, replace_dy; int w, h; int object_layer; diff --git a/cinelerra-5.1/plugins/findobj/findobjwindow.C b/cinelerra-5.1/plugins/findobj/findobjwindow.C index 1c11878c..5ccec768 100644 --- a/cinelerra-5.1/plugins/findobj/findobjwindow.C +++ b/cinelerra-5.1/plugins/findobj/findobjwindow.C @@ -32,7 +32,7 @@ FindObjWindow::FindObjWindow(FindObjMain *plugin) - : PluginClientWindow(plugin, 340, 660, 340, 660, 0) + : PluginClientWindow(plugin, 500, 660, 500, 660, 0) { this->plugin = plugin; } @@ -43,7 +43,7 @@ FindObjWindow::~FindObjWindow() void FindObjWindow::create_objects() { - int x = 10, y = 10, x1 = x, x2 = get_w()/2; + int x = 10, y = 10, x1 = x, x2 = get_w()*1/3, x3 = get_w()*2/3; plugin->load_configuration(); BC_Title *title; @@ -51,6 +51,7 @@ void FindObjWindow::create_objects() add_subwindow(algorithm = new FindObjAlgorithm(plugin, this, x1 + title->get_w() + 10, y)); algorithm->create_objects(); + add_subwindow(reset = new FindObjReset(plugin, this, get_w() - 15, y)); y += algorithm->get_h() + plugin->get_theme()->widget_border; add_subwindow(use_flann = new FindObjUseFlann(plugin, this, x, y)); @@ -182,15 +183,89 @@ void FindObjWindow::create_objects() object_h->center_text = object_h_text; object_h_text->center = object_h; - y += 40 + 15; + y = y1; + add_subwindow(replace_object = new FindObjReplace(plugin, this, + x3, y - title->get_h() - 15)); + + add_subwindow(title = new BC_Title(x3, y + 10, _("Replace X:"))); + drag_w = trk_w * plugin->config.replace_w / 100.; + drag_h = trk_h * plugin->config.replace_h / 100.; + ctr_x = trk_w * plugin->config.replace_x / 100., + ctr_y = trk_h * plugin->config.replace_y / 100.; + drag_x = ctr_x - drag_w/2; drag_y = ctr_y - drag_h/2; + drag_replace = new FindObjDragReplace(plugin, this, x3+title->get_w()+10, y+5, + drag_x, drag_y, drag_w, drag_h); + add_subwindow(drag_replace); + drag_replace->create_objects(); + y += title->get_h() + 15; + + add_subwindow(replace_x = new FindObjScanFloat(plugin, this, + x3, y, &plugin->config.replace_x)); + add_subwindow(replace_x_text = new FindObjScanFloatText(plugin, this, + x3 + replace_x->get_w() + 10, y + 10, &plugin->config.replace_x)); + replace_x->center_text = replace_x_text; + replace_x_text->center = replace_x; + + y += 40; + add_subwindow(title = new BC_Title(x3, y + 10, _("Replace Y:"))); + y += title->get_h() + 15; + add_subwindow(replace_y = new FindObjScanFloat(plugin, this, + x3, y, &plugin->config.replace_y)); + add_subwindow(replace_y_text = new FindObjScanFloatText(plugin, this, + x3 + replace_y->get_w() + 10, y + 10, &plugin->config.replace_y)); + replace_y->center_text = replace_y_text; + replace_y_text->center = replace_y; + + y += 40; + add_subwindow(new BC_Title(x3, y + 10, _("Replace W:"))); + y += title->get_h() + 15; + add_subwindow(replace_w = new FindObjScanFloat(plugin, this, + x3, y, &plugin->config.replace_w)); + add_subwindow(replace_w_text = new FindObjScanFloatText(plugin, this, + x3 + replace_w->get_w() + 10, y + 10, &plugin->config.replace_w)); + replace_w->center_text = replace_w_text; + replace_w_text->center = replace_w; + + y += 40; + add_subwindow(title = new BC_Title(x3, y + 10, _("Replace H:"))); + y += title->get_h() + 15; + add_subwindow(replace_h = new FindObjScanFloat(plugin, this, + x3, y, &plugin->config.replace_h)); + add_subwindow(replace_h_text = new FindObjScanFloatText(plugin, this, + x3 + replace_h->get_w() + 10, y + 10, + &plugin->config.replace_h)); + replace_h->center_text = replace_h_text; + replace_h_text->center = replace_h; + + y += 40; int y2 = y; + add_subwindow(title = new BC_Title(x3, y + 10, _("Replace DX:"))); + y += title->get_h() + 15; + add_subwindow(replace_dx = new FindObjScanFloat(plugin, this, + x3, y, &plugin->config.replace_dx, -100.f, 100.f)); + add_subwindow(replace_dx_text = new FindObjScanFloatText(plugin, this, + x3 + replace_dx->get_w() + 10, y + 10, &plugin->config.replace_dx)); + replace_dx->center_text = replace_dx_text; + replace_dx_text->center = replace_dx; + + y += 40; + add_subwindow(title = new BC_Title(x3, y + 10, _("Replace DY:"))); + y += title->get_h() + 15; + add_subwindow(replace_dy = new FindObjScanFloat(plugin, this, + x3, y, &plugin->config.replace_dy, -100.f, 100.f)); + add_subwindow(replace_dy_text = new FindObjScanFloatText(plugin, this, + x3 + replace_dy->get_w() + 10, y + 10, &plugin->config.replace_dy)); + replace_dy->center_text = replace_dy_text; + replace_dy_text->center = replace_dy; + + y = y2 + 15; add_subwindow(draw_keypoints = new FindObjDrawKeypoints(plugin, this, x, y)); y += draw_keypoints->get_h() + plugin->get_theme()->widget_border; - add_subwindow(replace_object = new FindObjReplace(plugin, this, x, y)); - y += replace_object->get_h() + plugin->get_theme()->widget_border; add_subwindow(draw_scene_border = new FindObjDrawSceneBorder(plugin, this, x, y)); y += draw_scene_border->get_h() + plugin->get_theme()->widget_border; add_subwindow(draw_object_border = new FindObjDrawObjectBorder(plugin, this, x, y)); y += draw_object_border->get_h() + plugin->get_theme()->widget_border; + add_subwindow(draw_replace_border = new FindObjDrawReplaceBorder(plugin, this, x, y)); + y += draw_object_border->get_h() + plugin->get_theme()->widget_border; add_subwindow(title = new BC_Title(x, y + 10, _("Object blend amount:"))); add_subwindow(blend = new FindObjBlend(plugin, @@ -201,6 +276,24 @@ void FindObjWindow::create_objects() show_window(1); } +FindObjReset::FindObjReset(FindObjMain *plugin, FindObjWindow *gui, int x, int y) + : BC_GenericButton(x - BC_GenericButton::calculate_w(gui, _("Reset")), y, _("Reset")) +{ + this->plugin = plugin; + this->gui = gui; +} + +int FindObjReset::handle_event() +{ + plugin->config.reset(); + gui->drag_scene->drag_deactivate(); + gui->drag_object->drag_deactivate(); + gui->drag_replace->drag_deactivate(); + gui->update_gui(); + plugin->send_configure_change(); + return 1; +} + void FindObjWindow::update_drag() { Track *track = drag_scene->get_drag_track(); @@ -215,12 +308,65 @@ void FindObjWindow::update_drag() drag_object->drag_h = trk_h * plugin->config.object_h/100.; drag_object->drag_x = trk_w * plugin->config.object_x/100. - drag_object->drag_w/2; drag_object->drag_y = trk_h * plugin->config.object_y/100. - drag_object->drag_h/2; - plugin->send_configure_change(); + track = drag_replace->get_drag_track(); + trk_w = track->track_w, trk_h = track->track_h; + drag_replace->drag_w = trk_w * plugin->config.replace_w/100.; + drag_replace->drag_h = trk_h * plugin->config.replace_h/100.; + drag_replace->drag_x = trk_w * plugin->config.replace_x/100. - drag_replace->drag_w/2; + drag_replace->drag_y = trk_h * plugin->config.replace_y/100. - drag_replace->drag_h/2; +} + +void FindObjWindow::update_gui() +{ + update_drag(); + FindObjConfig &conf = plugin->config; + algorithm->update(conf.algorithm); + use_flann->update(conf.use_flann); + drag_object->update(conf.drag_object); + object_x->update(conf.object_x); + object_x_text->update((float)conf.object_x); + object_y->update(conf.object_y); + object_y_text->update((float)conf.object_y); + object_w->update(conf.object_w); + object_w_text->update((float)conf.object_w); + object_h->update(conf.object_h); + object_h_text->update((float)conf.object_h); + drag_scene->update(conf.drag_scene); + scene_x->update(conf.scene_x); + scene_x_text->update((float)conf.scene_x); + scene_y->update(conf.scene_y); + scene_y_text->update((float)conf.scene_y); + scene_w->update(conf.scene_w); + scene_w_text->update((float)conf.scene_w); + scene_h->update(conf.scene_h); + scene_h_text->update((float)conf.scene_h); + drag_replace->update(conf.drag_replace); + replace_x->update(conf.replace_x); + replace_x_text->update((float)conf.replace_x); + replace_y->update(conf.replace_y); + replace_y_text->update((float)conf.replace_y); + replace_w->update(conf.replace_w); + replace_w_text->update((float)conf.replace_w); + replace_h->update(conf.replace_h); + replace_h_text->update((float)conf.replace_h); + replace_dx->update(conf.replace_dx); + replace_dx_text->update((float)conf.replace_dx); + replace_dx->update(conf.replace_dx); + replace_dx_text->update((float)conf.replace_dx); + draw_keypoints->update(conf.draw_keypoints); + draw_scene_border->update(conf.draw_scene_border); + replace_object->update(conf.replace_object); + draw_object_border->update(conf.draw_object_border); + draw_replace_border->update(conf.draw_replace_border); + object_layer->update( (int64_t)conf.object_layer); + replace_layer->update( (int64_t)conf.replace_layer); + scene_layer->update( (int64_t)conf.scene_layer); + blend->update( (int64_t)conf.blend); } FindObjScanFloat::FindObjScanFloat(FindObjMain *plugin, FindObjWindow *gui, - int x, int y, float *value) - : BC_FPot(x, y, *value, (float)0, (float)100) + int x, int y, float *value, float min, float max) + : BC_FPot(x, y, *value, min, max) { this->plugin = plugin; this->gui = gui; @@ -234,6 +380,7 @@ int FindObjScanFloat::handle_event() *value = get_value(); center_text->update(*value); gui->update_drag(); + plugin->send_configure_change(); return 1; } @@ -261,6 +408,7 @@ int FindObjScanFloatText::handle_event() *value = atof(get_text()); center->update(*value); gui->update_drag(); + plugin->send_configure_change(); return 1; } @@ -288,6 +436,28 @@ FindObjDrawObjectBorder::FindObjDrawObjectBorder(FindObjMain *plugin, FindObjWin this->plugin = plugin; } +int FindObjDrawObjectBorder::handle_event() +{ + plugin->config.draw_object_border = get_value(); + plugin->send_configure_change(); + return 1; +} + +FindObjDrawReplaceBorder::FindObjDrawReplaceBorder(FindObjMain *plugin, FindObjWindow *gui, + int x, int y) + : BC_CheckBox(x, y, plugin->config.draw_replace_border, _("Draw replace border")) +{ + this->gui = gui; + this->plugin = plugin; +} + +int FindObjDrawReplaceBorder::handle_event() +{ + plugin->config.draw_replace_border = get_value(); + plugin->send_configure_change(); + return 1; +} + FindObjDrawKeypoints::FindObjDrawKeypoints(FindObjMain *plugin, FindObjWindow *gui, int x, int y) @@ -321,14 +491,6 @@ int FindObjReplace::handle_event() } -int FindObjDrawObjectBorder::handle_event() -{ - plugin->config.draw_object_border = get_value(); - plugin->send_configure_change(); - return 1; -} - - FindObjDragScene::FindObjDragScene(FindObjMain *plugin, FindObjWindow *gui, int x, int y, float drag_x, float drag_y, float drag_w, float drag_h) : DragCheckBox(plugin->server->mwindow, x, y, _("Drag"), &plugin->config.drag_scene, @@ -361,7 +523,6 @@ void FindObjDragScene::update_gui() Track *track = get_drag_track(); int trk_w = track->track_w, trk_h = track->track_h; float ctr_x = drag_x + drag_w/2, ctr_y = drag_y + drag_h/2; -printf("scene=%f,%f wxh=%fx%f ctr=%f,%f\n",drag_x,drag_y,drag_w,drag_h, ctr_x,ctr_y); gui->scene_x->update( plugin->config.scene_x = 100. * ctr_x / trk_w ); gui->scene_y->update( plugin->config.scene_y = 100. * ctr_y / trk_h ); gui->scene_w->update( plugin->config.scene_w = 100. * drag_w / trk_w ); @@ -401,7 +562,6 @@ void FindObjDragObject::update_gui() Track *track = get_drag_track(); int trk_w = track->track_w, trk_h = track->track_h; float ctr_x = drag_x + drag_w/2, ctr_y = drag_y + drag_h/2; -printf("object %f,%f %fx%f ctr %f,%f\n", drag_x,drag_y,drag_w,drag_h,ctr_x,ctr_y); gui->object_x->update( plugin->config.object_x = 100. * ctr_x / trk_w ); gui->object_y->update( plugin->config.object_y = 100. * ctr_y / trk_h ); gui->object_w->update( plugin->config.object_w = 100. * drag_w / trk_w ); @@ -409,6 +569,45 @@ printf("object %f,%f %fx%f ctr %f,%f\n", drag_x,drag_y,drag_w,drag_h,ctr_x,ct plugin->send_configure_change(); } +FindObjDragReplace::FindObjDragReplace(FindObjMain *plugin, FindObjWindow *gui, int x, int y, + float drag_x, float drag_y, float drag_w, float drag_h) + : DragCheckBox(plugin->server->mwindow, x, y, _("Drag"), &plugin->config.drag_replace, + drag_x, drag_y, drag_w, drag_h) +{ + this->plugin = plugin; + this->gui = gui; +} + +FindObjDragReplace::~FindObjDragReplace() +{ +} + +int FindObjDragReplace::handle_event() +{ + int ret = DragCheckBox::handle_event(); + plugin->send_configure_change(); + return ret; +} +Track *FindObjDragReplace::get_drag_track() +{ + return plugin->server->plugin->track; +} +int64_t FindObjDragReplace::get_drag_position() +{ + return plugin->get_source_position(); +} +void FindObjDragReplace::update_gui() +{ + Track *track = get_drag_track(); + int trk_w = track->track_w, trk_h = track->track_h; + float ctr_x = drag_x + drag_w/2, ctr_y = drag_y + drag_h/2; + gui->replace_x->update( plugin->config.replace_x = 100. * ctr_x / trk_w ); + gui->replace_y->update( plugin->config.replace_y = 100. * ctr_y / trk_h ); + gui->replace_w->update( plugin->config.replace_w = 100. * drag_w / trk_w ); + gui->replace_h->update( plugin->config.replace_h = 100. * drag_h / trk_h ); + plugin->send_configure_change(); +} + FindObjAlgorithm::FindObjAlgorithm(FindObjMain *plugin, FindObjWindow *gui, int x, int y) @@ -465,6 +664,11 @@ int FindObjAlgorithm::from_text(char *text) return NO_ALGORITHM; } +void FindObjAlgorithm::update(int mode) +{ + set_text(to_text(mode)); +} + char* FindObjAlgorithm::to_text(int mode) { switch( mode ) { diff --git a/cinelerra-5.1/plugins/findobj/findobjwindow.h b/cinelerra-5.1/plugins/findobj/findobjwindow.h index 3c2aa634..2bc48117 100644 --- a/cinelerra-5.1/plugins/findobj/findobjwindow.h +++ b/cinelerra-5.1/plugins/findobj/findobjwindow.h @@ -27,6 +27,7 @@ #include "findobj.inc" #include "guicast.h" +class FindObjReset; class FindObjLayer; class FindObjScanFloat; class FindObjScanFloatText; @@ -34,12 +35,23 @@ class FindObjDrawSceneBorder; class FindObjDrawKeypoints; class FindObjReplace; class FindObjDrawObjectBorder; +class FindObjDrawReplaceBorder; class FindObjDragObject; class FindObjDragScene; +class FindObjDragReplace; class FindObjAlgorithm; class FindObjBlend; class FindObjWindow; +class FindObjReset : public BC_GenericButton +{ +public: + FindObjReset(FindObjMain *plugin, FindObjWindow *gui, int x, int y); + int handle_event(); + FindObjMain *plugin; + FindObjWindow *gui; +}; + class FindObjLayer : public BC_TumbleTextBox { public: @@ -55,7 +67,8 @@ public: class FindObjScanFloat : public BC_FPot { public: - FindObjScanFloat(FindObjMain *plugin, FindObjWindow *gui, int x, int y, float *value); + FindObjScanFloat(FindObjMain *plugin, FindObjWindow *gui, int x, int y, + float *value, float min=0., float max=100.); int handle_event(); void update(float v); FindObjMain *plugin; @@ -94,6 +107,15 @@ public: FindObjWindow *gui; }; +class FindObjDrawReplaceBorder : public BC_CheckBox +{ +public: + FindObjDrawReplaceBorder(FindObjMain *plugin, FindObjWindow *gui, int x, int y); + int handle_event(); + FindObjMain *plugin; + FindObjWindow *gui; +}; + class FindObjDrawKeypoints : public BC_CheckBox { public: @@ -144,12 +166,29 @@ public: FindObjWindow *gui; }; +class FindObjDragReplace : public DragCheckBox +{ +public: + FindObjDragReplace(FindObjMain *plugin, FindObjWindow *gui, int x, int y, + float drag_x, float drag_y, float drag_w, float drag_h); + ~FindObjDragReplace(); + + int handle_event(); + Track *get_drag_track(); + int64_t get_drag_position(); + void update_gui(); + + FindObjMain *plugin; + FindObjWindow *gui; +}; + class FindObjAlgorithm : public BC_PopupMenu { public: FindObjAlgorithm(FindObjMain *plugin, FindObjWindow *gui, int x, int y); int handle_event(); void create_objects(); + void update(int mode); static int calculate_w(FindObjWindow *gui); static int from_text(char *text); static char* to_text(int mode); @@ -182,19 +221,27 @@ public: ~FindObjWindow(); void create_objects(); void update_drag(); + void update_gui(); + FindObjReset *reset; FindObjAlgorithm *algorithm; FindObjUseFlann *use_flann; FindObjScanFloat *object_x, *object_y, *object_w, *object_h; FindObjScanFloatText *object_x_text, *object_y_text, *object_w_text, *object_h_text; FindObjScanFloat *scene_x, *scene_y, *scene_w, *scene_h; FindObjScanFloatText *scene_x_text, *scene_y_text, *scene_w_text, *scene_h_text; + FindObjScanFloat *replace_x, *replace_y, *replace_w, *replace_h; + FindObjScanFloatText *replace_x_text, *replace_y_text, *replace_w_text, *replace_h_text; + FindObjScanFloat *replace_dx, *replace_dy; + FindObjScanFloatText *replace_dx_text, *replace_dy_text; FindObjDrawKeypoints *draw_keypoints; FindObjDrawSceneBorder *draw_scene_border; FindObjReplace *replace_object; FindObjDrawObjectBorder *draw_object_border; + FindObjDrawReplaceBorder *draw_replace_border; FindObjDragObject *drag_object; FindObjDragScene *drag_scene; + FindObjDragReplace *drag_replace; FindObjLayer *object_layer; FindObjLayer *scene_layer; FindObjLayer *replace_layer; diff --git a/cinelerra-5.1/plugins/flowobj/flowobj.h b/cinelerra-5.1/plugins/flowobj/flowobj.h index 3e13fa97..091e6617 100644 --- a/cinelerra-5.1/plugins/flowobj/flowobj.h +++ b/cinelerra-5.1/plugins/flowobj/flowobj.h @@ -29,6 +29,9 @@ #include "opencv2/calib3d.hpp" #include "opencv2/video/video.hpp" +#include "opencv2/core/types_c.h" +#include + #include using namespace std; diff --git a/cinelerra-5.1/plugins/moveobj/moveobj.h b/cinelerra-5.1/plugins/moveobj/moveobj.h index 4a9214b1..8db73fba 100644 --- a/cinelerra-5.1/plugins/moveobj/moveobj.h +++ b/cinelerra-5.1/plugins/moveobj/moveobj.h @@ -28,6 +28,9 @@ #include "opencv2/calib3d.hpp" #include "opencv2/video/video.hpp" +#include "opencv2/core/types_c.h" +#include + #include using namespace std; diff --git a/cinelerra-5.1/plugins/svg/svg.C b/cinelerra-5.1/plugins/svg/svg.C index 96288bae..9b6007f5 100644 --- a/cinelerra-5.1/plugins/svg/svg.C +++ b/cinelerra-5.1/plugins/svg/svg.C @@ -181,7 +181,7 @@ int SvgMain::process_realtime(VFrame *input, VFrame *output) strcpy(last_svg_file, config.svg_file); int64_t last_ms_time = config.ms_time; need_reconfigure = load_configuration(); - if( last_dpi != config.dpi ) + if( !ofrm || last_dpi != config.dpi ) need_export = 1; if( strcmp(last_svg_file, config.svg_file) || last_ms_time != config.ms_time ) diff --git a/cinelerra-5.1/thirdparty/src/x265_2.7.tar.xz b/cinelerra-5.1/thirdparty/src/x265_2.7.tar.xz new file mode 100644 index 00000000..471711bc Binary files /dev/null and b/cinelerra-5.1/thirdparty/src/x265_2.7.tar.xz differ diff --git a/cinelerra-5.1/thirdparty/src/x265_v2.6.tar.xz b/cinelerra-5.1/thirdparty/src/x265_v2.6.tar.xz deleted file mode 100644 index cc16d1b1..00000000 Binary files a/cinelerra-5.1/thirdparty/src/x265_v2.6.tar.xz and /dev/null differ