From 0a995f8093680e0ea233c40d15584e83081ef4fa Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 18 Apr 2005 09:17:56 +0000 Subject: [PATCH] Removed mpeg plugin from CVS, now moved to the Community section of openscenegraph.org as a seperate project. --- Make/dependencies | 2 - Make/makedirdefs | 4 - src/osgPlugins/mpeg/GNUmakefile | 16 -- src/osgPlugins/mpeg/MpegImageStream.cpp | 322 ----------------------- src/osgPlugins/mpeg/MpegImageStream.h | 143 ---------- src/osgPlugins/mpeg/ReaderWriterMPEG.cpp | 41 --- 6 files changed, 528 deletions(-) delete mode 100644 src/osgPlugins/mpeg/GNUmakefile delete mode 100644 src/osgPlugins/mpeg/MpegImageStream.cpp delete mode 100644 src/osgPlugins/mpeg/MpegImageStream.h delete mode 100644 src/osgPlugins/mpeg/ReaderWriterMPEG.cpp diff --git a/Make/dependencies b/Make/dependencies index 7fb854b1b..7bd07a5e0 100644 --- a/Make/dependencies +++ b/Make/dependencies @@ -29,7 +29,6 @@ ifeq ($(DARWIN_QUICKTIME),yes) LIBUNGIF_INSTALLED ?= no LIBTIFF_INSTALLED ?= no LIBPNG_INSTALLED ?= no - LIBMPEG3_INSTALLED ?= no else @@ -38,7 +37,6 @@ else LIBUNGIF_INSTALLED ?= yes LIBTIFF_INSTALLED ?= yes LIBPNG_INSTALLED ?= yes - LIBMPEG3_INSTALLED ?= no endif diff --git a/Make/makedirdefs b/Make/makedirdefs index 74af94f16..3a8e6e6db 100644 --- a/Make/makedirdefs +++ b/Make/makedirdefs @@ -121,10 +121,6 @@ ifeq ($(LIBPNG_INSTALLED),yes) PLUGIN_DIRS += png endif -ifeq ($(LIBMPEG3_INSTALLED),yes) - PLUGIN_DIRS += mpeg -endif - ifeq ($(AVIFILE_INSTALLED),yes) PLUGIN_DIRS += avi endif diff --git a/src/osgPlugins/mpeg/GNUmakefile b/src/osgPlugins/mpeg/GNUmakefile deleted file mode 100644 index e6f19b0b1..000000000 --- a/src/osgPlugins/mpeg/GNUmakefile +++ /dev/null @@ -1,16 +0,0 @@ -TOPDIR = ../../.. -include $(TOPDIR)/Make/makedefs - -CXXFILES =\ - MpegImageStream.cpp\ - ReaderWriterMPEG.cpp\ - -MPEG_LIBS = -lmpeg3 - -LIBS += $(OSG_LIBS) $(MPEG_LIBS) $(OTHER_LIBS) - -TARGET_BASENAME = mpeg -include $(TOPDIR)/Make/cygwin_plugin_def -PLUGIN = $(PLUGIN_PREFIX)$(TARGET_BASENAME).$(PLUGIN_EXT) - -include $(TOPDIR)/Make/makerules diff --git a/src/osgPlugins/mpeg/MpegImageStream.cpp b/src/osgPlugins/mpeg/MpegImageStream.cpp deleted file mode 100644 index fb5562727..000000000 --- a/src/osgPlugins/mpeg/MpegImageStream.cpp +++ /dev/null @@ -1,322 +0,0 @@ -// -*-c++-*- - -/* - * Copyright (C) 2001 Ulrich Hertlein - * - * Uses libmpeg3 by Adam Williams - * See http://www.heroinewarrior.com - * - * The Open Scene Graph (OSG) is a cross platform C++/OpenGL library for - * real-time rendering of large 3D photo-realistic models. - * The OSG homepage is http://www.openscenegraph.org/ - * - * This software is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "MpegImageStream.h" -#include -#include - -#include -#include - - -#include -#include -#include - -#include "libmpeg3/libmpeg3.h" - -#include - - -using namespace osg; - -#define IDLE_TIMEOUT 150000L - - -// Constructor: setup and start thread -MpegImageStream::MpegImageStream(const char* fileName) : ImageStream() -{ - std::cout<<"Opening pegImageStream::MpegImageStream"< lock(_mutex); - _cmd[_wrIndex] = cmd; - _wrIndex = (_wrIndex + 1) % NUM_CMD_INDEX; -} - - -// Get command -MpegImageStream::ThreadCommand MpegImageStream::getCmd() -{ - ThreadCommand cmd = THREAD_IDLE; - - OpenThreads::ScopedLock lock(_mutex); - if (_rdIndex != _wrIndex) - { - cmd = _cmd[_rdIndex]; - _rdIndex = (_rdIndex + 1) % NUM_CMD_INDEX; - } - - return cmd; -} - - -void MpegImageStream::load(const char* fileName) -{ - mpeg3_t* mpg = mpeg3_open((char*) fileName); - if (!mpg) { - osg::notify(WARN) << "Unable to open " << fileName << std::endl; - return; - } - - if (!mpeg3_has_video(mpg)) - { - osg::notify(WARN) << "No video streams in" << fileName << std::endl; - return; - } - if (mpeg3_has_audio(mpg)) - { - osg::notify(INFO) << "Stream has audio" << std::endl; - } - - _mpg = (void*)mpg; - - mpeg3_set_cpus(mpg, 1); - mpeg3_set_mmx(mpg, _useMMX); - - int str = 0; //mpeg3_total_vstreams(mpg) - 1; - - _fps = mpeg3_frame_rate(mpg, str); - _frames = mpeg3_video_frames(mpg, str); - _len = (float) _frames / _fps; - - - int s = mpeg3_video_width(mpg, str); - int t = mpeg3_video_height(mpg, str); - - // Calculate texture size - // these are also calculated and stored within osg::Texture but - // too late (on the first apply) to be of any use... - int texWidth = 1; - for (; texWidth < s; texWidth <<= 1) - ; - int texHeight = 1; - for (; texHeight < t; texHeight <<= 1) - ; - - - // Allocate image data - unsigned char* data = new unsigned char [s * t * 4]; - _videoWriteData = new unsigned char [s * t * 4]; - - setImage(s, t, 1, - GL_RGB, - GL_BGRA, GL_UNSIGNED_BYTE, data, - osg::Image::USE_NEW_DELETE); - - - // Allocate decoder rows - // documentation says we need add'l bytes at the end of each - // row for MMX but this is more efficient and works so far. - _rows = new unsigned char* [t]; - - // set up the rows to the current view write data. - swapData(); - - - osg::notify(INFO) << _frames << " @ " << _fps << " " << _len << "s" << std::endl; - osg::notify(INFO) << "img " << s << "x" << t << std::endl; - osg::notify(INFO) << "tex " << texWidth << "x" << texHeight << std::endl; -} - - -void MpegImageStream::swapData() -{ - std::swap(_videoWriteData,_data); - unsigned char* dp = _videoWriteData; - for (int i = 0; i < t(); i++) - { -// #define FLIP_VERTICAL_SO_ORIENTATED_LIKE_OPENGL_WITH_ORIGIN_AT_BOTTOM_LEFT -#ifdef FLIP_VERTICAL_SO_ORIENTATED_LIKE_OPENGL_WITH_ORIGIN_AT_BOTTOM_LEFT - _rows[t()-i-1] = dp; -#else - _rows[i] = dp; -#endif - dp += (s() * 4); - } -} - - -void MpegImageStream::quit(bool wiatForThreadToExit) -{ - osg::notify(osg::DEBUG_INFO)<<"Sending quit"<tick(); - osg::Timer_t last_frame_tick = start_tick; - double timePerFrame = 1.0f/_fps; - double frameNumber = 0.0; - - while (!done) - { - // Handle commands - ThreadCommand cmd = getCmd(); - if (cmd != THREAD_IDLE) - { - switch (cmd) - { - case THREAD_START: // Start or continue stream - playing = true; - break; - case THREAD_STOP: // XXX - playing = false; - break; - case THREAD_REWIND: // XXX - t0 = 0.0; - mpeg3_seek_percentage(mpg, 0.0); - start_tick = timer->tick(); - frameNumber = 0; - break; - case THREAD_CLOSE: // Stop and close - playing = false; - if (mpg) - { - mpeg3_close(mpg); - mpg = NULL; - } - break; - case THREAD_QUIT: - playing = false; - done = true; - break; - default: - osg::notify(osg::WARN) << "Unknown command " << cmd << std::endl; - break; - } - } - - if (playing) - { - last_frame_tick = timer->tick(); - - // XXX needs more work to be real-time - mpeg3_read_frame(mpg, _rows, - 0, 0, _s, _t, - _s, _t, - MPEG3_BGRA8888, str); - - swapData(); - - dirty(); //Image(); - - ++frameNumber; - - if (frameNumber>=_frames) - { - if (getLoopingMode()==LOOPING) - { - rewind(); - } - else - { - pause(); - } - } - else - { - while (timePerFrame*(frameNumber+1)>timer->delta_s(start_tick,timer->tick())) - { - ::usleep(delay); - } - } - } - else if (!done) - { - //OpenThreads::Thread::YieldCurrentThread(); - ::usleep(IDLE_TIMEOUT); - } - } -} diff --git a/src/osgPlugins/mpeg/MpegImageStream.h b/src/osgPlugins/mpeg/MpegImageStream.h deleted file mode 100644 index 194070428..000000000 --- a/src/osgPlugins/mpeg/MpegImageStream.h +++ /dev/null @@ -1,143 +0,0 @@ -// -*-c++-*- - -/* - * Copyright (C) 2001 Ulrich Hertlein - * - * Uses libmpeg3 by Adam Williams - * See http://www.heroinewarrior.com - * - * The Open Scene Graph (OSG) is a cross platform C++/OpenGL library for - * real-time rendering of large 3D photo-realistic models. - * The OSG homepage is http://www.openscenegraph.org/ - * - * This software is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _MPEGIMAGESTREAM_H_ -#define _MPEGIMAGESTREAM_H_ - -#include -#include - -#include -#include - -#define NUM_CMD_INDEX 20 - -namespace osg { - - /** - * MPEG1/2 Image Stream class. - */ - class MpegImageStream : public osg::ImageStream, public OpenThreads::Thread - { - public: - MpegImageStream(const char* fileName = NULL); - - virtual Object* clone() const { return new MpegImageStream; } - virtual bool isSameKindAs(const Object* obj) const { - return dynamic_cast(obj) != NULL; - } - virtual const char* className() const { return "MpegImageStream"; } - - /// Start or continue stream. - virtual void play() - { - if (!isRunning()) start(); - - osg::notify(osg::INFO)<<"Play video"< -#include -#include -#include - -#include -#include -#include - -#include "MpegImageStream.h" - -class ReaderWriterMPEG : public osgDB::ReaderWriter -{ - public: - - virtual const char* className() const { return "MPEG ImageStream Reader"; } - - virtual bool acceptsExtension(const std::string& extension) const - { - return osgDB::equalCaseInsensitive(extension,"mpg") || - osgDB::equalCaseInsensitive(extension,"mpv"); - } - - virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options* options) const - { - std::string ext = osgDB::getLowerCaseFileExtension(file); - if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED; - - std::string fileName = osgDB::findDataFile( file, options ); - if (fileName.empty()) return ReadResult::FILE_NOT_FOUND; - - osg::MpegImageStream* mpeg = new osg::MpegImageStream(fileName.c_str()); - // mpeg->play(); - - return mpeg; - } -}; - -// now register with Registry to instantiate the above -// reader/writer. -osgDB::RegisterReaderWriterProxy g_readerWriter_MPEG_Proxy;