[Swfdec] 12 commits - configure.ac doc/Makefile.am libswfdec/swfdec_as_frame.c libswfdec/swfdec_audio.c libswfdec/swfdec_audio_event.c libswfdec/swfdec_audio_event.h libswfdec/swfdec_shape_parser.c libswfdec/swfdec_sound.c test/sound

Benjamin Otte company at kemper.freedesktop.org
Thu Oct 11 12:35:45 PDT 2007


 configure.ac                     |    2 -
 doc/Makefile.am                  |    2 -
 libswfdec/swfdec_as_frame.c      |    8 ++--
 libswfdec/swfdec_audio.c         |    1 
 libswfdec/swfdec_audio_event.c   |   24 +++++--------
 libswfdec/swfdec_audio_event.h   |    3 +
 libswfdec/swfdec_shape_parser.c  |    8 ++--
 libswfdec/swfdec_sound.c         |    1 
 test/sound/adpcm-2-2.swf.1.0.raw |binary
 test/sound/adpcm-2.swf.1.0.raw   |binary
 test/sound/adpcm-3-2.swf.1.0.raw |binary
 test/sound/adpcm-3.swf.1.0.raw   |binary
 test/sound/adpcm-4-2.swf.1.0.raw |binary
 test/sound/adpcm-4.swf.1.0.raw   |binary
 test/sound/adpcm-5-2.swf.1.0.raw |binary
 test/sound/adpcm-5.swf.1.0.raw   |binary
 test/sound/sound.c               |   69 +++++++++++++++++++++++++++------------
 17 files changed, 72 insertions(+), 46 deletions(-)

New commits:
diff-tree cd10b0bf08549c0002ff4dfc996736aa773eca68 (from 54212e64a66984677c8ef86078f81cf004836971)
Author: Pavel Roskin <proski at gnu.org>
Date:   Thu Oct 11 21:33:46 2007 +0200

    make gcc not complain about unused variables

diff --git a/libswfdec/swfdec_shape_parser.c b/libswfdec/swfdec_shape_parser.c
index 3b9d75d..75f3f99 100644
--- a/libswfdec/swfdec_shape_parser.c
+++ b/libswfdec/swfdec_shape_parser.c
@@ -220,8 +220,8 @@ swfdec_style_finish (SwfdecStyle *style,
 
   /* accumulate paths one by one */
   while (style->subpaths) {
-    SwfdecSubPath *start, *last, *cur;
-    SwfdecSubPath *start2, *last2, *cur2;
+    SwfdecSubPath *start, *last;
+    SwfdecSubPath *start2 = NULL, *last2 = NULL;
 
     last = start = &paths[GPOINTER_TO_UINT (style->subpaths->data)];
     swfdec_path_move_to (&style->draw->path, start->x_start, start->y_start);
@@ -235,10 +235,10 @@ swfdec_style_finish (SwfdecStyle *style,
     while (!swfdec_sub_path_match (last, start) ||
 	(paths2 != NULL && !swfdec_sub_path_match (last2, start2))) {
       for (walk = style->subpaths; walk; walk = walk->next) {
-	cur = &paths[GPOINTER_TO_UINT (walk->data)];
+	SwfdecSubPath *cur = &paths[GPOINTER_TO_UINT (walk->data)];
 	if (swfdec_sub_path_match (last, cur)) {
 	  if (paths2) {
-	    cur2 = &paths2[GPOINTER_TO_UINT (walk->data)];
+	    SwfdecSubPath *cur2 = &paths2[GPOINTER_TO_UINT (walk->data)];
 	    if (!swfdec_sub_path_match (last2, cur2))
 	      continue;
 	    swfdec_path_append (&style->draw->end_path, &cur2->path);
diff-tree 54212e64a66984677c8ef86078f81cf004836971 (from 71b563ea2b5ecd10426d9ec1c035f904275c2b0c)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 11 20:20:26 2007 +0200

    gtkdoc-check can't handle builddir != srcdir and fails for make distcheck

diff --git a/doc/Makefile.am b/doc/Makefile.am
index bfe7279..44bf0e4 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -177,4 +177,4 @@ include $(top_srcdir)/gtk-doc.make
 EXTRA_DIST += 
 
 # Comment this out if you want your docs-status tested during 'make check'
-TESTS = $(GTKDOC_CHECK)
+#TESTS = $(GTKDOC_CHECK)
diff-tree 71b563ea2b5ecd10426d9ec1c035f904275c2b0c (from 54a61d331d3f5c9bdcf87c39638adb4b8ada9ce2)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 11 20:19:53 2007 +0200

    read the files from the right directory

diff --git a/test/sound/sound.c b/test/sound/sound.c
index cbbac14..7b46788 100644
--- a/test/sound/sound.c
+++ b/test/sound/sound.c
@@ -130,11 +130,15 @@ audio_added (SwfdecPlayer *player, Swfde
     data->success = FALSE;
   } else {
     TestStream *stream = g_new0 (TestStream, 1);
+    char *dirname;
+
+    dirname = g_path_get_dirname (data->filename);
     stream->audio = audio;
-    stream->name = found->data;
+    stream->name = g_build_filename (dirname, found->data, NULL);
     stream->queue = swfdec_buffer_queue_new ();
     data->files = g_list_delete_link (data->files, found);
     data->streams = g_list_prepend (data->streams, stream);
+    g_free (dirname);
   }
   g_free (name);
 }
diff-tree 54a61d331d3f5c9bdcf87c39638adb4b8ada9ce2 (from 8166f67d4082877a4115c1e099e94b36b1d3a258)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 11 18:58:54 2007 +0200

    pop blocks before freeing the script
    
    popping the last block would cause crashes, because that accesses the script.

diff --git a/libswfdec/swfdec_as_frame.c b/libswfdec/swfdec_as_frame.c
index 3812313..619811c 100644
--- a/libswfdec/swfdec_as_frame.c
+++ b/libswfdec/swfdec_as_frame.c
@@ -269,10 +269,6 @@ swfdec_as_frame_dispose (GObject *object
   SwfdecAsFrame *frame = SWFDEC_AS_FRAME (object);
 
   g_slice_free1 (sizeof (SwfdecAsValue) * frame->n_registers, frame->registers);
-  if (frame->script) {
-    swfdec_script_unref (frame->script);
-    frame->script = NULL;
-  }
   if (frame->constant_pool) {
     swfdec_constant_pool_free (frame->constant_pool);
     frame->constant_pool = NULL;
@@ -285,6 +281,10 @@ swfdec_as_frame_dispose (GObject *object
     swfdec_as_frame_pop_block (frame);
   g_array_free (frame->blocks, TRUE);
   g_slist_free (frame->scope_chain);
+  if (frame->script) {
+    swfdec_script_unref (frame->script);
+    frame->script = NULL;
+  }
 
   G_OBJECT_CLASS (swfdec_as_frame_parent_class)->dispose (object);
 }
diff-tree 8166f67d4082877a4115c1e099e94b36b1d3a258 (from b1771f28adb77864e0072748ee08c462e4abe29d)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 11 18:44:17 2007 +0200

    rework sound system to only compare in 5.5kHz rate.
    
    This has 2 advantages:
    1) We can use a sane resampling algorithm
    2) THe raw files to compare to are 1/8th the size

diff --git a/test/sound/adpcm-2-2.swf.1.0.raw b/test/sound/adpcm-2-2.swf.1.0.raw
index f959559..e5b8175 100644
Binary files a/test/sound/adpcm-2-2.swf.1.0.raw and b/test/sound/adpcm-2-2.swf.1.0.raw differ
diff --git a/test/sound/adpcm-2.swf.1.0.raw b/test/sound/adpcm-2.swf.1.0.raw
index 20cbd37..e9a08e1 100644
Binary files a/test/sound/adpcm-2.swf.1.0.raw and b/test/sound/adpcm-2.swf.1.0.raw differ
diff --git a/test/sound/adpcm-3-2.swf.1.0.raw b/test/sound/adpcm-3-2.swf.1.0.raw
index a8de755..949b1da 100644
Binary files a/test/sound/adpcm-3-2.swf.1.0.raw and b/test/sound/adpcm-3-2.swf.1.0.raw differ
diff --git a/test/sound/adpcm-3.swf.1.0.raw b/test/sound/adpcm-3.swf.1.0.raw
index 0f1a834..bae56ea 100644
Binary files a/test/sound/adpcm-3.swf.1.0.raw and b/test/sound/adpcm-3.swf.1.0.raw differ
diff --git a/test/sound/adpcm-4-2.swf.1.0.raw b/test/sound/adpcm-4-2.swf.1.0.raw
index 2bc89ef..8d25897 100644
Binary files a/test/sound/adpcm-4-2.swf.1.0.raw and b/test/sound/adpcm-4-2.swf.1.0.raw differ
diff --git a/test/sound/adpcm-4.swf.1.0.raw b/test/sound/adpcm-4.swf.1.0.raw
index 1e8c6f4..f89a04c 100644
Binary files a/test/sound/adpcm-4.swf.1.0.raw and b/test/sound/adpcm-4.swf.1.0.raw differ
diff --git a/test/sound/adpcm-5-2.swf.1.0.raw b/test/sound/adpcm-5-2.swf.1.0.raw
index f57feb4..bbc25a6 100644
Binary files a/test/sound/adpcm-5-2.swf.1.0.raw and b/test/sound/adpcm-5-2.swf.1.0.raw differ
diff --git a/test/sound/adpcm-5.swf.1.0.raw b/test/sound/adpcm-5.swf.1.0.raw
index cc4c44b..e14b571 100644
Binary files a/test/sound/adpcm-5.swf.1.0.raw and b/test/sound/adpcm-5.swf.1.0.raw differ
diff --git a/test/sound/sound.c b/test/sound/sound.c
index cdb6f01..cbbac14 100644
--- a/test/sound/sound.c
+++ b/test/sound/sound.c
@@ -23,40 +23,65 @@
 #include <string.h>
 #include <libswfdec/swfdec.h>
 
+/**
+ * audio_diff:
+ * @compare: the buffer we rendered in 44.1kHz stereo 16bit
+ * @original: the original buffer in 5.5kHz stereo 16bit
+ * @filename: name of the file where @original came from
+ *
+ * Compares the 2 buffers for every 5.5kHz and complains with a useful 
+ * error message if they don't match.
+ *
+ * Returns: TRUE if the 2 files are equal
+ **/
 static gboolean
 audio_diff (SwfdecBuffer *compare, SwfdecBuffer *original, const char *filename)
 {
-  guint i;
-  gint16 *comp_data, *org_data;
+  guint i, length;
+  gint16 *comp_data, *comp_end, *org_data;
   
   /* must hold since we are rendering it */
-  g_assert (compare->length % 2 == 0);
-  if (original->length % 2 != 0) {
+  g_assert (compare->length % 4 == 0);
+  if (original->length % 4 != 0) {
     g_print ("  ERROR: %s: filesize (%u bytes) not multiple of 4\n", filename,
 	original->length);
     return FALSE;
   }
-  if (compare->length != original->length) {
-    /* we allow to cut 0 bytes off the comparison files - at least as long as we render additional 0s */
-    for (i = compare->length; i < original->length; i++) {
-      if (compare->data[i] != 0)
-	break;
+  length = original->length / 4;
+  comp_data = (gint16 *) compare->data;
+  comp_end = (gint16 *) (compare->data + compare->length);
+  org_data = (gint16 *) original->data;
+  comp_data += 14;
+  for (i = 0; i < length && comp_data < comp_end; i++) {
+    /* original data is little endian */
+    if (*comp_data != GINT16_FROM_LE (*org_data)) {
+      g_print ("  ERROR: %s: data mismatch at left channel for sample %u (is %04hX, should be %04hX)\n",
+	  filename, i, *comp_data, GINT16_FROM_LE (*org_data));
+      goto dump;
     }
-    if (i < original->length) {
-      g_print ("  ERROR: %s: sample count doesn't match (is %u, should be %u)\n", 
-	  filename, compare->length / 4, original->length / 4);
+    comp_data++;
+    org_data++;
+    if (*comp_data != GINT16_FROM_LE (*org_data)) {
+      g_print ("  ERROR: %s: data mismatch at right channel for sample %u (is %04hX, should be %04hX)\n",
+	  filename, i, *comp_data, GINT16_FROM_LE (*org_data));
       goto dump;
     }
+    comp_data += 15;
+    org_data++;
   }
-  comp_data = (gint16 *) compare->data;
-  org_data = (gint16 *) original->data;
-  for (i = 0; i < original->length / 2; i++) {
-    /* original data is little endian */
-    if (comp_data[i] != GINT16_FROM_LE (org_data[i])) {
-      g_print ("  ERROR: %s: data mismatch at sample %u (is %04hX, should be %04hX)\n",
-	  filename, i, comp_data[i], GINT16_FROM_LE (org_data[i]));
+  if (i < length) {
+    g_print ("  ERROR: %s: not enough data: Should be %u 5.5kHz samples, but is only %u samples",
+	filename, length, i);
+    goto dump;
+  }
+  while (comp_data < comp_end) {
+    if (comp_data[0] != 0 || comp_data[1] != 0) {
+      g_print ("  ERROR: %s: leftover data should be 0, but sample %u is %04hX, %04hX\n",
+	  filename, i, comp_data[0], comp_data[1]);
       goto dump;
     }
+    i++;
+    comp_data += 16;
   }
   return TRUE;
 dump:
diff-tree b1771f28adb77864e0072748ee08c462e4abe29d (from 40854374b86f321fb816ce505f2ef170f59dfaf1)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 11 18:37:42 2007 +0200

    add deug message

diff --git a/libswfdec/swfdec_audio_event.c b/libswfdec/swfdec_audio_event.c
index a82182d..8520bf9 100644
--- a/libswfdec/swfdec_audio_event.c
+++ b/libswfdec/swfdec_audio_event.c
@@ -154,6 +154,7 @@ swfdec_audio_event_decode (SwfdecAudioEv
     }
   }
   event->n_samples = event->decoded->length / bytes_per_sample * granule;
+  SWFDEC_LOG ("total 44100Hz samples: %u", event->n_samples);
 }
 
 static SwfdecAudioEvent *
diff-tree 40854374b86f321fb816ce505f2ef170f59dfaf1 (from 9a75550335d3a4ea2276c7573634d12a81fc030b)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 11 18:29:22 2007 +0200

    remove unnecessary check

diff --git a/libswfdec/swfdec_audio_event.c b/libswfdec/swfdec_audio_event.c
index afe5ed3..a82182d 100644
--- a/libswfdec/swfdec_audio_event.c
+++ b/libswfdec/swfdec_audio_event.c
@@ -61,8 +61,6 @@ swfdec_audio_event_render (SwfdecAudio *
 
   loop = event->loop + offset / event->n_samples;
   offset %= event->n_samples;
-  if (loop >= event->n_loops)
-    return;
   for (; loop < event->n_loops && n_samples > 0; loop++) {
     samples = MIN (n_samples, event->n_samples - offset);
     swfdec_sound_buffer_render	(dest, event->decoded, event->decoded_format,
diff-tree 9a75550335d3a4ea2276c7573634d12a81fc030b (from 45c38d22b5cca2eb87f7662a7156d6f36284de2e)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 11 18:28:27 2007 +0200

    return a correct number of remaining samples

diff --git a/libswfdec/swfdec_audio_event.c b/libswfdec/swfdec_audio_event.c
index e1baa03..afe5ed3 100644
--- a/libswfdec/swfdec_audio_event.c
+++ b/libswfdec/swfdec_audio_event.c
@@ -44,7 +44,10 @@ swfdec_audio_event_iterate (SwfdecAudio 
   event->loop += event->offset / event->n_samples;
   event->offset %= event->n_samples;
   
-  return event->n_samples * (event->n_loops - event->loop) - event->offset;
+  if (event->loop < event->n_loops)
+    return event->n_samples * (event->n_loops - event->loop) - event->offset;
+  else
+    return 0;
 }
 
 static void
diff-tree 45c38d22b5cca2eb87f7662a7156d6f36284de2e (from 63b3acbf8e21b00620db14fc3e8ce3e643875c90)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 11 16:22:37 2007 +0200

    rewrite loop handling
    
    This allows properly passing NULL as the previous buffer to the renderer

diff --git a/libswfdec/swfdec_audio_event.c b/libswfdec/swfdec_audio_event.c
index 7d876ae..e1baa03 100644
--- a/libswfdec/swfdec_audio_event.c
+++ b/libswfdec/swfdec_audio_event.c
@@ -36,21 +36,15 @@ static guint
 swfdec_audio_event_iterate (SwfdecAudio *audio, guint remove)
 {
   SwfdecAudioEvent *event = SWFDEC_AUDIO_EVENT (audio);
-  guint loops;
 
   if (event->n_samples == 0)
     return 0;
 
   event->offset += remove;
-  loops = event->offset / event->n_samples;
+  event->loop += event->offset / event->n_samples;
   event->offset %= event->n_samples;
-  if (loops >= event->loop_count) {
-    event->loop_count = 0;
-    return 0;
-  }
-  event->loop_count -= loops;
-
-  return event->n_samples * event->loop_count - event->offset;
+  
+  return event->n_samples * (event->n_loops - event->loop) - event->offset;
 }
 
 static void
@@ -62,14 +56,14 @@ swfdec_audio_event_render (SwfdecAudio *
   guint loop;
   guint samples;
 
-  loop = offset / event->n_samples;
+  loop = event->loop + offset / event->n_samples;
   offset %= event->n_samples;
-  if (loop >= event->loop_count)
+  if (loop >= event->n_loops)
     return;
-  for (loop = event->loop_count - loop; loop > 0 && n_samples > 0; loop--) {
+  for (; loop < event->n_loops && n_samples > 0; loop++) {
     samples = MIN (n_samples, event->n_samples - offset);
     swfdec_sound_buffer_render	(dest, event->decoded, event->decoded_format,
-	event->decoded, offset, samples);
+	loop == 0 ? NULL : event->decoded, offset, samples);
     n_samples -= samples;
     dest += samples * 4;
     offset = 0;
@@ -169,7 +163,7 @@ swfdec_audio_event_create (SwfdecSound *
   event = g_object_new (SWFDEC_TYPE_AUDIO_EVENT, NULL);
   event->sound = sound;
   event->start_sample = offset;
-  event->loop_count = n_loops;
+  event->n_loops = n_loops;
   event->stop_sample = end_offset;
   swfdec_audio_event_decode (event);
   event->offset = 0;
diff --git a/libswfdec/swfdec_audio_event.h b/libswfdec/swfdec_audio_event.h
index 6771c98..40a0eb6 100644
--- a/libswfdec/swfdec_audio_event.h
+++ b/libswfdec/swfdec_audio_event.h
@@ -45,13 +45,14 @@ struct _SwfdecAudioEvent
   SwfdecSound *		sound;		      	/* sound we're playing */
   guint			start_sample; 		/* sample at which to start playing */
   guint			stop_sample;	      	/* first sample to not play anymore or 0 for playing all */
-  guint			loop_count;		/* amount of times this sample still needs to be played back */
+  guint			n_loops;		/* amount of times this sample still needs to be played back */
   guint			n_envelopes;		/* amount of points in the envelope */
   SwfdecSoundEnvelope *	envelope;		/* volume envelope or NULL if none */
   /* dynamic data */
   SwfdecBuffer *	decoded;		/* the decoded buffer we play back */
   SwfdecAudioFormat	decoded_format;		/* format of the decoded buffer */
   guint			offset;			/* current offset in 44.1kHz */
+  guint			loop;			/* current loop we're in */
   guint			n_samples;	      	/* length of decoded buffer in 44.1kHz samples - can be 0 */
 };
 
diff-tree 63b3acbf8e21b00620db14fc3e8ce3e643875c90 (from 81bb20f0fc8d58b5096fec192677730b9a7dc353)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 11 16:22:08 2007 +0200

    format == 0 is fine after the format rewrite

diff --git a/libswfdec/swfdec_sound.c b/libswfdec/swfdec_sound.c
index 53722ce..7ee1660 100644
--- a/libswfdec/swfdec_sound.c
+++ b/libswfdec/swfdec_sound.c
@@ -456,7 +456,6 @@ swfdec_sound_buffer_render (gint16 *dest
   g_return_if_fail (dest != NULL);
   g_return_if_fail (source != NULL);
   g_return_if_fail (swfdec_sound_buffer_get_n_samples (source, format) > 0);
-  g_return_if_fail (format != 0);
   g_return_if_fail (previous == NULL || swfdec_sound_buffer_get_n_samples (previous, format) > 0);
 
   src = (gint16 *) source->data;
diff-tree 81bb20f0fc8d58b5096fec192677730b9a7dc353 (from f6c05239c8677f0e1675e8eb685e5590178ecbdf)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 11 16:21:43 2007 +0200

    fix typo

diff --git a/configure.ac b/configure.ac
index 6abc3ff..f33c09b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -249,7 +249,7 @@ AM_CONDITIONAL(HAVE_GST, [test "x$HAVE_G
 
 AC_ARG_ENABLE(soup,
 	AS_HELP_STRING([--enable-soup],
-			[enable libaoup HTTP support for swfdec-gtk (default=yes)])],
+			[enable libsoup HTTP support for swfdec-gtk (default=yes)])],
 	enable_libsoup=$enableval,
 	enable_libsoup="yes")
 
diff-tree f6c05239c8677f0e1675e8eb685e5590178ecbdf (from 493eff56ead0f496136751c5f7b4c276c22b5466)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 11 16:21:08 2007 +0200

    copy/paste error
    
    I do too many of them recently

diff --git a/libswfdec/swfdec_audio.c b/libswfdec/swfdec_audio.c
index f1a9d0b..79af900 100644
--- a/libswfdec/swfdec_audio.c
+++ b/libswfdec/swfdec_audio.c
@@ -236,6 +236,7 @@ swfdec_audio_format_new (guint rate, gui
       break;
     case 11025:
       ret = 1 << 2; 
+      break;
     case 5512:
       ret = 0 << 2; 
       break;


More information about the Swfdec mailing list