context.Result(result)
return result
- env2 = env.Copy( LIBPATH = env['BF_OPENAL'] )
+ env2 = env.Clone( LIBPATH = env['BF_OPENAL'] )
sconf_temp = mkdtemp()
conf = Configure( env2, {'CheckFreeAlut' : CheckFreeAlut}, sconf_temp, '/dev/null' )
if conf.CheckFreeAlut( env2 ):
##LOPTS = --dynamic
##DYNLDFLAGS = -shared $(LDFLAGS)
-BF_PROFILE_FLAGS = ' -pg -g '
+BF_PROFILE_CCFLAGS = ['-pg', '-g ']
BF_PROFILE = False
BF_DEBUG = False
-BF_DEBUG_FLAGS = '-g'
+BF_DEBUG_CCFLAGS = ['-g']
BF_BUILDDIR='../build/darwin'
BF_INSTALLDIR='../install/darwin'
##LOPTS = --dynamic
##DYNLDFLAGS = -shared $(LDFLAGS)
-BF_PROFILE_FLAGS = ['-pg','-g']
BF_PROFILE = False
+BF_PROFILE_CCFLAGS = ['-pg','-g']
BF_DEBUG = False
-BF_DEBUG_FLAGS = '-g'
+BF_DEBUG_CCFLAGS = ['-g']
BF_BUILDDIR = '../build/linux2'
BF_INSTALLDIR='../install/linux2'
LLIBS = [ '-ldxguid', '-lgdi32', '-lmsvcrt', '-lwinmm', '-lmingw32', '-lm', '-lws2_32', '-lz'] #'-lutil', '-lc', '-lm', '-ldl', '-lpthread' ]
BF_DEBUG = False
-BF_DEBUG_FLAGS= ''
+BF_DEBUG_CCFLAGS= []
BF_BUILDDIR = '../build/linuxcross'
BF_INSTALLDIR='../install/linuxcross'
##LOPTS = --dynamic
##DYNLDFLAGS = -shared $(LDFLAGS)
-BF_PROFILE_FLAGS = ' -pg -g '
+BF_PROFILE_CCFLAGS = ['-pg', '-g']
BF_PROFILE = False
BF_DEBUG = False
-BF_DEBUG_FLAGS = '-g'
+BF_DEBUG_CCFLAGS = ['-g']
BF_BUILDDIR='../build/openbsd3'
BF_INSTALLDIR='../install/openbsd3'
##LOPTS = --dynamic
##DYNLDFLAGS = -shared $(LDFLAGS)
-BF_PROFILE_FLAGS = ['-pg','-g']
+BF_PROFILE_CCFLAGS = ['-pg','-g']
BF_PROFILE = False
BF_DEBUG = False
-BF_DEBUG_FLAGS = ''
+BF_DEBUG_CCFLAGS = []
BF_BUILDDIR = '../build/sunos5'
BF_INSTALLDIR='../install/sunos5'
BF_DOCDIR='../install/doc'
-PLATFORM_LINKFLAGS = ['']
+PLATFORM_LINKFLAGS = []
LLIBS = ['-lshell32', '-lshfolder', '-lgdi32', '-lmsvcrt', '-lwinmm', '-lmingw32', '-lm', '-lws2_32', '-lz', '-lstdc++']
BF_DEBUG = False
-BF_DEBUG_FLAGS= '-g'
+BF_DEBUG_CCFLAGS= ['-g']
-BF_PROFILE_FLAGS = ['-pg','-g']
+BF_PROFILE_CCFLAGS = ['-pg','-g']
BF_PROFILE = False
BF_BUILDDIR = '..\\build\\win32-mingw'
BF_QUICKTIME_LIB = 'qtmlClient'
BF_QUICKTIME_LIBPATH = '${BF_QUICKTIME}/Libraries'
+WITH_BF_OPENJPEG = True
+
+WITH_BF_REDCODE = False
+BF_REDCODE_INC = '#extern'
+
WITH_BF_STATICOPENGL = False
BF_OPENGL_INC = '${BF_OPENGL}/include'
BF_OPENGL_LIBINC = '${BF_OPENGL}/lib'
sources = env.Glob('*.c')
incs = '.'
-flags = "-Wall -O3 -ffast-math -std=c99"
+if env['OURPLATFORM'] == 'win32-vc':
+ flags = []
+else:
+ flags = ['-Wall', '-O3', '-ffast-math', '-std=c99']
-oj_env = env.Copy();
-oj_env.Replace(CCFLAGS = '')
-oj_env.Replace(BF_DEBUG_FLAGS = '')
+oj_env = env.Clone()
+if not env['OURPLATFORM'] == 'win32-vc':
+ oj_env.Replace(CCFLAGS = '')
+ oj_env.Replace(BF_DEBUG_FLAGS = '')
oj_env.BlenderLib ( libname='extern_openjpeg',
sources=sources, includes=Split(incs),
defines=[],
libtype=['core','intern','player'],
- priority=[10, 10, 300], compileflags = Split(flags))
+ priority=[10, 10, 300], compileflags = flags)
sources = env.Glob('*.c')
incs = '. ../libopenjpeg'
-root = "extern/libredcode"
-
-if not os.path.isdir(root + "/include"):
- os.mkdir(root + "/include");
-if not os.path.isdir(root + "/include/redcode"):
- os.mkdir(root + "/include/redcode");
-
-for h in env.Glob('*.h'):
- shutil.copyfile(root + "/" + h,
- root + "/include/redcode/" + h)
-
-
env.BlenderLib ( libname='extern_redcode',
sources=sources, includes=Split(incs),
defines=[],
+#ifdef _WIN32
+#include <Winsock2.h>
+#else
#include <netinet/in.h>
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#
# Source: http://www.nelson-games.de/bl2m3g/source
#
-# $Id: m3g_export.py,v 0.1 2005/04/19 12:25 gerhardv Exp gerhardv $
+# $Id$
#
# Author: Gerhard Völkl
#
render_context.setRenderWinSize(100)
render_context.setImageType(Render.PNG)
render_context.enableExtensions(True)
- render_context.enableSky() # No alpha needed.
- render_context.enableRGBColor()
+ render_context.enablePremultiply() # No alpha needed.
+ render_context.enableRGBAColor()
render_context.threads = 2
#Render.EnableDispView() # Broken??
render_mat= B.Material.New()
render_mat.mode |= B.Material.Modes.SHADELESS
render_mat.mode |= B.Material.Modes.TEXFACE
-
-
+ render_mat.mode |= B.Material.Modes.ZTRANSP
+ render_mat.setAlpha(0.0)
+
render_me= B.Mesh.New()
render_me.verts.extend([Vector(0,0,0)]) # Stupid, dummy vert, preverts errors. when assigning UV's/
render_ob= B.Object.New('Mesh')
"""
-# $Id: export_lightwave_motion.py 9924 2007-01-27 02:15:14Z campbellbarton $
+# $Id$
# --------------------------------------------------------------------------
# ***** BEGIN GPL LICENSE BLOCK *****
#
own.life += ob.life
ob.life = 0
print own.life
- """\r
+ """
+
main()
'''
struct Object;
struct DerivedMesh;
struct BPoint;
+struct MDeformVert;
extern struct Lattice *editLatt;
void lattice_applyVertexCos(struct Object *ob, float (*vertexCos)[3]);
void lattice_calc_modifiers(struct Object *ob);
+struct MDeformVert* lattice_get_deform_verts(struct Object *lattice);
+
#endif
struct Object;
struct DerivedMesh;
struct ShrinkwrapModifierData;
+struct MDeformVert;
struct BVHTree;
float (*vertexCos)[3]; //vertexs being shrinkwraped
int numVerts;
+ struct MDeformVert* dvert; //Pointer to mdeform array
+ int vgroup; //Vertex group num
+
struct DerivedMesh *target; //mesh we are shrinking to
SpaceTransform local2target; //transform to move bettwem local and target space
extern void end_ffmpeg(void);
extern void append_ffmpeg(int frame, int *pixels, int rectx, int recty);
-void silence_log_ffmpeg(int quiet);
-
#ifdef __cplusplus
}
#endif
* ***** END GPL LICENSE BLOCK *****
*/
-#ifndef WIN32
- #include <unistd.h> // for read close
- #include <sys/param.h> // for MAXPATHLEN
+#ifndef _WIN32
+ #include <unistd.h> // for read close
+ #include <sys/param.h> // for MAXPATHLEN
#else
- #include <io.h> // for open close read
+ #include <io.h> // for open close read
+ #define open _open
+ #define read _read
+ #define close _close
+ #define write _write
#endif
#include <stdlib.h>
float vertexgroup_get_vertex_weight(const struct MDeformVert *dvert, int index, int group_num)
{
- if(group_num == -1)
+ if(group_num == -1 || dvert == NULL)
return 1.0;
- if(dvert == 0)
- return 0.0;
-
return deformvert_get_weight(dvert+index, group_num);
}
#include <fcntl.h>
#include <string.h>
-#ifndef WIN32
+#ifndef _WIN32
#include <unistd.h>
#else
#include <io.h>
+#define open _open
+#define read _read
+#define close _close
+#define write _write
#endif
#include "MEM_guardedalloc.h"
BLI_addtail(&ob->disp, dl);
}
}
+
+struct MDeformVert* lattice_get_deform_verts(struct Object *oblatt)
+{
+ if(oblatt->type == OB_LATTICE)
+ {
+ Lattice *lt = (oblatt==G.obedit)?editLatt:(Lattice*)oblatt->data;
+ return lt->dvert;
+ }
+
+ return NULL;
+}
+
{
if(derivedData) dm = CDDM_copy(derivedData);
else if(ob->type==OB_MESH) dm = CDDM_from_mesh(ob->data, ob);
+ else if(ob->type==OB_LATTICE) dm = NULL;
else return;
- if(dataMask & CD_MVERT)
+ if(dm != NULL && (dataMask & CD_MVERT))
{
CDDM_apply_vert_coords(dm, vertexCos);
CDDM_calc_normals(dm);
{
if(derivedData) dm = CDDM_copy(derivedData);
else if(ob->type==OB_MESH) dm = CDDM_from_editmesh(editData, ob->data);
+ else if(ob->type==OB_LATTICE) dm = NULL;
else return;
- if(dataMask & CD_MVERT)
+ if(dm != NULL && (dataMask & CD_MVERT))
{
CDDM_apply_vert_coords(dm, vertexCos);
CDDM_calc_normals(dm);
{
if(derivedData) dm = CDDM_copy(derivedData);
else if(ob->type==OB_MESH) dm = CDDM_from_mesh(ob->data, ob);
+ else if(ob->type==OB_LATTICE) dm = NULL;
else return;
- if(dataMask & CD_MVERT)
+ if(dm != NULL && (dataMask & CD_MVERT))
{
CDDM_apply_vert_coords(dm, vertexCos);
CDDM_calc_normals(dm);
{
if(derivedData) dm = CDDM_copy(derivedData);
else if(ob->type==OB_MESH) dm = CDDM_from_editmesh(editData, ob->data);
+ else if(ob->type==OB_LATTICE) dm = NULL;
else return;
- if(dataMask & CD_MVERT)
+ if(dm != NULL && (dataMask & CD_MVERT))
{
CDDM_apply_vert_coords(dm, vertexCos);
CDDM_calc_normals(dm);
#include "BKE_shrinkwrap.h"
#include "BKE_DerivedMesh.h"
+#include "BKE_lattice.h"
#include "BKE_utildefines.h"
#include "BKE_deform.h"
#include "BKE_cdderivedmesh.h"
calc.numVerts = numVerts;
calc.vertexCos = vertexCos;
+ //DeformVertex
+ calc.vgroup = get_named_vertexgroup_num(calc.ob, calc.smd->vgroup_name);
+ if(calc.original)
+ {
+ calc.dvert = calc.original->getVertDataArray(calc.original, CD_MDEFORMVERT);
+ }
+ else if(calc.ob->type == OB_LATTICE)
+ {
+ calc.dvert = lattice_get_deform_verts(calc.ob);
+ }
+
+
if(smd->target)
{
//TODO currently we need a copy in case object_get_derived_final returns an emDM that does not defines getVertArray or getFace array
void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
{
int i;
- const int vgroup = get_named_vertexgroup_num(calc->ob, calc->smd->vgroup_name);
- MDeformVert *const dvert = calc->original ? calc->original->getVertDataArray(calc->original, CD_MDEFORMVERT) : NULL;
BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh;
BVHTreeNearest nearest = NULL_BVHTreeNearest;
{
float *co = calc->vertexCos[i];
float tmp_co[3];
- float weight = vertexgroup_get_vertex_weight(dvert, i, vgroup);
+ float weight = vertexgroup_get_vertex_weight(calc->dvert, i, calc->vgroup);
if(weight == 0.0f) continue;
VECCOPY(tmp_co, co);
MVert *vert = NULL; //Needed in case of vertex normal
DerivedMesh* ss_mesh = NULL;
- //Vertex group data
- const int vgroup = get_named_vertexgroup_num(calc->ob, calc->smd->vgroup_name);
- const MDeformVert *dvert = calc->original ? calc->original->getVertDataArray(calc->original, CD_MDEFORMVERT) : NULL;
-
-
//Raycast and tree stuff
BVHTreeRayHit hit;
BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh; //target
float *co = calc->vertexCos[i];
float tmp_co[3], tmp_no[3];
float lim = 10000.0f; //TODO: we should use FLT_MAX here, but sweepsphere code isnt prepared for that
- float weight = vertexgroup_get_vertex_weight(dvert, i, vgroup);
+ float weight = vertexgroup_get_vertex_weight(calc->dvert, i, calc->vgroup);
if(weight == 0.0f) continue;
{
int i;
- const int vgroup = get_named_vertexgroup_num(calc->ob, calc->smd->vgroup_name);
- const MDeformVert *const dvert = calc->original ? calc->original->getVertDataArray(calc->original, CD_MDEFORMVERT) : NULL;
-
BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh;
BVHTreeNearest nearest = NULL_BVHTreeNearest;
{
float *co = calc->vertexCos[i];
float tmp_co[3];
- float weight = vertexgroup_get_vertex_weight(dvert, i, vgroup);
+ float weight = vertexgroup_get_vertex_weight(calc->dvert, i, calc->vgroup);
if(weight == 0.0f) continue;
//Convert the vertex to tree coordinates
#include "BKE_simple_deform.h"
#include "BKE_DerivedMesh.h"
+#include "BKE_lattice.h"
#include "BKE_deform.h"
#include "BKE_utildefines.h"
#include "BLI_arithb.h"
if(dm)
- dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT);
+ {
+ dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT);
+ }
+ else if(ob->type == OB_LATTICE)
+ {
+ dvert = lattice_get_deform_verts(ob);
+ }
+
switch(smd->mode)
else
fac= 0.0f;
+ if (coba->ipotype==4) {
+ /* constant */
+ out[0]= cbd2->r;
+ out[1]= cbd2->g;
+ out[2]= cbd2->b;
+ out[3]= cbd2->a;
+ return 1;
+ }
+
if(coba->ipotype>=2) {
/* ipo from right to left: 3 2 1 0 */
#include <ffmpeg/rational.h>
#include <ffmpeg/swscale.h>
#include <ffmpeg/opt.h>
-#include <ffmpeg/log.h>
#if LIBAVFORMAT_VERSION_INT < (49 << 16)
#define FFMPEG_OLD_FRAME_RATE 1
#define FFMPEG_AUTOSPLIT_SIZE 2000000000
-void silence_log_ffmpeg(int quiet)
-{
- if (quiet)
- {
- av_log_set_level(AV_LOG_QUIET);
- }
- else
- {
- av_log_set_level(AV_LOG_INFO);
- }
-}
-
/* Delete a picture buffer */
static void delete_picture(AVFrame* f)
#endif
#ifdef WITH_REDCODE
-#include <redcode/format.h>
+#ifdef _WIN32 /* on windows we use the one in extern instead */
+#include "libredcode/format.h"
+#else
+#include "libredcode/format.h"
+#endif
#endif
#include "IMB_imbuf_types.h"
* ***** END GPL LICENSE BLOCK *****
*/
-#ifdef WIN32
+#ifdef _WIN32
#include <io.h>
+#define open _open
+#define read _read
+#define close _close
+#define write _write
#endif
#include "imbuf.h"
#include "imbuf_patch.h"
#endif
#ifdef WITH_REDCODE
-#include <redcode/format.h>
-#include <redcode/codec.h>
+#ifdef _WIN32 /* on windows we use the ones in extern instead */
+#include "libredcode/format.h"
+#include "libredcode/codec.h"
+#else
+#include "libredcode/format.h"
+#include "libredcode/codec.h"
+#endif
#endif
/****/
* $Id$
*/
-#ifdef WIN32
+#ifdef _WIN32
#include <io.h>
#include <stddef.h>
#include <sys/types.h>
#include "mmap_win.h"
+#define open _open
+#define read _read
+#define close _close
#endif
#include "BLI_blenlib.h"
* $Id$
*/
+#ifdef _WIN32
+#include <io.h>
+#define open _open
+#define read _read
+#define close _close
+#endif
+
#include "BLI_blenlib.h"
#include "DNA_userdef_types.h"
#include "BKE_global.h"
-#include "BKE_writeffmpeg.h" /* for silence_log_ffmpeg */
#include "imbuf.h"
#include "imbuf_patch.h"
#include <ffmpeg/avcodec.h>
#include <ffmpeg/avformat.h>
//#include <ffmpeg/avdevice.h>
+#include <ffmpeg/log.h>
#if LIBAVFORMAT_VERSION_INT < (49 << 16)
#define FFMPEG_OLD_FRAME_RATE 1
#endif
#ifdef WITH_FFMPEG
+
+void silence_log_ffmpeg(int quiet)
+{
+ if (quiet)
+ {
+ av_log_set_level(AV_LOG_QUIET);
+ }
+ else
+ {
+ av_log_set_level(AV_LOG_INFO);
+ }
+}
+
extern void do_init_ffmpeg();
void do_init_ffmpeg()
{
static int isffmpeg (char *filename) {
AVFormatContext *pFormatCtx;
- int i, videoStream;
+ unsigned int i;
+ int videoStream;
AVCodec *pCodec;
AVCodecContext *pCodecCtx;
uiDefButS(block, NUM, redraw, "Cur:", 117+xoffs,95+yoffs,81,20, &coba->cur, 0.0, (float)(coba->tot-1), 0, 0, "Displays the active color from the colorband");
bt= uiDefBut(block, BUT, redraw, "Del", 199+xoffs,95+yoffs,37,20, 0, 0, 0, 0, 0, "Deletes the active position");
uiButSetFunc(bt, colorband_del_cb, coba, NULL);
- uiDefButS(block, ROW, redraw, "E", 236+xoffs,95+yoffs,16,20, &coba->ipotype, 5.0, 1.0, 0, 0, "Sets interpolation type 'Ease' (quadratic) ");
- uiDefButS(block, ROW, redraw, "C", 252+xoffs,95+yoffs,16,20, &coba->ipotype, 5.0, 3.0, 0, 0, "Sets interpolation type Cardinal");
- uiDefButS(block, ROW, redraw, "L", 268+xoffs,95+yoffs,16,20, &coba->ipotype, 5.0, 0.0, 0, 0, "Sets interpolation type Linear");
- uiDefButS(block, ROW, redraw, "S", 284+xoffs,95+yoffs,16,20, &coba->ipotype, 5.0, 2.0, 0, 0, "Sets interpolation type B-Spline");
+
+ uiDefButS(block, MENU, redraw, "Interpolation %t|Ease %x1|Cardinal %x3|Linear %x0|B-Spline %x2|Constant %x4",
+ 236+xoffs, 95+yoffs, 64, 20, &coba->ipotype, 0.0, 0.0, 0, 0, "Sets interpolation type");
uiDefBut(block, BUT_COLORBAND, redraw, "", xoffs,65+yoffs,300,30, coba, 0, 0, 0, 0, "");
uiButSetFunc(bt, colorband_add_cb, coba, NULL);
bt= uiDefBut(block, BUT, event, "Del", xs+8.0f*unit,butr->ymin+20.0f,2.0f*unit,20, NULL, 0, 0, 0, 0, "Deletes the active position");
uiButSetFunc(bt, colorband_del_cb, coba, NULL);
- uiDefButS(block, ROW, event, "E", xs+10.0f*unit,butr->ymin+20.0f,unit,20, &coba->ipotype, 5.0, 1.0, 0, 0, "Sets interpolation type 'Ease' (quadratic) ");
- uiDefButS(block, ROW, event, "C", xs+11.0f*unit,butr->ymin+20.0f,unit,20, &coba->ipotype, 5.0, 3.0, 0, 0, "Sets interpolation type Cardinal");
- uiDefButS(block, ROW, event, "L", xs+12.0f*unit,butr->ymin+20.0f,unit,20, &coba->ipotype, 5.0, 0.0, 0, 0, "Sets interpolation type Linear");
- uiDefButS(block, ROW, event, "S", xs+13.0f*unit,butr->ymin+20.0f,unit,20, &coba->ipotype, 5.0, 2.0, 0, 0, "Sets interpolation type B-Spline");
-
+
+ uiDefButS(block, MENU, event, "Interpolation %t|Ease %x1|Cardinal %x3|Linear %x0|B-Spline %x2|Constant %x4",
+ xs+10.0f*unit, butr->ymin+20.0f, unit*4, 20, &coba->ipotype, 0.0, 0.0, 0, 0, "Sets interpolation type");
+
uiDefBut(block, BUT_COLORBAND, event, "", xs,butr->ymin,butr->xmax-butr->xmin,20.0f, coba, 0, 0, 0, 0, "");
uiBlockEndAlign(block);
looking= 0;
for(efa= em->faces.first; efa; efa= efa->next) {
- if(efa->e4 && efa->f1==0) { /* not done quad */
+ if(efa->h==0 && efa->e4 && efa->f1==0) { /* not done quad */
if(efa->e1->f1<=2 && efa->e2->f1<=2 && efa->e3->f1<=2 && efa->e4->f1<=2) { /* valence ok */
/* if edge tagged, select opposing edge and mark face ok */
#include "reeb.h"
+
ReebGraph *GLOBAL_RG = NULL;
ReebGraph *FILTERED_RG = NULL;
BL_Texture * getTex (unsigned int idx) {
return (idx < MAXTEX) ? mTextures + idx : NULL;
}
+ Image * getImage (unsigned int idx) {
+ return (idx < MAXTEX && mMaterial) ? mMaterial->img[idx] : NULL;
+ }
// for ipos
void UpdateIPO(
}
// add result code
// length of result code
- const size_t rsltSize = 10;
+ const size_t rsltSize = 11;
// delimit description
const char delimRslt[] = ": ";
// set text of description
char rsltTxt[rsltSize];
std::ostrstream os(rsltTxt, rsltSize);
- os << std::hex << m_hRslt << delimRslt;
+ os << std::hex << m_hRslt << delimRslt << '\0';
// copy result to description
- m_desc.insert(0, rsltTxt, rsltSize);
+ m_desc.insert(0, rsltTxt);
// copy exception description to last exception string
m_lastError = m_desc;
}
#include "PyTypeList.h"
+#define VT_C(v,idx) ((unsigned char*)&v)[idx]
+#define VT_R(v) ((unsigned char*)&v)[0]
+#define VT_G(v) ((unsigned char*)&v)[1]
+#define VT_B(v) ((unsigned char*)&v)[2]
+#define VT_A(v) ((unsigned char*)&v)[3]
+#define VT_RGBA(v,r,g,b,a) VT_R(v)=(unsigned char)r, VT_G(v)=(unsigned char)g, VT_B(v)=(unsigned char)b, VT_A(v)=(unsigned char)a
// forward declaration
class FilterBase;
// attributes structure
static PyGetSetDef filterBSGetSets[] =
{
- {"color", (getter)getColor, (setter)setColor, "blue screen color", NULL},
- {"limits", (getter)getLimits, (setter)setLimits, "blue screen color limits", NULL},
+ {(char*)"color", (getter)getColor, (setter)setColor, (char*)"blue screen color", NULL},
+ {(char*)"limits", (getter)getLimits, (setter)setLimits, (char*)"blue screen color limits", NULL},
// attributes from FilterBase class
- {"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, "previous pixel filter", NULL},
+ {(char*)"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, (char*)"previous pixel filter", NULL},
{NULL}
};
short * size, unsigned int pixSize, unsigned int val)
{
// calculate differences
- int difRed = int((val >> 16) & 0xFF) - int(m_color[0]);
- int difGreen = int((val >> 8) & 0xFF) - int(m_color[1]);
- int difBlue = int(val & 0xFF) - int(m_color[2]);
+ int difRed = int(VT_R(val)) - int(m_color[0]);
+ int difGreen = int(VT_G(val)) - int(m_color[1]);
+ int difBlue = int(VT_B(val)) - int(m_color[2]);
// calc distance from "blue screen" color
unsigned int dist = (unsigned int)(difRed * difRed + difGreen * difGreen
+ difBlue * difBlue);
// condition for fully transparent color
if (m_squareLimits[0] >= dist)
// return color with zero alpha
- //return 0xFF000000;
- return val & 0x00FFFFFF;
+ VT_A(val) = 0;
// condition for fully opaque color
else if (m_squareLimits[1] <= dist)
// return normal colour
- return val | 0xFF000000;
+ VT_A(val) = 0xFF;
// otherwise calc alpha
else
- return (val & 0x00FFFFFF) | ((((dist - m_squareLimits[0]) << 8)
- / m_limitDist) << 24);
+ VT_A(val) = (((dist - m_squareLimits[0]) << 8) / m_limitDist);
+ return val;
}
/// virtual filtering function for byte source
// attributes structure
static PyGetSetDef filterGrayGetSets[] =
{ // attributes from FilterBase class
- {"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, "previous pixel filter", NULL},
+ {(char*)"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, (char*)"previous pixel filter", NULL},
{NULL}
};
// attributes structure
static PyGetSetDef filterColorGetSets[] =
{
- {"matrix", (getter)getMatrix, (setter)setMatrix, "matrix [4][5] for color calculation", NULL},
+ {(char*)"matrix", (getter)getMatrix, (setter)setMatrix, (char*)"matrix [4][5] for color calculation", NULL},
// attributes from FilterBase class
- {"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, "previous pixel filter", NULL},
+ {(char*)"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, (char*)"previous pixel filter", NULL},
{NULL}
};
for (int r = 0; r < 4; ++r)
{
levels[r][0] = 0;
- levels[r][1] = 0xFF << (r << 3);
+ levels[r][1] = 0xFF;
levels[r][2] = 0xFF;
}
}
for (int r = 0; r < 4; ++r)
{
for (int c = 0; c < 2; ++c)
- levels[r][c] = lev[r][c] << (r << 3);
+ levels[r][c] = lev[r][c];
levels[r][2] = lev[r][0] < lev[r][1] ? lev[r][1] - lev[r][0] : 1;
}
}
static PyObject * getLevels (PyFilter * self, void * closure)
{
ColorLevel & lev = getFilterLevel(self)->getLevels();
- return Py_BuildValue("((kk)(kk)(kk)(kk))",
- lev[0][0], lev[0][1], lev[1][0] >> 8, lev[1][1] >> 8,
- lev[2][0] >> 16, lev[2][1] >> 16, lev[3][0] >> 24, lev[3][1] >> 24);
+ return Py_BuildValue("((HH)(HH)(HH)(HH))",
+ lev[0][0], lev[0][1], lev[1][0], lev[1][1],
+ lev[2][0], lev[2][1], lev[3][0], lev[3][1]);
}
// set color levels
valid = PyInt_Check(PySequence_Fast_GET_ITEM(row, c));
// if it is valid, save it in matrix
if (valid)
- lev[r][c] = (unsigned long)(PyInt_AsLong(PySequence_Fast_GET_ITEM(row, c)));
+ lev[r][c] = (unsigned short)(PyInt_AsLong(PySequence_Fast_GET_ITEM(row, c)));
}
}
// if parameter is not valid, report error
// attributes structure
static PyGetSetDef filterLevelGetSets[] =
{
- {"levels", (getter)getLevels, (setter)setLevels, "levels matrix [4] (min, max)", NULL},
+ {(char*)"levels", (getter)getLevels, (setter)setLevels, (char*)"levels matrix [4] (min, max)", NULL},
// attributes from FilterBase class
- {"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, "previous pixel filter", NULL},
+ {(char*)"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, (char*)"previous pixel filter", NULL},
{NULL}
};
short * size, unsigned int pixSize, unsigned int val)
{
// calculate gray value
- unsigned int gray = (28 * ((val >> 16) & 0xFF) + 151 * ((val >> 8) & 0xFF)
- + 77 * (val & 0xFF)) & 0xFF00;
+ unsigned int gray = (28 * (VT_B(val)) + 151 * (VT_G(val))
+ + 77 * (VT_R(val))) >> 8;
// return gray scale value
- return (val & 0xFF000000) | gray << 8 | gray | gray >> 8;
+ VT_R(val) = gray;
+ VT_G(val) = gray;
+ VT_B(val) = gray;
+ return val;
}
/// virtual filtering function for byte source
ColorMatrix m_matrix;
/// calculate one color component
- unsigned int calcColor (unsigned int val, short idx)
+ unsigned char calcColor (unsigned int val, short idx)
{
- return (((m_matrix[idx][0] * (val & 0xFF) + m_matrix[idx][1] * ((val >> 8) & 0xFF)
- + m_matrix[idx][2] * ((val >> 16) & 0xFF) + m_matrix[idx][3] * ((val >> 24) & 0xFF)
- + m_matrix[idx][4]) >> 8) & 0xFF) << (idx << 3);
+ return (((m_matrix[idx][0] * (VT_R(val)) + m_matrix[idx][1] * (VT_G(val))
+ + m_matrix[idx][2] * (VT_B(val)) + m_matrix[idx][3] * (VT_A(val))
+ + m_matrix[idx][4]) >> 8) & 0xFF);
}
/// filter pixel template, source int buffer
short * size, unsigned int pixSize, unsigned int val)
{
// return calculated color
- return calcColor(val, 0) | calcColor(val, 1) | calcColor(val, 2)
- | calcColor(val, 3);
+ int color;
+ VT_RGBA(color, calcColor(val, 0), calcColor(val, 1), calcColor(val, 2), calcColor(val, 3));
+ return color;
}
/// virtual filtering function for byte source
/// type for color levels
-typedef unsigned long ColorLevel[4][3];
+typedef unsigned short ColorLevel[4][3];
/// pixel filter for color calculation
class FilterLevel : public FilterBase
/// calculate one color component
unsigned int calcColor (unsigned int val, short idx)
{
- unsigned int col = val & (0xFF << (idx << 3));
+ unsigned int col = VT_C(val,idx);;
if (col <= levels[idx][0]) col = 0;
- else if (col >= levels[idx][1]) col = 0xFF << (idx << 3);
- else if (idx < 3) col = (((col - levels[idx][0]) << 8) / levels[idx][2]) & (0xFF << (idx << 3));
- else col = (((col - levels[idx][0]) / levels[idx][2]) << 8) & (0xFF << (idx << 3));
+ else if (col >= levels[idx][1]) col = 0xFF;
+ else col = (((col - levels[idx][0]) << 8) / levels[idx][2]) & 0xFF;
return col;
}
short * size, unsigned int pixSize, unsigned int val)
{
// return calculated color
- return calcColor(val, 0) | calcColor(val, 1) | calcColor(val, 2)
- | calcColor(val, 3);
+ int color;
+ VT_RGBA(color, calcColor(val, 0), calcColor(val, 1), calcColor(val, 2), calcColor(val, 3));
+ return color;
}
/// virtual filtering function for byte source
// implementation FilterNormal
// constructor
-FilterNormal::FilterNormal (void) : m_colShift(0)
+FilterNormal::FilterNormal (void) : m_colIdx(0)
{
// set default depth
setDepth(4);
// check validity of index
if (colIdx < 3)
// set color shift
- m_colShift = colIdx << 3;
+ m_colIdx = colIdx;
}
// set depth
// attributes structure
static PyGetSetDef filterNormalGetSets[] =
{
- {"colorIdx", (getter)getColor, (setter)setColor, "index of color used to calculate normal (0 - red, 1 - green, 2 - blue)", NULL},
- {"depth", (getter)getDepth, (setter)setDepth, "depth of relief", NULL},
+ {(char*)"colorIdx", (getter)getColor, (setter)setColor, (char*)"index of color used to calculate normal (0 - red, 1 - green, 2 - blue)", NULL},
+ {(char*)"depth", (getter)getDepth, (setter)setDepth, (char*)"depth of relief", NULL},
// attributes from FilterBase class
- {"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, "previous pixel filter", NULL},
+ {(char*)"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, (char*)"previous pixel filter", NULL},
{NULL}
};
virtual ~FilterNormal (void) {}
/// get index of color used to calculate normals
- unsigned short getColor (void) { return m_colShift >> 3; }
+ unsigned short getColor (void) { return m_colIdx; }
/// set index of color used to calculate normals
void setColor (unsigned short colIdx);
/// scale to calculate normals
float m_depthScale;
- /// shift to used color component
- unsigned short m_colShift;
+ /// color index, 0=red, 1=green, 2=blue, 3=alpha
+ unsigned short m_colIdx;
/// filter pixel, source int buffer
template <class SRC> unsigned int tFilter (SRC * src, short x, short y,
short * size, unsigned int pixSize, unsigned int val = 0)
{
// get value of required color
- int actPix = int((val >> m_colShift) & 0xFF);
+ int actPix = int(VT_C(val,m_colIdx));
+ int upPix = actPix;
+ int leftPix = actPix;
// get upper and left pixel from actual pixel
- int upPix = y > 0 ? int((convertPrevious(src - pixSize * size[0], x, y - 1,
- size, pixSize) >> m_colShift) & 0xFF) : actPix;
- int leftPix = x > 0 ? int((convertPrevious(src - pixSize, x - 1, y, size, pixSize)
- >> m_colShift) & 0xFF) : actPix;
+ if (y > 0)
+ {
+ val = convertPrevious(src - pixSize * size[0], x, y - 1, size, pixSize);
+ upPix = VT_C(val,m_colIdx);
+ }
+ if (x > 0)
+ {
+ val = convertPrevious(src - pixSize, x - 1, y, size, pixSize);
+ leftPix = VT_C(val,m_colIdx);
+ }
// height differences (from blue color)
float dx = (actPix - leftPix) * m_depthScale;
float dy = (actPix - upPix) * m_depthScale;
dy = dy * dz + normScaleKoef;
dz += normScaleKoef;
// return normal vector converted to color
- return 0xFF000000 | int(dz) << 16 | int(dy) << 8 | int(dx);
+ VT_RGBA(val, dx, dy, dz, 0xFF);
+ return val;
}
/// filter pixel, source byte buffer
Filter_allocNew, /* tp_new */
};
+// FilterRGBA32
+
+// define python type
+PyTypeObject FilterRGBA32Type =
+{
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "VideoTexture.FilterRGBA32", /*tp_name*/
+ sizeof(PyFilter), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)Filter_dealloc,/*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "Source filter RGBA32 objects", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ NULL, /* tp_methods */
+ 0, /* tp_members */
+ NULL, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)Filter_init<FilterRGBA32>, /* tp_init */
+ 0, /* tp_alloc */
+ Filter_allocNew, /* tp_new */
+};
+
// FilterBGR24
// define python type
/// filter pixel, source byte buffer
virtual unsigned int filter (unsigned char * src, short x, short y,
short * size, unsigned int pixSize, unsigned int val)
- { return 0xFF000000 | src[0] << 16 | src[1] << 8 | src[2]; }
+ { VT_RGBA(val,src[0],src[1],src[2],0xFF); return val; }
+};
+
+/// class for RGBA32 conversion
+class FilterRGBA32 : public FilterBase
+{
+public:
+ /// constructor
+ FilterRGBA32 (void) {}
+ /// destructor
+ virtual ~FilterRGBA32 (void) {}
+
+ /// get source pixel size
+ virtual unsigned int getPixelSize (void) { return 4; }
+
+protected:
+ /// filter pixel, source byte buffer
+ virtual unsigned int filter (unsigned char * src, short x, short y,
+ short * size, unsigned int pixSize, unsigned int val)
+ {
+ if ((intptr_t(src)&0x3) == 0)
+ return *(unsigned int*)src;
+ else
+ {
+ VT_RGBA(val,src[0],src[1],src[2],src[3]);
+ return val;
+ }
+ }
};
/// class for BGR24 conversion
/// filter pixel, source byte buffer
virtual unsigned int filter (unsigned char * src, short x, short y,
short * size, unsigned int pixSize, unsigned int val)
- { return 0xFF000000 | src[2] << 16 | src[1] << 8 | src[0]; }
+ { VT_RGBA(val,src[2],src[1],src[0],0xFF); return val; }
};
/// class for YV12 conversion
int red = (298 * c + 409 * e + 128) >> 8;
if (red >= 0x100) red = 0xFF;
else if (red < 0) red = 0;
- int green = 298 * c - 100 * d - 208 * e;
- if (green > 0x10000) green = 0xFF00;
+ int green = (298 * c - 100 * d - 208 * e) >> 8;
+ if (green >= 0x100) green = 0xFF;
else if (green < 0) green = 0;
- int blue = (298 * c + 516 * d + 128) << 8;
- if (blue > 0x1000000) blue = 0xFF0000;
+ int blue = (298 * c + 516 * d + 128) >> 8;
+ if (blue >= 0x100) blue = 0xFF;
else if (blue < 0) blue = 0;
// return result
- return 0xFF000000 | blue & 0xFF0000 | green & 0xFF00
- | red & 0xFF;
+ VT_RGBA(val, red, green, blue, 0xFF);
+ return val;
}
};
// default filter
-FilterBGR24 defFilter;
+FilterRGB24 defFilter;
// load image from buffer
// attributes structure
static PyGetSetDef imageBuffGetSets[] =
{ // attributes from ImageBase class
- {"image", (getter)Image_getImage, NULL, "image data", NULL},
- {"size", (getter)Image_getSize, NULL, "image size", NULL},
- {"scale", (getter)Image_getScale, (setter)Image_setScale, "fast scale of image (near neighbour)", NULL},
- {"flip", (getter)Image_getFlip, (setter)Image_setFlip, "flip image vertically", NULL},
- {"filter", (getter)Image_getFilter, (setter)Image_setFilter, "pixel filter", NULL},
+ {(char*)"image", (getter)Image_getImage, NULL, (char*)"image data", NULL},
+ {(char*)"size", (getter)Image_getSize, NULL, (char*)"image size", NULL},
+ {(char*)"scale", (getter)Image_getScale, (setter)Image_setScale, (char*)"fast scale of image (near neighbour)", NULL},
+ {(char*)"flip", (getter)Image_getFlip, (setter)Image_setFlip, (char*)"flip image vertically", NULL},
+ {(char*)"filter", (getter)Image_getFilter, (setter)Image_setFilter, (char*)"pixel filter", NULL},
{NULL}
};
// attributes structure
static PyGetSetDef imageMixGetSets[] =
{ // attributes from ImageBase class
- {"image", (getter)Image_getImage, NULL, "image data", NULL},
- {"size", (getter)Image_getSize, NULL, "image size", NULL},
- {"scale", (getter)Image_getScale, (setter)Image_setScale, "fast scale of image (near neighbour)", NULL},
- {"flip", (getter)Image_getFlip, (setter)Image_setFlip, "flip image vertically", NULL},
- {"filter", (getter)Image_getFilter, (setter)Image_setFilter, "pixel filter", NULL},
+ {(char*)"image", (getter)Image_getImage, NULL, (char*)"image data", NULL},
+ {(char*)"size", (getter)Image_getSize, NULL, (char*)"image size", NULL},
+ {(char*)"scale", (getter)Image_getScale, (setter)Image_setScale, (char*)"fast scale of image (near neighbour)", NULL},
+ {(char*)"flip", (getter)Image_getFlip, (setter)Image_setFlip, (char*)"flip image vertically", NULL},
+ {(char*)"filter", (getter)Image_getFilter, (setter)Image_setFilter, (char*)"pixel filter", NULL},
{NULL}
};
// attributes structure
static PyGetSetDef imageRenderGetSets[] =
{
- {"background", (getter)getBackground, (setter)setBackground, "background color", NULL},
+ {(char*)"background", (getter)getBackground, (setter)setBackground, (char*)"background color", NULL},
// attributes from ImageBase class
- {"image", (getter)Image_getImage, NULL, "image data", NULL},
- {"size", (getter)Image_getSize, NULL, "image size", NULL},
- {"scale", (getter)Image_getScale, (setter)Image_setScale, "fast scale of image (near neighbour)", NULL},
- {"flip", (getter)Image_getFlip, (setter)Image_setFlip, "flip image vertically", NULL},
- {"filter", (getter)Image_getFilter, (setter)Image_setFilter, "pixel filter", NULL},
+ {(char*)"image", (getter)Image_getImage, NULL, (char*)"image data", NULL},
+ {(char*)"size", (getter)Image_getSize, NULL, (char*)"image size", NULL},
+ {(char*)"scale", (getter)Image_getScale, (setter)Image_setScale, (char*)"fast scale of image (near neighbour)", NULL},
+ {(char*)"flip", (getter)Image_getFlip, (setter)Image_setFlip, (char*)"flip image vertically", NULL},
+ {(char*)"filter", (getter)Image_getFilter, (setter)Image_setFilter, (char*)"pixel filter", NULL},
{NULL}
};
glReadPixels(m_upLeft[0], m_upLeft[1], (GLsizei)m_capSize[0], (GLsizei)m_capSize[1], GL_RGB,
GL_UNSIGNED_BYTE, m_viewportImage);
// filter loaded data
- FilterBGR24 filt;
+ FilterRGB24 filt;
filterImage(filt, m_viewportImage, m_capSize);
}
}
// attributes structure
static PyGetSetDef imageViewportGetSets[] =
{
- {"whole", (getter)ImageViewport_getWhole, (setter)ImageViewport_setWhole, "use whole viewport to capture", NULL},
- {"position", (getter)ImageViewport_getPosition, (setter)ImageViewport_setPosition, "upper left corner of captured area", NULL},
- {"capsize", (getter)ImageViewport_getCaptureSize, (setter)ImageViewport_setCaptureSize, "size of viewport area being captured", NULL},
+ {(char*)"whole", (getter)ImageViewport_getWhole, (setter)ImageViewport_setWhole, (char*)"use whole viewport to capture", NULL},
+ {(char*)"position", (getter)ImageViewport_getPosition, (setter)ImageViewport_setPosition, (char*)"upper left corner of captured area", NULL},
+ {(char*)"capsize", (getter)ImageViewport_getCaptureSize, (setter)ImageViewport_setCaptureSize, (char*)"size of viewport area being captured", NULL},
// attributes from ImageBase class
- {"image", (getter)Image_getImage, NULL, "image data", NULL},
- {"size", (getter)Image_getSize, NULL, "image size", NULL},
- {"scale", (getter)Image_getScale, (setter)Image_setScale, "fast scale of image (near neighbour)", NULL},
- {"flip", (getter)Image_getFlip, (setter)Image_setFlip, "flip image vertically", NULL},
- {"filter", (getter)Image_getFilter, (setter)Image_setFilter, "pixel filter", NULL},
+ {(char*)"image", (getter)Image_getImage, NULL, (char*)"image data", NULL},
+ {(char*)"size", (getter)Image_getSize, NULL, (char*)"image size", NULL},
+ {(char*)"scale", (getter)Image_getScale, (setter)Image_setScale, (char*)"fast scale of image (near neighbour)", NULL},
+ {(char*)"flip", (getter)Image_getFlip, (setter)Image_setFlip, (char*)"flip image vertically", NULL},
+ {(char*)"filter", (getter)Image_getFilter, (setter)Image_setFilter, (char*)"pixel filter", NULL},
{NULL}
};
// increase ref count
Py_INCREF((*it)->getType());
// add type to module
- PyModule_AddObject(module, (*it)->getName(), (PyObject*)(*it)->getType());
+ PyModule_AddObject(module, (char*)(*it)->getName(), (PyObject*)(*it)->getType());
}
}
{ exp.report(); }
-// are Blender materials used
-bool blendMats = false;
-
// Blender GameObject type
BlendType<KX_GameObject> gameObjectType ("KX_GameObject");
if (mat != NULL)
{
// is it blender material or polygon material
- blendMats = (mat->GetFlag() & RAS_BLENDERMAT) != 0;
- if (blendMats)
+ if (mat->GetFlag() & RAS_BLENDERGLSL)
+ {
+ self->m_imgTexture = static_cast<KX_BlenderMaterial*>(mat)->getImage(texID);
+ self->m_useMatTexture = false;
+ } else if (mat->GetFlag() & RAS_BLENDERMAT)
+ {
// get blender material texture
self->m_matTexture = static_cast<KX_BlenderMaterial*>(mat)->getTex(texID);
+ self->m_useMatTexture = true;
+ }
else
{
// get texture pointer from polygon material
MTFace * tface = static_cast<KX_PolygonMaterial*>(mat)->GetMTFace();
self->m_imgTexture = (Image*)tface->tpage;
+ self->m_useMatTexture = false;
}
}
// check if texture is available, if not, initialization failed
{
self->m_orgSaved = false;
// restore original texture code
- if (blendMats)
+ if (self->m_useMatTexture)
self->m_matTexture->swapTexture(self->m_orgTex);
else
self->m_imgTexture->bindcode = self->m_orgTex;
{
self->m_orgSaved = true;
// save original image code
- if (blendMats)
+ if (self->m_useMatTexture)
self->m_orgTex = self->m_matTexture->swapTexture(self->m_actTex);
else
{
// class Texture attributes
static PyGetSetDef textureGetSets[] =
{
- {"source", (getter)Texture_getSource, (setter)Texture_setSource, "source of texture", NULL},
- {"mipmap", (getter)Texture_getMipmap, (setter)Texture_setMipmap, "mipmap texture", NULL},
+ {(char*)"source", (getter)Texture_getSource, (setter)Texture_setSource, (char*)"source of texture", NULL},
+ {(char*)"mipmap", (getter)Texture_getMipmap, (setter)Texture_setMipmap, (char*)"mipmap texture", NULL},
{NULL}
};
{
PyObject_HEAD
+ // texture is using blender material
+ bool m_useMatTexture;
+
// video texture bind code
unsigned int m_actTex;
-
// original texture bind code
unsigned int m_orgTex;
// original texture saved
// Texture type description
extern PyTypeObject TextureType;
-// usage of Blender materials
-extern bool blendMats;
-
// load texture
void loadTexture (unsigned int texId, unsigned int * texture, short * size,
bool mipmap = false);
-----------------------------------------------------------------------------
*/
+// INT64_C fix for some linux machines (C99ism)
+#define __STDC_CONSTANT_MACROS
+#include <stdint.h>
+
+
#include "MEM_guardedalloc.h"
#include "PIL_time.h"
// constructor
VideoFFmpeg::VideoFFmpeg (HRESULT * hRslt) : VideoBase(),
m_codec(NULL), m_formatCtx(NULL), m_codecCtx(NULL),
-m_frame(NULL), m_frameDeinterlaced(NULL), m_frameBGR(NULL), m_imgConvertCtx(NULL),
+m_frame(NULL), m_frameDeinterlaced(NULL), m_frameRGB(NULL), m_imgConvertCtx(NULL),
m_deinterlace(false), m_preseek(0), m_videoStream(-1), m_baseFrameRate(25.0),
m_lastFrame(-1), m_curPosition(-1), m_startTime(0),
-m_captWidth(0), m_captHeight(0), m_captRate(0.f)
+m_captWidth(0), m_captHeight(0), m_captRate(0.f), m_isImage(false)
{
// set video format
m_format = RGB24;
if (m_codecCtx)
{
avcodec_close(m_codecCtx);
+ m_codecCtx = NULL;
}
if (m_formatCtx)
{
av_close_input_file(m_formatCtx);
+ m_formatCtx = NULL;
}
if (m_frame)
{
av_free(m_frame);
+ m_frame = NULL;
}
if (m_frameDeinterlaced)
{
MEM_freeN(m_frameDeinterlaced->data[0]);
av_free(m_frameDeinterlaced);
+ m_frameDeinterlaced = NULL;
}
- if (m_frameBGR)
+ if (m_frameRGB)
{
- MEM_freeN(m_frameBGR->data[0]);
- av_free(m_frameBGR);
+ MEM_freeN(m_frameRGB->data[0]);
+ av_free(m_frameRGB);
+ m_frameRGB = NULL;
}
if (m_imgConvertCtx)
{
sws_freeContext(m_imgConvertCtx);
+ m_imgConvertCtx = NULL;
}
-
m_codec = NULL;
- m_codecCtx = NULL;
- m_formatCtx = NULL;
- m_frame = NULL;
- m_frame = NULL;
- m_frameBGR = NULL;
- m_imgConvertCtx = NULL;
-
- // object will be deleted after that
+ m_status = SourceStopped;
return true;
}
// set initial parameters
-void VideoFFmpeg::initParams (short width, short height, float rate)
+void VideoFFmpeg::initParams (short width, short height, float rate, bool image)
{
m_captWidth = width;
m_captHeight = height;
m_captRate = rate;
+ m_isImage = image;
}
int VideoFFmpeg::openStream(const char *filename, AVInputFormat *inputFormat, AVFormatParameters *formatParams)
m_videoStream = videoStream;
m_frame = avcodec_alloc_frame();
m_frameDeinterlaced = avcodec_alloc_frame();
- m_frameBGR = avcodec_alloc_frame();
+ m_frameRGB = avcodec_alloc_frame();
// allocate buffer if deinterlacing is required
m_codecCtx->pix_fmt, m_codecCtx->width, m_codecCtx->height);
// allocate buffer to store final decoded frame
- avpicture_fill((AVPicture*)m_frameBGR,
+ avpicture_fill((AVPicture*)m_frameRGB,
(uint8_t*)MEM_callocN(avpicture_get_size(
- PIX_FMT_BGR24,
+ PIX_FMT_RGB24,
m_codecCtx->width, m_codecCtx->height),
- "ffmpeg bgr"),
- PIX_FMT_BGR24, m_codecCtx->width, m_codecCtx->height);
+ "ffmpeg rgb"),
+ PIX_FMT_RGB24, m_codecCtx->width, m_codecCtx->height);
// allocate sws context
m_imgConvertCtx = sws_getContext(
m_codecCtx->width,
m_codecCtx->pix_fmt,
m_codecCtx->width,
m_codecCtx->height,
- PIX_FMT_BGR24,
+ PIX_FMT_RGB24,
SWS_FAST_BILINEAR,
NULL, NULL, NULL);
av_free(m_frame);
MEM_freeN(m_frameDeinterlaced->data[0]);
av_free(m_frameDeinterlaced);
- MEM_freeN(m_frameBGR->data[0]);
- av_free(m_frameBGR);
+ MEM_freeN(m_frameRGB->data[0]);
+ av_free(m_frameRGB);
return -1;
}
return 0;
if (
#ifdef FFMPEG_PB_IS_POINTER
- m_formatCtx->pb->is_streamed
+ m_formatCtx->pb && m_formatCtx->pb->is_streamed
#else
m_formatCtx->pb.is_streamed
#endif
// for streaming it is important to do non blocking read
m_formatCtx->flags |= AVFMT_FLAG_NONBLOCK;
}
+
+ if (m_isImage)
+ {
+ // the file is to be treated as an image, i.e. load the first frame only
+ m_isFile = false;
+ // in case of reload, the filename is taken from m_imageName, no need to change it
+ if (m_imageName.Ptr() != filename)
+ m_imageName = filename;
+ m_preseek = 0;
+ play();
+ }
+
}
VideoBase::openCam(file, camIdx);
}
-
// play video
bool VideoFFmpeg::play (void)
{
init(short(m_codecCtx->width), short(m_codecCtx->height));
// process image
process((BYTE*)(frame->data[0]));
+ // in case it is an image, automatically stop reading it
+ if (m_isImage)
+ {
+ m_status = SourceStopped;
+ // close the file as we don't need it anymore
+ release();
+ }
}
}
}
input = m_frameDeinterlaced;
}
}
- // convert to BGR24
+ // convert to RGB24
sws_scale(m_imgConvertCtx,
input->data,
input->linesize,
0,
m_codecCtx->height,
- m_frameBGR->data,
- m_frameBGR->linesize);
+ m_frameRGB->data,
+ m_frameRGB->linesize);
av_free_packet(&packet);
frameLoaded = true;
break;
// attributes structure
static PyGetSetDef videoGetSets[] =
{ // methods from VideoBase class
- {"status", (getter)Video_getStatus, NULL, "video status", NULL},
- {"range", (getter)Video_getRange, (setter)Video_setRange, "replay range", NULL},
- {"repeat", (getter)Video_getRepeat, (setter)Video_setRepeat, "repeat count, -1 for infinite repeat", NULL},
- {"framerate", (getter)Video_getFrameRate, (setter)Video_setFrameRate, "frame rate", NULL},
+ {(char*)"status", (getter)Video_getStatus, NULL, (char*)"video status", NULL},
+ {(char*)"range", (getter)Video_getRange, (setter)Video_setRange, (char*)"replay range", NULL},
+ {(char*)"repeat", (getter)Video_getRepeat, (setter)Video_setRepeat, (char*)"repeat count, -1 for infinite repeat", NULL},
+ {(char*)"framerate", (getter)Video_getFrameRate, (setter)Video_setFrameRate, (char*)"frame rate", NULL},
// attributes from ImageBase class
- {"image", (getter)Image_getImage, NULL, "image data", NULL},
- {"size", (getter)Image_getSize, NULL, "image size", NULL},
- {"scale", (getter)Image_getScale, (setter)Image_setScale, "fast scale of image (near neighbour)", NULL},
- {"flip", (getter)Image_getFlip, (setter)Image_setFlip, "flip image vertically", NULL},
- {"filter", (getter)Image_getFilter, (setter)Image_setFilter, "pixel filter", NULL},
- {"preseek", (getter)VideoFFmpeg_getPreseek, (setter)VideoFFmpeg_setPreseek, "nb of frames of preseek", NULL},
- {"deinterlace", (getter)VideoFFmpeg_getDeinterlace, (setter)VideoFFmpeg_setDeinterlace, "deinterlace image", NULL},
+ {(char*)"image", (getter)Image_getImage, NULL, (char*)"image data", NULL},
+ {(char*)"size", (getter)Image_getSize, NULL, (char*)"image size", NULL},
+ {(char*)"scale", (getter)Image_getScale, (setter)Image_setScale, (char*)"fast scale of image (near neighbour)", NULL},
+ {(char*)"flip", (getter)Image_getFlip, (setter)Image_setFlip, (char*)"flip image vertically", NULL},
+ {(char*)"filter", (getter)Image_getFilter, (setter)Image_setFilter, (char*)"pixel filter", NULL},
+ {(char*)"preseek", (getter)VideoFFmpeg_getPreseek, (setter)VideoFFmpeg_setPreseek, (char*)"nb of frames of preseek", NULL},
+ {(char*)"deinterlace", (getter)VideoFFmpeg_getDeinterlace, (setter)VideoFFmpeg_setDeinterlace, (char*)"deinterlace image", NULL},
{NULL}
};
Image_allocNew, /* tp_new */
};
+// object initialization
+static int ImageFFmpeg_init (PyObject * pySelf, PyObject * args, PyObject * kwds)
+{
+ PyImage * self = reinterpret_cast<PyImage*>(pySelf);
+ // parameters - video source
+ // file name or format type for capture (only for Linux: video4linux or dv1394)
+ char * file = NULL;
+
+ // get parameters
+ if (!PyArg_ParseTuple(args, "s", &file))
+ return -1;
+
+ try
+ {
+ // create video object
+ Video_init<VideoFFmpeg>(self);
+
+ getVideoFFmpeg(self)->initParams(0, 0, 1.0, true);
+
+ // open video source
+ Video_open(getVideo(self), file, -1);
+ }
+ catch (Exception & exp)
+ {
+ exp.report();
+ return -1;
+ }
+ // initialization succeded
+ return 0;
+}
+
+PyObject * Image_reload (PyImage * self, PyObject *args)
+{
+ char * newname = NULL;
+
+ if (self->m_image != NULL && PyArg_ParseTuple(args, "|s", &newname))
+ {
+ VideoFFmpeg* video = getFFmpeg(self);
+ // check type of object
+ if (!newname)
+ newname = video->getImageName();
+ if (!newname) {
+ // if not set, retport error
+ PyErr_SetString(PyExc_RuntimeError, "No image file name given");
+ return NULL;
+ }
+ // make sure the previous file is cleared
+ video->release();
+ // open the new file
+ video->openFile(newname);
+ }
+ Py_RETURN_NONE;
+}
+
+// methods structure
+static PyMethodDef imageMethods[] =
+{ // methods from VideoBase class
+ {"refresh", (PyCFunction)Video_refresh, METH_NOARGS, "Refresh image, i.e. load it"},
+ {"reload", (PyCFunction)Image_reload, METH_VARARGS, "Reload image, i.e. reopen it"},
+ {NULL}
+};
+// attributes structure
+static PyGetSetDef imageGetSets[] =
+{ // methods from VideoBase class
+ {(char*)"status", (getter)Video_getStatus, NULL, (char*)"video status", NULL},
+ // attributes from ImageBase class
+ {(char*)"image", (getter)Image_getImage, NULL, (char*)"image data", NULL},
+ {(char*)"size", (getter)Image_getSize, NULL, (char*)"image size", NULL},
+ {(char*)"scale", (getter)Image_getScale, (setter)Image_setScale, (char*)"fast scale of image (near neighbour)", NULL},
+ {(char*)"flip", (getter)Image_getFlip, (setter)Image_setFlip, (char*)"flip image vertically", NULL},
+ {(char*)"filter", (getter)Image_getFilter, (setter)Image_setFilter, (char*)"pixel filter", NULL},
+ {NULL}
+};
+// python type declaration
+PyTypeObject ImageFFmpegType =
+{
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "VideoTexture.ImageFFmpeg", /*tp_name*/
+ sizeof(PyImage), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)Image_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "FFmpeg image source", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ imageMethods, /* tp_methods */
+ 0, /* tp_members */
+ imageGetSets, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)ImageFFmpeg_init, /* tp_init */
+ 0, /* tp_alloc */
+ Image_allocNew, /* tp_new */
+};
#endif //WITH_FFMPEG
virtual ~VideoFFmpeg ();
/// set initial parameters
- void initParams (short width, short height, float rate);
- /// open video file
+ void initParams (short width, short height, float rate, bool image=false);
+ /// open video/image file
virtual void openFile (char * file);
/// open video capture device
virtual void openCam (char * driver, short camIdx);
void setPreseek(int preseek) { if (preseek >= 0) m_preseek = preseek; }
bool getDeinterlace(void) { return m_deinterlace; }
void setDeinterlace(bool deinterlace) { m_deinterlace = deinterlace; }
+ char *getImageName(void) { return (m_isImage) ? m_imageName.Ptr() : NULL; }
protected:
// deinterlaced frame if codec requires it
AVFrame *m_frameDeinterlaced;
// decoded RGB24 frame if codec requires it
- AVFrame *m_frameBGR;
+ AVFrame *m_frameRGB;
// conversion from raw to RGB is done with sws_scale
struct SwsContext *m_imgConvertCtx;
// should the codec be deinterlaced?
/// frame rate of capture in frames per seconds
float m_captRate;
+ /// is file an image?
+ bool m_isImage;
+
+ /// keep last image name
+ STR_String m_imageName;
+
/// image calculation
virtual void calcImage (unsigned int texId);
bool grabFrame(long frame);
/// return the frame in RGB24 format, the image data is found in AVFrame.data[0]
- AVFrame* getFrame(void) { return m_frameBGR; }
+ AVFrame* getFrame(void) { return m_frameRGB; }
};
inline VideoFFmpeg * getFFmpeg (PyImage * self)
#if WITH_FFMPEG
extern PyTypeObject VideoFFmpegType;
+extern PyTypeObject ImageFFmpegType;
#endif
extern PyTypeObject FilterBlueScreenType;
extern PyTypeObject FilterGrayType;
extern PyTypeObject FilterLevelType;
extern PyTypeObject FilterNormalType;
extern PyTypeObject FilterRGB24Type;
+extern PyTypeObject FilterRGBA32Type;
extern PyTypeObject FilterBGR24Type;
extern PyTypeObject ImageBuffType;
extern PyTypeObject ImageMixType;
{
#if WITH_FFMPEG
pyImageTypes.add(&VideoFFmpegType, "VideoFFmpeg");
+ pyImageTypes.add(&ImageFFmpegType, "ImageFFmpeg");
#endif
pyImageTypes.add(&ImageBuffType, "ImageBuff");
pyImageTypes.add(&ImageMixType, "ImageMix");
pyFilterTypes.add(&FilterLevelType, "FilterLevel");
pyFilterTypes.add(&FilterNormalType, "FilterNormal");
pyFilterTypes.add(&FilterRGB24Type, "FilterRGB24");
+ pyFilterTypes.add(&FilterRGBA32Type, "FilterRGBA32");
pyFilterTypes.add(&FilterBGR24Type, "FilterBGR24");
}
pyFilterTypes.reg(m);
Py_INCREF(&TextureType);
- PyModule_AddObject(m, "Texture", (PyObject*)&TextureType);
+ PyModule_AddObject(m, (char*)"Texture", (PyObject*)&TextureType);
// init last error description
Exception::m_lastError[0] = '\0';
lenv.Append(CPPDEFINES=['GAMEBLENDER=1'])
if lenv['WITH_BF_BULLET']:
lenv.Append(CPPDEFINES=['WITH_BULLET=1'])
- # debug or not
- # CXXFLAGS defaults to CCFLAGS, therefore
- # we Replace() rather than Append() to CXXFLAGS the first time
- #lenv.Replace(CXXFLAGS = lenv['CCFLAGS'])
if lenv['BF_DEBUG'] or (libname in quickdebug):
- lenv.Append(CFLAGS = Split(lenv['BF_DEBUG_CFLAGS']))
- lenv.Append(CCFLAGS = Split(lenv['BF_DEBUG_CCFLAGS']))
- lenv.Append(CXXFLAGS = Split(lenv['BF_DEBUG_CXXFLAGS']))
+ lenv.Append(CFLAGS = lenv['BF_DEBUG_CFLAGS'])
+ lenv.Append(CCFLAGS = lenv['BF_DEBUG_CCFLAGS'])
+ lenv.Append(CXXFLAGS = lenv['BF_DEBUG_CXXFLAGS'])
else:
lenv.Append(CFLAGS = lenv['REL_CFLAGS'])
lenv.Append(CCFLAGS = lenv['REL_CCFLAGS'])