[9fans] httplib.rc

2009-02-22 Thread mattmobile
Hi,

while I was on holiday I made some changes to 
/n/sources/contrib/maht/rc/httplib.rc

I added the ability to request a specific byte range via http-ranges : -r 
offset count
and add the capability to include a referer header : -e referer

I also made reponses that were chunked de-chunked 
(only for non ssl requests otherwise they still need piping through 
/n/sources/contrib/maht/dechunk.c)


The script /n/sources/contrib/maht/rc/get_file.rc resumes the download of a 
named file (you can't pipe out from it)
provided the server provides it!

it also requires /n/sources/contrib/maht/rc/maths.rc which adds arithmetic 
functions to rc

see /n/sources/contrib/maht/rc/gauss.rc for an example of the convoluted way of 
using that!

matt

EOT



[9fans] imgfs

2009-02-22 Thread mattmobile
I did some work on /n/sources/contrib/maht/imgfs
stripped out a load of stuff and brought import_ppm inside rather than an 
external tool

imgfs
echo glenda > /n/imgfs/new
echo import ppm /n/sources/contrib/maht/imgfs/glenda.ppm > 
/n/imgfs/images/glenda/ctrl

ls -l  /n/imgfs/images/glenda/*

--rw-rw-rw- M 567 maht maht 0 Feb 22 18:54 /n/imgfs/images/glenda/alpha
--rw-rw-rw- M 567 maht maht 1 Feb 22 18:54 /n/imgfs/images/glenda/blue
--rw-rw-rw- M 567 maht maht 0 Feb 22 18:54 /n/imgfs/images/glenda/ctrl
--rw-rw-rw- M 567 maht maht 1 Feb 22 18:54 /n/imgfs/images/glenda/green
--rw-rw-rw- M 567 maht maht 3 Feb 22 18:54 /n/imgfs/images/glenda/height
--r--r--r-- M 567 maht maht 30021 Feb 22 18:54 /n/imgfs/images/glenda/ppm
--rw-rw-rw- M 567 maht maht 1 Feb 22 18:54 /n/imgfs/images/glenda/red
--rw-rw-rw- M 567 maht maht 0 Feb 22 18:54 /n/imgfs/images/glenda/select
--rw-rw-rw- M 567 maht maht 3 Feb 22 18:54 /n/imgfs/images/glenda/width

convolute works like this

echo convolute red 3x3 1.1 1.2 1.3 2.1 2.2 2.3 3.1 3.2 3.3 >  
/n/imgfs/images/glenda/ctrl

and that's as far as I got,
or rather I then started writing rc scripts to make gaussian convolution kernels

page ppm 

works if you want to see your results
writing to red green and blue changes the ppm

matt



[9fans] actionfs

2009-02-22 Thread mattmobile
Hi,

this one was an experiment

/n/sources/contrib/maht/actionfs.c

invoked with a regex like  actionfs (file.mpg).([0-9]+).(ppm)

if you then 

cat /n/actionfs/file.mpg.100.ppm

actionfs responds with the output from executing

/bin/action-read $fd file.mpg.100.ppm file.mpg 100 ppm

where $fd will be an fd to write to 

i.e. trivially action-read would be something like


#!/bin/rc

fd = $1
shift

echo $* > /fd/$fd

-

The coresponding action-write also works



#!/bin/rc

fd = $1
shift

cat /fd/$fd > /dev/null # or whatever

-

I wrote it specifically to extract individual frames from video files using 
ffmpeg on Linux and 
bring them into Plan9 for processing but generalized the arguments in case I 
thought of something 
interesting later.

My first round of experiment went like this

cpu% cat /bin/action-read
#!/bin/rc

# expect fd fullname videoname frameno
fname = `{echo -n $3 | tr ! '/'}
{
ssh storm single_frame $fname $4 
} > /fd/$1


cpu% cat /n/storm/home/maht/bin/single_frame
#!/usr/local/plan9/bin/rc

# expect filename frameno

timer = `{echo $2  | awk ' { printf "%d.%02d\n",  $1/ 25, 4 * ($1 % 25) }'}
{
ffmpeg -i $1 -t 00.001 -ss $timer /tmp/frame_$pid ^_%d.ppm
cat /tmp/frame_$pid ^_1.ppm 
rm -f frame_$pid ^_1.ppm
rm -f frame_$pid ^_2.ppm  # stupid ffmpeg outputs 2 frames (sometimes)
}  >[2] /dev/null


I was then using imgfs to calculate the average rgb value to look for black 
frames but (unsurprisingly) it was taking too long (4 secs per frame) esp. as 
the Plan9 I was using is in Qemu, cue installing Plan 9 on my terminal.

The ffmpeg part on the Linux side (2Ghz Opteron) was taking 1 second on its own 
so I have to come up with some sort of look ahead cache which is contrary to 
the idea, I may as well just convert the whole file to ppms at the start! I've 
not looked if it is I/O or CPU - perhaps a bit of both.

I've not got round to doing it on my fresh terminal yet. I've got a new 3.2Ghz 
Dual Xeon server to migrate to and a Quad Core terminal to play with so we'll 
see how that works out.

I was hoping to get Xcpu in there but I couldn't see how to get the Plan9 part 
working though I have the Linux bits up.

I have a couple of decent OSX boxes available too (one PPC one Intel) but I 
gave up getting it to compile :)

too many projects .

matt



[9fans] R G Loeliger meets Glenda

2009-02-23 Thread mattmobile
My first stab at a TIL was in AVR assembler but it was more fun to write the 
code than to find a way to use it.

I still don't have a use but at least I don't have to run it on the AVR anymore 
to experiment

first an example run

cpu% /n/sources/contrib/maht/rc/til
abc¯def
123

emit
abc def
123
: emit4 emit emit emit emit

 1 2 3 emit4
321
1 
 swp 3 2 swp dup dup drop emit4 emit
3321

As you may see 
 gets converted to newlines and ¯ (alt__ in plan9, alt0175 on the numpad in 
windows drawterm) gets converted to a space (any better ideas?)

It's the fruit of an evening's playing, so I've got a few features to add yet 
(saving the words will be trivial as you should see from the code)

I should give props to BashForth for giving me the idea, but I've not looked at 
any of it's code (ugh).

matt



[9fans] (no subject)

2009-02-23 Thread mattmobile
oops I forgot carriage returns get converted in email
imagine # is a ^m


pu% /n/sources/contrib/maht/rc/til
abc¯def#123#
emit
abc def
123
: emit4 emit emit emit emit
# 1 2 3 emit4
321
1 # swp 3 2 swp dup dup drop emit4 emit
3321

does this make sense / of interest to anyone :)

matt