[XviD-devel] Bitstream problems for RISC architectures

Edouard Gomez ed.gomez at free.fr
Fri Apr 4 20:38:19 CEST 2003


Eric R. Smith (ersmith at hfx.eastlink.ca) wrote:
> I've been porting XviD to a RISC architecture and ran into a problem 
> with the bitstream code. The version currently in CVS (and also in the 
> 0.9.1 release) does loads of a uint32_t from arbitrary addresses. This 
> works on the x86, but not on many RISCs, where uint32_t accesses must be 
> 32 bit aligned.

Oh ? i did some tests with xvid_encraw on a RISC machine (the one
available on the sourceforge compile farm) and i did not notice this
type of misalignment read. Good to know.
 
> The solution is quite straightforward: it's just to start the stream at 
> the previous word boundary and skip the necessary number of bits at the 
> beginning of the stream. Once the stream is aligned it will stay 
> aligned. I've appended a patch below. I've verified that this still 
> works on the x86 (and in fact is very slightly faster, since even when 
> unaligned loads are allowed they are slower than aligned ones). I've 
> only tested the decoder; I don't know if any more changes may be 
> necessary to the encoder.

I'm not that surprised as the bitstream functions are raw functions that
were not that optimized (except the fact they've been qualified with
inline to speed up things)

> (Incidentally, kudos for the very clean and easy to follow code; XviD is 
> the best written video codec I've come across!)

Thanks

> diff -u -b -r1.21 global.h
> diff -u -b -r1.17 bitstream.h

The patch is on my little queue waiting for some testing as i'm syncing
all trees for the bitstream.h file. Expect it to be commited during the
night (european time).

-- 
Edouard Gomez-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://edu.bnhof.de/pipermail/xvid-devel/attachments/20030404/7789f838/attachment.bin


More information about the XviD-devel mailing list