[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog libmedia/AudioDecoderSimple.cpp
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog libmedia/AudioDecoderSimple.cpp |
Date: |
Tue, 04 Dec 2007 22:03:30 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/12/04 22:03:30
Modified files:
. : ChangeLog
libmedia : AudioDecoderSimple.cpp
Log message:
(decode): don't leak BitsReader objects, minor cleanups (still sucks
pretty much).
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5084&r2=1.5085
http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/AudioDecoderSimple.cpp?cvsroot=gnash&r1=1.10&r2=1.11
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5084
retrieving revision 1.5085
diff -u -b -r1.5084 -r1.5085
--- ChangeLog 4 Dec 2007 21:42:17 -0000 1.5084
+++ ChangeLog 4 Dec 2007 22:03:29 -0000 1.5085
@@ -1,5 +1,7 @@
2007-12-04 Sandro Santilli <address@hidden>
+ * libmedia/AudioDecoderSimple.cpp (decode): don't leak BitsReader
+ objects, minor cleanups (still sucks pretty much).
* server/parser/video_stream_def.cpp (readDefineVideoFrame): read all
data at once rather then reading a byte each iteration of a loop,
read frame number from tag, improve robustness and other minor
cleanups.
Index: libmedia/AudioDecoderSimple.cpp
===================================================================
RCS file: /sources/gnash/gnash/libmedia/AudioDecoderSimple.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- libmedia/AudioDecoderSimple.cpp 4 Dec 2007 11:45:25 -0000 1.10
+++ libmedia/AudioDecoderSimple.cpp 4 Dec 2007 22:03:30 -0000 1.11
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-// $Id: AudioDecoderSimple.cpp,v 1.10 2007/12/04 11:45:25 strk Exp $
+// $Id: AudioDecoderSimple.cpp,v 1.11 2007/12/04 22:03:30 strk Exp $
#include "AudioDecoderSimple.h"
#include "utility.h"
@@ -91,15 +91,15 @@
}
/* Uncompress 4096 mono samples of ADPCM. */
- static boost::uint32_t doMonoBlock(boost::int16_t** out_data, int
n_bits, BitsReader* in, int sample, int stepsize_index)
+ static boost::uint32_t doMonoBlock(boost::int16_t** out_data, int
n_bits, BitsReader& in, int sample, int stepsize_index)
{
/* First sample doesn't need to be decompressed. */
boost::uint32_t sample_count = 1;
*(*out_data)++ = (boost::int16_t) sample;
- while (sample_count < 4096 && in->gotBits(n_bits))
+ while (sample_count < 4096 && in.gotBits(n_bits))
{
- int raw_code = in->read_uint(n_bits);
+ int raw_code = in.read_uint(n_bits);
doSample(n_bits, sample, stepsize_index, raw_code);
/* sample & stepsize_index are in/out params */
*(*out_data)++ = (boost::int16_t) sample;
@@ -113,7 +113,7 @@
static int doStereoBlock(
boost::int16_t** out_data, // in/out param
int n_bits,
- BitsReader* in,
+ BitsReader& in,
int left_sample,
int left_stepsize_index,
int right_sample,
@@ -125,13 +125,14 @@
*(*out_data)++ = (boost::int16_t) left_sample;
*(*out_data)++ = (boost::int16_t) right_sample;
- while (sample_count < 4096 && in->gotBits(n_bits*2))
+ unsigned bitsNeeded = n_bits*2;
+ while (sample_count < 4096 && in.gotBits(bitsNeeded))
{
- int left_raw_code = in->read_uint(n_bits);
+ int left_raw_code = in.read_uint(n_bits);
doSample(n_bits, left_sample, left_stepsize_index,
left_raw_code);
*(*out_data)++ = (boost::int16_t) left_sample;
- int right_raw_code = in->read_uint(n_bits);
+ int right_raw_code = in.read_uint(n_bits);
doSample(n_bits, right_sample, right_stepsize_index,
right_raw_code);
*(*out_data)++ = (boost::int16_t) right_sample;
@@ -146,27 +147,33 @@
// out_data[]. Returns the output samplecount.
static boost::uint32_t adpcm_expand(
unsigned char* &data,
- BitsReader* in,
+ BitsReader& in,
unsigned int insize,
bool stereo)
{
+ // Read header.
+ if ( ! in.gotBits(2) )
+ {
+ IF_VERBOSE_MALFORMED_SWF(
+ log_swferror(_("corrupted ADPCM header"));
+ );
+ return 0;
+ }
+ unsigned int n_bits = in.read_uint(2) + 2; // 2 to 5 bits
+
// The compression ratio is 4:1, so this should be enough...
boost::int16_t* out_data = new boost::int16_t[insize * 5];
data = reinterpret_cast<unsigned char *>(out_data);
- // Read header.
- //in->ensureBytes(1); // nbits
- unsigned int n_bits = in->read_uint(2) + 2; // 2 to 5 bits
(TODO: use unsigned...)
-
boost::uint32_t sample_count = 0;
- while (/*sample_count && !in->overread()*/in->gotBits(22))
+ while ( in.gotBits(22) )
{
// Read initial sample & index values.
- int sample = in->read_sint(16);
+ int sample = in.read_sint(16);
- int stepsize_index = in->read_uint(6);
+ int stepsize_index = in.read_uint(6);
assert(STEPSIZE_CT >= (1 << 6)); // ensure we
don't need to clamp.
if (stereo == false)
@@ -190,9 +197,9 @@
// Got values for left channel; now get initial
sample
// & index for right channel.
- int right_sample = in->read_sint(16);
+ int right_sample = in.read_sint(16);
- int right_stepsize_index = in->read_uint(6);
+ int right_stepsize_index = in.read_uint(6);
assert(STEPSIZE_CT >= (1 << 6)); //
ensure we don't need to clamp.
if (n_bits == 0) {
@@ -321,7 +328,8 @@
case AUDIO_CODEC_ADPCM:
{
//boost::uint32_t sample_count = inputSize * ( _stereo ? 1 : 2
); //(_sampleCount == 0 ? inputSize / ( _stereo ? 4 : 2 ) : _sampleCount);
- boost::uint32_t sample_count =
ADPCMDecoder::adpcm_expand(decodedData, new BitsReader(input,inputSize),
inputSize, _stereo);
+ BitsReader br(input, inputSize);
+ boost::uint32_t sample_count =
ADPCMDecoder::adpcm_expand(decodedData, br, inputSize, _stereo);
outsize = sample_count * (_stereo ? 4 : 2);
}
break;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog libmedia/AudioDecoderSimple.cpp,
Sandro Santilli <=