[XviD-devel] Hadamard Transform
Christoph Lampert
xvid-devel@xvid.org
Fri, 6 Sep 2002 13:09:00 +0200 (CEST)
On 6 Sep 2002, pascal massimino wrote:
> Arg.. you shouldn't be teasing me. I failed miserably in
> the trap :)
> Here are some Hadamard stuff. I let you imagine what
> the ASM version (or 8bits) would look like :)
#define BUTF(a, b, tmp) \
(tmp) = (a)+(b); \
(a) = (a)-(b); \
(b) = (tmp)
If I'm not wrong, you can do (a,b) -> (a-b,a+b) operation (and
every permutation, sign change etc.) without temp storage
doing:
1 -= 2 2 += 2 2 += 1
(a, b) -----> (a-b ,b) -----> (a-b, 2*b) -----> (a-b, b+a)
I don't know if this is faster (extra operation?), but it
might help not needing a 9th register.
gruel
(a computer science professor always proudly told his students
(e.g. me) that he keeps betting he can "exchange the value of
two variables without need for a temporary third". He always wins,
using a method similar to the one above ;-)