fix min speed value 0.005, fix canvas lock hang, fix reset_caches crashing on vicon...
authorGood Guy <good1.2guy@gmail.com>
Mon, 15 Jun 2020 01:32:30 +0000 (19:32 -0600)
committerGood Guy <good1.2guy@gmail.com>
Mon, 15 Jun 2020 01:32:30 +0000 (19:32 -0600)
12 files changed:
cinelerra-5.1/cinelerra/aautomation.C
cinelerra-5.1/cinelerra/automation.h
cinelerra-5.1/cinelerra/automation.inc
cinelerra-5.1/cinelerra/ffmpeg.C
cinelerra-5.1/cinelerra/floatauto.C
cinelerra-5.1/cinelerra/floatautos.C
cinelerra-5.1/cinelerra/floatautos.h
cinelerra-5.1/cinelerra/localsession.C
cinelerra-5.1/cinelerra/mainmenu.C
cinelerra-5.1/cinelerra/mwindow.C
cinelerra-5.1/cinelerra/trackcanvas.C
cinelerra-5.1/cinelerra/vautomation.C

index 3b58cad65914515034410c0b2a08ee86822dc5a1..69c29a477fc3f0e739f3b04876cf0198ea2d7bb5 100644 (file)
@@ -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();
index 615a9d55197f3b19cda11d376bb4803c4d6f1e28..e25b6376c9d1d26720c57d50d405029a32f4b0ae 100644 (file)
                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
index f573c3ecce2d48b64a8c2dc4cfd2860de972676e..31f58a663016158b04d187f74e74a286e8fadf80 100644 (file)
@@ -87,4 +87,6 @@ enum
        AUTOMATION_TYPE_PAN
 };
 
+#define SPEED_MIN 0.005
+
 #endif
index 493be6abeace4e55e9eac4177964649a63c6fc2e..499974f0e201ac30f3937dc90125d554d746d47c 100644 (file)
@@ -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;
index 8e3e63682af1a56e43d3d474bb3f8076d9909041..d575c38e9d846aa2c507145582600c0da821a556 100644 (file)
@@ -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);
index 95dcace9ce6d97288a6357a7e93512ec7a825eb6..ca8dc6bf2f95e42f31d101ffb85b7b654daa1cd4 100644 (file)
@@ -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()
index 0e7fa195f4ceb597d989b1af449faa2455f94c53..f53564d4052d0b0c9d3c4944bc98e48b3919341c 100644 (file)
@@ -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; }
 };
 
 
index 7e1f50eaeb030eede38dd7bff30822f6e2d6d66d..c8cd9041a8019711706d96e4f8418870b757e92b 100644 (file)
@@ -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);
                }
        }
 
index f1b980cb83eb6123b0ff96df5d603a8d7007ff8f..94c884206b3ac4e6c826546792f0d66734545760 100644 (file)
@@ -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;
 }
index d6b756163672804ac4797bcedf45ad2befe3104b..73df71401e603fe569df21ebde0bac0dd3630c5b 100644 (file)
@@ -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; i<clips_total; ++i ) {
                EDL *clip = session->drag_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,
index fc7283c9be31f76ba88e6dafe8a5b4178788ba07..0e42ed89109de1d18108197e4d2877d4f711f46b 100644 (file)
@@ -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; x<x2; ++x ) {
 // Interpolate value between frames
                X_TO_FLOATLINE(x)
@@ -2876,6 +2878,8 @@ int TrackCanvas::test_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;
        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;
index 0197fa4df2c00c767566361b1ccee627634f62c4..97322f3708d1769358fb7c133698e6db54bfe504 100644 (file)
@@ -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();