X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Frenderengine.C;h=177f33504d46b276a8812822b50b5b23592cc911;hb=cb73d14fe59acbe8eba0a62f4af26a23072201fa;hp=4e8bc7de26d189ca8fc36ebf8c3fd5969b2feee5;hpb=d66e2dde00fcfbe27c461a9956e66753faa62c95;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/cinelerra/renderengine.C b/cinelerra-5.1/cinelerra/renderengine.C index 4e8bc7de..177f3350 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" @@ -86,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() @@ -467,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"); @@ -519,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; @@ -530,17 +527,15 @@ void RenderEngine::run() //printf("RenderEngine::run 4.1 %d\n", playback_engine->tracking_position); if(!interrupted) { - if(do_audio) - playback_engine->tracking_position = - (double)arender->current_position / - command->get_edl()->session->sample_rate; - else - if(do_video) - { - playback_engine->tracking_position = - (double)vrender->current_position / - command->get_edl()->session->frame_rate; - } + playback_engine->tracking_position = + command->get_direction() == PLAY_FORWARD ? + command->end_position : command->start_position; + } + + 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;