Revision: 17264
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17264
Author:   ben2610
Date:     2008-11-01 13:48:46 +0100 (Sat, 01 Nov 2008)

Log Message:
-----------
BGE Video Texture: fix constant initializer problem with Exception description. 
Uniformized the line ending.

Modified Paths:
--------------
    trunk/blender/source/gameengine/VideoTexture/Exception.cpp
    trunk/blender/source/gameengine/VideoTexture/Exception.h
    trunk/blender/source/gameengine/VideoTexture/ImageMix.cpp
    trunk/blender/source/gameengine/VideoTexture/ImageRender.cpp
    trunk/blender/source/gameengine/VideoTexture/Texture.cpp
    trunk/blender/source/gameengine/VideoTexture/Texture.h
    trunk/blender/source/gameengine/VideoTexture/VideoFFmpeg.cpp
    trunk/blender/source/gameengine/VideoTexture/VideoFFmpeg.h
    trunk/blender/source/gameengine/VideoTexture/blendVideoTex.cpp

Modified: trunk/blender/source/gameengine/VideoTexture/Exception.cpp
===================================================================
--- trunk/blender/source/gameengine/VideoTexture/Exception.cpp  2008-11-01 
12:45:19 UTC (rev 17263)
+++ trunk/blender/source/gameengine/VideoTexture/Exception.cpp  2008-11-01 
12:48:46 UTC (rev 17264)
@@ -44,7 +44,6 @@
 ExpDesc::ExpDesc (ExceptionID & exp, char * desc, RESULT hres) 
 : m_expID(exp), m_hRslt(hres), m_description(desc)
 {
-       m_expDescs.push_back(this);
 }
 
 // destructor
@@ -196,3 +195,15 @@
        m_fileName = xpt.m_fileName;
        m_line = xpt.m_line;
 }
+
+void registerAllExceptions(void)
+{
+    errGenerDesc.registerDesc();
+    errNFoundDesc.registerDesc();
+    MaterialNotAvailDesc.registerDesc();
+    ImageSizesNotMatchDesc.registerDesc();
+    SceneInvalidDesc.registerDesc();
+    CameraInvalidDesc.registerDesc();
+    SourceVideoEmptyDesc.registerDesc();
+    SourceVideoCreationDesc.registerDesc();
+}

Modified: trunk/blender/source/gameengine/VideoTexture/Exception.h
===================================================================
--- trunk/blender/source/gameengine/VideoTexture/Exception.h    2008-11-01 
12:45:19 UTC (rev 17263)
+++ trunk/blender/source/gameengine/VideoTexture/Exception.h    2008-11-01 
12:48:46 UTC (rev 17264)
@@ -27,6 +27,7 @@
 #include <exception>
 #include <vector>
 #include <string>
+#include <algorithm>
 
 #include "Common.h"
 
@@ -117,6 +118,11 @@
                desc = m_description;
        }
 
+    void registerDesc(void)
+    {
+        if (std::find(m_expDescs.begin(), m_expDescs.end(), this) == 
m_expDescs.end())
+            m_expDescs.push_back(this);
+    }
        // list of exception descriptions
        static std::vector<ExpDesc*> m_expDescs;
 
@@ -192,4 +198,13 @@
 
 };
 
+extern ExpDesc MaterialNotAvailDesc;
+extern ExpDesc ImageSizesNotMatchDesc;
+extern ExpDesc SceneInvalidDesc;
+extern ExpDesc CameraInvalidDesc;
+extern ExpDesc SourceVideoEmptyDesc;
+extern ExpDesc SourceVideoCreationDesc;
+
+
+void registerAllExceptions(void);
 #endif

Modified: trunk/blender/source/gameengine/VideoTexture/ImageMix.cpp
===================================================================
--- trunk/blender/source/gameengine/VideoTexture/ImageMix.cpp   2008-11-01 
12:45:19 UTC (rev 17263)
+++ trunk/blender/source/gameengine/VideoTexture/ImageMix.cpp   2008-11-01 
12:48:46 UTC (rev 17264)
@@ -58,9 +58,9 @@
        return true;
 }
 
-static ExceptionID ImageSizesNotMatch;
+ExceptionID ImageSizesNotMatch;
 
-static ExpDesc ImageSizesNotMatchDesc (ImageSizesNotMatch, "Image sizes of 
sources are different");
+ExpDesc ImageSizesNotMatchDesc (ImageSizesNotMatch, "Image sizes of sources 
are different");
 
 // calculate image from sources and set its availability
 void ImageMix::calcImage (unsigned int texId)

Modified: trunk/blender/source/gameengine/VideoTexture/ImageRender.cpp
===================================================================
--- trunk/blender/source/gameengine/VideoTexture/ImageRender.cpp        
2008-11-01 12:45:19 UTC (rev 17263)
+++ trunk/blender/source/gameengine/VideoTexture/ImageRender.cpp        
2008-11-01 12:48:46 UTC (rev 17264)
@@ -94,6 +94,10 @@
        ImageViewport::calcImage(texId);
 }
 
+void ImageRender::Render()
+{
+    //
+}
 
 // refresh lights
 void ImageRender::refreshLights (void)
@@ -120,9 +124,9 @@
 BlendType<KX_Camera> cameraType ("KX_Camera");
 
 
-static ExceptionID SceneInvalid, CameraInvalid;
-static ExpDesc SceneInvalidDesc (SceneInvalid, "Scene object is invalid");
-static ExpDesc CameraInvalidDesc (CameraInvalid, "Camera object is invalid");
+ExceptionID SceneInvalid, CameraInvalid;
+ExpDesc SceneInvalidDesc (SceneInvalid, "Scene object is invalid");
+ExpDesc CameraInvalidDesc (CameraInvalid, "Camera object is invalid");
 
 // object initialization
 static int ImageRender_init (PyObject * pySelf, PyObject * args, PyObject * 
kwds)

Modified: trunk/blender/source/gameengine/VideoTexture/Texture.cpp
===================================================================
--- trunk/blender/source/gameengine/VideoTexture/Texture.cpp    2008-11-01 
12:45:19 UTC (rev 17263)
+++ trunk/blender/source/gameengine/VideoTexture/Texture.cpp    2008-11-01 
12:48:46 UTC (rev 17264)
@@ -165,8 +165,8 @@
 }
 
 
-static ExceptionID MaterialNotAvail;
-static ExpDesc MaterialNotAvailDesc (MaterialNotAvail, "Texture material is 
not available");
+ExceptionID MaterialNotAvail;
+ExpDesc MaterialNotAvailDesc (MaterialNotAvail, "Texture material is not 
available");
 
 // Texture object initialization
 int Texture_init (Texture *self, PyObject *args, PyObject *kwds)
@@ -272,13 +272,13 @@
                PyErr_SetString(PyExc_TypeError, "The value must be a bool");
                return NULL;
        }
-       // some trick here: we are in the business of loading a texture,
-       // no use to do it if we are still in the same rendering frame.
-       // We find this out by looking at the engine current clock time
-       KX_KetsjiEngine* engine = KX_GetActiveEngine();
-       if (engine->GetClockTime() != self->m_lastClock) 
-       {
-               self->m_lastClock = engine->GetClockTime();
+       // some trick here: we are in the business of loading a texture,
+       // no use to do it if we are still in the same rendering frame.
+       // We find this out by looking at the engine current clock time
+       KX_KetsjiEngine* engine = KX_GetActiveEngine();
+       if (engine->GetClockTime() != self->m_lastClock) 
+       {
+               self->m_lastClock = engine->GetClockTime();
                // set source refresh
                bool refreshSource = (param == Py_True);
                // try to proces texture from source

Modified: trunk/blender/source/gameengine/VideoTexture/Texture.h
===================================================================
--- trunk/blender/source/gameengine/VideoTexture/Texture.h      2008-11-01 
12:45:19 UTC (rev 17263)
+++ trunk/blender/source/gameengine/VideoTexture/Texture.h      2008-11-01 
12:48:46 UTC (rev 17264)
@@ -60,7 +60,7 @@
        // scaled image buffer size
        unsigned int m_scaledImgSize;
        // last refresh
-       double m_lastClock;
+       double m_lastClock;
 
        // image source
        PyImage * m_source;

Modified: trunk/blender/source/gameengine/VideoTexture/VideoFFmpeg.cpp
===================================================================
--- trunk/blender/source/gameengine/VideoTexture/VideoFFmpeg.cpp        
2008-11-01 12:45:19 UTC (rev 17263)
+++ trunk/blender/source/gameengine/VideoTexture/VideoFFmpeg.cpp        
2008-11-01 12:48:46 UTC (rev 17264)
@@ -51,11 +51,11 @@
 m_lastFrame(-1),  m_curPosition(-1), m_startTime(0), 
 m_captWidth(0), m_captHeight(0), m_captRate(0.f)
 {
-       // set video format
-       m_format = RGB24;
-       // force flip because ffmpeg always return the image in the wrong 
orientation for texture
-       setFlip(true);
-       // construction is OK
+       // set video format
+       m_format = RGB24;
+       // force flip because ffmpeg always return the image in the wrong 
orientation for texture
+       setFlip(true);
+       // construction is OK
        *hRslt = S_OK;
 }
 
@@ -175,9 +175,9 @@
 #else
        m_baseFrameRate = av_q2d(formatCtx->streams[videoStream]->r_frame_rate);
 #endif
-       if (m_baseFrameRate <= 0.0) 
-               m_baseFrameRate = defFrameRate;
-
+       if (m_baseFrameRate <= 0.0) 
+               m_baseFrameRate = defFrameRate;
+
        m_codec = codec;
        m_codecCtx = codecCtx;
        m_formatCtx = formatCtx;
@@ -241,9 +241,9 @@
        else
                m_preseek = 0;
 
-       // get video time range
+       // get video time range
        m_range[0] = 0.0;
-       m_range[1] = (double)m_formatCtx->duration / AV_TIME_BASE;
+       m_range[1] = (double)m_formatCtx->duration / AV_TIME_BASE;
 
        // open base class
        VideoBase::openFile(filename);
@@ -265,7 +265,7 @@
        AVInputFormat           *inputFormat;
        AVFormatParameters      formatParams;
        AVRational                      frameRate;
-       char                            *p, filename[28], rateStr[20];
+       char                            filename[28], rateStr[20];
 
        do_init_ffmpeg();
 
@@ -333,8 +333,8 @@
 
        // for video capture it is important to do non blocking read
        m_formatCtx->flags |= AVFMT_FLAG_NONBLOCK;
-       // open base class
-       VideoBase::openCam(file, camIdx);
+       // open base class
+       VideoBase::openCam(file, camIdx);
 }
 
 
@@ -346,7 +346,7 @@
                // if object is able to play
                if (VideoBase::play())
                {
-                       // set video position
+                       // set video position
                        setPositions();
                        // return success
                        return true;
@@ -372,92 +372,92 @@
 }
 
 
-// set video range
-void VideoFFmpeg::setRange (double start, double stop)
-{
-       try
-       {
-               // set range
-               VideoBase::setRange(start, stop);
-               // set range for video
-               setPositions();
-       }
-       CATCH_EXCP;
-}
-
-// set framerate
-void VideoFFmpeg::setFrameRate (float rate)
-{
-       VideoBase::setFrameRate(rate);
-}
-
-
-// image calculation
-void VideoFFmpeg::calcImage (unsigned int texId)
-{
-       loadFrame();
-}
-
-
-// load frame from video
-void VideoFFmpeg::loadFrame (void)
-{
-       // get actual time
-       double actTime = PIL_check_seconds_timer() - m_startTime;
-       // if video has ended
-       if (m_isFile && actTime * m_frameRate >= m_range[1])
-       {
-               // if repeats are set, decrease them
-               if (m_repeat > 0) 
-                       --m_repeat;
-               // if video has to be replayed
-               if (m_repeat != 0)
-               {
-                       // reset its position
-                       actTime -= (m_range[1] - m_range[0]) / m_frameRate;
-                       m_startTime += (m_range[1] - m_range[0]) / m_frameRate;
-               }
-               // if video has to be stopped, stop it
-               else 
-                       m_status = SourceStopped;
-       }
-       // if video is playing
-       if (m_status == SourcePlaying)
-       {
-               // actual frame
-               long actFrame = m_isFile ? long(actTime * actFrameRate()) : 
m_lastFrame + 1;
-               // if actual frame differs from last frame
-               if (actFrame != m_lastFrame)
-               {
-                       // get image
-                       if(grabFrame(actFrame))
-                       {
-                               AVFrame* frame = getFrame();
-                               // save actual frame
-                               m_lastFrame = actFrame;
-                               // init image, if needed
-                               init(short(m_codecCtx->width), 
short(m_codecCtx->height));
-                               // process image
-                               process((BYTE*)(frame->data[0]));
-                       }
-               }
-       }
-}
-
-
-// set actual position
-void VideoFFmpeg::setPositions (void)
-{
-       // set video start time
-       m_startTime = PIL_check_seconds_timer();
-       // if file is played and actual position is before end position
-       if (m_isFile && m_lastFrame >= 0 && m_lastFrame < m_range[1] * 
actFrameRate())
-               // continue from actual position
-               m_startTime -= double(m_lastFrame) / actFrameRate();
-       else
-               m_startTime -= m_range[0];
-}
-
+// set video range
+void VideoFFmpeg::setRange (double start, double stop)
+{
+       try
+       {
+               // set range
+               VideoBase::setRange(start, stop);
+               // set range for video
+               setPositions();
+       }
+       CATCH_EXCP;
+}
+
+// set framerate
+void VideoFFmpeg::setFrameRate (float rate)
+{
+       VideoBase::setFrameRate(rate);
+}
+
+
+// image calculation
+void VideoFFmpeg::calcImage (unsigned int texId)
+{
+       loadFrame();
+}
+
+
+// load frame from video
+void VideoFFmpeg::loadFrame (void)
+{

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to