gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ./ChangeLog server/Makefile.am server/act...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ./ChangeLog server/Makefile.am server/act...
Date: Tue, 09 May 2006 15:34:16 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Branch:         
Changes by:     Sandro Santilli <address@hidden>        06/05/09 15:34:16

Modified files:
        .              : ChangeLog 
        server         : Makefile.am action.cpp gnash.h impl.cpp impl.h 
                         movie_def_impl.cpp movie_def_impl.h sound.cpp 
                         sprite_definition.cpp sprite_definition.h 
                         sprite_instance.cpp stream.cpp stream.h swf.h 
                         text.cpp 
Added files:
        server         : execute_tag.h 
        server/swf     : TagLoadersTable.cpp TagLoadersTable.h 
                         tag_loaders.cpp tag_loaders.h 

Log message:
        * server/swf: new swf directory for SWF parsing related classes.
        * server/swf/TagLoadersTable.{h,cpp}: new class modeling a table of tag 
loaders.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/ChangeLog.diff?tr1=1.281&tr2=1.282&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/Makefile.am.diff?tr1=1.35&tr2=1.36&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/action.cpp.diff?tr1=1.70&tr2=1.71&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/execute_tag.h?rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/gnash.h.diff?tr1=1.21&tr2=1.22&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/impl.cpp.diff?tr1=1.34&tr2=1.35&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/impl.h.diff?tr1=1.24&tr2=1.25&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/movie_def_impl.cpp.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/movie_def_impl.h.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/sound.cpp.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/sprite_definition.cpp.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/sprite_definition.h.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/sprite_instance.cpp.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/stream.cpp.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/stream.h.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/swf.h.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/text.cpp.diff?tr1=1.16&tr2=1.17&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/swf/TagLoadersTable.cpp?rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/swf/TagLoadersTable.h?rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/swf/tag_loaders.cpp?rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/swf/tag_loaders.h?rev=1.1

Patches:
Index: gnash/ChangeLog
diff -u gnash/ChangeLog:1.281 gnash/ChangeLog:1.282
--- gnash/ChangeLog:1.281       Tue May  9 10:41:43 2006
+++ gnash/ChangeLog     Tue May  9 15:34:15 2006
@@ -1,5 +1,10 @@
 2006-05-09 Sandro Santilli <address@hidden>
 
+       * server/swf: new swf directory for SWF parsing related classes.
+       * server/swf/TagLoadersTable.{h,cpp}: new class modeling a
+       table of tag loaders.
+       * server/swf/tag_loaders.{h,cpp}: tag loaders extracted
+       from impl.cpp file and grouped into the swf namespace.
        * server/impl.cpp: (define_shape_loader) symbolic names for
        tag types 
        * server/movie_def_impl.cpp, server/movie_def_impl.h:
Index: gnash/server/Makefile.am
diff -u gnash/server/Makefile.am:1.35 gnash/server/Makefile.am:1.36
--- gnash/server/Makefile.am:1.35       Mon May  8 13:59:07 2006
+++ gnash/server/Makefile.am    Tue May  9 15:34:15 2006
@@ -154,6 +154,8 @@
         tesselate.cpp    \
         text.cpp         \
         array.cpp        \
+       swf/TagLoadersTable.cpp \
+       swf/tag_loaders.cpp     \
         types.cpp $(MP3_HANDLER)
 
 noinst_HEADERS = $(as_incls) \
@@ -169,6 +171,7 @@
        character_def.h \
        generic_character.h     \
        bitmap_character_def.h  \
+       execute_tag.h   \
        font.h          \
        fontlib.h       \
        Global.h        \
@@ -210,6 +213,8 @@
         xmlattrs.h      \
        xml.h           \
         xmlnode.h       \
+       swf/TagLoadersTable.h   \
+       swf/tag_loaders.h       \
        xmlsocket.h
 
 #libserver_la_LDFLAGS = -module -avoid-version -no-undefined
Index: gnash/server/action.cpp
diff -u gnash/server/action.cpp:1.70 gnash/server/action.cpp:1.71
--- gnash/server/action.cpp:1.70        Mon May  8 21:12:24 2006
+++ gnash/server/action.cpp     Tue May  9 15:34:16 2006
@@ -578,73 +578,6 @@
 
 
 //
-// do_action
-//
-
-
-/// Thin wrapper around action_buffer.
-struct do_action : public execute_tag
-{
-    action_buffer      m_buf;
-
-    void       read(stream* in)
-       {
-           m_buf.read(in);
-       }
-
-    virtual void       execute(movie* m)
-       {
-           m->add_action_buffer(&m_buf);
-       }
-
-    // Don't override because actions should not be replayed when seeking the 
movie.
-    //void     execute_state(movie* m) {}
-
-    virtual bool       is_action_tag() const
-       // Tell the caller that we are an action tag.
-       {
-           return true;
-       }
-};
-
-void   do_action_loader(stream* in, int tag_type, movie_definition* m)
-{
-    IF_VERBOSE_PARSE(log_msg("tag %d: do_action_loader\n", tag_type));
-
-    IF_VERBOSE_ACTION(log_msg("-- actions in frame %d\n", 
m->get_loading_frame()));
-
-    assert(in);
-    assert(tag_type == 12);
-    assert(m);
-               
-    do_action* da = new do_action;
-    da->read(in);
-
-    m->add_execute_tag(da);
-}
-
-       
-//
-// do_init_action
-//
-
-
-void   do_init_action_loader(stream* in, int tag_type, movie_definition* m)
-{
-    assert(tag_type == 59);
-
-    int        sprite_character_id = in->read_u16();
-
-    IF_VERBOSE_PARSE(log_msg("  tag %d: do_init_action_loader\n", tag_type));
-    IF_VERBOSE_ACTION(log_msg("  -- init actions for sprite %d\n", 
sprite_character_id));
-
-    do_action* da = new do_action;
-    da->read(in);
-    m->add_init_action(sprite_character_id, da);
-}
-
-
-//
 // action_buffer
 //
 
Index: gnash/server/gnash.h
diff -u gnash/server/gnash.h:1.21 gnash/server/gnash.h:1.22
--- gnash/server/gnash.h:1.21   Mon May  8 21:12:24 2006
+++ gnash/server/gnash.h        Tue May  9 15:34:16 2006
@@ -256,10 +256,10 @@
        DO_NOT_LOAD_FONT_SHAPES
 };
 
-movie_definition*      create_movie_no_recurse(
-       tu_file*                input_stream,
-       create_bitmaps_flag     cbf,
-       create_font_shapes_flag cfs);
+//movie_definition*    create_movie_no_recurse(
+//     tu_file*                input_stream,
+//     create_bitmaps_flag     cbf,
+//     create_font_shapes_flag cfs);
 
 /// \brief
 /// Create a gnash::movie_definition from the given file name.
Index: gnash/server/impl.cpp
diff -u gnash/server/impl.cpp:1.34 gnash/server/impl.cpp:1.35
--- gnash/server/impl.cpp:1.34  Tue May  9 10:41:43 2006
+++ gnash/server/impl.cpp       Tue May  9 15:34:16 2006
@@ -72,6 +72,8 @@
 #include "Function.h"
 #include "movie_def_impl.h"
 #include "swf.h"
+#include "swf/TagLoadersTable.h"
+#include "swf/tag_loaders.h"
 #include "generic_character.h"
 
 namespace gnash
@@ -111,17 +113,17 @@
 }
 
 // Keep a table of loader functions for the different tag types.
-hash<int, loader_function>     s_tag_loaders;
+SWF::TagLoadersTable s_tag_loaders;
 
-    // Associate the specified tag type with the given tag loader
-    // function.
+// Associate the specified tag type with the given tag loader
+// function.
 void
-register_tag_loader(int tag_type, loader_function lf)
+register_tag_loader(SWF::tag_type t, SWF::TagLoadersTable::loader_function lf)
 {
-    assert(s_tag_loaders.get(tag_type, NULL) == false);
-    assert(lf != NULL);
-    
-    s_tag_loaders.add(tag_type, lf);
+       bool loader_registered = s_tag_loaders.register_loader(t, lf);
+       //if ( !loader_registered )
+       // log_error("Duplicate loader registered for tag %d", t);
+       assert(loader_registered);
 }
 
 
@@ -203,76 +205,79 @@
 
 static void    ensure_loaders_registered()
 {
-    static bool        s_registered = false;
+       using namespace SWF::tag_loaders;
+
+       static bool s_registered = false;
        
-    if (s_registered == false)
-       {
-               // Register the standard loaders.
-               s_registered = true;
+       if (s_registered) return;
+
+       // Register the standard loaders.
+       s_registered = true;
+
+       register_tag_loader(SWF::END,           end_loader);
+       register_tag_loader(SWF::DEFINESHAPE,   define_shape_loader);
+       register_tag_loader(SWF::FREECHARACTER, fixme_loader); // 03
+       register_tag_loader(SWF::PLACEOBJECT,   place_object_2_loader);
+       register_tag_loader(SWF::REMOVEOBJECT,  remove_object_2_loader);
+       register_tag_loader(SWF::DEFINEBITS,    define_bits_jpeg_loader);
+       register_tag_loader(SWF::DEFINEBUTTON,  button_character_loader);
+       register_tag_loader(SWF::JPEGTABLES,    jpeg_tables_loader);
+       register_tag_loader(SWF::SETBACKGROUNDCOLOR, 
set_background_color_loader);
+       register_tag_loader(SWF::DEFINEFONT,    define_font_loader);
+       register_tag_loader(SWF::DEFINETEXT,    define_text_loader);
+       register_tag_loader(SWF::DOACTION,      do_action_loader);
+       register_tag_loader(SWF::DEFINEFONTINFO, define_font_info_loader);
+       register_tag_loader(SWF::DEFINESOUND,   define_sound_loader);
+       register_tag_loader(SWF::STARTSOUND,    start_sound_loader);
+       // 16 _UNKNOWN_ unimplemented
+       register_tag_loader(SWF::DEFINEBUTTONSOUND, button_sound_loader);
+       register_tag_loader(SWF::SOUNDSTREAMHEAD, fixme_loader); // 18
+       register_tag_loader(SWF::SOUNDSTREAMBLOCK, fixme_loader); // 19
+       register_tag_loader(SWF::DEFINELOSSLESS, define_bits_lossless_2_loader);
+       register_tag_loader(SWF::DEFINEBITSJPEG2, define_bits_jpeg2_loader);
+       register_tag_loader(SWF::DEFINESHAPE2,  define_shape_loader);
+       register_tag_loader(SWF::DEFINEBUTTONCXFORM, fixme_loader); // 23
+       // "protect" tag; we're not an authoring tool so we don't care.
+       register_tag_loader(SWF::PROTECT,       null_loader);
+       register_tag_loader(SWF::PATHSAREPOSTSCRIPT, fixme_loader); // 25
+       register_tag_loader(SWF::PLACEOBJECT2,  place_object_2_loader);
+       // 27 - _UNKNOWN_ unimplemented
+       register_tag_loader(SWF::REMOVEOBJECT2, remove_object_2_loader);
+       register_tag_loader(SWF::SYNCFRAME,     fixme_loader); // 29
+       // 30 - _UNKNOWN_ unimplemented
+       register_tag_loader(SWF::FREEALL,       fixme_loader); // 31
+       register_tag_loader(SWF::DEFINESHAPE3,  define_shape_loader);
+       register_tag_loader(SWF::DEFINETEXT2,   define_text_loader);
+       register_tag_loader(SWF::DEFINEBUTTON2, button_character_loader);
+       register_tag_loader(SWF::DEFINEBITSJPEG3, define_bits_jpeg3_loader);
+       register_tag_loader(SWF::DEFINELOSSLESS2, 
define_bits_lossless_2_loader);
+       register_tag_loader(SWF::DEFINEEDITTEXT, define_edit_text_loader);
+       register_tag_loader(SWF::DEFINEVIDEO,   fixme_loader); // 38
+       register_tag_loader(SWF::DEFINESPRITE,  sprite_loader);
+       register_tag_loader(SWF::NAMECHARACTER, fixme_loader); // 40
+       register_tag_loader(SWF::SERIALNUMBER,  fixme_loader); // 41
+       register_tag_loader(SWF::DEFINETEXTFORMAT, fixme_loader); // 42
+       register_tag_loader(SWF::FRAMELABEL,    frame_label_loader);
+       // 44 - _UNKNOWN_ unimplemented
+       register_tag_loader(SWF::SOUNDSTREAMHEAD2, fixme_loader); // 45
+       register_tag_loader(SWF::DEFINEMORPHSHAPE, define_shape_morph_loader);
+       register_tag_loader(SWF::FRAMETAG,      fixme_loader); // 47
+       register_tag_loader(SWF::DEFINEFONT2,   define_font_loader);
+       register_tag_loader(SWF::GENCOMMAND,    fixme_loader); // 49
+       register_tag_loader(SWF::DEFINECOMMANDOBJ, fixme_loader); // 50
+       register_tag_loader(SWF::CHARACTERSET,  fixme_loader); // 51
+       register_tag_loader(SWF::FONTREF,       fixme_loader); // 52
+       // 53 - _UNKNOWN_ unimplemented
+       // 54 - _UNKNOWN_ unimplemented
+       // 55 - _UNKNOWN_ unimplemented
+       register_tag_loader(SWF::EXPORTASSETS,  export_loader);
+       register_tag_loader(SWF::IMPORTASSETS,  import_loader);
+       // 58 - _UNKNOWN_ unimplemented
+       register_tag_loader(SWF::INITACTION, do_init_action_loader);   
+       register_tag_loader(SWF::DEFINEVIDEOSTREAM, fixme_loader); // 60
+
+       register_tag_loader(SWF::VIDEOFRAME, fixme_loader); // 61
 
-               register_tag_loader(SWF::END,           end_loader);
-               register_tag_loader(SWF::DEFINESHAPE,   define_shape_loader);
-               register_tag_loader(SWF::FREECHARACTER, fixme_loader); // 03
-               register_tag_loader(SWF::PLACEOBJECT,   place_object_2_loader);
-               register_tag_loader(SWF::REMOVEOBJECT,  remove_object_2_loader);
-               register_tag_loader(SWF::DEFINEBITS,    
define_bits_jpeg_loader);
-               register_tag_loader(SWF::DEFINEBUTTON,  
button_character_loader);
-               register_tag_loader(SWF::JPEGTABLES,    jpeg_tables_loader);
-               register_tag_loader(SWF::SETBACKGROUNDCOLOR, 
set_background_color_loader);
-               register_tag_loader(SWF::DEFINEFONT,    define_font_loader);
-               register_tag_loader(SWF::DEFINETEXT,    define_text_loader);
-               register_tag_loader(SWF::DOACTION,      do_action_loader);
-               register_tag_loader(SWF::DEFINEFONTINFO, 
define_font_info_loader);
-               register_tag_loader(SWF::DEFINESOUND,   define_sound_loader);
-               register_tag_loader(SWF::STARTSOUND,    start_sound_loader);
-               // 16 _UNKNOWN_ unimplemented
-               register_tag_loader(SWF::DEFINEBUTTONSOUND, 
button_sound_loader);
-               register_tag_loader(SWF::SOUNDSTREAMHEAD, fixme_loader); // 18
-               register_tag_loader(SWF::SOUNDSTREAMBLOCK, fixme_loader); // 19
-               register_tag_loader(SWF::DEFINELOSSLESS, 
define_bits_lossless_2_loader);
-               register_tag_loader(SWF::DEFINEBITSJPEG2, 
define_bits_jpeg2_loader);
-               register_tag_loader(SWF::DEFINESHAPE2,  define_shape_loader);
-               register_tag_loader(SWF::DEFINEBUTTONCXFORM, fixme_loader); // 
23
-               // "protect" tag; we're not an authoring tool so we don't care.
-               register_tag_loader(SWF::PROTECT,       null_loader);
-               register_tag_loader(SWF::PATHSAREPOSTSCRIPT, fixme_loader); // 
25
-               register_tag_loader(SWF::PLACEOBJECT2,  place_object_2_loader);
-               // 27 - _UNKNOWN_ unimplemented
-               register_tag_loader(SWF::REMOVEOBJECT2, remove_object_2_loader);
-               register_tag_loader(SWF::SYNCFRAME,     fixme_loader); // 29
-               // 30 - _UNKNOWN_ unimplemented
-               register_tag_loader(SWF::FREEALL,       fixme_loader); // 31
-               register_tag_loader(SWF::DEFINESHAPE3,  define_shape_loader);
-               register_tag_loader(SWF::DEFINETEXT2,   define_text_loader);
-               register_tag_loader(SWF::DEFINEBUTTON2, 
button_character_loader);
-               register_tag_loader(SWF::DEFINEBITSJPEG3, 
define_bits_jpeg3_loader);
-               register_tag_loader(SWF::DEFINELOSSLESS2, 
define_bits_lossless_2_loader);
-               register_tag_loader(SWF::DEFINEEDITTEXT, 
define_edit_text_loader);
-               register_tag_loader(SWF::DEFINEVIDEO,   fixme_loader); // 38
-               register_tag_loader(SWF::DEFINESPRITE,  sprite_loader);
-               register_tag_loader(SWF::NAMECHARACTER, fixme_loader); // 40
-               register_tag_loader(SWF::SERIALNUMBER,  fixme_loader); // 41
-               register_tag_loader(SWF::DEFINETEXTFORMAT, fixme_loader); // 42
-               register_tag_loader(SWF::FRAMELABEL,    frame_label_loader);
-               // 44 - _UNKNOWN_ unimplemented
-               register_tag_loader(SWF::SOUNDSTREAMHEAD2, fixme_loader); // 45
-               register_tag_loader(SWF::DEFINEMORPHSHAPE, 
define_shape_morph_loader);
-               register_tag_loader(SWF::FRAMETAG,      fixme_loader); // 47
-               register_tag_loader(SWF::DEFINEFONT2,   define_font_loader);
-               register_tag_loader(SWF::GENCOMMAND,    fixme_loader); // 49
-               register_tag_loader(SWF::DEFINECOMMANDOBJ, fixme_loader); // 50
-               register_tag_loader(SWF::CHARACTERSET,  fixme_loader); // 51
-               register_tag_loader(SWF::FONTREF,       fixme_loader); // 52
-               // 53 - _UNKNOWN_ unimplemented
-               // 54 - _UNKNOWN_ unimplemented
-               // 55 - _UNKNOWN_ unimplemented
-               register_tag_loader(SWF::EXPORTASSETS,  export_loader);
-               register_tag_loader(SWF::IMPORTASSETS,  import_loader);
-               // 58 - _UNKNOWN_ unimplemented
-               register_tag_loader(SWF::INITACTION,    do_init_action_loader); 
  
-               register_tag_loader(SWF::DEFINEVIDEOSTREAM, fixme_loader); // 60
-               register_tag_loader(SWF::VIDEOFRAME,    fixme_loader); // 61
-       }
 }
 
 
@@ -428,7 +433,7 @@
 }
 
 
-static bool    s_no_recurse_while_loading = false;     // @@ TODO get rid of 
this; make it the normal mode.
+bool   s_no_recurse_while_loading = false;     // @@ TODO get rid of this; 
make it the normal mode.
 
 
 movie_definition*      create_movie_no_recurse(
@@ -708,1270 +713,6 @@
 }
 
 
-//
-// Some tag implementations
-//
-
-
-void   null_loader(stream* in, int tag_type, movie_definition* m)
-    // Silently ignore the contents of this tag.
-{
-}
-
-void   frame_label_loader(stream* in, int tag_type, movie_definition* m)
-    // Label the current frame of m with the name from the stream.
-{
-    char*      n = in->read_string();
-    m->add_frame_name(n);
-    delete [] n;
-}
-
-/// SWF Tag SetBackgroundColor (9)
-struct set_background_color : public execute_tag
-{
-    rgba       m_color;
-
-    void       execute(movie* m)
-       {
-           float       current_alpha = m->get_background_alpha();
-           m_color.m_a = frnd(current_alpha * 255.0f);
-           m->set_background_color(m_color);
-       }
-
-    void       execute_state(movie* m)
-       {
-           execute(m);
-       }
-
-    void       read(stream* in)
-       {
-           m_color.read_rgb(in);
-
-           IF_VERBOSE_PARSE(log_msg("  set_background_color: (%d %d %d)\n",
-                                    m_color.m_r, m_color.m_g, m_color.m_b));
-       }
-};
-
-
-void   set_background_color_loader(stream* in, int tag_type, movie_definition* 
m)
-{
-    assert(tag_type == 9);
-    assert(m);
-
-    set_background_color*      t = new set_background_color;
-    t->read(in);
-
-    m->add_execute_tag(t);
-}
-
-#if 0
-// Bitmap character
-struct bitmap_character : public bitmap_character_def
-{
-    bitmap_character(bitmap_info* bi)
-       :
-       m_bitmap_info(bi)
-       {
-       }
-
-//             bitmap_character(image::rgb* image)
-//             {
-//                     assert(image != 0);
-
-//                     // Create our bitmap info, from our image.
-//                     m_bitmap_info = 
gnash::render::create_bitmap_info_rgb(image);
-//             }
-
-//             bitmap_character(image::rgba* image)
-//             {
-//                     assert(image != 0);
-
-//                     // Create our bitmap info, from our image.
-//                     m_bitmap_info = 
gnash::render::create_bitmap_info_rgba(image);
-//             }
-
-    gnash::bitmap_info*        get_bitmap_info()
-       {
-           return m_bitmap_info.get_ptr();
-       }
-
-private:
-    smart_ptr<gnash::bitmap_info>      m_bitmap_info;
-};
-#endif
-
-void   jpeg_tables_loader(stream* in, int tag_type, movie_definition* m)
-    // Load JPEG compression tables that can be used to load
-    // images further along in the stream.
-{
-    assert(tag_type == 8);
-
-#if TU_CONFIG_LINK_TO_JPEGLIB
-    jpeg::input*       j_in = 
jpeg::input::create_swf_jpeg2_header_only(in->get_underlying_stream());
-    assert(j_in);
-
-    m->set_jpeg_loader(j_in);
-#endif // TU_CONFIG_LINK_TO_JPEGLIB
-}
-
-
-void   define_bits_jpeg_loader(stream* in, int tag_type, movie_definition* m)
-    // A JPEG image without included tables; those should be in an
-    // existing jpeg::input object stored in the movie.
-{
-    assert(tag_type == 6);
-
-    uint16_t   character_id = in->read_u16();
-
-    //
-    // Read the image data.
-    //
-    bitmap_info*       bi = NULL;
-
-    if (m->get_create_bitmaps() == DO_LOAD_BITMAPS)
-       {
-#if TU_CONFIG_LINK_TO_JPEGLIB
-           jpeg::input*        j_in = m->get_jpeg_loader();
-           assert(j_in);
-           j_in->discard_partial_buffer();
-
-           image::rgb* im = image::read_swf_jpeg2_with_tables(j_in);
-           bi = render::create_bitmap_info_rgb(im);
-           delete im;
-#else
-           log_error("gnash is not linked to jpeglib -- can't load jpeg image 
data!\n");
-           bi = render::create_bitmap_info_empty();
-#endif
-       }
-    else
-       {
-           bi = render::create_bitmap_info_empty();
-       }
-
-    assert(bi->get_ref_count() == 0);
-
-    bitmap_character*  ch = new bitmap_character(bi);
-
-    m->add_bitmap_character(character_id, ch);
-}
-
-
-void   define_bits_jpeg2_loader(stream* in, int tag_type, movie_definition* m)
-{
-    assert(tag_type == 21);
-               
-    uint16_t   character_id = in->read_u16();
-
-    IF_VERBOSE_PARSE(log_msg("  define_bits_jpeg2_loader: charid = %d pos = 
0x%x\n", character_id, in->get_position()));
-
-    //
-    // Read the image data.
-    //
-               
-    bitmap_info*       bi = NULL;
-
-    if (m->get_create_bitmaps() == DO_LOAD_BITMAPS)
-       {
-#if TU_CONFIG_LINK_TO_JPEGLIB
-           image::rgb* im = image::read_jpeg(in->get_underlying_stream());
-           bi = render::create_bitmap_info_rgb(im);
-           delete im;
-#else
-           log_error("gnash is not linked to jpeglib -- can't load jpeg image 
data!\n");
-           bi = render::create_bitmap_info_empty();
-#endif
-       }
-    else
-       {
-           bi = render::create_bitmap_info_empty();
-       }
-
-    assert(bi->get_ref_count() == 0);
-
-    bitmap_character*  ch = new bitmap_character(bi);
-
-    m->add_bitmap_character(character_id, ch);
-}
-
-
-#if TU_CONFIG_LINK_TO_ZLIB
-void   inflate_wrapper(tu_file* in, void* buffer, int buffer_bytes)
-    // Wrapper function -- uses Zlib to uncompress in_bytes worth
-    // of data from the input file into buffer_bytes worth of data
-    // into *buffer.
-{
-    assert(in);
-    assert(buffer);
-    assert(buffer_bytes > 0);
-
-    int err;
-    z_stream d_stream; /* decompression stream */
-
-    d_stream.zalloc = (alloc_func)0;
-    d_stream.zfree = (free_func)0;
-    d_stream.opaque = (voidpf)0;
-
-    d_stream.next_in  = 0;
-    d_stream.avail_in = 0;
-
-    d_stream.next_out = (Byte*) buffer;
-    d_stream.avail_out = (uInt) buffer_bytes;
-
-    err = inflateInit(&d_stream);
-    if (err != Z_OK) {
-       log_error("error: inflate_wrapper() inflateInit() returned %d\n", err);
-       return;
-    }
-
-    uint8_t    buf[1];
-
-    for (;;) {
-       // Fill a one-byte (!) buffer.
-       buf[0] = in->read_byte();
-       d_stream.next_in = &buf[0];
-       d_stream.avail_in = 1;
-
-       err = inflate(&d_stream, Z_SYNC_FLUSH);
-       if (err == Z_STREAM_END) break;
-       if (err != Z_OK)
-           {
-               log_error("error: inflate_wrapper() inflate() returned %d\n", 
err);
-           }
-    }
-
-    err = inflateEnd(&d_stream);
-    if (err != Z_OK)
-       {
-           log_error("error: inflate_wrapper() inflateEnd() return %d\n", err);
-       }
-}
-#endif // TU_CONFIG_LINK_TO_ZLIB
-
-
-void   define_bits_jpeg3_loader(stream* in, int tag_type, movie_definition* m)
-    // loads a define_bits_jpeg3 tag. This is a jpeg file with an alpha
-    // channel using zlib compression.
-{
-    assert(tag_type == 35);
-
-    uint16_t   character_id = in->read_u16();
-
-    IF_VERBOSE_PARSE(log_msg("  define_bits_jpeg3_loader: charid = %d pos = 
0x%x\n", character_id, in->get_position()));
-
-    uint32_t   jpeg_size = in->read_u32();
-    uint32_t   alpha_position = in->get_position() + jpeg_size;
-
-    bitmap_info*       bi = NULL;
-
-    if (m->get_create_bitmaps() == DO_LOAD_BITMAPS)
-       {
-#if TU_CONFIG_LINK_TO_JPEGLIB == 0 || TU_CONFIG_LINK_TO_ZLIB == 0
-           log_error("gnash is not linked to jpeglib/zlib -- can't load 
jpeg/zipped image data!\n");
-           bi = render::create_bitmap_info_empty();
-#else
-           //
-           // Read the image data.
-           //
-               
-           // Read rgb data.
-           image::rgba*        im = 
image::read_swf_jpeg3(in->get_underlying_stream());
-
-           // Read alpha channel.
-           in->set_position(alpha_position);
-
-           int buffer_bytes = im->m_width * im->m_height;
-           uint8_t*    buffer = new uint8_t[buffer_bytes];
-
-           inflate_wrapper(in->get_underlying_stream(), buffer, buffer_bytes);
-
-           for (int i = 0; i < buffer_bytes; i++)
-               {
-                   im->m_data[4*i+3] = buffer[i];
-               }
-
-           delete [] buffer;
-
-           bi = render::create_bitmap_info_rgba(im);
-
-           delete im;
-#endif
-
-       }
-    else
-       {
-           bi = render::create_bitmap_info_empty();
-       }
-
-    // Create bitmap character.
-    bitmap_character*  ch = new bitmap_character(bi);
-
-    m->add_bitmap_character(character_id, ch);
-}
-
-
-void   define_bits_lossless_2_loader(stream* in, int tag_type, 
movie_definition* m)
-{
-    assert(tag_type == 20 || tag_type == 36);
-
-    uint16_t   character_id = in->read_u16();
-    uint8_t    bitmap_format = in->read_u8();  // 3 == 8 bit, 4 == 16 bit, 5 
== 32 bit
-    uint16_t   width = in->read_u16();
-    uint16_t   height = in->read_u16();
-
-    IF_VERBOSE_PARSE(log_msg("  defbitslossless2: tag_type = %d, id = %d, fmt 
= %d, w = %d, h = %d\n",
-                            tag_type,
-                            character_id,
-                            bitmap_format,
-                            width,
-                            height));
-
-    bitmap_info*       bi = NULL;
-    if (m->get_create_bitmaps() == DO_LOAD_BITMAPS)
-       {
-#if TU_CONFIG_LINK_TO_ZLIB == 0
-           log_error("gnash is not linked to zlib -- can't load zipped image 
data!\n");
-           return;
-#else
-           if (tag_type == 20)
-               {
-                   // RGB image data.
-                   image::rgb* image = image::create_rgb(width, height);
-
-                   if (bitmap_format == 3)
-                       {
-                           // 8-bit data, preceded by a palette.
-
-                           const int   bytes_per_pixel = 1;
-                           int color_table_size = in->read_u8();
-                           color_table_size += 1;      // !! SWF stores one 
less than the actual size
-
-                           int pitch = (width * bytes_per_pixel + 3) & ~3;
-
-                           int buffer_bytes = color_table_size * 3 + pitch * 
height;
-                           uint8_t*    buffer = new uint8_t[buffer_bytes];
-
-                           inflate_wrapper(in->get_underlying_stream(), 
buffer, buffer_bytes);
-                           assert(in->get_position() <= 
in->get_tag_end_position());
-
-                           uint8_t*    color_table = buffer;
-
-                           for (int j = 0; j < height; j++)
-                               {
-                                   uint8_t*    image_in_row = buffer + 
color_table_size * 3 + j * pitch;
-                                   uint8_t*    image_out_row = 
image::scanline(image, j);
-                                   for (int i = 0; i < width; i++)
-                                       {
-                                           uint8_t     pixel = image_in_row[i 
* bytes_per_pixel];
-                                           image_out_row[i * 3 + 0] = 
color_table[pixel * 3 + 0];
-                                           image_out_row[i * 3 + 1] = 
color_table[pixel * 3 + 1];
-                                           image_out_row[i * 3 + 2] = 
color_table[pixel * 3 + 2];
-                                       }
-                               }
-
-                           delete [] buffer;
-                       }
-                   else if (bitmap_format == 4)
-                       {
-                           // 16 bits / pixel
-                           const int   bytes_per_pixel = 2;
-                           int pitch = (width * bytes_per_pixel + 3) & ~3;
-
-                           int buffer_bytes = pitch * height;
-                           uint8_t*    buffer = new uint8_t[buffer_bytes];
-
-                           inflate_wrapper(in->get_underlying_stream(), 
buffer, buffer_bytes);
-                           assert(in->get_position() <= 
in->get_tag_end_position());
-                       
-                           for (int j = 0; j < height; j++)
-                               {
-                                   uint8_t*    image_in_row = buffer + j * 
pitch;
-                                   uint8_t*    image_out_row = 
image::scanline(image, j);
-                                   for (int i = 0; i < width; i++)
-                                       {
-                                           uint16_t    pixel = image_in_row[i 
* 2] | (image_in_row[i * 2 + 1] << 8);
-                                       
-                                           // @@ How is the data packed???  
I'm just guessing here that it's 565!
-                                           image_out_row[i * 3 + 0] = (pixel 
>> 8) & 0xF8;     // red
-                                           image_out_row[i * 3 + 1] = (pixel 
>> 3) & 0xFC;     // green
-                                           image_out_row[i * 3 + 2] = (pixel 
<< 3) & 0xF8;     // blue
-                                       }
-                               }
-                       
-                           delete [] buffer;
-                       }
-                   else if (bitmap_format == 5)
-                       {
-                           // 32 bits / pixel, input is ARGB format (???)
-                           const int   bytes_per_pixel = 4;
-                           int pitch = width * bytes_per_pixel;
-
-                           int buffer_bytes = pitch * height;
-                           uint8_t*    buffer = new uint8_t[buffer_bytes];
-
-                           inflate_wrapper(in->get_underlying_stream(), 
buffer, buffer_bytes);
-                           assert(in->get_position() <= 
in->get_tag_end_position());
-                       
-                           // Need to re-arrange ARGB into RGB.
-                           for (int j = 0; j < height; j++)
-                               {
-                                   uint8_t*    image_in_row = buffer + j * 
pitch;
-                                   uint8_t*    image_out_row = 
image::scanline(image, j);
-                                   for (int i = 0; i < width; i++)
-                                       {
-                                           uint8_t     a = image_in_row[i * 4 
+ 0];
-                                           uint8_t     r = image_in_row[i * 4 
+ 1];
-                                           uint8_t     g = image_in_row[i * 4 
+ 2];
-                                           uint8_t     b = image_in_row[i * 4 
+ 3];
-                                           image_out_row[i * 3 + 0] = r;
-                                           image_out_row[i * 3 + 1] = g;
-                                           image_out_row[i * 3 + 2] = b;
-                                           a = a;      // Inhibit warning.
-                                       }
-                               }
-
-                           delete [] buffer;
-                       }
-
-//                             bitmap_character*       ch = new 
bitmap_character(image);
-                   bi = render::create_bitmap_info_rgb(image);
-                   delete image;
-
-//                             // add image to movie, under character id.
-//                             m->add_bitmap_character(character_id, ch);
-               }
-           else
-               {
-                   // RGBA image data.
-                   assert(tag_type == 36);
-
-                   image::rgba*        image = image::create_rgba(width, 
height);
-
-                   if (bitmap_format == 3)
-                       {
-                           // 8-bit data, preceded by a palette.
-
-                           const int   bytes_per_pixel = 1;
-                           int color_table_size = in->read_u8();
-                           color_table_size += 1;      // !! SWF stores one 
less than the actual size
-
-                           int pitch = (width * bytes_per_pixel + 3) & ~3;
-
-                           int buffer_bytes = color_table_size * 4 + pitch * 
height;
-                           uint8_t*    buffer = new uint8_t[buffer_bytes];
-
-                           inflate_wrapper(in->get_underlying_stream(), 
buffer, buffer_bytes);
-                           assert(in->get_position() <= 
in->get_tag_end_position());
-
-                           uint8_t*    color_table = buffer;
-
-                           for (int j = 0; j < height; j++)
-                               {
-                                   uint8_t*    image_in_row = buffer + 
color_table_size * 4 + j * pitch;
-                                   uint8_t*    image_out_row = 
image::scanline(image, j);
-                                   for (int i = 0; i < width; i++)
-                                       {
-                                           uint8_t     pixel = image_in_row[i 
* bytes_per_pixel];
-                                           image_out_row[i * 4 + 0] = 
color_table[pixel * 4 + 0];
-                                           image_out_row[i * 4 + 1] = 
color_table[pixel * 4 + 1];
-                                           image_out_row[i * 4 + 2] = 
color_table[pixel * 4 + 2];
-                                           image_out_row[i * 4 + 3] = 
color_table[pixel * 4 + 3];
-                                       }
-                               }
-
-                           delete [] buffer;
-                       }
-                   else if (bitmap_format == 4)
-                       {
-                           // 16 bits / pixel
-                           const int   bytes_per_pixel = 2;
-                           int pitch = (width * bytes_per_pixel + 3) & ~3;
-
-                           int buffer_bytes = pitch * height;
-                           uint8_t*    buffer = new uint8_t[buffer_bytes];
-
-                           inflate_wrapper(in->get_underlying_stream(), 
buffer, buffer_bytes);
-                           assert(in->get_position() <= 
in->get_tag_end_position());
-                       
-                           for (int j = 0; j < height; j++)
-                               {
-                                   uint8_t*    image_in_row = buffer + j * 
pitch;
-                                   uint8_t*    image_out_row = 
image::scanline(image, j);
-                                   for (int i = 0; i < width; i++)
-                                       {
-                                           uint16_t    pixel = image_in_row[i 
* 2] | (image_in_row[i * 2 + 1] << 8);
-                                       
-                                           // @@ How is the data packed???  
I'm just guessing here that it's 565!
-                                           image_out_row[i * 4 + 0] = 255;     
                // alpha
-                                           image_out_row[i * 4 + 1] = (pixel 
>> 8) & 0xF8;     // red
-                                           image_out_row[i * 4 + 2] = (pixel 
>> 3) & 0xFC;     // green
-                                           image_out_row[i * 4 + 3] = (pixel 
<< 3) & 0xF8;     // blue
-                                       }
-                               }
-                       
-                           delete [] buffer;
-                       }
-                   else if (bitmap_format == 5)
-                       {
-                           // 32 bits / pixel, input is ARGB format
-
-                           inflate_wrapper(in->get_underlying_stream(), 
image->m_data, width * height * 4);
-                           assert(in->get_position() <= 
in->get_tag_end_position());
-                       
-                           // Need to re-arrange ARGB into RGBA.
-                           for (int j = 0; j < height; j++)
-                               {
-                                   uint8_t*    image_row = 
image::scanline(image, j);
-                                   for (int i = 0; i < width; i++)
-                                       {
-                                           uint8_t     a = image_row[i * 4 + 
0];
-                                           uint8_t     r = image_row[i * 4 + 
1];
-                                           uint8_t     g = image_row[i * 4 + 
2];
-                                           uint8_t     b = image_row[i * 4 + 
3];
-                                           image_row[i * 4 + 0] = r;
-                                           image_row[i * 4 + 1] = g;
-                                           image_row[i * 4 + 2] = b;
-                                           image_row[i * 4 + 3] = a;
-                                       }
-                               }
-                       }
-
-                   bi = render::create_bitmap_info_rgba(image);
-//                             bitmap_character*       ch = new 
bitmap_character(image);
-                   delete image;
-
-//                             // add image to movie, under character id.
-//                             m->add_bitmap_character(character_id, ch);
-               }
-#endif // TU_CONFIG_LINK_TO_ZLIB
-       }
-    else
-       {
-           bi = render::create_bitmap_info_empty();
-       }
-    assert(bi->get_ref_count() == 0);
-
-    bitmap_character*  ch = new bitmap_character(bi);
-
-    // add image to movie, under character id.
-    m->add_bitmap_character(character_id, ch);
-}
-
-// This is like null_loader except it prints a message to nag us to fix it.
-void
-fixme_loader(stream* in, int tag_type, movie_definition* m)
-{
-    IF_VERBOSE_PARSE(log_msg("  FIXME: tagtype = %d\n", tag_type));
-}
-
-void define_shape_loader(stream* in, int tag_type, movie_definition* m)
-{
-    assert(tag_type == SWF::DEFINESHAPE
-          || tag_type == SWF::DEFINESHAPE2
-          || tag_type == SWF::DEFINESHAPE3);
-
-    uint16_t   character_id = in->read_u16();
-    IF_VERBOSE_PARSE(log_msg("  shape_loader: id = %d\n", character_id));
-
-    shape_character_def*       ch = new shape_character_def;
-    ch->read(in, tag_type, true, m);
-
-    IF_VERBOSE_PARSE(log_msg("  bound rect:"); ch->get_bound().print());
-
-    m->add_character(character_id, ch);
-}
-
-void define_shape_morph_loader(stream* in, int tag_type, movie_definition* m)
-{
-    assert(tag_type == 46);
-    uint16_t character_id = in->read_u16();
-    IF_VERBOSE_PARSE(log_msg("  shape_morph_loader: id = %d\n", character_id));
-    morph2_character_def* morph = new morph2_character_def;
-    morph->read(in, tag_type, true, m);
-    m->add_character(character_id, morph);
-}
-
-//
-// font loaders
-//
-
-
-void   define_font_loader(stream* in, int tag_type, movie_definition* m)
-    // Load a DefineFont or DefineFont2 tag.
-{
-    assert(tag_type == 10 || tag_type == 48);
-
-    uint16_t   font_id = in->read_u16();
-               
-    font*      f = new font;
-    f->read(in, tag_type, m);
-
-    m->add_font(font_id, f);
-
-    // Automatically keeping fonts in fontlib is
-    // problematic.  The app should be responsible for
-    // optionally adding fonts to fontlib.
-    // //fontlib::add_font(f);
-}
-
-
-void   define_font_info_loader(stream* in, int tag_type, movie_definition* m)
-    // Load a DefineFontInfo tag.  This adds information to an
-    // existing font.
-{
-    assert(tag_type == 13);
-
-    uint16_t   font_id = in->read_u16();
-               
-    font*      f = m->get_font(font_id);
-    if (f)
-       {
-           f->read_font_info(in);
-       }
-    else
-       {
-           log_error("define_font_info_loader: can't find font w/ id %d\n", 
font_id);
-       }
-}
-
-void swf_event::read(stream* in, uint32_t flags)
-{
-    assert(flags != 0);
-
-    // Scream if more than one bit is set, since we're not set up to handle
-    // that, and it doesn't seem possible to express in ActionScript source,
-    // so it's important to know if this ever occurs in the wild.
-    if (flags & (flags - 1))
-       {
-           log_error("error: swf_event::read() -- more than one event type 
encoded!  "
-                     "unexpected! flags = 0x%x\n", flags);
-       }
-
-    // 14 bits reserved, 18 bits used
-
-    static const event_id      s_code_bits[18] =
-       {
-           event_id::LOAD,
-           event_id::ENTER_FRAME,
-           event_id::UNLOAD,
-           event_id::MOUSE_MOVE,
-           event_id::MOUSE_DOWN,
-           event_id::MOUSE_UP,
-           event_id::KEY_DOWN,
-           event_id::KEY_UP,
-           event_id::DATA,
-           event_id::INITIALIZE,
-           event_id::PRESS,
-           event_id::RELEASE,
-           event_id::RELEASE_OUTSIDE,
-           event_id::ROLL_OVER,
-           event_id::ROLL_OUT,
-           event_id::DRAG_OVER,
-           event_id::DRAG_OUT,
-       };
-
-    // Let's see if the event flag we received is for an event that we know of
-    if ((pow(2,int(sizeof(s_code_bits)/sizeof(s_code_bits[0])))-1) < flags)
-       {
-           log_error("error: swf_event::read() -- unknown / unhandled event 
type received, flags = 0x%x\n", flags);
-       }
-
-    for (int i = 0, mask = 1; i < 
int(sizeof(s_code_bits)/sizeof(s_code_bits[0])); i++, mask <<= 1)
-       {
-           if (flags & mask)
-               {
-                   m_event = s_code_bits[i];
-                   break;
-               }
-       }
-
-    // what to do w/ key_press???  Is the data in the reserved parts of the 
flags???
-    if (flags & (1 << 17))
-       {
-           log_error("swf_event::read -- KEY_PRESS found, not handled yet, 
flags = 0x%x\n", flags);
-       }
-
-    uint32_t   event_length = in->read_u32();
-    UNUSED(event_length);
-
-    // Read the actions.
-    IF_VERBOSE_ACTION(log_msg("---- actions for event %s\n", 
m_event.get_function_name().c_str()));
-    m_action_buffer.read(in);
-
-    if (m_action_buffer.get_length() != (int) event_length)
-       {
-           log_error("error -- swf_event::read(), event_length = %d, but read 
%d\n",
-                     event_length,
-                     m_action_buffer.get_length());
-           // @@ discard this event handler??
-       }
-
-    // Create a function to execute the actions.
-    std::vector<with_stack_entry>      empty_with_stack;
-    function_as_object*        func = new function_as_object(&m_action_buffer, 
NULL, 0, empty_with_stack);
-    func->set_length(m_action_buffer.get_length());
-
-    m_method.set_function_as_object(func);
-}
-
-
-
-/// SWF Tag PlaceObject2 (9) 
-struct place_object_2 : public execute_tag
-{
-    int        m_tag_type;
-    char*      m_name;
-    float      m_ratio;
-    cxform     m_color_transform;
-    matrix     m_matrix;
-    bool       m_has_matrix;
-    bool       m_has_cxform;
-    uint16_t   m_depth;
-    uint16_t   m_character_id;
-    uint16_t   m_clip_depth;
-    enum place_type {
-       PLACE,
-       MOVE,
-       REPLACE
-    } m_place_type;
-    std::vector<swf_event*>    m_event_handlers;
-
-
-    place_object_2()
-       :
-       m_tag_type(0),
-       m_name(NULL),
-       m_ratio(0),
-       m_has_matrix(false),
-       m_has_cxform(false),
-       m_depth(0),
-       m_character_id(0),
-       m_clip_depth(0),
-       m_place_type(PLACE)
-       {
-       }
-
-    ~place_object_2()
-       {
-           delete [] m_name;
-           m_name = NULL;
-
-           for (int i = 0, n = m_event_handlers.size(); i < n; i++)
-               {
-                   delete m_event_handlers[i];
-               }
-           m_event_handlers.resize(0);
-       }
-
-    void       read(stream* in, int tag_type, int movie_version)
-       {
-           assert(tag_type == 4 || tag_type == 26);
-
-           m_tag_type = tag_type;
-
-           if (tag_type == 4)
-               {
-                   // Original place_object tag; very simple.
-                   m_character_id = in->read_u16();
-                   m_depth = in->read_u16();
-                   m_matrix.read(in);
-
-                   IF_VERBOSE_PARSE(
-                       log_msg("  char_id = %d\n"
-                               "  depth = %d\n"
-                               "  mat = \n",
-                               m_character_id,
-                               m_depth);
-                       m_matrix.print());
-
-                   if (in->get_position() < in->get_tag_end_position())
-                       {
-                           m_color_transform.read_rgb(in);
-                           IF_VERBOSE_PARSE(log_msg("  cxform:\n"); 
m_color_transform.print());
-                       }
-               }
-           else if (tag_type == 26)
-               {
-                   in->align();
-
-                   bool        has_actions = in->read_uint(1) ? true : false;
-                   bool        has_clip_bracket = in->read_uint(1) ? true : 
false;
-                   bool        has_name = in->read_uint(1) ? true : false;
-                   bool        has_ratio = in->read_uint(1) ? true : false;
-                   bool        has_cxform = in->read_uint(1) ? true : false;
-                   bool        has_matrix = in->read_uint(1) ? true : false;
-                   bool        has_char = in->read_uint(1) ? true : false;
-                   bool        flag_move = in->read_uint(1) ? true : false;
-
-                   m_depth = in->read_u16();
-                   IF_VERBOSE_PARSE(log_msg("  depth = %d\n", m_depth));
-
-                   if (has_char) {
-                       m_character_id = in->read_u16();
-                       IF_VERBOSE_PARSE(log_msg("  char id = %d\n", 
m_character_id));
-                   }
-
-                   if (has_matrix) {
-                       m_has_matrix = true;
-                       m_matrix.read(in);
-                       IF_VERBOSE_PARSE(log_msg("  mat:\n"); m_matrix.print());
-                   }
-                   if (has_cxform) {
-                       m_has_cxform = true;
-                       m_color_transform.read_rgba(in);
-                       IF_VERBOSE_PARSE(log_msg("  cxform:\n"); 
m_color_transform.print());
-                   }
-                               
-                   if (has_ratio) {
-                       m_ratio = (float)in->read_u16() / (float)65535;
-                       IF_VERBOSE_PARSE(log_msg("  ratio: %f\n", m_ratio));
-                   }
-                               
-                   if (has_name) {
-                       m_name = in->read_string();
-                       IF_VERBOSE_PARSE(log_msg("  name = %s\n", m_name ? 
m_name : "<null>"));
-                   }
-                   if (has_clip_bracket) {
-                       m_clip_depth = in->read_u16(); 
-                       IF_VERBOSE_PARSE(log_msg("  clip_depth = %d\n", 
m_clip_depth));
-                   }
-                   if (has_actions)
-                       {
-                           uint16_t    reserved = in->read_u16();
-                           UNUSED(reserved);
-
-                           // The logical 'or' of all the following handlers.
-                           // I don't think we care about this...
-                           uint32_t    all_flags = 0;
-                           if (movie_version >= 6)
-                               {
-                                   all_flags = in->read_u32();
-                               }
-                           else
-                               {
-                                   all_flags = in->read_u16();
-                               }
-                           UNUSED(all_flags);
-
-                           IF_VERBOSE_PARSE(log_msg("  actions: flags = 
0x%X\n", all_flags));
-
-                           // Read swf_events.
-                           for (;;)
-                               {
-                                   // Read event.
-                                   in->align();
-
-                                   uint32_t    this_flags = 0;
-                                   if (movie_version >= 6)
-                                       {
-                                           this_flags = in->read_u32();
-                                       }
-                                   else
-                                       {
-                                           this_flags = in->read_u16();
-                                       }
-
-                                   if (this_flags == 0)
-                                       {
-                                           // Done with events.
-                                           break;
-                                       }
-
-                                   swf_event*  ev = new swf_event;
-                                   ev->read(in, this_flags);
-
-                                   m_event_handlers.push_back(ev);
-                               }
-                       }
-
-
-                   if (has_char == true && flag_move == true)
-                       {
-                           // Remove whatever's at m_depth, and put 
m_character there.
-                           m_place_type = REPLACE;
-                       }
-                   else if (has_char == false && flag_move == true)
-                       {
-                           // Moves the object at m_depth to the new location.
-                           m_place_type = MOVE;
-                       }
-                   else if (has_char == true && flag_move == false)
-                       {
-                           // Put m_character at m_depth.
-                           m_place_type = PLACE;
-                       }
-                                
-                   //log_msg("place object at depth %i\n", m_depth);
-               }
-       }
-
-               
-    void       execute(movie* m)
-       // Place/move/whatever our object in the given movie.
-       {
-           switch (m_place_type) {
-             case PLACE:
-                 m->add_display_object(
-                     m_character_id,
-                     m_name,
-                     m_event_handlers,
-                     m_depth,
-                     m_tag_type != 4,  // original place_object doesn't do 
replacement
-                     m_color_transform,
-                     m_matrix,
-                     m_ratio,
-                     m_clip_depth);
-                 break;
-                 
-             case MOVE:
-                 m->move_display_object(
-                     m_depth,
-                     m_has_cxform,
-                     m_color_transform,
-                     m_has_matrix,
-                     m_matrix,
-                     m_ratio,
-                     m_clip_depth);
-                 break;
-                 
-             case REPLACE:
-                 m->replace_display_object(
-                     m_character_id,
-                     m_name,
-                     m_depth,
-                     m_has_cxform,
-                     m_color_transform,
-                     m_has_matrix,
-                     m_matrix,
-                     m_ratio,
-                     m_clip_depth);
-                 break;
-           }
-       }
-    
-    void       execute_state(movie* m)
-       {
-           execute(m);
-       }
-    
-    void       execute_state_reverse(movie* m, int frame)
-       {
-           switch (m_place_type) {
-             case PLACE:
-                 // reverse of add is remove
-                 m->remove_display_object(m_depth, m_tag_type == 4 ? 
m_character_id : -1);
-                 break;
-                 
-             case MOVE:
-                 // reverse of move is move
-                 m->move_display_object(
-                     m_depth,
-                     m_has_cxform,
-                     m_color_transform,
-                     m_has_matrix,
-                     m_matrix,
-                     m_ratio,
-                     m_clip_depth);
-                 break;
-                 
-             case REPLACE:
-             {
-                 // reverse of replace is to re-add the previous object.
-                 execute_tag*  last_add = 
m->find_previous_replace_or_add_tag(frame, m_depth, -1);
-                 if (last_add) {
-                     last_add->execute_state(m);
-                 } else {
-                     log_error("reverse REPLACE can't find previous replace or 
add tag(%d, %d)\n",
-                               frame, m_depth);
-                     
-                 }
-                 break;
-             }
-           }
-       }
-    
-    virtual uint32     get_depth_id_of_replace_or_add_tag() const
-       // "depth_id" is the 16-bit depth & id packed into one 32-bit int.
-       {
-           if (m_place_type == PLACE || m_place_type == REPLACE)
-               {
-                   int id = -1;
-                   if (m_tag_type == 4)
-                       {
-                           // Old-style PlaceObject; the corresponding Remove
-                           // is specific to the character_id.
-                           id = m_character_id;
-                       }
-                   return ((m_depth & 0x0FFFF) << 16) | (id & 0x0FFFF);
-               }
-           else
-               {
-                   return (uint32) -1;
-               }
-       }
-};
-
-
-       
-void   place_object_2_loader(stream* in, int tag_type, movie_definition* m)
-{
-    assert(tag_type == 4 || tag_type == 26);
-
-    IF_VERBOSE_PARSE(log_msg("  place_object_2\n"));
-
-    place_object_2*    ch = new place_object_2;
-    ch->read(in, tag_type, m->get_version());
-
-    m->add_execute_tag(ch);
-}
-
-
-
-
-
-
-
-void   sprite_loader(stream* in, int tag_type, movie_definition* m)
-    // Create and initialize a sprite, and add it to the movie.
-{
-    assert(tag_type == SWF::DEFINESPRITE); // 39 - DefineSprite
-                
-    int        character_id = in->read_u16();
-
-    IF_VERBOSE_PARSE(log_msg("  sprite\n  char id = %d\n", character_id));
-
-    sprite_definition* ch = new sprite_definition(m);  // @@ combine 
sprite_definition with movie_def_impl
-    ch->read(in);
-
-    m->add_character(character_id, ch);
-}
-
-
-
-//
-// end_tag
-//
-
-// end_tag doesn't actually need to exist.
-
-void   end_loader(stream* in, int tag_type, movie_definition* m)
-{
-    assert(tag_type == 0);
-    assert(in->get_position() == in->get_tag_end_position());
-}
-
-
-/// SWF Tag RemoveObject2 (28) 
-struct remove_object_2 : public execute_tag
-{
-    int        m_depth, m_id;
-
-    remove_object_2() : m_depth(-1), m_id(-1) {}
-
-    void       read(stream* in, int tag_type)
-       {
-           assert(tag_type == 5 || tag_type == 28);
-
-           if (tag_type == 5)
-               {
-                   // Older SWF's allow multiple objects at the same depth;
-                   // this m_id disambiguates.  Later SWF's just use one
-                   // object per depth.
-                   m_id = in->read_u16();
-               }
-           m_depth = in->read_u16();
-       }
-
-    virtual void       execute(movie* m)
-       {
-           m->remove_display_object(m_depth, m_id);
-       }
-
-    virtual void       execute_state(movie* m)
-       {
-           execute(m);
-       }
-
-    virtual void       execute_state_reverse(movie* m, int frame)
-       {
-           // reverse of remove is to re-add the previous object.
-           execute_tag*        last_add = 
m->find_previous_replace_or_add_tag(frame, m_depth, m_id);
-           if (last_add)
-               {
-                   last_add->execute_state(m);
-               }
-           else
-               {
-                   log_error("reverse REMOVE can't find previous replace or 
add tag(%d, %d)\n",
-                             frame, m_depth);
-                                       
-               }
-       }
-
-    virtual bool       is_remove_tag() const { return true; }
-};
-
-
-void   remove_object_2_loader(stream* in, int tag_type, movie_definition* m)
-{
-    assert(tag_type == 5 || tag_type == 28);
-
-    remove_object_2*   t = new remove_object_2;
-    t->read(in, tag_type);
-
-    IF_VERBOSE_PARSE(log_msg("  remove_object_2(%d)\n", t->m_depth));
-
-    m->add_execute_tag(t);
-}
-
-
-void   button_sound_loader(stream* in, int tag_type, movie_definition* m)
-{
-    assert(tag_type == 17);
-
-    int        button_character_id = in->read_u16();
-    button_character_definition* ch = (button_character_definition*) 
m->get_character_def(button_character_id);
-    assert(ch != NULL);
-
-    ch->read(in, tag_type, m);
-}
-
-
-void   button_character_loader(stream* in, int tag_type, movie_definition* m)
-{
-    assert(tag_type == 7 || tag_type == 34);
-
-    int        character_id = in->read_u16();
-
-    IF_VERBOSE_PARSE(log_msg("  button character loader: char_id = %d\n", 
character_id));
-
-    button_character_definition*       ch = new button_character_definition;
-    ch->read(in, tag_type, m);
-
-    m->add_character(character_id, ch);
-}
-
-
-//
-// export
-//
-
-
-void   export_loader(stream* in, int tag_type, movie_definition* m)
-    // Load an export tag (for exposing internal resources of m)
-{
-    assert(tag_type == 56);
-
-    int        count = in->read_u16();
-
-    IF_VERBOSE_PARSE(log_msg("  export: count = %d\n", count));
-
-    // Read the exports.
-    for (int i = 0; i < count; i++)
-       {
-           uint16_t    id = in->read_u16();
-           char*       symbol_name = in->read_string();
-           IF_VERBOSE_PARSE(log_msg("  export: id = %d, name = %s\n", id, 
symbol_name));
-
-           if (font* f = m->get_font(id))
-               {
-                   // Expose this font for export.
-                   m->export_resource(tu_string(symbol_name), f);
-               }
-           else if (character_def* ch = m->get_character_def(id))
-               {
-                   // Expose this movie/button/whatever for export.
-                   m->export_resource(tu_string(symbol_name), ch);
-               }
-           else if (sound_sample* ch = m->get_sound_sample(id))
-               {
-                   m->export_resource(tu_string(symbol_name), ch);
-               }
-           else
-               {
-                   log_error("export error: don't know how to export resource 
'%s'\n",
-                             symbol_name);
-               }
-
-           delete [] symbol_name;
-       }
-}
-
-
-//
-// import
-//
-
-
-void   import_loader(stream* in, int tag_type, movie_definition* m)
-    // Load an import tag (for pulling in external resources)
-{
-    assert(tag_type == 57);
-
-    char*      source_url = in->read_string();
-    int        count = in->read_u16();
-
-    IF_VERBOSE_PARSE(log_msg("  import: source_url = %s, count = %d\n", 
source_url, count));
-
-    // Try to load the source movie into the movie library.
-    movie_definition*  source_movie = NULL;
-
-    if (s_no_recurse_while_loading == false)
-       {
-           source_movie = create_library_movie(source_url);
-           if (source_movie == NULL)
-               {
-                   // Give up on imports.
-                   log_error("can't import movie from url %s\n", source_url);
-                   return;
-               }
-       }
-
-    // Get the imports.
-    for (int i = 0; i < count; i++)
-       {
-           uint16_t    id = in->read_u16();
-           char*       symbol_name = in->read_string();
-           IF_VERBOSE_PARSE(log_msg("  import: id = %d, name = %s\n", id, 
symbol_name));
-
-           if (s_no_recurse_while_loading)
-               {
-                   m->add_import(source_url, id, symbol_name);
-               }
-           else
-               {
-                   // @@ TODO get rid of this, always use
-                   // s_no_recurse_while_loading, change
-                   // create_movie().
-
-                   smart_ptr<resource> res = 
source_movie->get_exported_resource(symbol_name);
-                   if (res == NULL)
-                       {
-                           log_error("import error: resource '%s' is not 
exported from movie '%s'\n",
-                                     symbol_name, source_url);
-                       }
-                   else if (font* f = res->cast_to_font())
-                       {
-                           // Add this shared font to the currently-loading 
movie.
-                           m->add_font(id, f);
-                       }
-                   else if (character_def* ch = res->cast_to_character_def())
-                       {
-                           // Add this character to the loading movie.
-                           m->add_character(id, ch);
-                       }
-                   else
-                       {
-                           log_error("import error: resource '%s' from movie 
'%s' has unknown type\n",
-                                     symbol_name, source_url);
-                       }
-               }
-
-           delete [] symbol_name;
-       }
-
-    delete [] source_url;
-}
-
 } // namespace gnash
 
 // Local Variables:
Index: gnash/server/impl.h
diff -u gnash/server/impl.h:1.24 gnash/server/impl.h:1.25
--- gnash/server/impl.h:1.24    Mon May  8 21:12:24 2006
+++ gnash/server/impl.h Tue May  9 15:34:16 2006
@@ -53,6 +53,7 @@
 #include "movie_interface.h"
 #include "character.h"
 #include "resource.h" // for sound_sample inheritance
+#include "swf/TagLoadersTable.h"
 
 #include <cstdarg>
 #include <cassert>
@@ -66,7 +67,6 @@
 struct character;
 struct character_def;
 struct display_info;
-struct execute_tag;
 struct font;
 struct movie_root;
 struct stream;
@@ -122,22 +122,6 @@
 };
 
 
-/// Execute tags include things that control the operation of the movie. 
-//
-/// Essentially, these are the events associated with a frame.
-///
-struct execute_tag
-{
-    virtual ~execute_tag() {}
-    virtual void       execute(movie* m) {}
-    virtual void       execute_state(movie* m) {}
-    virtual void       execute_state_reverse(movie* m, int frame) { 
execute_state(m); }
-    virtual bool       is_remove_tag() const { return false; }
-    virtual bool       is_action_tag() const { return false; }
-    virtual uint32     get_depth_id_of_replace_or_add_tag() const { return 
static_cast<uint32>(-1); }
-};
-
-
 //
 // Loader callbacks.
 //
@@ -146,46 +130,20 @@
 // standard tags are handled within gnash.  Host apps might want
 // to call this in order to handle special tag types.
 
+#if 0
 /// Signature of an SWF tag loader
 typedef void (*loader_function)(stream* input, int tag_type, movie_definition* 
m);
 
-/// Register a tag loader for the given tag
-void   register_tag_loader(int tag_type, loader_function lf);
-
 /// These are the registered tag loaders
 extern hash<int, loader_function> s_tag_loaders;
-       
-// Tag loader functions.
-void   null_loader(stream* in, int tag_type, movie_definition* m);
-void   set_background_color_loader(stream* in, int tag_type, movie_definition* 
m);
-void   jpeg_tables_loader(stream* in, int tag_type, movie_definition* m);
-void   define_bits_jpeg_loader(stream* in, int tag_type, movie_definition* m);
-void   define_bits_jpeg2_loader(stream* in, int tag_type, movie_definition* m);
-void   define_bits_jpeg3_loader(stream* in, int tag_type, movie_definition* m);
-void   fixme_loader(stream* in, int tag_type, movie_definition* m);
-void   define_shape_loader(stream* in, int tag_type, movie_definition* m);
-void   define_shape_morph_loader(stream* in, int tag_type, movie_definition* 
m);
-void   define_font_loader(stream* in, int tag_type, movie_definition* m);
-void   define_font_info_loader(stream* in, int tag_type, movie_definition* m);
-void   define_text_loader(stream* in, int tag_type, movie_definition* m);
-void   define_edit_text_loader(stream* in, int tag_type, movie_definition* m);
-void   place_object_2_loader(stream* in, int tag_type, movie_definition* m);
-void   define_bits_lossless_2_loader(stream* in, int tag_type, 
movie_definition* m);
-void   sprite_loader(stream* in, int tag_type, movie_definition* m);
-void   end_loader(stream* in, int tag_type, movie_definition* m);
-void   remove_object_2_loader(stream* in, int tag_type, movie_definition* m);
-void   do_action_loader(stream* in, int tag_type, movie_definition* m);
-void   button_character_loader(stream* in, int tag_type, movie_definition* m);
-void   frame_label_loader(stream* in, int tag_type, movie_definition* m);
-void   export_loader(stream* in, int tag_type, movie_definition* m);
-void   import_loader(stream* in, int tag_type, movie_definition* m);
-void   define_sound_loader(stream* in, int tag_type, movie_definition* m);
-void   start_sound_loader(stream* in, int tag_type, movie_definition* m);
-void   button_sound_loader(stream* in, int tag_type, movie_definition* m);
-void   do_init_action_loader(stream* in, int tag_type, movie_definition* m);
-// sound_stream_loader();      // head, head2, block
-
+#else
+extern SWF::TagLoadersTable s_tag_loaders;
+#endif
 
+/// Register a tag loader for the given tag
+void   register_tag_loader(SWF::tag_type t,
+               SWF::TagLoadersTable::loader_function lf);
+       
 //
 // swf_event
 //
Index: gnash/server/movie_def_impl.cpp
diff -u gnash/server/movie_def_impl.cpp:1.4 gnash/server/movie_def_impl.cpp:1.5
--- gnash/server/movie_def_impl.cpp:1.4 Tue May  9 10:41:44 2006
+++ gnash/server/movie_def_impl.cpp     Tue May  9 15:34:16 2006
@@ -55,6 +55,7 @@
 #include "render.h"
 #include "bitmap_character_def.h"
 #include "smart_ptr.h"
+#include "swf/TagLoadersTable.h"
 
 using namespace std;
 
@@ -360,22 +361,22 @@
 
     while ((uint32_t) str.get_position() < file_end_pos)
         {
-            int        tag_type = str.open_tag();
+            SWF::tag_type tag_type = str.open_tag();
 
             if (s_progress_function != NULL)
                 {
                     s_progress_function((uint32_t) str.get_position(), 
file_end_pos);
                 }
 
-            loader_function    lf = NULL;
+            SWF::TagLoadersTable::loader_function lf = NULL;
             //IF_VERBOSE_PARSE(log_msg("tag_type = %d\n", tag_type));
-            if (tag_type == 1)
+            if (tag_type == SWF::SHOWFRAME)
                 {
                     // show frame tag -- advance to the next frame.
                     IF_VERBOSE_PARSE(log_msg("  show_frame\n"));
                     m_loading_frame++;
                 }
-            else if (s_tag_loaders.get(tag_type, &lf))
+            else if (_tag_loaders.get(tag_type, &lf))
                 {
                     // call the tag loader.  The tag loader should add
                     // characters or tags to the movie data structure.
Index: gnash/server/movie_def_impl.h
diff -u gnash/server/movie_def_impl.h:1.3 gnash/server/movie_def_impl.h:1.4
--- gnash/server/movie_def_impl.h:1.3   Tue May  9 10:41:44 2006
+++ gnash/server/movie_def_impl.h       Tue May  9 15:34:16 2006
@@ -147,9 +147,12 @@
 ///
 class movie_def_impl : public movie_definition
 {
-       /// Characters Dictionary, could be a separate class
-       //hash<int, smart_ptr<character_def> >          m_characters;
+       /// Characters Dictionary
        CharacterDictionary     _dictionary;
+       //hash<int, smart_ptr<character_def> >          m_characters;
+
+       /// Tags loader table
+       SWF::TagLoadersTable& _tag_loaders;
 
        hash<int, smart_ptr<font> >                     m_fonts;
        hash<int, smart_ptr<bitmap_character_def> >     m_bitmap_characters;
@@ -193,6 +196,7 @@
        movie_def_impl(create_bitmaps_flag cbf,
                        create_font_shapes_flag cfs)
                :
+               _tag_loaders(s_tag_loaders), // FIXME: use a class-static 
TagLoadersTable for movie_def_impl
                m_create_bitmaps(cbf),
                m_create_font_shapes(cfs),
                m_frame_rate(30.0f),
Index: gnash/server/sound.cpp
diff -u gnash/server/sound.cpp:1.6 gnash/server/sound.cpp:1.7
--- gnash/server/sound.cpp:1.6  Mon May  8 21:12:24 2006
+++ gnash/server/sound.cpp      Tue May  9 15:34:16 2006
@@ -10,6 +10,7 @@
 #include "stream.h"
 #include "impl.h"
 #include "log.h"
+#include "execute_tag.h" // for start_sound_tag inheritance
 #include "movie_definition.h"
 
 namespace gnash {
@@ -49,79 +50,6 @@
                bool stereo);
 
 
-       void    define_sound_loader(stream* in, int tag_type, movie_definition* 
m)
-       // Load a DefineSound tag.
-       {
-               assert(tag_type == 14);
-
-               uint16_t        character_id = in->read_u16();
-
-               sound_handler::format_type      format = 
(sound_handler::format_type) in->read_uint(4);
-               int     sample_rate = in->read_uint(2); // multiples of 5512.5
-               bool    sample_16bit = in->read_uint(1) ? true : false;
-               bool    stereo = in->read_uint(1) ? true : false;
-               int     sample_count = in->read_u32();
-
-               static int      s_sample_rate_table[] = { 5512, 11025, 22050, 
44100 };
-
-               IF_VERBOSE_PARSE(log_msg("define sound: ch=%d, format=%d, 
rate=%d, 16=%d, stereo=%d, ct=%d\n",
-                                        character_id, int(format), 
sample_rate, int(sample_16bit), int(stereo), sample_count));
-
-               // If we have a sound_handler, ask it to init this sound.
-               if (s_sound_handler)
-               {
-                       int     data_bytes = 0;
-                       unsigned char*  data = NULL;
-
-                       if (format == sound_handler::FORMAT_ADPCM)
-                       {
-                               // Uncompress the ADPCM before handing data to 
host.
-                               data_bytes = sample_count * (stereo ? 4 : 2);
-                               data = new unsigned char[data_bytes];
-                               adpcm_expand(data, in, sample_count, stereo);
-                               format = sound_handler::FORMAT_NATIVE16;
-                       }
-                       else
-                       {
-                               // @@ This is pretty awful -- lots of copying, 
slow reading.
-                               data_bytes = in->get_tag_end_position() - 
in->get_position();
-                               data = new unsigned char[data_bytes];
-                               for (int i = 0; i < data_bytes; i++)
-                               {
-                                       data[i] = in->read_u8();
-                               }
-
-                               // Swap bytes on behalf of the host, to make it 
easier for the handler.
-                               // @@ I'm assuming this is a good idea?  Most 
sound handlers will prefer native endianness?
-                               if (format == sound_handler::FORMAT_UNCOMPRESSED
-                                   && sample_16bit)
-                               {
-                                       #ifndef _TU_LITTLE_ENDIAN_
-                                       // Swap sample bytes to get big-endian 
format.
-                                       for (int i = 0; i < data_bytes - 1; i 
+= 2)
-                                       {
-                                               swap(&data[i], &data[i+1]);
-                                       }
-                                       #endif // not _TU_LITTLE_ENDIAN_
-
-                                       format = sound_handler::FORMAT_NATIVE16;
-                               }
-                       }
-                       
-                       int     handler_id = s_sound_handler->create_sound(
-                               data,
-                               data_bytes,
-                               sample_count,
-                               format,
-                               s_sample_rate_table[sample_rate],
-                               stereo);
-                       sound_sample*   sam = new sound_sample_impl(handler_id);
-                       m->add_sound_sample(character_id, sam);
-
-                       delete [] data;
-               }
-       }
-
 
        /// SWF Tag StartSound (15) 
        struct start_sound_tag : public execute_tag
@@ -185,31 +113,6 @@
        };
 
 
-       void    start_sound_loader(stream* in, int tag_type, movie_definition* 
m)
-       // Load a StartSound tag.
-       {
-               assert(tag_type == 15);
-
-               uint16_t        sound_id = in->read_u16();
-
-               sound_sample_impl*      sam = (sound_sample_impl*) 
m->get_sound_sample(sound_id);
-               if (sam)
-               {
-                       start_sound_tag*        sst = new start_sound_tag();
-                       sst->read(in, tag_type, m, sam);
-
-                       IF_VERBOSE_PARSE(log_msg("start_sound tag: id=%d, stop 
= %d, loop ct = %d\n",
-                                                sound_id, 
int(sst->m_stop_playback), sst->m_loop_count));
-               }
-               else
-               {
-                       if (s_sound_handler)
-                       {
-                               log_error("start_sound_loader: sound_id %d is 
not defined\n", sound_id);
-                       }
-               }
-               
-       }
 
 
        // void define_button_sound(...) ???
@@ -429,8 +332,115 @@
                }
        }
 
+namespace SWF {
+namespace tag_loaders {
+
+// Load a DefineSound tag.
+void
+define_sound_loader(stream* in, tag_type tag, movie_definition* m)
+{
+       assert(tag == 14);
+
+       uint16_t        character_id = in->read_u16();
+
+       sound_handler::format_type      format = (sound_handler::format_type) 
in->read_uint(4);
+       int     sample_rate = in->read_uint(2); // multiples of 5512.5
+       bool    sample_16bit = in->read_uint(1) ? true : false;
+       bool    stereo = in->read_uint(1) ? true : false;
+       int     sample_count = in->read_u32();
+
+       static int      s_sample_rate_table[] = { 5512, 11025, 22050, 44100 };
+
+       IF_VERBOSE_PARSE(log_msg("define sound: ch=%d, format=%d, rate=%d, 
16=%d, stereo=%d, ct=%d\n",
+                                character_id, int(format), sample_rate, 
int(sample_16bit), int(stereo), sample_count));
+
+       // If we have a sound_handler, ask it to init this sound.
+       if (s_sound_handler)
+       {
+               int     data_bytes = 0;
+               unsigned char*  data = NULL;
+
+               if (format == sound_handler::FORMAT_ADPCM)
+               {
+                       // Uncompress the ADPCM before handing data to host.
+                       data_bytes = sample_count * (stereo ? 4 : 2);
+                       data = new unsigned char[data_bytes];
+                       adpcm_expand(data, in, sample_count, stereo);
+                       format = sound_handler::FORMAT_NATIVE16;
+               }
+               else
+               {
+                       // @@ This is pretty awful -- lots of copying, slow 
reading.
+                       data_bytes = in->get_tag_end_position() - 
in->get_position();
+                       data = new unsigned char[data_bytes];
+                       for (int i = 0; i < data_bytes; i++)
+                       {
+                               data[i] = in->read_u8();
+                       }
+
+                       // Swap bytes on behalf of the host, to make it easier 
for the handler.
+                       // @@ I'm assuming this is a good idea?  Most sound 
handlers will prefer native endianness?
+                       if (format == sound_handler::FORMAT_UNCOMPRESSED
+                           && sample_16bit)
+                       {
+                               #ifndef _TU_LITTLE_ENDIAN_
+                               // Swap sample bytes to get big-endian format.
+                               for (int i = 0; i < data_bytes - 1; i += 2)
+                               {
+                                       swap(&data[i], &data[i+1]);
+                               }
+                               #endif // not _TU_LITTLE_ENDIAN_
+
+                               format = sound_handler::FORMAT_NATIVE16;
+                       }
+               }
+               
+               int     handler_id = s_sound_handler->create_sound(
+                       data,
+                       data_bytes,
+                       sample_count,
+                       format,
+                       s_sample_rate_table[sample_rate],
+                       stereo);
+               sound_sample*   sam = new sound_sample_impl(handler_id);
+               m->add_sound_sample(character_id, sam);
+
+               delete [] data;
+       }
+}
+
+
+void
+start_sound_loader(stream* in, tag_type tag, movie_definition* m)
+// Load a StartSound tag.
+{
+       assert(tag == 15);
+
+       uint16_t        sound_id = in->read_u16();
+
+       sound_sample_impl*      sam = (sound_sample_impl*) 
m->get_sound_sample(sound_id);
+       if (sam)
+       {
+               start_sound_tag*        sst = new start_sound_tag();
+               sst->read(in, tag, m, sam);
+
+               IF_VERBOSE_PARSE(log_msg("start_sound tag: id=%d, stop = %d, 
loop ct = %d\n",
+                                        sound_id, int(sst->m_stop_playback), 
sst->m_loop_count));
+       }
+       else
+       {
+               if (s_sound_handler)
+               {
+                       log_error("start_sound_loader: sound_id %d is not 
defined\n", sound_id);
+               }
+       }
+       
+}
+
+} // namespace gnash::SWF::tag_loaders
+} // namespace gnash::SWF
 
-};     // end namespace gnash
+} // namespace gnash
 
 
 // Local Variables:
Index: gnash/server/sprite_definition.cpp
diff -u gnash/server/sprite_definition.cpp:1.3 
gnash/server/sprite_definition.cpp:1.4
--- gnash/server/sprite_definition.cpp:1.3      Mon May  8 21:12:24 2006
+++ gnash/server/sprite_definition.cpp  Tue May  9 15:34:16 2006
@@ -48,6 +48,7 @@
 
 #include "sprite_instance.h"
 #include "sprite_definition.h"
+#include "execute_tag.h" // for dtor visibility
 
 #include <vector>
 #include <string>
@@ -101,15 +102,16 @@
 
        while ((uint32_t) in->get_position() < (uint32_t) tag_end)
        {
-               int     tag_type = in->open_tag();
-               loader_function lf = NULL;
-               if (tag_type == 1)
+               SWF::tag_type tag_type = in->open_tag();
+
+               SWF::TagLoadersTable::loader_function lf = NULL;
+               if (tag_type == SWF::SHOWFRAME)
                {
                    // show frame tag -- advance to the next frame.
                    IF_VERBOSE_PARSE(log_msg("  show_frame (sprite)\n"));
                    m_loading_frame++;
                }
-               else if (s_tag_loaders.get(tag_type, &lf))
+               else if (_tag_loaders.get(tag_type, &lf))
                {
                    // call the tag loader.  The tag loader should add
                    // characters or tags to the movie data structure.
@@ -152,6 +154,7 @@
 
 sprite_definition::sprite_definition(movie_definition* m)
        :
+       _tag_loaders(s_tag_loaders),  // FIXME: use a class-static 
TagLoadersTable for sprite_definition
        m_movie_def(m),
        m_frame_count(0),
        m_loading_frame(0)
Index: gnash/server/sprite_definition.h
diff -u gnash/server/sprite_definition.h:1.4 
gnash/server/sprite_definition.h:1.5
--- gnash/server/sprite_definition.h:1.4        Tue May  9 10:41:44 2006
+++ gnash/server/sprite_definition.h    Tue May  9 15:34:16 2006
@@ -76,6 +76,9 @@
 
 private:
 
+       /// Tags loader table
+       SWF::TagLoadersTable& _tag_loaders;
+
        /// Top-level movie (the one with a character_def)
        movie_definition* m_movie_def;
 
Index: gnash/server/sprite_instance.cpp
diff -u gnash/server/sprite_instance.cpp:1.2 
gnash/server/sprite_instance.cpp:1.3
--- gnash/server/sprite_instance.cpp:1.2        Mon May  8 21:12:24 2006
+++ gnash/server/sprite_instance.cpp    Tue May  9 15:34:16 2006
@@ -59,6 +59,7 @@
 #include "MovieClipLoader.h" // @@ temp hack for loading tests
 #include "Function.h"
 #include "text.h"
+#include "execute_tag.h"
 
 using namespace std;
 
Index: gnash/server/stream.cpp
diff -u gnash/server/stream.cpp:1.3 gnash/server/stream.cpp:1.4
--- gnash/server/stream.cpp:1.3 Mon May  8 21:12:24 2006
+++ gnash/server/stream.cpp     Tue May  9 15:34:16 2006
@@ -12,6 +12,7 @@
 #include "log.h"
 #include "types.h"
 #include "tu_file.h"
+#include "swf.h"
 #include <string.h>
 
 namespace gnash {
@@ -233,7 +234,7 @@
        }
 
 
-       int     stream::open_tag()
+       SWF::tag_type stream::open_tag()
        // Return the tag type.
        {
                align();
@@ -251,7 +252,7 @@
                // fast-forward past it when we're done reading it.
                m_tag_stack.push_back(get_position() + tag_length);
 
-               return tag_type;
+               return static_cast<SWF::tag_type>(tag_type);
        }
 
 
Index: gnash/server/stream.h
diff -u gnash/server/stream.h:1.4 gnash/server/stream.h:1.5
--- gnash/server/stream.h:1.4   Mon May  8 21:12:24 2006
+++ gnash/server/stream.h       Tue May  9 15:34:16 2006
@@ -10,6 +10,8 @@
 #define GNASH_STREAM_H
 
 #include "container.h"
+#include "swf.h"
+
 class tu_file;
 
 namespace gnash {
@@ -48,7 +50,7 @@
                int     get_position();
                void    set_position(int pos);
                int     get_tag_end_position();
-               int     open_tag();
+               SWF::tag_type   open_tag();
                void    close_tag();
 
                tu_file*        get_underlying_stream() { return m_input; }
Index: gnash/server/swf.h
diff -u gnash/server/swf.h:1.13 gnash/server/swf.h:1.14
--- gnash/server/swf.h:1.13     Mon Apr 24 23:05:56 2006
+++ gnash/server/swf.h  Tue May  9 15:34:16 2006
@@ -40,7 +40,7 @@
 
 namespace gnash {
 
-/// SWF format definitions
+/// SWF format parsing classes
 namespace SWF { // gnash::SWF
 
 /// SWF tag types. Symbolc names copied from Ming
Index: gnash/server/text.cpp
diff -u gnash/server/text.cpp:1.16 gnash/server/text.cpp:1.17
--- gnash/server/text.cpp:1.16  Mon May  8 21:12:24 2006
+++ gnash/server/text.cpp       Tue May  9 15:34:16 2006
@@ -299,23 +299,6 @@
        }
 
 
-       /// Read a DefineText tag.
-       void    define_text_loader(stream* in, int tag_type, movie_definition* 
m)
-       {
-               assert(tag_type == 11 || tag_type == 33);
-
-               uint16_t        character_id = in->read_u16();
-               
-               text_character_def*     ch = new text_character_def(m);
-               IF_VERBOSE_PARSE(log_msg("text_character, id = %d\n", 
character_id));
-               ch->read(in, tag_type, m);
-
-               // IF_VERBOSE_PARSE(print some stuff);
-
-               m->add_character(character_id, ch);
-       }
-
-
        //
        // edit_text_character_def
        //
@@ -941,20 +924,6 @@
        }
 
 
-       void    define_edit_text_loader(stream* in, int tag_type, 
movie_definition* m)
-       // Read a DefineText tag.
-       {
-               assert(tag_type == 37);
-
-               uint16_t        character_id = in->read_u16();
-
-               edit_text_character_def*        ch = new 
edit_text_character_def(m);
-               IF_VERBOSE_PARSE(log_msg("edit_text_char, id = %d\n", 
character_id));
-               ch->read(in, tag_type, m);
-
-               m->add_character(character_id, ch);
-       }
-
 }      // end namespace gnash
 
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]