[Ffmpeg-devel] [PATCH]: Too much alignment assumed by H264 decoder

David S. Miller davem
Mon Dec 26 03:53:24 CET 2005


From: Mike Melanson <mike at multimedia.cx>
Date: Sun, 25 Dec 2005 17:51:52 -0800

> 	Plus, it still doesn't make any sense: Why is an 8-byte alignment 
> causing trouble but a 4-byte alignment is okay? Logically, the 8-byte 
> alignment *is also* a 4-byte alignment.

The issue is that the mv_cache[] is an array of int16 objects.
So even if you align the "array" on an 8-byte boundary (which
is done using the __align8 directive), when you index into this
array as this code does, the resulting pointer will not necessarily
be 8-byte aligned.

I have a case trapped in GDB to explain this point, we are at this
block of code in write_back_motion():

        for(y=0; y<4; y++){
            *(uint64_t*)s->current_picture.motion_val[list][b_xy + 0 + y*h->b_stride]= *(uint64_t*)h->mv_cache[list][scan8[0]+0 + 8*y];
            *(uint64_t*)s->current_picture.motion_val[list][b_xy + 2 + y*h->b_stride]= *(uint64_t*)h->mv_cache[list][scan8[0]+2 + 8*y];
        }

The problematic access is the h->mv_cache[] one, h->mv_cache itself
is 8-byte aligned, but the indexed value here is only 4-byte aligned.

Is the problem at least a little bit clearer to folks now? :-)





More information about the ffmpeg-devel mailing list