CVSROOT: /sources/gnash Module name: gnash Changes by: Benjamin Wolsey <bwy> 07/12/03 20:48:51
Modified files: . : ChangeLog libmedia : MediaParser.h libmedia/sdl : AudioDecoderFfmpeg.cpp MediaParserFfmpeg.cpp MediaParserFfmpeg.h Log message: * libmedia/MediaParser.h, libmedia/sdl/MediaParserFfmpeg.h: pass pointer to audio codec context (ffmpeg only). * libmedia/sdl/MediaParserFfmpeg.{h,cpp}: remove useless _frame. * libmedia/sdl/AudioDecoderFfmpeg.cpp: use parser's original audio codec context (fixes playback of some audio codecs); don't fail on missing parser until it's needed. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5072&r2=1.5073 http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/MediaParser.h?cvsroot=gnash&r1=1.9&r2=1.10 http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/sdl/AudioDecoderFfmpeg.cpp?cvsroot=gnash&r1=1.8&r2=1.9 http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/sdl/MediaParserFfmpeg.cpp?cvsroot=gnash&r1=1.7&r2=1.8 http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/sdl/MediaParserFfmpeg.h?cvsroot=gnash&r1=1.5&r2=1.6 Patches: Index: ChangeLog =================================================================== RCS file: /sources/gnash/gnash/ChangeLog,v retrieving revision 1.5072 retrieving revision 1.5073 diff -u -b -r1.5072 -r1.5073 --- ChangeLog 3 Dec 2007 19:05:00 -0000 1.5072 +++ ChangeLog 3 Dec 2007 20:48:50 -0000 1.5073 @@ -1,3 +1,12 @@ +2007-12-03 Benjamin Wolsey <[EMAIL PROTECTED]> + + * libmedia/MediaParser.h, libmedia/sdl/MediaParserFfmpeg.h: pass pointer + to audio codec context (ffmpeg only). + * libmedia/sdl/MediaParserFfmpeg.{h,cpp}: remove useless _frame. + * libmedia/sdl/AudioDecoderFfmpeg.cpp: use parser's original audio codec + context (fixes playback of some audio codecs); don't fail on missing + parser until it's needed. + 2007-12-03 Sandro Santilli <[EMAIL PROTECTED]> * libbase/curl_adapter.cpp (fill_cache): one liner early-out to Index: libmedia/MediaParser.h =================================================================== RCS file: /sources/gnash/gnash/libmedia/MediaParser.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -b -r1.9 -r1.10 --- libmedia/MediaParser.h 30 Nov 2007 00:13:01 -0000 1.9 +++ libmedia/MediaParser.h 3 Dec 2007 20:48:51 -0000 1.10 @@ -16,7 +16,7 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -// $Id: MediaParser.h,v 1.9 2007/11/30 00:13:01 tgc Exp $ +// $Id: MediaParser.h,v 1.10 2007/12/03 20:48:51 bwy Exp $ #ifndef __MEDIAPARSER_H__ #define __MEDIAPARSER_H__ @@ -131,6 +131,9 @@ sampleSize(sampleSizei), stereo(stereoi), duration(durationi), +#ifdef USE_FFMPEG + audioCodecCtx(NULL), +#endif type(typei) { } @@ -140,6 +143,9 @@ uint16_t sampleSize; bool stereo; uint64_t duration; +#ifdef USE_FFMPEG + AVCodecContext* audioCodecCtx; // If videoCodecCtx is ugly, so is this. +#endif codecType type; }; Index: libmedia/sdl/AudioDecoderFfmpeg.cpp =================================================================== RCS file: /sources/gnash/gnash/libmedia/sdl/AudioDecoderFfmpeg.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -b -r1.8 -r1.9 --- libmedia/sdl/AudioDecoderFfmpeg.cpp 30 Nov 2007 13:56:04 -0000 1.8 +++ libmedia/sdl/AudioDecoderFfmpeg.cpp 3 Dec 2007 20:48:51 -0000 1.9 @@ -17,7 +17,7 @@ // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // -// $Id: AudioDecoderFfmpeg.cpp,v 1.8 2007/11/30 13:56:04 bwy Exp $ +// $Id: AudioDecoderFfmpeg.cpp,v 1.9 2007/12/03 20:48:51 bwy Exp $ #include "AudioDecoderFfmpeg.h" @@ -33,7 +33,11 @@ AudioDecoderFfmpeg::~AudioDecoderFfmpeg() { - if (_audioCodecCtx) avcodec_close(_audioCodecCtx); + if (_audioCodecCtx) + { + avcodec_close(_audioCodecCtx); + av_free(_audioCodecCtx); + } if (_parser) av_parser_close(_parser); } @@ -104,7 +108,8 @@ if (info->type == FLASH) { enum CodecID codec_id; - switch(info->codec) { + switch(info->codec) + { case AUDIO_CODEC_RAW: codec_id = CODEC_ID_PCM_U16LE; break; @@ -121,25 +126,35 @@ _audioCodec = avcodec_find_decoder(codec_id); // Init the parser _parser = av_parser_init(codec_id); - } else if (info->type == FFMPEG) { + } + else if (info->type == FFMPEG) + { _audioCodec = avcodec_find_decoder(static_cast<CodecID>(info->codec)); // Init the parser _parser = av_parser_init(static_cast<CodecID>(info->codec)); - } else { - return false; } - - if (!_parser) { - log_error(_("libavcodec can't parse the current audio format")); + else + { return false; } - if (!_audioCodec) { + if (!_audioCodec) + { log_error(_("libavcodec can't decode the current audio format")); return false; } + // Reuse the audioCodecCtx from the ffmpeg parser if exists/possible + if (info->audioCodecCtx) + { + log_debug("re-using the parser's audioCodecCtx"); + _audioCodecCtx = info->audioCodecCtx; + } + else + { _audioCodecCtx = avcodec_alloc_context(); + } + if (!_audioCodecCtx) { log_error(_("libavcodec couldn't allocate context")); return false; @@ -171,6 +186,14 @@ decodedBytes = 0; if (parse) { + + if (!_parser) + { + log_error(_("libavcodec can't parse the current audio format")); + return NULL; + } + + bufsize = 0; while (bufsize == 0 && decodedBytes < inputSize) { uint8_t* frame; @@ -200,12 +223,15 @@ } else { int tmp = 0; + #ifdef FFMPEG_AUDIO2 tmp = avcodec_decode_audio2(_audioCodecCtx, reinterpret_cast<int16_t*>(output), &bufsize, input, inputSize); #else tmp = avcodec_decode_audio(_audioCodecCtx, reinterpret_cast<int16_t*>(output), &bufsize, input, inputSize); #endif + + if (bytes_decoded < 0 || tmp < 0 || bufsize < 0) { log_error(_("Error while decoding audio data. Upgrading ffmpeg/libavcodec might fix this issue.")); // Setting data position to data size will get the sound removed Index: libmedia/sdl/MediaParserFfmpeg.cpp =================================================================== RCS file: /sources/gnash/gnash/libmedia/sdl/MediaParserFfmpeg.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -b -r1.7 -r1.8 --- libmedia/sdl/MediaParserFfmpeg.cpp 1 Dec 2007 12:58:41 -0000 1.7 +++ libmedia/sdl/MediaParserFfmpeg.cpp 3 Dec 2007 20:48:51 -0000 1.8 @@ -16,7 +16,7 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -// $Id: MediaParserFfmpeg.cpp,v 1.7 2007/12/01 12:58:41 bwy Exp $ +// $Id: MediaParserFfmpeg.cpp,v 1.8 2007/12/03 20:48:51 bwy Exp $ #include "MediaParserFfmpeg.h" #include "log.h" @@ -34,7 +34,6 @@ _videoCodecCtx(NULL), _audioCodecCtx(NULL), _formatCtx(NULL), - _frame(NULL), _lastVideoTimestamp(0), _lastAudioTimestamp(0), Index: libmedia/sdl/MediaParserFfmpeg.h =================================================================== RCS file: /sources/gnash/gnash/libmedia/sdl/MediaParserFfmpeg.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -b -r1.5 -r1.6 --- libmedia/sdl/MediaParserFfmpeg.h 30 Nov 2007 00:13:02 -0000 1.5 +++ libmedia/sdl/MediaParserFfmpeg.h 3 Dec 2007 20:48:51 -0000 1.6 @@ -16,7 +16,7 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -// $Id: MediaParserFfmpeg.h,v 1.5 2007/11/30 00:13:02 tgc Exp $ +// $Id: MediaParserFfmpeg.h,v 1.6 2007/12/03 20:48:51 bwy Exp $ #ifndef __MEDIAPARSERFFMPEG_H__ #define __MEDIAPARSERFFMPEG_H__ @@ -103,13 +103,10 @@ // the format (mp3, avi, etc.) AVFormatContext *_formatCtx; - // A ffmpeg frame - AVFrame* _frame; - // A ffmpeg thingy ByteIOContext _byteIOCxt; - // The timestamp of the last parsed video frame, in milseconds. + // The timestamp of the last parsed video frame, in milliseconds. uint32_t _lastVideoTimestamp; // The timestamp of the last parsed audio frame, in seconds. _______________________________________________ Gnash-commit mailing list Gnash-commit@gnu.org http://lists.gnu.org/mailman/listinfo/gnash-commit