From f595c1e0de88f7ce15e5a2486fa90e150cdb0fc7 Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <randrianasulu@gmail.com>
Date: Mon, 12 Jul 2021 02:17:24 +0300
Subject: [PATCH] Add hidden fast/slow playback preference

---
 cinelerra-5.1/cinelerra/amodule.C         |  2 +-
 cinelerra-5.1/cinelerra/assetpopup.C      |  2 +-
 cinelerra-5.1/cinelerra/awindowgui.C      |  2 +-
 cinelerra-5.1/cinelerra/batchrender.C     |  2 +-
 cinelerra-5.1/cinelerra/exportedl.C       | 15 ++++++++++-----
 cinelerra-5.1/cinelerra/fileref.C         |  2 +-
 cinelerra-5.1/cinelerra/indexfile.C       |  2 +-
 cinelerra-5.1/cinelerra/mixersalign.C     |  2 +-
 cinelerra-5.1/cinelerra/packagerenderer.C |  2 +-
 cinelerra-5.1/cinelerra/playbackengine.C  |  8 ++++----
 cinelerra-5.1/cinelerra/preferences.C     | 15 +++++++++++++++
 cinelerra-5.1/cinelerra/preferences.h     |  4 ++++
 cinelerra-5.1/cinelerra/proxy.C           |  2 +-
 cinelerra-5.1/cinelerra/render.C          |  2 +-
 cinelerra-5.1/cinelerra/renderengine.C    |  2 +-
 cinelerra-5.1/cinelerra/resourcepixmap.C  |  2 +-
 cinelerra-5.1/cinelerra/resourcethread.C  |  2 +-
 cinelerra-5.1/cinelerra/trackcanvas.C     |  2 +-
 cinelerra-5.1/cinelerra/transportque.C    | 19 ++++++++++++++++---
 cinelerra-5.1/cinelerra/transportque.h    |  7 +++++--
 cinelerra-5.1/cinelerra/vmodule.C         |  2 +-
 cinelerra-5.1/cinelerra/vwindowgui.C      |  2 +-
 22 files changed, 70 insertions(+), 30 deletions(-)

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<char*> *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/exportedl.C b/cinelerra-5.1/cinelerra/exportedl.C
index d4d670eb..5b1d0bd5 100644
--- a/cinelerra-5.1/cinelerra/exportedl.C
+++ b/cinelerra-5.1/cinelerra/exportedl.C
@@ -192,9 +192,11 @@ void ExportEDLAsset::export_it()
 			char destinpoint[12];
 			char destoutpoint[12];
 			
-			char filename[1024];
-			if (edit->asset)
+			char filename[1024], asset_pathname[1024];
+			if (edit->asset) {
 			strcpy(filename,basename(edit->asset->path));
+			strcpy(asset_pathname, edit->asset->path);
+			}
 			
 			if(!edit->asset)
 			strcpy(reel_name,"BL  ");
@@ -220,8 +222,9 @@ void ExportEDLAsset::export_it()
 					fprintf(fh, " %s %s", last_sourceout, last_sourceout);
 					fprintf(fh, " %s %s", destinpoint, destinpoint);
 					fprintf(fh,"\n");
-					if(edit->asset)
+					if(edit->asset){
 					fprintf(fh,"* FROM CLIP NAME: %s\n", filename);
+					fprintf(fh,"* FROM FILE: %s\n", asset_pathname);}
 				} else
 				{
 					colnum --;
@@ -231,8 +234,9 @@ void ExportEDLAsset::export_it()
 				fprintf(fh, " %s %s", sourceinpoint, sourceoutpoint);
 				fprintf(fh, " %s %s", destinpoint, destoutpoint);
 				fprintf(fh,"\n");
-				if(edit->asset)
+				if(edit->asset) {
 				fprintf(fh,"* FROM CLIP NAME: %s\n", filename);
+				fprintf(fh,"* FROM FILE: %s\n", asset_pathname);}
 				last_dissolve = 1;
 			} else
 			{
@@ -241,8 +245,9 @@ void ExportEDLAsset::export_it()
 				fprintf(fh, " %s %s", sourceinpoint, sourceoutpoint);
 				fprintf(fh, " %s %s", destinpoint, destoutpoint);
 				fprintf(fh,"\n");
-				if(edit->asset)
+				if(edit->asset) {
 				fprintf(fh,"* FROM CLIP NAME: %s\n", filename);
+				fprintf(fh,"* FROM FILE: %s\n", asset_pathname);}
 				last_dissolve = 0;
 			}
 
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 6f4e57c9..c067e659 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,11 @@ 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; i<that->shbtn_prefs.size(); ++i )
 		this->shbtn_prefs.append(new ShBtnPref(*that->shbtn_prefs[i]));
@@ -330,6 +338,10 @@ 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);
@@ -490,6 +502,9 @@ 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);
diff --git a/cinelerra-5.1/cinelerra/preferences.h b/cinelerra-5.1/cinelerra/preferences.h
index e814f426..b9ef3d7c 100644
--- a/cinelerra-5.1/cinelerra/preferences.h
+++ b/cinelerra-5.1/cinelerra/preferences.h
@@ -191,6 +191,10 @@ public:
 	ArrayList<ShBtnPref *> shbtn_prefs;
 // file open probe order
 	ArrayList<ProbePref *> 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 0ee987e8..4403f6d0 100644
--- a/cinelerra-5.1/cinelerra/render.C
+++ b/cinelerra-5.1/cinelerra/render.C
@@ -685,7 +685,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..24b6d5a9 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();
 }
 
@@ -132,12 +135,22 @@ int TransportCommand::get_direction(int command)
 	return PLAY_FORWARD;
 }
 
+
+
 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 +162,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..f5e18d1c 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();
@@ -76,6 +77,7 @@ public:
 	int loop_play;
 // SLOW,FAST play speed
 	float speed;
+	
 
 	int single_frame() { return single_frame(command); }
 	int get_direction() { return get_direction(command); }
@@ -84,6 +86,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;
-- 
2.32.0

