[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/stream.h server/swf/tag_...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/stream.h server/swf/tag_... |
Date: |
Thu, 09 Aug 2007 04:18:38 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/08/09 04:18:38
Modified files:
. : ChangeLog
server : stream.h
server/swf : tag_loaders.cpp
Log message:
* server/stream.h (ensureBytes): be more verbose about the lack
of
data. Fix signed/unsigned comparison.
* server/swf/tag_loaders.cpp (adpcm_expand): fix count of needed
bytes. Fixes bug #20725.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3970&r2=1.3971
http://cvs.savannah.gnu.org/viewcvs/gnash/server/stream.h?cvsroot=gnash&r1=1.22&r2=1.23
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf/tag_loaders.cpp?cvsroot=gnash&r1=1.122&r2=1.123
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3970
retrieving revision 1.3971
diff -u -b -r1.3970 -r1.3971
--- ChangeLog 8 Aug 2007 20:51:38 -0000 1.3970
+++ ChangeLog 9 Aug 2007 04:18:37 -0000 1.3971
@@ -1,3 +1,10 @@
+2007-08-09 Sandro Santilli <address@hidden>
+
+ * server/stream.h (ensureBytes): be more verbose about the lack of
+ data. Fix signed/unsigned comparison.
+ * server/swf/tag_loaders.cpp (adpcm_expand): fix count of needed
+ bytes. Fixes bug #20725.
+
2007-08-08 Benjamin Wolsey <address@hidden>
* plugin/plugin.cpp: replicate compatibility version to the end, to
Index: server/stream.h
===================================================================
RCS file: /sources/gnash/gnash/server/stream.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- server/stream.h 7 Aug 2007 20:53:10 -0000 1.22
+++ server/stream.h 9 Aug 2007 04:18:37 -0000 1.23
@@ -15,6 +15,7 @@
#include "GnashException.h"
#include <string>
+#include <sstream>
// Define the following macro if you want to want Gnash parser
// to assume the underlying SWF is well-formed. It would make
@@ -194,9 +195,12 @@
void ensureBytes(unsigned long needed)
{
#ifndef GNASH_TRUST_SWF_INPUT
- if ( get_tag_end_position() - get_position() < needed )
+ unsigned long int left = get_tag_end_position() -
get_position();
+ if ( left < needed )
{
- throw ParserException("premature end of tag");
+ std::stringstream ss;
+ ss << "premature end of tag: need to read " <<
needed << " bytes, but only " << left << " left in this tag";
+ throw ParserException(ss.str());
}
#endif
}
Index: server/swf/tag_loaders.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/swf/tag_loaders.cpp,v
retrieving revision 1.122
retrieving revision 1.123
diff -u -b -r1.122 -r1.123
--- server/swf/tag_loaders.cpp 8 Aug 2007 18:26:38 -0000 1.122
+++ server/swf/tag_loaders.cpp 9 Aug 2007 04:18:38 -0000 1.123
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: tag_loaders.cpp,v 1.122 2007/08/08 18:26:38 strk Exp $ */
+/* $Id: tag_loaders.cpp,v 1.123 2007/08/09 04:18:38 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -1054,7 +1054,7 @@
sound_handler* handler = get_sound_handler();
- in->ensureBytes(2+1+4); // character id + flags + sample count
+ in->ensureBytes(2+4+1+4); // character id + flags + sample count
uint16_t character_id = in->read_u16();
@@ -1318,6 +1318,7 @@
case sound_handler::FORMAT_ADPCM:
{
+ //log_debug("ADPCM format");
// Uncompress the ADPCM before handing data to host.
if (sample_count == 0) sample_count = data_bytes / ( stereo ? 4 : 2 );
adpcm_expand(data, in, sample_count, stereo);
@@ -1326,6 +1327,7 @@
break;
}
case sound_handler::FORMAT_RAW:
+ //log_debug("RAW format");
// 8- or 16-bit mono or stereo host-endian audio
// Convert to 16-bit host-endian
if (sample_16bit) {
@@ -1344,6 +1346,7 @@
break;
case sound_handler::FORMAT_UNCOMPRESSED:
+ //log_debug("UNCOMPRESSED format");
// 8- or 16-bit mono or stereo little-endian audio
// Convert to 16-bit host-endian.
if (!sample_16bit)
@@ -1393,6 +1396,7 @@
break;
case sound_handler::FORMAT_MP3:
+ //log_debug("MP3 format");
// Decompressed elsewhere
in->ensureBytes(data_bytes);
data = new unsigned char[data_bytes];
@@ -1401,6 +1405,7 @@
case sound_handler::FORMAT_NELLYMOSER_8HZ_MONO:
case sound_handler::FORMAT_NELLYMOSER:
+ //log_debug("NELLYMOSER format");
// One day...
in->ensureBytes(data_bytes);
in->skip_bytes(data_bytes);
@@ -1410,6 +1415,7 @@
// This is impossible as an input but stops fussy compilers
// complaining about unhandled enum values.
case sound_handler::FORMAT_NATIVE16:
+ //log_debug("NATIVE16 format");
break;
}
}
@@ -1738,7 +1744,7 @@
static void adpcm_expand(
unsigned char* &data,
stream* in,
- int sample_count, // in stereo, this is number of *pairs* of
samples
+ int sample_count, // in stereo, this is number of *pairs* of
samples (TODO: why is this signed at all ??)
bool stereo)
{
int16_t* out_data = new int16_t[stereo ? sample_count*2 : sample_count];
@@ -1746,11 +1752,27 @@
// Read header.
in->ensureBytes(2); // header size
- int n_bits = in->read_uint(2) + 2; // 2 to 5 bits
+ unsigned int n_bits = in->read_uint(2) + 2; // 2 to 5 bits (TODO:
use unsigned...)
+
+
+#ifndef GNASH_TRUST_SWF_INPUT
+
+ // bitsPerSample is the number of bits for each sample
+ unsigned int bitsPerSample = n_bits;
+ if (stereo) bitsPerSample *= 2;
+
+ // There's going to be one block every 4096 samples (or fraction)
+ unsigned int blocksCount = (unsigned int)ceil(sample_count/4096);
+
+ // Every block will have an header of 22 bits
+ unsigned int bitsPerBlock = 22;
+
+ unsigned long bytesNeeded = (unsigned long)ceil( (
(sample_count*bitsPerSample) + (bitsPerBlock * blocksCount) ) / 8 );
+
+ //log_debug("adpcm_expand, stereo:%d, sample_count:%d, nbits:%d,
bytesNeeded:%d", stereo, sample_count, n_bits, bytesNeeded);
- // 4 is the fixed header for each sample ( 16bit sample id, 6bit
stepsize_index )
- // nbits is the number of bits for each sample
- in->ensureBytes( sample_count * ( 3 + (int)ceil(n_bits/8) ) );
+ in->ensureBytes(bytesNeeded);
+#endif // GNASH_TRUST_SWF_INPUT
while (sample_count)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog server/stream.h server/swf/tag_...,
Sandro Santilli <=