X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Frenderengine.C;h=3c73709af7d1c57db02d7edd5e11bedeb4f40fd2;hb=d079f6253a75cc8cfedbab636ad0bc7f5dc9c5f5;hp=6ad6629c00719f9bce155cff2a680e768ee3d34d;hpb=ed1cab1d6cbde6129bbd09b9609f7bba03ab610f;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/cinelerra/renderengine.C b/cinelerra-5.1/cinelerra/renderengine.C index 6ad6629c..3c73709a 100644 --- a/cinelerra-5.1/cinelerra/renderengine.C +++ b/cinelerra-5.1/cinelerra/renderengine.C @@ -27,6 +27,7 @@ #include "condition.h" #include "edl.h" #include "edlsession.h" +#include "meterhistory.h" #include "mutex.h" #include "mwindow.h" #include "playbackengine.h" @@ -66,12 +67,7 @@ RenderEngine::RenderEngine(PlaybackEngine *playback_engine, audio_cache = 0; video_cache = 0; - if(playback_engine && playback_engine->mwindow) - mwindow = playback_engine->mwindow; - else - mwindow = 0; - show_tc = 0; - + mwindow = !playback_engine ? 0 : playback_engine->mwindow; input_lock = new Condition(1, "RenderEngine::input_lock"); start_lock = new Condition(1, "RenderEngine::start_lock"); @@ -91,10 +87,11 @@ RenderEngine::~RenderEngine() delete input_lock; delete start_lock; delete output_lock; + delete render_active; delete interrupt_lock; delete first_frame_lock; delete config; - edl->Garbage::remove_user(); + if( edl ) edl->Garbage::remove_user(); } EDL* RenderEngine::get_edl() @@ -194,11 +191,11 @@ void RenderEngine::get_duty() do_video = 0; //printf("RenderEngine::get_duty %d\n", __LINE__); - if(!command->single_frame() && - get_edl()->tracks->playable_audio_tracks() && - get_edl()->session->audio_channels) + if( get_edl()->tracks->playable_audio_tracks() && + get_edl()->session->audio_channels ) { - do_audio = 1; + do_audio = !command->single_frame() ? 1 : 0; + if( command->audio_toggle ) do_audio = !do_audio; } //printf("RenderEngine::get_duty %d\n", __LINE__); @@ -472,36 +469,31 @@ int RenderEngine::close_output() void RenderEngine::get_output_levels(double *levels, int64_t position) { - if(do_audio) - { - int history_entry = arender->get_history_number(arender->level_samples, - position); - for(int i = 0; i < MAXCHANNELS; i++) - { - if(arender->audio_out[i]) - levels[i] = arender->level_history[i][history_entry]; + if( do_audio ) { + MeterHistory *meter_history = arender->meter_history; + int64_t tolerance = 4*arender->meter_render_fragment; + int pos = meter_history->get_nearest(position, tolerance); + for( int i=0; iaudio_out[i] ) continue; + levels[i] = meter_history->get_peak(i, pos); } } } void RenderEngine::get_module_levels(ArrayList *module_levels, int64_t position) { - if(do_audio) - { - for(int i = 0; i < arender->total_modules; i++) - { -//printf("RenderEngine::get_module_levels %p %p\n", ((AModule*)arender->modules[i]), ((AModule*)arender->modules[i])->level_samples); - int history_entry = arender->get_history_number(((AModule*)arender->modules[i])->level_samples, position); - - module_levels->append(((AModule*)arender->modules[i])->level_history[history_entry]); + if( do_audio ) { + int64_t tolerance = 4*arender->meter_render_fragment; + for( int i=0; itotal_modules; ++i ) { + AModule *amodule = (AModule *)arender->modules[i]; + MeterHistory *meter_history = amodule->meter_history; + int pos = meter_history->get_nearest(position, tolerance); + module_levels->append(meter_history->get_peak(0, pos)); } } } - - - void RenderEngine::run() { render_active->lock("RenderEngine::run"); @@ -524,7 +516,7 @@ void RenderEngine::run() // Fix the tracking position if(playback_engine) { - if(command->command == CURRENT_FRAME) + if(command->command == CURRENT_FRAME || command->command == LAST_FRAME) { //printf("RenderEngine::run 4.1 %d\n", playback_engine->tracking_position); playback_engine->tracking_position = command->playbackstart; @@ -548,6 +540,12 @@ void RenderEngine::run() } } + if( playback_engine->is_playing_back && command->displacement ) { + double position = playback_engine->tracking_position - + 1./command->get_edl()->session->frame_rate; + playback_engine->tracking_position = position >= 0 ? position : 0; + } + if(!interrupted) playback_engine->command->command = STOP; playback_engine->stop_tracking();