#!/bin/csh -f
# 01.09.92 maxframes Alex Urrutia + Keven Fedirko v1.00
#
# This little script when run, will tell the user howmany frames (from an
# existing rendered animation) that flipbook will allow to flip without
# skipping any frames.  In the future perhaps one can be written that will
# querry the ram available, and then through trial & error with a bit of
# user-interaction, how large the images can be to fit into the available RAM
# configuration on the user's machine...

if ($#argv < 1) then
	echo
	echo "Usage: maxframes <sequence_name> "
	echo
	exit -1
endif
@ count = 0;
foreach i ( `\ls ./$1*.pic` )
	@ count++
end
if ($count == 0) then
	exit -1
endif
infopic $i>size.info
free > ram.info
set width=`cat size.info|awk '/width/{printf("%s",$3)}'`
set height=`cat size.info|awk '/height/{printf("%s",$3)}'`
set freemem=`cat ram.info|awk '/freemem/{printf("%s",$2)}'`
rm size.info ram.info
@ bytes = ($width * $height) * 4
@ kbytes = $bytes / 1024
@ frames = 1
loop:
if (($frames * $kbytes) < $freemem) then
	@ frames++
	goto loop
endif
@ frames--
echo
echo "MAX NUMBER OF $width X $height FRAMES:  $frames"
echo
