[Swfdec] 8 commits - libswfdec/swfdec_as_date.c libswfdec/swfdec_as_object.c libswfdec/swfdec_as_types.c libswfdec/swfdec_bits.c libswfdec/swfdec_codec_gst.c libswfdec/swfdec_text_field_movie_html.c test/trace

Benjamin Otte company at kemper.freedesktop.org
Thu Jan 10 04:37:43 PST 2008


 libswfdec/swfdec_as_date.c               |   47 +++----
 libswfdec/swfdec_as_object.c             |    4 
 libswfdec/swfdec_as_types.c              |  190 +++++++++++++++----------------
 libswfdec/swfdec_bits.c                  |    2 
 libswfdec/swfdec_codec_gst.c             |   13 +-
 libswfdec/swfdec_text_field_movie_html.c |    2 
 test/trace/Makefile.am                   |    2 
 test/trace/default.as                    |   49 -------
 test/trace/default.stas                  |   49 +++++++
 9 files changed, 178 insertions(+), 180 deletions(-)

New commits:
commit 07c006a9785a5043c0a0a4b8d78b28c0735020c4
Author: Valery Masiutsin <val.masutin at gmail.com>
Date:   Thu Jan 10 12:41:15 2008 +0100

    this variable can be used uninitialized

diff --git a/libswfdec/swfdec_text_field_movie_html.c b/libswfdec/swfdec_text_field_movie_html.c
index 0fc6897..b0aa94f 100644
--- a/libswfdec/swfdec_text_field_movie_html.c
+++ b/libswfdec/swfdec_text_field_movie_html.c
@@ -542,7 +542,7 @@ swfdec_text_field_movie_html_text_append_paragraph (SwfdecTextFieldMovie *text,
   SwfdecTextFormat *format, *format_prev, *format_font;
   GSList *iter, *fonts, *iter_font;
   guint index_, index_prev;
-  gboolean textformat, bullet, font;
+  gboolean textformat, bullet, font = FALSE;
   char *escaped;
 
   g_return_val_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text), string);
commit bfaa75ec99c1b7dea4168811a97ef2071c5313bb
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Jan 10 12:38:29 2008 +0100

    s/ALIGN/SWFDEC_ALIGN/
    
    apparently some weird headers have an ALIGN macro hidden somewhere

diff --git a/libswfdec/swfdec_codec_gst.c b/libswfdec/swfdec_codec_gst.c
index 22c5638..2167050 100644
--- a/libswfdec/swfdec_codec_gst.c
+++ b/libswfdec/swfdec_codec_gst.c
@@ -492,7 +492,7 @@ swfdec_video_decoder_gst_decode (SwfdecVideoDecoder *dec, SwfdecBuffer *buffer,
     SwfdecVideoImage *image)
 {
   SwfdecGstVideo *player = (SwfdecGstVideo *) dec;
-#define ALIGN(x, n) (((x) + (n) - 1) & (~((n) - 1)))
+#define SWFDEC_ALIGN(x, n) (((x) + (n) - 1) & (~((n) - 1)))
   GstBuffer *buf;
   GstCaps *caps;
   GstStructure *structure;
@@ -542,17 +542,18 @@ swfdec_video_decoder_gst_decode (SwfdecVideoDecoder *dec, SwfdecBuffer *buffer,
       break;
     case SWFDEC_VIDEO_FORMAT_I420:
       image->plane[0] = buf->data;
-      image->rowstride[0] = ALIGN (image->width, 4);
-      image->plane[1] = image->plane[0] + image->rowstride[0] * ALIGN (image->height, 2);
-      image->rowstride[1] = ALIGN (image->width, 8) / 2;
-      image->plane[2] = image->plane[1] + image->rowstride[1] * ALIGN (image->height, 2) / 2;
+      image->rowstride[0] = SWFDEC_ALIGN (image->width, 4);
+      image->plane[1] = image->plane[0] + image->rowstride[0] * SWFDEC_ALIGN (image->height, 2);
+      image->rowstride[1] = SWFDEC_ALIGN (image->width, 8) / 2;
+      image->plane[2] = image->plane[1] + image->rowstride[1] * SWFDEC_ALIGN (image->height, 2) / 2;
       image->rowstride[2] = image->rowstride[1];
-      g_assert (image->plane[2] + image->rowstride[2] * ALIGN (image->height, 2) / 2 == image->plane[0] + buf->size);
+      g_assert (image->plane[2] + image->rowstride[2] * SWFDEC_ALIGN (image->height, 2) / 2 == image->plane[0] + buf->size);
       break;
     default:
       g_return_val_if_reached (FALSE);
   }
   return TRUE;
+#undef SWFDEC_ALIGN
 }
 
 static GstCaps *
commit 433e3503b0eb38246ba068ec0699944cc1d62ba0
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Jan 10 12:33:52 2008 +0100

    cast the types in correctly debug message

diff --git a/libswfdec/swfdec_bits.c b/libswfdec/swfdec_bits.c
index 4faaa0b..1cf166d 100644
--- a/libswfdec/swfdec_bits.c
+++ b/libswfdec/swfdec_bits.c
@@ -743,7 +743,7 @@ out:
   } else {
     if (buffer->length < z.total_out) {
       SWFDEC_WARNING ("Not enough data decompressed: %lu instead of %"G_GSIZE_FORMAT" expected",
-	  z.total_out, buffer->length);
+	  (gulong) z.total_out, buffer->length);
       memset (buffer->data + z.total_out, 0, buffer->length - z.total_out);
     }
   }
commit af566c89e2fbefe9b61dcfb088cda66edbe09958
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Jan 10 12:32:23 2008 +0100

    silence old gcc versions

diff --git a/libswfdec/swfdec_as_object.c b/libswfdec/swfdec_as_object.c
index b9c7a13..a5af75d 100644
--- a/libswfdec/swfdec_as_object.c
+++ b/libswfdec/swfdec_as_object.c
@@ -1298,7 +1298,7 @@ swfdec_as_object_create (SwfdecAsFunction *fun, guint n_args,
   SwfdecAsContext *context;
   SwfdecAsFunction *cur;
   SwfdecAsFrame *frame;
-  guint size;
+  guint size = 0;
   GType type = 0;
 
   g_return_if_fail (SWFDEC_IS_AS_FUNCTION (fun));
commit 616c94fc0b584d3c359bc09e29be381f8f43e4ab
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Jan 10 12:24:48 2008 +0100

    get rid of fpclassify()
    
    Should make porting easier.

diff --git a/libswfdec/swfdec_as_types.c b/libswfdec/swfdec_as_types.c
index 8e87a6b..420d094 100644
--- a/libswfdec/swfdec_as_types.c
+++ b/libswfdec/swfdec_as_types.c
@@ -248,105 +248,103 @@ swfdec_as_integer_to_string (SwfdecAsContext *context, int i)
 const char *
 swfdec_as_double_to_string (SwfdecAsContext *context, double d)
 {
+  gboolean found = FALSE, gotdot = FALSE;
+  guint digits = 15;
+  char tmp[50], *end, *start, *s;
+
   g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), SWFDEC_AS_STR_EMPTY);
 
-  switch (fpclassify (d)) {
-    case FP_ZERO:
-      return SWFDEC_AS_STR_0;
-    case FP_INFINITE:
-      return d < 0 ? SWFDEC_AS_STR__Infinity : SWFDEC_AS_STR_Infinity;
-    case FP_NAN:
-      return SWFDEC_AS_STR_NaN;
-    default:
-      {
-	gboolean found = FALSE, gotdot = FALSE;
-	guint digits = 15;
-	char tmp[50], *end, *start, *s;
-	tmp[0] = ' ';
-	s = &tmp[1];
-	if (ABS (d) > 0.00001 && ABS (d) < 1e+15) {
-	  g_ascii_formatd (s, 50, "%.22f", d);
-	} else {
-	  g_ascii_formatd (s, 50, "%.25e", d);
-	}
-	start = s;
-	/* skip - sign */
-	if (*start == '-')
-	  start++;
-	/* count digits (maximum allowed is 15) */
-	while (digits) {
-	  if (*start == '.') {
-	    start++;
-	    gotdot = TRUE;
-	    continue;
-	  }
-	  if (*start < '0' || *start > '9')
-	    break;
-	  if (found || *start != '0') {
-	    digits--;
-	    found = TRUE;
-	  }
-	  start++;
-	}
-	end = start;
-	/* go to end of string */
-	while (*end != 'e' && *end != 0)
-	  end++;
-	/* round using the next digit */
-	if (*start >= '5' && *start <= '9') {
-	  char *finish = NULL;
-	  /* skip all 9s at the end */
-	  while (start[-1] == '9')
-	    start--;
-	  /* if we're before the dot, replace 9s with 0s */
-	  if (start[-1] == '.') {
-	    finish = start;
-	    start--;
-	  }
-	  while (start[-1] == '9') {
-	    start[-1] = '0';
-	    start--;
-	  }
-	  /* write out correct number */
-	  if (start[-1] == '-') {
-	    s--;
-	    start[-2] = '-';
-	    start[-1] = '1';
-	  } else if (start[-1] == ' ') {
-	    s--;
-	    start[-1] = '1';
-	  } else {
-	    start[-1]++;
-	  }
-	  /* reposition cursor at end */
-	  if (finish)
-	    start = finish;
-	}
-	/* remove trailing zeros (note we skipped zero above, so there will be non-0 bytes left) */
-	if (gotdot) {
-	  while (start[-1] == '0')
-	    start--;
-	  if (start[-1] == '.')
-	    start--;
-	}
-	/* add exponent */
-	if (*end == 'e') {
-	  /* 'e' */
-	  *start++ = *end++;
-	  /* + or - */
-	  *start++ = *end++;
-	  /* skip 0s */
-	  while (*end == '0')
-	    end++;
-	  /* add rest */
-	  while (*end != 0)
-	    *start++ = *end++;
-	}
-	/* end string */
-	*start = 0;
-	return swfdec_as_context_get_string (context, s);
-      }
+  if (isnan (d))
+    return SWFDEC_AS_STR_NaN;
+  if (!isinf (d))
+    return d < 0 ? SWFDEC_AS_STR__Infinity : SWFDEC_AS_STR_Infinity;
+  /* stupid -0.0 */
+  if (fabs (d) == 0.0)
+    return SWFDEC_AS_STR_0;
+
+  tmp[0] = ' ';
+  s = &tmp[1];
+  if (ABS (d) > 0.00001 && ABS (d) < 1e+15) {
+    g_ascii_formatd (s, 50, "%.22f", d);
+  } else {
+    g_ascii_formatd (s, 50, "%.25e", d);
+  }
+  start = s;
+  /* skip - sign */
+  if (*start == '-')
+    start++;
+  /* count digits (maximum allowed is 15) */
+  while (digits) {
+    if (*start == '.') {
+      start++;
+      gotdot = TRUE;
+      continue;
+    }
+    if (*start < '0' || *start > '9')
+      break;
+    if (found || *start != '0') {
+      digits--;
+      found = TRUE;
+    }
+    start++;
+  }
+  end = start;
+  /* go to end of string */
+  while (*end != 'e' && *end != 0)
+    end++;
+  /* round using the next digit */
+  if (*start >= '5' && *start <= '9') {
+    char *finish = NULL;
+    /* skip all 9s at the end */
+    while (start[-1] == '9')
+      start--;
+    /* if we're before the dot, replace 9s with 0s */
+    if (start[-1] == '.') {
+      finish = start;
+      start--;
+    }
+    while (start[-1] == '9') {
+      start[-1] = '0';
+      start--;
+    }
+    /* write out correct number */
+    if (start[-1] == '-') {
+      s--;
+      start[-2] = '-';
+      start[-1] = '1';
+    } else if (start[-1] == ' ') {
+      s--;
+      start[-1] = '1';
+    } else {
+      start[-1]++;
+    }
+    /* reposition cursor at end */
+    if (finish)
+      start = finish;
+  }
+  /* remove trailing zeros (note we skipped zero above, so there will be non-0 bytes left) */
+  if (gotdot) {
+    while (start[-1] == '0')
+      start--;
+    if (start[-1] == '.')
+      start--;
+  }
+  /* add exponent */
+  if (*end == 'e') {
+    /* 'e' */
+    *start++ = *end++;
+    /* + or - */
+    *start++ = *end++;
+    /* skip 0s */
+    while (*end == '0')
+      end++;
+    /* add rest */
+    while (*end != 0)
+      *start++ = *end++;
   }
+  /* end string */
+  *start = 0;
+  return swfdec_as_context_get_string (context, s);
 }
 
 /**
commit 135358d039b3f6e1f79809aab42defffa009c9fb
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Jan 10 12:06:27 2008 +0100

    make this function more readable and hopefully fix OpenBSD complaints

diff --git a/libswfdec/swfdec_as_date.c b/libswfdec/swfdec_as_date.c
index 648b50f..890d274 100644
--- a/libswfdec/swfdec_as_date.c
+++ b/libswfdec/swfdec_as_date.c
@@ -918,37 +918,34 @@ swfdec_as_date_UTC (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
 
   memset (&brokentime, 0, sizeof (brokentime));
 
-  i = 0;
-
-  if (argc > i) {
-    if (swfdec_as_date_value_to_number_and_integer_floor (cx, &argv[i++], &d,
+  if (argc > 0) {
+    if (swfdec_as_date_value_to_number_and_integer_floor (cx, &argv[0], &d,
 	  &num)) {
       year = num;
     } else {
       // special case: if year is not finite set it to -1900
       year = -1900;
     }
+  } else {
+    return;
   }
 
   // if we don't got atleast two values, return undefined
   // do it only here, so valueOf first arg is called
-  if (argc < 2) {
+  if (argc < 2) 
     return;
-  }
 
-  if (argc > i) {
-    if (swfdec_as_date_value_to_number_and_integer (cx, &argv[i++], &d,
-	  &num)) {
-      brokentime.month = num;
-    } else {
-      // special case: if month is not finite set year to -1900
-      year = -1900;
-      brokentime.month = 0;
-    }
+  if (swfdec_as_date_value_to_number_and_integer (cx, &argv[1], &d,
+	&num)) {
+    brokentime.month = num;
+  } else {
+    // special case: if month is not finite set year to -1900
+    year = -1900;
+    brokentime.month = 0;
   }
 
-  if (argc > i) {
-    if (swfdec_as_date_value_to_number_and_integer (cx, &argv[i++], &d,
+  if (argc > 2) {
+    if (swfdec_as_date_value_to_number_and_integer (cx, &argv[2], &d,
 	  &num)) {
       brokentime.day_of_month = num;
     } else {
@@ -959,8 +956,8 @@ swfdec_as_date_UTC (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
     brokentime.day_of_month = 1;
   }
 
-  if (argc > i) {
-    if (swfdec_as_date_value_to_number_and_integer (cx, &argv[i++], &d,
+  if (argc > 3) {
+    if (swfdec_as_date_value_to_number_and_integer (cx, &argv[3], &d,
 	  &num)) {
       brokentime.hours = num;
     } else {
@@ -969,8 +966,8 @@ swfdec_as_date_UTC (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
     }
   }
 
-  if (argc > i) {
-    if (swfdec_as_date_value_to_number_and_integer (cx, &argv[i++], &d,
+  if (argc > 4) {
+    if (swfdec_as_date_value_to_number_and_integer (cx, &argv[4], &d,
 	  &num)) {
       brokentime.minutes = num;
     } else {
@@ -979,8 +976,8 @@ swfdec_as_date_UTC (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
     }
   }
 
-  if (argc > i) {
-    if (swfdec_as_date_value_to_number_and_integer (cx, &argv[i++], &d,
+  if (argc > 5) {
+    if (swfdec_as_date_value_to_number_and_integer (cx, &argv[5], &d,
 	  &num)) {
       brokentime.seconds = num;
     } else {
@@ -995,8 +992,8 @@ swfdec_as_date_UTC (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
     brokentime.year = year;
   }
 
-  if (argc > i) {
-    if (swfdec_as_date_value_to_number_and_integer (cx, &argv[i++], &d,
+  if (argc > 6) {
+    if (swfdec_as_date_value_to_number_and_integer (cx, &argv[6], &d,
 	  &num)) {
       brokentime.milliseconds = num;
     } else {
commit 3d93cb3797729c70119069f54f74794a71103f55
Author: Benjamin Otte <otte at gnome.org>
Date:   Wed Jan 9 23:48:10 2008 +0100

    typo

diff --git a/libswfdec/swfdec_as_object.c b/libswfdec/swfdec_as_object.c
index b3c220a..b9c7a13 100644
--- a/libswfdec/swfdec_as_object.c
+++ b/libswfdec/swfdec_as_object.c
@@ -101,7 +101,7 @@
  * @variable: garbage-collected name of the current variables
  * @value: value of the current variable
  * @flags: Flags associated with the current variable
- * @data: User dta passed to swfdec_as_object_foreach()
+ * @data: User data passed to swfdec_as_object_foreach()
  *
  * Function prototype for the swfdec_as_object_foreach() function.
  *
commit 55c0e70445d7f4968e37cac2ff7a987f3608190e
Author: Benjamin Otte <otte at gnome.org>
Date:   Wed Jan 9 12:55:47 2008 +0100

    rename default.as to default.stas and include it in EXTRA_DIST

diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 45ed833..f73c024 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -702,6 +702,8 @@ EXTRA_DIST = \
 	date-properties-7.swf.trace \
 	date-properties-8.swf \
 	date-properties-8.swf.trace \
+	default.stas \
+	default.sts
 	definebutton-5.swf \
 	definebutton-5.swf.act \
 	definebutton-5.swf.trace \
diff --git a/test/trace/default.as b/test/trace/default.as
deleted file mode 100644
index 3f31797..0000000
--- a/test/trace/default.as
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Swfdec
- * Copyright (C) 2008 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, 
- * Boston, MA  02110-1301  USA
- */
-
-run_test = function (t, file) {
-  var e;
-  print ("Testing " + file);
-  try {
-    t.reset (file);
-    t.trace (file + ".trace");
-    t.advance (0);
-    t.advance (Math.ceil (10000 / t.rate));
-    t.trace ();
-  } catch (e) {
-    if (e) {
-      error (e);
-      return false;
-    }
-  };
-  Native.print ("  OK\n");
-  return true;
-};
-
-filenames.sort ();
-t = new Test ();
-fail = [];
-for (var i = 0; i < filenames.length; i++) {
-  if (!run_test (t, filenames[i]))
-    fail.push (filenames[i]);
-};
-if (fail.length > 0) {
-  error (fail.join ("\n       "));
-  throw (fail.length + " failures");
-}
diff --git a/test/trace/default.stas b/test/trace/default.stas
new file mode 100644
index 0000000..3f31797
--- /dev/null
+++ b/test/trace/default.stas
@@ -0,0 +1,49 @@
+/* Swfdec
+ * Copyright (C) 2008 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+ * Boston, MA  02110-1301  USA
+ */
+
+run_test = function (t, file) {
+  var e;
+  print ("Testing " + file);
+  try {
+    t.reset (file);
+    t.trace (file + ".trace");
+    t.advance (0);
+    t.advance (Math.ceil (10000 / t.rate));
+    t.trace ();
+  } catch (e) {
+    if (e) {
+      error (e);
+      return false;
+    }
+  };
+  Native.print ("  OK\n");
+  return true;
+};
+
+filenames.sort ();
+t = new Test ();
+fail = [];
+for (var i = 0; i < filenames.length; i++) {
+  if (!run_test (t, filenames[i]))
+    fail.push (filenames[i]);
+};
+if (fail.length > 0) {
+  error (fail.join ("\n       "));
+  throw (fail.length + " failures");
+}


More information about the Swfdec mailing list