gnump3d-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnump3d-devel] Caching downsampled files


From: Mark Schouten
Subject: [Gnump3d-devel] Caching downsampled files
Date: Tue, 9 Mar 2004 01:05:24 +0100
User-agent: Mutt/1.3.28i

Hi,

I tested the downsampling off files recently, and it seems to work
properly. Since the downsampling itself requires a quite large amount
of CPU-time, I changed my GnuMP3d so that it is cached.

If a cached version is found, it is directly read from disk. You can
setup the needed configurationvariables in the gnump3-configfile.

Attached is the diff. What do you think?

Mark Schouten
Alphen aan den Rijn
Netherlands


Mark Schouten

-- 
Read my rules of email-engagement: http://prevented.net/email-rules.html


settopbox:/var/tmp/gnump3d# diff /usr/bin/gnump3d /tmp/gnump3d.orig
102,103d101
< my $down_cachedir;    # Which dir do we use for caching downsampled data
< my $down_cache_limit; # How much diskspace do we allow for caching
1554,1561d1551
<     # Create a filename that is usable on disk withou creating directorys.
<     #
<     my $cacheFile = "$safeFile"."@".$quality;
<     $cacheFile =~ s/"//g;
<     $cacheFile =~ s/ /_/g;
<     $cacheFile =~ s/\//\|/g;
<
<     #
1588,1609c1578,1579
<
<     my $writecache = 0;
<     my $pre_exit;
<
<     if (!(-e "$down_cachedir/$cacheFile.full" && open (SAMPLE, 
"$down_cachedir/$cacheFile.full"))) {
<       opendir(CACHECHECK, $down_cachedir);
<       my $cachesize = 0;
<       foreach(grep {!/^\.{1,2}/} readdir(CACHECHECK)) {
<               $cachesize += -s $down_cachedir."/".$_;
<       }
<       close(CACHECHECK);
<       if ($cachesize > ($down_cache_limit*1024*1024)) {
<               print "Shit, cache is to big. Write something to clean up!";
<               print "Cache is $cachesize bytes. ". 
$down_cache_limit*1024*1024 ." is allowed.\n";
<       } else {
<               print "Cache is $cachesize bytes. ". 
$down_cache_limit*1024*1024 ." is allowed.\n";
<       }
<       open( SAMPLE, "$cmd|" )
<           or die "Cannot run : '$cmd $file' : $!";
<       open( CACHING, "+>$down_cachedir/$cacheFile" );
<       $writecache = 1;
<     }
---
>     open( SAMPLE, "$cmd|" )
>       or die "Cannot run : '$cmd $file' : $!";
1621d1590
<           $pre_exit = 1;
1626d1594
<       print CACHING $buff if ($writecache == 1);
1630,1631d1597
<     close( CACHING ) if ($writecache == 1);
<     rename("$down_cachedir/$cacheFile", "$down_cachedir/$cacheFile.full") if 
($pre_exit == 0);
2955,2956d2920
<   $down_cachedir   = getConfig( "downsample_cachedir", 0 );
<   $down_cache_limit= getConfig( "downsample_cachedir_sizelimit", 0 );





reply via email to

[Prev in Thread] Current Thread [Next in Thread]