gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r9967: Rework the expected resampler


From: Sandro Santilli
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r9967: Rework the expected resampler output size computation, and put the abort
Date: Wed, 08 Oct 2008 17:47:29 +0200
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 9967
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Wed 2008-10-08 17:47:29 +0200
message:
  Rework the expected resampler output size computation, and put the abort
  back. Seems sane now.
modified:
  libmedia/ffmpeg/AudioDecoderFfmpeg.cpp
=== modified file 'libmedia/ffmpeg/AudioDecoderFfmpeg.cpp'
--- a/libmedia/ffmpeg/AudioDecoderFfmpeg.cpp    2008-10-08 15:19:19 +0000
+++ b/libmedia/ffmpeg/AudioDecoderFfmpeg.cpp    2008-10-08 15:47:29 +0000
@@ -24,7 +24,7 @@
 #include <cmath> // for std::ceil
 #include <algorithm> // for std::copy, std::max
 
-#define GNASH_DEBUG_AUDIO_DECODING
+//#define GNASH_DEBUG_AUDIO_DECODING
 
 #ifdef FFMPEG_AUDIO2
 # define AVCODEC_DECODE_AUDIO avcodec_decode_audio2
@@ -392,17 +392,19 @@
                bool stereo = _audioCodecCtx->channels > 1 ? true : false;
                int samples = stereo ? outSize >> 2 : outSize >> 1;
 
-               int resampledFrameSize = int(std::ceil(outSize*resampleFactor));
-        // Make it an even number as it's going to be considered an array of 
int16..
-        if ( resampledFrameSize&0x01 ) ++resampledFrameSize;
+        int expectedMaxOutSamples = std::ceil(samples*resampleFactor);
+
+        // *channels *sampleSize 
+               int resampledFrameSize = expectedMaxOutSamples*2*2;
 
                // Allocate just the required amount of bytes
                boost::uint8_t* resampledOutput = new 
boost::uint8_t[resampledFrameSize]; 
 
 #ifdef GNASH_DEBUG_AUDIO_DECODING
-               log_debug("Calling the resampler; "
+               log_debug("Calling the resampler; resampleFactor:%d; "
                        "ouput to 44100hz, 2channels, %dbytes; "
                        "input is %dhz, %dchannels, %dbytes, %dsamples",
+            resampleFactor,
                        resampledFrameSize, _audioCodecCtx->sample_rate,
             _audioCodecCtx->channels, outSize, samples);
 #endif
@@ -419,10 +421,10 @@
                outPtr = reinterpret_cast<boost::int16_t*>(resampledOutput);
                delete [] output;
 
-               if (resampledFrameSize < samples*2*2)
+               if (expectedMaxOutSamples < samples)
                {
-                       log_error(" --- Computation of resampled frame size 
(%d) < then the one based on samples (%d)",
-                               resampledFrameSize, samples*2*2);
+                       log_error(" --- Computation of resampled samples (%d) < 
then the actual returned samples (%d)",
+                               expectedMaxOutSamples, samples);
 
                        log_debug(" input frame size: %d", outSize);
                        log_debug(" input sample rate: %d", 
_audioCodecCtx->sample_rate);
@@ -434,7 +436,7 @@
                        log_debug(" output samples: %d", samples);
 
             /// Memory errors...
-                       //abort();
+                       abort();
                }
 
                // we let the consistency check run before we override outSize


reply via email to

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