[Swfdec] Branch 'interpreter' - 6 commits - libswfdec/swfdec_bits.c libswfdec/swfdec_compiler.c libswfdec/swfdec_sprite.c test/swfdec-extract.c

Benjamin Otte company at kemper.freedesktop.org
Fri Feb 2 14:10:19 PST 2007


 libswfdec/swfdec_bits.c     |    4 +++-
 libswfdec/swfdec_compiler.c |    6 +++++-
 libswfdec/swfdec_sprite.c   |   26 ++++++++++++++------------
 test/swfdec-extract.c       |    2 +-
 4 files changed, 23 insertions(+), 15 deletions(-)

New commits:
diff-tree 940ef9614313d253bb9282e26f48968b4af13c85 (from 828ab7af700ce3d9b4e44b90c4f7d804b5d243cc)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Feb 2 21:30:02 2007 +0100

    missing \n

diff --git a/test/swfdec-extract.c b/test/swfdec-extract.c
index bea068e..ac79124 100644
--- a/test/swfdec-extract.c
+++ b/test/swfdec-extract.c
@@ -259,7 +259,7 @@ main (int argc, char *argv[])
     if (!export_graphic (SWFDEC_GRAPHIC (character), argv[3]))
       ret = 1;
   } else {
-    g_printerr ("id %ld does not specify an exportable object", id);
+    g_printerr ("id %ld does not specify an exportable object\n", id);
     ret = 1;
   }
 
diff-tree 828ab7af700ce3d9b4e44b90c4f7d804b5d243cc (from parents)
Merge: 94e07c556a4e4f471f6700af54f35e55edf79a85 12bf86eb10e873ca735fad310d7ab9e517f6662b
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Feb 2 19:00:13 2007 +0100

    Merge branch 'master' into interpreter

diff-tree 12bf86eb10e873ca735fad310d7ab9e517f6662b (from b144bf362ce73d4a739663f8a28261eb317f45be)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Feb 2 18:59:45 2007 +0100

    Finish compiling at end of bitstream, too, not just with 0 action

diff --git a/libswfdec/swfdec_compiler.c b/libswfdec/swfdec_compiler.c
index abeec0b..68221e3 100644
--- a/libswfdec/swfdec_compiler.c
+++ b/libswfdec/swfdec_compiler.c
@@ -559,6 +559,10 @@ compile_push (CompileState *state, guint
     switch (type) {
       case 0: /* string */
 	s = swfdec_bits_skip_string (state->bits);
+	if (s) {
+	  compile_state_error (state, "Push: Could not get string");
+	  return;
+	}
 	compile_state_debug_add (state, "Push \"%s\"", s);
 	push_string (state, s);
 	break;
@@ -1300,7 +1304,7 @@ swfdec_compile (SwfdecPlayer *player, Sw
     name = "Unnamed script";
   compile_state_init (player->jscx, bits, version, &state);
   SWFDEC_INFO ("Creating new script in frame");
-  while ((action = swfdec_bits_get_u8 (bits))) {
+  while (swfdec_bits_left (bits) && (action = swfdec_bits_get_u8 (bits))) {
     if (action & 0x80) {
       len = swfdec_bits_get_u16 (bits);
     } else {
diff-tree b144bf362ce73d4a739663f8a28261eb317f45be (from c93579e07522e43a3d4d3ba9927d50ee74d5d5cb)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Feb 2 18:59:15 2007 +0100

    Clean up parsing of actions in PlaceObject2

diff --git a/libswfdec/swfdec_sprite.c b/libswfdec/swfdec_sprite.c
index 440c3b8..9201218 100644
--- a/libswfdec/swfdec_sprite.c
+++ b/libswfdec/swfdec_sprite.c
@@ -395,10 +395,13 @@ swfdec_spriteseg_place_object_2 (SwfdecS
     else
       script_name = g_strdup_printf ("Sprite%u", SWFDEC_CHARACTER (content->graphic)->id);
     while ((event_flags = swfdec_get_clipeventflags (s, bits)) != 0) {
-      guint tmp = swfdec_bits_get_u32 (bits);
-      SwfdecBits save = *bits;
-      swfdec_bits_skip_bytes (&save, tmp);
-
+      guint length = swfdec_bits_get_u32 (bits);
+      SwfdecBits action_bits;
+      SwfdecBuffer *buffer = swfdec_bits_get_buffer (bits, length);
+
+      if (buffer == NULL)
+	break;
+      swfdec_bits_init (&action_bits, buffer);
       if (event_flags & SWFDEC_EVENT_KEY_PRESS)
 	key_code = swfdec_bits_get_u8 (bits);
       else
@@ -413,14 +416,13 @@ swfdec_spriteseg_place_object_2 (SwfdecS
       }
       if (content->events == NULL)
 	content->events = swfdec_event_list_new (SWFDEC_DECODER (s)->player);
-      swfdec_event_list_parse (content->events, &s->b, s->version, 
+      swfdec_event_list_parse (content->events, &action_bits, s->version, 
 	  event_flags, key_code, script_name);
-      if (bits->ptr != save.ptr) {
-	SWFDEC_ERROR ("record size and actual parsed action differ by %d bytes",
-	    (int) (save.ptr - bits->ptr));
+      if (swfdec_bits_left (&action_bits)) {
+	SWFDEC_ERROR ("not all action data was parsed: %u bytes left",
+	    swfdec_bits_left (&action_bits));
       }
-      /* FIXME: who should we trust with parsing here? */
-      *bits = save;
+      swfdec_buffer_unref (buffer);
     }
     g_free (script_name);
   }
diff-tree c93579e07522e43a3d4d3ba9927d50ee74d5d5cb (from f8448012991988e247c42ba67603b46e29a8d59f)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Feb 2 18:58:14 2007 +0100

    when checking available bits fails, consume all bits

diff --git a/libswfdec/swfdec_bits.c b/libswfdec/swfdec_bits.c
index f9f2749..fb18394 100644
--- a/libswfdec/swfdec_bits.c
+++ b/libswfdec/swfdec_bits.c
@@ -55,7 +55,9 @@ swfdec_bits_left (SwfdecBits *b)
 
 #define SWFDEC_BITS_CHECK(b,n) G_STMT_START { \
   if (swfdec_bits_left(b) < (n)) { \
-    SWFDEC_ERROR("reading past end of buffer"); \
+    SWFDEC_ERROR ("reading past end of buffer"); \
+    b->ptr = b->end; \
+    b->idx = 0; \
     return 0; \
   } \
 }G_STMT_END
diff-tree f8448012991988e247c42ba67603b46e29a8d59f (from a7b8850adba4086c321e69c8933f6248b3de0803)
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Feb 2 15:32:35 2007 +0100

    Set clip depth correctly
    
    Real depths get 16384 subtracted when reading from a file,
    this is necessary for clip depths, too.

diff --git a/libswfdec/swfdec_sprite.c b/libswfdec/swfdec_sprite.c
index ffb8eb7..440c3b8 100644
--- a/libswfdec/swfdec_sprite.c
+++ b/libswfdec/swfdec_sprite.c
@@ -376,8 +376,8 @@ swfdec_spriteseg_place_object_2 (SwfdecS
     SWFDEC_LOG ("  name = %s", content->name);
   }
   if (has_clip_depth) {
-    content->clip_depth = swfdec_bits_get_u16 (bits);
-    SWFDEC_LOG ("  clip_depth = %d (=> %d)", content->clip_depth, content->clip_depth - 16384);
+    content->clip_depth = swfdec_bits_get_u16 (bits) - 16384;
+    SWFDEC_LOG ("  clip_depth = %d (=> %d)", content->clip_depth + 16384, content->clip_depth);
   }
   if (has_clip_actions) {
     int reserved, clip_event_flags, event_flags, key_code;


More information about the Swfdec mailing list