Major refactor to the cache object (again)! It now uses bytes to determine how many frames to keep.

This commit is contained in:
Jonathan Thomas
2012-10-11 17:30:32 -05:00
parent cebf9728c8
commit 217c54a5ae
7 changed files with 78 additions and 130 deletions

View File

@@ -4,7 +4,7 @@ using namespace openshot;
FFmpegReader::FFmpegReader(string path) throw(InvalidFile, NoStreamsFound, InvalidCodec)
: last_frame(0), is_seeking(0), seeking_pts(0), seeking_frame(0), seek_count(0),
audio_pts_offset(99999), video_pts_offset(99999), working_cache(-1), final_cache(24), path(path),
audio_pts_offset(99999), video_pts_offset(99999), working_cache(0), final_cache(24), path(path),
is_video_seek(true), check_interlace(false), check_fps(false), enable_seek(true),
rescaler_position(0), num_of_rescalers(32), is_open(false) {
@@ -453,10 +453,6 @@ Frame* FFmpegReader::ReadStream(int requested_frame)
// Return requested frame (if found)
if (final_cache.Exists(requested_frame))
{
// Set cache's current frame
working_cache.SetCurrentFrame(requested_frame);
final_cache.SetCurrentFrame(requested_frame);
// Return prepared frame
return final_cache.GetFrame(requested_frame);
}
@@ -887,10 +883,6 @@ void FFmpegReader::Seek(int requested_frame) throw(TooManySeeks)
// Increment seek count
seek_count++;
// Reset the current frame for the cache
working_cache.SetCurrentFrame(requested_frame);
final_cache.SetCurrentFrame(requested_frame);
// too many seeks
if (seek_count > 10)
throw TooManySeeks("Too many seek attempts... something seems wrong.", path);