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

Jeff Downs heydowns
Fri May 29 18:16:53 CEST 2009


On Thu, 28 May 2009, M?ns Rullg?rd wrote:

> Jeff Downs <heydowns at borg.com> writes:
> >
> > 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.

If that is the case, then should the macro definitions be fixed?  The 
read/write pairing is used elsewhere (dsputil.h).

Either way, here is the change in lcldec that was suggested.

	-Jeff
-------------- next part --------------
Index: libavcodec/lcldec.c
===================================================================
--- libavcodec/lcldec.c	(revision 18972)
+++ libavcodec/lcldec.c	(working copy)
@@ -127,9 +127,11 @@
             continue;
         }
         if ((mask & (1 << (--maskbit))) == 0) {
+            uint32_t tmp;
             if (destptr + 4 > destptr_end)
                 break;
-            AV_WN32(destptr, AV_RN32(srcptr));
+            tmp = AV_RN32(srcptr);
+            AV_WN32(destptr, tmp);
             srclen -= 4;
             destptr += 4;
             srcptr += 4;



More information about the ffmpeg-devel mailing list