gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] [patch #8747] Patches to fix 8-bit PCM sound wailing/cras


From: Nutchanon Wetchasit
Subject: [Gnash-commit] [patch #8747] Patches to fix 8-bit PCM sound wailing/crashing in FFmpeg media backend
Date: Wed, 23 Sep 2015 04:32:24 +0000
User-agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.12) Gecko/20100101 Firefox/10.0.12 Iceweasel/10.0.12

Follow-up Comment #9, patch #8747 (project gnash):

Does following comments look okay (for patch 3 and patch 5)?

3/5: 0006_use-correct-8bit-pcm-ffmpeg-codec.patch:

            case AUDIO_CODEC_UNCOMPRESSED:
            case AUDIO_CODEC_RAW:
                if (info.sampleSize == 2) {
                    // Flash's 16-bit UNCOMPRESSED and RAW audio comes as
                    // a signed PCM format. UNCOMPRESSED audio always use
                    // little-endian byte order. RAW audio uses encoder's
                    // native byte order; as majority of encoders run
                    // on little-endian machine, we use little-endian for it.
                    codec_id = AV_CODEC_ID_PCM_S16LE;
                } else {
                    // Flash's 8-bit UNCOMPRESSED and RAW audio comes as an
                    // unsigned PCM format. No difference between
                    // UNCOMPRESSED and RAW.
                    codec_id = AV_CODEC_ID_PCM_U8;
                }
                break;


Note: GStreamer backend have a similar problem in its code documentation;
the code itself correctly implements a 8-bit _unsigned_
<http://git.savannah.gnu.org/cgit/gnash.git/tree/libmedia/AudioDecoderSimple.cpp?id=516a6cae2301c582b54d7f00188c8e22c5d76c1b#n257>
PCM codec,
but the comments
<http://git.savannah.gnu.org/cgit/gnash.git/tree/libmedia/AudioDecoderSimple.cpp?id=516a6cae2301c582b54d7f00188c8e22c5d76c1b#n390>
still say
<http://git.savannah.gnu.org/cgit/gnash.git/tree/libmedia/AudioDecoderSimple.cpp?id=516a6cae2301c582b54d7f00188c8e22c5d76c1b#n401>
8-bit signed. I'll submit a fix for that as
a different patch entry.

5/5: 0008-fix-ffmpeg-resample-factor-count-calculation.patch:

    if (_resampler.init(_audioCodecCtx)) {
        // Resampling is needed.

        // Compute new size based on frame_size and
        // resampling configuration

        // Find out the needed sample rate scaling
        double resampleFactor = 44100.0/_audioCodecCtx->sample_rate;

        // Compute total number of input samples
        int inSamples = outSize;
        bool stereo = _audioCodecCtx->channels > 1 ? true : false;

        if (stereo) inSamples = inSamples >> 1;
        if (_audioCodecCtx->sample_fmt == AV_SAMPLE_FMT_S16 ||
            _audioCodecCtx->sample_fmt == AV_SAMPLE_FMT_S16P) {
            inSamples = inSamples >> 1;
        }

        // Compute total number of output samples
        int expectedMaxOutSamples = std::ceil(inSamples*resampleFactor);

        // Compute output buffer size (in bytes); by multiplying
        // output samples count with output sample format's frame size,
        // which is number of bytes per sample (2) times channels (2).
        int resampledFrameSize = expectedMaxOutSamples*2*2;

        // Allocate just the required amount of bytes
        std::uint8_t* resampledOutput = new std::uint8_t[resampledFrameSize];


For patch 1, 2, 4; they're just fixing coding oversight and removing hacks,
I didn't really have anything else to say about them.

If comments above are OK, I'll proceed to submit new version of patch 3, 4, 5.

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/patch/?8747>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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