]> git.sesse.net Git - ffmpeg/commitdiff
Don't use expressions with side effects in macro parameters
authorMartin Storsjö <martin@martin.st>
Thu, 28 Jul 2016 10:10:22 +0000 (13:10 +0300)
committerMartin Storsjö <martin@martin.st>
Sun, 31 Jul 2016 19:50:51 +0000 (22:50 +0300)
AV_WB32 can be implemented as a macro that expands its parameters
multiple times (in case AV_HAVE_FAST_UNALIGNED isn't set and the
compiler doesn't support GCC attributes); make sure not to read
multiple times from the source in this case.

Signed-off-by: Martin Storsjö <martin@martin.st>
libavcodec/dxv.c
libavformat/xmv.c

index 99327dfaceaf9a6345d40e3be019cb2b387ef116..39b297a2356f54b166e1853016dd6638c207aa21 100644 (file)
@@ -121,8 +121,10 @@ static int dxv_decompress_dxt1(AVCodecContext *avctx)
     int pos = 2;
 
     /* Copy the first two elements */
-    AV_WL32(ctx->tex_data, bytestream2_get_le32(gbc));
-    AV_WL32(ctx->tex_data + 4, bytestream2_get_le32(gbc));
+    value = bytestream2_get_le32(gbc);
+    AV_WL32(ctx->tex_data, value);
+    value = bytestream2_get_le32(gbc);
+    AV_WL32(ctx->tex_data + 4, value);
 
     /* Process input until the whole texture has been filled */
     while (pos + 2 <= ctx->tex_size / 4) {
@@ -172,10 +174,14 @@ static int dxv_decompress_dxt5(AVCodecContext *avctx)
     int probe, check;
 
     /* Copy the first four elements */
-    AV_WL32(ctx->tex_data +  0, bytestream2_get_le32(gbc));
-    AV_WL32(ctx->tex_data +  4, bytestream2_get_le32(gbc));
-    AV_WL32(ctx->tex_data +  8, bytestream2_get_le32(gbc));
-    AV_WL32(ctx->tex_data + 12, bytestream2_get_le32(gbc));
+    value = bytestream2_get_le32(gbc);
+    AV_WL32(ctx->tex_data +  0, value);
+    value = bytestream2_get_le32(gbc);
+    AV_WL32(ctx->tex_data +  4, value);
+    value = bytestream2_get_le32(gbc);
+    AV_WL32(ctx->tex_data +  8, value);
+    value = bytestream2_get_le32(gbc);
+    AV_WL32(ctx->tex_data + 12, value);
 
     /* Process input until the whole texture has been filled */
     while (pos + 2 <= ctx->tex_size / 4) {
index b2112b0e9581d7c25e015f51175428e3e7207794..fa391560f05683cbbc9f958e8ebb32bdbacebc63 100644 (file)
@@ -512,8 +512,10 @@ static int xmv_fetch_video_packet(AVFormatContext *s,
      * WMV2 is little-endian.
      * TODO: This manual swap is of course suboptimal.
      */
-    for (i = 0; i < frame_size; i += 4)
-        AV_WB32(pkt->data + i, avio_rl32(pb));
+    for (i = 0; i < frame_size; i += 4) {
+        uint32_t val = avio_rl32(pb);
+        AV_WB32(pkt->data + i, val);
+    }
 
     pkt->stream_index = video->stream_index;