Filters
-------

Image processing filters can make a big difference to the quality of compressed
scenes. If dithering has been used, however, the filters may dramatically
reduce the colour range. It is also possible to use the filter code in other
programs. The interface is as follows:

Callers load the filter code at a quad word aligned address in memory. The init
routine is called. Then the filter routine is called as necessary.

First word: init entry point
(byte offset 0)

 Purpose: allows filter to initialise any values it needs (these are stored
          inside the filter's code space or allocated by the init routine).

 On entry:
   r0 - source x size of movie
   r1 - source y size of movie
   r2 - colour space of movie: 0: RGB
                               1: YUV
                               2: Y
   r3 - layout packing: byte 0 of r3 contains the number of bits of the first
                        field (Y or R)
                        byte 1 contains that of the second field (G or U)
                        byte 2 contains that of the third field (B or V)
                        For example, 5 bit per component YUV would have r3 as
                        &00050505, while 6 bit Y, 5 bit U and V would have r3
                        as &00050506.
   r4..r12 - undefined: scratch
   r13 - stack
   r14 - return address
   processor mode: USR
 On exit
   r0-r12 - may be corrupted
   r13 - same as on entry
   flags - V set signals error: r0 points to an error block

Second word: filter one frame

 Purpose: apply the filter and produce one filtered frame

 On entry:
   r0 - buffer to be filtered (word aligned)
   r1 - previous output pointer (allows temporal filtering from previous frame)
        (0 if no previous frame available)
   r2 - result pointer - save output pixels here (word aligned)
   r3..r12 - scratch
   r13 - stack
   r14 - return address
   processor mode: USR *or* SVC, interrupts ENABLED (usually)
   flags - irrelevant
 On exit
   r0..r12 - irrelevant
   r13 - must be same value as on entry
   r14 - irrelevant
   processor mode: same as called mode
   flags - irrelevant

 Pixels are stored as Words!!! (well, the bottom 15 bits of one, anyway)



AREncode and Filters
--------------------

A new keyword has been added to CompLib. It is the -Filter keyword. -Filter
takes one parameter which is a ; separated list of filter names. The filter
names are the names of the files in Tools.Filters. All the filters listed
will be applied to a frame in the order they were given.
