[Swfdec-commits] Branch '0.8' - 4 commits - swfdec/swfdec_audio_decoder_uncompressed.c swfdec/swfdec_bitmap_data.c swfdec/swfdec_bots.c swfdec/swfdec_image.c swfdec/swfdec_renderer.c swfdec/swfdec_types.h

Benjamin Otte company at kemper.freedesktop.org
Thu Oct 30 09:11:52 PDT 2008


 swfdec/swfdec_audio_decoder_uncompressed.c |   16 +++++++++-------
 swfdec/swfdec_bitmap_data.c                |   12 ++++++------
 swfdec/swfdec_bots.c                       |   11 ++++++++---
 swfdec/swfdec_image.c                      |    3 ++-
 swfdec/swfdec_renderer.c                   |    4 ++--
 swfdec/swfdec_types.h                      |    2 +-
 6 files changed, 28 insertions(+), 20 deletions(-)

New commits:
commit f935532759ade1a3b06bcc94f9a88da7bb5e797a
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 30 17:11:27 2008 +0100

    fix potential alignmnt problems

diff --git a/swfdec/swfdec_audio_decoder_uncompressed.c b/swfdec/swfdec_audio_decoder_uncompressed.c
index 5371d9f..6a4caf6 100644
--- a/swfdec/swfdec_audio_decoder_uncompressed.c
+++ b/swfdec/swfdec_audio_decoder_uncompressed.c
@@ -59,8 +59,10 @@ swfdec_audio_decoder_uncompressed_upscale (SwfdecBuffer *buffer, SwfdecAudioForm
 	buffer->length - n_samples * 2 * channels);
   }
   ret = swfdec_buffer_new (n_samples * 4 * granularity);
-  src = (gint16 *) buffer->data;
-  dest = (gint16 *) ret->data;
+  /* can be upscaled, because the input buffer and the newly allocated buffer 
+   * are aligned properly */
+  src = (gint16 *) (gpointer) buffer->data;
+  dest = (gint16 *) (gpointer) ret->data;
   for (i = 0; i < n_samples; i++) {
     for (j = 0; j < granularity; j++) {
       *dest++ = src[0];
@@ -96,19 +98,19 @@ static SwfdecBuffer *
 swfdec_audio_decoder_uncompressed_decode_16bit (SwfdecBuffer *buffer)
 {
   SwfdecBuffer *ret;
-  gint16 *src, *dest;
+  SwfdecBits bits;
+  gint16 *dest;
   guint i;
 
   if (buffer->length & 2) {
     SWFDEC_ERROR ("buffer length not a multiple of 16bit");
   }
   ret = swfdec_buffer_new (buffer->length & ~1);
-  src = (gint16 *) buffer->data;
-  dest = (gint16 *) ret->data;
+  swfdec_bits_init (&bits, buffer);
+  dest = (gint16 *) (gpointer) ret->data;
   for (i = 0; i < ret->length; i += 2) {
-    *dest = GINT16_FROM_LE (*src);
+    *dest = swfdec_bits_get_u16 (&bits);
     dest++;
-    src++;
   }
 
   return ret;
commit 3fa1c067d996b1414f2023c6866cecf44eac284f
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 30 17:11:19 2008 +0100

    fix alignment problems

diff --git a/swfdec/swfdec_bots.c b/swfdec/swfdec_bots.c
index b5d8177..eda1b7a 100644
--- a/swfdec/swfdec_bots.c
+++ b/swfdec/swfdec_bots.c
@@ -178,7 +178,8 @@ swfdec_bots_put_u16 (SwfdecBots *bots, guint i)
   g_return_if_fail (i <= G_MAXUINT16);
 
   swfdec_bots_prepare_bytes (bots, 2);
-  *(guint16 *)bots->ptr = GUINT16_TO_LE (i);
+  bots->ptr[0] = i;
+  bots->ptr[1] = i >> 8;
   bots->ptr += 2;
 }
 
@@ -188,7 +189,8 @@ swfdec_bots_put_s16 (SwfdecBots *bots, int i)
   g_return_if_fail (i >= G_MININT16 && i <= G_MAXINT16);
 
   swfdec_bots_prepare_bytes (bots, 2);
-  *(guint16 *)bots->ptr = GINT16_TO_LE (i);
+  bots->ptr[0] = i;
+  bots->ptr[1] = i >> 8;
   bots->ptr += 2;
 }
 
@@ -198,7 +200,10 @@ swfdec_bots_put_u32 (SwfdecBots *bots, guint i)
   g_return_if_fail (i <= G_MAXUINT32);
 
   swfdec_bots_prepare_bytes (bots, 4);
-  *(guint32 *)bots->ptr = GUINT32_TO_LE (i);
+  bots->ptr[0] = i;
+  bots->ptr[1] = i >> 8;
+  bots->ptr[2] = i >> 16;
+  bots->ptr[3] = i >> 24;
   bots->ptr += 4;
 }
 
commit bdf0e901332300d7da7c589d772d29e97929a92a
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 30 17:10:10 2008 +0100

    fix bogus alignment warnings on ARM

diff --git a/swfdec/swfdec_bitmap_data.c b/swfdec/swfdec_bitmap_data.c
index dac1dd1..a7b1728 100644
--- a/swfdec/swfdec_bitmap_data.c
+++ b/swfdec/swfdec_bitmap_data.c
@@ -316,7 +316,7 @@ swfdec_bitmap_data_getPixel (SwfdecAsContext *cx, SwfdecAsObject *object,
   addr = cairo_image_surface_get_data (bitmap->surface);
   addr += cairo_image_surface_get_stride (bitmap->surface) * y;
   addr += 4 * x;
-  color = *(SwfdecColor *) addr;
+  color = *(SwfdecColor *) (gpointer) addr;
   color = SWFDEC_COLOR_UNMULTIPLY (color);
   color &= SWFDEC_COLOR_COMBINE (0xFF, 0xFF, 0xFF, 0);
   SWFDEC_AS_VALUE_SET_INT (ret, color);
@@ -342,10 +342,10 @@ swfdec_bitmap_data_setPixel (SwfdecAsContext *cx, SwfdecAsObject *object,
   addr = cairo_image_surface_get_data (bitmap->surface);
   addr += cairo_image_surface_get_stride (bitmap->surface) * y;
   addr += 4 * x;
-  old = *(SwfdecColor *) addr;
+  old = *(SwfdecColor *) (gpointer) addr;
   old |= SWFDEC_COLOR_COMBINE (0xFF, 0xFF, 0xFF, 0);
   color = old & SWFDEC_COLOR_OPAQUE (color);
-  *(SwfdecColor *) addr = SWFDEC_COLOR_MULTIPLY (color);
+  *(SwfdecColor *) (gpointer) addr = SWFDEC_COLOR_MULTIPLY (color);
   cairo_surface_mark_dirty_rectangle (bitmap->surface, x, y, 1, 1);
   swfdec_bitmap_data_invalidate (bitmap, x, y, 1, 1);
 }
@@ -575,7 +575,7 @@ swfdec_bitmap_data_getPixel32 (SwfdecAsContext *cx, SwfdecAsObject *object,
   addr = cairo_image_surface_get_data (bitmap->surface);
   addr += cairo_image_surface_get_stride (bitmap->surface) * y;
   addr += 4 * x;
-  color = *(SwfdecColor *) addr;
+  color = *(SwfdecColor *) (gpointer) addr;
   color = SWFDEC_COLOR_UNMULTIPLY (color);
   SWFDEC_AS_VALUE_SET_INT (ret, color);
 }
@@ -600,9 +600,9 @@ swfdec_bitmap_data_setPixel32 (SwfdecAsContext *cx, SwfdecAsObject *object,
   addr += cairo_image_surface_get_stride (bitmap->surface) * y;
   addr += 4 * x;
   if (swfdec_surface_has_alpha (bitmap->surface)) {
-    *(SwfdecColor *) addr = SWFDEC_COLOR_MULTIPLY ((SwfdecColor) color);
+    *(SwfdecColor *) (gpointer) addr = SWFDEC_COLOR_MULTIPLY ((SwfdecColor) color);
   } else {
-    *(SwfdecColor *) addr = SWFDEC_COLOR_OPAQUE ((SwfdecColor) color);
+    *(SwfdecColor *) (gpointer) addr = SWFDEC_COLOR_OPAQUE ((SwfdecColor) color);
   }
   cairo_surface_mark_dirty_rectangle (bitmap->surface, x, y, 1, 1);
   swfdec_bitmap_data_invalidate (bitmap, x, y, 1, 1);
diff --git a/swfdec/swfdec_image.c b/swfdec/swfdec_image.c
index 23a6845..328d19b 100644
--- a/swfdec/swfdec_image.c
+++ b/swfdec/swfdec_image.c
@@ -402,7 +402,8 @@ swfdec_image_lossless_load (SwfdecImage *image, SwfdecRenderer *renderer)
     if (palette_size < 256)
       memset (palette + palette_size, 0, (256 - palette_size) * 4);
 
-    pixels = (guint32 *) data;
+    /* cast is safe, we malloc'd the memory above */
+    pixels = (guint32 *) (gpointer) data;
     for (j = 0; j < (guint) image->height; j++) {
       for (i = 0; i < (guint) image->width; i++) {
 	*pixels = palette[indexed_data[i]];
diff --git a/swfdec/swfdec_renderer.c b/swfdec/swfdec_renderer.c
index 259f28a..39faa60 100644
--- a/swfdec/swfdec_renderer.c
+++ b/swfdec/swfdec_renderer.c
@@ -429,10 +429,10 @@ swfdec_renderer_transform (SwfdecRenderer *renderer, cairo_surface_t *surface,
   tstride = cairo_image_surface_get_stride (target);
   for (y = 0; y < h; y++) {
     for (x = 0; x < w; x++) {
-      color = ((guint32 *) sdata)[x];
+      color = ((guint32 *) (gpointer) sdata)[x];
       color |= mask;
       color = swfdec_color_apply_transform_premultiplied (color, trans);
-      ((guint32 *) tdata)[x] = color;
+      ((guint32 *) (gpointer) tdata)[x] = color;
     }
     sdata += sstride;
     tdata += tstride;
commit a6d2d12f1195e45932b980584e99d421c1a45de2
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 30 17:09:35 2008 +0100

    portability fix: make sure SwfdecColor is 32bit

diff --git a/swfdec/swfdec_types.h b/swfdec/swfdec_types.h
index d8281c9..0bc9bdf 100644
--- a/swfdec/swfdec_types.h
+++ b/swfdec/swfdec_types.h
@@ -9,7 +9,7 @@ G_BEGIN_DECLS
 
 /* Pixel value in the same colorspace as cairo - endian-dependant ARGB.
  * The alpha pixel must be present */
-typedef guint SwfdecColor;
+typedef guint32 SwfdecColor;
 
 /* audio is 44100Hz, framerate is multiple of 256Hz, FLV timestamps are 1000Hz
  * This is a multiple of all these numbers, so we can be always accurate


More information about the Swfdec-commits mailing list