From: Good Guy Date: Thu, 12 Jul 2018 20:33:53 +0000 (-0600) Subject: png img proxy fixes, speed zoom segv fix, colapse ins 1frm silence undo, repair rende... X-Git-Url: https://git.cinelerra-gg.org/git/?a=commitdiff_plain;h=5621db270ccbeabc106e0f438941dba6f930652b;p=goodguy%2Fhistory.git png img proxy fixes, speed zoom segv fix, colapse ins 1frm silence undo, repair renderengine interrupt lock, add trace classes for mutex/condition --- diff --git a/cinelerra-5.1/cinelerra/assetedit.C b/cinelerra-5.1/cinelerra/assetedit.C index 0a417e4b..301cf482 100644 --- a/cinelerra-5.1/cinelerra/assetedit.C +++ b/cinelerra-5.1/cinelerra/assetedit.C @@ -193,8 +193,8 @@ int AssetEdit::window_height() h += 210; if( indexable->is_asset ) { Asset *asset = (Asset *)indexable; - if( asset->format == FILE_MPEG || - asset->format == FILE_FFMPEG ) h += 42; + if( File::can_scale_input(asset) ) + h += 42; } } return h; @@ -498,7 +498,7 @@ void AssetEditWindow::create_objects() add_subwindow(win_height); y += win_height->get_h() + 5; - if( asset && (asset->format == FILE_MPEG || asset->format == FILE_FFMPEG ) ) { + if( asset && File::can_scale_input(asset) ) { y += 5; x = x1; add_subwindow(new BC_Title(x, y, _("Actual width:"))); diff --git a/cinelerra-5.1/cinelerra/file.C b/cinelerra-5.1/cinelerra/file.C index 03348e0a..13e1b457 100644 --- a/cinelerra-5.1/cinelerra/file.C +++ b/cinelerra-5.1/cinelerra/file.C @@ -266,13 +266,23 @@ int File::get_options(FormatTools *format, return 0; } - - - - - - - +int File::can_scale_input(Asset *asset) +{ + switch( asset->format ) { + case FILE_MPEG: + case FILE_FFMPEG: + return 1; + case FILE_EXR: + case FILE_JPEG: + case FILE_PNG: + case FILE_PPM: + case FILE_TGA: + case FILE_TIFF: + if( asset->video_length < 0 ) + return 1; + } + return 0; +} int File::set_processors(int cpus) // Set the number of cpus for certain codecs diff --git a/cinelerra-5.1/cinelerra/file.h b/cinelerra-5.1/cinelerra/file.h index bb1a80ef..2ca1acbe 100644 --- a/cinelerra-5.1/cinelerra/file.h +++ b/cinelerra-5.1/cinelerra/file.h @@ -232,6 +232,8 @@ public: // Get best colormodel for hardware accelerated recording. // Called by VideoDevice. static int get_best_colormodel(Asset *asset, int driver); +// asset scaling on read_frame + static int can_scale_input(Asset *asset); // Get nearest colormodel that can be decoded without a temporary frame. // Used by read_frame. int colormodel_supported(int colormodel); diff --git a/cinelerra-5.1/cinelerra/filelist.C b/cinelerra-5.1/cinelerra/filelist.C index b98864f9..dd78cf57 100644 --- a/cinelerra-5.1/cinelerra/filelist.C +++ b/cinelerra-5.1/cinelerra/filelist.C @@ -132,9 +132,15 @@ int FileList::open_file(int rd, int wr) //printf("FileList::open_file 2\n", asset->use_header); //printf("FileList::open_file %d\n", __LINE__); asset->format = frame_type; + int width = asset->width; + int height = asset->height; result = read_frame_header(asset->path); + asset->actual_width = asset->width; + if( width ) asset->width = width; + asset->actual_height = asset->height; + if( height ) asset->height = height; asset->layers = 1; - if(!asset->frame_rate) + if( !asset->frame_rate ) asset->frame_rate = 1; asset->video_length = -1; } @@ -371,7 +377,7 @@ int FileList::read_frame(VFrame *frame) data->allocate_compressed_data(ostat.st_size); data->set_compressed_size(ostat.st_size); (void)fread(data->get_data(), ostat.st_size, 1, fd); - temp = new VFrame(asset->width, asset->height, + temp = new VFrame(asset->actual_width, asset->actual_height, frame->get_color_model(), 0); read_frame(temp, data); break; @@ -387,7 +393,8 @@ int FileList::read_frame(VFrame *frame) } else { - temp = new VFrame(asset->width, asset->height, frame->get_color_model(), 0); + temp = new VFrame(asset->actual_width, asset->actual_height, + frame->get_color_model(), 0); read_frame(temp, asset->path); } } diff --git a/cinelerra-5.1/cinelerra/mwindowedit.C b/cinelerra-5.1/cinelerra/mwindowedit.C index 4e5ec288..53cb4c33 100644 --- a/cinelerra-5.1/cinelerra/mwindowedit.C +++ b/cinelerra-5.1/cinelerra/mwindowedit.C @@ -1608,7 +1608,7 @@ void MWindow::paste_silence() if( edl->session->frame_rate > 0 ) end += 1./edl->session->frame_rate; } - undo->update_undo_before(); + undo->update_undo_before(_("silence"), this); edl->paste_silence(start, end, edl->session->labels_follow_edits, edl->session->plugins_follow_edits, @@ -2400,11 +2400,13 @@ void MWindow::speed_before() int MWindow::speed_after(int done) { int result = 0; - if( speed_edl && done >= 0 ) - result = normalize_speed(speed_edl, edl); - if( done ) { - speed_edl->remove_user(); - speed_edl = 0; + if( speed_edl ) { + if( done >= 0 ) + result = normalize_speed(speed_edl, edl); + if( done != 0 ) { + speed_edl->remove_user(); + speed_edl = 0; + } } return result; } diff --git a/cinelerra-5.1/cinelerra/proxy.C b/cinelerra-5.1/cinelerra/proxy.C index fc1380ed..b534a10e 100644 --- a/cinelerra-5.1/cinelerra/proxy.C +++ b/cinelerra-5.1/cinelerra/proxy.C @@ -260,15 +260,13 @@ Asset *ProxyRender::add_original(Indexable *idxbl, int new_scale) if( !proxy ) { proxy = new Asset(new_path); // new compression parameters - int64_t video_length = idxbl->get_video_frames(); - if( video_length < 0 ) { + if( idxbl->get_video_frames() < 0 ) { proxy->format = FILE_PNG; proxy->png_use_alpha = 1; - proxy->video_length = 1; + proxy->video_length = -1; } else { proxy->copy_format(format_asset, 0); - proxy->video_length = video_length; } proxy->awindow_folder = AW_PROXY_FOLDER; proxy->audio_data = 0; @@ -472,6 +470,7 @@ void ProxyUseScaler::update() int ProxyUseScaler::handle_event() { + pwindow->dialog->new_scale = 1; pwindow->dialog->use_scaler = get_value(); pwindow->scale_factor->update_sizes(); pwindow->update(); diff --git a/cinelerra-5.1/cinelerra/renderengine.C b/cinelerra-5.1/cinelerra/renderengine.C index c2bfb365..721e3be8 100644 --- a/cinelerra-5.1/cinelerra/renderengine.C +++ b/cinelerra-5.1/cinelerra/renderengine.C @@ -73,7 +73,7 @@ RenderEngine::RenderEngine(PlaybackEngine *playback_engine, start_lock = new Condition(1, "RenderEngine::start_lock"); output_lock = new Condition(1, "RenderEngine::output_lock"); render_active = new Condition(1,"RenderEngine::render_active"); - interrupt_lock = new Mutex("RenderEngine::interrupt_lock"); + interrupt_lock = new Condition(1, "RenderEngine::interrupt_lock"); first_frame_lock = new Condition(1, "RenderEngine::first_frame_lock"); } @@ -499,7 +499,7 @@ void RenderEngine::run() render_active->lock("RenderEngine::run"); start_render_threads(); start_lock->unlock(); - interrupt_lock->reset(); + interrupt_lock->unlock(); wait_render_threads(); diff --git a/cinelerra-5.1/cinelerra/renderengine.h b/cinelerra-5.1/cinelerra/renderengine.h index 5e3ed940..4e9c9689 100644 --- a/cinelerra-5.1/cinelerra/renderengine.h +++ b/cinelerra-5.1/cinelerra/renderengine.h @@ -111,7 +111,7 @@ public: // Lock out audio and synchronization timers until first frame is done Condition *first_frame_lock; // Lock out interrupts before and after renderengine is active - Mutex *interrupt_lock; + Condition *interrupt_lock; int done; int is_nested; diff --git a/cinelerra-5.1/guicast/condition.h b/cinelerra-5.1/guicast/condition.h index 1143ef03..22b38a6b 100644 --- a/cinelerra-5.1/guicast/condition.h +++ b/cinelerra-5.1/guicast/condition.h @@ -51,4 +51,41 @@ public: const char *title; }; +#if 0 +#include + +class TCondition : public Condition +{ +public: + TCondition(int init_value = 0, const char *title = 0, int is_binary = 0) + : Condition(init_value, title, is_binary) { + printf("new TCondition(%s) = %p\n", title, this); + } + ~TCondition() { + printf("del TCondition(%s) = %p\n", title, this); + } + void lock(const char *location = 0) { + printf("Locking %p: %s\n", this, title); Condition::lock(location); + printf("Locked %p: %s\n", this, title); + } + void unlock() { + printf("Unlocking %p: %s\n", this, title); Condition::unlock(); + } + int timed_lock(int microseconds, const char *location = 0) { + printf("timed locking %p: %s\n", this, title); + int ret = Condition::timed_lock(microseconds, location); + printf("timed locked %p:%d %s\n", this, ret, title); return ret; + } + void reset() { + printf("Reset %p: %s\n", this, title); + Condition::reset(); + } + int get_value() { + int ret = Condition::get_value(); + printf("get_value %p:%d %s\n", this, ret, title); + return ret; + } +}; + +#endif #endif diff --git a/cinelerra-5.1/guicast/mutex.C b/cinelerra-5.1/guicast/mutex.C index c6cddd76..6ac188d5 100644 --- a/cinelerra-5.1/guicast/mutex.C +++ b/cinelerra-5.1/guicast/mutex.C @@ -20,6 +20,7 @@ */ #include +#include #include #include "bcsignals.h" @@ -115,7 +116,8 @@ int Mutex::unlock() UNSET_LOCK(this); - if(pthread_mutex_unlock(&mutex)) perror("Mutex::unlock"); + int ret = pthread_mutex_unlock(&mutex); + if( ret ) fprintf(stderr, "Mutex::unlock: %s\n",strerror(ret)); return 0; } diff --git a/cinelerra-5.1/guicast/mutex.h b/cinelerra-5.1/guicast/mutex.h index c61317ee..4a1052cd 100644 --- a/cinelerra-5.1/guicast/mutex.h +++ b/cinelerra-5.1/guicast/mutex.h @@ -53,4 +53,40 @@ public: const char *title; }; +#if 0 +#include + +class TMutex : public Mutex +{ // logged +public: + TMutex(const char *title = 0, int recursive = 0) + : Mutex(title, recursive) { + printf("new TMutex(%s) = %p\n", title, this); + } + ~TMutex() { + printf("del TMutex(%s) = %p\n", title, this); + } + int lock(const char *location = 0) { + printf("locking %p: %s\n", this, title); int ret = Mutex::lock(location); + printf("locked %p:%d %s\n", this, ret, title); return ret; + } + int unlock() { + printf("unlocking %p: %s\n", this, title); return Mutex::unlock(); + } + int trylock(const char *location = 0) { + printf("try locking %p: %s\n", this, title); int ret = Mutex::trylock(location); + printf("try locked %p:%d %s\n", this, ret, title); return ret; + } + int reset() { + printf("reset %p: %s\n", this, title); + return Mutex::reset(); + } + int is_locked() { + int ret = Mutex::is_locked(); + printf("is_locked %p:%d %s\n", this, ret, title); + return ret; + } +}; + +#endif #endif