From: Good Guy Date: Wed, 2 Aug 2017 23:30:37 +0000 (-0600) Subject: x265 upgrade to 2.5, cinfinity cc lic, keyframe reticle redraw, crikey/titler event... X-Git-Url: http://git.cinelerra-gg.org/git/?p=goodguy%2Fhistory.git;a=commitdiff_plain;h=e5d1c3ec8b49e9e4cd31f30e991f52ab11de93b1 x265 upgrade to 2.5, cinfinity cc lic, keyframe reticle redraw, crikey/titler event fix, render wdw widen/warns/1frame, render opts setups --- diff --git a/cinelerra-5.1/COPYING b/cinelerra-5.1/COPYING index eeb586b3..a3fa5380 100644 --- a/cinelerra-5.1/COPYING +++ b/cinelerra-5.1/COPYING @@ -338,3 +338,10 @@ proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. + +Also: + +cinfinity icons (c) by "sam" are licensed under a +Creative Commons Attribution 4.0 International License. +see: . + diff --git a/cinelerra-5.1/cinelerra/assetedit.C b/cinelerra-5.1/cinelerra/assetedit.C index b5a733bc..dc43432c 100644 --- a/cinelerra-5.1/cinelerra/assetedit.C +++ b/cinelerra-5.1/cinelerra/assetedit.C @@ -272,8 +272,7 @@ void AssetEditWindow::create_objects() if( asset ) { add_subwindow(new BC_Title(x, y, _("File format:"))); x = x2; - add_subwindow(new BC_Title(x, y, File::formattostr(mwindow->plugindb, - asset->format), + add_subwindow(new BC_Title(x, y, File::formattostr(asset->format), MEDIUMFONT, mwindow->theme->assetedit_color)); x = x1; @@ -885,8 +884,7 @@ AssetEditFormat::~AssetEditFormat() int AssetEditFormat::handle_event() { Asset *asset = fwindow->asset_edit->changed_params; - asset->format = File::strtoformat(fwindow->mwindow->plugindb, - get_selection(0, 0)->get_text()); + asset->format = File::strtoformat(get_selection(0, 0)->get_text()); return 1; } diff --git a/cinelerra-5.1/cinelerra/file.C b/cinelerra-5.1/cinelerra/file.C index 7e3493b1..2d1c4af2 100644 --- a/cinelerra-5.1/cinelerra/file.C +++ b/cinelerra-5.1/cinelerra/file.C @@ -93,14 +93,13 @@ File::File() File::~File() { - if(getting_options) - { - if(format_window) format_window->set_done(0); + if( getting_options ) { + if( format_window ) format_window->set_done(0); format_completion->lock("File::~File"); format_completion->unlock(); } - if(temp_frame) delete temp_frame; + if( temp_frame ) delete temp_frame; close_file(0); @@ -141,8 +140,7 @@ void File::reset_parameters() int File::raise_window() { - if(getting_options && format_window) - { + if( getting_options && format_window ) { format_window->raise_window(); format_window->flush(); } @@ -151,8 +149,7 @@ int File::raise_window() void File::close_window() { - if(getting_options) - { + if( getting_options ) { format_window->lock_window("File::close_window"); format_window->set_done(1); format_window->unlock_window(); @@ -169,121 +166,86 @@ int File::get_options(FormatTools *format, getting_options = 1; format_completion->lock("File::get_options"); - switch(asset->format) - { - case FILE_AC3: - FileAC3::get_parameters(parent_window, - asset, - format_window, - audio_options, - video_options); - break; + switch( asset->format ) { + case FILE_AC3: + FileAC3::get_parameters(parent_window, + asset, + format_window, + audio_options, + video_options); + break; #ifdef HAVE_DV - case FILE_RAWDV: - FileDV::get_parameters(parent_window, - asset, - format_window, - audio_options, - video_options); - break; + case FILE_RAWDV: + FileDV::get_parameters(parent_window, asset, format_window, + audio_options, video_options); + break; #endif - case FILE_PCM: - case FILE_WAV: - case FILE_AU: - case FILE_AIFF: - case FILE_SND: - FileSndFile::get_parameters(parent_window, - asset, - format_window, - audio_options, - video_options); - break; - case FILE_FFMPEG: - FileFFMPEG::get_parameters(parent_window, - asset, - format_window, - audio_options, - video_options); - break; - case FILE_AMPEG: - case FILE_VMPEG: - FileMPEG::get_parameters(parent_window, - asset, - format_window, - audio_options, - video_options); - break; - case FILE_JPEG: - case FILE_JPEG_LIST: - FileJPEG::get_parameters(parent_window, - asset, - format_window, - audio_options, - video_options); - break; + case FILE_PCM: + case FILE_WAV: + case FILE_AU: + case FILE_AIFF: + case FILE_SND: + FileSndFile::get_parameters(parent_window, asset, format_window, + audio_options, video_options); + break; + case FILE_FFMPEG: + FileFFMPEG::get_parameters(parent_window, asset, format_window, + audio_options, video_options); + break; + case FILE_AMPEG: + case FILE_VMPEG: + FileMPEG::get_parameters(parent_window, asset, format_window, + audio_options, video_options); + break; + case FILE_JPEG: + case FILE_JPEG_LIST: + FileJPEG::get_parameters(parent_window, asset, format_window, + audio_options, video_options); + break; #ifdef HAVE_OPENEXR - case FILE_EXR: - case FILE_EXR_LIST: - FileEXR::get_parameters(parent_window, - asset, - format_window, - audio_options, - video_options); - break; + case FILE_EXR: + case FILE_EXR_LIST: + FileEXR::get_parameters(parent_window, asset, format_window, + audio_options, video_options); + break; #endif - case FILE_FLAC: - FileFLAC::get_parameters(parent_window, - asset, - format_window, - audio_options, - video_options); - break; - case FILE_PNG: - case FILE_PNG_LIST: - FilePNG::get_parameters(parent_window, - asset, - format_window, - audio_options, - video_options); - break; - case FILE_TGA: - case FILE_TGA_LIST: - FileTGA::get_parameters(parent_window, - asset, - format_window, - audio_options, - video_options); - break; - case FILE_TIFF: - case FILE_TIFF_LIST: - FileTIFF::get_parameters(parent_window, - asset, - format_window, - audio_options, - video_options); - break; - case FILE_OGG: - FileOGG::get_parameters(parent_window, - asset, - format_window, - audio_options, - video_options); - break; - default: - break; + case FILE_FLAC: + FileFLAC::get_parameters(parent_window, asset, format_window, + audio_options, video_options); + break; + case FILE_PNG: + case FILE_PNG_LIST: + FilePNG::get_parameters(parent_window, asset, format_window, + audio_options, video_options); + break; + case FILE_TGA: + case FILE_TGA_LIST: + FileTGA::get_parameters(parent_window, asset, format_window, + audio_options, video_options); + break; + case FILE_TIFF: + case FILE_TIFF_LIST: + FileTIFF::get_parameters(parent_window, asset, format_window, + audio_options, video_options); + break; + case FILE_OGG: + FileOGG::get_parameters(parent_window, asset, format_window, + audio_options, video_options); + break; + default: + break; } - if(!format_window) - { + if( !format_window ) { ErrorBox *errorbox = new ErrorBox(_(PROGRAM_NAME ": Error"), parent_window->get_abs_cursor_x(1), parent_window->get_abs_cursor_y(1)); format_window = errorbox; getting_options = 1; - if(audio_options) + if( audio_options ) errorbox->create_objects(_("This format doesn't support audio.")); else - if(video_options) + if( video_options ) errorbox->create_objects(_("This format doesn't support video.")); errorbox->run_window(); delete errorbox; @@ -340,7 +302,7 @@ void File::set_white_balance_raw(int value) void File::set_cache_frames(int value) { // caching only done locally - if(!video_thread) + if( !video_thread ) use_cache = value; } @@ -348,8 +310,7 @@ int File::purge_cache() { // caching only done locally int result = 0; - if( frame_cache->cache_items() > 0 ) - { + if( frame_cache->cache_items() > 0 ) { frame_cache->remove_all(); result = 1; } @@ -513,11 +474,11 @@ int File::open_file(Preferences *preferences, this->wr = wr; file = 0; - if(debug) printf("File::open_file %d\n", __LINE__); + if( debug ) printf("File::open_file %d\n", __LINE__); - if(debug) printf("File::open_file %p %d\n", this, __LINE__); + if( debug ) printf("File::open_file %p %d\n", this, __LINE__); - switch(this->asset->format) { + switch( this->asset->format ) { // get the format now // If you add another format to case 0, you also need to add another case for the // file format #define. @@ -616,7 +577,7 @@ int File::open_file(Preferences *preferences, // Reopen file with correct parser and get header. - if(file->open_file(rd, wr)) { + if( file->open_file(rd, wr) ) { delete file; file = 0; return FILE_NOT_FOUND; } @@ -625,7 +586,7 @@ int File::open_file(Preferences *preferences, // Set extra writing parameters to mandatory settings. if( wr ) { - if(this->asset->dither) file->set_dither(); + if( this->asset->dither ) file->set_dither(); } if( rd ) { @@ -642,7 +603,7 @@ int File::open_file(Preferences *preferences, asset->copy_from(this->asset, 1); //asset->dump(); - if(debug) printf("File::open_file %d file=%p\n", __LINE__, file); + if( debug ) printf("File::open_file %d file=%p\n", __LINE__, file); // sleep(1); return FILE_OK; @@ -651,9 +612,9 @@ int File::open_file(Preferences *preferences, void File::delete_temp_samples_buffer() { - if(temp_samples_buffer) { - for(int j = 0; j < audio_ring_buffers; j++) { - for(int i = 0; i < asset->channels; i++) { + if( temp_samples_buffer ) { + for( int j = 0; j < audio_ring_buffers; j++ ) { + for( int i = 0; i < asset->channels; i++ ) { delete temp_samples_buffer[j][i]; } delete [] temp_samples_buffer[j]; @@ -668,10 +629,10 @@ void File::delete_temp_samples_buffer() void File::delete_temp_frame_buffer() { - if(temp_frame_buffer) { - for(int k = 0; k < video_ring_buffers; k++) { - for(int i = 0; i < asset->layers; i++) { - for(int j = 0; j < video_buffer_size; j++) { + if( temp_frame_buffer ) { + for( int k = 0; k < video_ring_buffers; k++ ) { + for( int i = 0; i < asset->layers; i++ ) { + for( int j = 0; j < video_buffer_size; j++ ) { delete temp_frame_buffer[k][i][j]; } delete [] temp_frame_buffer[k][i]; @@ -690,19 +651,19 @@ int File::close_file(int ignore_thread) { const int debug = 0; - if(debug) printf("File::close_file file=%p %d\n", file, __LINE__); + if( debug ) printf("File::close_file file=%p %d\n", file, __LINE__); - if(!ignore_thread) { + if( !ignore_thread ) { stop_audio_thread(); stop_video_thread(); } - if(debug) printf("File::close_file file=%p %d\n", file, __LINE__); - if(file) { + if( debug ) printf("File::close_file file=%p %d\n", file, __LINE__); + if( file ) { // The file's asset is a copy of the argument passed to open_file so the // user must copy lengths from the file's asset. - if(asset && wr) { + if( asset && wr ) { asset->audio_length = current_sample; asset->video_length = current_frame; } @@ -710,16 +671,16 @@ int File::close_file(int ignore_thread) file->close_file(); delete file; } - if(debug) printf("File::close_file file=%p %d\n", file, __LINE__); + if( debug ) printf("File::close_file file=%p %d\n", file, __LINE__); delete_temp_samples_buffer(); delete_temp_frame_buffer(); - if(debug) printf("File::close_file file=%p %d\n", file, __LINE__); + if( debug ) printf("File::close_file file=%p %d\n", file, __LINE__); - if(debug) printf("File::close_file file=%p %d\n", file, __LINE__); + if( debug ) printf("File::close_file file=%p %d\n", file, __LINE__); reset_parameters(); - if(debug) printf("File::close_file file=%p %d\n", file, __LINE__); + if( debug ) printf("File::close_file file=%p %d\n", file, __LINE__); return 0; } @@ -737,8 +698,7 @@ int File::start_audio_thread(int buffer_size, int ring_buffers) this->audio_ring_buffers = ring_buffers; - if(!audio_thread) - { + if( !audio_thread ) { audio_thread = new FileThread(this, 1, 0); audio_thread->start_writing(buffer_size, 0, ring_buffers, 0); } @@ -753,8 +713,7 @@ int File::start_video_thread(int buffer_size, this->video_ring_buffers = ring_buffers; this->video_buffer_size = buffer_size; - if(!video_thread) - { + if( !video_thread ) { video_thread = new FileThread(this, 0, 1); video_thread->start_writing(buffer_size, color_model, @@ -768,8 +727,7 @@ int File::start_video_decode_thread() { // Currently, CR2 is the only one which won't work asynchronously, so // we're not using a virtual function yet. - if(!video_thread /* && asset->format != FILE_CR2 */) - { + if( !video_thread /* && asset->format != FILE_CR2 */ ) { video_thread = new FileThread(this, 0, 1); video_thread->start_reading(); use_cache = 0; @@ -779,8 +737,7 @@ int File::start_video_decode_thread() int File::stop_audio_thread() { - if(audio_thread) - { + if( audio_thread ) { audio_thread->stop_writing(); delete audio_thread; audio_thread = 0; @@ -790,8 +747,7 @@ int File::stop_audio_thread() int File::stop_video_thread() { - if(video_thread) - { + if( video_thread ) { video_thread->stop_reading(); video_thread->stop_writing(); delete video_thread; @@ -807,8 +763,7 @@ FileThread* File::get_video_thread() int File::set_channel(int channel) { - if(file && channel < asset->channels) - { + if( file && channel < asset->channels ) { current_channel = channel; return 0; } @@ -891,14 +846,11 @@ int File::skim_video(int track, void *vp, skim_fn fn) int File::set_layer(int layer, int is_thread) { - if(file && layer < asset->layers) - { - if(!is_thread && video_thread) - { + if( file && layer < asset->layers ) { + if( !is_thread && video_thread ) { video_thread->set_layer(layer); } - else - { + else { current_layer = layer; } return 0; @@ -911,9 +863,8 @@ int64_t File::get_audio_length() { int64_t result = asset->audio_length; int64_t base_samplerate = -1; - if(result > 0) - { - if(base_samplerate > 0) + if( result > 0 ) { + if( base_samplerate > 0 ) return (int64_t)((double)result / asset->sample_rate * base_samplerate + 0.5); else return result; @@ -926,9 +877,8 @@ int64_t File::get_video_length() { int64_t result = asset->video_length; float base_framerate = -1; - if(result > 0) - { - if(base_framerate > 0) + if( result > 0 ) { + if( base_framerate > 0 ) return (int64_t)((double)result / asset->frame_rate * base_framerate + 0.5); else return result; @@ -941,7 +891,7 @@ int64_t File::get_video_length() int64_t File::get_video_position() { float base_framerate = -1; - if(base_framerate > 0) + if( base_framerate > 0 ) return (int64_t)((double)current_frame / asset->frame_rate * base_framerate + 0.5); else return current_frame; @@ -950,9 +900,9 @@ int64_t File::get_video_position() int64_t File::get_audio_position() { // int64_t base_samplerate = -1; -// if(base_samplerate > 0) +// if( base_samplerate > 0 ) // { -// if(normalized_sample_rate == base_samplerate) +// if( normalized_sample_rate == base_samplerate ) // return normalized_sample; // else // return (int64_t)((double)current_sample / @@ -970,7 +920,7 @@ int File::set_audio_position(int64_t position) { int result = 0; - if(!file) return 1; + if( !file ) return 1; #define REPOSITION(x, y) \ (labs((x) - (y)) > 1) @@ -983,7 +933,7 @@ int File::set_audio_position(int64_t position) // normalized_sample); result = file->set_audio_position(current_sample); - if(result) + if( result ) printf("File::set_audio_position position=%jd" " base_samplerate=%f asset=%p asset->sample_rate=%d\n", position, base_samplerate, asset, asset->sample_rate); @@ -997,26 +947,23 @@ int File::set_video_position(int64_t position, int is_thread) { int result = 0; - if(!file) return 0; + if( !file ) return 0; // Convert to file's rate -// if(base_framerate > 0) +// if( base_framerate > 0 ) // position = (int64_t)((double)position / // base_framerate * // asset->frame_rate + // 0.5); - if(video_thread && !is_thread) - { + if( video_thread && !is_thread ) { // Call thread. Thread calls this again to set the file state. video_thread->set_video_position(position); } else - if(current_frame != position) - { - if(file) - { + if( current_frame != position ) { + if( file ) { current_frame = position; result = file->set_video_position(current_frame); } @@ -1030,14 +977,12 @@ int File::write_samples(Samples **buffer, int64_t len) { int result = 1; - if(file) - { + if( file ) { write_lock->lock("File::write_samples"); // Convert to arrays for backwards compatability double *temp[asset->channels]; - for(int i = 0; i < asset->channels; i++) - { + for( int i = 0; i < asset->channels; i++ ) { temp[i] = buffer[i]->get_data(); } @@ -1094,8 +1039,7 @@ int File::write_compressed_frame(VFrame *buffer) int File::write_audio_buffer(int64_t len) { int result = 0; - if(audio_thread) - { + if( audio_thread ) { result = audio_thread->write_buffer(len); } return result; @@ -1104,8 +1048,7 @@ int File::write_audio_buffer(int64_t len) int File::write_video_buffer(int64_t len) { int result = 0; - if(video_thread) - { + if( video_thread ) { result = video_thread->write_buffer(len); } @@ -1114,14 +1057,13 @@ int File::write_video_buffer(int64_t len) Samples** File::get_audio_buffer() { - if(audio_thread) return audio_thread->get_audio_buffer(); + if( audio_thread ) return audio_thread->get_audio_buffer(); return 0; } VFrame*** File::get_video_buffer() { - if(video_thread) - { + if( video_thread ) { VFrame*** result = video_thread->get_video_buffer(); return result; @@ -1134,35 +1076,34 @@ VFrame*** File::get_video_buffer() int File::read_samples(Samples *samples, int64_t len) { // Never try to read more samples than exist in the file - if (asset->audio_length >= 0 && current_sample + len > asset->audio_length) { + if( asset->audio_length >= 0 && current_sample + len > asset->audio_length ) { len = asset->audio_length - current_sample; } - if(len <= 0) return 0; + if( len <= 0 ) return 0; int result = 0; const int debug = 0; - if(debug) PRINT_TRACE + if( debug ) PRINT_TRACE - if(debug) PRINT_TRACE + if( debug ) PRINT_TRACE double *buffer = samples->get_data(); int64_t base_samplerate = asset->sample_rate; - if(file) - { + if( file ) { // Resample recursively calls this with the asset sample rate - if(base_samplerate == 0) base_samplerate = asset->sample_rate; + if( base_samplerate == 0 ) base_samplerate = asset->sample_rate; - if(debug) PRINT_TRACE + if( debug ) PRINT_TRACE result = file->read_samples(buffer, len); - if(debug) PRINT_TRACE + if( debug ) PRINT_TRACE current_sample += len; normalized_sample += len; } - if(debug) PRINT_TRACE + if( debug ) PRINT_TRACE return result; } @@ -1171,16 +1112,16 @@ int File::read_frame(VFrame *frame, int is_thread) { const int debug = 0; - if(debug) PRINT_TRACE + if( debug ) PRINT_TRACE //printf("File::read_frame %d\n", __LINE__); - if(video_thread && !is_thread) return video_thread->read_frame(frame); + if( video_thread && !is_thread ) return video_thread->read_frame(frame); //printf("File::read_frame %d\n", __LINE__); - if(debug) PRINT_TRACE + if( debug ) PRINT_TRACE if( !file ) return 1; - if(debug) PRINT_TRACE + if( debug ) PRINT_TRACE int result = 0; int supported_colormodel = colormodel_supported(frame->get_color_model()); int advance_position = 1; @@ -1188,33 +1129,28 @@ int File::read_frame(VFrame *frame, int is_thread) int64_t cache_position = !asset->single_frame ? current_frame : -1; // Test cache if( cache_active && frame_cache->get_frame(frame, cache_position, - current_layer, asset->frame_rate) ) - { + current_layer, asset->frame_rate) ) { // Can't advance position if cache used. //printf("File::read_frame %d\n", __LINE__); advance_position = 0; } // Need temp - else if(frame->get_color_model() != BC_COMPRESSED && + else if( frame->get_color_model() != BC_COMPRESSED && (supported_colormodel != frame->get_color_model() || frame->get_w() != asset->width || - frame->get_h() != asset->height)) - { + frame->get_h() != asset->height) ) { // printf("File::read_frame %d\n", __LINE__); // Can't advance position here because it needs to be added to cache - if(temp_frame) - { - if(!temp_frame->params_match(asset->width, asset->height, supported_colormodel)) - { + if( temp_frame ) { + if( !temp_frame->params_match(asset->width, asset->height, supported_colormodel) ) { delete temp_frame; temp_frame = 0; } } // printf("File::read_frame %d\n", __LINE__); - if(!temp_frame) - { + if( !temp_frame ) { temp_frame = new VFrame(0, -1, asset->width, @@ -1232,14 +1168,13 @@ int File::read_frame(VFrame *frame, int is_thread) frame->set_status(-1); //printf("File::read_frame %d\n", __LINE__); } - else - { + else { // Can't advance position here because it needs to be added to cache //printf("File::read_frame %d\n", __LINE__); result = file->read_frame(frame); if( result && frame->get_status() > 0 ) frame->set_status(-1); -//for(int i = 0; i < 100 * 1000; i++) ((float*)frame->get_rows()[0])[i] = 1.0; +//for( int i = 0; i < 100 * 1000; i++ ) ((float*)frame->get_rows()[0])[i] = 1.0; } if( result && !current_frame ) @@ -1250,8 +1185,8 @@ int File::read_frame(VFrame *frame, int is_thread) current_layer, asset->frame_rate, 1, 0); //printf("File::read_frame %d\n", __LINE__); - if(advance_position) current_frame++; - if(debug) PRINT_TRACE + if( advance_position ) current_frame++; + if( debug ) PRINT_TRACE return 0; } @@ -1273,39 +1208,34 @@ int File::can_copy_from(Asset *asset, int File::strtoformat(const char *format) { - return strtoformat(0, format); -} - -int File::strtoformat(ArrayList *plugindb, const char *format) -{ - if(!strcasecmp(format, _(AC3_NAME))) return FILE_AC3; - if(!strcasecmp(format, _(SCENE_NAME))) return FILE_SCENE; - if(!strcasecmp(format, _(WAV_NAME))) return FILE_WAV; - if(!strcasecmp(format, _(PCM_NAME))) return FILE_PCM; - if(!strcasecmp(format, _(AU_NAME))) return FILE_AU; - if(!strcasecmp(format, _(AIFF_NAME))) return FILE_AIFF; - if(!strcasecmp(format, _(SND_NAME))) return FILE_SND; - if(!strcasecmp(format, _(PNG_NAME))) return FILE_PNG; - if(!strcasecmp(format, _(PNG_LIST_NAME))) return FILE_PNG_LIST; - if(!strcasecmp(format, _(TIFF_NAME))) return FILE_TIFF; - if(!strcasecmp(format, _(TIFF_LIST_NAME))) return FILE_TIFF_LIST; - if(!strcasecmp(format, _(JPEG_NAME))) return FILE_JPEG; - if(!strcasecmp(format, _(JPEG_LIST_NAME))) return FILE_JPEG_LIST; - if(!strcasecmp(format, _(EXR_NAME))) return FILE_EXR; - if(!strcasecmp(format, _(EXR_LIST_NAME))) return FILE_EXR_LIST; - if(!strcasecmp(format, _(FLAC_NAME))) return FILE_FLAC; - if(!strcasecmp(format, _(CR2_NAME))) return FILE_CR2; - if(!strcasecmp(format, _(CR2_LIST_NAME))) return FILE_CR2_LIST; - if(!strcasecmp(format, _(MPEG_NAME))) return FILE_MPEG; - if(!strcasecmp(format, _(AMPEG_NAME))) return FILE_AMPEG; - if(!strcasecmp(format, _(VMPEG_NAME))) return FILE_VMPEG; - if(!strcasecmp(format, _(TGA_NAME))) return FILE_TGA; - if(!strcasecmp(format, _(TGA_LIST_NAME))) return FILE_TGA_LIST; - if(!strcasecmp(format, _(OGG_NAME))) return FILE_OGG; - if(!strcasecmp(format, _(VORBIS_NAME))) return FILE_VORBIS; - if(!strcasecmp(format, _(RAWDV_NAME))) return FILE_RAWDV; - if(!strcasecmp(format, _(FFMPEG_NAME))) return FILE_FFMPEG; - if(!strcasecmp(format, _(DBASE_NAME))) return FILE_DB; + if( !strcasecmp(format, _(AC3_NAME)) ) return FILE_AC3; + if( !strcasecmp(format, _(SCENE_NAME)) ) return FILE_SCENE; + if( !strcasecmp(format, _(WAV_NAME)) ) return FILE_WAV; + if( !strcasecmp(format, _(PCM_NAME)) ) return FILE_PCM; + if( !strcasecmp(format, _(AU_NAME)) ) return FILE_AU; + if( !strcasecmp(format, _(AIFF_NAME)) ) return FILE_AIFF; + if( !strcasecmp(format, _(SND_NAME)) ) return FILE_SND; + if( !strcasecmp(format, _(PNG_NAME)) ) return FILE_PNG; + if( !strcasecmp(format, _(PNG_LIST_NAME)) ) return FILE_PNG_LIST; + if( !strcasecmp(format, _(TIFF_NAME)) ) return FILE_TIFF; + if( !strcasecmp(format, _(TIFF_LIST_NAME)) ) return FILE_TIFF_LIST; + if( !strcasecmp(format, _(JPEG_NAME)) ) return FILE_JPEG; + if( !strcasecmp(format, _(JPEG_LIST_NAME)) ) return FILE_JPEG_LIST; + if( !strcasecmp(format, _(EXR_NAME)) ) return FILE_EXR; + if( !strcasecmp(format, _(EXR_LIST_NAME)) ) return FILE_EXR_LIST; + if( !strcasecmp(format, _(FLAC_NAME)) ) return FILE_FLAC; + if( !strcasecmp(format, _(CR2_NAME)) ) return FILE_CR2; + if( !strcasecmp(format, _(CR2_LIST_NAME)) ) return FILE_CR2_LIST; + if( !strcasecmp(format, _(MPEG_NAME)) ) return FILE_MPEG; + if( !strcasecmp(format, _(AMPEG_NAME)) ) return FILE_AMPEG; + if( !strcasecmp(format, _(VMPEG_NAME)) ) return FILE_VMPEG; + if( !strcasecmp(format, _(TGA_NAME)) ) return FILE_TGA; + if( !strcasecmp(format, _(TGA_LIST_NAME)) ) return FILE_TGA_LIST; + if( !strcasecmp(format, _(OGG_NAME)) ) return FILE_OGG; + if( !strcasecmp(format, _(VORBIS_NAME)) ) return FILE_VORBIS; + if( !strcasecmp(format, _(RAWDV_NAME)) ) return FILE_RAWDV; + if( !strcasecmp(format, _(FFMPEG_NAME)) ) return FILE_FFMPEG; + if( !strcasecmp(format, _(DBASE_NAME)) ) return FILE_DB; return 0; } @@ -1313,12 +1243,7 @@ int File::strtoformat(ArrayList *plugindb, const char *format) const char* File::formattostr(int format) { - return formattostr(0, format); -} - -const char* File::formattostr(ArrayList *plugindb, int format) -{ - switch(format) { + switch( format ) { case FILE_SCENE: return _(SCENE_NAME); case FILE_AC3: return _(AC3_NAME); case FILE_WAV: return _(WAV_NAME); @@ -1353,20 +1278,20 @@ const char* File::formattostr(ArrayList *plugindb, int format) int File::strtobits(const char *bits) { - if(!strcasecmp(bits, _(NAME_8BIT))) return BITSLINEAR8; - if(!strcasecmp(bits, _(NAME_16BIT))) return BITSLINEAR16; - if(!strcasecmp(bits, _(NAME_24BIT))) return BITSLINEAR24; - if(!strcasecmp(bits, _(NAME_32BIT))) return BITSLINEAR32; - if(!strcasecmp(bits, _(NAME_ULAW))) return BITSULAW; - if(!strcasecmp(bits, _(NAME_ADPCM))) return BITS_ADPCM; - if(!strcasecmp(bits, _(NAME_FLOAT))) return BITSFLOAT; + if( !strcasecmp(bits, _(NAME_8BIT)) ) return BITSLINEAR8; + if( !strcasecmp(bits, _(NAME_16BIT)) ) return BITSLINEAR16; + if( !strcasecmp(bits, _(NAME_24BIT)) ) return BITSLINEAR24; + if( !strcasecmp(bits, _(NAME_32BIT)) ) return BITSLINEAR32; + if( !strcasecmp(bits, _(NAME_ULAW)) ) return BITSULAW; + if( !strcasecmp(bits, _(NAME_ADPCM)) ) return BITS_ADPCM; + if( !strcasecmp(bits, _(NAME_FLOAT)) ) return BITSFLOAT; return BITSLINEAR16; } const char* File::bitstostr(int bits) { //printf("File::bitstostr\n"); - switch(bits) { + switch( bits ) { case BITSLINEAR8: return (NAME_8BIT); case BITSLINEAR16: return (NAME_16BIT); case BITSLINEAR24: return (NAME_24BIT); @@ -1382,25 +1307,24 @@ const char* File::bitstostr(int bits) int File::str_to_byteorder(const char *string) { - if(!strcasecmp(string, _("Lo Hi"))) return 1; + if( !strcasecmp(string, _("Lo Hi")) ) return 1; return 0; } const char* File::byteorder_to_str(int byte_order) { - if(byte_order) return _("Lo Hi"); + if( byte_order ) return _("Lo Hi"); return _("Hi Lo"); } int File::bytes_per_sample(int bits) { - switch(bits) - { - case BITSLINEAR8: return 1; - case BITSLINEAR16: return 2; - case BITSLINEAR24: return 3; - case BITSLINEAR32: return 4; - case BITSULAW: return 1; + switch( bits ) { + case BITSLINEAR8: return 1; + case BITSLINEAR16: return 2; + case BITSLINEAR24: return 3; + case BITSLINEAR32: return 4; + case BITSULAW: return 1; } return 1; } @@ -1416,26 +1340,25 @@ int File::get_best_colormodel(int driver) int File::get_best_colormodel(Asset *asset, int driver) { - switch(asset->format) - { + switch( asset->format ) { #ifdef HAVE_DV - case FILE_RAWDV: return FileDV::get_best_colormodel(asset, driver); + case FILE_RAWDV: return FileDV::get_best_colormodel(asset, driver); #endif - case FILE_MPEG: return FileMPEG::get_best_colormodel(asset, driver); - case FILE_JPEG: - case FILE_JPEG_LIST: return FileJPEG::get_best_colormodel(asset, driver); + case FILE_MPEG: return FileMPEG::get_best_colormodel(asset, driver); + case FILE_JPEG: + case FILE_JPEG_LIST: return FileJPEG::get_best_colormodel(asset, driver); #ifdef HAVE_OPENEXR - case FILE_EXR: - case FILE_EXR_LIST: return FileEXR::get_best_colormodel(asset, driver); + case FILE_EXR: + case FILE_EXR_LIST: return FileEXR::get_best_colormodel(asset, driver); #endif - case FILE_PNG: - case FILE_PNG_LIST: return FilePNG::get_best_colormodel(asset, driver); - case FILE_TGA: - case FILE_TGA_LIST: return FileTGA::get_best_colormodel(asset, driver); - case FILE_CR2: - case FILE_CR2_LIST: return FileCR2::get_best_colormodel(asset, driver); - case FILE_DB: return FileDB::get_best_colormodel(asset, driver); - case FILE_FFMPEG: return FileFFMPEG::get_best_colormodel(asset, driver); + case FILE_PNG: + case FILE_PNG_LIST: return FilePNG::get_best_colormodel(asset, driver); + case FILE_TGA: + case FILE_TGA_LIST: return FileTGA::get_best_colormodel(asset, driver); + case FILE_CR2: + case FILE_CR2_LIST: return FileCR2::get_best_colormodel(asset, driver); + case FILE_DB: return FileDB::get_best_colormodel(asset, driver); + case FILE_FFMPEG: return FileFFMPEG::get_best_colormodel(asset, driver); } return BC_RGB888; @@ -1444,7 +1367,7 @@ int File::get_best_colormodel(Asset *asset, int driver) int File::colormodel_supported(int colormodel) { - if(file) + if( file ) return file->colormodel_supported(colormodel); return BC_RGB888; @@ -1461,113 +1384,109 @@ int64_t File::get_memory_usage() int64_t result = 0; result += file_memory_usage(); - if(temp_frame) result += temp_frame->get_data_size(); + if( temp_frame ) result += temp_frame->get_data_size(); result += frame_cache->get_memory_usage(); - if(video_thread) result += video_thread->get_memory_usage(); + if( video_thread ) result += video_thread->get_memory_usage(); - if(result < MIN_CACHEITEM_SIZE) result = MIN_CACHEITEM_SIZE; + if( result < MIN_CACHEITEM_SIZE ) result = MIN_CACHEITEM_SIZE; return result; } -int File::supports_video(ArrayList *plugindb, char *format) +int File::renders_video(Asset *asset) { - int format_i = strtoformat(plugindb, format); - - return supports_video(format_i); +//printf("File::supports_video %d\n", format); + switch( asset->format ) { + case FILE_OGG: + case FILE_JPEG: + case FILE_JPEG_LIST: + case FILE_CR2: + case FILE_CR2_LIST: + case FILE_EXR: + case FILE_EXR_LIST: + case FILE_PNG: + case FILE_PNG_LIST: + case FILE_TGA: + case FILE_TGA_LIST: + case FILE_TIFF: + case FILE_TIFF_LIST: + case FILE_VMPEG: + case FILE_RAWDV: + return 1; + case FILE_FFMPEG: + return FileFFMPEG::renders_video(asset->fformat); + } return 0; } -int File::supports_audio(ArrayList *plugindb, char *format) +int File::renders_audio(Asset *asset) { - int format_i = strtoformat(plugindb, format); - - return supports_audio(format_i); + switch( asset->format ) { + case FILE_AC3: + case FILE_FLAC: + case FILE_PCM: + case FILE_WAV: + case FILE_OGG: + case FILE_VORBIS: + case FILE_AMPEG: + case FILE_AU: + case FILE_AIFF: + case FILE_SND: + case FILE_RAWDV: + return 1; + case FILE_FFMPEG: + return FileFFMPEG::renders_audio(asset->fformat); + } return 0; } - -int File::supports_video(int format) +int File::is_image_render(int format) { -//printf("File::supports_video %d\n", format); - switch(format) - { - case FILE_OGG: - case FILE_JPEG: - case FILE_JPEG_LIST: - case FILE_CR2: - case FILE_CR2_LIST: - case FILE_EXR: - case FILE_EXR_LIST: - case FILE_PNG: - case FILE_PNG_LIST: - case FILE_TGA: - case FILE_TGA_LIST: - case FILE_TIFF: - case FILE_TIFF_LIST: - case FILE_VMPEG: - case FILE_FFMPEG: - case FILE_RAWDV: - return 1; + switch( format ) { + case FILE_EXR: + case FILE_JPEG: + case FILE_PNG: + case FILE_TGA: + case FILE_TIFF: + return 1; } - return 0; -} -int File::supports_audio(int format) -{ - switch(format) - { - case FILE_AC3: - case FILE_FLAC: - case FILE_PCM: - case FILE_WAV: - case FILE_OGG: - case FILE_VORBIS: - case FILE_AMPEG: - case FILE_AU: - case FILE_AIFF: - case FILE_SND: - case FILE_FFMPEG: - case FILE_RAWDV: - return 1; - } return 0; } const char* File::get_tag(int format) { - switch(format) - { - case FILE_AC3: return "ac3"; - case FILE_AIFF: return "aif"; - case FILE_AMPEG: return "mp3"; - case FILE_AU: return "au"; - case FILE_RAWDV: return "dv"; - case FILE_DB: return "db"; - case FILE_EXR: return "exr"; - case FILE_EXR_LIST: return "exr"; - case FILE_FLAC: return "flac"; - case FILE_JPEG: return "jpg"; - case FILE_JPEG_LIST: return "jpg"; - case FILE_OGG: return "ogg"; - case FILE_PCM: return "pcm"; - case FILE_PNG: return "png"; - case FILE_PNG_LIST: return "png"; - case FILE_TGA: return "tga"; - case FILE_TGA_LIST: return "tga"; - case FILE_TIFF: return "tif"; - case FILE_TIFF_LIST: return "tif"; - case FILE_VMPEG: return "m2v"; - case FILE_VORBIS: return "ogg"; - case FILE_WAV: return "wav"; - case FILE_FFMPEG: return "ffmpg"; + switch( format ) { + case FILE_AC3: return "ac3"; + case FILE_AIFF: return "aif"; + case FILE_AMPEG: return "mp3"; + case FILE_AU: return "au"; + case FILE_RAWDV: return "dv"; + case FILE_DB: return "db"; + case FILE_EXR: return "exr"; + case FILE_EXR_LIST: return "exr"; + case FILE_FLAC: return "flac"; + case FILE_JPEG: return "jpg"; + case FILE_JPEG_LIST: return "jpg"; + case FILE_OGG: return "ogg"; + case FILE_PCM: return "pcm"; + case FILE_PNG: return "png"; + case FILE_PNG_LIST: return "png"; + case FILE_TGA: return "tga"; + case FILE_TGA_LIST: return "tga"; + case FILE_TIFF: return "tif"; + case FILE_TIFF_LIST: return "tif"; + case FILE_VMPEG: return "m2v"; + case FILE_VORBIS: return "ogg"; + case FILE_WAV: return "wav"; + case FILE_FFMPEG: return "ffmpg"; } return 0; } const char* File::get_prefix(int format) { - switch(format) { + switch( format ) { case FILE_PCM: return "PCM"; case FILE_WAV: return "WAV"; case FILE_PNG: return "PNG"; @@ -1606,14 +1525,13 @@ const char* File::get_prefix(int format) PackagingEngine *File::new_packaging_engine(Asset *asset) { PackagingEngine *result; - switch (asset->format) - { - case FILE_OGG: - result = (PackagingEngine*)new PackagingEngineOGG(); - break; - default: - result = (PackagingEngine*) new PackagingEngineDefault(); - break; + switch( asset->format ) { + case FILE_OGG: + result = (PackagingEngine*)new PackagingEngineOGG(); + break; + default: + result = (PackagingEngine*) new PackagingEngineDefault(); + break; } return result; @@ -1705,4 +1623,3 @@ void File::init_cin_path() setenv_path(cinbwr_path, "CIN_BROWSER", CIN_BROWSER); } - diff --git a/cinelerra-5.1/cinelerra/file.h b/cinelerra-5.1/cinelerra/file.h index 5378a76f..5e695bcb 100644 --- a/cinelerra-5.1/cinelerra/file.h +++ b/cinelerra-5.1/cinelerra/file.h @@ -246,17 +246,14 @@ public: // The minimum setting for cache_size should be bigger than 1MB. int64_t get_memory_usage(); - static int supports_video(ArrayList *plugindb, char *format); // returns 1 if the format supports video or audio - static int supports_audio(ArrayList *plugindb, char *format); + static int renders_video(Asset *asset); + static int renders_audio(Asset *asset); // Get the extension for the filename static const char* get_tag(int format); static const char* get_prefix(int format); - static int supports_video(int format); // returns 1 if the format supports video or audio - static int supports_audio(int format); static int strtoformat(const char *format); static const char* formattostr(int format); - static int strtoformat(ArrayList *plugindb, const char *format); - static const char* formattostr(ArrayList *plugindb, int format); + static int is_image_render(int format); static int strtobits(const char *bits); static const char* bitstostr(int bits); static int str_to_byteorder(const char *string); diff --git a/cinelerra-5.1/cinelerra/fileffmpeg.C b/cinelerra-5.1/cinelerra/fileffmpeg.C index 27bd7de4..99fa7119 100644 --- a/cinelerra-5.1/cinelerra/fileffmpeg.C +++ b/cinelerra-5.1/cinelerra/fileffmpeg.C @@ -367,6 +367,21 @@ int FileFFMPEG::get_best_colormodel(Asset *asset, int driver) return BC_RGB888; } +int FileFFMPEG::can_render(const char *fformat, const char *type) +{ + FileSystem fs; + char option_path[BCTEXTLEN]; + FFMPEG::set_option_path(option_path, type); + fs.update(option_path); + int total_files = fs.total_files(); + for( int i=0; iget_name(); + const char *ext = strrchr(name,'.'); + if( !ext ) continue; + if( !strcmp(fformat, ++ext) ) return 1; + } + return 0; +} int FileFFMPEG::get_ff_option(const char *nm, const char *options, char *value) { diff --git a/cinelerra-5.1/cinelerra/fileffmpeg.h b/cinelerra-5.1/cinelerra/fileffmpeg.h index edbe437f..51e19151 100644 --- a/cinelerra-5.1/cinelerra/fileffmpeg.h +++ b/cinelerra-5.1/cinelerra/fileffmpeg.h @@ -39,6 +39,9 @@ public: int &width, int &height, char *title=0); int get_audio_for_video(int vstream, int astream, int64_t &channel_mask); static void get_info(char *path,char *text,int len); + static int can_render(const char *fformat, const char *type); + static int renders_audio(const char *fformat) { return can_render(fformat, "audio"); } + static int renders_video(const char *fformat) { return can_render(fformat, "video"); } static int get_ff_option(const char *nm, const char *options, char *value); int open_file(int rd,int wr); int get_index(IndexFile *index_file, MainProgressBar *progress_bar); diff --git a/cinelerra-5.1/cinelerra/formatcheck.C b/cinelerra-5.1/cinelerra/formatcheck.C index 42adf3c8..57d35127 100644 --- a/cinelerra-5.1/cinelerra/formatcheck.C +++ b/cinelerra-5.1/cinelerra/formatcheck.C @@ -42,7 +42,7 @@ int FormatCheck::check_format() if(!result && asset->video_data) { // Only 1 format can store video. - if(!File::supports_video(asset->format)) + if(!File::renders_video(asset)) { ErrorBox errorbox(_(PROGRAM_NAME ": Error")); errorbox.create_objects(_("The format you selected doesn't support video.")); @@ -53,7 +53,7 @@ int FormatCheck::check_format() if(!result && asset->audio_data) { - if(!File::supports_audio(asset->format)) + if(!File::renders_audio(asset)) { ErrorBox errorbox(_(PROGRAM_NAME ": Error")); errorbox.create_objects(_("The format you selected doesn't support audio.")); diff --git a/cinelerra-5.1/cinelerra/formattools.C b/cinelerra-5.1/cinelerra/formattools.C index 4f6580d4..14ef6107 100644 --- a/cinelerra-5.1/cinelerra/formattools.C +++ b/cinelerra-5.1/cinelerra/formattools.C @@ -62,9 +62,7 @@ FormatTools::FormatTools(MWindow *mwindow, format_button = 0; format_text = 0; audio_title = 0; - audio_switch = 0; video_title = 0; - video_switch = 0; channels_title = 0; channels_button = 0; multiple_files = 0; @@ -339,17 +337,17 @@ void FormatTools::update_format() { if( do_audio && prompt_audio && audio_switch ) { audio_switch->update(asset->audio_data); - if( !asset->audio_data ) - audio_switch->disable(); - else + if( File::renders_audio(asset) ) audio_switch->enable(); + else + audio_switch->disable(); } if( do_video && prompt_video && video_switch ) { video_switch->update(asset->video_data); - if( !asset->video_data ) - video_switch->disable(); - else + if( File::renders_video(asset) ) video_switch->enable(); + else + video_switch->disable(); } if( asset->format == FILE_FFMPEG ) { ffmpeg_type->show(); @@ -453,11 +451,8 @@ void FormatTools::update(Asset *asset, int *strategy) if(path_textbox) path_textbox->update(asset->path); - format_text->update(File::formattostr(plugindb, asset->format)); - if(do_audio && prompt_audio && audio_switch) - audio_switch->update(asset->audio_data); - if(do_video && prompt_video && video_switch) - video_switch->update(asset->video_data); + format_text->update(File::formattostr(asset->format)); + update_format(); if(strategy) { multiple_files->update(strategy); @@ -788,13 +783,13 @@ int FormatFormat::handle_event() { BC_ListBoxItem *selection = get_selection(0, 0); if( selection ) { - int new_format = File::strtoformat(format->plugindb, get_selection(0, 0)->get_text()); + int new_format = File::strtoformat(get_selection(0, 0)->get_text()); // if(new_format != format->asset->format) { Asset *asset = format->asset; asset->format = new_format; - asset->audio_data = File::supports_audio(asset->format); - asset->video_data = File::supports_video(asset->format); + asset->audio_data = File::renders_audio(asset); + asset->video_data = File::renders_video(asset); asset->ff_audio_options[0] = 0; asset->ff_video_options[0] = 0; format->format_text->update(selection->get_text()); diff --git a/cinelerra-5.1/cinelerra/formattools.h b/cinelerra-5.1/cinelerra/formattools.h index d471db8b..d4c7761b 100644 --- a/cinelerra-5.1/cinelerra/formattools.h +++ b/cinelerra-5.1/cinelerra/formattools.h @@ -70,7 +70,7 @@ public: // In recording preferences, aspects of the format are locked // depending on the driver used. void update_driver(int driver); - void update_format(); + virtual void update_format(); void reposition_window(int &init_x, int &init_y); diff --git a/cinelerra-5.1/cinelerra/interfaceprefs.C b/cinelerra-5.1/cinelerra/interfaceprefs.C index d463fb24..556bc8bd 100644 --- a/cinelerra-5.1/cinelerra/interfaceprefs.C +++ b/cinelerra-5.1/cinelerra/interfaceprefs.C @@ -81,7 +81,8 @@ void InterfacePrefs::create_objects() BC_Title *title; add_subwindow(title = new BC_Title(x, y, _("Keyframe reticle:"))); y += 25; - keyframe_reticle = new KeyframeReticle(x, y, &pwindow->thread->preferences->keyframe_reticle); + keyframe_reticle = new KeyframeReticle(pwindow, this, x, y, + &pwindow->thread->preferences->keyframe_reticle); add_subwindow(keyframe_reticle); keyframe_reticle->create_objects(); @@ -495,15 +496,19 @@ HairlineItem::~HairlineItem() int HairlineItem::handle_event() { + popup->pwindow->thread->redraw_overlays = 1; popup->set_text(get_text()); *(popup->output) = hairline; return 1; } -KeyframeReticle::KeyframeReticle(int x, int y, int *output) +KeyframeReticle::KeyframeReticle(PreferencesWindow *pwindow, + InterfacePrefs *iface_prefs, int x, int y, int *output) : BC_PopupMenu(x, y, 175, hairline_to_string(*output)) { + this->pwindow = pwindow; + this->iface_prefs = iface_prefs; this->output = output; } diff --git a/cinelerra-5.1/cinelerra/interfaceprefs.h b/cinelerra-5.1/cinelerra/interfaceprefs.h index 12d43a31..d4efc81f 100644 --- a/cinelerra-5.1/cinelerra/interfaceprefs.h +++ b/cinelerra-5.1/cinelerra/interfaceprefs.h @@ -173,7 +173,8 @@ public: InterfacePrefs *iface_prefs; int handle_event(); - ShBtnPrefs(PreferencesWindow *pwindow, InterfacePrefs *iface_prefs, int x, int y); + ShBtnPrefs(PreferencesWindow *pwindow, + InterfacePrefs *iface_prefs, int x, int y); }; class StillImageUseDuration : public BC_CheckBox { @@ -194,11 +195,15 @@ public: class KeyframeReticle : public BC_PopupMenu { public: - KeyframeReticle(int x, int y, int *output); + KeyframeReticle(PreferencesWindow *pwindow, + InterfacePrefs *iface_prefs, int x, int y, int *output); ~KeyframeReticle(); - const char* hairline_to_string(int type); + const char *hairline_to_string(int type); void create_objects(); + + PreferencesWindow *pwindow; + InterfacePrefs *iface_prefs; int *output; }; diff --git a/cinelerra-5.1/cinelerra/menuaeffects.C b/cinelerra-5.1/cinelerra/menuaeffects.C index 6d9983c5..643267de 100644 --- a/cinelerra-5.1/cinelerra/menuaeffects.C +++ b/cinelerra-5.1/cinelerra/menuaeffects.C @@ -74,7 +74,7 @@ int MenuAEffectThread::get_derived_attributes(Asset *asset, BC_Hash *defaults) // Fix asset for audio only - if(!File::supports_audio(asset->format)) asset->format = FILE_WAV; + if(!File::renders_audio(asset)) asset->format = FILE_WAV; asset->audio_data = 1; asset->video_data = 0; diff --git a/cinelerra-5.1/cinelerra/menuveffects.C b/cinelerra-5.1/cinelerra/menuveffects.C index 733ad2ce..02368fee 100644 --- a/cinelerra-5.1/cinelerra/menuveffects.C +++ b/cinelerra-5.1/cinelerra/menuveffects.C @@ -67,7 +67,7 @@ int MenuVEffectThread::get_derived_attributes(Asset *asset, BC_Hash *defaults) asset->load_defaults(defaults, "VEFFECT_", 1, 1, 1, 0, 0); // Fix asset for video only - if(!File::supports_video(asset->format)) { + if(!File::renders_video(asset)) { asset->format = FILE_FFMPEG; strcpy(asset->vcodec, "mp4"); } diff --git a/cinelerra-5.1/cinelerra/record.C b/cinelerra-5.1/cinelerra/record.C index 719c8869..4cd0ae44 100644 --- a/cinelerra-5.1/cinelerra/record.C +++ b/cinelerra-5.1/cinelerra/record.C @@ -1095,8 +1095,8 @@ void Record::start_writing_file() if( !writing_file ) { written_frames = 0; written_samples = 0; - do_video = File::supports_video(default_asset->format); - do_audio = File::supports_audio(default_asset->format); + do_video = File::renders_video(default_asset); + do_audio = File::renders_audio(default_asset); if( single_frame ) do_audio = 0; if( !do_video && single_frame ) single_frame = 0; diff --git a/cinelerra-5.1/cinelerra/recordgui.C b/cinelerra-5.1/cinelerra/recordgui.C index 1e95c612..00b257e9 100644 --- a/cinelerra-5.1/cinelerra/recordgui.C +++ b/cinelerra-5.1/cinelerra/recordgui.C @@ -265,7 +265,7 @@ void RecordGUI::create_objects() x = x3 + x2 + x1 + 40; add_subwindow(new BC_Title(x, y, - File::formattostr(mwindow->plugindb, asset->format), + File::formattostr(asset->format), MEDIUMFONT, mwindow->theme->recordgui_fixed_color)); y += pad; diff --git a/cinelerra-5.1/cinelerra/render.C b/cinelerra-5.1/cinelerra/render.C index 34b5c7dc..6667cbbb 100644 --- a/cinelerra-5.1/cinelerra/render.C +++ b/cinelerra-5.1/cinelerra/render.C @@ -270,9 +270,9 @@ void Render::start_interactive() BC_DialogThread::start(); } else if( in_progress ) { - ErrorBox error_box(_(PROGRAM_NAME ": Error"), - mwindow->gui->get_abs_cursor_x(1), - mwindow->gui->get_abs_cursor_y(1)); + int cx, cy; + mwindow->gui->get_abs_cursor_xy(cx, cy, 1); + ErrorBox error_box(_(PROGRAM_NAME ": Error"), cx, cy); error_box.create_objects(_("Already rendering")); error_box.raise_window(); error_box.run_window(); @@ -294,9 +294,9 @@ void Render::start_batches(ArrayList *jobs) start_render(); } else if( in_progress ) { - ErrorBox error_box(_(PROGRAM_NAME ": Error"), - mwindow->gui->get_abs_cursor_x(1), - mwindow->gui->get_abs_cursor_y(1)); + int cx, cy; + mwindow->gui->get_abs_cursor_xy(cx, cy, 1); + ErrorBox error_box(_(PROGRAM_NAME ": Error"), cx, cy); error_box.create_objects("Already rendering"); error_box.raise_window(); error_box.run_window(); @@ -328,7 +328,6 @@ BC_Window* Render::new_gui() { this->jobs = 0; batch_cancelled = 0; - format_error = 0; result = 0; if(mode == Render::INTERACTIVE) { @@ -350,7 +349,7 @@ void Render::handle_done_event(int result) { if(!result) { // add to recentlist only on OK - render_window->format_tools->path_recent-> + render_window->render_format->path_recent-> add_item(File::formattostr(asset->format), asset->path); } render_window = 0; @@ -358,13 +357,55 @@ void Render::handle_done_event(int result) void Render::handle_close_event(int result) { - int format_error = 0; const int debug = 0; + double render_range = get_render_range(); + const char *err_msg = 0; + + if( !result && !render_range ) { + err_msg = _("zero render range"); + result = 1; + } + if( !result && asset->video_data ) { + double frame_rate = mwindow->edl->session->frame_rate; + if( frame_rate > 0 && render_range+1e-3 < 1./frame_rate ) { + err_msg = _("Video data and range less than 1 frame"); + result = 1; + } + } + if( !result && asset->audio_data ) { + double sample_rate = mwindow->edl->session->sample_rate; + if( sample_rate > 0 && render_range+1e-6 < 1./sample_rate ) { + err_msg = _("Audio data and range less than 1 sample"); + result = 1; + } + } + if( !result && File::is_image_render(asset->format) ) { + if( asset->video_data ) { + double frames = render_range * mwindow->edl->session->frame_rate; + if( !EQUIV(frames, 1.) ) { + err_msg = _("Image format and not 1 frame"); + result = 1; + } + } + else { + err_msg = _("Image format and no video data"); + result = 1; + } + } + if( err_msg ) { + int cx, cy; + mwindow->gui->get_abs_cursor_xy(cx, cy, 1); + ErrorBox error_box(_(PROGRAM_NAME ": Error"),cx, cy); + error_box.create_objects(err_msg); + error_box.raise_window(); + error_box.run_window(); + } if(!result) { // Check the asset format for errors. FormatCheck format_check(asset); - format_error = format_check.check_format(); + if( format_check.check_format() ) + result = 1; } //PRINT_TRACE @@ -374,8 +415,7 @@ void Render::handle_close_event(int result) mwindow->save_defaults(); //PRINT_TRACE - if(!format_error && !result) - { + if( !result ) { if(debug) printf("Render::handle_close_event %d\n", __LINE__); if(!result) start_render(); if(debug) printf("Render::handle_close_event %d\n", __LINE__); @@ -402,7 +442,7 @@ int Render::check_asset(EDL *edl, Asset &asset) { if(asset.video_data && edl->tracks->playable_video_tracks() && - File::supports_video(asset.format)) + File::renders_video(&asset)) { asset.video_data = 1; asset.layers = 1; @@ -418,7 +458,7 @@ int Render::check_asset(EDL *edl, Asset &asset) if(asset.audio_data && edl->tracks->playable_audio_tracks() && - File::supports_audio(asset.format)) + File::renders_audio(&asset)) { asset.audio_data = 1; asset.channels = edl->session->audio_channels; @@ -658,11 +698,8 @@ RenderThread::~RenderThread() } -void RenderThread::render_single(int test_overwrite, - Asset *asset, - EDL *edl, - int strategy, - int range_type) +void RenderThread::render_single(int test_overwrite, Asset *asset, EDL *edl, + int strategy, int range_type) { // Total length in seconds double total_length; @@ -693,20 +730,25 @@ void RenderThread::render_single(int test_overwrite, command->get_edl()->copy_all(edl); command->change_type = CHANGE_ALL; - if (range_type == RANGE_BACKCOMPAT) { + switch( range_type ) { + case RANGE_BACKCOMPAT: // Get highlighted playback range command->set_playback_range(); // Adjust playback range with in/out points command->playback_range_adjust_inout(); - } - else if (range_type == RANGE_PROJECT) { + break; + case RANGE_PROJECT: command->playback_range_project(); - } - else if (range_type == RANGE_SELECTION) { + break; + case RANGE_SELECTION: command->set_playback_range(); - } - else if (range_type == RANGE_INOUT) { + break; + case RANGE_INOUT: command->playback_range_inout(); + break; + case RANGE_1FRAME: + command->playback_range_1frame(); + break; } render->packages = new PackageDispatcher; @@ -887,9 +929,9 @@ if(debug) printf("Render::render %d\n", __LINE__); if(mwindow) { if(debug) printf("Render::render %d\n", __LINE__); - ErrorBox error_box(_(PROGRAM_NAME ": Error"), - mwindow->gui->get_abs_cursor_x(1), - mwindow->gui->get_abs_cursor_y(1)); + int cx, cy; + mwindow->gui->get_abs_cursor_xy(cx, cy, 1); + ErrorBox error_box(_(PROGRAM_NAME ": Error"), cx, cy); error_box.create_objects(_("Error rendering data.")); error_box.raise_window(); error_box.run_window(); @@ -996,7 +1038,8 @@ void RenderThread::run() { if(render->mode == Render::INTERACTIVE) { - render_single(1, render->asset, mwindow->edl, render->strategy, render->range_type); + render_single(1, render->asset, mwindow->edl, + render->strategy, render->range_type); } else if(render->mode == Render::BATCH) @@ -1077,7 +1120,7 @@ void RenderThread::run() } -#define WIDTH 440 +#define WIDTH 480 #define HEIGHT 455 @@ -1092,6 +1135,10 @@ RenderWindow::RenderWindow(MWindow *mwindow, this->mwindow = mwindow; this->render = render; this->asset = asset; + rangeproject = 0; + rangeselection = 0; + rangeinout = 0; + range1frame = 0; } RenderWindow::~RenderWindow() @@ -1099,7 +1146,7 @@ RenderWindow::~RenderWindow() SET_TRACE lock_window("RenderWindow::~RenderWindow"); SET_TRACE - delete format_tools; + delete render_format; SET_TRACE delete loadmode; SET_TRACE @@ -1112,39 +1159,46 @@ void RenderWindow::load_profile(int profile_slot) { render->load_profile(profile_slot, asset); update_range_type(render->range_type); - format_tools->update(asset, &render->strategy); + render_format->update(asset, &render->strategy); } void RenderWindow::create_objects() { - int x = 10, y = 5; + int x = 10, y = 10; lock_window("RenderWindow::create_objects"); - add_subwindow(new BC_Title(x, - y, + add_subwindow(new BC_Title(x, y, (char*)((render->strategy == FILE_PER_LABEL || render->strategy == FILE_PER_LABEL_FARM) ? _("Select the first file to render to:") : _("Select a file to render to:")))); y += 25; - format_tools = new FormatTools(mwindow, this, asset); - format_tools->create_objects(x, y, + render_format = new RenderFormat(mwindow, this, asset); + render_format->create_objects(x, y, 1, 1, 1, 1, 0, 1, 0, 0, &render->strategy, 0); - add_subwindow(new BC_Title(x, y, _("Render range:"))); + BC_Title *title; + add_subwindow(title = new BC_Title(x, y, _("Render range:"))); - x += 110; + int is_image = File::is_image_render(asset->format); + if( is_image ) + render->range_type = RANGE_1FRAME; + + int x1 = x + title->get_w() + 20, x2 = x1 + 140; add_subwindow(rangeproject = new RenderRangeProject(this, - render->range_type == RANGE_PROJECT, x, y)); + render->range_type == RANGE_PROJECT, x1, y)); + add_subwindow(range1frame = new RenderRange1Frame(this, + render->range_type == RANGE_1FRAME, x2, y)); y += 20; add_subwindow(rangeselection = new RenderRangeSelection(this, - render->range_type == RANGE_SELECTION, x, y)); - y += 20; + render->range_type == RANGE_SELECTION, x1, y)); add_subwindow(rangeinout = new RenderRangeInOut(this, - render->range_type == RANGE_INOUT, x, y)); + render->range_type == RANGE_INOUT, x2, y)); y += 30; - x = 5; + + if( is_image ) + enable_render_range(0); renderprofile = new RenderProfile(mwindow, this, x, y, 1); renderprofile->create_objects(); @@ -1155,16 +1209,35 @@ void RenderWindow::create_objects() add_subwindow(new BC_OKButton(this)); add_subwindow(new BC_CancelButton(this)); + show_window(); unlock_window(); } void RenderWindow::update_range_type(int range_type) { + if( render->range_type == range_type ) return; render->range_type = range_type; rangeproject->update(range_type == RANGE_PROJECT); rangeselection->update(range_type == RANGE_SELECTION); rangeinout->update(range_type == RANGE_INOUT); + range1frame->update(range_type == RANGE_1FRAME); +} + +void RenderWindow::enable_render_range(int v) +{ + if( v ) { + rangeproject->enable(); + rangeselection->enable(); + rangeinout->enable(); + range1frame->enable(); + } + else { + rangeproject->disable(); + rangeselection->disable(); + rangeinout->disable(); + range1frame->disable(); + } } @@ -1202,4 +1275,73 @@ int RenderRangeInOut::handle_event() return 1; } +RenderRange1Frame::RenderRange1Frame(RenderWindow *rwindow, int value, int x, int y) + : BC_Radial(x, y, value, _("One Frame")) +{ + this->rwindow = rwindow; +} +int RenderRange1Frame::handle_event() +{ + rwindow->update_range_type(RANGE_1FRAME); + return 1; +} + +double Render::get_render_range() +{ + EDL *edl = mwindow->edl; + double last = edl->tracks->total_playable_length(); + double framerate = edl->session->frame_rate; + if( framerate <= 0 ) framerate = 1; + double start = 0, end = last; + switch( range_type ) { + default: + case RANGE_BACKCOMPAT: + start = edl->local_session->get_selectionstart(1); + end = edl->local_session->get_selectionend(1); + if( EQUIV(start, end) ) end = last; + break; + case RANGE_PROJECT: + break; + case RANGE_SELECTION: + start = edl->local_session->get_selectionstart(1); + end = edl->local_session->get_selectionend(1); + break; + case RANGE_INOUT: + start = edl->local_session->inpoint_valid() ? + edl->local_session->get_inpoint() : 0; + end = edl->local_session->outpoint_valid() ? + edl->local_session->get_outpoint() : last; + break; + case RANGE_1FRAME: + start = end = edl->local_session->get_selectionstart(1); + if( edl->session->frame_rate > 0 ) end += 1./edl->session->frame_rate; + break; + } + if( start < 0 ) start = 0; + if( end > last ) end = last; + return end - start; +} + +RenderFormat::RenderFormat(MWindow *mwindow, BC_WindowBase *window, Asset *asset) + : FormatTools(mwindow, window, asset) +{ +} +RenderFormat::~RenderFormat() +{ +} + +void RenderFormat::update_format() +{ + FormatTools::update_format(); + RenderWindow *render_window = (RenderWindow *)window; + if( render_window->is_hidden() ) return; + + int is_image = File::is_image_render(asset->format); + if( is_image ) { + render_window->update_range_type(RANGE_1FRAME); + render_window->enable_render_range(0); + } + else + render_window->enable_render_range(1); +} diff --git a/cinelerra-5.1/cinelerra/render.h b/cinelerra-5.1/cinelerra/render.h index 357af62f..6faf5589 100644 --- a/cinelerra-5.1/cinelerra/render.h +++ b/cinelerra-5.1/cinelerra/render.h @@ -36,7 +36,7 @@ #include "errorbox.inc" #include "file.inc" #include "formatpopup.inc" -#include "formattools.inc" +#include "formattools.h" #include "guicast.h" #include "loadmode.inc" #include "mainprogress.inc" @@ -125,6 +125,7 @@ public: int load_defaults(Asset *asset); int save_defaults(Asset *asset); int load_profile(int profile_slot, Asset *asset); + double get_render_range(); // force asset parameters regardless of window // This should be integrated into the Asset Class. static int check_asset(EDL *edl, Asset &asset); @@ -184,7 +185,6 @@ public: double total_start, total_end; // External Render farm checks this every frame. int result; - int format_error; Asset *default_asset; // Asset containing the file format Asset *asset; @@ -257,6 +257,23 @@ public: }; +class RenderRange1Frame : public BC_Radial +{ +public: + RenderRange1Frame(RenderWindow *rwindow, int value, int x, int y); + int handle_event(); + RenderWindow *rwindow; +}; + + +class RenderFormat : public FormatTools +{ +public: + RenderFormat(MWindow *mwindow, BC_WindowBase *window, Asset *asset); + ~RenderFormat(); + void update_format(); +}; + class RenderWindow : public BC_Window { @@ -269,33 +286,23 @@ public: ~RenderWindow(); void create_objects(); + void enable_render_range(int v); void update_range_type(int range_type); void load_profile(int profile_slot); RenderRangeProject *rangeproject; RenderRangeSelection *rangeselection; RenderRangeInOut *rangeinout; + RenderRange1Frame *range1frame; RenderProfile *renderprofile; LoadMode *loadmode; - FormatTools *format_tools; + RenderFormat *render_format; MWindow *mwindow; Render *render; Asset *asset; }; - - - - - - - - - - - - #endif diff --git a/cinelerra-5.1/cinelerra/render.inc b/cinelerra-5.1/cinelerra/render.inc index 1b4c1e28..e5866df1 100644 --- a/cinelerra-5.1/cinelerra/render.inc +++ b/cinelerra-5.1/cinelerra/render.inc @@ -42,5 +42,6 @@ class RenderWindow; #define RANGE_PROJECT 1 #define RANGE_SELECTION 2 #define RANGE_INOUT 3 +#define RANGE_1FRAME 4 #endif diff --git a/cinelerra-5.1/cinelerra/transportque.C b/cinelerra-5.1/cinelerra/transportque.C index 4a880ee0..fef68582 100644 --- a/cinelerra-5.1/cinelerra/transportque.C +++ b/cinelerra-5.1/cinelerra/transportque.C @@ -256,19 +256,11 @@ void TransportCommand::playback_range_project() end_position = edl->tracks->total_playable_length(); } - - - - - - - - - - - - - +void TransportCommand::playback_range_1frame() +{ + start_position = end_position = edl->local_session->get_selectionstart(1); + if( edl->session->frame_rate > 0 ) end_position += 1./edl->session->frame_rate; +} TransportQue::TransportQue() diff --git a/cinelerra-5.1/cinelerra/transportque.h b/cinelerra-5.1/cinelerra/transportque.h index 5082c1a6..5093b0ea 100644 --- a/cinelerra-5.1/cinelerra/transportque.h +++ b/cinelerra-5.1/cinelerra/transportque.h @@ -49,6 +49,7 @@ public: void playback_range_inout(); // Set playback range to whole project for rendering void playback_range_project(); + void playback_range_1frame(); int single_frame(); EDL* get_edl(); diff --git a/cinelerra-5.1/configure.ac b/cinelerra-5.1/configure.ac index 48f55f28..ab5c9430 100644 --- a/cinelerra-5.1/configure.ac +++ b/cinelerra-5.1/configure.ac @@ -299,7 +299,7 @@ PKG_3RD([x264],[auto], [ . ]) PKG_3RD([x265],[auto], - [x265_2.4], + [x265_2.5], [ libx265.a ], [ . source ]) diff --git a/cinelerra-5.1/plugins/crikey/crikeywindow.C b/cinelerra-5.1/plugins/crikey/crikeywindow.C index 06693891..9b7bd82e 100644 --- a/cinelerra-5.1/plugins/crikey/crikeywindow.C +++ b/cinelerra-5.1/plugins/crikey/crikeywindow.C @@ -155,6 +155,8 @@ int CriKeyColorPicker::handle_new_color(int color, int alpha) gui->lock_window("CriKeyColorPicker::handle_new_color"); gui->update_color(this->color = color); gui->flush(); + gui->plugin->config.color = color; + gui->plugin->send_configure_change(); gui->unlock_window(); return 1; } @@ -215,6 +217,15 @@ int CriKeyWindow::grab_event(XEvent *event) { if( key_mode->mode != KEY_POINT ) return 0; + MWindow *mwindow = plugin->server->mwindow; + CWindowGUI *cwindow_gui = mwindow->cwindow->gui; + CWindowCanvas *canvas = cwindow_gui->canvas; + int cx, cy; canvas->get_canvas()->get_relative_cursor_xy(cx, cy); + if( cx < mwindow->theme->ccanvas_x ) return 0; + if( cx >= mwindow->theme->ccanvas_x+mwindow->theme->ccanvas_w ) return 0; + if( cy < mwindow->theme->ccanvas_y ) return 0; + if( cy >= mwindow->theme->ccanvas_y+mwindow->theme->ccanvas_h ) return 0; + switch( event->type ) { case ButtonPress: if( dragging ) return 0; @@ -229,11 +240,8 @@ int CriKeyWindow::grab_event(XEvent *event) default: return 0; } - MWindow *mwindow = plugin->server->mwindow; - CWindowGUI *cwindow_gui = mwindow->cwindow->gui; - CWindowCanvas *canvas = cwindow_gui->canvas; - float cursor_x = canvas->get_canvas()->get_relative_cursor_x(); - float cursor_y = canvas->get_canvas()->get_relative_cursor_y(); + + float cursor_x = cx, cursor_y = cy; canvas->canvas_to_output(mwindow->edl, 0, cursor_x, cursor_y); int64_t position = plugin->get_source_position(); float projector_x, projector_y, projector_z; diff --git a/cinelerra-5.1/plugins/titler/titlerwindow.C b/cinelerra-5.1/plugins/titler/titlerwindow.C index 74a4aadf..01cddf4f 100644 --- a/cinelerra-5.1/plugins/titler/titlerwindow.C +++ b/cinelerra-5.1/plugins/titler/titlerwindow.C @@ -465,6 +465,15 @@ int TitleWindow::resize_event(int w, int h) int TitleWindow::grab_event(XEvent *event) { + MWindow *mwindow = client->server->mwindow; + CWindowGUI *cwindow_gui = mwindow->cwindow->gui; + CWindowCanvas *canvas = cwindow_gui->canvas; + int cx, cy; canvas->get_canvas()->get_relative_cursor_xy(cx, cy); + if( cx < mwindow->theme->ccanvas_x ) return 0; + if( cx >= mwindow->theme->ccanvas_x+mwindow->theme->ccanvas_w ) return 0; + if( cy < mwindow->theme->ccanvas_y ) return 0; + if( cy >= mwindow->theme->ccanvas_y+mwindow->theme->ccanvas_h ) return 0; + switch( event->type ) { case ButtonPress: if( !dragging ) break; @@ -478,11 +487,8 @@ int TitleWindow::grab_event(XEvent *event) default: return 0; } - MWindow *mwindow = client->server->mwindow; - CWindowGUI *cwindow_gui = mwindow->cwindow->gui; - CWindowCanvas *canvas = cwindow_gui->canvas; - float cursor_x = canvas->get_canvas()->get_relative_cursor_x(); - float cursor_y = canvas->get_canvas()->get_relative_cursor_y(); + + float cursor_x = cx, cursor_y = cy; canvas->canvas_to_output(mwindow->edl, 0, cursor_x, cursor_y); int64_t position = client->get_source_position(); float projector_x, projector_y, projector_z; @@ -504,7 +510,7 @@ int TitleWindow::grab_event(XEvent *event) int y0 = title_y, y1 = title_y+(title_h+1)/2, y2 = title_y+title_h; int drag_dx = 0, drag_dy = 0; if( !dragging ) { // clockwise - if( abs(drag_dx = cursor_x-x0) < r && // x0,y0 + if( abs(drag_dx = cursor_x-x0) < r && // x0,y0 abs(drag_dy = cursor_y-y0) < r ) dragging = 1; else if( abs(drag_dx = cursor_x-x1) < r && // x1,y0 abs(drag_dy = cursor_y-y0) < r ) dragging = 2; diff --git a/cinelerra-5.1/thirdparty/src/x265_2.4.tar.xz b/cinelerra-5.1/thirdparty/src/x265_2.4.tar.xz deleted file mode 100644 index 79f74c0e..00000000 Binary files a/cinelerra-5.1/thirdparty/src/x265_2.4.tar.xz and /dev/null differ diff --git a/cinelerra-5.1/thirdparty/src/x265_2.5.tar.xz b/cinelerra-5.1/thirdparty/src/x265_2.5.tar.xz new file mode 100644 index 00000000..55e6976a Binary files /dev/null and b/cinelerra-5.1/thirdparty/src/x265_2.5.tar.xz differ