gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] [SCM] Gnash branch, master, updated. 731befc1cd9a4dbf4066


From: Benjamin Wolsey
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. 731befc1cd9a4dbf4066aa980ae7dadaafbd5059
Date: Wed, 20 Oct 2010 17:50:52 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, master has been updated
       via  731befc1cd9a4dbf4066aa980ae7dadaafbd5059 (commit)
       via  d6e20925f19502e93e822fa4d875f0574a8345bb (commit)
       via  736a59d56beb7cf42f2eaf80e5d37131e6b5aea0 (commit)
       via  bb1358dec3b2a7d82f9705fecb19740e4af7e5ee (commit)
       via  6676d6936b4a5b1464bfbafce752e7d73ddf8f62 (commit)
       via  bd37eca7d9f77c46340e71095af180f9f2ac2c3a (commit)
       via  62c6d2dbb05924edfb62eb809d2ab96d7b75ba88 (commit)
       via  cdc287186de052597ea223cef4b8477798b24607 (commit)
       via  63b086ce3b33b10ca8e6f4b6e8e6f01029080959 (commit)
      from  8dfe5b76c7722cc4b94f78f7e2a9e4e0579aaaf2 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=731befc1cd9a4dbf4066aa980ae7dadaafbd5059


commit 731befc1cd9a4dbf4066aa980ae7dadaafbd5059
Merge: d6e2092 8dfe5b7
Author: Benjamin Wolsey <address@hidden>
Date:   Wed Oct 20 19:50:41 2010 +0200

    Merge branch 'master' of git.sv.gnu.org:/srv/git/gnash


http://git.savannah.gnu.org/cgit//commit/?id=d6e20925f19502e93e822fa4d875f0574a8345bb


commit d6e20925f19502e93e822fa4d875f0574a8345bb
Author: Benjamin Wolsey <address@hidden>
Date:   Wed Oct 20 19:39:20 2010 +0200

    Stop after first GIF image record, so that later invalid records
    don't prevent the image from being stored.

diff --git a/libbase/GnashImageGif.cpp b/libbase/GnashImageGif.cpp
index f6d1b0a..1b85579 100644
--- a/libbase/GnashImageGif.cpp
+++ b/libbase/GnashImageGif.cpp
@@ -103,117 +103,127 @@ GifInput::readScanline(unsigned char* rgbData)
 
 }
 
-void
-GifInput::read()
+bool
+GifInput::processRecord(GifRecordType record)
 {
-    _gif = DGifOpen(_inStream.get(), &readData); 
-
-    GifRecordType record;
-
-    // Parse the (first?) image into memory.
-    // Is there a multi-dimensional smart array? It's silly to
-    // have to allocate each row separately and can mean a lot
-    // of reallocation.
-    do {
-
-        if (DGifGetRecordType(_gif, &record) != GIF_OK) {
-            throw ParserException(_("GIF: Error retrieving record type"));
-        }
-        
-        switch (record) {
-
-            case IMAGE_DESC_RECORD_TYPE:
-            {
-                // Fill the _gif->Image fields 
-                if (DGifGetImageDesc(_gif) != GIF_OK) {
-                    throw ParserException(_("GIF: Error retrieving image "
-                                "description"));
-                }
-                const int backgroundColor = _gif->SBackGroundColor;
-
-                // Set the height dimension of the array
-                _gifData.reset(new PixelRow[getHeight()]);
-                
-                // The GIF 'screen' width and height
-                const size_t screenWidth = getWidth();
-                const size_t screenHeight = getHeight();
-
-                // Set all the pixels to the background colour.
-                for (size_t i = 0; i < screenHeight; ++i) {
-                    // Set the width dimension of the array
-                    _gifData[i].reset(new GifPixelType[screenWidth]);
-                    // Fill all the pixels with the background color.
-                    std::fill_n(_gifData[i].get(), screenWidth,
-                            backgroundColor);
-                }
-                
-                // The position of the image on the GIF 'screen'
-                const size_t imageHeight = _gif->Image.Height;
-                const size_t imageWidth = _gif->Image.Width;
-                const size_t imageTop = _gif->Image.Top;
-                const size_t imageLeft = _gif->Image.Left;
-                
-                if (imageHeight + imageTop > screenHeight ||
-                    imageWidth + imageLeft > screenWidth) {
-                    throw ParserException(_("GIF: invalid image data "
-                                "(bounds outside GIF screen)"));
-                }
+    switch (record) {
+
+        case IMAGE_DESC_RECORD_TYPE:
+        {
+            // Fill the _gif->Image fields 
+            if (DGifGetImageDesc(_gif) != GIF_OK) {
+                throw ParserException(_("GIF: Error retrieving image "
+                            "description"));
+            }
+            const int backgroundColor = _gif->SBackGroundColor;
+
+            // Set the height dimension of the array
+            _gifData.reset(new PixelRow[getHeight()]);
+            
+            // The GIF 'screen' width and height
+            const size_t screenWidth = getWidth();
+            const size_t screenHeight = getHeight();
+
+            // Set all the pixels to the background colour.
+            for (size_t i = 0; i < screenHeight; ++i) {
+                // Set the width dimension of the array
+                _gifData[i].reset(new GifPixelType[screenWidth]);
+                // Fill all the pixels with the background color.
+                std::fill_n(_gifData[i].get(), screenWidth,
+                        backgroundColor);
+            }
+            
+            // The position of the image on the GIF 'screen'
+            const size_t imageHeight = _gif->Image.Height;
+            const size_t imageWidth = _gif->Image.Width;
+            const size_t imageTop = _gif->Image.Top;
+            const size_t imageLeft = _gif->Image.Left;
+            
+            if (imageHeight + imageTop > screenHeight ||
+                imageWidth + imageLeft > screenWidth) {
+                throw ParserException(_("GIF: invalid image data "
+                            "(bounds outside GIF screen)"));
+            }
 
-                // Handle interlaced data in four passes.
-                if (_gif->Image.Interlace) {
-                    log_debug(_("Found interlaced GIF (%d x %d)"),
-                            screenWidth, screenHeight);
+            // Handle interlaced data in four passes.
+            if (_gif->Image.Interlace) {
+                log_debug(_("Found interlaced GIF (%d x %d)"),
+                        screenWidth, screenHeight);
 
-                    // The order of interlaced GIFs.
-                    const int interlacedOffsets[] = { 0, 4, 2, 1 };
-                    const int interlacedJumps[] = { 8, 8, 4, 2 };
+                // The order of interlaced GIFs.
+                const int interlacedOffsets[] = { 0, 4, 2, 1 };
+                const int interlacedJumps[] = { 8, 8, 4, 2 };
 
-                    for (size_t i = 0; i < 4; ++i) {
+                for (size_t i = 0; i < 4; ++i) {
 
-                        for (size_t j = imageTop + interlacedOffsets[i];
-                                    j < imageTop + imageHeight;
-                                    j += interlacedJumps[i]) {
+                    for (size_t j = imageTop + interlacedOffsets[i];
+                                j < imageTop + imageHeight;
+                                j += interlacedJumps[i]) {
 
-                            if (DGifGetLine(_gif, &_gifData[j][imageLeft],
-                                        imageWidth) != GIF_OK) {
+                        if (DGifGetLine(_gif, &_gifData[j][imageLeft],
+                                    imageWidth) != GIF_OK) {
 
-                                throw ParserException(_("GIF: failed reading "
-                                            "pixel data"));
+                            throw ParserException(_("GIF: failed reading "
+                                        "pixel data"));
 
-                            }
                         }
                     }
-                    break;
                 }
+                // One record is enough.
+                return true;
+            }
 
-                // Non-interlaced data.
-                log_debug(_("Found non-interlaced GIF (%d x %d)"),
-                        screenWidth, screenHeight);
+            // Non-interlaced data.
+            log_debug(_("Found non-interlaced GIF (%d x %d)"),
+                    screenWidth, screenHeight);
+
+            for (size_t i = imageTop; i < imageHeight; ++i) {
+                // Read the gif data into the gif array.
+                if (DGifGetLine(_gif, &_gifData[i][imageLeft], imageWidth)
+                        != GIF_OK) {
+                    throw ParserException(_("GIF: failed reading "
+                                "pixel data"));
+                }                    
+            }
+            // One record is enough.
+            return true;
+        }
 
-                for (size_t i = imageTop; i < imageHeight; ++i) {
-                    // Read the gif data into the gif array.
-                    if (DGifGetLine(_gif, &_gifData[i][imageLeft], imageWidth)
-                            != GIF_OK) {
-                        throw ParserException(_("GIF: failed reading "
-                                    "pixel data"));
-                    }                    
+        case EXTENSION_RECORD_TYPE:
+            // Skip all extension records.
+            GifByteType* extension;
+            int extCode;
+            DGifGetExtension(_gif, &extCode, &extension);
+            while (extension) {
+                if (DGifGetExtensionNext(_gif, &extension) == GIF_ERROR) {
+                    break;
                 }
-                break;
             }
-            case EXTENSION_RECORD_TYPE:
-                // Skip all extension records.
-                GifByteType* extension;
-                int extCode;
-                DGifGetExtension(_gif, &extCode, &extension);
-                while (extension) {
-                    if (DGifGetExtensionNext(_gif, &extension) == GIF_ERROR) {
-                        break;
-                    }
-                }
-                break;         
-            default:
-                break;
+            break;         
+        default:
+            break;
+    }
+    return false;
+}
+
+void
+GifInput::read()
+{
+    _gif = DGifOpen(_inStream.get(), &readData); 
+
+    GifRecordType record;
+
+    // Parse the (first?) image into memory.
+    // Is there a multi-dimensional smart array? It's silly to
+    // have to allocate each row separately and can mean a lot
+    // of reallocation.
+    do {
+
+        if (DGifGetRecordType(_gif, &record) != GIF_OK) {
+            throw ParserException(_("GIF: Error retrieving record type"));
         }
+        if (processRecord(record)) break;
+            
     } while (record != TERMINATE_RECORD_TYPE);
 
     // Set the type to RGB
diff --git a/libbase/GnashImageGif.h b/libbase/GnashImageGif.h
index 8362b1f..982478d 100644
--- a/libbase/GnashImageGif.h
+++ b/libbase/GnashImageGif.h
@@ -77,15 +77,14 @@ public:
     /// @param rgbData  The buffer for writing raw RGB data to.
     void readScanline(unsigned char* rgb_data);
 
-
     /// Create a GifInput and transfer ownership to the caller.
     //
     /// @param in   The IOChannel to read GIF data from.
     DSOEXPORT static std::auto_ptr<Input> create(
             boost::shared_ptr<IOChannel> in)
     {
-        std::auto_ptr<Input> ret ( new GifInput(in) );
-        if ( ret.get() ) ret->read();
+        std::auto_ptr<Input> ret(new GifInput(in));
+        if (ret.get()) ret->read();
         return ret;
     }
 
@@ -94,6 +93,11 @@ private:
     /// Initialize gif_lib
     void init();
 
+    /// Process a single image record
+    //
+    /// @return     false if no image was parsed, true if we have an image.
+    bool processRecord(GifRecordType record);
+
     // State needed for input.
     GifFileType* _gif;
     

http://git.savannah.gnu.org/cgit//commit/?id=736a59d56beb7cf42f2eaf80e5d37131e6b5aea0


commit 736a59d56beb7cf42f2eaf80e5d37131e6b5aea0
Author: Benjamin Wolsey <address@hidden>
Date:   Wed Oct 20 19:12:42 2010 +0200

    Ensure bytes.

diff --git a/libcore/swf/DefineBitsTag.cpp b/libcore/swf/DefineBitsTag.cpp
index 1c84420..13abb59 100644
--- a/libcore/swf/DefineBitsTag.cpp
+++ b/libcore/swf/DefineBitsTag.cpp
@@ -348,6 +348,7 @@ readDefineBitsJpeg3(SWFStream& in, TagType tag)
     const boost::uint32_t jpeg_size = in.read_u32();
 
     if (tag == DEFINEBITSJPEG4) {
+        in.ensureBytes(2);
         const float deblocking = in.read_short_ufixed();
         IF_VERBOSE_PARSE(
             log_parse("DefineBitsJpeg4 deblocking: %1%", deblocking);

http://git.savannah.gnu.org/cgit//commit/?id=bb1358dec3b2a7d82f9705fecb19740e4af7e5ee


commit bb1358dec3b2a7d82f9705fecb19740e4af7e5ee
Author: Benjamin Wolsey <address@hidden>
Date:   Wed Oct 20 19:06:32 2010 +0200

    Support for DefineBitsJpeg4 tag (no tests, no examples).

diff --git a/libcore/swf/DefaultTagLoaders.cpp 
b/libcore/swf/DefaultTagLoaders.cpp
index 0dedca7..31167a3 100644
--- a/libcore/swf/DefaultTagLoaders.cpp
+++ b/libcore/swf/DefaultTagLoaders.cpp
@@ -224,6 +224,8 @@ addDefaultLoaders(TagLoadersTable& table)
         (TagPair(SWF::DEFINEFONTNAME, DefineFontNameTag::loader))
         // 89
         (TagPair(SWF::STARTSOUND2, StartSound2Tag::loader))
+        // 90
+        (TagPair(SWF::DEFINEBITSJPEG4, DefineBitsTag::loader))
         // 777
         (TagPair(SWF::REFLEX, reflex_loader))
 #ifdef ENABLE_AVM2
diff --git a/libcore/swf/DefineBitsTag.cpp b/libcore/swf/DefineBitsTag.cpp
index 0530294..1c84420 100644
--- a/libcore/swf/DefineBitsTag.cpp
+++ b/libcore/swf/DefineBitsTag.cpp
@@ -58,7 +58,8 @@ namespace {
     std::auto_ptr<image::GnashImage> readDefineBitsJpeg(SWFStream& in,
             movie_definition& m);
     std::auto_ptr<image::GnashImage> readDefineBitsJpeg2(SWFStream& in);
-    std::auto_ptr<image::GnashImage> readDefineBitsJpeg3(SWFStream& in);
+    /// DefineBitsJpeg3, also DefineBitsJpeg4!
+    std::auto_ptr<image::GnashImage> readDefineBitsJpeg3(SWFStream& in, 
TagType tag);
     std::auto_ptr<image::GnashImage> readLossless(SWFStream& in, TagType tag);
 
 }
@@ -218,18 +219,23 @@ DefineBitsTag::loader(SWFStream& in, TagType tag, 
movie_definition& m,
             im = readDefineBitsJpeg2(in);
             break;
         case SWF::DEFINEBITSJPEG3:
-            im = readDefineBitsJpeg3(in);
+        case SWF::DEFINEBITSJPEG4:
+            im = readDefineBitsJpeg3(in, tag);
             break;
         case SWF::DEFINELOSSLESS:
         case SWF::DEFINELOSSLESS2:
             im = readLossless(in, tag);
             break;
-
         default:
             std::abort();
     }
 
-    if (!im.get()) return;
+    if (!im.get()) {
+        IF_VERBOSE_MALFORMED_SWF(
+            log_swferror(_("Failed to parse bitmap for character %1%"), id);
+        );
+        return;
+    }
 
     Renderer* renderer = r.renderer();
     if (!renderer) {
@@ -334,14 +340,20 @@ readDefineBitsJpeg2(SWFStream& in)
 }
 
 
-// loads a define_bits_jpeg3 tag. This is a jpeg file with an alpha
-// channel using zlib compression.
+/// Parse a DefineBitsJpeg3 or 4 tag.
 std::auto_ptr<image::GnashImage>
-readDefineBitsJpeg3(SWFStream& in)
+readDefineBitsJpeg3(SWFStream& in, TagType tag)
 {
     in.ensureBytes(4);
     const boost::uint32_t jpeg_size = in.read_u32();
 
+    if (tag == DEFINEBITSJPEG4) {
+        const float deblocking = in.read_short_ufixed();
+        IF_VERBOSE_PARSE(
+            log_parse("DefineBitsJpeg4 deblocking: %1%", deblocking);
+        );
+    }
+
     const FileType ft = checkFileType(in);
 
     // If the image doesn't contain JPEG data, it also has no alpha

http://git.savannah.gnu.org/cgit//commit/?id=6676d6936b4a5b1464bfbafce752e7d73ddf8f62


commit 6676d6936b4a5b1464bfbafce752e7d73ddf8f62
Author: Benjamin Wolsey <address@hidden>
Date:   Wed Oct 20 18:38:56 2010 +0200

    Read GIF and PNG for DefineBitsJpeg3 as well (documented,
    only DefineBitsJpeg2 is confirmed).

diff --git a/libcore/swf/DefineBitsTag.cpp b/libcore/swf/DefineBitsTag.cpp
index 50e9fce..0530294 100644
--- a/libcore/swf/DefineBitsTag.cpp
+++ b/libcore/swf/DefineBitsTag.cpp
@@ -53,7 +53,7 @@ namespace SWF {
 
 // Forward declarations
 namespace {
-    void inflateWrapper(SWFStream& in, void* buffer, int buffer_bytes);
+    void inflateWrapper(SWFStream& in, void* buffer, size_t buffer_bytes);
 
     std::auto_ptr<image::GnashImage> readDefineBitsJpeg(SWFStream& in,
             movie_definition& m);
@@ -281,37 +281,56 @@ readDefineBitsJpeg(SWFStream& /*in*/, movie_definition& m)
     return im;
 }
 
-
-std::auto_ptr<image::GnashImage>
-readDefineBitsJpeg2(SWFStream& in)
+/// Check the file type of the stream
+//
+/// This peeks at the first three bytes. The stream position after
+/// the function returns is the same as at the call time.
+//
+/// If the stream is too short to determine the type, a ParserException
+/// is thrown.
+FileType
+checkFileType(SWFStream& in)
 {
+#ifndef NDEBUG
+    const size_t start = in.tell();
+#endif
 
-    char buf[3];
-    if (in.read(buf, 3) < 3) {
-        log_swferror(_("DEFINEBITS data too short to read type header"));
-        return std::auto_ptr<image::GnashImage>();
-    }
-    in.seek(in.tell() - 3);
+    const size_t bytes = 3;
+    char buf[bytes];
 
-    FileType ft = GNASH_FILETYPE_JPEG;  
+    const size_t read = in.read(buf, bytes);
+    in.seek(in.tell() - read);
+
+    if (read < bytes) {
+        throw ParserException("DefineBits data is much too short!");
+    }
 
     // Check the data type. The pp version 9,0,115,0 supports PNG and GIF
     // in DefineBits tags, though it is not documented. The version makes
     // no difference.
     if (std::equal(buf, buf + 3, "\x89PN")) {
-        ft = GNASH_FILETYPE_PNG;
+        return GNASH_FILETYPE_PNG;
     }
-    else if (std::equal(buf, buf + 3, "GIF")) {
-        ft = GNASH_FILETYPE_GIF;
+
+    if (std::equal(buf, buf + 3, "GIF")) {
+        return GNASH_FILETYPE_GIF;
     }
+    return GNASH_FILETYPE_JPEG;  
+
+    assert(in.tell() == start);
+}
+
+
+std::auto_ptr<image::GnashImage>
+readDefineBitsJpeg2(SWFStream& in)
+{
+    const FileType ft = checkFileType(in);
 
     // Read the image data.
     boost::shared_ptr<IOChannel> ad(StreamAdapter::getFile(in,
                 in.get_tag_end_position()).release());
 
-    std::auto_ptr<image::GnashImage> im(image::Input::readImageData(ad, ft));
-    return im;
-
+    return image::Input::readImageData(ad, ft);
 }
 
 
@@ -322,6 +341,20 @@ readDefineBitsJpeg3(SWFStream& in)
 {
     in.ensureBytes(4);
     const boost::uint32_t jpeg_size = in.read_u32();
+
+    const FileType ft = checkFileType(in);
+
+    // If the image doesn't contain JPEG data, it also has no alpha
+    // data.
+    if (ft != GNASH_FILETYPE_JPEG) {
+        log_debug("TESTING: non-JPEG data in DefineBitsJpeg3");
+        // Read the image data.
+        boost::shared_ptr<IOChannel> ad(StreamAdapter::getFile(in,
+                    in.get_tag_end_position()).release());
+        return image::Input::readImageData(ad, ft);
+    }
+
+    // We assume it's a JPEG with alpha data.
     const boost::uint32_t alpha_position = in.tell() + jpeg_size;
 
 #ifndef HAVE_ZLIB_H
@@ -531,17 +564,15 @@ readLossless(SWFStream& in, TagType tag)
 // of data from the input file into buffer_bytes worth of data
 // into *buffer.
 void
-inflateWrapper(SWFStream& in, void* buffer, int buffer_bytes)
+inflateWrapper(SWFStream& in, void* buffer, size_t buffer_bytes)
 {
     assert(buffer);
-    assert(buffer_bytes > 0);
-
-    z_stream d_stream; /* decompression SWFStream */
 
-    d_stream.zalloc = (alloc_func)0;
-    d_stream.zfree = (free_func)0;
-    d_stream.opaque = (voidpf)0;
+    z_stream d_stream;
 
+    d_stream.zalloc = 0;
+    d_stream.zfree = 0;
+    d_stream.opaque = 0;
     d_stream.next_in  = 0;
     d_stream.avail_in = 0;
 
@@ -565,7 +596,8 @@ inflateWrapper(SWFStream& in, void* buffer, int 
buffer_bytes)
     for (;;) {
         unsigned int chunkSize = CHUNKSIZE;
         assert(in.tell() <= endTagPos);
-        unsigned int availableBytes =  endTagPos - in.tell();
+        const size_t availableBytes =  endTagPos - in.tell();
+
         if (availableBytes < chunkSize) {
             if (!availableBytes) {
                 // nothing more to read

http://git.savannah.gnu.org/cgit//commit/?id=bd37eca7d9f77c46340e71095af180f9f2ac2c3a


commit bd37eca7d9f77c46340e71095af180f9f2ac2c3a
Author: Benjamin Wolsey <address@hidden>
Date:   Wed Oct 20 17:43:31 2010 +0200

    Parse logging.

diff --git a/libcore/swf/DefineBitsTag.cpp b/libcore/swf/DefineBitsTag.cpp
index 1b57b25..50e9fce 100644
--- a/libcore/swf/DefineBitsTag.cpp
+++ b/libcore/swf/DefineBitsTag.cpp
@@ -233,11 +233,16 @@ DefineBitsTag::loader(SWFStream& in, TagType tag, 
movie_definition& m,
 
     Renderer* renderer = r.renderer();
     if (!renderer) {
-        IF_VERBOSE_PARSE(log_parse(_("No renderer, not adding bitmap")));
+        IF_VERBOSE_PARSE(
+            log_parse(_("No renderer, not adding bitmap %1%"), id)
+        );
         return;
     }    
     boost::intrusive_ptr<CachedBitmap> bi = renderer->createCachedBitmap(im);
 
+    IF_VERBOSE_PARSE(
+        log_parse(_("Adding bitmap id %1%"), id);
+    );
     // add bitmap to movie under DisplayObject id.
     m.addBitmap(id, bi);
 }
@@ -369,15 +374,14 @@ readLossless(SWFStream& in, TagType tag)
                 "w = %d, h = %d"), tag, bitmap_format, width, height);
     );
 
+    std::auto_ptr<image::GnashImage> image;  
     if (!width || !height) {
          IF_VERBOSE_MALFORMED_SWF(
-            log_swferror(_("Bitmap DisplayObject has a height or width of 0"));
-        );   
-        return std::auto_ptr<image::GnashImage>();  
+            log_swferror(_("Bitmap has a height or width of 0"));
+        );
+        return image;
     } 
     
-    std::auto_ptr<image::GnashImage> image;
-
 #ifndef HAVE_ZLIB_H
     log_error(_("gnash is not linked to zlib -- can't load zipped image 
data"));
     return image;

http://git.savannah.gnu.org/cgit//commit/?id=62c6d2dbb05924edfb62eb809d2ab96d7b75ba88


commit 62c6d2dbb05924edfb62eb809d2ab96d7b75ba88
Author: Benjamin Wolsey <address@hidden>
Date:   Wed Oct 20 17:36:45 2010 +0200

    Reduce duplication.

diff --git a/libcore/swf/DefaultTagLoaders.cpp 
b/libcore/swf/DefaultTagLoaders.cpp
index db71900..0dedca7 100644
--- a/libcore/swf/DefaultTagLoaders.cpp
+++ b/libcore/swf/DefaultTagLoaders.cpp
@@ -120,7 +120,7 @@ addDefaultLoaders(TagLoadersTable& table)
         (TagPair(SWF::FREECHARACTER, unexpected)) 
         (TagPair(SWF::PLACEOBJECT, PlaceObject2Tag::loader))
         (TagPair(SWF::REMOVEOBJECT, RemoveObjectTag::loader)) // 05
-        (TagPair(SWF::DEFINEBITS, define_bits_jpeg_loader))
+        (TagPair(SWF::DEFINEBITS, DefineBitsTag::loader))
         (TagPair(SWF::DEFINEBUTTON, DefineButtonTag::loader))
         (TagPair(SWF::JPEGTABLES, jpeg_tables_loader))
         (TagPair(SWF::SETBACKGROUNDCOLOR, SetBackgroundColorTag::loader))
@@ -137,8 +137,8 @@ addDefaultLoaders(TagLoadersTable& table)
         (TagPair(SWF::SOUNDSTREAMHEAD, sound_stream_head_loader))
         // 19
         (TagPair(SWF::SOUNDSTREAMBLOCK, StreamSoundBlockTag::loader))
-        (TagPair(SWF::DEFINELOSSLESS, define_bits_lossless_2_loader))
-        (TagPair(SWF::DEFINEBITSJPEG2, define_bits_jpeg2_loader))
+        (TagPair(SWF::DEFINELOSSLESS, DefineBitsTag::loader))
+        (TagPair(SWF::DEFINEBITSJPEG2, DefineBitsTag::loader))
         (TagPair(SWF::DEFINESHAPE2, DefineShapeTag::loader))
         (TagPair(SWF::DEFINEBUTTONCXFORM, DefineButtonCxformTag::loader)) // 23
         (TagPair(SWF::PROTECT, ignore))
@@ -152,8 +152,8 @@ addDefaultLoaders(TagLoadersTable& table)
         (TagPair(SWF::DEFINETEXT2, DefineText2Tag::loader))
         // 37
         (TagPair(SWF::DEFINEBUTTON2, DefineButton2Tag::loader))
-        (TagPair(SWF::DEFINEBITSJPEG3, define_bits_jpeg3_loader))
-        (TagPair(SWF::DEFINELOSSLESS2, define_bits_lossless_2_loader))
+        (TagPair(SWF::DEFINEBITSJPEG3, DefineBitsTag::loader))
+        (TagPair(SWF::DEFINELOSSLESS2, DefineBitsTag::loader))
         (TagPair(SWF::DEFINEEDITTEXT, DefineEditTextTag::loader))
         (TagPair(SWF::DEFINEVIDEO, unexpected)) // 38
         (TagPair(SWF::DEFINESPRITE, sprite_loader))
diff --git a/libcore/swf/DefineBitsTag.cpp b/libcore/swf/DefineBitsTag.cpp
index b6205d2..1b57b25 100644
--- a/libcore/swf/DefineBitsTag.cpp
+++ b/libcore/swf/DefineBitsTag.cpp
@@ -1,4 +1,4 @@
-// tag_loaders.cpp: SWF tags loaders, for Gnash.
+// DefineBitsTag.cpp: bitmap tag loading for Gnash.
 //
 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
 //   Foundation, Inc
@@ -22,11 +22,12 @@
 #include "gnashconfig.h" // HAVE_ZLIB_H, USE_SWFTREE
 #endif
 
-#include "tag_loaders.h"
+#include "DefineBitsTag.h"
 
 #include <limits>
 #include <cassert>
 #include <boost/static_assert.hpp>
+#include <boost/scoped_array.hpp>
 
 #include "IOChannel.h"
 #include "utility.h"
@@ -53,6 +54,13 @@ namespace SWF {
 // Forward declarations
 namespace {
     void inflateWrapper(SWFStream& in, void* buffer, int buffer_bytes);
+
+    std::auto_ptr<image::GnashImage> readDefineBitsJpeg(SWFStream& in,
+            movie_definition& m);
+    std::auto_ptr<image::GnashImage> readDefineBitsJpeg2(SWFStream& in);
+    std::auto_ptr<image::GnashImage> readDefineBitsJpeg3(SWFStream& in);
+    std::auto_ptr<image::GnashImage> readLossless(SWFStream& in, TagType tag);
+
 }
 
 namespace {
@@ -185,16 +193,12 @@ jpeg_tables_loader(SWFStream& in, TagType tag, 
movie_definition& m,
     m.set_jpeg_loader(input);
 }
 
-// A JPEG image without included tables; those should be in an
-// existing image::JpegInput object stored in the movie.
 void
-define_bits_jpeg_loader(SWFStream& in, TagType tag, movie_definition& m,
-               const RunResources& r)
+DefineBitsTag::loader(SWFStream& in, TagType tag, movie_definition& m,
+        const RunResources& r)
 {
-    assert(tag == SWF::DEFINEBITS); // 6
-
     in.ensureBytes(2);
-    boost::uint16_t id = in.read_u16();
+    const boost::uint16_t id = in.read_u16();
 
     if (m.getBitmap(id)) {
         IF_VERBOSE_MALFORMED_SWF(
@@ -204,68 +208,83 @@ define_bits_jpeg_loader(SWFStream& in, TagType tag, 
movie_definition& m,
         return;
     }
 
+    std::auto_ptr<image::GnashImage> im;
+
+    switch (tag) {
+        case SWF::DEFINEBITS:
+            im = readDefineBitsJpeg(in, m);
+            break;
+        case SWF::DEFINEBITSJPEG2:
+            im = readDefineBitsJpeg2(in);
+            break;
+        case SWF::DEFINEBITSJPEG3:
+            im = readDefineBitsJpeg3(in);
+            break;
+        case SWF::DEFINELOSSLESS:
+        case SWF::DEFINELOSSLESS2:
+            im = readLossless(in, tag);
+            break;
+
+        default:
+            std::abort();
+    }
+
+    if (!im.get()) return;
+
+    Renderer* renderer = r.renderer();
+    if (!renderer) {
+        IF_VERBOSE_PARSE(log_parse(_("No renderer, not adding bitmap")));
+        return;
+    }    
+    boost::intrusive_ptr<CachedBitmap> bi = renderer->createCachedBitmap(im);
+
+    // add bitmap to movie under DisplayObject id.
+    m.addBitmap(id, bi);
+}
+
+namespace {
+
+// A JPEG image without included tables; those should be in an
+// existing image::JpegInput object stored in the movie.
+std::auto_ptr<image::GnashImage>
+readDefineBitsJpeg(SWFStream& /*in*/, movie_definition& m)
+{
+    std::auto_ptr<image::GnashImage> im;
+
     // Read the image data.
     image::JpegInput* j_in = m.get_jpeg_loader();
     if (!j_in) {
         IF_VERBOSE_MALFORMED_SWF(
             log_swferror(_("DEFINEBITS: No jpeg loader registered in movie "
-                    "definition - discarding bitmap DisplayObject %d"), id);
+                    "definition - discarding bitmap"));
         );
-        return;
+        return im;
     }
 
     j_in->discardPartialBuffer();
     
-    std::auto_ptr<image::GnashImage> im;
     try {
         im = image::JpegInput::readSWFJpeg2WithTables(*j_in);
     }
     catch (const std::exception& e) {
         IF_VERBOSE_MALFORMED_SWF(
             log_swferror("Error reading jpeg2 with headers for DisplayObject "
-                "id %d: %s", id, e.what());
+                "%s", e.what());
         );
-        return;
     }
     
-    Renderer* renderer = r.renderer();
-    if (!renderer) {
-        IF_VERBOSE_PARSE(log_parse(_("No renderer, not adding bitmap")));
-        return;
-    }    
-    boost::intrusive_ptr<CachedBitmap> bi = renderer->createCachedBitmap(im);
-
-    // add bitmap to movie under DisplayObject id.
-    m.addBitmap(id, bi);
+    return im;
 }
 
 
-void
-define_bits_jpeg2_loader(SWFStream& in, TagType tag, movie_definition& m,
-               const RunResources& r)
+std::auto_ptr<image::GnashImage>
+readDefineBitsJpeg2(SWFStream& in)
 {
-    assert(tag == SWF::DEFINEBITSJPEG2); // 21
-
-    in.ensureBytes(2);
-    boost::uint16_t id = in.read_u16();
-
-    IF_VERBOSE_PARSE(
-        log_parse(_("  define_bits_jpeg2_loader: charid = %d pos = %ld"),
-              id, in.tell());
-    );
-    
-    if (m.getBitmap(id)) {
-        IF_VERBOSE_MALFORMED_SWF(
-            log_swferror(_("DEFINEBITSJPEG2: Duplicate id (%d) for bitmap "
-                    "DisplayObject - discarding it"), id);
-        );
-        return;
-    }
 
     char buf[3];
     if (in.read(buf, 3) < 3) {
         log_swferror(_("DEFINEBITS data too short to read type header"));
-        return;
+        return std::auto_ptr<image::GnashImage>();
     }
     in.seek(in.tell() - 3);
 
@@ -286,43 +305,23 @@ define_bits_jpeg2_loader(SWFStream& in, TagType tag, 
movie_definition& m,
                 in.get_tag_end_position()).release());
 
     std::auto_ptr<image::GnashImage> im(image::Input::readImageData(ad, ft));
-
-    Renderer* renderer = r.renderer();
-    if (!renderer) {
-        IF_VERBOSE_PARSE(log_parse(_("No renderer, not adding bitmap")));
-        return;
-    }    
-    boost::intrusive_ptr<CachedBitmap> bi = renderer->createCachedBitmap(im);
-
-    // add bitmap to movie under DisplayObject id.
-    m.addBitmap(id, bi);
+    return im;
 
 }
 
 
 // loads a define_bits_jpeg3 tag. This is a jpeg file with an alpha
 // channel using zlib compression.
-void
-define_bits_jpeg3_loader(SWFStream& in, TagType tag, movie_definition& m,
-               const RunResources& r)
+std::auto_ptr<image::GnashImage>
+readDefineBitsJpeg3(SWFStream& in)
 {
-    assert(tag == SWF::DEFINEBITSJPEG3); // 35
-
-    in.ensureBytes(2);
-    const boost::uint16_t id = in.read_u16();
-
-    IF_VERBOSE_PARSE(
-        log_parse(_("  define_bits_jpeg3_loader: charid = %d pos = %lx"),
-              id, in.tell());
-    );
-
     in.ensureBytes(4);
     const boost::uint32_t jpeg_size = in.read_u32();
     const boost::uint32_t alpha_position = in.tell() + jpeg_size;
 
 #ifndef HAVE_ZLIB_H
     log_error(_("gnash is not linked to zlib -- can't load jpeg3 image data"));
-    return;
+    return std::auto_ptr<image::GnashImage>();
 #else
 
     // Read rgb data.
@@ -331,7 +330,7 @@ define_bits_jpeg3_loader(SWFStream& in, TagType tag, 
movie_definition& m,
     std::auto_ptr<image::ImageRGBA> im = image::Input::readSWFJpeg3(ad);
     
     /// Failure to read the jpeg.
-    if (!im.get()) return;
+    if (!im.get()) return std::auto_ptr<image::GnashImage>();
 
     // Read alpha channel.
     in.seek(alpha_position);
@@ -349,28 +348,16 @@ define_bits_jpeg3_loader(SWFStream& in, TagType tag, 
movie_definition& m,
     //  ea8bbad50ccbc52dd734dfc93a7f06a7  6964trev3c.swf
     image::mergeAlpha(*im, buffer.get(), bufferLength);
 
-    Renderer* renderer = r.renderer();
-    if (!renderer) {
-        IF_VERBOSE_PARSE(log_parse(_("No renderer, not adding bitmap")));
-        return;
-    }    
-    boost::intrusive_ptr<CachedBitmap> bi = renderer->createCachedBitmap(
-            static_cast<std::auto_ptr<image::GnashImage> >(im));
-
-    // add bitmap to movie under DisplayObject id.
-    m.addBitmap(id, bi);
 #endif
+    return static_cast<std::auto_ptr<image::GnashImage> >(im);
 }
 
 
-void
-define_bits_lossless_2_loader(SWFStream& in, TagType tag, movie_definition& m,
-               const RunResources& r)
+std::auto_ptr<image::GnashImage>
+readLossless(SWFStream& in, TagType tag)
 {
     assert(tag == SWF::DEFINELOSSLESS || tag == SWF::DEFINELOSSLESS2);
-    in.ensureBytes(2 + 2 + 2 + 1); // the initial header 
-
-    const boost::uint16_t id = in.read_u16();
+    in.ensureBytes(2 + 2 + 1); // the initial header 
 
     // 3 == 8 bit, 4 == 16 bit, 5 == 32 bit
     const boost::uint8_t bitmap_format = in.read_u8();
@@ -378,34 +365,25 @@ define_bits_lossless_2_loader(SWFStream& in, TagType tag, 
movie_definition& m,
     const boost::uint16_t height = in.read_u16();
 
     IF_VERBOSE_PARSE(
-        log_parse(_("  defbitslossless2: tag = %d, id = %d, fmt = %d, "
-                "w = %d, h = %d"), tag, id, bitmap_format, width, height);
+        log_parse(_("  defbitslossless2: tag = %d, fmt = %d, "
+                "w = %d, h = %d"), tag, bitmap_format, width, height);
     );
 
     if (!width || !height) {
          IF_VERBOSE_MALFORMED_SWF(
-            log_swferror(_("Bitmap DisplayObject %d has a height or width of 
0"),
-                id);
+            log_swferror(_("Bitmap DisplayObject has a height or width of 0"));
         );   
-        return;  
-    }
-
-    // No need to parse any further if it already exists, as we aren't going
-    // to add it.
-    if (m.getBitmap(id)) {
-        IF_VERBOSE_MALFORMED_SWF(
-            log_swferror(_("DEFINEBITSLOSSLESS: Duplicate id (%d) "
-                           "for bitmap DisplayObject - discarding it"), id);
-        );
-    }
+        return std::auto_ptr<image::GnashImage>();  
+    } 
+    
+    std::auto_ptr<image::GnashImage> image;
 
 #ifndef HAVE_ZLIB_H
     log_error(_("gnash is not linked to zlib -- can't load zipped image 
data"));
-    return;
+    return image;
 #else
 
     unsigned short channels;
-    std::auto_ptr<image::GnashImage> image;
     bool alpha = false;
 
     try {
@@ -429,7 +407,7 @@ define_bits_lossless_2_loader(SWFStream& in, TagType tag, 
movie_definition& m,
         // size. This isn't usually from operator new.
         log_error(_("Will not allocate %1%x%2% image in DefineBitsLossless "
                 "tag"), width, height);
-        return;
+        return image;
     }
 
     unsigned short bytes_per_pixel;
@@ -453,7 +431,7 @@ define_bits_lossless_2_loader(SWFStream& in, TagType tag, 
movie_definition& m,
 
         default:
             log_error(_("Unknown bitmap format. Ignoring"));
-            return;
+            return std::auto_ptr<image::GnashImage>();
     }
 
     const size_t pitch = (width * bytes_per_pixel + 3) &~ 3;
@@ -538,21 +516,12 @@ define_bits_lossless_2_loader(SWFStream& in, TagType tag, 
movie_definition& m,
 
     }
 
-    Renderer* renderer = r.renderer();
-    if (!renderer) {
-        IF_VERBOSE_PARSE(log_parse(_("No renderer, not adding bitmap")));
-        return;
-    }    
-    boost::intrusive_ptr<CachedBitmap> bi = 
renderer->createCachedBitmap(image);
-
-    // add bitmap to movie under DisplayObject id.
-    m.addBitmap(id, bi);
 #endif // HAVE_ZLIB_H
+    
+    return image;
 
 }
 
-namespace {
-
 #ifdef HAVE_ZLIB_H
 // Wrapper function -- uses Zlib to uncompress in_bytes worth
 // of data from the input file into buffer_bytes worth of data
diff --git a/libcore/swf/DefineBitsTag.h b/libcore/swf/DefineBitsTag.h
index 59e962e..6bcb544 100644
--- a/libcore/swf/DefineBitsTag.h
+++ b/libcore/swf/DefineBitsTag.h
@@ -35,17 +35,13 @@ namespace SWF {
 void jpeg_tables_loader(SWFStream&, TagType, movie_definition&,
                const RunResources&);
 
-void define_bits_jpeg_loader(SWFStream&, TagType, movie_definition&,
-               const RunResources&);
-
-void define_bits_jpeg2_loader(SWFStream&, TagType, movie_definition&,
-               const RunResources&);
+class DefineBitsTag
+{
+public:
+    static void loader(SWFStream&, TagType, movie_definition&,
+            const RunResources&);
 
-void define_bits_jpeg3_loader(SWFStream&, TagType, movie_definition&,
-               const RunResources&);
-
-void define_bits_lossless_2_loader(SWFStream&, TagType, movie_definition&,
-               const RunResources&);
+};
 
 } // namespace SWF
 } // namespace gnash

http://git.savannah.gnu.org/cgit//commit/?id=cdc287186de052597ea223cef4b8477798b24607


commit cdc287186de052597ea223cef4b8477798b24607
Author: Benjamin Wolsey <address@hidden>
Date:   Wed Oct 20 16:29:26 2010 +0200

    Rearrange.

diff --git a/libcore/swf/DefineBitsTag.cpp b/libcore/swf/DefineBitsTag.cpp
index 639a6fa..b6205d2 100644
--- a/libcore/swf/DefineBitsTag.cpp
+++ b/libcore/swf/DefineBitsTag.cpp
@@ -50,7 +50,11 @@
 namespace gnash {
 namespace SWF {
 
-/// Anonymous namespace
+// Forward declarations
+namespace {
+    void inflateWrapper(SWFStream& in, void* buffer, int buffer_bytes);
+}
+
 namespace {
 
 /// Provide an IOChannel interface around a SWFStream for reading 
@@ -295,87 +299,6 @@ define_bits_jpeg2_loader(SWFStream& in, TagType tag, 
movie_definition& m,
 
 }
 
-#ifdef HAVE_ZLIB_H
-void inflate_wrapper(SWFStream& 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(buffer);
-    assert(buffer_bytes > 0);
-
-    z_stream d_stream; /* decompression SWFStream */
-
-    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 = static_cast<Byte*>(buffer);
-    d_stream.avail_out = static_cast<uInt>(buffer_bytes);
-
-    int err = inflateInit(&d_stream);
-    if (err != Z_OK) {
-        IF_VERBOSE_MALFORMED_SWF(
-            log_swferror(_("inflate_wrapper() inflateInit() returned %d (%s)"),
-                err, d_stream.msg);
-        );
-        return;
-    }
-
-    const size_t CHUNKSIZE = 256;
-
-    boost::uint8_t buf[CHUNKSIZE];
-    unsigned long endTagPos = in.get_tag_end_position();
-
-    for (;;) {
-        unsigned int chunkSize = CHUNKSIZE;
-        assert(in.tell() <= endTagPos);
-        unsigned int availableBytes =  endTagPos - in.tell();
-        if (availableBytes < chunkSize) {
-            if (!availableBytes) {
-                // nothing more to read
-                IF_VERBOSE_MALFORMED_SWF(
-                    log_swferror(_("inflate_wrapper(): no end of zstream "
-                        "found within swf tag boundaries"));
-                );
-                break;
-            }
-            chunkSize = availableBytes;
-        }
-    
-        BOOST_STATIC_ASSERT(sizeof(char) == sizeof(boost::uint8_t));
-
-        // Fill the buffer    
-        in.read(reinterpret_cast<char*>(buf), chunkSize);
-        d_stream.next_in = &buf[0];
-        d_stream.avail_in = chunkSize;
-
-        err = inflate(&d_stream, Z_SYNC_FLUSH);
-        if (err == Z_STREAM_END) {
-            // correct end
-            break;
-        }
-
-        if (err != Z_OK) {
-            IF_VERBOSE_MALFORMED_SWF(
-                log_swferror(_("inflate_wrapper() inflate() returned %d (%s)"),
-                    err, d_stream.msg);
-            );
-            break;
-        }
-    }
-
-    err = inflateEnd(&d_stream);
-    if (err != Z_OK) {
-        log_error(_("inflate_wrapper() inflateEnd() return %d (%s)"),
-                err, d_stream.msg);
-    }
-}
-#endif // HAVE_ZLIB_H
-
 
 // loads a define_bits_jpeg3 tag. This is a jpeg file with an alpha
 // channel using zlib compression.
@@ -419,7 +342,7 @@ define_bits_jpeg3_loader(SWFStream& in, TagType tag, 
movie_definition& m,
 
     boost::scoped_array<boost::uint8_t> buffer(new 
boost::uint8_t[bufferLength]);
 
-    inflate_wrapper(in, buffer.get(), bufferLength);
+    inflateWrapper(in, buffer.get(), bufferLength);
 
     // TESTING:
     // magical trevor contains this tag
@@ -537,7 +460,7 @@ define_bits_lossless_2_loader(SWFStream& in, TagType tag, 
movie_definition& m,
     const size_t bufSize = colorTableSize * channels + pitch * height;
     boost::scoped_array<boost::uint8_t> buffer(new boost::uint8_t[bufSize]);
 
-    inflate_wrapper(in, buffer.get(), bufSize);
+    inflateWrapper(in, buffer.get(), bufSize);
     assert(in.tell() <= in.get_tag_end_position());
 
     switch (bitmap_format) {
@@ -628,7 +551,93 @@ define_bits_lossless_2_loader(SWFStream& in, TagType tag, 
movie_definition& m,
 
 }
 
-} // namespace gnash::SWF
+namespace {
+
+#ifdef HAVE_ZLIB_H
+// Wrapper function -- uses Zlib to uncompress in_bytes worth
+// of data from the input file into buffer_bytes worth of data
+// into *buffer.
+void
+inflateWrapper(SWFStream& in, void* buffer, int buffer_bytes)
+{
+    assert(buffer);
+    assert(buffer_bytes > 0);
+
+    z_stream d_stream; /* decompression SWFStream */
+
+    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 = static_cast<Byte*>(buffer);
+    d_stream.avail_out = static_cast<uInt>(buffer_bytes);
+
+    int err = inflateInit(&d_stream);
+    if (err != Z_OK) {
+        IF_VERBOSE_MALFORMED_SWF(
+            log_swferror(_("inflateWrapper() inflateInit() returned %d (%s)"),
+                err, d_stream.msg);
+        );
+        return;
+    }
+
+    const size_t CHUNKSIZE = 256;
+
+    boost::uint8_t buf[CHUNKSIZE];
+    unsigned long endTagPos = in.get_tag_end_position();
+
+    for (;;) {
+        unsigned int chunkSize = CHUNKSIZE;
+        assert(in.tell() <= endTagPos);
+        unsigned int availableBytes =  endTagPos - in.tell();
+        if (availableBytes < chunkSize) {
+            if (!availableBytes) {
+                // nothing more to read
+                IF_VERBOSE_MALFORMED_SWF(
+                    log_swferror(_("inflateWrapper(): no end of zstream "
+                        "found within swf tag boundaries"));
+                );
+                break;
+            }
+            chunkSize = availableBytes;
+        }
+    
+        BOOST_STATIC_ASSERT(sizeof(char) == sizeof(boost::uint8_t));
+
+        // Fill the buffer    
+        in.read(reinterpret_cast<char*>(buf), chunkSize);
+        d_stream.next_in = &buf[0];
+        d_stream.avail_in = chunkSize;
+
+        err = inflate(&d_stream, Z_SYNC_FLUSH);
+        if (err == Z_STREAM_END) {
+            // correct end
+            break;
+        }
+
+        if (err != Z_OK) {
+            IF_VERBOSE_MALFORMED_SWF(
+                log_swferror(_("inflateWrapper() inflate() returned %d (%s)"),
+                    err, d_stream.msg);
+            );
+            break;
+        }
+    }
+
+    err = inflateEnd(&d_stream);
+    if (err != Z_OK) {
+        log_error(_("inflateWrapper() inflateEnd() return %d (%s)"),
+                err, d_stream.msg);
+    }
+}
+#endif // HAVE_ZLIB_H
+
+} // unnamed namespace
+
+} // namespace SWF
 } // namespace gnash
 
 // Local Variables:

http://git.savannah.gnu.org/cgit//commit/?id=63b086ce3b33b10ca8e6f4b6e8e6f01029080959


commit 63b086ce3b33b10ca8e6f4b6e8e6f01029080959
Author: Benjamin Wolsey <address@hidden>
Date:   Wed Oct 20 16:23:36 2010 +0200

    Drop obsolete declarations, move definebits tags into own file.

diff --git a/libcore/Makefile.am b/libcore/Makefile.am
index 5b921de..0a69088 100644
--- a/libcore/Makefile.am
+++ b/libcore/Makefile.am
@@ -99,6 +99,7 @@ libgnashcore_la_SOURCES = \
        swf/SoundInfoRecord.cpp \
        swf/TextRecord.cpp \
        swf/tag_loaders.cpp \
+       swf/DefineBitsTag.cpp \
        swf/DefineFontAlignZonesTag.cpp \
        swf/DefineShapeTag.cpp \
        swf/DefineScalingGridTag.cpp \
@@ -166,6 +167,7 @@ noinst_HEADERS = \
        MovieLibrary.h \
        ExternalInterface.h \
        swf/tag_loaders.h \
+       swf/DefineBitsTag.h \
        swf/DefaultTagLoaders.h \
        swf/ImportAssetsTag.h \
        swf/ExportAssetsTag.h \
diff --git a/libcore/swf/DefaultTagLoaders.cpp 
b/libcore/swf/DefaultTagLoaders.cpp
index a084c5f..db71900 100644
--- a/libcore/swf/DefaultTagLoaders.cpp
+++ b/libcore/swf/DefaultTagLoaders.cpp
@@ -20,8 +20,12 @@
 #include "gnashconfig.h"
 #endif
 
-#include "SWF.h"
 #include "DefaultTagLoaders.h"
+
+#include <boost/assign.hpp>
+#include <set>
+
+#include "SWF.h"
 #include "TagLoadersTable.h"
 #include "tag_loaders.h" 
 #include "ScriptLimitsTag.h"
@@ -42,6 +46,7 @@
 #include "SetTabIndexTag.h"
 #include "StartSoundTag.h"
 #include "StreamSoundBlockTag.h"
+#include "DefineBitsTag.h"
 #include "DefineButtonSoundTag.h"
 #include "DefineMorphShapeTag.h"
 #include "DefineVideoStreamTag.h"
@@ -55,9 +60,6 @@
 # include "DefineSceneAndFrameLabelDataTag.h"
 #endif
 
-#include <boost/assign.hpp>
-#include <boost/bind.hpp>
-
 namespace gnash {
 namespace SWF {
 
diff --git a/libcore/swf/DefineBitsTag.cpp b/libcore/swf/DefineBitsTag.cpp
new file mode 100644
index 0000000..639a6fa
--- /dev/null
+++ b/libcore/swf/DefineBitsTag.cpp
@@ -0,0 +1,638 @@
+// tag_loaders.cpp: SWF tags loaders, for Gnash.
+//
+//   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
+//   Foundation, Inc
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifdef HAVE_CONFIG_H
+#include "gnashconfig.h" // HAVE_ZLIB_H, USE_SWFTREE
+#endif
+
+#include "tag_loaders.h"
+
+#include <limits>
+#include <cassert>
+#include <boost/static_assert.hpp>
+
+#include "IOChannel.h"
+#include "utility.h"
+#include "log.h"
+#include "SWFStream.h"
+#include "zlib_adapter.h"
+#include "SWFMovieDefinition.h"
+#include "SWF.h"
+#include "swf/TagLoadersTable.h"
+#include "GnashException.h"
+#include "RunResources.h"
+#include "Renderer.h"
+#include "CachedBitmap.h"
+#include "GnashImage.h"
+#include "GnashImageJpeg.h"
+
+#ifdef HAVE_ZLIB_H
+#include <zlib.h>
+#endif
+
+namespace gnash {
+namespace SWF {
+
+/// Anonymous namespace
+namespace {
+
+/// Provide an IOChannel interface around a SWFStream for reading 
+/// embedded image data
+class StreamAdapter : public IOChannel
+{
+    SWFStream& s;
+    std::streampos startPos;
+    std::streampos endPos;
+    std::streampos currPos;
+
+    StreamAdapter(SWFStream& str, std::streampos maxPos)
+        :
+        s(str),
+        startPos(s.tell()),
+        endPos(maxPos),
+        currPos(startPos)
+    {
+        assert(endPos > startPos);
+    }
+
+    virtual ~StreamAdapter() {}
+
+    virtual std::streamsize read(void* dst, std::streamsize bytes) {
+        std::streamsize bytesLeft = endPos - currPos;
+        if (bytesLeft < bytes) {
+            if (!bytesLeft) return 0;
+            //log_debug("Requested to read past end of stream range");
+            bytes = bytesLeft;
+        }
+        std::streamsize actuallyRead = s.read(static_cast<char*>(dst), bytes);
+        currPos += actuallyRead;
+        return actuallyRead;
+    }
+
+    virtual void go_to_end() {
+        s.seek(endPos);
+    }
+
+    virtual bool eof() const {
+        return (currPos == endPos);
+    }
+
+    // Return false on failure, true on success
+    virtual bool seek(std::streampos pos) {
+        // SWFStream::seek() returns true on success
+        if (s.seek(pos)) {
+            currPos = pos;
+            return true;
+        }
+        return false;
+    }
+
+    virtual size_t size() const {
+        return (endPos - startPos);
+    }
+
+    virtual std::streampos tell() const {
+        return currPos;
+    }
+    
+    virtual bool bad() const {
+        // Is there any point in this?
+        return false;
+    }
+
+public:
+
+    /// Get an IOChannel from a gnash::SWFStream
+    static std::auto_ptr<IOChannel> getFile(SWFStream& str,
+            unsigned long endPos) {
+        std::auto_ptr<IOChannel> ret (new StreamAdapter(str, endPos));
+        return ret;
+    }
+};
+
+} // anonymous namespace
+
+// Load JPEG compression tables that can be used to load
+// images further along in the SWFStream.
+void
+jpeg_tables_loader(SWFStream& in, TagType tag, movie_definition& m,
+               const RunResources& /*r*/)
+{
+    assert(tag == SWF::JPEGTABLES);
+
+    IF_VERBOSE_PARSE(
+        log_parse(_("  jpeg_tables_loader"));
+    );
+
+    const std::streampos currPos = in.tell();
+    const std::streampos endPos = in.get_tag_end_position();
+
+    assert(endPos >= currPos);
+
+    const unsigned long jpegHeaderSize = endPos - currPos;
+
+    if (!jpegHeaderSize) {
+        log_debug(_("No bytes to read in JPEGTABLES tag at offset %d"),
+                currPos);
+    }
+
+    std::auto_ptr<image::JpegInput> input;
+
+    try {
+        // NOTE: we cannot limit input SWFStream here as the same jpeg::input
+        // instance will be used for reading subsequent DEFINEBITS and similar
+        // tags, which are *different* tags, so have different boundaries !!
+        //
+        // Anyway the actual reads are limited to currently opened tag as 
+        // of gnash::SWFStream::read(), so this is not a problem.
+        //
+        boost::shared_ptr<IOChannel> ad(StreamAdapter::getFile(in,
+                    std::numeric_limits<std::streamsize>::max()).release());
+        //  transfer ownership to the image::JpegInput
+        input = image::JpegInput::createSWFJpeg2HeaderOnly(ad, jpegHeaderSize);
+
+    }
+    catch (const std::exception& e) {
+        IF_VERBOSE_MALFORMED_SWF(
+            log_swferror("Error creating header-only jpeg2 input: %s",
+                e.what());
+        );
+        return;
+    }
+
+    log_debug("Setting jpeg loader to %p", (void*)input.get());
+    m.set_jpeg_loader(input);
+}
+
+// A JPEG image without included tables; those should be in an
+// existing image::JpegInput object stored in the movie.
+void
+define_bits_jpeg_loader(SWFStream& in, TagType tag, movie_definition& m,
+               const RunResources& r)
+{
+    assert(tag == SWF::DEFINEBITS); // 6
+
+    in.ensureBytes(2);
+    boost::uint16_t id = in.read_u16();
+
+    if (m.getBitmap(id)) {
+        IF_VERBOSE_MALFORMED_SWF(
+            log_swferror(_("DEFINEBITS: Duplicate id (%d) for bitmap "
+                    "DisplayObject - discarding it"), id);
+        );
+        return;
+    }
+
+    // Read the image data.
+    image::JpegInput* j_in = m.get_jpeg_loader();
+    if (!j_in) {
+        IF_VERBOSE_MALFORMED_SWF(
+            log_swferror(_("DEFINEBITS: No jpeg loader registered in movie "
+                    "definition - discarding bitmap DisplayObject %d"), id);
+        );
+        return;
+    }
+
+    j_in->discardPartialBuffer();
+    
+    std::auto_ptr<image::GnashImage> im;
+    try {
+        im = image::JpegInput::readSWFJpeg2WithTables(*j_in);
+    }
+    catch (const std::exception& e) {
+        IF_VERBOSE_MALFORMED_SWF(
+            log_swferror("Error reading jpeg2 with headers for DisplayObject "
+                "id %d: %s", id, e.what());
+        );
+        return;
+    }
+    
+    Renderer* renderer = r.renderer();
+    if (!renderer) {
+        IF_VERBOSE_PARSE(log_parse(_("No renderer, not adding bitmap")));
+        return;
+    }    
+    boost::intrusive_ptr<CachedBitmap> bi = renderer->createCachedBitmap(im);
+
+    // add bitmap to movie under DisplayObject id.
+    m.addBitmap(id, bi);
+}
+
+
+void
+define_bits_jpeg2_loader(SWFStream& in, TagType tag, movie_definition& m,
+               const RunResources& r)
+{
+    assert(tag == SWF::DEFINEBITSJPEG2); // 21
+
+    in.ensureBytes(2);
+    boost::uint16_t id = in.read_u16();
+
+    IF_VERBOSE_PARSE(
+        log_parse(_("  define_bits_jpeg2_loader: charid = %d pos = %ld"),
+              id, in.tell());
+    );
+    
+    if (m.getBitmap(id)) {
+        IF_VERBOSE_MALFORMED_SWF(
+            log_swferror(_("DEFINEBITSJPEG2: Duplicate id (%d) for bitmap "
+                    "DisplayObject - discarding it"), id);
+        );
+        return;
+    }
+
+    char buf[3];
+    if (in.read(buf, 3) < 3) {
+        log_swferror(_("DEFINEBITS data too short to read type header"));
+        return;
+    }
+    in.seek(in.tell() - 3);
+
+    FileType ft = GNASH_FILETYPE_JPEG;  
+
+    // Check the data type. The pp version 9,0,115,0 supports PNG and GIF
+    // in DefineBits tags, though it is not documented. The version makes
+    // no difference.
+    if (std::equal(buf, buf + 3, "\x89PN")) {
+        ft = GNASH_FILETYPE_PNG;
+    }
+    else if (std::equal(buf, buf + 3, "GIF")) {
+        ft = GNASH_FILETYPE_GIF;
+    }
+
+    // Read the image data.
+    boost::shared_ptr<IOChannel> ad(StreamAdapter::getFile(in,
+                in.get_tag_end_position()).release());
+
+    std::auto_ptr<image::GnashImage> im(image::Input::readImageData(ad, ft));
+
+    Renderer* renderer = r.renderer();
+    if (!renderer) {
+        IF_VERBOSE_PARSE(log_parse(_("No renderer, not adding bitmap")));
+        return;
+    }    
+    boost::intrusive_ptr<CachedBitmap> bi = renderer->createCachedBitmap(im);
+
+    // add bitmap to movie under DisplayObject id.
+    m.addBitmap(id, bi);
+
+}
+
+#ifdef HAVE_ZLIB_H
+void inflate_wrapper(SWFStream& 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(buffer);
+    assert(buffer_bytes > 0);
+
+    z_stream d_stream; /* decompression SWFStream */
+
+    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 = static_cast<Byte*>(buffer);
+    d_stream.avail_out = static_cast<uInt>(buffer_bytes);
+
+    int err = inflateInit(&d_stream);
+    if (err != Z_OK) {
+        IF_VERBOSE_MALFORMED_SWF(
+            log_swferror(_("inflate_wrapper() inflateInit() returned %d (%s)"),
+                err, d_stream.msg);
+        );
+        return;
+    }
+
+    const size_t CHUNKSIZE = 256;
+
+    boost::uint8_t buf[CHUNKSIZE];
+    unsigned long endTagPos = in.get_tag_end_position();
+
+    for (;;) {
+        unsigned int chunkSize = CHUNKSIZE;
+        assert(in.tell() <= endTagPos);
+        unsigned int availableBytes =  endTagPos - in.tell();
+        if (availableBytes < chunkSize) {
+            if (!availableBytes) {
+                // nothing more to read
+                IF_VERBOSE_MALFORMED_SWF(
+                    log_swferror(_("inflate_wrapper(): no end of zstream "
+                        "found within swf tag boundaries"));
+                );
+                break;
+            }
+            chunkSize = availableBytes;
+        }
+    
+        BOOST_STATIC_ASSERT(sizeof(char) == sizeof(boost::uint8_t));
+
+        // Fill the buffer    
+        in.read(reinterpret_cast<char*>(buf), chunkSize);
+        d_stream.next_in = &buf[0];
+        d_stream.avail_in = chunkSize;
+
+        err = inflate(&d_stream, Z_SYNC_FLUSH);
+        if (err == Z_STREAM_END) {
+            // correct end
+            break;
+        }
+
+        if (err != Z_OK) {
+            IF_VERBOSE_MALFORMED_SWF(
+                log_swferror(_("inflate_wrapper() inflate() returned %d (%s)"),
+                    err, d_stream.msg);
+            );
+            break;
+        }
+    }
+
+    err = inflateEnd(&d_stream);
+    if (err != Z_OK) {
+        log_error(_("inflate_wrapper() inflateEnd() return %d (%s)"),
+                err, d_stream.msg);
+    }
+}
+#endif // HAVE_ZLIB_H
+
+
+// loads a define_bits_jpeg3 tag. This is a jpeg file with an alpha
+// channel using zlib compression.
+void
+define_bits_jpeg3_loader(SWFStream& in, TagType tag, movie_definition& m,
+               const RunResources& r)
+{
+    assert(tag == SWF::DEFINEBITSJPEG3); // 35
+
+    in.ensureBytes(2);
+    const boost::uint16_t id = in.read_u16();
+
+    IF_VERBOSE_PARSE(
+        log_parse(_("  define_bits_jpeg3_loader: charid = %d pos = %lx"),
+              id, in.tell());
+    );
+
+    in.ensureBytes(4);
+    const boost::uint32_t jpeg_size = in.read_u32();
+    const boost::uint32_t alpha_position = in.tell() + jpeg_size;
+
+#ifndef HAVE_ZLIB_H
+    log_error(_("gnash is not linked to zlib -- can't load jpeg3 image data"));
+    return;
+#else
+
+    // Read rgb data.
+    boost::shared_ptr<IOChannel> ad(StreamAdapter::getFile(in,
+                alpha_position).release());
+    std::auto_ptr<image::ImageRGBA> im = image::Input::readSWFJpeg3(ad);
+    
+    /// Failure to read the jpeg.
+    if (!im.get()) return;
+
+    // Read alpha channel.
+    in.seek(alpha_position);
+
+    const size_t imWidth = im->width();
+    const size_t imHeight = im->height();
+    const size_t bufferLength = imWidth * imHeight;
+
+    boost::scoped_array<boost::uint8_t> buffer(new 
boost::uint8_t[bufferLength]);
+
+    inflate_wrapper(in, buffer.get(), bufferLength);
+
+    // TESTING:
+    // magical trevor contains this tag
+    //  ea8bbad50ccbc52dd734dfc93a7f06a7  6964trev3c.swf
+    image::mergeAlpha(*im, buffer.get(), bufferLength);
+
+    Renderer* renderer = r.renderer();
+    if (!renderer) {
+        IF_VERBOSE_PARSE(log_parse(_("No renderer, not adding bitmap")));
+        return;
+    }    
+    boost::intrusive_ptr<CachedBitmap> bi = renderer->createCachedBitmap(
+            static_cast<std::auto_ptr<image::GnashImage> >(im));
+
+    // add bitmap to movie under DisplayObject id.
+    m.addBitmap(id, bi);
+#endif
+}
+
+
+void
+define_bits_lossless_2_loader(SWFStream& in, TagType tag, movie_definition& m,
+               const RunResources& r)
+{
+    assert(tag == SWF::DEFINELOSSLESS || tag == SWF::DEFINELOSSLESS2);
+    in.ensureBytes(2 + 2 + 2 + 1); // the initial header 
+
+    const boost::uint16_t id = in.read_u16();
+
+    // 3 == 8 bit, 4 == 16 bit, 5 == 32 bit
+    const boost::uint8_t bitmap_format = in.read_u8();
+    const boost::uint16_t width = in.read_u16();
+    const boost::uint16_t height = in.read_u16();
+
+    IF_VERBOSE_PARSE(
+        log_parse(_("  defbitslossless2: tag = %d, id = %d, fmt = %d, "
+                "w = %d, h = %d"), tag, id, bitmap_format, width, height);
+    );
+
+    if (!width || !height) {
+         IF_VERBOSE_MALFORMED_SWF(
+            log_swferror(_("Bitmap DisplayObject %d has a height or width of 
0"),
+                id);
+        );   
+        return;  
+    }
+
+    // No need to parse any further if it already exists, as we aren't going
+    // to add it.
+    if (m.getBitmap(id)) {
+        IF_VERBOSE_MALFORMED_SWF(
+            log_swferror(_("DEFINEBITSLOSSLESS: Duplicate id (%d) "
+                           "for bitmap DisplayObject - discarding it"), id);
+        );
+    }
+
+#ifndef HAVE_ZLIB_H
+    log_error(_("gnash is not linked to zlib -- can't load zipped image 
data"));
+    return;
+#else
+
+    unsigned short channels;
+    std::auto_ptr<image::GnashImage> image;
+    bool alpha = false;
+
+    try {
+        switch (tag) {
+            case SWF::DEFINELOSSLESS:
+                image.reset(new image::ImageRGB(width, height));
+                channels = 3;
+                break;
+            case SWF::DEFINELOSSLESS2:
+                image.reset(new image::ImageRGBA(width, height));
+                channels = 4;
+                alpha = true;
+                break;
+            default:
+                // This is already asserted.
+                std::abort();
+        }
+    }
+    catch (const std::bad_alloc&) {
+        // Image constructors will throw bad_alloc if they don't like the
+        // size. This isn't usually from operator new.
+        log_error(_("Will not allocate %1%x%2% image in DefineBitsLossless "
+                "tag"), width, height);
+        return;
+    }
+
+    unsigned short bytes_per_pixel;
+    int colorTableSize = 0;
+
+    switch (bitmap_format) {
+        case 3:
+            bytes_per_pixel = 1;
+            in.ensureBytes(1);
+            // SWF stores one less than the actual size.
+            colorTableSize = in.read_u8() + 1;
+            break;
+
+        case 4:
+            bytes_per_pixel = 2;
+            break;
+
+        case 5:
+            bytes_per_pixel = 4;
+            break;
+
+        default:
+            log_error(_("Unknown bitmap format. Ignoring"));
+            return;
+    }
+
+    const size_t pitch = (width * bytes_per_pixel + 3) &~ 3;
+    const size_t bufSize = colorTableSize * channels + pitch * height;
+    boost::scoped_array<boost::uint8_t> buffer(new boost::uint8_t[bufSize]);
+
+    inflate_wrapper(in, buffer.get(), bufSize);
+    assert(in.tell() <= in.get_tag_end_position());
+
+    switch (bitmap_format) {
+
+        case 3:
+        {
+            // 8-bit data, preceded by a palette.
+            boost::uint8_t* colorTable = buffer.get();
+
+            for (size_t j = 0; j < height; ++j) {
+                boost::uint8_t* inRow = buffer.get() + 
+                    colorTableSize * channels + j * pitch;
+
+                boost::uint8_t* outRow = scanline(*image, j);
+                for (size_t i = 0; i < width; ++i) {
+                    boost::uint8_t pixel = inRow[i * bytes_per_pixel];
+                    outRow[i * channels + 0] = colorTable[pixel * channels + 
0];
+                    outRow[i * channels + 1] = colorTable[pixel * channels + 
1];
+                    outRow[i * channels + 2] = colorTable[pixel * channels + 
2];
+                    if (alpha) {
+                        outRow[i * channels + 3] =
+                            colorTable[pixel * channels + 3];
+                    }
+                }
+            }
+            break;
+        }
+
+        case 4:
+            // 16 bits / pixel
+
+            for (size_t j = 0; j < height; ++j) {
+
+                boost::uint8_t* inRow = buffer.get() + j * pitch;
+                boost::uint8_t* outRow = scanline(*image, j);
+                for (size_t i = 0; i < width; ++i) {
+                    const boost::uint16_t pixel = inRow[i * 2] |
+                        (inRow[i * 2 + 1] << 8);
+
+                    // How is the data packed??? Whoever wrote this was
+                    // just guessing here that it's 565!
+                    outRow[i * channels + 0] = (pixel >> 8) & 0xF8;    // red
+                    outRow[i * channels + 1] = (pixel >> 3) & 0xFC;    // green
+                    outRow[i * channels + 2] = (pixel << 3) & 0xF8;    // blue
+ 
+                    // This was saved to the first byte before, but that
+                    // can hardly be correct.
+                    // Real examples of this format are rare to non-existent.
+                    if (alpha) {
+                        outRow[i * channels + 3] = 255;
+                    }
+                }
+            }
+            break;
+
+        case 5:
+            // Need to re-arrange ARGB into RGB or RGBA.
+            for (size_t j = 0; j < height; ++j) {
+                boost::uint8_t* inRow = buffer.get() + j * pitch;
+                boost::uint8_t* outRow = scanline(*image, j);
+                const int inChannels = 4;
+
+                for (size_t i = 0; i < width; ++i) {
+                    // Copy pixels 1-3.
+                    std::copy(&inRow[i * inChannels + 1],
+                            &inRow[i * inChannels + 4], &outRow[i * channels]);
+
+                    // Add the alpha channel if necessary.
+                    if (alpha) {
+                        outRow[i * channels + 3] = inRow[i * 4];
+                    }
+                }
+            }
+            break;
+
+    }
+
+    Renderer* renderer = r.renderer();
+    if (!renderer) {
+        IF_VERBOSE_PARSE(log_parse(_("No renderer, not adding bitmap")));
+        return;
+    }    
+    boost::intrusive_ptr<CachedBitmap> bi = 
renderer->createCachedBitmap(image);
+
+    // add bitmap to movie under DisplayObject id.
+    m.addBitmap(id, bi);
+#endif // HAVE_ZLIB_H
+
+}
+
+} // namespace gnash::SWF
+} // namespace gnash
+
+// Local Variables:
+// mode: C++
+// indent-tabs-mode: t
+// End:
+
diff --git a/libcore/swf/DefineBitsTag.h b/libcore/swf/DefineBitsTag.h
new file mode 100644
index 0000000..59e962e
--- /dev/null
+++ b/libcore/swf/DefineBitsTag.h
@@ -0,0 +1,59 @@
+// 
+//   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
+//   Foundation, Inc
+// 
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+
+#ifndef GNASH_SWF_DEFINEBITSTAG_H
+#define GNASH_SWF_DEFINEBITSTAG_H
+
+#include "SWF.h" 
+
+// Forward declarations
+namespace gnash {
+    class movie_definition;
+    class RunResources;
+    class SWFStream;
+}
+
+namespace gnash {
+namespace SWF {
+
+void jpeg_tables_loader(SWFStream&, TagType, movie_definition&,
+               const RunResources&);
+
+void define_bits_jpeg_loader(SWFStream&, TagType, movie_definition&,
+               const RunResources&);
+
+void define_bits_jpeg2_loader(SWFStream&, TagType, movie_definition&,
+               const RunResources&);
+
+void define_bits_jpeg3_loader(SWFStream&, TagType, movie_definition&,
+               const RunResources&);
+
+void define_bits_lossless_2_loader(SWFStream&, TagType, movie_definition&,
+               const RunResources&);
+
+} // namespace SWF
+} // namespace gnash
+
+
+#endif 
+
+// Local Variables:
+// mode: C++
+// indent-tabs-mode: t
+// End:
diff --git a/libcore/swf/tag_loaders.cpp b/libcore/swf/tag_loaders.cpp
index 27ff5df..c74ad55 100644
--- a/libcore/swf/tag_loaders.cpp
+++ b/libcore/swf/tag_loaders.cpp
@@ -24,21 +24,12 @@
 
 #include "tag_loaders.h"
 
-#include <set>
-#include <limits>
 #include <cassert>
-#include <utility> // for std::make_pair
-#include <boost/static_assert.hpp>
 
-#include "IOChannel.h"
 #include "utility.h"
-#include "action_buffer.h"
-#include "Font.h"
 #include "log.h"
 #include "SWFStream.h"
-#include "zlib_adapter.h"
 #include "sprite_definition.h"
-#include "MovieClip.h"
 #include "SWFMovieDefinition.h"
 #include "SWF.h"
 #include "swf/TagLoadersTable.h"
@@ -50,97 +41,13 @@
 #include "SimpleBuffer.h"
 #include "sound_handler.h"
 #include "RunResources.h"
-#include "Renderer.h"
-#include "Movie.h"
-#include "CachedBitmap.h"
-#include "GnashImage.h"
-#include "GnashImageJpeg.h"
-
-#ifdef HAVE_ZLIB_H
-#include <zlib.h>
-#endif
 
 namespace gnash {
-
 namespace SWF {
 
 /// Anonymous namespace
 namespace {
 
-/// Provide an IOChannel interface around a SWFStream for reading 
-/// embedded image data
-class StreamAdapter : public IOChannel
-{
-    SWFStream& s;
-    std::streampos startPos;
-    std::streampos endPos;
-    std::streampos currPos;
-
-    StreamAdapter(SWFStream& str, std::streampos maxPos)
-        :
-        s(str),
-        startPos(s.tell()),
-        endPos(maxPos),
-        currPos(startPos)
-    {
-        assert(endPos > startPos);
-    }
-
-    virtual ~StreamAdapter() {}
-
-    virtual std::streamsize read(void* dst, std::streamsize bytes) {
-        std::streamsize bytesLeft = endPos - currPos;
-        if (bytesLeft < bytes) {
-            if (!bytesLeft) return 0;
-            //log_debug("Requested to read past end of stream range");
-            bytes = bytesLeft;
-        }
-        std::streamsize actuallyRead = s.read(static_cast<char*>(dst), bytes);
-        currPos += actuallyRead;
-        return actuallyRead;
-    }
-
-    virtual void go_to_end() {
-        s.seek(endPos);
-    }
-
-    virtual bool eof() const {
-        return (currPos == endPos);
-    }
-
-    // Return false on failure, true on success
-    virtual bool seek(std::streampos pos) {
-        // SWFStream::seek() returns true on success
-        if (s.seek(pos)) {
-            currPos = pos;
-            return true;
-        }
-        return false;
-    }
-
-    virtual size_t size() const {
-        return (endPos - startPos);
-    }
-
-    virtual std::streampos tell() const {
-        return currPos;
-    }
-    
-    virtual bool bad() const {
-        // Is there any point in this?
-        return false;
-    }
-
-public:
-
-    /// Get an IOChannel from a gnash::SWFStream
-    static std::auto_ptr<IOChannel> getFile(SWFStream& str,
-            unsigned long endPos) {
-        std::auto_ptr<IOChannel> ret (new StreamAdapter(str, endPos));
-        return ret;
-    }
-};
-
 const boost::uint32_t samplerates[] = { 5512, 11025, 22050, 44100 };
 
 } // anonymous namespace
@@ -185,506 +92,6 @@ frame_label_loader(SWFStream& in, TagType tag, 
movie_definition& m,
     }
 }
 
-// Load JPEG compression tables that can be used to load
-// images further along in the SWFStream.
-void
-jpeg_tables_loader(SWFStream& in, TagType tag, movie_definition& m,
-               const RunResources& /*r*/)
-{
-    assert(tag == SWF::JPEGTABLES);
-
-    IF_VERBOSE_PARSE(
-        log_parse(_("  jpeg_tables_loader"));
-    );
-
-    const std::streampos currPos = in.tell();
-    const std::streampos endPos = in.get_tag_end_position();
-
-    assert(endPos >= currPos);
-
-    const unsigned long jpegHeaderSize = endPos - currPos;
-
-    if (!jpegHeaderSize) {
-        log_debug(_("No bytes to read in JPEGTABLES tag at offset %d"),
-                currPos);
-    }
-
-    std::auto_ptr<image::JpegInput> input;
-
-    try {
-        // NOTE: we cannot limit input SWFStream here as the same jpeg::input
-        // instance will be used for reading subsequent DEFINEBITS and similar
-        // tags, which are *different* tags, so have different boundaries !!
-        //
-        // Anyway the actual reads are limited to currently opened tag as 
-        // of gnash::SWFStream::read(), so this is not a problem.
-        //
-        boost::shared_ptr<IOChannel> ad(StreamAdapter::getFile(in,
-                    std::numeric_limits<std::streamsize>::max()).release());
-        //  transfer ownership to the image::JpegInput
-        input = image::JpegInput::createSWFJpeg2HeaderOnly(ad, jpegHeaderSize);
-
-    }
-    catch (const std::exception& e) {
-        IF_VERBOSE_MALFORMED_SWF(
-            log_swferror("Error creating header-only jpeg2 input: %s",
-                e.what());
-        );
-        return;
-    }
-
-    log_debug("Setting jpeg loader to %p", (void*)input.get());
-    m.set_jpeg_loader(input);
-}
-
-
-// A JPEG image without included tables; those should be in an
-// existing image::JpegInput object stored in the movie.
-void
-define_bits_jpeg_loader(SWFStream& in, TagType tag, movie_definition& m,
-               const RunResources& r)
-{
-    assert(tag == SWF::DEFINEBITS); // 6
-
-    in.ensureBytes(2);
-    boost::uint16_t id = in.read_u16();
-
-    if (m.getBitmap(id)) {
-        IF_VERBOSE_MALFORMED_SWF(
-            log_swferror(_("DEFINEBITS: Duplicate id (%d) for bitmap "
-                    "DisplayObject - discarding it"), id);
-        );
-        return;
-    }
-
-    // Read the image data.
-    image::JpegInput* j_in = m.get_jpeg_loader();
-    if (!j_in) {
-        IF_VERBOSE_MALFORMED_SWF(
-            log_swferror(_("DEFINEBITS: No jpeg loader registered in movie "
-                    "definition - discarding bitmap DisplayObject %d"), id);
-        );
-        return;
-    }
-
-    j_in->discardPartialBuffer();
-    
-    std::auto_ptr<image::GnashImage> im;
-    try {
-        im = image::JpegInput::readSWFJpeg2WithTables(*j_in);
-    }
-    catch (const std::exception& e) {
-        IF_VERBOSE_MALFORMED_SWF(
-            log_swferror("Error reading jpeg2 with headers for DisplayObject "
-                "id %d: %s", id, e.what());
-        );
-        return;
-    }
-    
-    Renderer* renderer = r.renderer();
-    if (!renderer) {
-        IF_VERBOSE_PARSE(log_parse(_("No renderer, not adding bitmap")));
-        return;
-    }    
-    boost::intrusive_ptr<CachedBitmap> bi = renderer->createCachedBitmap(im);
-
-    // add bitmap to movie under DisplayObject id.
-    m.addBitmap(id, bi);
-}
-
-
-void
-define_bits_jpeg2_loader(SWFStream& in, TagType tag, movie_definition& m,
-               const RunResources& r)
-{
-    assert(tag == SWF::DEFINEBITSJPEG2); // 21
-
-    in.ensureBytes(2);
-    boost::uint16_t id = in.read_u16();
-
-    IF_VERBOSE_PARSE(
-        log_parse(_("  define_bits_jpeg2_loader: charid = %d pos = %ld"),
-              id, in.tell());
-    );
-    
-    if (m.getBitmap(id)) {
-        IF_VERBOSE_MALFORMED_SWF(
-            log_swferror(_("DEFINEBITSJPEG2: Duplicate id (%d) for bitmap "
-                    "DisplayObject - discarding it"), id);
-        );
-        return;
-    }
-
-    char buf[3];
-    if (in.read(buf, 3) < 3) {
-        log_swferror(_("DEFINEBITS data too short to read type header"));
-        return;
-    }
-    in.seek(in.tell() - 3);
-
-    FileType ft = GNASH_FILETYPE_JPEG;  
-
-    // Check the data type. The pp version 9,0,115,0 supports PNG and GIF
-    // in DefineBits tags, though it is not documented. The version makes
-    // no difference.
-    if (std::equal(buf, buf + 3, "\x89PN")) {
-        ft = GNASH_FILETYPE_PNG;
-    }
-    else if (std::equal(buf, buf + 3, "GIF")) {
-        ft = GNASH_FILETYPE_GIF;
-    }
-
-    // Read the image data.
-    boost::shared_ptr<IOChannel> ad(StreamAdapter::getFile(in,
-                in.get_tag_end_position()).release());
-
-    std::auto_ptr<image::GnashImage> im(image::Input::readImageData(ad, ft));
-
-    Renderer* renderer = r.renderer();
-    if (!renderer) {
-        IF_VERBOSE_PARSE(log_parse(_("No renderer, not adding bitmap")));
-        return;
-    }    
-    boost::intrusive_ptr<CachedBitmap> bi = renderer->createCachedBitmap(im);
-
-    // add bitmap to movie under DisplayObject id.
-    m.addBitmap(id, bi);
-
-}
-
-
-#ifdef HAVE_ZLIB_H
-void inflate_wrapper(SWFStream& 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(buffer);
-    assert(buffer_bytes > 0);
-
-    z_stream d_stream; /* decompression SWFStream */
-
-    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 = static_cast<Byte*>(buffer);
-    d_stream.avail_out = static_cast<uInt>(buffer_bytes);
-
-    int err = inflateInit(&d_stream);
-    if (err != Z_OK) {
-        IF_VERBOSE_MALFORMED_SWF(
-            log_swferror(_("inflate_wrapper() inflateInit() returned %d (%s)"),
-                err, d_stream.msg);
-        );
-        return;
-    }
-
-    const size_t CHUNKSIZE = 256;
-
-    boost::uint8_t buf[CHUNKSIZE];
-    unsigned long endTagPos = in.get_tag_end_position();
-
-    for (;;) {
-        unsigned int chunkSize = CHUNKSIZE;
-        assert(in.tell() <= endTagPos);
-        unsigned int availableBytes =  endTagPos - in.tell();
-        if (availableBytes < chunkSize) {
-            if (!availableBytes) {
-                // nothing more to read
-                IF_VERBOSE_MALFORMED_SWF(
-                    log_swferror(_("inflate_wrapper(): no end of zstream "
-                        "found within swf tag boundaries"));
-                );
-                break;
-            }
-            chunkSize = availableBytes;
-        }
-    
-        BOOST_STATIC_ASSERT(sizeof(char) == sizeof(boost::uint8_t));
-
-        // Fill the buffer    
-        in.read(reinterpret_cast<char*>(buf), chunkSize);
-        d_stream.next_in = &buf[0];
-        d_stream.avail_in = chunkSize;
-
-        err = inflate(&d_stream, Z_SYNC_FLUSH);
-        if (err == Z_STREAM_END) {
-            // correct end
-            break;
-        }
-
-        if (err != Z_OK) {
-            IF_VERBOSE_MALFORMED_SWF(
-                log_swferror(_("inflate_wrapper() inflate() returned %d (%s)"),
-                    err, d_stream.msg);
-            );
-            break;
-        }
-    }
-
-    err = inflateEnd(&d_stream);
-    if (err != Z_OK) {
-        log_error(_("inflate_wrapper() inflateEnd() return %d (%s)"),
-                err, d_stream.msg);
-    }
-}
-#endif // HAVE_ZLIB_H
-
-
-// loads a define_bits_jpeg3 tag. This is a jpeg file with an alpha
-// channel using zlib compression.
-void
-define_bits_jpeg3_loader(SWFStream& in, TagType tag, movie_definition& m,
-               const RunResources& r)
-{
-    assert(tag == SWF::DEFINEBITSJPEG3); // 35
-
-    in.ensureBytes(2);
-    const boost::uint16_t id = in.read_u16();
-
-    IF_VERBOSE_PARSE(
-        log_parse(_("  define_bits_jpeg3_loader: charid = %d pos = %lx"),
-              id, in.tell());
-    );
-
-    in.ensureBytes(4);
-    const boost::uint32_t jpeg_size = in.read_u32();
-    const boost::uint32_t alpha_position = in.tell() + jpeg_size;
-
-#ifndef HAVE_ZLIB_H
-    log_error(_("gnash is not linked to zlib -- can't load jpeg3 image data"));
-    return;
-#else
-
-    // Read rgb data.
-    boost::shared_ptr<IOChannel> ad(StreamAdapter::getFile(in,
-                alpha_position).release());
-    std::auto_ptr<image::ImageRGBA> im = image::Input::readSWFJpeg3(ad);
-    
-    /// Failure to read the jpeg.
-    if (!im.get()) return;
-
-    // Read alpha channel.
-    in.seek(alpha_position);
-
-    const size_t imWidth = im->width();
-    const size_t imHeight = im->height();
-    const size_t bufferLength = imWidth * imHeight;
-
-    boost::scoped_array<boost::uint8_t> buffer(new 
boost::uint8_t[bufferLength]);
-
-    inflate_wrapper(in, buffer.get(), bufferLength);
-
-    // TESTING:
-    // magical trevor contains this tag
-    //  ea8bbad50ccbc52dd734dfc93a7f06a7  6964trev3c.swf
-    image::mergeAlpha(*im, buffer.get(), bufferLength);
-
-    Renderer* renderer = r.renderer();
-    if (!renderer) {
-        IF_VERBOSE_PARSE(log_parse(_("No renderer, not adding bitmap")));
-        return;
-    }    
-    boost::intrusive_ptr<CachedBitmap> bi = renderer->createCachedBitmap(
-            static_cast<std::auto_ptr<image::GnashImage> >(im));
-
-    // add bitmap to movie under DisplayObject id.
-    m.addBitmap(id, bi);
-#endif
-}
-
-
-void
-define_bits_lossless_2_loader(SWFStream& in, TagType tag, movie_definition& m,
-               const RunResources& r)
-{
-    assert(tag == SWF::DEFINELOSSLESS || tag == SWF::DEFINELOSSLESS2);
-    in.ensureBytes(2 + 2 + 2 + 1); // the initial header 
-
-    const boost::uint16_t id = in.read_u16();
-
-    // 3 == 8 bit, 4 == 16 bit, 5 == 32 bit
-    const boost::uint8_t bitmap_format = in.read_u8();
-    const boost::uint16_t width = in.read_u16();
-    const boost::uint16_t height = in.read_u16();
-
-    IF_VERBOSE_PARSE(
-        log_parse(_("  defbitslossless2: tag = %d, id = %d, fmt = %d, "
-                "w = %d, h = %d"), tag, id, bitmap_format, width, height);
-    );
-
-    if (!width || !height) {
-         IF_VERBOSE_MALFORMED_SWF(
-            log_swferror(_("Bitmap DisplayObject %d has a height or width of 
0"),
-                id);
-        );   
-        return;  
-    }
-
-    // No need to parse any further if it already exists, as we aren't going
-    // to add it.
-    if (m.getBitmap(id)) {
-        IF_VERBOSE_MALFORMED_SWF(
-            log_swferror(_("DEFINEBITSLOSSLESS: Duplicate id (%d) "
-                           "for bitmap DisplayObject - discarding it"), id);
-        );
-    }
-
-#ifndef HAVE_ZLIB_H
-    log_error(_("gnash is not linked to zlib -- can't load zipped image 
data"));
-    return;
-#else
-
-    unsigned short channels;
-    std::auto_ptr<image::GnashImage> image;
-    bool alpha = false;
-
-    try {
-        switch (tag) {
-            case SWF::DEFINELOSSLESS:
-                image.reset(new image::ImageRGB(width, height));
-                channels = 3;
-                break;
-            case SWF::DEFINELOSSLESS2:
-                image.reset(new image::ImageRGBA(width, height));
-                channels = 4;
-                alpha = true;
-                break;
-            default:
-                // This is already asserted.
-                std::abort();
-        }
-    }
-    catch (const std::bad_alloc&) {
-        // Image constructors will throw bad_alloc if they don't like the
-        // size. This isn't usually from operator new.
-        log_error(_("Will not allocate %1%x%2% image in DefineBitsLossless "
-                "tag"), width, height);
-        return;
-    }
-
-    unsigned short bytes_per_pixel;
-    int colorTableSize = 0;
-
-    switch (bitmap_format) {
-        case 3:
-            bytes_per_pixel = 1;
-            in.ensureBytes(1);
-            // SWF stores one less than the actual size.
-            colorTableSize = in.read_u8() + 1;
-            break;
-
-        case 4:
-            bytes_per_pixel = 2;
-            break;
-
-        case 5:
-            bytes_per_pixel = 4;
-            break;
-
-        default:
-            log_error(_("Unknown bitmap format. Ignoring"));
-            return;
-    }
-
-    const size_t pitch = (width * bytes_per_pixel + 3) &~ 3;
-    const size_t bufSize = colorTableSize * channels + pitch * height;
-    boost::scoped_array<boost::uint8_t> buffer(new boost::uint8_t[bufSize]);
-
-    inflate_wrapper(in, buffer.get(), bufSize);
-    assert(in.tell() <= in.get_tag_end_position());
-
-    switch (bitmap_format) {
-
-        case 3:
-        {
-            // 8-bit data, preceded by a palette.
-            boost::uint8_t* colorTable = buffer.get();
-
-            for (size_t j = 0; j < height; ++j) {
-                boost::uint8_t* inRow = buffer.get() + 
-                    colorTableSize * channels + j * pitch;
-
-                boost::uint8_t* outRow = scanline(*image, j);
-                for (size_t i = 0; i < width; ++i) {
-                    boost::uint8_t pixel = inRow[i * bytes_per_pixel];
-                    outRow[i * channels + 0] = colorTable[pixel * channels + 
0];
-                    outRow[i * channels + 1] = colorTable[pixel * channels + 
1];
-                    outRow[i * channels + 2] = colorTable[pixel * channels + 
2];
-                    if (alpha) {
-                        outRow[i * channels + 3] =
-                            colorTable[pixel * channels + 3];
-                    }
-                }
-            }
-            break;
-        }
-
-        case 4:
-            // 16 bits / pixel
-
-            for (size_t j = 0; j < height; ++j) {
-
-                boost::uint8_t* inRow = buffer.get() + j * pitch;
-                boost::uint8_t* outRow = scanline(*image, j);
-                for (size_t i = 0; i < width; ++i) {
-                    const boost::uint16_t pixel = inRow[i * 2] |
-                        (inRow[i * 2 + 1] << 8);
-
-                    // How is the data packed??? Whoever wrote this was
-                    // just guessing here that it's 565!
-                    outRow[i * channels + 0] = (pixel >> 8) & 0xF8;    // red
-                    outRow[i * channels + 1] = (pixel >> 3) & 0xFC;    // green
-                    outRow[i * channels + 2] = (pixel << 3) & 0xF8;    // blue
- 
-                    // This was saved to the first byte before, but that
-                    // can hardly be correct.
-                    // Real examples of this format are rare to non-existent.
-                    if (alpha) {
-                        outRow[i * channels + 3] = 255;
-                    }
-                }
-            }
-            break;
-
-        case 5:
-            // Need to re-arrange ARGB into RGB or RGBA.
-            for (size_t j = 0; j < height; ++j) {
-                boost::uint8_t* inRow = buffer.get() + j * pitch;
-                boost::uint8_t* outRow = scanline(*image, j);
-                const int inChannels = 4;
-
-                for (size_t i = 0; i < width; ++i) {
-                    // Copy pixels 1-3.
-                    std::copy(&inRow[i * inChannels + 1],
-                            &inRow[i * inChannels + 4], &outRow[i * channels]);
-
-                    // Add the alpha channel if necessary.
-                    if (alpha) {
-                        outRow[i * channels + 3] = inRow[i * 4];
-                    }
-                }
-            }
-            break;
-
-    }
-
-    Renderer* renderer = r.renderer();
-    if (!renderer) {
-        IF_VERBOSE_PARSE(log_parse(_("No renderer, not adding bitmap")));
-        return;
-    }    
-    boost::intrusive_ptr<CachedBitmap> bi = 
renderer->createCachedBitmap(image);
-
-    // add bitmap to movie under DisplayObject id.
-    m.addBitmap(id, bi);
-#endif // HAVE_ZLIB_H
-
-}
 
 // Create and initialize a sprite, and add it to the movie.
 void
diff --git a/libcore/swf/tag_loaders.h b/libcore/swf/tag_loaders.h
index e6f8b7f..881e1d5 100644
--- a/libcore/swf/tag_loaders.h
+++ b/libcore/swf/tag_loaders.h
@@ -21,63 +21,28 @@
 #define GNASH_SWF_TAG_LOADERS_H
 
 #include "SWF.h" 
-#include "SWFStream.h"
-
-#include <cassert>
 
 // Forward declarations
 namespace gnash {
     class movie_definition;
     class RunResources;
+    class SWFStream;
 }
 
 namespace gnash {
 namespace SWF {
 
-/// Silently ignore the contents of this tag.
-void null_loader(SWFStream&, TagType, movie_definition&, const RunResources&);
-
-/// \brief
-/// Load JPEG compression tables that can be used to load
-/// images further along in the SWFStream. (SWF::JPEGTABLES)
-void jpeg_tables_loader(SWFStream&, TagType, movie_definition&,
-               const RunResources&);
-
-/// \brief
-/// A JPEG image without included tables; those should be in an
-/// existing jpeg::input object stored in the movie. (SWF::DEFINEBITS)
-void define_bits_jpeg_loader(SWFStream&, TagType, movie_definition&,
-               const RunResources&);
-
-/// Handler for SWF::DEFINEBITSJPEG2 tag
-void define_bits_jpeg2_loader(SWFStream&, TagType, movie_definition&,
-               const RunResources&);
-
-/// \brief
-/// Loads a define_bits_jpeg3 tag. This is a jpeg file with an alpha
-/// channel using zlib compression. (SWF::DEFINEBITSJPEG3)
-void define_bits_jpeg3_loader(SWFStream&, TagType, movie_definition&,
-               const RunResources&);
-
 /// SWF Tags Reflex (777)
 //
 void reflex_loader(SWFStream&, TagType, movie_definition&,
                const RunResources&);
 
-void define_bits_lossless_2_loader(SWFStream&, TagType, movie_definition&,
-               const RunResources&);
-
 /// Create and initialize a sprite, and add it to the movie. 
 //
 /// Handles a SWF::DEFINESPRITE tag
 ///
 void sprite_loader(SWFStream&, TagType, movie_definition&, const 
RunResources&);
 
-void remove_object_2_loader(SWFStream&, TagType, movie_definition&,
-               const RunResources&);
-
-void do_action_loader(SWFStream&, TagType, movie_definition&, const 
RunResources&);
-
 /// Label the current frame  (SWF::FRAMELABEL)
 void frame_label_loader(SWFStream&, TagType, movie_definition&,
                const RunResources&);
@@ -86,25 +51,10 @@ void frame_label_loader(SWFStream&, TagType, 
movie_definition&,
 void define_sound_loader(SWFStream&, TagType, movie_definition&,
                const RunResources&);
 
-void do_init_action_loader(SWFStream&, TagType, movie_definition&,
-               const RunResources&);
-
 /// Load SWF::SOUNDSTREAMHEAD or SWF::SOUNDSTREAMHEAD2 tag.
 void sound_stream_head_loader(SWFStream&, TagType, movie_definition&,
                const RunResources&);
 
-/// Load a SWF::SOUNDSTREAMBLOCK tag.
-void sound_stream_block_loader(SWFStream&, TagType, movie_definition&,
-               const RunResources&);
-
-void
-define_video_loader(SWFStream& in, TagType tag, movie_definition& m,
-               const RunResources& r);
-
-void
-video_loader(SWFStream& in, TagType tag, movie_definition& m,
-               const RunResources& r);
-
 void
 file_attributes_loader(SWFStream& in, TagType tag, movie_definition& m,
                const RunResources& r);

-----------------------------------------------------------------------

Summary of changes:
 libbase/GnashImageGif.cpp                          |  200 +++---
 libbase/GnashImageGif.h                            |   10 +-
 libcore/Makefile.am                                |    2 +
 libcore/swf/DefaultTagLoaders.cpp                  |   22 +-
 libcore/swf/DefineBitsTag.cpp                      |  665 ++++++++++++++++++++
 .../swf/{CSMTextSettingsTag.h => DefineBitsTag.h}  |   31 +-
 libcore/swf/tag_loaders.cpp                        |  593 -----------------
 libcore/swf/tag_loaders.h                          |   52 +--
 8 files changed, 809 insertions(+), 766 deletions(-)
 create mode 100644 libcore/swf/DefineBitsTag.cpp
 copy libcore/swf/{CSMTextSettingsTag.h => DefineBitsTag.h} (70%)


hooks/post-receive
-- 
Gnash



reply via email to

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