[Swfdec] 8 commits - libswfdec/swfdec_buffer.c
libswfdec/swfdec_buffer.h libswfdec/swfdec_root_sprite.c
libswfdec/swfdec_swf_decoder.c libswfdec/swfdec_tag.c NEWS
test/parse.c
Benjamin Otte
company at kemper.freedesktop.org
Fri Apr 20 13:41:18 PDT 2007
NEWS | 15 ++++++
libswfdec/swfdec_buffer.c | 91 ++++++++++++++++++++++++++++++++++++-----
libswfdec/swfdec_buffer.h | 6 +-
libswfdec/swfdec_root_sprite.c | 2
libswfdec/swfdec_swf_decoder.c | 13 +++--
libswfdec/swfdec_tag.c | 8 +--
test/parse.c | 6 +-
7 files changed, 118 insertions(+), 23 deletions(-)
New commits:
diff-tree 240265e9d7ff72a51ff1c283805796df95547de2 (from parents)
Merge: 083d9e36ce49430024e5bc90783f1144cc7c0202 a171b4ba49fbd8fa8addb521184fc9b2cde60e50
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Apr 20 22:01:30 2007 +0200
Merge branch 'master' of ssh://company@git.freedesktop.org/git/swfdec
diff-tree 083d9e36ce49430024e5bc90783f1144cc7c0202 (from bc8720b4d23eb94de1e95327805ecfdd945cd3ce)
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Apr 20 18:46:58 2007 +0200
make sure to never call a parse function for a sprite that has all frames parsed
diff --git a/libswfdec/swfdec_swf_decoder.c b/libswfdec/swfdec_swf_decoder.c
index 8d172a9..ac39d6c 100644
--- a/libswfdec/swfdec_swf_decoder.c
+++ b/libswfdec/swfdec_swf_decoder.c
@@ -295,7 +295,7 @@ swfdec_swf_decoder_parse (SwfdecDecoder
if (func == NULL) {
SWFDEC_WARNING ("tag function not implemented for %d %s",
tag, swfdec_swf_decoder_get_tag_name (tag));
- } else {
+ } else if (s->main_sprite->parse_frame < s->main_sprite->n_frames) {
s->parse_sprite = s->main_sprite;
ret = func (s);
s->parse_sprite = NULL;
@@ -308,6 +308,9 @@ swfdec_swf_decoder_parse (SwfdecDecoder
swfdec_buffer_queue_get_offset (s->input_queue), tag,
swfdec_swf_decoder_get_tag_name (tag), tag_len);
}
+ } else {
+ ret = SWFDEC_STATE_EOF;
+ SWFDEC_ERROR ("data after last frame");
}
if (tag == 0) {
diff --git a/libswfdec/swfdec_tag.c b/libswfdec/swfdec_tag.c
index 0d0eeb8..6000d45 100644
--- a/libswfdec/swfdec_tag.c
+++ b/libswfdec/swfdec_tag.c
@@ -195,7 +195,7 @@ tag_func_define_sprite (SwfdecSwfDecoder
int id;
SwfdecSprite *sprite;
int ret;
- guint tag;
+ guint tag = 1;
parse = s->b;
@@ -209,7 +209,7 @@ tag_func_define_sprite (SwfdecSwfDecoder
swfdec_sprite_set_n_frames (sprite, swfdec_bits_get_u16 (&parse), SWFDEC_DECODER (s)->rate);
s->parse_sprite = sprite;
- do {
+ while (tag != 0 && s->parse_sprite->parse_frame < s->parse_sprite->n_frames) {
int x;
guint tag_len;
SwfdecTagFunc *func;
@@ -246,7 +246,7 @@ tag_func_define_sprite (SwfdecSwfDecoder
}
}
- } while (tag != 0);
+ }
s->b = parse;
/* this assumes that no recursive DefineSprite happens and we check it doesn't */
diff-tree bc8720b4d23eb94de1e95327805ecfdd945cd3ce (from 826b8d99b1b4fd4d7c2571def8bc10c4a6539c17)
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Apr 20 18:46:02 2007 +0200
document the rest of the functions and make some of them return guint
diff --git a/libswfdec/swfdec_buffer.c b/libswfdec/swfdec_buffer.c
index c2b9d85..c41a830 100644
--- a/libswfdec/swfdec_buffer.c
+++ b/libswfdec/swfdec_buffer.c
@@ -46,6 +46,8 @@
/**
* SwfdecBuffer:
+ * @data: the data. read-only
+ * @length: number of bytes in @data. read-only
*
* To allow for easy sharing of memory regions, #SwfdecBuffer was created.
* Every buffer refers to a memory region and its size and takes care of
@@ -322,6 +324,13 @@ swfdec_buffer_queue_get_type (void)
return type_swfdec_buffer_queue;
}
+/**
+ * swfdec_buffer_queue_new:
+ *
+ * Creates a new empty buffer queue.
+ *
+ * Returns: a new buffer queue. Use swfdec_buffer_queue_unref () to free it.
+ **/
SwfdecBufferQueue *
swfdec_buffer_queue_new (void)
{
@@ -332,26 +341,65 @@ swfdec_buffer_queue_new (void)
return buffer_queue;
}
-int
+/**
+ * swfdec_buffer_queue_get_depth:
+ * @queue: a #SwfdecBufferQueue
+ *
+ * Returns the number of bytes currently in @queue.
+ *
+ * Returns: amount of bytes in @queue.
+ **/
+guint
swfdec_buffer_queue_get_depth (SwfdecBufferQueue * queue)
{
+ g_return_val_if_fail (queue != NULL, 0);
+
return queue->depth;
}
-int
+/**
+ * swfdec_buffer_queue_get_offset:
+ * @queue: a #SwfdecBufferQueue
+ *
+ * Queries the amount of bytes that has already been pulled out of
+ * @queue using functions like swfdec_buffer_queue_pull().
+ *
+ * Returns: Number of bytes that were already pulled from this queue.
+ **/
+guint
swfdec_buffer_queue_get_offset (SwfdecBufferQueue * queue)
{
+ g_return_val_if_fail (queue != NULL, 0);
+
return queue->offset;
}
+/**
+ * swfdec_buffer_queue_clear:
+ * @queue: a #SwfdecBufferQueue
+ *
+ * Resets @queue into to initial state. All buffers it contains will be
+ * released and the offset will be reset to 0.
+ **/
void
swfdec_buffer_queue_clear (SwfdecBufferQueue *queue)
{
+ g_return_if_fail (queue != NULL);
+
g_list_foreach (queue->buffers, (GFunc) swfdec_buffer_unref, NULL);
g_list_free (queue->buffers);
memset (queue, 0, sizeof (SwfdecBufferQueue));
}
+/**
+ * swfdec_buffer_queue_push:
+ * @queue: a #SwfdecBufferQueue
+ * @buffer: #SwfdecBuffer to append to @queue
+ *
+ * Appends the given @buffer to the buffers already in @queue. This function
+ * will take ownership of the given @buffer. Use swfdec_buffer_ref () before
+ * calling this function to keep a reference.
+ **/
void
swfdec_buffer_queue_push (SwfdecBufferQueue * queue, SwfdecBuffer * buffer)
{
@@ -390,6 +438,18 @@ swfdec_buffer_queue_pull_buffer (SwfdecB
return swfdec_buffer_queue_pull (queue, buffer->length);
}
+/**
+ * swfdec_buffer_queue_pull:
+ * @queue: a #SwfdecBufferQueue
+ * @length: amount of bytes to pull
+ *
+ * If enough data is still available in @queue, the first @length bytes are
+ * put into a new buffer and that buffer is returned. The @length bytes are
+ * removed from the head of the queue. If not enough data is available, %NULL
+ * is returned.
+ *
+ * Returns: a new #SwfdecBuffer or %NULL
+ **/
SwfdecBuffer *
swfdec_buffer_queue_pull (SwfdecBufferQueue * queue, guint length)
{
diff --git a/libswfdec/swfdec_buffer.h b/libswfdec/swfdec_buffer.h
index 95b89f0..90555d1 100644
--- a/libswfdec/swfdec_buffer.h
+++ b/libswfdec/swfdec_buffer.h
@@ -33,6 +33,7 @@ struct _SwfdecBuffer
unsigned char *data;
guint length;
+ /*< private >*/
int ref_count;
SwfdecBuffer *parent;
@@ -46,6 +47,7 @@ GType swfdec_buffer_get_type (void);
struct _SwfdecBufferQueue
{
+ /*< private >*/
GList *buffers;
guint depth;
guint offset;
@@ -68,8 +70,8 @@ void swfdec_buffer_unref (SwfdecBuffer *
SwfdecBufferQueue *swfdec_buffer_queue_new (void);
void swfdec_buffer_queue_clear (SwfdecBufferQueue *queue);
-int swfdec_buffer_queue_get_depth (SwfdecBufferQueue * queue);
-int swfdec_buffer_queue_get_offset (SwfdecBufferQueue * queue);
+guint swfdec_buffer_queue_get_depth (SwfdecBufferQueue * queue);
+guint swfdec_buffer_queue_get_offset (SwfdecBufferQueue * queue);
void swfdec_buffer_queue_push (SwfdecBufferQueue * queue,
SwfdecBuffer * buffer);
SwfdecBuffer *swfdec_buffer_queue_pull (SwfdecBufferQueue * queue, guint length);
diff --git a/libswfdec/swfdec_swf_decoder.c b/libswfdec/swfdec_swf_decoder.c
index f8a34b1..8d172a9 100644
--- a/libswfdec/swfdec_swf_decoder.c
+++ b/libswfdec/swfdec_swf_decoder.c
@@ -238,11 +238,11 @@ swfdec_swf_decoder_parse (SwfdecDecoder
break;
case SWFDEC_STATE_PARSETAG:
{
- int header_length;
- int x;
+ guint header_length;
+ guint x;
SwfdecTagFunc *func;
- int tag;
- int tag_len;
+ guint tag;
+ guint tag_len;
if (!swfdec_swf_decoder_deflate_all (s))
return SWFDEC_STATUS_ERROR;
diff-tree 826b8d99b1b4fd4d7c2571def8bc10c4a6539c17 (from 117ecebbdd9eab3f3227ed1a56d1bb2394789d32)
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Apr 20 17:37:48 2007 +0200
be a bit more sane on command line errors
diff --git a/test/parse.c b/test/parse.c
index 6fa7234..48bbd2f 100644
--- a/test/parse.c
+++ b/test/parse.c
@@ -28,13 +28,13 @@
int
main (int argc, char *argv[])
{
- char *fn = "it.swf";
SwfdecPlayer *player;
swfdec_init ();
- if(argc>=2){
- fn = argv[1];
+ if (argc < 2){
+ g_print ("usage: %s FILENAME\n", argv[0]);
+ return 0;
}
player = swfdec_player_new_from_file (argv[1]);
diff-tree 117ecebbdd9eab3f3227ed1a56d1bb2394789d32 (from d5d6259d8f66e4b23d19678d905aca3e58c8fc6b)
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Apr 20 13:06:33 2007 +0200
Change intriduction in docs to be struct-specific
diff --git a/libswfdec/swfdec_buffer.c b/libswfdec/swfdec_buffer.c
index 86c00a6..c2b9d85 100644
--- a/libswfdec/swfdec_buffer.c
+++ b/libswfdec/swfdec_buffer.c
@@ -36,6 +36,17 @@
* @title: SwfdecBuffer
* @short_description: memory region handling
*
+ * This section describes how memory is to be handled when interacting with the
+ * Swfdec library. Memory regions are refcounted and passed using a
+ * #SwfdecBuffer. If large memory segments need to be handled that may span
+ * multiple buffers, Swfdec uses a #SwfdecBufferQueue.
+ */
+
+/*** SwfdecBuffer ***/
+
+/**
+ * SwfdecBuffer:
+ *
* To allow for easy sharing of memory regions, #SwfdecBuffer was created.
* Every buffer refers to a memory region and its size and takes care of
* freeing that region when the buffer is no longer needed. They are
@@ -44,15 +55,8 @@
* functionalities like extracting parts of the buffer using
* swfdec_buffer_new_subbuffer() or using mmapped files with
* swfdec_buffer_new_from_file() without the need for a different API.
- *
- * A #SwfdecBufferQueue is a queue of continuous buffers that allows reading
- * its data in chunks of pre-defined sizes. It is used to transform a data
- * stream that was provided by buffers of random sizes to buffers of the right
- * size.
*/
-/*** SwfdecBuffer ***/
-
/**
* SWFDEC_TYPE_BUFFER:
*
@@ -290,6 +294,15 @@ swfdec_buffer_unref (SwfdecBuffer * buff
/*** SwfdecBufferQueue ***/
/**
+ * SwfdecBufferQueue:
+ *
+ * A #SwfdecBufferQueue is a queue of continuous buffers that allows reading
+ * its data in chunks of pre-defined sizes. It is used to transform a data
+ * stream that was provided by buffers of random sizes to buffers of the right
+ * size.
+ */
+
+/**
* SWFDEC_TYPE_BUFFER_QUEUE:
*
* #SwfdecBufferQueue is a boxed type for the glib type system. This macro
diff-tree d5d6259d8f66e4b23d19678d905aca3e58c8fc6b (from 02d5d57466eac0d39c0ac4af6364683724d7ee4f)
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Apr 20 13:06:05 2007 +0200
handle the 0-byte tag length case in the debug message
diff --git a/libswfdec/swfdec_tag.c b/libswfdec/swfdec_tag.c
index e372fc1..0d0eeb8 100644
--- a/libswfdec/swfdec_tag.c
+++ b/libswfdec/swfdec_tag.c
@@ -221,7 +221,7 @@ tag_func_define_sprite (SwfdecSwfDecoder
tag_len = swfdec_bits_get_u32 (&parse);
}
SWFDEC_INFO ("sprite parsing at %td, tag %d %s, length %d",
- parse.ptr - parse.buffer->data, tag,
+ parse.buffer ? parse.ptr - parse.buffer->data : 0, tag,
swfdec_swf_decoder_get_tag_name (tag), tag_len);
if (tag_len == 0) {
diff-tree 02d5d57466eac0d39c0ac4af6364683724d7ee4f (from c6976c653468bdd720f0d765781247e7625255f6)
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Apr 20 12:57:28 2007 +0200
we don't like exports without names
diff --git a/libswfdec/swfdec_root_sprite.c b/libswfdec/swfdec_root_sprite.c
index 41e8b31..722e61e 100644
--- a/libswfdec/swfdec_root_sprite.c
+++ b/libswfdec/swfdec_root_sprite.c
@@ -127,6 +127,8 @@ tag_func_export_assets (SwfdecSwfDecoder
if (object == NULL) {
SWFDEC_ERROR ("cannot export id %u as %s, id wasn't found", id, name);
g_free (name);
+ } else if (name == NULL) {
+ SWFDEC_ERROR ("cannot export id %u, no name was given", id);
} else {
SwfdecRootExportData *data = g_new (SwfdecRootExportData, 1);
data->name = name;
diff-tree c6976c653468bdd720f0d765781247e7625255f6 (from 15ed4a69b4ffc265fe103ba79a0b60af7e42a9fa)
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Apr 20 10:03:09 2007 +0200
update NEWS
diff --git a/NEWS b/NEWS
index d31b5d2..a719ed3 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,19 @@
+ 0.4.4 ()
+
+This is a stability release. The number of new supported Flash features
+is limited.
+- add initial support for some tags from Flash 8 (in particular
+ DefineShape4 and PlaceObject3)
+- audio and video can now be decoded with GStreamer
+- add new API in the form of libswfdec-gtk for people that want to
+ include Swfdec in their applications
+- improve the JPEG decoding code (less crashy, more JPEGs decoded)
+- throw zzuf (http://sam.zoy.org/zzuf/) at Swfdec and fix exposed
+ issues
+- various fixes that make writing bindings simpler
+- lots of bugs fixed, including: 10551, 10629
+
0.4.3 ("Your tube")
This release can play Youtube video. While this alone is enough for a
More information about the Swfdec
mailing list