From a6e4ede4b9a11b56b3aece044ff2a1546630ca38 Mon Sep 17 00:00:00 2001 From: Good Guy Date: Sun, 14 Jun 2020 19:32:30 -0600 Subject: [PATCH] fix min speed value 0.005, fix canvas lock hang, fix reset_caches crashing on vicon drawing --- cinelerra-5.1/cinelerra/aautomation.C | 1 + cinelerra-5.1/cinelerra/automation.h | 8 ++++---- cinelerra-5.1/cinelerra/automation.inc | 2 ++ cinelerra-5.1/cinelerra/ffmpeg.C | 7 ++++++- cinelerra-5.1/cinelerra/floatauto.C | 16 ++++++++++++++-- cinelerra-5.1/cinelerra/floatautos.C | 2 ++ cinelerra-5.1/cinelerra/floatautos.h | 4 ++++ cinelerra-5.1/cinelerra/localsession.C | 6 +++++- cinelerra-5.1/cinelerra/mainmenu.C | 2 -- cinelerra-5.1/cinelerra/mwindow.C | 7 +++++-- cinelerra-5.1/cinelerra/trackcanvas.C | 6 ++++++ cinelerra-5.1/cinelerra/vautomation.C | 1 + 12 files changed, 50 insertions(+), 12 deletions(-) diff --git a/cinelerra-5.1/cinelerra/aautomation.C b/cinelerra-5.1/cinelerra/aautomation.C index 3b58cad6..69c29a47 100644 --- a/cinelerra-5.1/cinelerra/aautomation.C +++ b/cinelerra-5.1/cinelerra/aautomation.C @@ -48,6 +48,7 @@ void AAutomation::create_objects() autos[AUTOMATION_SPEED] = new FloatAutos(edl, track, 1.0); autos[AUTOMATION_SPEED]->create_objects(); + ((FloatAutos*)autos[AUTOMATION_SPEED])->set_float_min(SPEED_MIN); autos[AUTOMATION_PAN] = new PanAutos(edl, track); autos[AUTOMATION_PAN]->create_objects(); diff --git a/cinelerra-5.1/cinelerra/automation.h b/cinelerra-5.1/cinelerra/automation.h index 615a9d55..e25b6376 100644 --- a/cinelerra-5.1/cinelerra/automation.h +++ b/cinelerra-5.1/cinelerra/automation.h @@ -45,14 +45,14 @@ CLAMP(value, 0, 100); \ if (autogrouptype == AUTOGROUPTYPE_ZOOM && value < 0) \ value = 0; \ - else if (autogrouptype == AUTOGROUPTYPE_SPEED && value < 0.001) \ - value = 0.001; + else if (autogrouptype == AUTOGROUPTYPE_SPEED && value < SPEED_MIN) \ + value = SPEED_MIN; #define AUTOMATIONVIEWCLAMPS(value, autogrouptype) \ if (autogrouptype == AUTOGROUPTYPE_ZOOM && value < 0) \ value = 0; \ - else if (autogrouptype == AUTOGROUPTYPE_SPEED && value < 0) \ - value = 0; + else if (autogrouptype == AUTOGROUPTYPE_SPEED && value < SPEED_MIN) \ + value = SPEED_MIN; class Automation diff --git a/cinelerra-5.1/cinelerra/automation.inc b/cinelerra-5.1/cinelerra/automation.inc index f573c3ec..31f58a66 100644 --- a/cinelerra-5.1/cinelerra/automation.inc +++ b/cinelerra-5.1/cinelerra/automation.inc @@ -87,4 +87,6 @@ enum AUTOMATION_TYPE_PAN }; +#define SPEED_MIN 0.005 + #endif diff --git a/cinelerra-5.1/cinelerra/ffmpeg.C b/cinelerra-5.1/cinelerra/ffmpeg.C index 493be6ab..499974f0 100644 --- a/cinelerra-5.1/cinelerra/ffmpeg.C +++ b/cinelerra-5.1/cinelerra/ffmpeg.C @@ -285,6 +285,7 @@ FFStream::FFStream(FFMPEG *ffmpeg, AVStream *st, int fidx) FFStream::~FFStream() { + frm_lock->lock("FFStream::~FFStream"); if( reading > 0 || writing > 0 ) avcodec_close(avctx); if( avctx ) avcodec_free_context(&avctx); if( fmt_ctx ) avformat_close_input(&fmt_ctx); @@ -295,6 +296,7 @@ FFStream::~FFStream() if( frame ) av_frame_free(&frame); if( fframe ) av_frame_free(&fframe); if( probe_frame ) av_frame_free(&probe_frame); + frm_lock->unlock(); delete frm_lock; if( stats_fp ) fclose(stats_fp); if( stats_in ) av_freep(&stats_in); @@ -491,7 +493,7 @@ int FFStream::decode(AVFrame *frame) } int ret = 0; int retries = MAX_RETRY; - + frm_lock->lock("FFStream::decode"); while( ret >= 0 && !flushed && --retries >= 0 ) { if( need_packet ) { if( (ret=read_packet()) < 0 ) break; @@ -514,6 +516,7 @@ int FFStream::decode(AVFrame *frame) flushed = st_eof(); } } + frm_lock->unlock(); if( retries < 0 ) { fprintf(stderr, "FFStream::decode: Retry limit\n"); @@ -726,6 +729,7 @@ int FFStream::seek(int64_t no, double rate) tstmp = av_rescale_q(tstmp, time_base, AV_TIME_BASE_Q); idx = -1; #endif + frm_lock->lock("FFStream::seek"); av_frame_free(&probe_frame); avcodec_flush_buffers(avctx); avformat_flush(fmt_ctx); @@ -772,6 +776,7 @@ int FFStream::seek(int64_t no, double rate) break; } } + frm_lock->unlock(); if( ret < 0 ) { printf("** seek fail %jd, %jd\n", pos, tstmp); seeked = need_packet = 0; diff --git a/cinelerra-5.1/cinelerra/floatauto.C b/cinelerra-5.1/cinelerra/floatauto.C index 8e3e6368..d575c38e 100644 --- a/cinelerra-5.1/cinelerra/floatauto.C +++ b/cinelerra-5.1/cinelerra/floatauto.C @@ -189,9 +189,13 @@ void FloatAuto::toggle_curve_mode() } -void FloatAuto::set_value(float newvalue) +void FloatAuto::set_value(float value) { - this->value=newvalue; + float float_min = ((FloatAutos*)autos)->float_min; + if( value < float_min ) value = float_min; + float float_max = ((FloatAutos*)autos)->float_max; + if( value > float_max ) value = float_max; + this->value = value; this->adjust_curves(); if(previous) ((FloatAuto*)previous)->adjust_curves(); if(next) ((FloatAuto*)next)->adjust_curves(); @@ -356,6 +360,10 @@ inline void FloatAuto::set_ctrl_positions(FloatAuto *prev, FloatAuto* next) void FloatAuto::adjust_to_new_coordinates(int64_t position, float value) // define new position and value in one step, do necessary re-adjustments { + float float_min = ((FloatAutos*)autos)->float_min; + if( value < float_min ) value = float_min; + float float_max = ((FloatAutos*)autos)->float_max; + if( value > float_max ) value = float_max; this->value = value; this->position = position; adjust_ctrl_positions(); @@ -415,6 +423,10 @@ void FloatAuto::copy(int64_t start, int64_t end, FileXML *file, int default_auto void FloatAuto::load(FileXML *file) { value = file->tag.get_property("VALUE", value); + float float_min = ((FloatAutos*)autos)->float_min; + if( value < float_min ) value = float_min; + float float_max = ((FloatAutos*)autos)->float_max; + if( value > float_max ) value = float_max; control_in_value = file->tag.get_property("CONTROL_IN_VALUE", control_in_value); control_out_value = file->tag.get_property("CONTROL_OUT_VALUE", control_out_value); curve_mode = (t_mode)file->tag.get_property("TANGENT_MODE", (int)FREE); diff --git a/cinelerra-5.1/cinelerra/floatautos.C b/cinelerra-5.1/cinelerra/floatautos.C index 95dcace9..ca8dc6bf 100644 --- a/cinelerra-5.1/cinelerra/floatautos.C +++ b/cinelerra-5.1/cinelerra/floatautos.C @@ -37,6 +37,8 @@ FloatAutos::FloatAutos(EDL *edl, { this->default_ = default_; type = AUTOMATION_TYPE_FLOAT; + float_min = -FLT_MAX; + float_max = FLT_MAX; } FloatAutos::~FloatAutos() diff --git a/cinelerra-5.1/cinelerra/floatautos.h b/cinelerra-5.1/cinelerra/floatautos.h index 0e7fa195..f53564d4 100644 --- a/cinelerra-5.1/cinelerra/floatautos.h +++ b/cinelerra-5.1/cinelerra/floatautos.h @@ -70,6 +70,10 @@ public: void dump(); Auto* new_auto(); float default_; + + float float_min, float_max; + void set_float_min(float mn) { float_min = mn; } + void set_float_max(float mx) { float_max = mx; } }; diff --git a/cinelerra-5.1/cinelerra/localsession.C b/cinelerra-5.1/cinelerra/localsession.C index 7e1f50ea..c8cd9041 100644 --- a/cinelerra-5.1/cinelerra/localsession.C +++ b/cinelerra-5.1/cinelerra/localsession.C @@ -86,7 +86,7 @@ LocalSession::LocalSession(EDL *edl) automation_maxs[AUTOGROUPTYPE_AUDIO_FADE] = 6; automation_mins[AUTOGROUPTYPE_VIDEO_FADE] = 0; automation_maxs[AUTOGROUPTYPE_VIDEO_FADE] = 100; - automation_mins[AUTOGROUPTYPE_SPEED] = 0.005; + automation_mins[AUTOGROUPTYPE_SPEED] = SPEED_MIN; automation_maxs[AUTOGROUPTYPE_SPEED] = 5.000; automation_mins[AUTOGROUPTYPE_INT255] = 0; automation_maxs[AUTOGROUPTYPE_INT255] = 255; @@ -296,7 +296,9 @@ void LocalSession::load_xml(FileXML *file, unsigned long load_flags) for (int i = 0; i < AUTOGROUPTYPE_COUNT; i++) { if (!Automation::autogrouptypes_fixedrange[i]) { automation_mins[i] = file->tag.get_property(xml_autogrouptypes_titlesmin[i],automation_mins[i]); + AUTOMATIONCLAMPS(automation_mins[i], i); automation_maxs[i] = file->tag.get_property(xml_autogrouptypes_titlesmax[i],automation_maxs[i]); + AUTOMATIONCLAMPS(automation_maxs[i], i); } } floatauto_type = file->tag.get_property("FLOATAUTO_TYPE", floatauto_type); @@ -361,7 +363,9 @@ int LocalSession::load_defaults(BC_Hash *defaults) for (int i = 0; i < AUTOGROUPTYPE_COUNT; i++) { if (!Automation::autogrouptypes_fixedrange[i]) { automation_mins[i] = defaults->get(xml_autogrouptypes_titlesmin[i], automation_mins[i]); + AUTOMATIONCLAMPS(automation_mins[i], i); automation_maxs[i] = defaults->get(xml_autogrouptypes_titlesmax[i], automation_maxs[i]); + AUTOMATIONCLAMPS(automation_maxs[i], i); } } diff --git a/cinelerra-5.1/cinelerra/mainmenu.C b/cinelerra-5.1/cinelerra/mainmenu.C index f1b980cb..94c88420 100644 --- a/cinelerra-5.1/cinelerra/mainmenu.C +++ b/cinelerra-5.1/cinelerra/mainmenu.C @@ -949,9 +949,7 @@ Clear::Clear(MWindow *mwindow) int Clear::handle_event() { if( mwindow->session->current_operation == NO_OPERATION ) { - mwindow->cwindow->gui->lock_window("Clear::handle_event"); mwindow->clear_entry(); - mwindow->cwindow->gui->unlock_window(); } return 1; } diff --git a/cinelerra-5.1/cinelerra/mwindow.C b/cinelerra-5.1/cinelerra/mwindow.C index d6b75616..73df7140 100644 --- a/cinelerra-5.1/cinelerra/mwindow.C +++ b/cinelerra-5.1/cinelerra/mwindow.C @@ -301,6 +301,7 @@ MWindow::~MWindow() gui->del_keyboard_listener( (int (BC_WindowBase::*)(BC_WindowBase *)) &MWindowGUI::keyboard_listener); + reset_caches(); #if 0 // release the hounds if( awindow && awindow->gui ) awindow->gui->close(0); @@ -329,7 +330,6 @@ MWindow::~MWindow() gui->close(0); join(); #endif - reset_caches(); dead_plugins->remove_all_objects(); // must delete theme before destroying plugindb // theme destructor will be deleted by delete_plugins @@ -3964,7 +3964,7 @@ void MWindow::clip_to_media() return; } undo_before(); - awindow->gui->stop_vicon_drawing(); + awindow->gui->close_view_popup(); int clips_total = session->drag_clips->total; for( int i=0; idrag_clips->values[i]; @@ -4441,6 +4441,7 @@ int MWindow::create_aspect_ratio(float &w, float &h, int width, int height) void MWindow::reset_caches() { + awindow->gui->close_view_popup(); frame_cache->remove_all(); wave_cache->remove_all(); audio_cache->remove_all(); @@ -4464,6 +4465,7 @@ void MWindow::reset_caches() void MWindow::remove_from_caches(Indexable *idxbl) { + awindow->gui->close_view_popup(); frame_cache->remove_item(idxbl); wave_cache->remove_item(idxbl); if( gui->render_engine && @@ -4497,6 +4499,7 @@ void MWindow::remove_from_caches(Indexable *idxbl) if( zwindow->zgui->playback_engine->video_cache ) zwindow->zgui->playback_engine->video_cache->delete_entry(asset); } + awindow->gui->start_vicon_drawing(); } void MWindow::remove_assets_from_project(int push_undo, int redraw, int delete_indexes, diff --git a/cinelerra-5.1/cinelerra/trackcanvas.C b/cinelerra-5.1/cinelerra/trackcanvas.C index fc7283c9..0e42ed89 100644 --- a/cinelerra-5.1/cinelerra/trackcanvas.C +++ b/cinelerra-5.1/cinelerra/trackcanvas.C @@ -2842,6 +2842,8 @@ void TrackCanvas::draw_floatline(int center_pixel, float automation_min = mwindow->edl->local_session->automation_mins[autogrouptype]; float automation_max = mwindow->edl->local_session->automation_maxs[autogrouptype]; float automation_range = automation_max - automation_min; + if( autogrouptype == AUTOGROUPTYPE_SPEED && automation_range < SPEED_MIN ) + automation_range = SPEED_MIN; for( int x=x1; xedl->local_session->automation_mins[autogrouptype]; float automation_max = mwindow->edl->local_session->automation_maxs[autogrouptype]; float automation_range = automation_max - automation_min; + if( autogrouptype == AUTOGROUPTYPE_SPEED && automation_range < SPEED_MIN ) + automation_range = SPEED_MIN; FloatAuto *previous1 = 0, *next1 = 0; X_TO_FLOATLINE(cursor_x); @@ -3124,6 +3128,8 @@ void TrackCanvas::calculate_auto_position(double *x, double *y, float automation_min = mwindow->edl->local_session->automation_mins[autogrouptype]; float automation_max = mwindow->edl->local_session->automation_maxs[autogrouptype]; float automation_range = automation_max - automation_min; + if( autogrouptype == AUTOGROUPTYPE_SPEED && automation_range < SPEED_MIN ) + automation_range = SPEED_MIN; FloatAuto *ptr = (FloatAuto*)current; *x = (double)(ptr->position - unit_start) / zoom_units; *y = ((ptr->get_value() - automation_min) / automation_range - 0.5) * -yscale; diff --git a/cinelerra-5.1/cinelerra/vautomation.C b/cinelerra-5.1/cinelerra/vautomation.C index 0197fa4d..97322f37 100644 --- a/cinelerra-5.1/cinelerra/vautomation.C +++ b/cinelerra-5.1/cinelerra/vautomation.C @@ -54,6 +54,7 @@ void VAutomation::create_objects() autos[AUTOMATION_SPEED] = new FloatAutos(edl, track, 1.); autos[AUTOMATION_SPEED]->create_objects(); + ((FloatAutos*)autos[AUTOMATION_SPEED])->set_float_min(SPEED_MIN); autos[AUTOMATION_MODE] = new IntAutos(edl, track, TRANSFER_NORMAL); autos[AUTOMATION_MODE]->create_objects(); -- 2.26.2