[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog libmedia/FLVParser.cpp libmedia...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog libmedia/FLVParser.cpp libmedia... |
Date: |
Mon, 16 Jun 2008 14:41:54 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 08/06/16 14:41:53
Modified files:
. : ChangeLog
libmedia : FLVParser.cpp FLVParser.h MediaParser.h
libmedia/ffmpeg: AudioDecoderFfmpeg.cpp MediaParserFfmpeg.cpp
MediaParserFfmpeg.h VideoDecoderFfmpeg.cpp
VideoDecoderFfmpeg.h
Log message:
* libmedia/FLVParser.{cpp,h}: use _seekRequest from base class,
not the custom one.
* libmedia/MediaParser.h: add an ExtraInfo class pointer to VideoInfo
and AudioInfo classes, to allow for custom additional info to be
passed to decoders.
* libmedia/ffmpeg/MediaParserFfmpeg.{cpp,h}: pass extradata and
extradataSize trough an ffmpeg-specific ExtraInfo class for
VideoInfo and AudioInfo.
* libmedia/ffmpeg/AudioDecoderFfmpeg.cpp: use extra info for
initialization of decoder. Fixes decoder inititialization for
square.ogg case.
* libmedia/ffmpeg/VideoDecoderFfmpeg.{cpp,h}: extend the private
::init() method to take extra data, use extradata passed with
VideoInfo when available. Fixes decoder initialization for
square.ogg case.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6941&r2=1.6942
http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/FLVParser.cpp?cvsroot=gnash&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/FLVParser.h?cvsroot=gnash&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/MediaParser.h?cvsroot=gnash&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/ffmpeg/AudioDecoderFfmpeg.cpp?cvsroot=gnash&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/ffmpeg/MediaParserFfmpeg.cpp?cvsroot=gnash&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/ffmpeg/MediaParserFfmpeg.h?cvsroot=gnash&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/ffmpeg/VideoDecoderFfmpeg.cpp?cvsroot=gnash&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/ffmpeg/VideoDecoderFfmpeg.h?cvsroot=gnash&r1=1.12&r2=1.13
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6941
retrieving revision 1.6942
diff -u -b -r1.6941 -r1.6942
--- ChangeLog 16 Jun 2008 12:23:05 -0000 1.6941
+++ ChangeLog 16 Jun 2008 14:41:51 -0000 1.6942
@@ -1,3 +1,21 @@
+2008-06-16 Sandro Santilli <address@hidden>
+
+ * libmedia/FLVParser.{cpp,h}: use _seekRequest from base class,
+ not the custom one.
+ * libmedia/MediaParser.h: add an ExtraInfo class pointer to VideoInfo
+ and AudioInfo classes, to allow for custom additional info to be
+ passed to decoders.
+ * libmedia/ffmpeg/MediaParserFfmpeg.{cpp,h}: pass extradata and
+ extradataSize trough an ffmpeg-specific ExtraInfo class for
+ VideoInfo and AudioInfo.
+ * libmedia/ffmpeg/AudioDecoderFfmpeg.cpp: use extra info for
+ initialization of decoder. Fixes decoder inititialization for
+ square.ogg case.
+ * libmedia/ffmpeg/VideoDecoderFfmpeg.{cpp,h}: extend the private
+ ::init() method to take extra data, use extradata passed with
+ VideoInfo when available. Fixes decoder initialization for
+ square.ogg case.
+
2008-06-16 Benjamin Wolsey <address@hidden>
* server/vm/ASHandlers.cpp: minor cleanups.
Index: libmedia/FLVParser.cpp
===================================================================
RCS file: /sources/gnash/gnash/libmedia/FLVParser.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- libmedia/FLVParser.cpp 16 Jun 2008 11:16:11 -0000 1.19
+++ libmedia/FLVParser.cpp 16 Jun 2008 14:41:52 -0000 1.20
@@ -76,11 +76,11 @@
// encoded frame on the queue, or while it is waiting on the wakeup
// condition
- // Setting _seekRequested to true will make the parser thread
+ // Setting _seekRequest to true will make the parser thread
// take care of cleaning up the buffers before going on with
// parsing, thus fixing the case in which streamLock was obtained
// while the parser was pushing to queue
- _seekRequested = true;
+ _seekRequest = true;
_lastParsedPosition=9; // 9 is FLV header size...
_parsingComplete=false; // or NetStream will send the Play.Stop event...
@@ -124,10 +124,10 @@
if ( _parsingComplete ) return false;
- if ( _seekRequested )
+ if ( _seekRequest )
{
clearBuffers();
- _seekRequested = false;
+ _seekRequest = false;
}
Index: libmedia/FLVParser.h
===================================================================
RCS file: /sources/gnash/gnash/libmedia/FLVParser.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- libmedia/FLVParser.h 16 Jun 2008 11:16:11 -0000 1.18
+++ libmedia/FLVParser.h 16 Jun 2008 14:41:53 -0000 1.19
@@ -204,11 +204,6 @@
/// Will be reset on seek, and will be protected by the _streamMutex
boost::uint64_t _lastParsedPosition;
- /// On seek, this flag will be set, while holding a lock on
_streamMutex.
- /// The parser, when obtained a lock on _streamMutex, will check this
- /// flag, if found to be true will clear the buffers and reset to false.
- bool _seekRequested;
-
/// Audio frame cursor position
//
/// This is the video frame number that will
Index: libmedia/MediaParser.h
===================================================================
RCS file: /sources/gnash/gnash/libmedia/MediaParser.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- libmedia/MediaParser.h 16 Jun 2008 11:16:12 -0000 1.26
+++ libmedia/MediaParser.h 16 Jun 2008 14:41:53 -0000 1.27
@@ -132,6 +132,16 @@
bool stereo;
boost::uint64_t duration;
codecType type;
+
+ /// An abstract class to hold any additional info
+ /// required for proper decoder initialization
+ class ExtraInfo {
+ public:
+ virtual ~ExtraInfo() {}
+ };
+
+ /// Extra info about audio stream, if when needed
+ std::auto_ptr<ExtraInfo> extra;
};
/// \brief
@@ -158,6 +168,16 @@
boost::uint16_t frameRate;
boost::uint64_t duration;
codecType type;
+
+ /// An abstract class to hold any additional info
+ /// required for proper decoder initialization
+ class ExtraInfo {
+ public:
+ virtual ~ExtraInfo() {}
+ };
+
+ /// Extra info about audio stream, if when needed
+ std::auto_ptr<ExtraInfo> extra;
};
/// An encoded video frame
@@ -455,13 +475,10 @@
bool _parserThreadKillRequested;
boost::condition _parserThreadWakeup;
+ /// On seek, this flag will be set, while holding a lock on
_streamMutex.
+ /// The parser, when obtained a lock on _streamMutex, will check this
+ /// flag, if found to be true will clear the buffers and reset to false.
bool _seekRequest;
- mutable boost::mutex _seekRequestMutex;
-
- bool seekRequested() const;
-
- void seekBegin();
- void seekEnd();
/// Wait on the _parserThreadWakeup condition if buffer is full
/// or parsing was completed.
Index: libmedia/ffmpeg/AudioDecoderFfmpeg.cpp
===================================================================
RCS file: /sources/gnash/gnash/libmedia/ffmpeg/AudioDecoderFfmpeg.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- libmedia/ffmpeg/AudioDecoderFfmpeg.cpp 13 Jun 2008 21:47:21 -0000
1.12
+++ libmedia/ffmpeg/AudioDecoderFfmpeg.cpp 16 Jun 2008 14:41:53 -0000
1.13
@@ -19,6 +19,8 @@
#include "AudioDecoderFfmpeg.h"
+#include "MediaParserFfmpeg.h" // for ExtraAudioInfoFfmpeg
+
#include <cmath> // for std::ceil
#include <algorithm> // for std::copy, std::max
@@ -164,6 +166,14 @@
return false;
}
+ if ( info->extra.get() )
+ {
+ assert(dynamic_cast<ExtraAudioInfoFfmpeg*>(info->extra.get()));
+ const ExtraAudioInfoFfmpeg& ei =
static_cast<ExtraAudioInfoFfmpeg&>(*info->extra);
+ _audioCodecCtx->extradata = ei.data;
+ _audioCodecCtx->extradata_size = ei.dataSize;
+ }
+
int ret = avcodec_open(_audioCodecCtx, _audioCodec);
if (ret < 0) {
//avcodec_close(_audioCodecCtx);
Index: libmedia/ffmpeg/MediaParserFfmpeg.cpp
===================================================================
RCS file: /sources/gnash/gnash/libmedia/ffmpeg/MediaParserFfmpeg.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- libmedia/ffmpeg/MediaParserFfmpeg.cpp 16 Jun 2008 11:16:12 -0000
1.15
+++ libmedia/ffmpeg/MediaParserFfmpeg.cpp 16 Jun 2008 14:41:53 -0000
1.16
@@ -73,7 +73,7 @@
if (actuallyRead < 1)
{
- log_error(_("Gnash could not read from movie url"));
+ throw IOException(_("MediaParserFfmpeg could not read probe
data from input"));
return NULL;
}
@@ -139,21 +139,19 @@
//
boost::uint64_t timestamp = static_cast<boost::uint64_t>(packet.dts *
as_double(_videoStream->time_base) * 1000.0);
+#if 1
LOG_ONCE( log_unimpl("%s", __PRETTY_FUNCTION__) );
return false;
-
-#if 0
+#else
// flags, for keyframe
- bool isKeyFrame = packet.flags&PKT_FLAG_KEY;
+ //bool isKeyFrame = packet.flags&PKT_FLAG_KEY;
- VideoFrameInfo* info = new VideoFrameInfo;
- info->dataSize = packet.size;
- info->isKeyFrame = isKeyFrame;
- info->dataPosition = pos;
- info->timestamp = timestamp;
+ // TODO: check if we need to copy the packet.data
+ std::auto_ptr<EncodedVideoFrame> frame(new
EncodedVideoFrame(packet.data, packet.size, 0, timestamp));
+ packet.data = 0;
- pushEncodedVideoFrame(info);
+ pushEncodedVideoFrame(frame);
return true;
#endif
@@ -175,12 +173,14 @@
//
boost::uint64_t timestamp = static_cast<boost::uint64_t>(packet.dts *
as_double(_audioStream->time_base) * 1000.0);
+#if 1
LOG_ONCE( log_unimpl("%s", __PRETTY_FUNCTION__) );
return false;
-#if 0
+#else
std::auto_ptr<EncodedAudioFrame> frame ( new EncodedAudioFrame );
- frame->dataSize = packet.size
+ frame->data.reset(packet.data); // TODO: check if we need to copy this
+ frame->dataSize = packet.size;
frame->timestamp = timestamp;
pushEncodedAudioFrame(frame);
@@ -198,14 +198,14 @@
if ( _parsingComplete )
{
- log_debug("MediaParserFfmpeg::parseNextFrame: parsing complete,
nothing to do");
+ //log_debug("MediaParserFfmpeg::parseNextFrame: parsing
complete, nothing to do");
return false;
}
// position the stream where we left parsing as
// it could be somewhere else for reading a specific
// or seeking.
- _stream->seek(_lastParsedPosition);
+ //_stream->seek(_lastParsedPosition);
assert(_formatCtx);
@@ -258,8 +258,6 @@
bool
MediaParserFfmpeg::parseNextChunk()
{
- // parse 2 frames...
- if ( ! parseNextFrame() ) return false;
if ( ! parseNextFrame() ) return false;
return true;
}
@@ -327,7 +325,14 @@
throw IOException("MediaParserFfmpeg couldn't open input
stream");
}
- // Find audio and video stream
+ log_debug("Parsing FFMPEG media file: %d streams",
_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 < (unsigned)_formatCtx->nb_streams; i++)
{
AVCodecContext* enc = _formatCtx->streams[i]->codec;
@@ -339,6 +344,9 @@
{
_audioStreamIndex = i;
_audioStream = _formatCtx->streams[i];
+ log_debug(_(" Using stream %d for
audio: codec id %d"),
+ i,
_audioStream->codec->codec_id);
+ // codec_name will only be filled by
avcodec_find_decoder (later);
}
break;
@@ -347,6 +355,9 @@
{
_videoStreamIndex = i;
_videoStream = _formatCtx->streams[i];
+ log_debug(_(" Using stream %d for
video: codec id %d"),
+ i,
_videoStream->codec->codec_id);
+ // codec_name will only be filled by
avcodec_find_decoder (later);
}
break;
default:
@@ -367,6 +378,8 @@
boost::uint64_t duration = _videoStream->duration;
#endif
_videoInfo.reset( new VideoInfo(codec, width, height,
frameRate, duration, FFMPEG /*codec type*/) );
+ //log_debug("EXTRA: %d bytes of video extra data",
_videoStream->codec->extradata_size);
+ _videoInfo->extra.reset(new
ExtraVideoInfoFfmpeg(_videoStream->codec->extradata,
_videoStream->codec->extradata_size));
}
// Create AudioInfo
@@ -382,7 +395,11 @@
boost::uint64_t duration = _videoStream->duration;
#endif
_audioInfo.reset( new AudioInfo(codec, sampleRate, sampleSize,
stereo, duration, FFMPEG /*codec type*/) );
+ //log_debug("EXTRA: %d bytes of audio extra data",
_videoStream->codec->extradata_size);
+ _audioInfo->extra.reset(new
ExtraAudioInfoFfmpeg(_audioStream->codec->extradata,
_audioStream->codec->extradata_size));
}
+
+
}
Index: libmedia/ffmpeg/MediaParserFfmpeg.h
===================================================================
RCS file: /sources/gnash/gnash/libmedia/ffmpeg/MediaParserFfmpeg.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- libmedia/ffmpeg/MediaParserFfmpeg.h 16 Jun 2008 11:16:12 -0000 1.11
+++ libmedia/ffmpeg/MediaParserFfmpeg.h 16 Jun 2008 14:41:53 -0000 1.12
@@ -50,6 +50,36 @@
namespace gnash {
namespace media {
+/// Class to hold extra info found in audio stream by the parser.
+/// The info will be needed for proper initialization of decoder.
+class ExtraAudioInfoFfmpeg : public AudioInfo::ExtraInfo
+{
+public:
+ ExtraAudioInfoFfmpeg(boost::uint8_t* nData, size_t nDataSize)
+ :
+ data(nData),
+ dataSize(nDataSize)
+ {
+ }
+ boost::uint8_t* data;
+ size_t dataSize;
+};
+
+/// Class to hold extra info found in video stream by the parser.
+/// The info will be needed for proper initialization of decoder.
+class ExtraVideoInfoFfmpeg : public VideoInfo::ExtraInfo
+{
+public:
+ ExtraVideoInfoFfmpeg(boost::uint8_t* nData, size_t nDataSize)
+ :
+ data(nData),
+ dataSize(nDataSize)
+ {
+ }
+ boost::uint8_t* data;
+ size_t dataSize;
+};
+
/// FFMPEG based MediaParser
///
class MediaParserFfmpeg: public MediaParser
Index: libmedia/ffmpeg/VideoDecoderFfmpeg.cpp
===================================================================
RCS file: /sources/gnash/gnash/libmedia/ffmpeg/VideoDecoderFfmpeg.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- libmedia/ffmpeg/VideoDecoderFfmpeg.cpp 5 Jun 2008 13:36:57 -0000
1.14
+++ libmedia/ffmpeg/VideoDecoderFfmpeg.cpp 16 Jun 2008 14:41:53 -0000
1.15
@@ -19,6 +19,7 @@
#include "VideoDecoderFfmpeg.h"
+#include "MediaParserFfmpeg.h" // for ExtraVideoInfoFfmpeg
#ifdef HAVE_FFMPEG_SWSCALE_H
#define HAVE_SWSCALE_H 1
@@ -61,11 +62,20 @@
if ( info.type == FLASH ) codec_id =
FlashToFfmpegCodec(static_cast<videoCodecType>(info.codec));
else codec_id = static_cast<enum CodecID>(info.codec);
- init(codec_id, info.width, info.height);
+ boost::uint8_t* extradata=0;
+ int extradataSize=0;
+ if ( info.extra.get() )
+ {
+ assert(dynamic_cast<ExtraVideoInfoFfmpeg*>(info.extra.get()));
+ const ExtraVideoInfoFfmpeg& ei =
static_cast<ExtraVideoInfoFfmpeg&>(*info.extra);
+ extradata = ei.data;
+ extradataSize = ei.dataSize;
+ }
+ init(codec_id, info.width, info.height, extradata, extradataSize);
}
void
-VideoDecoderFfmpeg::init(enum CodecID codecId, int width, int height)
+VideoDecoderFfmpeg::init(enum CodecID codecId, int width, int height,
boost::uint8_t* extradata, int extradataSize)
{
// Init the avdecoder-decoder
avcodec_init();
@@ -84,6 +94,9 @@
return;
}
+ _videoCodecCtx->extradata = extradata;
+ _videoCodecCtx->extradata_size = extradataSize;
+
int ret = avcodec_open(_videoCodecCtx, _videoCodec);
if (ret < 0) {
log_error(_("VideoDecoderFfmpeg::init: avcodec_open: failed to initialize
FFMPEG codec %s (%d)"),
Index: libmedia/ffmpeg/VideoDecoderFfmpeg.h
===================================================================
RCS file: /sources/gnash/gnash/libmedia/ffmpeg/VideoDecoderFfmpeg.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- libmedia/ffmpeg/VideoDecoderFfmpeg.h 5 Jun 2008 07:19:02 -0000
1.12
+++ libmedia/ffmpeg/VideoDecoderFfmpeg.h 16 Jun 2008 14:41:53 -0000
1.13
@@ -81,7 +81,7 @@
private:
- void init(enum CodecID format, int width, int height);
+ void init(enum CodecID format, int width, int height, boost::uint8_t*
extradata=0, int extradataSize=0);
std::auto_ptr<image::rgb> decode(const boost::uint8_t* input,
boost::uint32_t input_size);