From: Good Guy Date: Tue, 10 Aug 2021 23:22:15 +0000 (-0600) Subject: Andrew contribution to add preference method for Fast/Slow speed X-Git-Tag: 2021-08~6 X-Git-Url: https://cinelerra-gg.org/git/?a=commitdiff_plain;h=e9cdcb62fbd9794a368f11e7808c6ddf83fbd467;p=goodguy%2Fcinelerra.git Andrew contribution to add preference method for Fast/Slow speed --- diff --git a/cinelerra-5.1/cinelerra/amodule.C b/cinelerra-5.1/cinelerra/amodule.C index d8fb4396..f8d2e789 100644 --- a/cinelerra-5.1/cinelerra/amodule.C +++ b/cinelerra-5.1/cinelerra/amodule.C @@ -283,7 +283,7 @@ int AModule::import_samples(AEdit *edit, int command = direction == PLAY_REVERSE ? NORMAL_REWIND : NORMAL_FWD; if( !nested_command ) - nested_command = new TransportCommand; + nested_command = new TransportCommand(get_preferences()); nested_command->command = command; nested_command->get_edl()->copy_all(nested_edl); nested_command->change_type = CHANGE_ALL; diff --git a/cinelerra-5.1/cinelerra/assetpopup.C b/cinelerra-5.1/cinelerra/assetpopup.C index bbdf172f..66b3361a 100644 --- a/cinelerra-5.1/cinelerra/assetpopup.C +++ b/cinelerra-5.1/cinelerra/assetpopup.C @@ -949,7 +949,7 @@ int SnapshotMenuItem::handle_event() processors > 1 ? 2 : 1, 0); VFrame ***frames = file.get_video_buffer(); VFrame *frame = frames[0][0]; - TransportCommand command; + TransportCommand command(preferences); //command.command = audio_tracks ? NORMAL_FWD : CURRENT_FRAME; command.command = CURRENT_FRAME; command.get_edl()->copy_all(edl); diff --git a/cinelerra-5.1/cinelerra/awindowgui.C b/cinelerra-5.1/cinelerra/awindowgui.C index 67c75918..be782977 100644 --- a/cinelerra-5.1/cinelerra/awindowgui.C +++ b/cinelerra-5.1/cinelerra/awindowgui.C @@ -882,7 +882,7 @@ void AssetPicon::reset() void AssetPicon::open_render_engine(EDL *edl, int is_audio) { - TransportCommand command; + TransportCommand command(mwindow->preferences); command.command = is_audio ? NORMAL_FWD : CURRENT_FRAME; command.get_edl()->copy_all(edl); command.change_type = CHANGE_ALL; diff --git a/cinelerra-5.1/cinelerra/batchrender.C b/cinelerra-5.1/cinelerra/batchrender.C index ace9e562..b657e0f0 100644 --- a/cinelerra-5.1/cinelerra/batchrender.C +++ b/cinelerra-5.1/cinelerra/batchrender.C @@ -542,7 +542,7 @@ void BatchRenderThread::calculate_dest_paths(ArrayList *paths, PackageDispatcher *packages = new PackageDispatcher; // Load EDL - TransportCommand *command = new TransportCommand; + TransportCommand *command = new TransportCommand(preferences); FileXML *file = new FileXML; file->read_from_file(job->edl_path); diff --git a/cinelerra-5.1/cinelerra/fileref.C b/cinelerra-5.1/cinelerra/fileref.C index a60b3f3e..094c44ec 100644 --- a/cinelerra-5.1/cinelerra/fileref.C +++ b/cinelerra-5.1/cinelerra/fileref.C @@ -96,7 +96,7 @@ int FileREF::open_file(int rd, int wr) asset->sample_rate = ref->get_sample_rate(); asset->audio_length = asset->audio_data ? ref->get_audio_samples() : 0; strcpy(asset->acodec, "REF"); - command = new TransportCommand(); + command = new TransportCommand(file->preferences); command->reset(); command->get_edl()->copy_all(ref); command->command = NORMAL_FWD; diff --git a/cinelerra-5.1/cinelerra/indexfile.C b/cinelerra-5.1/cinelerra/indexfile.C index 0337d0c2..977ad1cb 100644 --- a/cinelerra-5.1/cinelerra/indexfile.C +++ b/cinelerra-5.1/cinelerra/indexfile.C @@ -350,7 +350,7 @@ int IndexFile::open_source() } else { - TransportCommand command; + TransportCommand command(mwindow->preferences); command.command = NORMAL_FWD; command.get_edl()->copy_all((EDL*)indexable); command.change_type = CHANGE_ALL; diff --git a/cinelerra-5.1/cinelerra/mixersalign.C b/cinelerra-5.1/cinelerra/mixersalign.C index 6e9abcc6..bd4116f3 100644 --- a/cinelerra-5.1/cinelerra/mixersalign.C +++ b/cinelerra-5.1/cinelerra/mixersalign.C @@ -1011,7 +1011,7 @@ void MixersAlign::apply_undo(int no) MixersAlignARender::MixersAlignARender(MWindow *mwindow, EDL *edl) : RenderEngine(0, mwindow->preferences, 0, 0) { - TransportCommand command; + TransportCommand command(mwindow->preferences); command.command = NORMAL_FWD; command.get_edl()->copy_all(edl); command.change_type = CHANGE_ALL; diff --git a/cinelerra-5.1/cinelerra/packagerenderer.C b/cinelerra-5.1/cinelerra/packagerenderer.C index 1c86af68..49aaf98a 100644 --- a/cinelerra-5.1/cinelerra/packagerenderer.C +++ b/cinelerra-5.1/cinelerra/packagerenderer.C @@ -137,7 +137,7 @@ int PackageRenderer::initialize(MWindow *mwindow, //printf("PackageRenderer::initialize %d\n", preferences->processors); - command = new TransportCommand; + command = new TransportCommand(preferences); command->command = NORMAL_FWD; command->get_edl()->copy_all(edl); command->change_type = CHANGE_ALL; diff --git a/cinelerra-5.1/cinelerra/playbackengine.C b/cinelerra-5.1/cinelerra/playbackengine.C index 3b2b9ed4..815e506f 100644 --- a/cinelerra-5.1/cinelerra/playbackengine.C +++ b/cinelerra-5.1/cinelerra/playbackengine.C @@ -56,14 +56,14 @@ PlaybackEngine::PlaybackEngine(MWindow *mwindow, Canvas *output) tracking_active = 0; audio_cache = 0; video_cache = 0; - command = new TransportCommand(); + command = new TransportCommand(mwindow->preferences); command->command = STOP; - next_command = new TransportCommand(); + next_command = new TransportCommand(mwindow->preferences); next_command->change_type = CHANGE_ALL; - stop_command = new TransportCommand(); + stop_command = new TransportCommand(mwindow->preferences); stop_command->command = STOP; stop_command->realtime = 1; - sent_command = new TransportCommand(); + sent_command = new TransportCommand(mwindow->preferences); sent_command->command = -1; send_active = 0; tracking_lock = new Mutex("PlaybackEngine::tracking_lock"); diff --git a/cinelerra-5.1/cinelerra/preferences.C b/cinelerra-5.1/cinelerra/preferences.C index f4716a72..2b8d84bd 100644 --- a/cinelerra-5.1/cinelerra/preferences.C +++ b/cinelerra-5.1/cinelerra/preferences.C @@ -128,6 +128,9 @@ Preferences::Preferences() android_remote = 0; android_port = 23432; strcpy(android_pin, "cinelerra"); + + fast_speed = 2.0; + slow_speed = 0.5; memset(channel_positions, 0, sizeof(channel_positions)); int channels = 0; @@ -201,6 +204,10 @@ void Preferences::copy_from(Preferences *that) android_remote = that->android_remote; android_port = that->android_port; strcpy(android_pin, that->android_pin); + + slow_speed = that->slow_speed; + fast_speed = that->fast_speed; + this->shbtn_prefs.remove_all_objects(); for( int i=0; ishbtn_prefs.size(); ++i ) this->shbtn_prefs.append(new ShBtnPref(*that->shbtn_prefs[i])); @@ -332,6 +339,8 @@ int Preferences::load_defaults(BC_Hash *defaults) scan_commercials = defaults->get("SCAN_COMMERCIALS", scan_commercials); android_remote = defaults->get("ANDROID_REMOTE", android_remote); android_port = defaults->get("ANDROID_PORT", android_port); + fast_speed = defaults->get("FAST_SPEED", fast_speed); + slow_speed = defaults->get("SLOW_SPEED", slow_speed); defaults->get("ANDROID_PIN", android_pin); defaults->get("INDEX_DIRECTORY", index_directory); index_size = defaults->get("INDEX_SIZE", index_size); @@ -495,7 +504,8 @@ int Preferences::save_defaults(BC_Hash *defaults) defaults->update("ANDROID_REMOTE", android_remote); defaults->update("ANDROID_PIN", android_pin); defaults->update("ANDROID_PORT", android_port); - + defaults->update("SLOW_SPEED", slow_speed); + defaults->update("FAST_SPEED", fast_speed); defaults->update("CACHE_SIZE", cache_size); defaults->update("CACHE_TRANSITIONS", cache_transitions); defaults->update("INDEX_DIRECTORY", index_directory); diff --git a/cinelerra-5.1/cinelerra/preferences.h b/cinelerra-5.1/cinelerra/preferences.h index 7dd3871c..4f743975 100644 --- a/cinelerra-5.1/cinelerra/preferences.h +++ b/cinelerra-5.1/cinelerra/preferences.h @@ -193,6 +193,9 @@ public: ArrayList shbtn_prefs; // file open probe order ArrayList file_probes; +// fast/slow forward and backward speeds, default 2.0/0.5 + float fast_speed; + float slow_speed; // ====================================== Plugin Set ============================== char plugin_dir[BCTEXTLEN]; diff --git a/cinelerra-5.1/cinelerra/proxy.C b/cinelerra-5.1/cinelerra/proxy.C index 64897df9..0012fd19 100644 --- a/cinelerra-5.1/cinelerra/proxy.C +++ b/cinelerra-5.1/cinelerra/proxy.C @@ -741,7 +741,7 @@ void ProxyClient::process_package(LoadPackage *ptr) result = 1; } else { - TransportCommand command; + TransportCommand command(preferences); command.command = CURRENT_FRAME; command.get_edl()->copy_all((EDL *)orig); command.change_type = CHANGE_ALL; diff --git a/cinelerra-5.1/cinelerra/render.C b/cinelerra-5.1/cinelerra/render.C index a7456717..77e7ce79 100644 --- a/cinelerra-5.1/cinelerra/render.C +++ b/cinelerra-5.1/cinelerra/render.C @@ -684,7 +684,7 @@ void RenderThread::render_single(int test_overwrite, Asset *asset, EDL *edl, render->result = 0; // Create rendering command - TransportCommand *command = new TransportCommand; + TransportCommand *command = new TransportCommand(mwindow->preferences); command->command = NORMAL_FWD; command->get_edl()->copy_all(edl); command->change_type = CHANGE_ALL; diff --git a/cinelerra-5.1/cinelerra/renderengine.C b/cinelerra-5.1/cinelerra/renderengine.C index 0d8b0634..7e7a52d7 100644 --- a/cinelerra-5.1/cinelerra/renderengine.C +++ b/cinelerra-5.1/cinelerra/renderengine.C @@ -62,7 +62,7 @@ RenderEngine::RenderEngine(PlaybackEngine *playback_engine, do_video = 0; interrupted = 0; this->preferences = new Preferences; - this->command = new TransportCommand; + this->command = new TransportCommand(preferences); this->preferences->copy_from(preferences); edl = 0; diff --git a/cinelerra-5.1/cinelerra/resourcepixmap.C b/cinelerra-5.1/cinelerra/resourcepixmap.C index 991b85d4..1406dd2d 100644 --- a/cinelerra-5.1/cinelerra/resourcepixmap.C +++ b/cinelerra-5.1/cinelerra/resourcepixmap.C @@ -472,7 +472,7 @@ void ResourcePixmap::draw_audio_source(TrackCanvas *canvas, Edit *edit, int x, i } if( !mwindow->gui->render_engine ) { - TransportCommand command; + TransportCommand command(mwindow->preferences); command.command = NORMAL_FWD; command.get_edl()->copy_all(edit->nested_edl); command.change_type = CHANGE_ALL; diff --git a/cinelerra-5.1/cinelerra/resourcethread.C b/cinelerra-5.1/cinelerra/resourcethread.C index fca02199..18b8dc81 100644 --- a/cinelerra-5.1/cinelerra/resourcethread.C +++ b/cinelerra-5.1/cinelerra/resourcethread.C @@ -327,7 +327,7 @@ void ResourceThreadBase::open_render_engine(EDL *nested_edl, if( !render_engine ) { MWindow *mwindow = resource_thread->mwindow; - TransportCommand command; + TransportCommand command(mwindow->preferences); command.command = do_audio ? NORMAL_FWD : CURRENT_FRAME; command.get_edl()->copy_all(nested_edl); command.change_type = CHANGE_ALL; diff --git a/cinelerra-5.1/cinelerra/trackcanvas.C b/cinelerra-5.1/cinelerra/trackcanvas.C index d15f9a37..d39ce455 100644 --- a/cinelerra-5.1/cinelerra/trackcanvas.C +++ b/cinelerra-5.1/cinelerra/trackcanvas.C @@ -4601,7 +4601,7 @@ int TrackCanvas::render_handle_frame(EDL *edl, int64_t pos, int mode) case 0: { VFrame vlt(edl->get_w(), edl->get_h(), edl->session->color_model); VFrame vrt(edl->get_w(), edl->get_h(), edl->session->color_model); - TransportCommand command; + TransportCommand command(mwindow->preferences); command.command = CURRENT_FRAME; command.get_edl()->copy_all((EDL *)edl); command.change_type = CHANGE_ALL; diff --git a/cinelerra-5.1/cinelerra/transportque.C b/cinelerra-5.1/cinelerra/transportque.C index a8c1fb92..5048beaf 100644 --- a/cinelerra-5.1/cinelerra/transportque.C +++ b/cinelerra-5.1/cinelerra/transportque.C @@ -26,10 +26,12 @@ #include "edlsession.h" #include "localsession.h" #include "playbackengine.h" +#include "preferences.h" #include "tracks.h" #include "transportque.h" -TransportCommand::TransportCommand() + +TransportCommand::TransportCommand(Preferences *preferences) { // In rendering we want a master EDL so settings don't get clobbered // in the middle of a job. @@ -37,6 +39,7 @@ TransportCommand::TransportCommand() edl->create_objects(); command = 0; change_type = 0; + this->preferences = preferences; reset(); } @@ -134,10 +137,16 @@ int TransportCommand::get_direction(int command) float TransportCommand::get_speed(int command, float speed) { +// fast = 2.0, slow = 0.5 +// float my_fast_speed = 2.0; +// float my_slow_speed = 0.5; +float my_fast_speed = preferences->fast_speed; +float my_slow_speed = preferences->slow_speed; + switch(command) { case SLOW_FWD: case SLOW_REWIND: - return speed ? speed : 0.5; + return speed ? speed : my_slow_speed; case NORMAL_FWD: case NORMAL_REWIND: @@ -149,7 +158,7 @@ float TransportCommand::get_speed(int command, float speed) case FAST_FWD: case FAST_REWIND: - return speed ? speed : 2.; + return speed ? speed : my_fast_speed; } return 0.; diff --git a/cinelerra-5.1/cinelerra/transportque.h b/cinelerra-5.1/cinelerra/transportque.h index 2594594f..fcfc1703 100644 --- a/cinelerra-5.1/cinelerra/transportque.h +++ b/cinelerra-5.1/cinelerra/transportque.h @@ -26,12 +26,13 @@ #include "condition.inc" #include "edl.inc" #include "playbackengine.inc" +#include "preferences.inc" #include "transportque.inc" class TransportCommand { public: - TransportCommand(); + TransportCommand(Preferences *preferences); ~TransportCommand(); void reset(); @@ -41,7 +42,7 @@ public: void set_playback_range(EDL *edl, int use_inout, int do_displacement); static int single_frame(int command); static int get_direction(int command); - static float get_speed(int command, float speed=0); + float get_speed(int command, float speed=0); // Adjust playback range with in/out points for rendering void playback_range_adjust_inout(); @@ -84,6 +85,7 @@ public: private: // Copied to render engines EDL *edl; + Preferences *preferences; }; #endif diff --git a/cinelerra-5.1/cinelerra/vmodule.C b/cinelerra-5.1/cinelerra/vmodule.C index e2a2f7f6..64521524 100644 --- a/cinelerra-5.1/cinelerra/vmodule.C +++ b/cinelerra-5.1/cinelerra/vmodule.C @@ -178,7 +178,7 @@ int VModule::import_frame(VFrame *output, VEdit *current_edit, nested_renderengine = 0; } if( !nested_command ) - nested_command = new TransportCommand; + nested_command = new TransportCommand(get_preferences()); nested_command->command = command; nested_command->get_edl()->copy_all(nested_edl); nested_command->change_type = CHANGE_ALL; diff --git a/cinelerra-5.1/cinelerra/vwindowgui.C b/cinelerra-5.1/cinelerra/vwindowgui.C index 196b2980..9b7f6ca8 100644 --- a/cinelerra-5.1/cinelerra/vwindowgui.C +++ b/cinelerra-5.1/cinelerra/vwindowgui.C @@ -97,7 +97,7 @@ VWindowGUI::~VWindowGUI() void VWindowGUI::draw_wave() { - TransportCommand command; + TransportCommand command(mwindow->preferences); command.command = NORMAL_FWD; command.get_edl()->copy_all(vwindow->get_edl()); command.change_type = CHANGE_ALL; diff --git a/cinelerra-5.1/plugins/titler/titler.C b/cinelerra-5.1/plugins/titler/titler.C index 95218e4c..06fb7938 100644 --- a/cinelerra-5.1/plugins/titler/titler.C +++ b/cinelerra-5.1/plugins/titler/titler.C @@ -1213,7 +1213,7 @@ Indexable *TitleMain::open_background(const char *filename) nested_edl->create_objects(); nested_edl->set_path(filename); nested_edl->load_xml(&xml_file, LOAD_ALL); - TransportCommand command; + TransportCommand command(server->preferences); //command.command = audio_tracks ? NORMAL_FWD : CURRENT_FRAME; command.command = CURRENT_FRAME; command.get_edl()->copy_all(nested_edl);