[Swfdec] 7 commits - libswfdec/swfdec_movie.c libswfdec/swfdec_resource.c libswfdec/swfdec_resource.h libswfdec/swfdec_sprite_movie_as.c test/trace

Benjamin Otte company at kemper.freedesktop.org
Sat Nov 10 13:22:25 PST 2007


 libswfdec/swfdec_movie.c                              |    4 +
 libswfdec/swfdec_resource.c                           |   48 ++++++++----------
 libswfdec/swfdec_resource.h                           |    3 -
 libswfdec/swfdec_sprite_movie_as.c                    |    8 ++-
 test/trace/Makefile.am                                |    9 +++
 test/trace/moviecliploader-unknown-format-5.swf       |binary
 test/trace/moviecliploader-unknown-format-5.swf.trace |    3 +
 test/trace/moviecliploader-unknown-format-6.swf       |binary
 test/trace/moviecliploader-unknown-format-6.swf.trace |    3 +
 test/trace/moviecliploader-unknown-format-7.swf       |binary
 test/trace/moviecliploader-unknown-format-7.swf.trace |   16 ++++++
 test/trace/moviecliploader-unknown-format-8.swf       |binary
 test/trace/moviecliploader-unknown-format-8.swf.trace |   16 ++++++
 test/trace/moviecliploader-unknown-format.as          |   36 +++++++++++++
 14 files changed, 117 insertions(+), 29 deletions(-)

New commits:
commit a357df6ea473ee8c6f8e1c6c189d2dd4b7adb004
Author: Benjamin Otte <otte at gnome.org>
Date:   Sat Nov 10 22:19:56 2007 +0100

    mark the parent, too

diff --git a/libswfdec/swfdec_movie.c b/libswfdec/swfdec_movie.c
index 8ec7961..2f79b06 100644
--- a/libswfdec/swfdec_movie.c
+++ b/libswfdec/swfdec_movie.c
@@ -1018,6 +1018,8 @@ swfdec_movie_mark (SwfdecAsObject *object)
   GList *walk;
   GSList *iter;
 
+  if (movie->parent)
+    swfdec_as_object_mark (SWFDEC_AS_OBJECT (movie->parent));
   swfdec_as_string_mark (movie->original_name);
   swfdec_as_string_mark (movie->name);
   for (walk = movie->list; walk; walk = walk->next) {
commit 0167ea2e783500c2c0290194fc2f7998f5720c6b
Author: Benjamin Otte <otte at gnome.org>
Date:   Sat Nov 10 19:35:20 2007 +0100

    seems I never compiled this :o

diff --git a/libswfdec/swfdec_resource.c b/libswfdec/swfdec_resource.c
index 9ad4105..c93d151 100644
--- a/libswfdec/swfdec_resource.c
+++ b/libswfdec/swfdec_resource.c
@@ -242,7 +242,7 @@ swfdec_resource_loader_target_parse (SwfdecLoaderTarget *target, SwfdecLoader *l
   SwfdecStatus status;
   guint parsed;
 
-  if (dec == NULL && swfdec_buffer_queue_get_offset (loader->queue == 0)) {
+  if (dec == NULL && swfdec_buffer_queue_get_offset (loader->queue) == 0) {
     if (swfdec_buffer_queue_get_depth (loader->queue) < SWFDEC_DECODER_DETECT_LENGTH)
       return;
     buffer = swfdec_buffer_queue_peek (loader->queue, 4);
commit ca60b5b27a2c9d9b0a83d14b46a5250cfdac4272
Author: Benjamin Otte <otte at gnome.org>
Date:   Sat Nov 10 18:57:04 2007 +0100

    add a test for the recent SEGV when loading unknown formats

diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index e4efc2a..bbb3ac2 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -1041,6 +1041,15 @@ EXTRA_DIST = \
 	moviecliploader-properties-7.swf.trace \
 	moviecliploader-properties-8.swf \
 	moviecliploader-properties-8.swf.trace \
+	moviecliploader-unknown-format.as \
+	moviecliploader-unknown-format-5.swf \
+	moviecliploader-unknown-format-5.swf.trace \
+	moviecliploader-unknown-format-6.swf \
+	moviecliploader-unknown-format-6.swf.trace \
+	moviecliploader-unknown-format-7.swf \
+	moviecliploader-unknown-format-7.swf.trace \
+	moviecliploader-unknown-format-8.swf \
+	moviecliploader-unknown-format-8.swf.trace \
 	name.swf \
 	name.swf.trace \
 	name2.swf \
diff --git a/test/trace/moviecliploader-unknown-format-5.swf b/test/trace/moviecliploader-unknown-format-5.swf
new file mode 100644
index 0000000..9b0ddd9
Binary files /dev/null and b/test/trace/moviecliploader-unknown-format-5.swf differ
diff --git a/test/trace/moviecliploader-unknown-format-5.swf.trace b/test/trace/moviecliploader-unknown-format-5.swf.trace
new file mode 100644
index 0000000..12917c7
--- /dev/null
+++ b/test/trace/moviecliploader-unknown-format-5.swf.trace
@@ -0,0 +1,3 @@
+true
+/
+/
diff --git a/test/trace/moviecliploader-unknown-format-6.swf b/test/trace/moviecliploader-unknown-format-6.swf
new file mode 100644
index 0000000..e9d0039
Binary files /dev/null and b/test/trace/moviecliploader-unknown-format-6.swf differ
diff --git a/test/trace/moviecliploader-unknown-format-6.swf.trace b/test/trace/moviecliploader-unknown-format-6.swf.trace
new file mode 100644
index 0000000..a535854
--- /dev/null
+++ b/test/trace/moviecliploader-unknown-format-6.swf.trace
@@ -0,0 +1,3 @@
+true
+1/1
+0/0
diff --git a/test/trace/moviecliploader-unknown-format-7.swf b/test/trace/moviecliploader-unknown-format-7.swf
new file mode 100644
index 0000000..4123e54
Binary files /dev/null and b/test/trace/moviecliploader-unknown-format-7.swf differ
diff --git a/test/trace/moviecliploader-unknown-format-7.swf.trace b/test/trace/moviecliploader-unknown-format-7.swf.trace
new file mode 100644
index 0000000..2928133
--- /dev/null
+++ b/test/trace/moviecliploader-unknown-format-7.swf.trace
@@ -0,0 +1,16 @@
+start
+that's progress: 0/0
+that's progress: 0/-1
+that's progress: 0/0
+that's progress: 0/-1
+done \o/
+false
+true
+n-format.as
+onEnterFrame
+onEnterFrame
+onEnterFrame
+false
+-1/0
+0/-1
+onEnterFrame
diff --git a/test/trace/moviecliploader-unknown-format-8.swf b/test/trace/moviecliploader-unknown-format-8.swf
new file mode 100644
index 0000000..56319ac
Binary files /dev/null and b/test/trace/moviecliploader-unknown-format-8.swf differ
diff --git a/test/trace/moviecliploader-unknown-format-8.swf.trace b/test/trace/moviecliploader-unknown-format-8.swf.trace
new file mode 100644
index 0000000..2928133
--- /dev/null
+++ b/test/trace/moviecliploader-unknown-format-8.swf.trace
@@ -0,0 +1,16 @@
+start
+that's progress: 0/0
+that's progress: 0/-1
+that's progress: 0/0
+that's progress: 0/-1
+done \o/
+false
+true
+n-format.as
+onEnterFrame
+onEnterFrame
+onEnterFrame
+false
+-1/0
+0/-1
+onEnterFrame
diff --git a/test/trace/moviecliploader-unknown-format.as b/test/trace/moviecliploader-unknown-format.as
new file mode 100644
index 0000000..231bd11
--- /dev/null
+++ b/test/trace/moviecliploader-unknown-format.as
@@ -0,0 +1,36 @@
+// makeswf -v 7 -s 200x150 -r 1 -o moviecliploader-unknown-format.swf moviecliploader-unknown-format.as
+
+x = createEmptyMovieClip ("b", 1);
+b._name = "a";
+
+l = new MovieClipLoader ();
+l.onLoadError = function (m, e, s) {
+  trace (m);
+  trace (e);
+  trace (s);
+};
+l.onLoadStart = function (m) {
+  trace ("start");
+};
+l.onLoadProgress = function (m, l, t) {
+  trace ("that's progress: " + l + "/" + t);
+  trace ("that's progress: " + a.getBytesLoaded () + "/" + a.getBytesTotal ());
+};
+l.onLoadComplete = function (m, l, t) {
+  trace ("done \\o/");
+};
+
+l.onLoadInit = function (m) {
+  trace (a == x);
+  trace (a == m);
+  trace (a._url.substr (-11));
+  a.onEnterFrame = function () { trace ("onEnterFrame"); };
+};
+l.loadClip ("moviecliploader-unknown-format.as", a);
+
+setTimeout (function () { 
+  trace (x == a);
+  trace (a._framesloaded + "/" + a._totalframes);
+  trace (a.getBytesLoaded () + "/" + a.getBytesTotal ());
+  loadMovie ("fscommand:quit", ""); 
+}, 5000);
commit 635f74859a767beceecf660b3d70d134a9b9ce5c
Author: Benjamin Otte <otte at gnome.org>
Date:   Sat Nov 10 18:05:57 2007 +0100

    make this work correctly if no decoder has been set due to unknown format

diff --git a/libswfdec/swfdec_resource.c b/libswfdec/swfdec_resource.c
index 3c02af4..9ad4105 100644
--- a/libswfdec/swfdec_resource.c
+++ b/libswfdec/swfdec_resource.c
@@ -239,34 +239,24 @@ swfdec_resource_loader_target_parse (SwfdecLoaderTarget *target, SwfdecLoader *l
   SwfdecResource *resource = SWFDEC_RESOURCE (target);
   SwfdecBuffer *buffer;
   SwfdecDecoder *dec = resource->decoder;
-  SwfdecDecoderClass *klass;
   SwfdecStatus status;
   guint parsed;
 
-  if (dec == NULL) {
+  if (dec == NULL && swfdec_buffer_queue_get_offset (loader->queue == 0)) {
     if (swfdec_buffer_queue_get_depth (loader->queue) < SWFDEC_DECODER_DETECT_LENGTH)
       return;
     buffer = swfdec_buffer_queue_peek (loader->queue, 4);
     dec = swfdec_decoder_new (resource->player, buffer);
     swfdec_buffer_unref (buffer);
     if (dec == NULL) {
-      SWFDEC_ERROR ("no decoder found");
-      swfdec_loader_set_target (loader, NULL);
-      return;
-    }
-
-    if (SWFDEC_IS_SWF_DECODER (dec)) {
+      SWFDEC_ERROR ("no decoder found for format");
+    } else if (SWFDEC_IS_SWF_DECODER (dec)) {
       swfdec_loader_set_data_type (loader, SWFDEC_LOADER_DATA_SWF);
       resource->decoder = dec;
     } else {
       SWFDEC_FIXME ("implement handling of %s", G_OBJECT_TYPE_NAME (dec));
-      g_object_unref (dec);
-      swfdec_loader_set_target (loader, NULL);
-      return;
     }
   }
-  klass = SWFDEC_DECODER_GET_CLASS (dec);
-  g_return_if_fail (klass->parse);
   while (swfdec_buffer_queue_get_depth (loader->queue)) {
     parsed = 0;
     status = 0;
@@ -282,7 +272,11 @@ swfdec_resource_loader_target_parse (SwfdecLoaderTarget *target, SwfdecLoader *l
 	buffer = swfdec_buffer_queue_pull (loader->queue, 65536 - parsed);
       }
       parsed += buffer->length;
-      status = klass->parse (dec, buffer);
+      if (dec) {
+	status = swfdec_decoder_parse (dec, buffer);
+      } else {
+	swfdec_buffer_unref (buffer);
+      }
     } while ((status & (SWFDEC_STATUS_ERROR | SWFDEC_STATUS_NEEDBITS | SWFDEC_STATUS_EOF)) == 0);
     if (status & SWFDEC_STATUS_ERROR) {
       SWFDEC_ERROR ("parsing error");
commit c8db312e4f4e1f8e81a532d31de0f4f16572b624
Author: Benjamin Otte <otte at gnome.org>
Date:   Sat Nov 10 18:05:30 2007 +0100

    unparsable files result in getBytesTotal() returning -1

diff --git a/libswfdec/swfdec_sprite_movie_as.c b/libswfdec/swfdec_sprite_movie_as.c
index b751327..ec6fce9 100644
--- a/libswfdec/swfdec_sprite_movie_as.c
+++ b/libswfdec/swfdec_sprite_movie_as.c
@@ -90,8 +90,12 @@ swfdec_sprite_movie_getBytesTotal (SwfdecAsContext *cx, SwfdecAsObject *object,
   SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, (gpointer)&movie, "");
 
   resource = swfdec_movie_get_own_resource (movie);
-  if (resource && resource->decoder) {
-    SWFDEC_AS_VALUE_SET_INT (rval, resource->decoder->bytes_total);
+  if (resource) {
+    if (resource->decoder) {
+      SWFDEC_AS_VALUE_SET_INT (rval, resource->decoder->bytes_total);
+    } else {
+      SWFDEC_AS_VALUE_SET_INT (rval, -1);
+    }
   } else {
     SWFDEC_AS_VALUE_SET_INT (rval, 0);
   }
commit fd8483f0127ade0fac7abb99f82f7946ef4a555a
Author: Benjamin Otte <otte at gnome.org>
Date:   Sat Nov 10 13:17:16 2007 +0100

    use the resource's version, not the decoder's one.
    
    The decoder can be NULL if there's no file

diff --git a/libswfdec/swfdec_movie.c b/libswfdec/swfdec_movie.c
index 57c18d0..8ec7961 100644
--- a/libswfdec/swfdec_movie.c
+++ b/libswfdec/swfdec_movie.c
@@ -390,7 +390,7 @@ swfdec_movie_resolve (SwfdecMovie *movie)
 guint
 swfdec_movie_get_version (SwfdecMovie *movie)
 {
-  return SWFDEC_SWF_DECODER (movie->resource->decoder)->version;
+  return movie->resource->version;
 }
 
 void
commit 57466e38e16e8c4736884eac000099afe9fa16de
Author: Benjamin Otte <otte at gnome.org>
Date:   Sat Nov 10 13:15:49 2007 +0100

    add a version number to SwfdecResource

diff --git a/libswfdec/swfdec_resource.c b/libswfdec/swfdec_resource.c
index 6b7f540..3c02af4 100644
--- a/libswfdec/swfdec_resource.c
+++ b/libswfdec/swfdec_resource.c
@@ -236,9 +236,9 @@ swfdec_resource_loader_target_open (SwfdecLoaderTarget *target, SwfdecLoader *lo
 static void
 swfdec_resource_loader_target_parse (SwfdecLoaderTarget *target, SwfdecLoader *loader)
 {
-  SwfdecResource *instance = SWFDEC_RESOURCE (target);
+  SwfdecResource *resource = SWFDEC_RESOURCE (target);
   SwfdecBuffer *buffer;
-  SwfdecDecoder *dec = instance->decoder;
+  SwfdecDecoder *dec = resource->decoder;
   SwfdecDecoderClass *klass;
   SwfdecStatus status;
   guint parsed;
@@ -247,7 +247,7 @@ swfdec_resource_loader_target_parse (SwfdecLoaderTarget *target, SwfdecLoader *l
     if (swfdec_buffer_queue_get_depth (loader->queue) < SWFDEC_DECODER_DETECT_LENGTH)
       return;
     buffer = swfdec_buffer_queue_peek (loader->queue, 4);
-    dec = swfdec_decoder_new (instance->player, buffer);
+    dec = swfdec_decoder_new (resource->player, buffer);
     swfdec_buffer_unref (buffer);
     if (dec == NULL) {
       SWFDEC_ERROR ("no decoder found");
@@ -257,7 +257,7 @@ swfdec_resource_loader_target_parse (SwfdecLoaderTarget *target, SwfdecLoader *l
 
     if (SWFDEC_IS_SWF_DECODER (dec)) {
       swfdec_loader_set_data_type (loader, SWFDEC_LOADER_DATA_SWF);
-      instance->decoder = dec;
+      resource->decoder = dec;
     } else {
       SWFDEC_FIXME ("implement handling of %s", G_OBJECT_TYPE_NAME (dec));
       g_object_unref (dec);
@@ -289,15 +289,17 @@ swfdec_resource_loader_target_parse (SwfdecLoaderTarget *target, SwfdecLoader *l
       swfdec_loader_set_target (loader, NULL);
       return;
     }
-    if ((status & SWFDEC_STATUS_INIT) &&
-	swfdec_resource_is_root (instance)) {
-      swfdec_player_initialize (instance->player, 
-	  SWFDEC_IS_SWF_DECODER (dec) ? SWFDEC_SWF_DECODER (dec)->version : 7, /* <-- HACK */
-	  dec->rate, dec->width, dec->height);
+    if ((status & SWFDEC_STATUS_INIT)) {
+      if (SWFDEC_IS_SWF_DECODER (dec))
+	resource->version = SWFDEC_SWF_DECODER (dec)->version;
+      if (swfdec_resource_is_root (resource)) {
+	swfdec_player_initialize (resource->player, resource->version,
+	    dec->rate, dec->width, dec->height);
+      }
     }
     if (status & SWFDEC_STATUS_IMAGE)
-      swfdec_resource_loader_target_image (instance);
-    swfdec_resource_emit_signal (instance, SWFDEC_AS_STR_onLoadProgress, TRUE, NULL, 0);
+      swfdec_resource_loader_target_image (resource);
+    swfdec_resource_emit_signal (resource, SWFDEC_AS_STR_onLoadProgress, TRUE, NULL, 0);
     if (status & SWFDEC_STATUS_EOF)
       return;
   }
@@ -422,6 +424,7 @@ swfdec_resource_new (SwfdecPlayer *player, SwfdecLoader *loader, const char *var
   g_return_val_if_fail (SWFDEC_IS_LOADER (loader), NULL);
 
   resource = g_object_new (SWFDEC_TYPE_RESOURCE, NULL);
+  resource->version = 7;
   resource->player = player;
   resource->variables = g_strdup (variables);
   swfdec_resource_set_loader (resource, loader);
@@ -527,6 +530,7 @@ swfdec_resource_load (SwfdecPlayer *player, const char *target, const char *url,
     g_free (path);
   } else {
     resource = g_object_new (SWFDEC_TYPE_RESOURCE, NULL);
+    resource->version = SWFDEC_AS_CONTEXT (player)->version;
     resource->player = player;
     resource->target = path;
     if (loader)
diff --git a/libswfdec/swfdec_resource.h b/libswfdec/swfdec_resource.h
index bbf60dd..08de138 100644
--- a/libswfdec/swfdec_resource.h
+++ b/libswfdec/swfdec_resource.h
@@ -48,10 +48,11 @@ struct _SwfdecResource
   SwfdecFlashSecurity	flash_security;
 
   SwfdecPlayer *	player;		/* player we belong to */
+  guint			version;	/* version of this resource */
   SwfdecSpriteMovie * 	movie;		/* the movie responsible for creating this instance */
 
   SwfdecLoader *	loader;		/* the loader providing data for the decoder */
-  SwfdecDecoder *	decoder;	/* decoder in use or NULL if not yet created (only happens after loadMovie()) */
+  SwfdecDecoder *	decoder;	/* decoder in use or NULL if broken file */
   char *		variables;	/* extra variables to be set */
 
   GHashTable *		exports;	/* string->SwfdecCharacter mapping of exported characters */


More information about the Swfdec mailing list