X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Ffile.C;h=bc1a6290ef3388240d40b903c0d149278bf68b94;hb=74afbc29ac4ce9d94d53e10342979f2c59f1f193;hp=2da3eff10aa51fa44a89a3dd030608e0b20b2680;hpb=9d5997d77ab7736be577456d8fd3dda0ba522d39;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/cinelerra/file.C b/cinelerra-5.1/cinelerra/file.C index 2da3eff1..bc1a6290 100644 --- a/cinelerra-5.1/cinelerra/file.C +++ b/cinelerra-5.1/cinelerra/file.C @@ -75,6 +75,7 @@ #include "samples.h" #include "vframe.h" +//static int temp_debug = 0; //suppress noref warning void *vorbis0_ov_callbacks[] = { &OV_CALLBACKS_DEFAULT, &OV_CALLBACKS_NOCLOSE, @@ -99,8 +100,10 @@ File::~File() format_completion->unlock(); } - if( temp_frame ) delete temp_frame; - + if( temp_frame ) { +//printf("File::~File %d temp_debug=%d\n", __LINE__, --temp_debug); + delete temp_frame; + } close_file(0); @@ -298,7 +301,6 @@ void File::set_white_balance_raw(int value) this->white_balance_raw = value; } - void File::set_cache_frames(int value) { // caching only done locally @@ -319,7 +321,7 @@ int File::purge_cache() int File::delete_oldest() { -// caching only done locally +// return the number of bytes freed return frame_cache->delete_oldest(); } @@ -474,8 +476,6 @@ 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 %p %d\n", this, __LINE__); switch( this->asset->format ) { @@ -1113,14 +1113,7 @@ int File::read_frame(VFrame *frame, int is_thread) const int debug = 0; //printf("File::read_frame pos=%jd cache=%d 1frame=%d\n", // current_frame, use_cache, asset->single_frame); - if( debug ) PRINT_TRACE - -//printf("File::read_frame %d\n", __LINE__); - if( video_thread && !is_thread ) return video_thread->read_frame(frame); - -//printf("File::read_frame %d\n", __LINE__); - if( debug ) PRINT_TRACE if( !file ) return 1; if( debug ) PRINT_TRACE int result = 0; @@ -1128,6 +1121,7 @@ int File::read_frame(VFrame *frame, int is_thread) int advance_position = 1; int cache_active = use_cache || asset->single_frame ? 1 : 0; 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) ) { @@ -1138,8 +1132,9 @@ int File::read_frame(VFrame *frame, int is_thread) // Need temp else if( frame->get_color_model() != BC_COMPRESSED && (supported_colormodel != frame->get_color_model() || - frame->get_w() != asset->width || - frame->get_h() != asset->height) ) { + (!file->can_scale_input() && + (frame->get_w() != asset->width || + 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 @@ -1150,14 +1145,8 @@ int File::read_frame(VFrame *frame, int is_thread) } } -// printf("File::read_frame %d\n", __LINE__); if( !temp_frame ) { - temp_frame = new VFrame(0, - -1, - asset->width, - asset->height, - supported_colormodel, - -1); + temp_frame = new VFrame(asset->width, asset->height, supported_colormodel, 0); } // printf("File::read_frame %d\n", __LINE__); @@ -1191,10 +1180,7 @@ int File::read_frame(VFrame *frame, int is_thread) return 0; } -int File::can_copy_from(Asset *asset, - int64_t position, - int output_w, - int output_h) +int File::can_copy_from(Asset *asset, int64_t position, int output_w, int output_h) { if( asset && file ) { return asset->width == output_w && @@ -1331,12 +1317,10 @@ int File::bytes_per_sample(int bits) } - - - -int File::get_best_colormodel(int driver) +int File::get_best_colormodel(int driver, int vstream) { - return get_best_colormodel(asset, driver); + return file ? file->get_best_colormodel(driver, vstream) : + get_best_colormodel(asset, driver); } int File::get_best_colormodel(Asset *asset, int driver) @@ -1394,10 +1378,9 @@ int64_t File::get_memory_usage() } -int File::renders_video(Asset *asset) +int File::renders_video(int format) { -//printf("File::supports_video %d\n", format); - switch( asset->format ) { + switch( format ) { case FILE_OGG: case FILE_JPEG: case FILE_JPEG_LIST: @@ -1413,16 +1396,21 @@ int File::renders_video(Asset *asset) case FILE_TIFF_LIST: case FILE_VMPEG: case FILE_RAWDV: - return 1; case FILE_FFMPEG: - return FileFFMPEG::renders_video(asset->fformat); + return 1; } return 0; } +int File::renders_video(Asset *asset) +{ + return asset->format == FILE_FFMPEG ? + FileFFMPEG::renders_video(asset->fformat) : + renders_video(asset->format); +} -int File::renders_audio(Asset *asset) +int File::renders_audio(int format) { - switch( asset->format ) { + switch( format ) { case FILE_AC3: case FILE_FLAC: case FILE_PCM: @@ -1434,12 +1422,17 @@ int File::renders_audio(Asset *asset) case FILE_AIFF: case FILE_SND: case FILE_RAWDV: - return 1; case FILE_FFMPEG: - return FileFFMPEG::renders_audio(asset->fformat); + return 1; } return 0; } +int File::renders_audio(Asset *asset) +{ + return asset->format == FILE_FFMPEG ? + FileFFMPEG::renders_audio(asset->fformat) : + renders_audio(asset->format); +} int File::is_image_render(int format) { @@ -1585,42 +1578,26 @@ void File::getenv_path(char *result, const char *path) *rp = 0; } -void File::setenv_path(char *result, const char *var, const char *path) +void File::setenv_path(const char *var, const char *path, int overwrite) { - char *env = getenv(var); - if( env ) return; char env_path[BCTEXTLEN]; getenv_path(env_path, path); - sprintf(result, "%s=%s", var, env_path); - putenv(result); + setenv(var, env_path, overwrite); } -char File::cinexe_path[BCTEXTLEN]; -char File::cinpkg_path[BCTEXTLEN]; -char File::cindat_path[BCTEXTLEN]; -char File::cinlib_path[BCTEXTLEN]; -char File::cincfg_path[BCTEXTLEN]; -char File::cinplg_path[BCTEXTLEN]; -char File::cinlad_path[BCTEXTLEN]; -char File::cinlcl_path[BCTEXTLEN]; -char File::cinbwr_path[BCTEXTLEN]; - void File::init_cin_path() { char env_path[BCTEXTLEN], env_pkg[BCTEXTLEN]; // these values are advertised for forks/shell scripts get_exe_path(env_path, env_pkg); - snprintf(cinexe_path, sizeof(cinexe_path), "CIN_PATH=%s", env_path); - putenv(cinexe_path); - snprintf(cinpkg_path, sizeof(cinpkg_path), "CIN_PKG=%s", env_pkg); - putenv(cinpkg_path); - - setenv_path(cindat_path, "CIN_DAT", CINDAT_DIR); - setenv_path(cinlib_path, "CIN_LIB", CINLIB_DIR); - setenv_path(cincfg_path, "CIN_CONFIG", CONFIG_DIR); - setenv_path(cinplg_path, "CIN_PLUGIN", PLUGIN_DIR); - setenv_path(cinlad_path, "CIN_LADSPA", LADSPA_DIR); - setenv_path(cinlcl_path, "CIN_LOCALE", LOCALE_DIR); - setenv_path(cinbwr_path, "CIN_BROWSER", CIN_BROWSER); + setenv_path("CIN_PATH", env_path, 1); + setenv_path("CIN_PKG", env_pkg, 1); + setenv_path("CIN_DAT", CINDAT_DIR, 0); + setenv_path("CIN_LIB", CINLIB_DIR, 0); + setenv_path("CIN_CONFIG", CONFIG_DIR, 0); + setenv_path("CIN_PLUGIN", PLUGIN_DIR, 0); + setenv_path("CIN_LADSPA", LADSPA_DIR, 0); + setenv_path("CIN_LOCALE", LOCALE_DIR, 0); + setenv_path("CIN_BROWSER", CIN_BROWSER, 0); }