X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fframecache.C;h=fdf7ef358e11088c696869555efefbe5d354469c;hb=ecf90ad2d14e5f72505b824b7b50edd717d2d404;hp=a5f6deb25c128d48b35ed0eaabd1a1dc60e53353;hpb=30bdb85eb33a8ee7ba675038a86c6be59c43d7bd;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/cinelerra/framecache.C b/cinelerra-5.1/cinelerra/framecache.C index a5f6deb2..fdf7ef35 100644 --- a/cinelerra-5.1/cinelerra/framecache.C +++ b/cinelerra-5.1/cinelerra/framecache.C @@ -2,21 +2,21 @@ /* * CINELERRA * Copyright (C) 2008 Adam Williams - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * + * */ #include "bcsignals.h" @@ -29,6 +29,7 @@ #include "vframe.h" +#include #include #include #include @@ -79,7 +80,7 @@ FrameCache::~FrameCache() // Returns 1 if frame exists in cache and copies it to the frame argument. -int FrameCache::get_frame(VFrame *frame, +int FrameCache::get_frame(VFrame *frame, int64_t position, int layer, double frame_rate, @@ -89,18 +90,18 @@ int FrameCache::get_frame(VFrame *frame, FrameCacheItem *result = 0; if(frame_exists(frame, - position, + position, layer, frame_rate, &result, source_id)) { - if(result->data) + if(result->data) { // Frame may have come from the readahead thread. // Those frames are in the codec color model. // But to pass frame_exists, they must be identical. -// BC_CModels::transfer(frame->get_rows(), +// BC_CModels::transfer(frame->get_rows(), // result->data->get_rows(), // result->data->get_y(), // result->data->get_u(), @@ -108,28 +109,22 @@ int FrameCache::get_frame(VFrame *frame, // frame->get_y(), // frame->get_u(), // frame->get_v(), -// 0, -// 0, -// result->data->get_w(), +// 0, +// 0, +// result->data->get_w(), // result->data->get_h(), -// 0, -// 0, -// frame->get_w(), +// 0, +// 0, +// frame->get_w(), // frame->get_h(), -// result->data->get_color_model(), +// result->data->get_color_model(), // frame->get_color_model(), // 0, // result->data->get_w(), // frame->get_w()); - +// no context data since keyframe updates may vary input frame->copy_from(result->data); - - -// This would have copied the color matrix for interpolate, but -// required the same plugin stack as the reader. -// frame->copy_stacks(result->data); - frame->copy_params(result->data); } result->age = get_age(); } @@ -173,12 +168,8 @@ VFrame* FrameCache::get_frame_ptr(int64_t position, // Puts frame in cache if enough space exists and the frame doesn't already // exist. -void FrameCache::put_frame(VFrame *frame, - int64_t position, - int layer, - double frame_rate, - int use_copy, - Indexable *indexable) +void FrameCache::put_frame(VFrame *frame, int64_t position, + int layer, double frame_rate, int use_copy, Indexable *indexable) { lock->lock("FrameCache::put_frame"); FrameCacheItem *item = 0; @@ -187,13 +178,7 @@ void FrameCache::put_frame(VFrame *frame, //printf("FrameCache::put_frame %d position=%jd\n", __LINE__, position); - if(frame_exists(frame, - position, - layer, - frame_rate, - &item, - source_id)) - { + if(frame_exists(frame, position, layer, frame_rate, &item, source_id)) { item->age = get_age(); lock->unlock(); return; @@ -202,24 +187,17 @@ void FrameCache::put_frame(VFrame *frame, item = new FrameCacheItem; - if(use_copy) - { - item->data = new VFrame(*frame); - } - else - { - item->data = frame; - } + item->data = use_copy ? new VFrame(*frame) : frame; // Copy metadata item->position = position; item->layer = layer; item->frame_rate = frame_rate; item->source_id = source_id; - if(indexable) + if(indexable) item->path = cstrdup(indexable->path); - item->age = get_age(); + item->age = position < 0 ? INT_MAX : get_age(); //printf("FrameCache::put_frame %d position=%jd\n", __LINE__, position); put_item(item); @@ -229,12 +207,8 @@ void FrameCache::put_frame(VFrame *frame, -int FrameCache::frame_exists(VFrame *format, - int64_t position, - int layer, - double frame_rate, - FrameCacheItem **item_return, - int source_id) +int FrameCache::frame_exists(VFrame *format, int64_t position, + int layer, double frame_rate, FrameCacheItem **item_return, int source_id) { FrameCacheItem *item = (FrameCacheItem*)get_item(position); // printf("FrameCache::frame_exists %d item=%p item->position=%jd position=%jd\n", @@ -257,7 +231,7 @@ int FrameCache::frame_exists(VFrame *format, // item->data); // format->dump_params(); -// This originally tested the frame stacks because a change in the +// This originally tested the frame stacks because a change in the // interpolate plugin could cause CR2 to interpolate or not interpolate. // This was disabled. if(EQUIV(item->frame_rate, frame_rate) && @@ -274,7 +248,7 @@ int FrameCache::frame_exists(VFrame *format, return 0; } -int FrameCache::frame_exists(int64_t position, +int FrameCache::frame_exists(int64_t position, int layer, double frame_rate, int color_model, @@ -322,7 +296,7 @@ void FrameCache::dump() printf("FrameCache::dump 1 %d\n", total()); FrameCacheItem *item = (FrameCacheItem *)first; while( item ) { - printf(" position=%jd frame_rate=%f age=%d size=%jd\n", + printf(" position=%jd frame_rate=%f age=%d size=%ld\n", item->position, item->frame_rate, item->age, item->data->get_data_size()); item = (FrameCacheItem*)item->next;