[XviD-devel] suggestion: label pointer alignment

Mat Hostetter mat at curl.com
Sun Apr 18 22:48:45 CEST 2004


I've been reading through a bunch of XviD functions.
One thing that would make the code clearer is if pointers which were
known to be aligned mod N were marked in some way, perhaps using a
typedef or a comment.

Alignment knowledge is especially important when writing SSE2 code,
since you want to know whether to use movqda or movqdu (aligned
vs. unaligned).

For example, I was just looking at interpolate8x8_avg2_c.  It takes
three pointers, but doesn't specify their alignments.  I would naively
guess they are always 8-byte aligned, and interpolate8x8_avg2_mmx just
loads them with movq, which seems to confirm the theory.  But then
again, interpolate8x8_halfpel_h_xmm intentionally does an unaligned
movq, so movq doesn't prove alignment.

Similarly, the argument to calc_cbp* appears to be aligned modulo
the cache line size, and the sse2 implementation assumes it is 16-byte
aligned, but the API doesn't officially say that anywhere.

-Mat


More information about the XviD-devel mailing list