[FFmpeg-devel] [PATCH] Fix MSRLE type punning

Måns Rullgård mans
Fri Dec 5 20:52:23 CET 2008


"Alex Converse" <alex.converse at gmail.com> writes:

> Since my last punning related email went over so well...
>
> libavcodec/msrledec.c:200: warning: dereferencing type-punned pointer will
> break strict-aliasing rules
>
> Regards,
> Alex Converse
>
> diff --git a/libavcodec/msrledec.c b/libavcodec/msrledec.c
> index f44b8b6..010ddda 100644
> --- a/libavcodec/msrledec.c
> +++ b/libavcodec/msrledec.c
> @@ -191,7 +191,7 @@ static int msrle_decode_8_16_24_32(AVCodecContext *avctx, AVPicture *pic, int de
>              }
>              pos += p2;
>          } else { //Run of pixels
> -            int pix[4]; //original pixel
> +            uint8_t pix[4]; //original pixel
>              switch(depth){
>              case  8: pix[0] = *src++;
>                       break;

That patch looks OK but for a different reason.  The assignments it's
warning about appear to be unnecessary, so this patch seems correct:

diff --git a/libavcodec/msrledec.c b/libavcodec/msrledec.c
index f44b8b6..a944062 100644
--- a/libavcodec/msrledec.c
+++ b/libavcodec/msrledec.c
@@ -197,7 +197,6 @@ static int msrle_decode_8_16_24_32(AVCodecContext *avctx, AVPicture *pic, int de
                      break;
             case 16: pix16 = AV_RL16(src);
                      src += 2;
-                     *(uint16_t*)pix = pix16;
                      break;
             case 24: pix[0] = *src++;
                      pix[1] = *src++;
@@ -205,7 +204,6 @@ static int msrle_decode_8_16_24_32(AVCodecContext *avctx, AVPicture *pic, int de
                      break;
             case 32: pix32 = AV_RL32(src);
                      src += 4;
-                     *(uint32_t*)pix = pix32;
                      break;
             }
             if (output + p1 * (depth >> 3) > output_end)


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




More information about the ffmpeg-devel mailing list