[FFmpeg-devel] [PATCH] Fix unaligned access in lcl decoder

Måns Rullgård mans
Fri May 29 00:28:44 CEST 2009


Jeff Downs <heydowns at borg.com> writes:

> On Wed, 27 May 2009, Reimar D?ffinger wrote:
>
>> On Wed, May 27, 2009 at 02:31:56PM -0400, Jeff Downs wrote:
>> > Index: libavcodec/lcldec.c
>> > ===================================================================
>> > --- libavcodec/lcldec.c	(revision 18893)
>> > +++ libavcodec/lcldec.c	(working copy)
>> > @@ -129,7 +129,7 @@
>> >          if ((mask & (1 << (--maskbit))) == 0) {
>> >              if (destptr + 4 > destptr_end)
>> >                  break;
>> > -            *(int*)destptr = *(int*)srcptr;
>> > +            AV_WN32(destptr, AV_RN32(srcptr));
>> >              srclen -= 4;
>> >              destptr += 4;
>> >              srcptr += 4;
>> 
>> Did you check the compiler does not make a mess of it, due to multiple evaluation of AV_RN?
>> I'd feel mor comfortable with a temporary variable in there.
>> Well, actually I wonder, is there any reason why these need to be macros instead of
>> static inline functions?
>
> It looks fine. It expands to:
>
> (((struct unaligned_32 *) (destptr))->l) = 
>     ((((const struct unaligned_32 *) (srcptr))->l));

That's what it does with gcc.  With the shift/or variant it will be
something much uglier.

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list