gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog backend/render_handler_agg.cpp ...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog backend/render_handler_agg.cpp ...
Date: Mon, 10 Sep 2007 16:53:30 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/09/10 16:53:30

Modified files:
        .              : ChangeLog 
        backend        : render_handler_agg.cpp render_handler_cairo.cpp 
                         render_handler_ogl.cpp 
        libbase        : embedVideoDecoderFfmpeg.cpp 
                         embedVideoDecoderGst.cpp image.cpp image.h 
                         image_filters.cpp 
        server         : FreetypeGlyphsProvider.cpp bitmap_info.h 
                         fill_style.cpp fontlib.cpp fontlib.h 
        server/asobj   : NetStream.cpp NetStreamFfmpeg.cpp 
        server/parser  : BitmapMovieDefinition.cpp 
        server/swf     : tag_loaders.cpp 

Log message:
                * server/bitmap_info.h: drop OGL-specific members.
                * libbase/image.{cpp,h}: cleanup the image_base interface:
                  - make more members private to reduce chaces of buffer size
                    and associated size-describing members mismatch (still more
                    to do)
                  - add more methods from statics which do not have access
                    to now-private members
                * backend/render_handler_ogl.cpp: add OGL-specific members
                  to bitmap_info_ogl, update uses of image_base.
                * backend/render_handler_agg.cpp, 
libbase/embedVideoDecoderFfmpeg.cpp,
                  libbase/embedVideoDecoderGst.cpp, libbase/image_filters.cpp,
                  server/FreetypeGlyphsProvider.cpp, fill_style.cpp,
                  server/fontlib.{cpp,h}, 
server/parser/BitmapMovieDefinition.cpp,
                  server/swf/tag_loaders.cpp, server/asobj/NetStream.cpp,
                  server/asobj/NetStreamFfmpeg.cpp, 
backend/render_handler_cairo.cpp:
                  Update uses of image_base

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4262&r2=1.4263
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/render_handler_agg.cpp?cvsroot=gnash&r1=1.107&r2=1.108
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/render_handler_cairo.cpp?cvsroot=gnash&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/render_handler_ogl.cpp?cvsroot=gnash&r1=1.76&r2=1.77
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/embedVideoDecoderFfmpeg.cpp?cvsroot=gnash&r1=1.21&r2=1.22
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/embedVideoDecoderGst.cpp?cvsroot=gnash&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/image.cpp?cvsroot=gnash&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/image.h?cvsroot=gnash&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/image_filters.cpp?cvsroot=gnash&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/gnash/server/FreetypeGlyphsProvider.cpp?cvsroot=gnash&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gnash/server/bitmap_info.h?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/server/fill_style.cpp?cvsroot=gnash&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/gnash/server/fontlib.cpp?cvsroot=gnash&r1=1.33&r2=1.34
http://cvs.savannah.gnu.org/viewcvs/gnash/server/fontlib.h?cvsroot=gnash&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStream.cpp?cvsroot=gnash&r1=1.70&r2=1.71
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStreamFfmpeg.cpp?cvsroot=gnash&r1=1.89&r2=1.90
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/BitmapMovieDefinition.cpp?cvsroot=gnash&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf/tag_loaders.cpp?cvsroot=gnash&r1=1.136&r2=1.137

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.4262
retrieving revision 1.4263
diff -u -b -r1.4262 -r1.4263
--- ChangeLog   10 Sep 2007 14:34:10 -0000      1.4262
+++ ChangeLog   10 Sep 2007 16:53:28 -0000      1.4263
@@ -1,5 +1,24 @@
 2007-09-10 Sandro Santilli <address@hidden>
 
+       * server/bitmap_info.h: drop OGL-specific members.
+       * libbase/image.{cpp,h}: cleanup the image_base interface:
+         - make more members private to reduce chaces of buffer size
+           and associated size-describing members mismatch (still more
+           to do)
+         - add more methods from statics which do not have access
+           to now-private members 
+       * backend/render_handler_ogl.cpp: add OGL-specific members
+         to bitmap_info_ogl, update uses of image_base.
+       * backend/render_handler_agg.cpp, libbase/embedVideoDecoderFfmpeg.cpp,
+         libbase/embedVideoDecoderGst.cpp, libbase/image_filters.cpp,
+         server/FreetypeGlyphsProvider.cpp, fill_style.cpp,
+         server/fontlib.{cpp,h}, server/parser/BitmapMovieDefinition.cpp,
+         server/swf/tag_loaders.cpp, server/asobj/NetStream.cpp,
+         server/asobj/NetStreamFfmpeg.cpp, backend/render_handler_cairo.cpp:
+         Update uses of image_base
+
+2007-09-10 Sandro Santilli <address@hidden>
+
        * server/asobj/NetStreamGst.cpp (GstInstallPluginsResultCb): comment
          out unused parameter and garbage message.
        * server/parser/video_stream_def.cpp (dtor): delete [] since we

Index: backend/render_handler_agg.cpp
===================================================================
RCS file: /sources/gnash/gnash/backend/render_handler_agg.cpp,v
retrieving revision 1.107
retrieving revision 1.108
diff -u -b -r1.107 -r1.108
--- backend/render_handler_agg.cpp      3 Sep 2007 11:46:42 -0000       1.107
+++ backend/render_handler_agg.cpp      10 Sep 2007 16:53:29 -0000      1.108
@@ -17,7 +17,7 @@
 
  
 
-/* $Id: render_handler_agg.cpp,v 1.107 2007/09/03 11:46:42 udog Exp $ */
+/* $Id: render_handler_agg.cpp,v 1.108 2007/09/10 16:53:29 strk Exp $ */
 
 // Original version by Udo Giacomozzi and Hannes Mayr, 
 // INDUNET GmbH (www.indunet.it)
@@ -397,8 +397,8 @@
   // that can later be passed to fill_styleX_bitmap(), to set a
   // bitmap fill style.
   {    
-    return new agg_bitmap_info<agg::pixfmt_rgb24_pre> (im->m_width, 
im->m_height,
-      im->m_pitch, im->m_data, 24);
+    return new agg_bitmap_info<agg::pixfmt_rgb24_pre> (im->width(), 
im->height(),
+      im->pitch(), im->data(), 24);
     assert(0); 
   }
 
@@ -410,8 +410,8 @@
   //
   // This version takes an image with an alpha channel.
   {
-    return new agg_bitmap_info<agg::pixfmt_rgba32_pre> (im->m_width, 
im->m_height,
-      im->m_pitch, im->m_data, 32); 
+    return new agg_bitmap_info<agg::pixfmt_rgba32_pre> (im->width(), 
im->height(),
+      im->pitch(), im->data(), 32); 
   }
 
 
@@ -479,8 +479,8 @@
     mat.concatenate(*source_mat);
     
     // compute video scaling relative to video obejct size
-    double vscaleX = TWIPS_TO_PIXELS(bounds->width())  / frame->m_width;
-    double vscaleY = TWIPS_TO_PIXELS(bounds->height()) / frame->m_height;
+    double vscaleX = TWIPS_TO_PIXELS(bounds->width())  / frame->width();
+    double vscaleY = TWIPS_TO_PIXELS(bounds->height()) / frame->height();
     
     // convert Gnash matrix to AGG matrix and scale down to pixel coordinates
     // while we're at it
@@ -507,8 +507,8 @@
     typedef agg::image_accessor_clone<baseformat> img_source_type;
     
     // rendering buffer is used to access the frame pixels here        
-    agg::rendering_buffer img_buf(frame->m_data, frame->m_width, 
frame->m_height,
-      frame->m_width*3);
+    agg::rendering_buffer img_buf(frame->data(), frame->width(), 
frame->height(),
+      frame->pitch());
          
     baseformat img_pixf(img_buf);
     

Index: backend/render_handler_cairo.cpp
===================================================================
RCS file: /sources/gnash/gnash/backend/render_handler_cairo.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- backend/render_handler_cairo.cpp    13 Jul 2007 16:05:08 -0000      1.23
+++ backend/render_handler_cairo.cpp    10 Sep 2007 16:53:29 -0000      1.24
@@ -30,10 +30,10 @@
 rgb_to_cairo_rgb24(uint8_t* dst, const image::rgb* im)
 {
     uint32_t* dst32 = reinterpret_cast<uint32_t*>(dst);
-    for (int y = 0;  y < im->m_height;  y++)
+    for (size_t y = 0;  y < im->height();  y++)
     {
-       const uint8_t* src = image::scanline(im, y);
-       for (int x = 0;  x < im->m_width;  x++, src += 3)
+       const uint8_t* src = im->scanline(y);
+       for (size_t x = 0;  x < im->width();  x++, src += 3)
        {
            // 32-bit RGB data in native endian format
            *dst32++ = (src[0] << 16) | (src[1] << 8) | src[2];
@@ -47,10 +47,10 @@
 rgba_to_cairo_argb32(uint8_t* dst, const image::rgba* im)
 {
     uint32_t* dst32 = reinterpret_cast<uint32_t*>(dst);
-    for (int y = 0;  y < im->m_height;  y++)
+    for (size_t y = 0;  y < im->height();  y++)
     {
-       const uint8_t* src = image::scanline(im, y);
-       for (int x = 0;  x < im->m_width;  x++, src += 4)
+       const uint8_t* src = im->scanline(y);
+       for (size_t x = 0;  x < im->width();  x++, src += 4)
        {
            // 32-bit ARGB data in native endian format
            *dst32++ = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3];
@@ -618,8 +618,8 @@
 
            // Extract frame attributes
            image::rgb* frame = static_cast<image::rgb*>(baseframe);
-           int         w = frame->m_width;
-           int         h = frame->m_height;
+           int         w = frame->width();
+           int         h = frame->height();
 
            // Compute bounding rectangle size relative to video object
            double w_scale = bounds->width()  / w;
@@ -720,15 +720,15 @@
     assert(im);
 
     // Convert 24-bit BGR data to 32-bit RGB
-    int buf_size = im->m_width * im->m_height * 4;
+    int buf_size = im->width() * im->height() * 4;
     m_buffer = new unsigned char[buf_size];
     rgb_to_cairo_rgb24(m_buffer, im);
 
     // Create the cairo image
-    m_original_width  = im->m_width;
-    m_original_height = im->m_height;
+    m_original_width  = im->width();
+    m_original_height = im->height();
     m_image = cairo_image_surface_create_for_data(m_buffer,
-       CAIRO_FORMAT_RGB24, im->m_width, im->m_height, im->m_width * 4);
+       CAIRO_FORMAT_RGB24, im->width(), im->height(), im->width() * 4);
     m_pattern = cairo_pattern_create_for_surface(m_image);
 }
 
@@ -739,15 +739,17 @@
     assert(im);
 
     // Allocate output buffer
-    int buf_size = im->m_width * im->m_height * 4;
+    size_t buf_size = im->size(); 
+
+    // TODO: who owns this buffer ??
     m_buffer = new unsigned char[buf_size];
     rgba_to_cairo_argb32(m_buffer, im);
 
     // Create the image
-    m_original_width  = im->m_width;
-    m_original_height = im->m_height;
+    m_original_width  = im->width();
+    m_original_height = im->height();
     m_image = cairo_image_surface_create_for_data(m_buffer,
-       CAIRO_FORMAT_ARGB32, im->m_width, im->m_height, im->m_width * 4);
+       CAIRO_FORMAT_ARGB32, im->width(), im->height(), im->width() * 4);
     m_pattern = cairo_pattern_create_for_surface(m_image);
 }
 

Index: backend/render_handler_ogl.cpp
===================================================================
RCS file: /sources/gnash/gnash/backend/render_handler_ogl.cpp,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -b -r1.76 -r1.77
--- backend/render_handler_ogl.cpp      26 Jul 2007 19:25:35 -0000      1.76
+++ backend/render_handler_ogl.cpp      10 Sep 2007 16:53:29 -0000      1.77
@@ -5,7 +5,7 @@
 
 // A render_handler that uses SDL & OpenGL
 
-/* $Id: render_handler_ogl.cpp,v 1.76 2007/07/26 19:25:35 strk Exp $ */
+/* $Id: render_handler_ogl.cpp,v 1.77 2007/09/10 16:53:29 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -67,7 +67,9 @@
                }
        }
 
-       virtual void layout_image(image::image_base* im);
+       void layout_image(image::image_base* im);
+
+       std::auto_ptr<image::image_base>  m_suspended_image;
 };
 
 // static GLint iquad[] = {-1, 1, 1, 1, 1, -1, -1, -1};
@@ -145,7 +147,7 @@
        };
        mode    m_mode;
        gnash::rgba     m_color;
-       gnash::bitmap_info*     m_bitmap_info;
+       bitmap_info_ogl*        m_bitmap_info;
        gnash::matrix   m_bitmap_matrix;
        gnash::cxform   m_bitmap_color_transform;
        bool    m_has_nonzero_bitmap_additive_color;
@@ -153,6 +155,7 @@
        fill_style()
            :
            m_mode(INVALID),
+            m_bitmap_info(0),
            m_has_nonzero_bitmap_additive_color(false)
            {
            }
@@ -168,11 +171,11 @@
                glDisable(GL_TEXTURE_2D);
            } else if (m_mode == BITMAP_WRAP
                       || m_mode == BITMAP_CLAMP) {
-               assert(m_bitmap_info != NULL);
+               assert(m_bitmap_info != 0);
                
                apply_color(m_color);
                
-               if (m_bitmap_info == NULL) {
+               if (m_bitmap_info == 0) {
                    glDisable(GL_TEXTURE_2D);
                } else {
                    // Set up the texture for rendering.
@@ -188,11 +191,10 @@
                            );
                    }
                    
-                               if (m_bitmap_info->m_texture_id == 0 && 
m_bitmap_info->m_suspended_image != NULL)
+                               if (m_bitmap_info->m_texture_id == 0 && 
m_bitmap_info->m_suspended_image.get() )
                                {
-                                       
m_bitmap_info->layout_image(m_bitmap_info->m_suspended_image);
-                                       delete m_bitmap_info->m_suspended_image;
-                                       m_bitmap_info->m_suspended_image = NULL;
+                                       
m_bitmap_info->layout_image(m_bitmap_info->m_suspended_image.get());
+                                       
m_bitmap_info->m_suspended_image.reset();
                                }
 
                                // assert(m_bitmap_info->m_texture_id);
@@ -277,10 +279,14 @@
 
        void    disable() { m_mode = INVALID; }
        void    set_color(const gnash::rgba& color) { m_mode = COLOR; m_color = 
color; }
-       void    set_bitmap(const gnash::bitmap_info* bi, const gnash::matrix& 
m, bitmap_wrap_mode wm, const gnash::cxform& color_transform)
+       void    set_bitmap(const gnash::bitmap_info* bi_, const gnash::matrix& 
m, bitmap_wrap_mode wm, const gnash::cxform& color_transform)
            {
                m_mode = (wm == WRAP_REPEAT) ? BITMAP_WRAP : BITMAP_CLAMP;
-               m_bitmap_info = const_cast<gnash::bitmap_info*> ( bi );
+
+               bitmap_info* bi = const_cast<bitmap_info*>(bi_);
+
+               assert( dynamic_cast<bitmap_info_ogl*> ( bi ) );
+               m_bitmap_info = static_cast<bitmap_info_ogl*> ( bi );
                m_bitmap_matrix = m;
                m_bitmap_color_transform = color_transform;
                m_bitmap_color_transform.clamp();
@@ -404,7 +410,7 @@
                float w_bounds = TWIPS_TO_PIXELS(b.m_x - a.m_x);
                float h_bounds = TWIPS_TO_PIXELS(c.m_y - a.m_y);
 
-               unsigned char*   ptr = frame->m_data;
+               unsigned char*   ptr = frame->data();
                float xpos = a.m_x < 0 ? 0.0f : a.m_x;  //hack
                float ypos = a.m_y < 0 ? 0.0f : a.m_y;  //hack
                glRasterPos2f(xpos, ypos);      //hack
@@ -428,8 +434,8 @@
                        ptr += frame->planes[i].size;
                }
 #else
-               int height = frame->m_height;
-               int width = frame->m_width;
+               size_t height = frame->height();
+               size_t width = frame->width();
                float zx = w_bounds / (float) width;
                float zy = h_bounds / (float) height;
                glPixelZoom(zx,  -zy);  // flip & zoom image
@@ -796,7 +802,7 @@
 
     void       draw_bitmap(
        const gnash::matrix& m,
-       const gnash::bitmap_info* bi,
+       const gnash::bitmap_info* bi_,
        const gnash::rect& coords,
        const gnash::rect& uv_coords,
        const gnash::rgba& color)
@@ -807,7 +813,7 @@
        // Intended for textured glyph rendering.
        {
 //         GNASH_REPORT_FUNCTION;
-           assert(bi);
+           assert(bi_);
 
            apply_color(color);
 
@@ -818,11 +824,15 @@
            d.m_x = b.m_x + c.m_x - a.m_x;
            d.m_y = b.m_y + c.m_y - a.m_y;
 
-                       if (bi->m_texture_id == 0 && bi->m_suspended_image != 
NULL)
+               gnash::bitmap_info* cbi_ = const_cast<gnash::bitmap_info*>(bi_);
+
+               assert(dynamic_cast<bitmap_info_ogl*>(cbi_));
+               bitmap_info_ogl* bi = static_cast<bitmap_info_ogl*>(cbi_);
+
+                       if (bi->m_texture_id == 0 && 
bi->m_suspended_image.get() )
                        {
-                               
const_cast<bitmap_info*>(bi)->layout_image(bi->m_suspended_image);
-                               delete bi->m_suspended_image;
-                               const_cast<bitmap_info*>(bi)->m_suspended_image 
= NULL;
+                               bi->layout_image(bi->m_suspended_image.get());
+                               bi->m_suspended_image.reset();
                        }
 
                        // assert(bi->m_texture_id);
@@ -1078,8 +1088,8 @@
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 
-       m_original_width = im->m_width;
-       m_original_height = im->m_height;
+       m_original_width = im->width();
+       m_original_height = im->height();
 
        switch (im->m_type)
        {
@@ -1088,10 +1098,10 @@
 
                        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, 
GL_LINEAR);
 
-                       int     w = 1; while (w < im->m_width) { w <<= 1; }
-                       int     h = 1; while (h < im->m_height) { h <<= 1; }
+                       size_t  w = 1; while (w < im->width()) { w <<= 1; }
+                       size_t  h = 1; while (h < im->height()) { h <<= 1; }
 
-                       if (w != im->m_width    || h != im->m_height)
+                       if (w != im->width() || h != im->height())
                        {
 #if (RESAMPLE_METHOD == 1)
                                int     viewport_dim[2] = { 0, 0 };
@@ -1104,34 +1114,33 @@
                                        // buffer isn't big enough to fit the 
source
                                        // texture, or the source data isn't 
padded
                                        // quite right.
-                                       software_resample(3, im->m_width, 
im->m_height, im->m_pitch, im->m_data, w, h);
+                                       software_resample(3, im->width(), 
im->height(), im->pitch(), im->data(), w, h);
                        }
                                else
                        {
-                                       hardware_resample(3, im->m_width, 
im->m_height, im->m_data, w, h);
+                                       hardware_resample(3, im->width(), 
im->height(), im->data(), w, h);
                        }
 #elif (RESAMPLE_METHOD == 2)
                                {
                        // Faster/simpler software bilinear rescale.
-                       software_resample(3, im->m_width, im->m_height, 
im->m_pitch, im->m_data, w, h);
+                       software_resample(3, im->width(), im->height(), 
im->pitch(), im->data(), w, h);
                                }
 #else
                                {
                        // Fancy but slow software resampling.
-                       image::rgb*     rescaled = image::create_rgb(w, h);
-                       image::resample(rescaled, 0, 0, w - 1, h - 1,
+                       std::auto_ptr<image::rgb> rescaled ( 
image::create_rgb(w, h) );
+                       image::resample(rescaled.get(), 0, 0, w - 1, h - 1,
                                        im, 0, 0, (float) im->m_width, (float) 
im->m_height);
 
-                       glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, 
GL_UNSIGNED_BYTE, rescaled->m_data);
+                       glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, 
GL_UNSIGNED_BYTE, rescaled->data());
 
-                       delete rescaled;
                                }
 #endif
                        }
                        else
                        {
                                // Use original image directly.
-                               glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, 
GL_RGB, GL_UNSIGNED_BYTE, im->m_data);
+                               glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, 
GL_RGB, GL_UNSIGNED_BYTE, im->data());
                        }
 
                        break;
@@ -1141,10 +1150,10 @@
 
                        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, 
GL_LINEAR);
 
-                       int     w = 1; while (w < im->m_width) { w <<= 1; }
-                       int     h = 1; while (h < im->m_height) { h <<= 1; }
+                       size_t  w = 1; while (w < im->width()) { w <<= 1; }
+                       size_t  h = 1; while (h < im->height()) { h <<= 1; }
 
-                       if (w != im->m_width    || h != im->m_height)
+                       if (w != im->width() || h != im->height())
                        {
 #if (RESAMPLE_METHOD == 1)
                                int     viewport_dim[2] = { 0, 0 };
@@ -1157,16 +1166,16 @@
                                        // buffer isn't big enough to fit the 
source
                                        // texture, or the source data isn't 
padded
                                        // quite right.
-                                       software_resample(4, im->m_width, 
im->m_height, im->m_pitch, im->m_data, w, h);
+                                       software_resample(4, im->width(), 
im->height(), im->pitch(), im->data(), w, h);
                        }
                                else
                        {
-                                       hardware_resample(4, im->m_width, 
im->m_height, im->m_data, w, h);
+                                       hardware_resample(4, im->width(), 
im->height(), im->data(), w, h);
                        }
 #elif (RESAMPLE_METHOD == 2)
                                {
                        // Faster/simpler software bilinear rescale.
-                       software_resample(4, im->m_width, im->m_height, 
im->m_pitch, im->m_data, w, h);
+                       software_resample(4, im->width(), im->height(), 
im->pitch(), im->data(), w, h);
                                }
 #else
                                {
@@ -1184,33 +1193,33 @@
                        else
                        {
                                // Use original image directly.
-                               glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 
0, GL_RGBA, GL_UNSIGNED_BYTE, im->m_data);
+                               glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 
0, GL_RGBA, GL_UNSIGNED_BYTE, im->data());
                        }
 
                        break;
                }
-               case image::image_base::ROW:
+               case image::image_base::ALPHA:
                {
                        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, 
GL_LINEAR_MIPMAP_LINEAR);
 
 #ifndef NDEBUG
                        // You must use power-of-two dimensions!!
-                       int     w = 1; while (w < im->m_width) { w <<= 1; }
-                       int     h = 1; while (h < im->m_height) { h <<= 1; }
-                       assert(w == im->m_width);
-                       assert(h == im->m_height);
+                       size_t  w = 1; while (w < im->width()) { w <<= 1; }
+                       size_t  h = 1; while (h < im->height()) { h <<= 1; }
+                       assert(w == im->width());
+                       assert(h == im->height());
 #endif // not NDEBUG
 
                        glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA,
-                               im->m_width, im->m_height, 0, GL_ALPHA, 
GL_UNSIGNED_BYTE, im->m_data);
+                               im->width(), im->height(), 0, GL_ALPHA, 
GL_UNSIGNED_BYTE, im->data());
 
                        // Build mips.
                        int     level = 1;
-                       while (im->m_width > 1 || im->m_height > 1)
+                       while (im->width() > 1 || im->height() > 1)
                        {
-                               
render_handler_ogl::make_next_miplevel(&im->m_width, &im->m_height, im->m_data);
+                               im->make_next_miplevel();
                                glTexImage2D(GL_TEXTURE_2D, level, GL_ALPHA, 
-                                       im->m_width, im->m_height, 0, GL_ALPHA, 
GL_UNSIGNED_BYTE, im->m_data);
+                                       im->width(), im->height(), 0, GL_ALPHA, 
GL_UNSIGNED_BYTE, im->data());
                                level++;
                        }
 
@@ -1218,11 +1227,12 @@
                }
 
                default:
-//                     printf("unsupported image type\n");
+//                     log_error("Unsupported image type");
                        break;
        }
 
 }
+
 inline bool opengl_accessible()
 {
 #if defined(_WIN32) || defined(WIN32)
@@ -1246,16 +1256,17 @@
        assert(data);
 
        // TODO optimization
-       image::image_base* im = new image::image_base(data, width, height, 1, 
image::image_base::ROW);
-       memcpy(im->m_data, data, width * height);
+       //image::image_base* im = new image::image_base(data, width, height, 1, 
image::image_base::ALPHA);
+       //memcpy(im->data(), data, width * height);
+       std::auto_ptr<image::image_base> im ( image::create_alpha(width, 
height) );
+       im->update(data);
 
        if (opengl_accessible() == false) 
        {
                m_suspended_image = im;
                return;
        }
-       layout_image(im);
-       delete im;
+       layout_image(im.get());
 }
 
 
@@ -1267,8 +1278,7 @@
 
        if (opengl_accessible() == false) 
        {
-               m_suspended_image = image::create_rgb(im->m_width, 
im->m_height);
-               memcpy(m_suspended_image->m_data, im->m_data, im->m_pitch * 
im->m_height);
+               m_suspended_image = im->clone();
                return;
        }
        layout_image(im);
@@ -1284,8 +1294,7 @@
 
        if (opengl_accessible() == false) 
        {
-               m_suspended_image = image::create_rgba(im->m_width, 
im->m_height);
-               memcpy(m_suspended_image->m_data, im->m_data, im->m_pitch * 
im->m_height);
+               m_suspended_image = im->clone();
                return;
        }
        layout_image(im);

Index: libbase/embedVideoDecoderFfmpeg.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/embedVideoDecoderFfmpeg.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- libbase/embedVideoDecoderFfmpeg.cpp 17 Jul 2007 22:05:03 -0000      1.21
+++ libbase/embedVideoDecoderFfmpeg.cpp 10 Sep 2007 16:53:29 -0000      1.22
@@ -87,6 +87,9 @@
        cc->width = width;
        cc->height = height;
 
+       assert(cc->width > 0);
+       assert(cc->height > 0);
+
        // Determine required buffer size and allocate buffer
        if (outputFormat == YUV) {
                decodedFrame.reset(new image::yuv(width, height));
@@ -172,7 +175,8 @@
                        return ret_image;
                }
 
-               ret_image->update(decodedFrame->m_data);
+               // clone decodedFrame instead ?
+               ret_image->update(*decodedFrame);
                return ret_image;
        }
 
@@ -199,11 +203,12 @@
        }
        
        if (got) {
+               log_debug("Got");
                boost::scoped_array<uint8_t> buffer;
 
                if (outputFormat == NONE) { // NullGui?
                        av_free(frame);
-                       ret_image->update(decodedFrame->m_data);
+                       ret_image->update(*decodedFrame);
                        return ret_image;
 
                } else if (outputFormat == YUV && cc->pix_fmt != 
PIX_FMT_YUV420P) {
@@ -217,8 +222,8 @@
 
                if (outputFormat == YUV) {
                        image::yuv* yuvframe = 
static_cast<image::yuv*>(decodedFrame.get());
-                       int copied = 0;
-                       uint8_t* ptr = yuvframe->m_data;
+                       size_t copied = 0;
+                       uint8_t* ptr = yuvframe->data();
                        for (int i = 0; i < 3 ; i++)
                        {
                                int shift = (i == 0 ? 0 : 1);
@@ -234,15 +239,20 @@
                                        ptr += w;
                                }
                        }
-                       yuvframe->m_size = copied;
+                       //yuvframe->m_size = copied;
+                       assert(yuvframe->size() == copied); // correct ?
                } else if (outputFormat == RGB) {
 
+               log_debug("updating decodedFrame with data from ffmpeg");
+
                        uint8_t* srcptr = frame->data[0];
                        uint8_t* srcend = frame->data[0] + frame->linesize[0] * 
cc->height;
-                       uint8_t* dstptr = decodedFrame->m_data;
+                       uint8_t* dstptr = decodedFrame->data();
+                       uint8_t* dstend = 
decodedFrame->data()+decodedFrame->size();
                        unsigned int srcwidth = cc->width * 3;
 
                        while (srcptr < srcend) {
+                               assert( dstptr < dstend );
                                memcpy(dstptr, srcptr, srcwidth);
                                srcptr += frame->linesize[0];
                                dstptr += srcwidth;
@@ -250,6 +260,7 @@
 
                }
        }
+       else log_debug("Didn't get");
 
        av_free(frame);
        // If haven't decoded any frame yet, return
@@ -259,8 +270,11 @@
                ret_image.reset(NULL);
                return ret_image;
        }
-       ret_image->update(decodedFrame->m_data);
-       return ret_image;
+
+       log_debug("Returning a clone of decodedFrame");
+       return decodedFrame->clone();
+       //ret_image->update(*decodedFrame);
+       //return ret_image;
 }
 
 } // end of gnash namespace

Index: libbase/embedVideoDecoderGst.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/embedVideoDecoderGst.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- libbase/embedVideoDecoderGst.cpp    21 Aug 2007 17:12:42 -0000      1.10
+++ libbase/embedVideoDecoderGst.cpp    10 Sep 2007 16:53:29 -0000      1.11
@@ -15,7 +15,7 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-// $Id: embedVideoDecoderGst.cpp,v 1.10 2007/08/21 17:12:42 strk Exp $
+// $Id: embedVideoDecoderGst.cpp,v 1.11 2007/09/10 16:53:29 strk Exp $
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -221,7 +221,9 @@
                        ret_image.reset(NULL);
                        return ret_image;
                }
-               ret_image->update(decodedFrame->m_data);
+
+               // return decodedFrame->clone() ?
+               ret_image->update(*decodedFrame);
                return ret_image;
        }
 
@@ -239,8 +241,9 @@
                ret_image.reset(NULL);
                return ret_image;
        }
-       ret_image->update(decodedFrame->m_data);
 
+       // return decodedFrame->clone() ?
+       ret_image->update(*decodedFrame);
        return ret_image;
 }
 

Index: libbase/image.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/image.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- libbase/image.cpp   31 Aug 2007 00:49:16 -0000      1.23
+++ libbase/image.cpp   10 Sep 2007 16:53:29 -0000      1.24
@@ -20,9 +20,12 @@
        //
        // image_base
        //
+
+       /// Create an image taking ownership of the given buffer, supposedly of 
height*pitch bytes
        image_base::image_base(uint8_t* data, int width, int height, int pitch, 
id_image type)
                :
                m_type(type),
+               m_size(height*pitch),
                m_data(data),
                m_width(width),
                m_height(height),
@@ -30,24 +33,36 @@
        {
        }
 
-       void image_base::update(uint8_t* data)
+       /// Create an image allocating a buffer of height*pitch bytes
+       image_base::image_base(int width, int height, int pitch, id_image type)
+               :
+               m_type(type),
+               m_size(height*pitch),
+               m_data(new uint8_t[m_size]),
+               m_width(width),
+               m_height(height),
+               m_pitch(pitch)
        {
-               memcpy(m_data, data, m_pitch * m_height);
+               assert(pitch >= width);
        }
 
-       uint8_t*        scanline(image_base* surf, int y)
+       void image_base::update(uint8_t* data)
        {
-               assert(surf);
-               assert(y >= 0 && y < surf->m_height);
-               return ((uint8_t*) surf->m_data) + surf->m_pitch * y;
+               memcpy(m_data.get(), data, m_size);
        }
 
+       void image_base::update(const image_base& from)
+       {
+               assert(from.m_pitch == m_pitch);
+               assert(m_size <= from.m_size);
+               assert(m_type == from.m_type);
+               memcpy(m_data.get(), from.m_data.get(), m_size);
+       }
 
-       const uint8_t*  scanline(const image_base* surf, int y)
+       uint8_t* image_base::scanline(size_t y)
        {
-               assert(surf);
-               assert(y >= 0 && y < surf->m_height);
-               return ((const uint8_t*) surf->m_data) + surf->m_pitch * y;
+               assert(y < m_height);
+               return m_data.get() + m_pitch * y;
        }
 
 
@@ -57,26 +72,18 @@
 
        rgb::rgb(int width, int height)
                :
-               image_base(
-                       0,
-                       width,
-                       height,
-                       (width * 3 + 3) & ~3, RGB)      // round pitch up to 
nearest 4-byte boundary
+               image_base( width, height,
+                       (width * 3 + 3) & ~3, // round pitch up to nearest 
4-byte boundary
+                       RGB)
        {
                assert(width > 0);
                assert(height > 0);
                assert(m_pitch >= m_width * 3);
                assert((m_pitch & 3) == 0);
-
-               m_data = new uint8_t[m_pitch * m_height];
        }
 
        rgb::~rgb()
        {
-               // TODO FIXME: m_data is a member of image_base, 
-               // so ONLY image_base should delete it !
-               // USE A SCOPED POINTER FOR THIS !
-               delete [] m_data;
        }
 
 
@@ -88,6 +95,66 @@
                return new rgb(width, height);
        }
 
+       bool rgb::make_next_miplevel()
+       {
+               assert(m_data.get());
+               assert(m_type == RGB);
+
+               size_t imWidth = m_width;
+               size_t imHeight = m_height;
+
+               size_t new_w = imWidth >> 1;
+               size_t new_h = imHeight >> 1;
+               if (new_w < 1) new_w = 1;
+               if (new_h < 1) new_h = 1;
+
+               if (new_w * 2 != imWidth  || new_h * 2 != imHeight)
+               {
+                       // Image can't be shrunk along (at least) one
+                       // of its dimensions, so don't bother
+                       // resampling.  Technically we should, but
+                       // it's pretty useless at this point.  Just
+                       // change the image dimensions and leave the
+                       // existing pixels.
+                       return false;
+               }
+
+               size_t new_pitch = new_w * 3;
+
+               // Round pitch up to the nearest 4-byte boundary.
+               new_pitch = (new_pitch + 3) & ~3;
+
+               // Resample.  Simple average 2x2 --> 1, in-place.
+               size_t  pitch = m_pitch;
+               for (size_t j = 0; j < new_h; j++) {
+                       uint8_t*        out = m_data.get() + j * new_pitch;
+                       uint8_t*        in = m_data.get() + (j << 1) * pitch;
+                       for (size_t i = 0; i < new_w; i++) {
+                               int     r, g, b;
+                               r = (*(in + 0) + *(in + 3) + *(in + 0 + pitch) 
+ *(in + 3 + pitch));
+                               g = (*(in + 1) + *(in + 4) + *(in + 1 + pitch) 
+ *(in + 4 + pitch));
+                               b = (*(in + 2) + *(in + 5) + *(in + 2 + pitch) 
+ *(in + 5 + pitch));
+                               *(out + 0) = r >> 2;
+                               *(out + 1) = g >> 2;
+                               *(out + 2) = b >> 2;
+                               out += 3;
+                               in += 6;
+                       }
+               }
+
+               // Munge image's members to reflect the shrunken image.
+               m_width = new_w;
+               m_height = new_h;
+               m_pitch = new_pitch;
+               m_size = m_height*m_pitch;
+
+               assert(m_pitch >= m_width);
+
+               return true;
+       }
+
+
+
 
        //
        // rgba
@@ -96,23 +163,16 @@
 
        rgba::rgba(int width, int height)
                :
-               image_base(0, width, height, width * 4, RGBA)
+               image_base(width, height, width * 4, RGBA)
        {
                assert(width > 0);
                assert(height > 0);
                assert(m_pitch >= m_width * 4);
                assert((m_pitch & 3) == 0);
-
-//             m_data = (uint8_t*) dlmalloc(m_pitch * m_height);
-               m_data = new uint8_t[m_pitch * m_height];
        }
 
        rgba::~rgba()
        {
-               // TODO FIXME: m_data is a member of image_base, 
-               // so ONLY image_base should delete it !
-               // USE A SCOPED POINTER FOR THIS !
-               delete [] m_data;
        }
 
 
@@ -125,13 +185,13 @@
        }
 
 
-       void    rgba::set_pixel(int x, int y, uint8_t r, uint8_t g, uint8_t b, 
uint8_t a)
+       void    rgba::set_pixel(size_t x, size_t y, uint8_t r, uint8_t g, 
uint8_t b, uint8_t a)
        // Set the pixel at the given position.
        {
-               assert(x >= 0 && x < m_width);
-               assert(y >= 0 && y < m_height);
+               assert(x < m_width);
+               assert(y < m_height);
 
-               uint8_t*        data = scanline(this, y) + 4 * x;
+               uint8_t*        data = scanline(y) + 4 * x;
 
                data[0] = r;
                data[1] = g;
@@ -139,6 +199,70 @@
                data[3] = a;
        }
 
+       // Set alpha value for given pixel 
+       void    rgba::set_alpha(size_t x, size_t y, uint8_t a)
+       {
+               assert(x < m_width);
+               assert(y < m_height);
+
+               uint8_t*        data = scanline(y) + 4 * x;
+
+               data[3] = a;
+       }
+
+       bool    rgba::make_next_miplevel()
+       {
+               assert(m_data.get());
+               assert(m_type == RGBA);
+
+               size_t  new_w = m_width >> 1;
+               size_t  new_h = m_height >> 1;
+               if (new_w < 1) new_w = 1;
+               if (new_h < 1) new_h = 1;
+
+               if (new_w * 2 != m_width  || new_h * 2 != m_height)
+               {
+                       // Image can't be shrunk along (at least) one
+                       // of its dimensions, so don't bother
+                       // resampling.  Technically we should, but
+                       // it's pretty useless at this point.  Just
+                       // change the image dimensions and leave the
+                       // existing pixels.
+                       return false;
+               }
+
+               size_t  new_pitch = new_w * 4;
+
+               // Resample.  Simple average 2x2 --> 1, in-place.
+               size_t  pitch = m_pitch;
+               for (size_t j = 0; j < new_h; j++) {
+                       uint8_t*        out = ((uint8_t*) m_data.get()) + j * 
new_pitch;
+                       uint8_t*        in = ((uint8_t*) m_data.get()) + (j << 
1) * pitch;
+                       for (size_t i = 0; i < new_w; i++) {
+                               int     r, g, b, a;
+                               r = (*(in + 0) + *(in + 4) + *(in + 0 + pitch) 
+ *(in + 4 + pitch));
+                               g = (*(in + 1) + *(in + 5) + *(in + 1 + pitch) 
+ *(in + 5 + pitch));
+                               b = (*(in + 2) + *(in + 6) + *(in + 2 + pitch) 
+ *(in + 6 + pitch));
+                               a = (*(in + 3) + *(in + 7) + *(in + 3 + pitch) 
+ *(in + 7 + pitch));
+                               *(out + 0) = r >> 2;
+                               *(out + 1) = g >> 2;
+                               *(out + 2) = b >> 2;
+                               *(out + 3) = a >> 2;
+                               out += 4;
+                               in += 8;
+                       }
+               }
+
+               // Munge image's members to reflect the shrunken image.
+               m_width = new_w;
+               m_height = new_h;
+               m_pitch = new_pitch;
+               m_size = m_height*m_pitch;
+
+               assert(m_pitch >= m_width);
+
+               return true;
+       }
 
        //
        // alpha
@@ -154,29 +278,73 @@
 
        alpha::alpha(int width, int height)
                :
-               image_base(0, width, height, width, ALPHA)
+               image_base(width, height, width, ALPHA)
        {
                assert(width > 0);
                assert(height > 0);
 
-//             m_data = (uint8_t*) dlmalloc(m_pitch * m_height);
-               m_data = new uint8_t[m_pitch * m_height];
+               //m_data = new uint8_t[m_pitch * m_height];
        }
 
 
        alpha::~alpha()
        {
-                       delete [] m_data;
        }
 
+       bool alpha::make_next_miplevel()
+       {
+               assert(m_data.get());
+               assert(m_type == ALPHA);
+
+               size_t  new_w = m_width >> 1;
+               size_t  new_h = m_height >> 1;
+               if (new_w < 1) new_w = 1;
+               if (new_h < 1) new_h = 1;
+
+               if (new_w * 2 != m_width || new_h * 2 != m_height)
+               {
+                       // Image can't be shrunk along (at least) one
+                       // of its dimensions, so don't bother
+                       // resampling.  Technically we should, but
+                       // it's pretty useless at this point.  Just
+                       // change the image dimensions and leave the
+                       // existing pixels.
+                       return false;
+               }
+
+               // Resample.  Simple average 2x2 --> 1, in-place.
+               for (size_t j = 0; j < new_h; j++)
+               {
+                       uint8_t* out = m_data.get() + j * new_w;
+                       uint8_t* in = m_data.get() + (j << 1) * m_width;
+                       for (size_t i = 0; i < new_w; i++)
+                       {
+                               int     a;
+                               a = (*(in + 0) + *(in + 1) + *(in + 0 + 
m_width) + *(in + 1 + m_width));
+                               *(out) = a >> 2;
+                               out++;
+                               in += 2;
+                       }
+               }
+
+               // Munge parameters to reflect the shrunken image.
+               m_width = m_pitch = new_w;
+               m_height = new_h;
+               m_size = m_height*m_pitch;
+
+               assert(m_pitch >= m_width);
 
-       void    alpha::set_pixel(int x, int y, uint8_t a)
+               return true;
+       }
+
+
+       void    alpha::set_pixel(size_t x, size_t y, uint8_t a)
        // Set the pixel at the given position.
        {
-               assert(x >= 0 && x < m_width);
-               assert(y >= 0 && y < m_height);
+               assert(x < m_width);
+               assert(y < m_height);
 
-               uint8_t*        data = scanline(this, y) + x;
+               uint8_t*        data = scanline(y) + x;
 
                data[0] = a;
        }
@@ -193,7 +361,7 @@
 
                for (int j = 0, n = m_height; j < n; j++)
                {
-                       if (memcmp(scanline(this, j), scanline(&a, j), m_width))
+                       if (memcmp(scanline(j), a.scanline(j), m_width))
                        {
                                // Mismatch.
                                return false;
@@ -214,7 +382,7 @@
 
                for (int i = 0, n = m_height; i < n; i++)
                {
-                       h = bernstein_hash(scanline(this, i), m_width, h);
+                       h = bernstein_hash(scanline(i), m_width, h);
                }
 
                return h;
@@ -224,7 +392,7 @@
        // yuv
        //
        yuv::yuv(int w, int h) :
-               image_base(0, w, h, w, YUV)
+               image_base(0, w, h, w, YUV) // pitch initialized to wrong 
value, will fix m_size below
 
        {
                planes[Y].w = m_width;
@@ -265,7 +433,7 @@
                        planes[i].coords[3][1] = th;
                }
 
-               m_data = new uint8_t[m_size];
+               m_data.reset( new uint8_t[m_size] );
 
        //              m_bounds->m_x_min = 0.0f;
        //              m_bounds->m_x_max = 1.0f;
@@ -283,28 +451,21 @@
                return x + 1;
        }
 
-       int yuv::size() const
-       {
-               return m_size;
-       }
-
-       void yuv::update(uint8_t* data)
-       {
-               memcpy(m_data, data, m_size);
-       }
-
        //
        // utility
        //
 
 
-       void    write_jpeg(tu_file* out, rgb* image, int quality)
        // Write the given image to the given out stream, in jpeg format.
+       void    write_jpeg(tu_file* out, rgb* image, int quality)
        {
-               std::auto_ptr<jpeg::output> j_out ( jpeg::output::create(out, 
image->m_width, image->m_height, quality) );
+               size_t height = image->height();
+
+               std::auto_ptr<jpeg::output> j_out ( jpeg::output::create(out, 
image->width(), height, quality) );
 
-               for (int y = 0; y < image->m_height; y++) {
-                       j_out->write_scanline(scanline(image, y));
+               for (size_t y = 0; y < height; ++y)
+               {
+                       j_out->write_scanline(image->scanline(y));
                }
 
        }
@@ -338,7 +499,7 @@
 
                for (int y = 0; y < j_in->get_height(); y++)
                {
-                       j_in->read_scanline(scanline(im.get(), y));
+                       j_in->read_scanline(im->scanline(y));
                }
 
                return im.release();
@@ -357,7 +518,7 @@
                rgb*    im = image::create_rgb(j_in->get_width(), 
j_in->get_height());
 
                for (int y = 0; y < j_in->get_height(); y++) {
-                       j_in->read_scanline(scanline(im, y));
+                       j_in->read_scanline(im->scanline(y));
                }
 
                j_in->finish_image();
@@ -386,7 +547,7 @@
                {
                        j_in->read_scanline(line.get());
 
-                       uint8_t*        data = scanline(im.get(), y);
+                       uint8_t*        data = im->scanline(y);
                        for (int x = 0; x < j_in->get_width(); x++) 
                        {
                                data[4*x+0] = line[3*x+0];
@@ -402,9 +563,12 @@
        }
 
 
-       void    write_tga(tu_file* out, rgba* im)
        // Write a 32-bit Targa format bitmap.  Dead simple, no compression.
+       void    write_tga(tu_file* out, rgba* im)
        {
+               size_t imWidth = im->width();
+               size_t imHeight = im->height();
+
                out->write_byte(0);
                out->write_byte(0);
                out->write_byte(2);     /* uncompressed RGB */
@@ -413,15 +577,15 @@
                out->write_byte(0);
                out->write_le16(0);     /* X origin */
                out->write_le16(0);     /* y origin */
-               out->write_le16(im->m_width);
-               out->write_le16(im->m_height);
+               out->write_le16(imWidth);
+               out->write_le16(imHeight);
                out->write_byte(32);    /* 32 bit bitmap */
                out->write_byte(0);
 
-               for (int y = 0; y < im->m_height; y++)
+               for (size_t y = 0; y < imHeight; y++)
                {
-                       uint8_t*        p = scanline(im, y);
-                       for (int x = 0; x < im->m_width; x++)
+                       uint8_t*        p = im->scanline(y);
+                       for (size_t x = 0; x < imWidth; x++)
                        {
                                out->write_byte(p[x * 4]);
                                out->write_byte(p[x * 4 + 1]);
@@ -431,108 +595,6 @@
                }
        }
 
-       void    make_next_miplevel(rgb* image)
-       // Fast, in-place resample.  For making mip-maps.  Munges the
-       // input image to produce the output image.
-       {
-               assert(image->m_data);
-
-               int     new_w = image->m_width >> 1;
-               int     new_h = image->m_height >> 1;
-               if (new_w < 1) new_w = 1;
-               if (new_h < 1) new_h = 1;
-
-               int     new_pitch = new_w * 3;
-               // Round pitch up to the nearest 4-byte boundary.
-               new_pitch = (new_pitch + 3) & ~3;
-
-               if (new_w * 2 != image->m_width  || new_h * 2 != 
image->m_height)
-               {
-                       // Image can't be shrunk along (at least) one
-                       // of its dimensions, so don't bother
-                       // resampling.  Technically we should, but
-                       // it's pretty useless at this point.  Just
-                       // change the image dimensions and leave the
-                       // existing pixels.
-               }
-               else
-               {
-                       // Resample.  Simple average 2x2 --> 1, in-place.
-                       int     pitch = image->m_pitch;
-                       for (int j = 0; j < new_h; j++) {
-                               uint8_t*        out = ((uint8_t*) 
image->m_data) + j * new_pitch;
-                               uint8_t*        in = ((uint8_t*) image->m_data) 
+ (j << 1) * pitch;
-                               for (int i = 0; i < new_w; i++) {
-                                       int     r, g, b;
-                                       r = (*(in + 0) + *(in + 3) + *(in + 0 + 
pitch) + *(in + 3 + pitch));
-                                       g = (*(in + 1) + *(in + 4) + *(in + 1 + 
pitch) + *(in + 4 + pitch));
-                                       b = (*(in + 2) + *(in + 5) + *(in + 2 + 
pitch) + *(in + 5 + pitch));
-                                       *(out + 0) = r >> 2;
-                                       *(out + 1) = g >> 2;
-                                       *(out + 2) = b >> 2;
-                                       out += 3;
-                                       in += 6;
-                               }
-                       }
-               }
-
-               // Munge image's members to reflect the shrunken image.
-               image->m_width = new_w;
-               image->m_height = new_h;
-               image->m_pitch = new_pitch;
-       }
-
-
-       void    make_next_miplevel(rgba* image)
-       // Fast, in-place resample.  For making mip-maps.  Munges the
-       // input image to produce the output image.
-       {
-               assert(image->m_data);
-
-               int     new_w = image->m_width >> 1;
-               int     new_h = image->m_height >> 1;
-               if (new_w < 1) new_w = 1;
-               if (new_h < 1) new_h = 1;
-
-               int     new_pitch = new_w * 4;
-
-               if (new_w * 2 != image->m_width  || new_h * 2 != 
image->m_height)
-               {
-                       // Image can't be shrunk along (at least) one
-                       // of its dimensions, so don't bother
-                       // resampling.  Technically we should, but
-                       // it's pretty useless at this point.  Just
-                       // change the image dimensions and leave the
-                       // existing pixels.
-               }
-               else
-               {
-                       // Resample.  Simple average 2x2 --> 1, in-place.
-                       int     pitch = image->m_pitch;
-                       for (int j = 0; j < new_h; j++) {
-                               uint8_t*        out = ((uint8_t*) 
image->m_data) + j * new_pitch;
-                               uint8_t*        in = ((uint8_t*) image->m_data) 
+ (j << 1) * pitch;
-                               for (int i = 0; i < new_w; i++) {
-                                       int     r, g, b, a;
-                                       r = (*(in + 0) + *(in + 4) + *(in + 0 + 
pitch) + *(in + 4 + pitch));
-                                       g = (*(in + 1) + *(in + 5) + *(in + 1 + 
pitch) + *(in + 5 + pitch));
-                                       b = (*(in + 2) + *(in + 6) + *(in + 2 + 
pitch) + *(in + 6 + pitch));
-                                       a = (*(in + 3) + *(in + 7) + *(in + 3 + 
pitch) + *(in + 7 + pitch));
-                                       *(out + 0) = r >> 2;
-                                       *(out + 1) = g >> 2;
-                                       *(out + 2) = b >> 2;
-                                       *(out + 3) = a >> 2;
-                                       out += 4;
-                                       in += 8;
-                               }
-                       }
-               }
-
-               // Munge image's members to reflect the shrunken image.
-               image->m_width = new_w;
-               image->m_height = new_h;
-               image->m_pitch = new_pitch;
-       }
 }
 
 

Index: libbase/image.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/image.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- libbase/image.h     28 Aug 2007 13:12:38 -0000      1.15
+++ libbase/image.h     10 Sep 2007 16:53:29 -0000      1.16
@@ -13,6 +13,7 @@
 #include "tu_types.h"
 
 #include <boost/scoped_array.hpp>
+#include <memory> // for auto_ptr
 
 class tu_file;
 namespace jpeg { class input; }
@@ -37,19 +38,46 @@
 
                id_image m_type;
 
-               // TODO FIXME: m_data allocation is currently managed
-               // by subclasses (see rgb and rgba), this is really unsafe.
-               // Rather, *this* calss should manage it, using a scoped
-               // pointer
-               // USE A SCOPED POINTER FOR THIS !
-               uint8_t*        m_data;
-
-               int     m_width;
-               int     m_height;
-               int     m_pitch;        // byte offset from one row to the next
+               image_base(const image_base& o)
+                       :
+                       m_type(o.m_type),
+                       m_size(o.size()),
+                       m_data(new uint8_t[m_size]),
+                       m_width(o.width()),
+                       m_height(o.height()),
+                       m_pitch(o.m_pitch)
+               {
+                       update(o);
+               }
+               
+                       
 
                image_base(uint8_t* data, int width, int height, int pitch, 
id_image type);
 
+               /// Construct an image_base allocating data for height*pitch 
bytes
+               image_base(int width, int height, int pitch, id_image type);
+
+               /// Return a copy of this image
+               virtual std::auto_ptr<image_base> clone() const=0;
+
+               /// Return size of this image buffer, in bytes
+               size_t size() const { return m_size; }
+
+               /// Return size in bytes of a row of this image 
+               size_t pitch() const { return m_pitch; }
+
+               /// Return size in bytes of a single pixel value
+               size_t pixelSize() const
+               {
+                       return m_pitch/m_width;
+               }
+
+               /// Return width of image in pixels
+               size_t width() const { return m_width; }
+
+               /// Return height of image in pixels
+               size_t height() const { return m_height; }
+
                /// Copy image data from a buffer.
                //
                /// Note that this buffer MUST have the same m_pitch, or 
unexpected things
@@ -60,25 +88,124 @@
                ///
                void update(uint8_t* data);
 
+               /// Copy image data from another image data
+               //
+               /// Note that this buffer MUST have the same m_pitch and m_type
+               /// or an assertion will fail.
+               ///
+               /// @param from image to copy data from.
+               ///
+               void update(const image_base& from);
+
+               /// Return a pointer to the underlying data
+               uint8_t* data() { return m_data.get(); }
+
+               /// Return a pointer to first byte of given line
+               DSOEXPORT uint8_t* scanline(size_t y);
+
+               /// Return a read-only pointer to first byte of given line
+               DSOEXPORT const uint8_t* scanline(size_t y) const
+               {
+                       return const_cast<image_base*>(this)->scanline(y);
+               }
+
                virtual ~image_base() {}
+
+
+               /// \brief
+               /// Fast, in-place resample.  For making mip-maps.  Munges the
+               /// input image to produce the output image.
+               //
+               /// @return true if resample happened, false otherwise
+               ///         (image can't be shrinked, for example)
+               ///
+               virtual bool make_next_miplevel() { return false; }
+
+       protected:
+
+               /// Size of image buffer in bytes
+               size_t m_size;
+
+               /// Data bytes, geometry defined by members below
+               boost::scoped_array<uint8_t> m_data;
+
+               /// Width of image, in pixels
+               size_t  m_width;
+
+               /// Height of image, in pixels
+               size_t  m_height;
+
+               /// Byte offset from one row to the next
+               //
+               /// This is basically width in bytes of each line.
+               /// For example, in an alpha image type this is equal to m_width
+               /// while for an RGB this is 3 times the m_width.
+               ///
+               size_t  m_pitch;
+
+       private:
+
        };
 
        /// 24-bit RGB image.  Packed data, red byte first (RGBRGB...)
        class DSOEXPORT rgb : public image_base
        {
+
        public:
+
                rgb(int width, int height);
+
+               rgb(const rgb& o)
+                       :
+                       image_base(o)
+               {}
+
+               std::auto_ptr<image_base> clone() const
+               {
+                       return std::auto_ptr<image_base>(new rgb(*this));
+               }
+
                ~rgb();
+
+               // See dox in base class
+               bool make_next_miplevel();
        };
 
        /// 32-bit RGBA image.  Packed data, red byte first (RGBARGBA...)
        class DSOEXPORT rgba : public image_base
        {
+
        public:
+
                rgba(int width, int height);
+
+               rgba(const rgba& o)
+                       :
+                       image_base(o)
+               {}
+
                ~rgba();
 
-               void    set_pixel(int x, int y, uint8_t r, uint8_t g, uint8_t 
b, uint8_t a);
+               std::auto_ptr<image_base> clone() const
+               {
+                       return std::auto_ptr<image_base>(new rgba(*this));
+               }
+
+
+               /// Set pixel value 
+               //
+               /// TODO: move in base class ?
+               ///
+               void    set_pixel(size_t x, size_t y, uint8_t r, uint8_t g, 
uint8_t b, uint8_t a);
+
+               /// Set alpha value for given pixel
+               //
+               /// TODO: move in base class ?
+               ///
+               void    set_alpha(size_t x, size_t y, uint8_t a);
+
+               // See dox in base class
+               bool make_next_miplevel();
        };
 
        /// 8-bit alpha image.
@@ -86,9 +213,27 @@
        {
        public:
                alpha(int width, int height);
+
+               alpha(const alpha& o)
+                       :
+                       image_base(o)
+               {}
+
+               std::auto_ptr<image_base> clone() const
+               {
+                       return std::auto_ptr<image_base>(new alpha(*this));
+               }
+
                ~alpha();
 
-               void    set_pixel(int x, int y, uint8_t a);
+               // See dox in base class
+               bool make_next_miplevel();
+
+               /// Set pixel value 
+               //
+               /// TODO: move in base class ?
+               ///
+               void    set_pixel(size_t x, size_t y, uint8_t a);
 
                // Bitwise content comparison.
                bool    operator==(const alpha& a) const;
@@ -105,10 +250,26 @@
        enum {Y, U, V, T, NB_TEXS};
 
        yuv(int w, int h);
+
+       yuv(const yuv& o)
+               :
+               image_base(o)
+       {
+               planes[0] = o.planes[0];
+               planes[1] = o.planes[1];
+               planes[2] = o.planes[2];
+               planes[3] = o.planes[3];
+       }
+
        ~yuv() {}
-       void update(uint8_t* data);
+
+       std::auto_ptr<image_base> clone() const
+       {
+               return std::auto_ptr<image_base>(new yuv(*this));
+       }
+
+
        unsigned int video_nlpo2(unsigned int x) const;
-       int size() const;
 
        struct plane {
                unsigned int w, h, p2w, p2h, offset, size;
@@ -117,9 +278,8 @@
                float coords[4][2];
        } planes[4];
 
-       int m_size;
-
 };
+
        /// Make a system-memory 24-bit bitmap surface.  24-bit packed
        /// data, red byte first.
        DSOEXPORT rgb*  create_rgb(int width, int height);
@@ -134,11 +294,6 @@
        /// Make a system-memory 8-bit bitmap surface.
        DSOEXPORT alpha*        create_alpha(int width, int height);
 
-       
-       DSOEXPORT uint8_t*      scanline(image_base* surf, int y);
-       DSOEXPORT const uint8_t*        scanline(const image_base* surf, int y);
-
-
        DSOEXPORT void  resample(rgb* out, int out_x0, int out_y0, int out_x1, 
int out_y1,
                         rgb* in, float in_x0, float in_y0, float in_x1, float 
in_y1);
 
@@ -176,16 +331,6 @@
        /// For reading SWF JPEG3-style image data, like ordinary JPEG, 
        /// but stores the data in rgba format.
        DSOEXPORT rgba* read_swf_jpeg3(tu_file* in);
-
-       /// \brief
-       /// Fast, in-place, DESTRUCTIVE resample.  For making mip-maps.
-       /// Munges the input image to produce the output image.
-       DSOEXPORT void  make_next_miplevel(rgb* image);
-
-       /// \brief
-       /// Fast, in-place resample.  For making mip-maps.  Munges the
-       /// input image to produce the output image.
-       DSOEXPORT void  make_next_miplevel(rgba* image);
 }
 
 

Index: libbase/image_filters.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/image_filters.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- libbase/image_filters.cpp   16 Jun 2007 12:47:54 -0000      1.15
+++ libbase/image_filters.cpp   10 Sep 2007 16:53:29 -0000      1.16
@@ -11,7 +11,7 @@
 // converted from K&R C to C-like C++, changed the interfaces a bit,
 // etc.
 
-/* $Id: image_filters.cpp,v 1.15 2007/06/16 12:47:54 strk Exp $ */
+/* $Id: image_filters.cpp,v 1.16 2007/09/10 16:53:29 strk Exp $ */
 
 #include "image.h"
 #include "utility.h"
@@ -45,16 +45,16 @@
 void   get_row(uint8_t* row, image::rgb* image, int x0, int xsize, int y)
 // Copy RGB data from the specified row into the given buffer.
 {
-    y = iclamp(y, 0, image->m_height - 1);
+    y = iclamp(y, 0, image->height() - 1);
     int        x1 = x0 + xsize - 1;
-    if (x1 >= image->m_width) {
+    if (x1 >= image->width()) {
        // clip, then extend.
-       int     extra_pixels = x1 - image->m_width + 1;
-       uint8_t*        p = ((uint8_t*) image->m_data) + (y * image->m_pitch);
-       memcpy(row, p + x0 * 3, (3 * (image->m_width - x0)));
+       int     extra_pixels = x1 - image->width() + 1;
+       uint8_t*        p = ((uint8_t*) image->data()) + (y * image->pitch());
+       memcpy(row, p + x0 * 3, (3 * (image->width() - x0)));
        // repeat last pixel
-       p = p + (image->m_width - 1) * 3;
-       uint8_t*        q = row + (image->m_width - x0) * 3;
+       p = p + (image->width() - 1) * 3;
+       uint8_t*        q = row + (image->width() - x0) * 3;
        while (extra_pixels > 0) {
            *(q + 0) = *(p + 0);
            *(q + 1) = *(p + 1);
@@ -65,7 +65,7 @@
     }
     else
        {
-           memcpy(row, ((uint8_t*) image->m_data) + (y * image->m_pitch) + x0 
* 3, (3 * xsize));
+           memcpy(row, ((uint8_t*) image->data()) + (y * image->pitch()) + x0 
* 3, (3 * xsize));
        }
 }
 
@@ -73,16 +73,16 @@
 void   get_row(uint8_t* row, image::rgba* image, int x0, int xsize, int y)
 // Copy RGBA data from the specified row into the given buffer.
 {
-    y = iclamp(y, 0, image->m_height - 1);
+    y = iclamp(y, 0, image->height() - 1);
     int        x1 = x0 + xsize - 1;
-    if (x1 >= image->m_width) {
+    if (x1 >= image->width()) {
        // clip, then extend.
-       int     extra_pixels = x1 - image->m_width + 1;
-       uint8_t*        p = ((uint8_t*) image->m_data) + (y * image->m_pitch);
-       memcpy(row, p + x0 * 4, (4 * (image->m_width - x0)));
+       int     extra_pixels = x1 - image->width() + 1;
+       uint8_t*        p = ((uint8_t*) image->data()) + (y * image->pitch());
+       memcpy(row, p + x0 * 4, (4 * (image->width() - x0)));
        // repeat last pixel
-       p = p + (image->m_width - 1) * 4;
-       uint8_t*        q = row + (image->m_width - x0) * 4;
+       p = p + (image->width() - 1) * 4;
+       uint8_t*        q = row + (image->width() - x0) * 4;
        while (extra_pixels > 0) {
            *(q + 0) = *(p + 0);
            *(q + 1) = *(p + 1);
@@ -94,7 +94,7 @@
     }
     else
        {
-           memcpy(row, ((uint8_t*) image->m_data) + (y * image->m_pitch) + x0 
* 4, (4 * xsize));
+           memcpy(row, ((uint8_t*) image->data()) + (y * image->pitch()) + x0 
* 4, (4 * xsize));
        }
 }
 
@@ -103,14 +103,14 @@
 // Copy RGB data from the specified column into the given buffer.
 {
 
-    if ((x < 0) || (x >= image->m_width)) {
+    if ((x < 0) || (x >= image->width())) {
        assert(0);
-       x = iclamp(x, 0, image->m_width - 1);
+       x = iclamp(x, 0, image->width() - 1);
     }
 
-    int d = image->m_pitch;
-    uint8_t* p = ((uint8_t*) image->m_data) + x * 3;
-    for (int i = image->m_height; i-- > 0; p += d) {
+    int d = image->pitch();
+    uint8_t* p = ((uint8_t*) image->data()) + x * 3;
+    for (int i = image->height(); i-- > 0; p += d) {
        *column++ = *p;
        *column++ = *(p + 1);
        *column++ = *(p + 2);
@@ -121,14 +121,14 @@
 void   get_column(uint8_t* column, image::rgba* image, int x)
 // Copy RGBA data from the specified column into the given buffer.
 {
-    if ((x < 0) || (x >= image->m_width)) {
+    if ((x < 0) || (x >= image->width())) {
        assert(0);
-       x = iclamp(x, 0, image->m_width - 1);
+       x = iclamp(x, 0, image->width() - 1);
     }
 
-    int d = image->m_pitch;
-    uint8_t* p = ((uint8_t*) image->m_data) + x * 4;
-    for (int i = image->m_height; i-- > 0; p += d) {
+    int d = image->pitch();
+    uint8_t* p = ((uint8_t*) image->data()) + x * 4;
+    for (int i = image->height(); i-- > 0; p += d) {
        *column++ = *p;
        *column++ = *(p + 1);
        *column++ = *(p + 2);
@@ -145,14 +145,14 @@
     static int         yy = -1;
     static uint8_t*    p = NULL;
 
-    if ((x < 0) || (x >= image->m_width) || (y < 0) || (y >= image->m_height)) 
{
+    if ((x < 0) || (x >= image->width()) || (y < 0) || (y >= image->height())) 
{
        assert(0);
        return;
     }
     if ((im != image) || (yy != y)) {
        im = image;
        yy = y;
-       p = ((uint8_t*) image->m_data) + (y * image->m_pitch);
+       p = ((uint8_t*) image->data()) + (y * image->pitch());
     }
     p[x * 3 + 0] = iclamp(frnd(r), 0, 255);
     p[x * 3 + 1] = iclamp(frnd(g), 0, 255);
@@ -168,14 +168,14 @@
     static int         yy = -1;
     static uint8_t*    p = NULL;
 
-    if ((x < 0) || (x >= image->m_width) || (y < 0) || (y >= image->m_height)) 
{
+    if ((x < 0) || (x >= image->width()) || (y < 0) || (y >= image->height())) 
{
        assert(0);
        return;
     }
     if ((im != image) || (yy != y)) {
        im = image;
        yy = y;
-       p = ((uint8_t*) image->m_data) + (y * image->m_pitch);
+       p = ((uint8_t*) image->data()) + (y * image->pitch());
     }
     p[x * 4    + 0] = iclamp(frnd(r), 0, 255);
     p[x * 4    + 1] = iclamp(frnd(g), 0, 255);
@@ -373,10 +373,10 @@
 
     assert(out_x0 <= out_x1);
     assert(out_y0 <= out_y1);
-    assert(out_x0 >= 0 && out_x0 < out->m_width);
-    assert(out_x1 >= 0 && out_x1 < out->m_width);
-    assert(out_y0 >= 0 && out_y0 < out->m_height);
-    assert(out_y1 >= 0 && out_y1 < out->m_height);
+    assert(out_x0 >= 0 && out_x0 < out->width());
+    assert(out_x1 >= 0 && out_x1 < out->width());
+    assert(out_y0 >= 0 && out_y0 < out->height());
+    assert(out_y1 >= 0 && out_y1 < out->height());
 
     float      (*filter_function)(float);
     float      support;
@@ -419,11 +419,11 @@
     if (xscale == 0) { xscale = 1.0f; }
 
     /* pre-calculate filter contributions for a row */
-    contrib.resize(tmp->m_width);
+    contrib.resize(tmp->width());
     if(xscale < 1.0f) {
        width = support / xscale;
        fscale = 1.0f / xscale;
-       for (i = 0; i < tmp->m_width; ++i) {
+       for (i = 0; i < tmp->width(); ++i) {
            contrib[i].resize(0);
 
            center = (float) i / xscale;
@@ -437,7 +437,7 @@
            }
        }
     } else {
-       for (i = 0; i < tmp->m_width; ++i) {
+       for (i = 0; i < tmp->width(); ++i) {
            contrib[i].resize(0);
            center = (float) i / xscale;
            left = int(ceilf(center - support));
@@ -453,9 +453,9 @@
 
     /* apply filter to zoom horizontally from src to tmp */
     raster = (uint8_t*) my_calloc(in_window_w, 3);
-    for (k = 0; k < tmp->m_height; ++k) {
+    for (k = 0; k < tmp->height(); ++k) {
        get_row(raster, in, int(floorf(in_x0)), in_window_w, k);
-       for (i = 0; i < tmp->m_width; ++i) {
+       for (i = 0; i < tmp->width(); ++i) {
            float       red = 0.0f;
            float       green = 0.0f;
            float       blue = 0.0f;
@@ -484,7 +484,7 @@
            for (k = left; k <= right; ++k) {
                weight = center - (float) k;
                weight = (*filter_function)(weight / fscale) / fscale;
-               n = iclamp(k, 0, tmp->m_height - 1);
+               n = iclamp(k, 0, tmp->height() - 1);
                contrib[i].push_back(CONTRIB(n, weight));
            }
        }
@@ -497,15 +497,15 @@
            for(k = left; k <= right; ++k) {
                weight = center - (float) k;
                weight = (*filter_function)(weight);
-               n = iclamp(k, 0, tmp->m_height - 1);
+               n = iclamp(k, 0, tmp->height() - 1);
                contrib[i].push_back(CONTRIB(n, weight));
            }
        }
     }
 
     /* apply filter to zoom vertically from tmp to dst */
-    raster = (uint8_t*) my_calloc(tmp->m_height, 3);
-    for (k = 0; k < tmp->m_width; ++k) {
+    raster = (uint8_t*) my_calloc(tmp->height(), 3);
+    for (k = 0; k < tmp->width(); ++k) {
        get_column(raster, tmp.get(), k);
        for (i = 0; i < out_height; ++i) {
            float       red = 0.0f;
@@ -537,10 +537,10 @@
     GNASH_REPORT_FUNCTION;
     assert(out_x0 <= out_x1);
     assert(out_y0 <= out_y1);
-    assert(out_x0 >= 0 && out_x0 < out->m_width);
-    assert(out_x1 >= 0 && out_x1 < out->m_width);
-    assert(out_y0 >= 0 && out_y0 < out->m_height);
-    assert(out_y1 >= 0 && out_y1 < out->m_height);
+    assert(out_x0 >= 0 && out_x0 < out->width());
+    assert(out_x1 >= 0 && out_x1 < out->width());
+    assert(out_y0 >= 0 && out_y0 < out->height());
+    assert(out_y1 >= 0 && out_y1 < out->height());
 
     float      (*filter_function)(float);
     float      support;
@@ -584,11 +584,11 @@
     if (xscale == 0) { xscale = 1.0f; }
 
     /* pre-calculate filter contributions for a row */
-    contrib.resize(tmp->m_width);
+    contrib.resize(tmp->width());
     if(xscale < 1.0f) {
        width = support / xscale;
        fscale = 1.0f / xscale;
-       for (i = 0; i < tmp->m_width; ++i) {
+       for (i = 0; i < tmp->width(); ++i) {
            contrib[i].resize(0);
 
            center = (float) i / xscale;
@@ -602,7 +602,7 @@
            }
        }
     } else {
-       for (i = 0; i < tmp->m_width; ++i) {
+       for (i = 0; i < tmp->width(); ++i) {
            contrib[i].resize(0);
            center = (float) i / xscale;
            left = int(ceilf(center - support));
@@ -618,9 +618,9 @@
 
     /* apply filter to zoom horizontally from src to tmp */
     raster = (uint8_t*) my_calloc(in_window_w, 4);
-    for (k = 0; k < tmp->m_height; ++k) {
+    for (k = 0; k < tmp->height(); ++k) {
        get_row(raster, in, int(floorf(in_x0)), in_window_w, k);
-       for (i = 0; i < tmp->m_width; ++i) {
+       for (i = 0; i < tmp->width(); ++i) {
            float       red = 0.0f;
            float       green = 0.0f;
            float       blue = 0.0f;
@@ -651,7 +651,7 @@
            for (k = left; k <= right; ++k) {
                weight = center - (float) k;
                weight = (*filter_function)(weight / fscale) / fscale;
-               n = iclamp(k, 0, tmp->m_height - 1);
+               n = iclamp(k, 0, tmp->height() - 1);
                contrib[i].push_back(CONTRIB(n, weight));
            }
        }
@@ -664,15 +664,15 @@
            for(k = left; k <= right; ++k) {
                weight = center - (float) k;
                weight = (*filter_function)(weight);
-               n = iclamp(k, 0, tmp->m_height - 1);
+               n = iclamp(k, 0, tmp->height() - 1);
                contrib[i].push_back(CONTRIB(n, weight));
            }
        }
     }
 
     /* apply filter to zoom vertically from tmp to dst */
-    raster = (uint8_t*) my_calloc(tmp->m_height, 4);
-    for (k = 0; k < tmp->m_width; ++k) {
+    raster = (uint8_t*) my_calloc(tmp->height(), 4);
+    for (k = 0; k < tmp->width(); ++k) {
        get_column(raster, tmp.get(), k);
        for (i = 0; i < out_height; ++i) {
            float       red = 0.0f;

Index: server/FreetypeGlyphsProvider.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/FreetypeGlyphsProvider.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- server/FreetypeGlyphsProvider.cpp   19 Aug 2007 20:22:43 -0000      1.11
+++ server/FreetypeGlyphsProvider.cpp   10 Sep 2007 16:53:29 -0000      1.12
@@ -213,13 +213,14 @@
 
        std::auto_ptr<image::alpha> alpha ( image::create_alpha(w, h) );
 
-       memset(alpha->m_data, 0, alpha->m_width * alpha->m_height);
+       // TODO: replace with image_base::clear(byte value)
+       memset(alpha->data(), 0, alpha->size());
 
        // copy image to alpha
        for (int i = 0; i < bitmap.rows; i++)
        {
                uint8_t*        src = bitmap.buffer + bitmap.pitch * i;
-               uint8_t*        dst = alpha->m_data + alpha->m_pitch * i;
+               uint8_t*        dst = alpha->scanline(i); 
                int     x = bitmap.width;
                while (x-- > 0)
                {

Index: server/bitmap_info.h
===================================================================
RCS file: /sources/gnash/gnash/server/bitmap_info.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- server/bitmap_info.h        1 Jul 2007 10:54:20 -0000       1.4
+++ server/bitmap_info.h        10 Sep 2007 16:53:29 -0000      1.5
@@ -16,7 +16,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 
-/* $Id: bitmap_info.h,v 1.4 2007/07/01 10:54:20 bjacques Exp $ */
+/* $Id: bitmap_info.h,v 1.5 2007/09/10 16:53:29 strk Exp $ */
 
 #ifndef GNASH_BITMAP_INFO_H
 #define GNASH_BITMAP_INFO_H
@@ -43,8 +43,8 @@
 class DSOEXPORT bitmap_info : public ref_counted
 {
 public:
-       virtual void layout_image(image::image_base* /*im*/) { };
-       image::image_base*  m_suspended_image;
+//     virtual void layout_image(image::image_base* /*im*/) { };
+//     image::image_base*  m_suspended_image;
 
        unsigned int    m_texture_id;           // nuke?
        int             m_original_width;       // nuke?
@@ -52,7 +52,7 @@
                
        bitmap_info()
                :
-               m_suspended_image(NULL),
+//             m_suspended_image(NULL),
                m_texture_id(0),
                m_original_width(0),
                m_original_height(0)

Index: server/fill_style.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/fill_style.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- server/fill_style.cpp       10 Sep 2007 04:29:54 -0000      1.12
+++ server/fill_style.cpp       10 Sep 2007 16:53:29 -0000      1.13
@@ -409,7 +409,8 @@
         // Linear gradient.
         im = image::create_rgba(256, 1);
 
-        for (int i = 0; i < im->m_width; i++) {
+        for (size_t i = 0; i < im->width(); i++)
+       {
             rgba       sample = sample_gradient(i);
             im->set_pixel(i, 0, sample.m_r, sample.m_g, sample.m_b, 
sample.m_a);
         }
@@ -419,9 +420,9 @@
         // Radial gradient.
         im = image::create_rgba(64, 64);
 
-        for (int j = 0; j < im->m_height; j++) {
-            for (int i = 0; i < im->m_width; i++) {
-                float  radius = (im->m_height - 1) / 2.0f;
+        for (size_t j = 0; j < im->height(); j++) {
+            for (size_t i = 0; i < im->width(); i++) {
+                float  radius = (im->height() - 1) / 2.0f;
                 float  y = (j - radius) / radius;
                 float  x = (i - radius) / radius;
                 int    ratio = (int) floorf(255.5f * sqrt(x * x + y * y));
@@ -438,11 +439,11 @@
                // Focal gradient.
                im = image::create_rgba(64, 64);
 
-               for (int j = 0; j < im->m_height; j++)
+               for (size_t j = 0; j < im->height(); j++)
                {
-                       for (int i = 0; i < im->m_width; i++)
+                       for (size_t i = 0; i < im->width(); i++)
                        {
-                               float radiusy = (im->m_height - 1) / 2.0f;
+                               float radiusy = (im->height() - 1) / 2.0f;
                                float radiusx = radiusy + abs(radiusy * 
m_focal_point);
                                float y = (j - radiusy) / radiusy;
                                float x = (i - radiusx) / radiusx;

Index: server/fontlib.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/fontlib.cpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- server/fontlib.cpp  24 Jul 2007 19:43:30 -0000      1.33
+++ server/fontlib.cpp  10 Sep 2007 16:53:29 -0000      1.34
@@ -5,7 +5,7 @@
 
 // A module to take care of all of gnash's loaded fonts.
 
-/* $Id: fontlib.cpp,v 1.33 2007/07/24 19:43:30 strk Exp $ */
+/* $Id: fontlib.cpp,v 1.34 2007/09/10 16:53:29 strk Exp $ */
 
 #include "container.h"
 #include "tu_file.h"
@@ -58,7 +58,7 @@
        static const int        OVERSAMPLE_FACTOR = (1 << OVERSAMPLE_BITS);
 
        // The dimensions of the textures that the glyphs get packed into.
-       static const int        GLYPH_CACHE_TEXTURE_SIZE = 256;
+       static const size_t     GLYPH_CACHE_TEXTURE_SIZE = 256;
 
        // How much space to leave around the individual glyph image.
        // This should be at least 1.  The bigger it is, the smoother
@@ -71,10 +71,10 @@
        static int      s_glyph_render_size = s_glyph_nominal_size << 
OVERSAMPLE_BITS;
 
        
-       void    set_nominal_glyph_pixel_size(int pixel_size)
+       void    set_nominal_glyph_pixel_size(size_t pixel_size)
        {
-               static const int        MIN_SIZE = 4;
-               static const int        MAX_SIZE = GLYPH_CACHE_TEXTURE_SIZE / 2;
+               static const size_t     MIN_SIZE = 4;
+               static const size_t     MAX_SIZE = GLYPH_CACHE_TEXTURE_SIZE / 2;
 
                if (pixel_size < MIN_SIZE)
                {
@@ -249,7 +249,7 @@
                if (fp)
                {
                        fprintf(fp, "P6\n%d %d\n255\n", 
GLYPH_CACHE_TEXTURE_SIZE, GLYPH_CACHE_TEXTURE_SIZE);
-                       for (int i = 0; i < GLYPH_CACHE_TEXTURE_SIZE * 
GLYPH_CACHE_TEXTURE_SIZE; i++)
+                       for (size_t i = 0; i < GLYPH_CACHE_TEXTURE_SIZE * 
GLYPH_CACHE_TEXTURE_SIZE; i++)
                        {
                                fputc(s_current_cache_image[i], fp);
                                fputc(s_current_cache_image[i], fp);
@@ -271,8 +271,8 @@
                        }
                        else
                        {
-                               int w = GLYPH_CACHE_TEXTURE_SIZE;
-                               int h = GLYPH_CACHE_TEXTURE_SIZE;
+                               size_t w = GLYPH_CACHE_TEXTURE_SIZE;
+                               size_t h = GLYPH_CACHE_TEXTURE_SIZE;
 
                                // save bitmap size
                                s_file->write_le16(w);
@@ -317,8 +317,8 @@
                assert(r.m_x_min >= 0);
                assert(r.m_y_min >= 0);
 
-               if (r.m_x_max > GLYPH_CACHE_TEXTURE_SIZE
-                   || r.m_y_max > GLYPH_CACHE_TEXTURE_SIZE)
+               if ((size_t)r.m_x_max > GLYPH_CACHE_TEXTURE_SIZE
+                   || (size_t)r.m_y_max > GLYPH_CACHE_TEXTURE_SIZE)
                {
                        // Rect overflows the texture bounds.
                        return false;
@@ -380,7 +380,7 @@
        }
 
 
-       bool    pack_rectangle(int* px, int* py, int width, int height)
+       bool    pack_rectangle(int* px, int* py, size_t width, size_t height)
        // Find a spot for the rectangle in the current cache image.
        // Return true if there's a spot; false if there's no room.
        {
@@ -627,13 +627,13 @@
                        rgi.m_offset_y = offset_y / s_rendering_box * 
s_glyph_nominal_size - min_y;
 
                        // Copy the rendered glyph into the new image.
-                       {for (int j = 0, n = rgi.m_image->m_height; j < n; j++)
+                       for (size_t j = 0, n = rgi.m_image->height(); j < n; 
j++)
                        {
                                memcpy(
-                                       image::scanline(rgi.m_image, j),
+                                       rgi.m_image->scanline(j),
                                        output + (min_y + j) * 
s_glyph_nominal_size + min_x,
-                                       rgi.m_image->m_width);
-                       }}
+                                       rgi.m_image->width());
+                       }
                }
                else
                {
@@ -786,8 +786,8 @@
                                const rendered_glyph_info*      ga = (const 
rendered_glyph_info*) a;
                                const rendered_glyph_info*      gb = (const 
rendered_glyph_info*) b;
 
-                               int     a_size = ga->m_image->m_width + 
ga->m_image->m_height;
-                               int     b_size = gb->m_image->m_width + 
gb->m_image->m_height;
+                               int     a_size = ga->m_image->width() + 
ga->m_image->height();
+                               int     b_size = gb->m_image->width() + 
gb->m_image->height();
 
                                return b_size - a_size;
                        }
@@ -822,12 +822,12 @@
                                        break;
                                }
 
-                               int     raw_width = rgi.m_image->m_width;
-                               int     raw_height = rgi.m_image->m_height;
+                               size_t  raw_width = rgi.m_image->width();
+                               size_t  raw_height = rgi.m_image->height();
 
                                // Need to pad around the outside.
-                               int     width = raw_width + (PAD_PIXELS * 2);
-                               int     height = raw_height + (PAD_PIXELS * 2);
+                               size_t  width = raw_width + (PAD_PIXELS * 2);
+                               size_t  height = raw_height + (PAD_PIXELS * 2);
 
                                assert(width < GLYPH_CACHE_TEXTURE_SIZE);
                                assert(height < GLYPH_CACHE_TEXTURE_SIZE);
@@ -839,12 +839,12 @@
                                {
                                        // Fits!
                                        // Blit the output image into its new 
spot.
-                                       for (int j = 0; j < raw_height; j++)
+                                       for (size_t j = 0; j < raw_height; j++)
                                        {
                                                memcpy(s_current_cache_image
                                                       + (pack_y + PAD_PIXELS + 
j) * GLYPH_CACHE_TEXTURE_SIZE
                                                       + pack_x + PAD_PIXELS,
-                                                      
image::scanline(rgi.m_image, j),
+                                                      rgi.m_image->scanline(j),
                                                       raw_width);
                                        }
 

Index: server/fontlib.h
===================================================================
RCS file: /sources/gnash/gnash/server/fontlib.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- server/fontlib.h    13 Jul 2007 16:05:09 -0000      1.8
+++ server/fontlib.h    10 Sep 2007 16:53:29 -0000      1.9
@@ -88,7 +88,7 @@
        // Applies to fonts processed *after* this call only.
        // The "nominal" size is perhaps around twice the
        // average glyph height.
-       void    set_nominal_glyph_pixel_size(int pixel_size);
+       void    set_nominal_glyph_pixel_size(size_t pixel_size);
 
        /// Clean up the font library
        void    clear();

Index: server/asobj/NetStream.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetStream.cpp,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -b -r1.70 -r1.71
--- server/asobj/NetStream.cpp  31 Aug 2007 21:53:32 -0000      1.70
+++ server/asobj/NetStream.cpp  10 Sep 2007 16:53:30 -0000      1.71
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: NetStream.cpp,v 1.70 2007/08/31 21:53:32 strk Exp $ */
+/* $Id: NetStream.cpp,v 1.71 2007/09/10 16:53:30 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -556,20 +556,10 @@
 {
        boost::mutex::scoped_lock lock(image_mutex);
 
-       // TODO: inspect if we could return m_imageframe directly...
-
-       std::auto_ptr<image::image_base> ret_image;
-
-       if (!m_imageframe) return ret_image;
+       if (!m_imageframe) return std::auto_ptr<image::image_base>(0);
 
-       if (m_videoFrameFormat == render::YUV) {
-               ret_image.reset(new image::yuv(m_imageframe->m_width, 
m_imageframe->m_height));
-       } else if (m_videoFrameFormat == render::RGB) {
-               ret_image.reset(new image::rgb(m_imageframe->m_width, 
m_imageframe->m_height));
-       } 
-
-       ret_image->update(m_imageframe->m_data);
-       return ret_image;
+       // TODO: inspect if we could return m_imageframe directly...
+       return m_imageframe->clone();
 }
 
 std::pair<const char*, const char*>

Index: server/asobj/NetStreamFfmpeg.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetStreamFfmpeg.cpp,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -b -r1.89 -r1.90
--- server/asobj/NetStreamFfmpeg.cpp    6 Sep 2007 12:21:06 -0000       1.89
+++ server/asobj/NetStreamFfmpeg.cpp    10 Sep 2007 16:53:30 -0000      1.90
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: NetStreamFfmpeg.cpp,v 1.89 2007/09/06 12:21:06 tgc Exp $ */
+/* $Id: NetStreamFfmpeg.cpp,v 1.90 2007/09/10 16:53:30 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -582,8 +582,11 @@
 static void
 rgbcopy(image::rgb* dst, raw_mediadata_t* src, int width)
 {
-       assert(src->m_size <= static_cast<uint32_t>(dst->m_width * 
dst->m_height * 3));
+       assert( dst->size() >= src->m_size ); 
+       assert( dst->pitch() >= width );
+       dst->update(src->m_data);
 
+#if 0
        uint8_t* dstptr = dst->m_data;
 
        uint8_t* srcptr = src->m_data;
@@ -594,6 +597,7 @@
                dstptr += dst->m_pitch;
                srcptr += width;
        }
+#endif
 }
 
 // decoder thread
@@ -859,7 +863,7 @@
                        video->m_data = new 
uint8_t[static_cast<image::yuv*>(m_imageframe)->size()];
                } else if (m_videoFrameFormat == render::RGB) {
                        image::rgb* tmp = 
static_cast<image::rgb*>(m_imageframe);
-                       video->m_data = new uint8_t[tmp->m_pitch * 
tmp->m_height];
+                       video->m_data = new uint8_t[m_imageframe->size()]; // 
tmp->m_pitch * tmp->m_height];
                }
 
                video->m_ptr = video->m_data;

Index: server/parser/BitmapMovieDefinition.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/parser/BitmapMovieDefinition.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- server/parser/BitmapMovieDefinition.cpp     1 Jul 2007 10:54:33 -0000       
1.11
+++ server/parser/BitmapMovieDefinition.cpp     10 Sep 2007 16:53:30 -0000      
1.12
@@ -1,4 +1,4 @@
-// BitmapMovieDefinition.cpp:  , for Gnash.
+// BitmapMovieDefinition.cpp:  Bitmap movie definition, for Gnash.
 // 
 //   Copyright (C) 2007 Free Software Foundation, Inc.
 // 
@@ -82,7 +82,7 @@
        :
        _version(6),
        // image::rgb size is in pixels
-       _framesize(0, 0, image->m_width*20, image->m_height*20),
+       _framesize(0, 0, image->width()*20, image->height()*20),
        _framecount(1),
        _playlist(_framecount),
        _framerate(12),

Index: server/swf/tag_loaders.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/swf/tag_loaders.cpp,v
retrieving revision 1.136
retrieving revision 1.137
diff -u -b -r1.136 -r1.137
--- server/swf/tag_loaders.cpp  4 Sep 2007 11:27:43 -0000       1.136
+++ server/swf/tag_loaders.cpp  10 Sep 2007 16:53:30 -0000      1.137
@@ -1,4 +1,4 @@
-// tag_loaders.cpp:  for Gnash.
+// tag_loaders.cpp: SWF tags loaders, for Gnash.
 //
 //   Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
 //
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: tag_loaders.cpp,v 1.136 2007/09/04 11:27:43 cmusick Exp $ */
+/* $Id: tag_loaders.cpp,v 1.137 2007/09/10 16:53:30 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -748,23 +748,29 @@
        // Read rgb data.
        std::auto_ptr<tu_file> ad( StreamAdapter::getFile(*in) );
        std::auto_ptr<image::rgba> im( image::read_swf_jpeg3(ad.get()) );
-       //std::auto_ptr<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];
+       size_t imWidth = im->width();
+       size_t imHeight = im->height();
 
-       inflate_wrapper(*in, buffer, buffer_bytes);
+       size_t  buffer_bytes = imWidth * imHeight;
 
+       boost::scoped_array<uint8_t> buffer ( new uint8_t[buffer_bytes] );
+
+       inflate_wrapper(*in, buffer.get(), buffer_bytes);
+
+       // TESTING:
+       // magical trevor contains this tag
+       //  ea8bbad50ccbc52dd734dfc93a7f06a7  6964trev3c.swf
+       //
+       uint8_t* data = im->data();
        for (int i = 0; i < buffer_bytes; i++)
        {
-           im->m_data[4*i+3] = buffer[i];
+           data[4*i+3] = buffer[i];
        }
 
-       delete [] buffer;
-
        // Create bitmap character.
        bitmap_character_def* ch = new bitmap_character_def(im);
 
@@ -832,7 +838,7 @@
                for (int j = 0; j < height; j++)
                {
                    uint8_t*    image_in_row = buffer.get() + color_table_size 
* 3 + j * pitch;
-                   uint8_t*    image_out_row = image::scanline(image.get(), j);
+                   uint8_t*    image_out_row = image->scanline(j);
                    for (int i = 0; i < width; i++)
                    {
                        uint8_t pixel = image_in_row[i * bytes_per_pixel];
@@ -858,7 +864,7 @@
                for (int j = 0; j < height; j++)
                {
                    uint8_t*    image_in_row = buffer.get() + j * pitch;
-                   uint8_t*    image_out_row = image::scanline(image.get(), j);
+                   uint8_t*    image_out_row = image->scanline(j);
                    for (int i = 0; i < width; i++)
                    {
                        uint16_t        pixel = image_in_row[i * 2] | 
(image_in_row[i * 2 + 1] << 8);
@@ -887,7 +893,7 @@
                for (int j = 0; j < height; j++)
                {
                    uint8_t*    image_in_row = buffer.get() + j * pitch;
-                   uint8_t*    image_out_row = image::scanline(image.get(), j);
+                   uint8_t*    image_out_row = image->scanline(j);
                    for (int i = 0; i < width; i++)
                    {
                        uint8_t a = image_in_row[i * 4 + 0];
@@ -946,7 +952,7 @@
                for (int j = 0; j < height; j++)
                {
                    uint8_t*    image_in_row = buffer.get() + color_table_size 
* 4 + j * pitch;
-                   uint8_t*    image_out_row = image::scanline(image.get(), j);
+                   uint8_t*    image_out_row = image->scanline(j);
                    for (int i = 0; i < width; i++)
                    {
                        uint8_t pixel = image_in_row[i * bytes_per_pixel];
@@ -973,7 +979,7 @@
                for (int j = 0; j < height; j++)
                {
                    uint8_t*    image_in_row = buffer.get() + j * pitch;
-                   uint8_t*    image_out_row = image::scanline(image.get(), j);
+                   uint8_t*    image_out_row = image->scanline(j);
                    for (int i = 0; i < width; i++)
                    {
                        uint16_t        pixel = image_in_row[i * 2] | 
(image_in_row[i * 2 + 1] << 8);
@@ -991,13 +997,13 @@
            {
                // 32 bits / pixel, input is ARGB format
 
-               inflate_wrapper(*in, image->m_data, width * height * 4);
+               inflate_wrapper(*in, image->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.get(), j);
+                   uint8_t*    image_row = image->scanline(j);
                    for (int i = 0; i < width; i++)
                    {
                        uint8_t a = image_row[i * 4 + 0];




reply via email to

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