The attached patch is required to build with current FFmpeg, including the version packaged in Debian testing (Wheezy).
It almost certainly breaks support for Etch, but should still work with the most recent Debian stable (Squeeze). Some testing would be useful, or at least comments on what to do about this. It would be pretty complex to rewrite the code to support Etch as well. bwy -- Use Gnash, the GNU Flash Player! http://www.gnu.org/software/gnash/ Benjamin Wolsey, Software Developer - http://benjaminwolsey.de C++ and Open-Source Flash blog - http://www.benjaminwolsey.de/bwysblog xmpp:[email protected] http://identi.ca/bwy
From 3b1d86d9deb979e3ee4712e9bb5cecfb3e4b777c Mon Sep 17 00:00:00 2001 From: Benjamin Wolsey <[email protected]> Date: Tue, 26 Apr 2011 14:31:48 +0200 Subject: [PATCH] Update FFmpeg usage to work with Debian Wheezy Current FFmpeg drops various deprecated functions. This commit introduces more copying for obvious correctness. This may be avoided after some testing. --- libmedia/ffmpeg/AudioDecoderFfmpeg.cpp | 79 ++++++++++++++---------------- libmedia/ffmpeg/AudioResamplerFfmpeg.cpp | 36 ++++++------- libmedia/ffmpeg/MediaParserFfmpeg.cpp | 15 +----- libmedia/ffmpeg/VideoDecoderFfmpeg.cpp | 7 ++- 4 files changed, 61 insertions(+), 76 deletions(-) diff --git a/libmedia/ffmpeg/AudioDecoderFfmpeg.cpp b/libmedia/ffmpeg/AudioDecoderFfmpeg.cpp index 1421aa6..1f185bb 100644 --- a/libmedia/ffmpeg/AudioDecoderFfmpeg.cpp +++ b/libmedia/ffmpeg/AudioDecoderFfmpeg.cpp @@ -29,8 +29,6 @@ //#define GNASH_DEBUG_AUDIO_DECODING -#define AVCODEC_DECODE_AUDIO avcodec_decode_audio2 - namespace gnash { namespace media { namespace ffmpeg { @@ -520,16 +518,18 @@ boost::uint8_t* AudioDecoderFfmpeg::decodeFrame(const boost::uint8_t* input, boost::uint32_t inputSize, boost::uint32_t& outputSize) { - //GNASH_REPORT_FUNCTION; - assert(inputSize); + AVPacket packet; + av_new_packet(&packet, inputSize); + std::copy(input, input + inputSize, packet.data); + const size_t bufsize = AVCODEC_MAX_AUDIO_FRAME_SIZE; // TODO: make this a private member, to reuse (see NetStreamFfmpeg in 0.8.3) boost::uint8_t* output; - output = reinterpret_cast<boost::uint8_t*>(av_malloc(bufsize)); + output = static_cast<boost::uint8_t*>(av_malloc(bufsize)); if (!output) { log_error(_("failed to allocate audio buffer.")); outputSize = 0; @@ -548,9 +548,8 @@ AudioDecoderFfmpeg::decodeFrame(const boost::uint8_t* input, inputSize, _audioCodecCtx->channels, _audioCodecCtx->frame_size); #endif - // older ffmpeg versions didn't accept a const input.. - int tmp = AVCODEC_DECODE_AUDIO(_audioCodecCtx, outPtr, &outSize, - input, inputSize); + const int tmp = avcodec_decode_audio3(_audioCodecCtx, outPtr, &outSize, + &packet); #ifdef GNASH_DEBUG_AUDIO_DECODING log_debug(" avcodec_decode_audio[2](ctx, bufptr, %d, input, %d) " @@ -656,47 +655,43 @@ AudioDecoderFfmpeg::parseInput(const boost::uint8_t* input, boost::uint32_t inputSize, boost::uint8_t const ** outFrame, int* outFrameSize) { - if ( _needsParsing ) - { - return av_parser_parse(_parser, _audioCodecCtx, + if (_needsParsing) { + return av_parser_parse2(_parser, _audioCodecCtx, // as of 2008-10-28 SVN, ffmpeg doesn't // accept a pointer to pointer to const.. const_cast<boost::uint8_t**>(outFrame), outFrameSize, input, inputSize, - 0, 0); // pts & dts + 0, 0, AV_NOPTS_VALUE); } - else - { - // democratic value for a chunk to decode... - // @todo this might be constrained by codec id, check that ! - - // NOTE: AVCODEC_MAX_AUDIO_FRAME_SIZE resulted bigger - // than avcodec_decode_audio could handle, resulting - // in eventSoundTest1.swf regression. - //static const unsigned int maxFrameSize = AVCODEC_MAX_AUDIO_FRAME_SIZE; - - // NOTE: 1024 resulted too few - // to properly decode (or resample?) raw audio - // thus resulting noisy (bugs #21177 and #22284) - //static const unsigned int maxFrameSize = 1024; - - // NOTE: 96000 was found to be the max returned - // by avcodec_decode_audio when passed anything - // bigger than that. Works fine with all of - // eventSoundTest1.swf, bug #21177 and bug #22284 - // - static const unsigned int maxFrameSize = 96000; - int frameSize = inputSize < maxFrameSize ? inputSize : maxFrameSize; - - // we assume the input is just a set of frames - // and we'll consume all - *outFrame = input; // frame always start on input - *outFrameSize = frameSize; - int parsed = frameSize; - return parsed; - } + // democratic value for a chunk to decode... + // @todo this might be constrained by codec id, check that ! + + // NOTE: AVCODEC_MAX_AUDIO_FRAME_SIZE resulted bigger + // than avcodec_decode_audio could handle, resulting + // in eventSoundTest1.swf regression. + //static const unsigned int maxFrameSize = AVCODEC_MAX_AUDIO_FRAME_SIZE; + + // NOTE: 1024 resulted too few + // to properly decode (or resample?) raw audio + // thus resulting noisy (bugs #21177 and #22284) + //static const unsigned int maxFrameSize = 1024; + + // NOTE: 96000 was found to be the max returned + // by avcodec_decode_audio when passed anything + // bigger than that. Works fine with all of + // eventSoundTest1.swf, bug #21177 and bug #22284 + // + static const unsigned int maxFrameSize = 96000; + + int frameSize = inputSize < maxFrameSize ? inputSize : maxFrameSize; + + // we assume the input is just a set of frames + // and we'll consume all + *outFrame = input; // frame always start on input + *outFrameSize = frameSize; + return frameSize; } diff --git a/libmedia/ffmpeg/AudioResamplerFfmpeg.cpp b/libmedia/ffmpeg/AudioResamplerFfmpeg.cpp index 3a43655..34e06b6 100644 --- a/libmedia/ffmpeg/AudioResamplerFfmpeg.cpp +++ b/libmedia/ffmpeg/AudioResamplerFfmpeg.cpp @@ -30,41 +30,39 @@ namespace media { namespace ffmpeg { AudioResamplerFfmpeg::AudioResamplerFfmpeg() - :_context(NULL) + : + _context(0) { } AudioResamplerFfmpeg::~AudioResamplerFfmpeg() { - if ( _context ) { - audio_resample_close( _context ); - } + if (_context) { + audio_resample_close(_context); + } } bool AudioResamplerFfmpeg::init( AVCodecContext* ctx ) { - if ( (ctx->sample_rate != 44100) || (ctx->channels != 2) ) { - if ( ! _context ) { - _context = audio_resample_init( - 2, ctx->channels, 44100, ctx->sample_rate - ); + if ((ctx->sample_rate != 44100) || (ctx->channels != 2)) { + if (!_context) { + _context = av_audio_resample_init( + 2, ctx->channels, 44100, ctx->sample_rate, + AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16, 16, + 10, 0, 0.8); + } + return true; } - return true; - } - - return false; + return false; } int -AudioResamplerFfmpeg::resample( - boost::int16_t* input, - boost::int16_t* output, - int samples - ) +AudioResamplerFfmpeg::resample(boost::int16_t* input, boost::int16_t* output, + int samples) { - return audio_resample( _context, output, input, samples ); + return audio_resample(_context, output, input, samples); } diff --git a/libmedia/ffmpeg/MediaParserFfmpeg.cpp b/libmedia/ffmpeg/MediaParserFfmpeg.cpp index 19c8136..06e2f25 100644 --- a/libmedia/ffmpeg/MediaParserFfmpeg.cpp +++ b/libmedia/ffmpeg/MediaParserFfmpeg.cpp @@ -396,17 +396,6 @@ MediaParserFfmpeg::initializeParser() log_debug("Parsing FFMPEG media file: format:%s; nstreams:%d", _inputFmt->name, _formatCtx->nb_streams); - if ( _formatCtx->title[0] ) - log_debug(_(" Title:'%s'"), _formatCtx->title); - if ( _formatCtx->author[0] ) - log_debug(_(" Author:'%s'"), _formatCtx->author); - if ( _formatCtx->copyright[0] ) - log_debug(_(" Copyright:'%s'"), _formatCtx->copyright); - if ( _formatCtx->comment[0] ) - log_debug(_(" Comment:'%s'"), _formatCtx->comment); - if ( _formatCtx->album[0] ) - log_debug(_(" Album:'%s'"), _formatCtx->album); - // Find first audio and video stream for (unsigned int i = 0; i < static_cast<unsigned int>(_formatCtx->nb_streams); i++) { @@ -423,7 +412,7 @@ MediaParserFfmpeg::initializeParser() } switch (enc->codec_type) { - case CODEC_TYPE_AUDIO: + case AVMEDIA_TYPE_AUDIO: if (_audioStreamIndex < 0) { _audioStreamIndex = i; _audioStream = _formatCtx->streams[i]; @@ -433,7 +422,7 @@ MediaParserFfmpeg::initializeParser() } break; - case CODEC_TYPE_VIDEO: + case AVMEDIA_TYPE_VIDEO: if (_videoStreamIndex < 0) { _videoStreamIndex = i; _videoStream = _formatCtx->streams[i]; diff --git a/libmedia/ffmpeg/VideoDecoderFfmpeg.cpp b/libmedia/ffmpeg/VideoDecoderFfmpeg.cpp index 79a42a0..05e0f69 100644 --- a/libmedia/ffmpeg/VideoDecoderFfmpeg.cpp +++ b/libmedia/ffmpeg/VideoDecoderFfmpeg.cpp @@ -354,10 +354,13 @@ VideoDecoderFfmpeg::decode(const boost::uint8_t* input, return ret; } + AVPacket packet; + av_new_packet(&packet, input_size); + std::copy(input, input + input_size, packet.data); + int bytes = 0; // no idea why avcodec_decode_video wants a non-const input... - avcodec_decode_video(_videoCodecCtx->getContext(), frame, &bytes, - input, input_size); + avcodec_decode_video2(_videoCodecCtx->getContext(), frame, &bytes, &packet); if (!bytes) { log_error("Decoding of a video frame failed"); -- 1.7.4.4
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Gnash-dev mailing list [email protected] https://lists.gnu.org/mailman/listinfo/gnash-dev

