[FFmpeg-devel] [RFC]Do not alias data pointer in kega decoder

Carl Eugen Hoyos cehoyos at ag.or.at
Thu Feb 28 23:38:50 CET 2013


Hi!

Attached patch fixes the kega fate failure with icc 13.1.0 on intel64 - 
http://fate.ffmpeg.org/report.cgi?time=20130228212822&slot=x86_64-archlinux-icc-2013 - 
a regression since 33cd32b. Since it does not help for ia32, it is probably 
not the correct solution;-(

Other ideas welcome, Carl Eugen
-------------- next part --------------
diff --git a/libavcodec/kgv1dec.c b/libavcodec/kgv1dec.c
index 008843c..8efd238 100644
--- a/libavcodec/kgv1dec.c
+++ b/libavcodec/kgv1dec.c
@@ -50,7 +50,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
     const uint8_t *buf_end = buf + avpkt->size;
     KgvContext * const c = avctx->priv_data;
     int offsets[8];
-    uint16_t *out, *prev;
+    uint8_t *out, *prev;
     int outcnt = 0, maxcnt;
     int w, h, i, res;
 
@@ -75,9 +75,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
     c->cur.reference = 3;
     if ((res = ff_get_buffer(avctx, &c->cur)) < 0)
         return res;
-    out  = (uint16_t *) c->cur.data[0];
+    out  = c->cur.data[0];
     if (c->prev.data[0]) {
-        prev = (uint16_t *) c->prev.data[0];
+        prev = c->prev.data[0];
     } else {
         prev = NULL;
     }
@@ -90,11 +90,12 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
         buf += 2;
 
         if (!(code & 0x8000)) {
-            out[outcnt++] = code; // rgb555 pixel coded directly
+            AV_WL16(&out[2 * outcnt], code); // rgb555 pixel coded directly
+            outcnt++;
         } else {
             int count;
             int inp_off;
-            uint16_t *inp;
+            uint8_t *inp;
 
             if ((code & 0x6000) == 0x6000) {
                 // copy from previous frame
@@ -148,7 +149,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
                 break;
 
             for (i = inp_off; i < count + inp_off; i++) {
-                out[outcnt++] = inp[i];
+                AV_WN16(&out[2 * outcnt], AV_RN16(&inp[2 * i]));
+                outcnt++;
             }
         }
     }


More information about the ffmpeg-devel mailing list