CVSROOT: /sources/gnash Module name: gnash Changes by: Sandro Santilli <strk> 07/10/19 12:17:28
Modified files: . : ChangeLog server/parser : video_stream_def.cpp video_stream_def.h server/swf : tag_loaders.cpp Log message: * server/parser/video_stream_def.{cpp,h}: split read into readDefineVideoStream and readDefineVideoFrame, make presence of a non-null _decoder member a sign of a completed call to readDefineVideoStream (thus a sign of a statically-defined videostream vs. a dynamically created one [ using new Video ] ). * server/swf/tag_loaders.cpp: update calls to video_stream_def ::read* CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4645&r2=1.4646 http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/video_stream_def.cpp?cvsroot=gnash&r1=1.21&r2=1.22 http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/video_stream_def.h?cvsroot=gnash&r1=1.14&r2=1.15 http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf/tag_loaders.cpp?cvsroot=gnash&r1=1.147&r2=1.148 Patches: Index: ChangeLog =================================================================== RCS file: /sources/gnash/gnash/ChangeLog,v retrieving revision 1.4645 retrieving revision 1.4646 diff -u -b -r1.4645 -r1.4646 --- ChangeLog 19 Oct 2007 10:29:17 -0000 1.4645 +++ ChangeLog 19 Oct 2007 12:17:27 -0000 1.4646 @@ -1,5 +1,16 @@ 2007-10-19 Sandro Santilli <[EMAIL PROTECTED]> + * server/parser/video_stream_def.{cpp,h}: split read into + readDefineVideoStream and readDefineVideoFrame, make + presence of a non-null _decoder member a sign of a + completed call to readDefineVideoStream (thus a sign + of a statically-defined videostream vs. a dynamically + created one [ using new Video ] ). + * server/swf/tag_loaders.cpp: update calls to video_stream_def + ::read* + +2007-10-19 Sandro Santilli <[EMAIL PROTECTED]> + * server/parser/video_stream_def.cpp (read): rework the input buffer padding to be cleaner, safer and a bit faster (only memset the pad); (destructor): get rid of the embedded video Index: server/parser/video_stream_def.cpp =================================================================== RCS file: /sources/gnash/gnash/server/parser/video_stream_def.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -u -b -r1.21 -r1.22 --- server/parser/video_stream_def.cpp 19 Oct 2007 10:29:17 -0000 1.21 +++ server/parser/video_stream_def.cpp 19 Oct 2007 12:17:28 -0000 1.22 @@ -16,7 +16,7 @@ // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // -// $Id: video_stream_def.cpp,v 1.21 2007/10/19 10:29:17 strk Exp $ +// $Id: video_stream_def.cpp,v 1.22 2007/10/19 12:17:28 strk Exp $ #include "video_stream_def.h" #include "video_stream_instance.h" @@ -51,15 +51,14 @@ void -video_stream_definition::read(stream* in, SWF::tag_type tag, movie_definition* m) +video_stream_definition::readDefineVideoStream(stream* in, SWF::tag_type tag, movie_definition* m) { // Character ID has been read already, and was loaded in the constructor - assert(tag == SWF::DEFINEVIDEOSTREAM || tag == SWF::VIDEOFRAME); + assert(tag == SWF::DEFINEVIDEOSTREAM); + assert(!_decoder.get()); // allowed to be called only once - if (tag == SWF::DEFINEVIDEOSTREAM) - { m_start_frame = m->get_loading_frame(); m_num_frames = in->read_u16(); @@ -82,11 +81,18 @@ _decoder.reset( new VideoDecoder() ); #endif bool ret = _decoder->setup(_width, _height, m_deblocking_flags, m_smoothing_flags, m_codec_id, gnash::render::videoFrameFormat()); - if (!ret) _decoder.reset(); + if (!ret) _decoder.reset(new VideoDecoder()); // This is so statically-defined video_stream_def always have a _decoder != NULL + +} + +void +video_stream_definition::readDefineVideoFrame(stream* in, SWF::tag_type tag, movie_definition* m) +{ + // Character ID has been read already, and was loaded in the constructor + + assert(tag == SWF::VIDEOFRAME); + assert ( _decoder.get() ); // not allowed to be called for a dynamically-created video_stream_def - } - else if (tag == SWF::VIDEOFRAME && _decoder) - { // We don't use the videoframe number, but instead // each video frame is tied to the swf-frame where // it belongs. @@ -116,17 +122,12 @@ // in the tag instead of skipping it ? size_t frameNum = m->get_loading_frame(); - // TODO: use a private function for this as we - // should eventually delete any previously - // existing element for key frameNum - m_video_frames[frameNum] = img.release(); + setFrameData(frameNum, img); } else { log_error(_("An error occured while decoding video frame in frame %d"), m->get_loading_frame()); } - } - } @@ -150,5 +151,19 @@ } } +void +video_stream_definition::setFrameData(uint32_t frameNum, std::auto_ptr<image::image_base> image) +{ + image::image_base*& ptr = m_video_frames[frameNum]; + if ( ptr ) + { + IF_VERBOSE_MALFORMED_SWF( + log_swferror(_("Mulitple video frames defined for frame %u"), frameNum); + ); + return; + } + ptr = image.release(); +} + } // namespace gnash Index: server/parser/video_stream_def.h =================================================================== RCS file: /sources/gnash/gnash/server/parser/video_stream_def.h,v retrieving revision 1.14 retrieving revision 1.15 diff -u -b -r1.14 -r1.15 --- server/parser/video_stream_def.h 19 Oct 2007 09:30:24 -0000 1.14 +++ server/parser/video_stream_def.h 19 Oct 2007 12:17:28 -0000 1.15 @@ -16,7 +16,7 @@ // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // -// $Id: video_stream_def.h,v 1.14 2007/10/19 09:30:24 strk Exp $ +// $Id: video_stream_def.h,v 1.15 2007/10/19 12:17:28 strk Exp $ #ifndef GNASH_VIDEO_STREAM_DEF_H #define GNASH_VIDEO_STREAM_DEF_H @@ -57,25 +57,24 @@ character* create_character_instance(character* parent, int id); - /// Read tag SWF::DEFINEVIDEOSTREAM or SWF::VIDEOFRAME + /// Read tag SWF::DEFINEVIDEOSTREAM // - /// For DEFINEVIDEOSTREAM tag, the character_id is assumed to have been - /// already read by caller. + /// The character_id is assumed to have been already read by caller. /// - /// For VIDEOFRAME, again, the character_id (which contains association - /// between the VIDEOFRAME tag and the VIDEOSTREAM defined before) is - /// assumed to have been already read. + /// This function is allowed to be called only *once* for each + /// instance of this class. /// - /// For clarity, a *single* instance of this class should theoretically - /// read a DEFINEVIDEOSTREAM on first call and zero or more VIDEOFRAME - /// tags. + void readDefineVideoStream(stream* in, SWF::tag_type tag, movie_definition* m); + + /// Read tag SWF::VIDEOFRAME + // + /// The character_id (used to find this instance in the character's dictionary) + /// is assumed to have been already read. /// - /// TODO: separate the two reader functions, provide a constructor - /// reading the DEFINEVIDEOSTREAM and only expose the parser - /// for VIDEOFRAME (to ensure, at C++ level, that we won't - /// parse DEFINEVIDEOSTREAM twice). + /// This function is allowed to be called zero or more times, as long + /// as readDefineVideoStream was read before. /// - void read(stream* in, SWF::tag_type tag, movie_definition* m); + void readDefineVideoFrame(stream* in, SWF::tag_type tag, movie_definition* m); /// Return local video bounds in twips const rect& get_bound() const @@ -138,6 +137,22 @@ typedef std::map<uint32_t, image::image_base*> EmbedFrameMap; EmbedFrameMap m_video_frames; + /// Set data for the given frame + // + /// If a frame image is already known for the given frame number + /// it will NOT be replaced, and an SWF error will be printed. + /// The 'img' parameter will be deleted. + /// + /// See get_frame_data to extract it. + /// + /// @param frameNum + /// Frame number. + /// + /// @param img + /// Frame data. Ownership is transferred. + /// + void setFrameData(uint32_t frameNum, std::auto_ptr<image::image_base> img); + /// Width of the video uint32_t _width; Index: server/swf/tag_loaders.cpp =================================================================== RCS file: /sources/gnash/gnash/server/swf/tag_loaders.cpp,v retrieving revision 1.147 retrieving revision 1.148 diff -u -b -r1.147 -r1.148 --- server/swf/tag_loaders.cpp 19 Oct 2007 09:20:55 -0000 1.147 +++ server/swf/tag_loaders.cpp 19 Oct 2007 12:17:28 -0000 1.148 @@ -17,7 +17,7 @@ // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // -/* $Id: tag_loaders.cpp,v 1.147 2007/10/19 09:20:55 strk Exp $ */ +/* $Id: tag_loaders.cpp,v 1.148 2007/10/19 12:17:28 strk Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -1391,10 +1391,10 @@ assert(tag == SWF::DEFINEVIDEOSTREAM); // 60 uint16_t character_id = in->read_u16(); - video_stream_definition* ch = new video_stream_definition(character_id); - ch->read(in, tag, m); + std::auto_ptr<video_stream_definition> chdef ( new video_stream_definition(character_id) ); + chdef->readDefineVideoStream(in, tag, m); - m->add_character(character_id, ch); + m->add_character(character_id, chdef.release()); } @@ -1424,7 +1424,7 @@ return; } - vdef->read(in, tag, m); + vdef->readDefineVideoFrame(in, tag, m); } void _______________________________________________ Gnash-commit mailing list Gnash-commit@gnu.org http://lists.gnu.org/mailman/listinfo/gnash-commit