Commit: fbc379b5cf5ebf63e2cfe3b8c8d668dfefa389a5
Author: Benoit Bolsee
Date:   Sat Apr 11 20:24:31 2015 +0200
Branches: decklink
https://developer.blender.org/rBfbc379b5cf5ebf63e2cfe3b8c8d668dfefa389a5

BGE DeckLink: fix extend mode.

The algorithm copied from VideoTexture's fast scaling was working only for
shrinking but we also need expanding here. Fixed that.

===================================================================

M       source/gameengine/VideoTexture/DeckLink.cpp

===================================================================

diff --git a/source/gameengine/VideoTexture/DeckLink.cpp 
b/source/gameengine/VideoTexture/DeckLink.cpp
index c0f6c40..d13c8ae 100644
--- a/source/gameengine/VideoTexture/DeckLink.cpp
+++ b/source/gameengine/VideoTexture/DeckLink.cpp
@@ -281,7 +281,7 @@ static bool decklink_ConvImage(u_int *dest, const short 
*destSize, const u_int *
 {
        short w, h, x, y;
        const u_int *s;
-       u_int *d;
+       u_int *d, p;
        bool sameSize = (destSize[0] == srcSize[0] && destSize[1] == 
srcSize[1]);
 
        if (sameSize || !extend)
@@ -337,21 +337,27 @@ static bool decklink_ConvImage(u_int *dest, const short 
*destSize, const u_int *
                                {
                                        // increase width accum
                                        accWidth += destSize[0];
-                                       // if pixel has to be drawn
-                                       if (accWidth >= srcSize[0])
+                                       // convert pixel
+                                       p = (swap) ? CONV_PIXEL(*s) : *s;
+                                       // if pixel has to be drown one or more 
times
+                                       while (accWidth >= srcSize[0])
                                        {
                                                // decrease accum
                                                accWidth -= srcSize[0];
-                                               // convert pixel
-                                               *d = (swap) ? CONV_PIXEL(*s) : 
*s;
-                                               // next pixel
-                                               ++d;
+                                               *d++ = p;
                                        }
                                }
+                               // if there should be more identical lines
+                               while (accHeight >= srcSize[1])
+                               {
+                                       accHeight -= srcSize[1];
+                                       // copy previous line
+                                       memcpy(d, d - destSize[0], 4 * 
destSize[0]);
+                                       d += destSize[0];
+                               }
                        }
-                       // if pixel row will not be drawn
                        else
-                               // move source pointer to next row
+                               // if we skip a source line
                                s += srcSize[0];
                }
        }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to