X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Ffilelist.C;h=f4f26dac22e9479c53b74881780180ad3d3c3dc9;hp=dd78cf5726deeeb9924fb46b968bee5a70f40878;hb=cb1a1530246ad67fb9be9aa2dbba5b88eb63e933;hpb=7fd85fb66168f6b518c5f2d73e04036e87faa0e1 diff --git a/cinelerra-5.1/cinelerra/filelist.C b/cinelerra-5.1/cinelerra/filelist.C index dd78cf57..f4f26dac 100644 --- a/cinelerra-5.1/cinelerra/filelist.C +++ b/cinelerra-5.1/cinelerra/filelist.C @@ -113,38 +113,34 @@ int FileList::open_file(int rd, int wr) if(stream) { char string[BCTEXTLEN]; - (void)fread(string, strlen(list_prefix), 1, stream); + int len = strlen(list_prefix); + int ret = fread(string, 1, strlen(list_prefix), stream); fclose(stream); - - if(!strncasecmp(string, list_prefix, strlen(list_prefix))) - { - -//printf("FileList::open_file %d\n", __LINE__); + result = len == ret ? 0 : 1; + if( !result && !strncasecmp(string, list_prefix, len)) { asset->format = list_type; - -// Open index here or get frame size from file. result = read_list_header(); -//printf("FileList::open_file %d %s\n", __LINE__, path_list.values[0]); - if(!result) result = read_frame_header(path_list.values[0]); + if( !result ) + result = read_frame_header(path_list.values[0]); } - else - { -//printf("FileList::open_file 2\n", asset->use_header); -//printf("FileList::open_file %d\n", __LINE__); + else if( !result && frame_type != FILE_UNKNOWN ) { asset->format = frame_type; + result = read_frame_header(asset->path); + asset->video_length = -1; + } + else + result = 1; + if( !result ) { 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 ) - asset->frame_rate = 1; - asset->video_length = -1; + asset->frame_rate = 10; } - result = 0; } else eprintf(_("Error while opening \"%s\" for reading. \n%m\n"), asset->path); @@ -352,49 +348,51 @@ int FileList::read_frame(VFrame *frame) asset->single_frame = 1; // Allocate and decompress single frame into new temporary //printf("FileList::read_frame %d\n", frame->get_color_model()); - if(!temp || temp->get_color_model() != frame->get_color_model()) - { - if(temp) delete temp; - temp = 0; - - - if(!use_path() || frame->get_color_model() == BC_COMPRESSED) - { + if( !temp || temp->get_color_model() != frame->get_color_model() ) { + delete temp; temp = 0; + int aw = asset->actual_width, ah = asset->actual_height; + int color_model = frame->get_color_model(); + switch( color_model ) { + case BC_YUV420P: + case BC_YUV420PI: + case BC_YUV422P: + aw = (aw+1) & ~1; ah = (ah+1) & ~1; + break; + case BC_YUV410P: + case BC_YUV411P: + aw = (aw+3) & ~3; ah = (ah+3) & ~3; + break; + } + if( !use_path() || color_model == BC_COMPRESSED ) { FILE *fd = fopen(asset->path, "rb"); - if(fd) - { + if( fd ) { struct stat ostat; stat(asset->path, &ostat); - switch(frame->get_color_model()) - { - case BC_COMPRESSED: - frame->allocate_compressed_data(ostat.st_size); - frame->set_compressed_size(ostat.st_size); - (void)fread(frame->get_data(), ostat.st_size, 1, fd); - break; - default: - 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->actual_width, asset->actual_height, - frame->get_color_model(), 0); - read_frame(temp, data); - break; + switch(frame->get_color_model()) { + case BC_COMPRESSED: + frame->allocate_compressed_data(ostat.st_size); + frame->set_compressed_size(ostat.st_size); + (void)fread(frame->get_data(), ostat.st_size, 1, fd); + break; + default: + 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(aw, ah, color_model); + read_frame(temp, data); + break; } fclose(fd); } - else - { + else { eprintf(_("Error while opening \"%s\" for reading. \n%m\n"), asset->path); result = 1; } } - else - { - temp = new VFrame(asset->actual_width, asset->actual_height, - frame->get_color_model(), 0); + else { + temp = new VFrame(aw, ah, color_model); read_frame(temp, asset->path); } }