X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Ffile.C;h=fbc03adf1dfc9460c92db0a7344381669f0fea20;hb=9db053d413fde01439cc72ec2109913dfda2ec7b;hp=b9d161e93fcdafe9bda24e0af7647c79de8e32fc;hpb=089f2be86316b88f72a6c359ab10e2b95539005b;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/cinelerra/file.C b/cinelerra-5.1/cinelerra/file.C index b9d161e9..fbc03adf 100644 --- a/cinelerra-5.1/cinelerra/file.C +++ b/cinelerra-5.1/cinelerra/file.C @@ -623,9 +623,12 @@ int File::open_file(Preferences *preferences, if( rd ) { // one frame image file, no specific length - if( !this->asset->audio_data && this->asset->video_data && - this->asset->video_length <= 1 ) + if( !this->asset->audio_data && + this->asset->video_data && !this->asset->single_frame && + this->asset->video_length >= 0 && this->asset->video_length <= 1 ) { + this->asset->single_frame = 1; this->asset->video_length = -1; + } } // Synchronize header parameters @@ -1124,7 +1127,7 @@ 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 (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; @@ -1171,10 +1174,11 @@ int File::read_frame(VFrame *frame, int is_thread) if(debug) PRINT_TRACE if( !file ) return 1; if(debug) PRINT_TRACE + int result = 0; int supported_colormodel = colormodel_supported(frame->get_color_model()); int advance_position = 1; - int cache_active = use_cache || asset->video_length < 0 ? 1 : 0; - int64_t cache_position = asset->video_length >= 0 ? current_frame : -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) ) @@ -1214,37 +1218,26 @@ int File::read_frame(VFrame *frame, int is_thread) // printf("File::read_frame %d\n", __LINE__); temp_frame->copy_stacks(frame); - int result = file->read_frame(temp_frame); - if( result && frame->get_status() > 0 ) + result = file->read_frame(temp_frame); + if( !result ) + frame->transfer_from(temp_frame); + else if( result && frame->get_status() > 0 ) frame->set_status(-1); -//for(int i = 0; i < 1000 * 1000; i++) ((float*)temp_frame->get_rows()[0])[i] = 1.0; -// printf("File::read_frame %d %d %d %d %d %d\n", -// temp_frame->get_color_model(), -// temp_frame->get_w(), -// temp_frame->get_h(), -// frame->get_color_model(), -// frame->get_w(), -// frame->get_h()); - BC_CModels::transfer(frame->get_rows(), temp_frame->get_rows(), - frame->get_y(), frame->get_u(), frame->get_v(), - temp_frame->get_y(), temp_frame->get_u(), temp_frame->get_v(), - 0, 0, temp_frame->get_w(), temp_frame->get_h(), - 0, 0, frame->get_w(), frame->get_h(), - temp_frame->get_color_model(), - frame->get_color_model(), 0, temp_frame->get_w(), - frame->get_w()); -// printf("File::read_frame %d\n", __LINE__); +//printf("File::read_frame %d\n", __LINE__); } else { // Can't advance position here because it needs to be added to cache //printf("File::read_frame %d\n", __LINE__); - int result = file->read_frame(frame); + 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; } + if( result && !current_frame ) + frame->clear_frame(); + if( cache_active && advance_position && frame->get_status() > 0 ) frame_cache->put_frame(frame, cache_position, current_layer, asset->frame_rate, 1, 0);