Sunday, April 20, 2008

SVG Animation Update

I've made a couple of quick fixes to the SVG Animation patch I mentioned earlier. The fixes are:
  • Implements the <set> element
  • Gets the 'discrete' calcMode working
  • Gets setCurrentTime working
This should allow more SMIL Animation examples to work. These changes also happen to make the SMIL parts of Acid 3 work. Well, sort of. Tests 75 works, but test 76 fails intermittently. If I do a full refresh of the Acid 3 page it works. I've no doubt got something wrong in the setCurrentTime implementation. Builds:This is probably about all the time I can spend on looking at SMIL for now, apart from minor tweaks, but the original author of the patch commented in my last post that they were interested in resuming work on it. I hope that's the case - It'd be great to see this completed.

Categories: ,

Labels:

Saturday, April 19, 2008

Firefox SVG Animation Patch

I wanted to try out an SVG Animation example that someone sent me but Firefox currently doesn't have support for this. Bug 216462 contains a patch with a work in progress implementation of SVG Animation so I looked into trying it out.

Unfortunately it has suffered some bitrot recently so I made the changes to get it to apply on the current CVS. There were some problems causing crashes which I fixed up and I've updated the bug with the adjusted patch.

Jeff Schiller commented previously in the bug about wanting to try it out but not being able to build so I made my builds available for him to play with. His latest blog post mentions the results of trying the build out. Thanks for giving it the run through Jeff!

If you want to have a play with a build with the SMIL patch applied, you can try my experimental builds:These also have the video patch applied.

The original author of the patch has a status page and a page of tests that can be used to try it out. I don't know how up to date those are with regards to the current version of the patch though.

On the video front, I've updated some of the binary video builds to fix some bugs exposed by the excellent Metavid site - a <video> early adopter.

Categories: , ,

Labels:

Monday, April 14, 2008

Seaside with XUL

Pavel Krivanek posted to the Seaside mailing list about generating XUL from Seaside. XUL is the user interface markup language that Firefox and applications based on XULRunner use for the user interface. Seaside is a continuation based web framework written in Smalltalk.

Using this combination they get native look and feel for the platform for Smalltalk applications.

Categories: , ,

Labels:

Friday, April 04, 2008

Collection of Factor Articles in PDF

Factor has experienced some rapid change in the libraries and language over the past few years. I've written a few blog posts about Factor in the past and many of them suffer from bitrot due to this, making it hard to try out the examples in the latest Factor versions.

I've collected some of these articles, put them in a PDF document, and am slowly working through them so they are up to date with recent Factor versions. The document is split into sections for the articles that should work, and those that don't. Even the out of date articles make intersting reading for examples on how to use Factor.

There's nothing new in the document since it's a collection of things available from my blog posts, but having the central document makes it easier to update, print out, and read.

You can download it from factor-articles.pdf.

The git repository with the LaTeX source is git://double.co.nz/git/factor-articles.git or http://double.co.nz/git/factor-articles.git. You can view the gitweb interface.

The atom feed can be used to know when updates have occurred. The PDF file is updated as soon as the git repository is updated so it'll let you know when a new version is available.

Comments and suggestions welcome.

Categories:

Labels:

HTML5 Video on the N810

The Nokia Internet Tablet's use GStreamer for the multimedia functionality. Chris Blizzard built Mozilla on the Nokia N810 with the GStreamer video backend patch applied.

He has a video on his weblog showing the N810 playing video inside Mozilla. Nice!

Categories: , ,

Labels:

Thursday, April 03, 2008

Factor Parsing DSL

I've been doing some experimenting with the emedded grammar code I wrote for Factor, trying to make it easier to use and a bit more useful for real world projects.

My inspiration for the changes has been seeing the kinds of things OMeta can do and the examples in the Steps towards the reinvention of programming from the Viewpoints Research Institute.

The original parsing expression grammar code (in the vocab 'peg') produced a data structure composed of Factor tuples that was interpreted at runtime via a call to the word 'parse'. It still has the data structure of tuples but now it can be compiled into Factor quotations, which are then compiled to native machine code via the Factor compiler. The 'parse' word calls 'compile' on the datastructure and calls it.

I created a parsing word that allows you to embed the peg expression directly in code, have it compiled to a quotation at parse time, and then called at runtime. Usage looks like:
"1+2" [EBNF expr=[0-9] '+' [0-9] EBNF] call
The older peg code had an <EBNF ... EBNF> embedded language and each rule in the language was translated to a Factor word. That's now changed to an EBNF: definition. An example:
EBNF: expr 
digit = [0-9] => [[ digit> ]]
number = (digit)+ => [[ 10 digits>integer ]]
value = number
| ("(" exp ")") => [[ second ]]

fac = fac:x "*" value:y => [[ drop x y * ]]
| fac:x "/" value:y => [[ drop x y / ]]
| number

exp = exp:x "+" fac:y => [[ drop x y + ]]
| exp:x "-" fac:y => [[ drop x y - ]]
| fac
;EBNF
This creates a word, 'expr', that runs the last rule in the embedded language (the 'exp' rule in this case) on the string passed to it:
"1+2*3+4" expr parse-result-ast .
=> 11
If you've used peg.ebnf before you'll see some new features in this code:
  • You can do character ranges using code like [a-zA-Z] to match upper and lowercase characters, etc.
  • Factor quotations can be embedded to process the results of choices. Anything between the [[ ... ]] will be run when that choice succeeds and the result put in the abstract syntax tree for that rule. The default AST produced by the rule is on the stack of the quotation. The example above drops this in some cases, and transforms it in others.
  • Rule elements can have variable names suffixed to it and these can be referenced in the action quotations. This is implemented using locals. This can be seen in EBNF code like this:
    exp:x "+" exp:y => [[ drop x y + ]]
    Usually that rule produces an AST consisting of a 3 element sequence, each element being the AST produced by the rules elements. The action quotation is transformed into:

    [let* | x [ 0 over nth ]
    y [ 2 over nth ] |
    drop x y +
    ] with-locals
    This is efficient and makes the grammar easier to read.
  • Another major new feature is grammars now handle direct and indirect left recursion. I implemented this from the VPRI paper Packrat Parsers Can Support Left Recursion. It makes converting existing grammars to peg grammars much easier.
  • Semantic actions have been added. These are like normal [[ ... ]] actions except they have stack effect ( ast -- bool ). Given an abstract syntax tree from the preceding element, it should return a boolean indicating whether the parse succeeded or not. For example:
    odd= [0-9] ?[ digit> odd? ]?
  • Some of the syntax has changed. Previously { ... } was used for repeating zero or more times and [ ... ] was for optional. Now I use (...)*, (...)+, (...)?, for zero or more, one or more, and optional respectively. The dot (.) is used to match anything at that point. Terminals can be enclosed in single or double quotations.
  • There is a 'rule' word that can be used to get a single rule from a compiled grammar:
    EBNF: foo
    number=([0-9])+
    expr = number '+' number
    ;EXPR
    "1+2" foo parse-result-ast => { "1" "+" "2" }
    "1+2" "number" \ foo rule parse parse-result-ast => "1"
    Notice the 'rule' word returns the parser object rather than the compiled quotation. This is useful for testing and further combining with other parsers.
These changes are in the main Factor repository. There is the peg.pl0 and peg.expr vocabs as examples. The peg.ebnf code is in an experimental state and is likely to change a lot until I'm satisfied with it so be aware that it might not be wise to use it in stable code unless you're happy with tracking the changes. I welcome feedback and ideas though.

One feature I'm currently working on but haven't put in the main repository yet is the ability to use the embedded grammar DSL to operate over Factor arrays and tuples. This allows writing an embedded grammar to produced an AST, and another embedded grammar to transform that AST into something else. Here's what code to transform an AST currently looks like:
TUPLE: plus lhs rhs ;

EBNF: adder
num = . ?[ number? ]?
plus = . ?[ plus? ]? expr:a expr:b => [[ drop a b + ]]
expr = plus | num
;EBNF

T{ plus f 1 T{ plus f 2 3 } } adder parse-result-ast .

=> 6
This uses features I've already discussed, like semantic actions, to detect the type of the object. The difference is that the parser produced by EBNF: operates not on strings, but on an abstract sequence type that is implemented for strings, sequence, and tuples. I'm still playing around with ideas for this but I think it'll be a useful way to reuse grammars and string them together to perform tasks.

Categories:

Labels:

Firefox HTML5 Video with GStreamer

I wrote earlier about refactoring the HTML5 video patch to allow different backends. I've now added a patch for GStreamer support to bug 422540.

To build a Firefox with this support, get the latest trunk CVS source. Apply the patch from bug 382267, followed by the patch from bug 422540. Build with the --enable-gstreamer configure option. Or follow these steps to build from the git repository.

I've made a prebuilt binary for Linux which you can download from firefox-3.0pre-video.en-US.linux-i686.tar.bz2.

With this build, when you visit a page that uses <video> it will use the GStreamer codecs available on your system to decode and play them. The Theora examples on my test page continue to work, and I've also tested it decoding H.264 videos in .mp4 and .mov files, using the Fluendo plugins.

This is a first cut at support and still needs some work but it plays quite well so far. Seeking works within files but there is no built in controls for it yet. You can write JavaScript that changes the 'currentTime' property of the video element DOM object to move forward and back in the video.

Categories: , ,

Labels: