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

Jeff Downs heydowns
Wed May 27 23:36:11 CEST 2009


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));

But I will add a temp if maintainer wants.

	-Jeff



More information about the ffmpeg-devel mailing list