[Hdrflow-svn] SF.net SVN: hdrflow: [240] trunk/app/HDRFlow
Status: Pre-Alpha
Brought to you by:
glslang
From: <gl...@us...> - 2007-08-12 20:39:18
|
Revision: 240 http://hdrflow.svn.sourceforge.net/hdrflow/?rev=240&view=rev Author: glslang Date: 2007-08-12 13:39:16 -0700 (Sun, 12 Aug 2007) Log Message: ----------- +initial Cache implementation Modified Paths: -------------- trunk/app/HDRFlow/Bucket.hpp trunk/app/HDRFlow/Cache.cpp trunk/app/HDRFlow/Cache.hpp trunk/app/HDRFlow/HDRFlow.xcodeproj/project.pbxproj Removed Paths: ------------- trunk/app/HDRFlow/Bucket.cpp Deleted: trunk/app/HDRFlow/Bucket.cpp =================================================================== --- trunk/app/HDRFlow/Bucket.cpp 2007-08-09 22:22:55 UTC (rev 239) +++ trunk/app/HDRFlow/Bucket.cpp 2007-08-12 20:39:16 UTC (rev 240) @@ -1,11 +0,0 @@ - -// HDRFlow - A image processing application - -// Copyright (c) 2007 Goncalo N. M. de Carvalho -// Released under the GPL. -// For more information, see http://www.cryogenicgraphics.com/hdrflow. - -#include "Bucket.hpp" - -namespace hdrflow { -} Modified: trunk/app/HDRFlow/Bucket.hpp =================================================================== --- trunk/app/HDRFlow/Bucket.hpp 2007-08-09 22:22:55 UTC (rev 239) +++ trunk/app/HDRFlow/Bucket.hpp 2007-08-12 20:39:16 UTC (rev 240) @@ -10,14 +10,37 @@ #include <HDRFlow/openlibraries.hpp> +namespace ml = olib::openmedialib::ml; + namespace hdrflow { class Bucket { public: - explicit Bucket( ); + explicit Bucket( int position, ml::frame_type_ptr frame ) + : position_( position ) + , frame_( frame ) + { } + + int position( ) const + { return position_; } + void set_position( int position ) + { position_ = position; } + + ml::frame_type_ptr frame( ) const + { return frame_; } + void set_frame( ml::frame_type_ptr frame ) + { frame_ = frame; } + + bool is_loaded( ) { return frame_ != 0; } + +private: + int position_; + ml::frame_type_ptr frame_; }; +typedef boost::shared_ptr<Bucket> BucketPtr; + } #endif Modified: trunk/app/HDRFlow/Cache.cpp =================================================================== --- trunk/app/HDRFlow/Cache.cpp 2007-08-09 22:22:55 UTC (rev 239) +++ trunk/app/HDRFlow/Cache.cpp 2007-08-12 20:39:16 UTC (rev 240) @@ -7,5 +7,59 @@ #include "Cache.hpp" +namespace pl = olib::openpluginlib; +namespace ml = olib::openmedialib::ml; + namespace hdrflow { + +bool Cache::connect( const pl::string& media, bool fill ) +{ + pl::string in( media + "/sequence: " ); + input_ = ml::create_input( in ); + if( input_ == 0 ) + return false; + + if( fill ) + { + for( int i = 0; i < buckets_.size( ); ++i ) + { + input_->seek( i, false ); + buckets_.push_back( BucketPtr( new Bucket( i, input_->fetch( ) ) ) ); + } + } + + return true; } + +BucketPtr Cache::reserve_bucket( int position ) +{ + const_iterator b = find_bucket( position ); + if( b == buckets_.end( ) ) + { + b = acquire_bucket( ); + if( b != buckets_.end( ) ) + { + input_->seek( position, false ); + + ( *b )->set_position( position ); + ( *b )->set_frame( input_->fetch( ) ); + } + } + else + { + + } + + return *b; +} + +int Cache::length( ) const +{ + if( input_ ) + return input_->get_frames( ); + + return 0; +} + + +} Modified: trunk/app/HDRFlow/Cache.hpp =================================================================== --- trunk/app/HDRFlow/Cache.hpp 2007-08-09 22:22:55 UTC (rev 239) +++ trunk/app/HDRFlow/Cache.hpp 2007-08-12 20:39:16 UTC (rev 240) @@ -8,16 +8,52 @@ #ifndef CACHE_INC_ #define CACHE_INC_ +#include <list> + #include <HDRFlow/openlibraries.hpp> +#include "Bucket.hpp" + +namespace pl = olib::openpluginlib; +namespace ml = olib::openmedialib::ml; + namespace hdrflow { class Cache { public: - explicit Cache( ); + typedef std::list<BucketPtr> container; + typedef container::iterator iterator; + typedef container::const_iterator const_iterator; + typedef container::reverse_iterator reverse_iterator; + typedef container::const_reverse_iterator const_reverse_iterator; + +public: + explicit Cache( int n ) + : buckets_( n ) + { } + + bool connect( const pl::string& media, bool fill = true ); + void disconnect( ); + void flush( ); + void clear( ); + + BucketPtr reserve_bucket( int position ); + + int length( ) const; + bool valid( ) const { return input_ != 0; } + +private: + const_iterator find_bucket( int position ) const; + const_iterator acquire_bucket( ); + +private: + container buckets_; + ml::input_type_ptr input_; }; +typedef boost::shared_ptr<Cache> CachePtr; + } #endif Modified: trunk/app/HDRFlow/HDRFlow.xcodeproj/project.pbxproj =================================================================== --- trunk/app/HDRFlow/HDRFlow.xcodeproj/project.pbxproj 2007-08-09 22:22:55 UTC (rev 239) +++ trunk/app/HDRFlow/HDRFlow.xcodeproj/project.pbxproj 2007-08-12 20:39:16 UTC (rev 240) @@ -11,7 +11,6 @@ 671E22A30C4166E400CA1860 /* ScriptEditorController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 671E22A20C4166E400CA1860 /* ScriptEditorController.mm */; }; 673D04500C522C980096513A /* PreferencesController.m in Sources */ = {isa = PBXBuildFile; fileRef = 673D044F0C522C980096513A /* PreferencesController.m */; }; 674E44640C3F854A0036A908 /* ScriptEditor.nib in Resources */ = {isa = PBXBuildFile; fileRef = 674E44620C3F854A0036A908 /* ScriptEditor.nib */; }; - 676191B60C6643570076713C /* Bucket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 676191B50C6643570076713C /* Bucket.cpp */; }; 676191BF0C6643B20076713C /* Cache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 676191BE0C6643B20076713C /* Cache.cpp */; }; 677740360C5C0184005FF29D /* PlugInsPreferencesOutlineViewNode.mm in Sources */ = {isa = PBXBuildFile; fileRef = 677740350C5C0184005FF29D /* PlugInsPreferencesOutlineViewNode.mm */; }; 678A4AA70C2B18B50011E9F7 /* CustomOpenGLView.m in Sources */ = {isa = PBXBuildFile; fileRef = 678A4AA60C2B18B50011E9F7 /* CustomOpenGLView.m */; }; @@ -51,7 +50,6 @@ 674E44630C3F854A0036A908 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/ScriptEditor.nib; sourceTree = "<group>"; }; 676191810C663D100076713C /* Cache.hpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = Cache.hpp; sourceTree = "<group>"; }; 676191A40C6642CC0076713C /* Bucket.hpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = Bucket.hpp; sourceTree = "<group>"; }; - 676191B50C6643570076713C /* Bucket.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Bucket.cpp; sourceTree = "<group>"; }; 676191BE0C6643B20076713C /* Cache.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Cache.cpp; sourceTree = "<group>"; }; 6777402D0C5C0022005FF29D /* PlugInsPreferencesOutlineViewNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PlugInsPreferencesOutlineViewNode.h; sourceTree = "<group>"; }; 677740350C5C0184005FF29D /* PlugInsPreferencesOutlineViewNode.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = PlugInsPreferencesOutlineViewNode.mm; sourceTree = "<group>"; }; @@ -99,7 +97,6 @@ isa = PBXGroup; children = ( 676191A40C6642CC0076713C /* Bucket.hpp */, - 676191B50C6643570076713C /* Bucket.cpp */, 676191810C663D100076713C /* Cache.hpp */, 676191BE0C6643B20076713C /* Cache.cpp */, 67F6CCF70C285D6C00098F90 /* CustomOpenGLView.h */, @@ -287,7 +284,6 @@ 67C0BED90C5BCD4600E0E258 /* HDRFlowController.mm in Sources */, 67C0BEFB0C5BED8500E0E258 /* PlugInsPreferencesController.mm in Sources */, 677740360C5C0184005FF29D /* PlugInsPreferencesOutlineViewNode.mm in Sources */, - 676191B60C6643570076713C /* Bucket.cpp in Sources */, 676191BF0C6643B20076713C /* Cache.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |