Update of /cvsroot/libwpg/libwpg/src/lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2314/src/lib
Modified Files:
Tag: STABLE-0-1-0
WPG1Parser.cpp WPG2Parser.cpp
Log Message:
some optimizations + change in handling corrupted bitmap
Index: WPG2Parser.cpp
===================================================================
RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v
retrieving revision 1.58.2.13
retrieving revision 1.58.2.14
diff -u -d -r1.58.2.13 -r1.58.2.14
--- WPG2Parser.cpp 23 Jul 2008 14:42:16 -0000 1.58.2.13
+++ WPG2Parser.cpp 23 Jul 2008 15:05:30 -0000 1.58.2.14
@@ -1457,6 +1457,8 @@
std::vector<unsigned char> buffer;
+ buffer.reserve(tmpBufferSize);
+
// plain data, uncompression
if(compression_format==0)
for(unsigned ii=0; ii < tmpBufferSize && m_input->tell() <= m_recordEnd; ii++)
@@ -1483,7 +1485,10 @@
{
data_size = new_data_size;
if (tmpBufferSize < data_size*width*height)
+ {
tmpBufferSize = data_size*width*height;
+ buffer.reserve(tmpBufferSize);
+ }
raster_len = data_size*width;
}
}
@@ -1522,7 +1527,7 @@
{
unsigned count = 1 + readU8();
if ( buffer.size() < raster_len )
- return;
+ break;
unsigned raster_source = buffer.size() - raster_len;
for( ; count; --count)
for(unsigned long r = 0; r < raster_len; r++)
Index: WPG1Parser.cpp
===================================================================
RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG1Parser.cpp,v
retrieving revision 1.33.2.9
retrieving revision 1.33.2.10
diff -u -d -r1.33.2.9 -r1.33.2.10
--- WPG1Parser.cpp 23 Jul 2008 09:54:17 -0000 1.33.2.9
+++ WPG1Parser.cpp 23 Jul 2008 15:05:30 -0000 1.33.2.10
@@ -510,6 +510,8 @@
// round to the next byte
unsigned scanline_width = (width * depth + 7)/8;
+ unsigned tmpBufferSize = scanline_width * height;
+ buffer.reserve(tmpBufferSize);
WPG_DEBUG_MSG(("Scanline width: %d\n", scanline_width));
WPG_DEBUG_MSG(("Output size: %d\n", scanline_width * height));
@@ -544,8 +546,7 @@
if (buffer.size() < scanline_width )
{
WPG_DEBUG_MSG(("Cannot copy the scanline, not enough data %li\n", (long)buffer.size()));
- buffer.clear();
- return;
+ break;
}
unsigned raster_source = buffer.size() - scanline_width;
for( ; count; --count)
@@ -559,6 +560,9 @@
}
WPG_DEBUG_MSG(("Finish decoding RLE data\n"));
WPG_DEBUG_MSG(("Buffer length: %li\n", (long)buffer.size()));
+
+ for ( ; buffer.size() < tmpBufferSize ; )
+ buffer.push_back(0);
}
void WPG1Parser::fillPixels(libwpg::WPGBitmap& bitmap, const unsigned char* buffer, int width, int height, int depth)
|