:: Re: [Frei0r] [frei0r-devel] [PATCH]…
Página Principal
Delete this message
Reply to this message
Autor: Dan Dennedy
Data:  
Para: Minimalistic plugin API for video effects
Tópicos Novos: Re: [Frei0r] [frei0r-devel] [PATCH] Building Frei0r on MSVC
Assunto: Re: [Frei0r] [frei0r-devel] [PATCH] Building Frei0r on MSVC
Wrong mailing list.

On Sat, Dec 14, 2013 at 3:07 PM, Andrius da Costa Ribas
<andriusmao@???> wrote:
> Hello,
>
> I'm new to this mailing list. I'm trying to build Kdenlive, and as Frei0r is
> one of its dependencies, I've tried to build it too, however I needed some
> adjustments to make it work with MSVC. Would you please review the attached
> patch and commit if it is okay?


I don't have a problem with the allocation casts.

I am not happy with the asm for the rounding functions. I do not know
if they are equivalent enough. What happens when there is a bug report
about them? Do the reporters and reporters have to figure out what the
asm does? Are they based on code from another project that can give us
more confidence about them?

Perhaps any supplemental math functions and constants (M_PI) belong in
frei0r_math.h or include/msvc/frei0r_math.h and not sprinkled
throughout the code.

Regarding M_PI, I see in partik0l.cpp:

#if defined(_MSC_VER)
#define _USE_MATH_DEFINES
#endif /* _MSC_VER */

In some functions (for ex, dither.c:f0r_update()) you changed arrays
on the stack to the heap, but the mem is not freed. Please look for
those and fix them.

> Cheers,
> Andrius.
>
> _______________________________________________
> frei0r-devel mailing list
> frei0r-devel@???
> http://piksel.no/cgi-bin/mailman/listinfo/frei0r-devel
>


--
+-DRD-+
diff --git a/src/filter/alpha0ps/alpha0ps.c b/src/filter/alpha0ps/alpha0ps.c
index cda5535..a690389 100755
--- a/src/filter/alpha0ps/alpha0ps.c
+++ b/src/filter/alpha0ps/alpha0ps.c
@@ -38,6 +38,7 @@ Copyright (C) 2010  Marko Cebokli    http://lea.hamradio.si/~s57uuu
 #include <stdlib.h>
 #include <math.h>
 #include <assert.h>
+#include <float.h> // FLT_MAX



 #include "fibe_f.h"
@@ -388,7 +389,7 @@ int i,j,m;
 if ((x<xt[0])||(x>xt[t-1]))
     {
 //    printf("\n\n x=%f je izven mej tabele!",x);
-    return 1.0/0.0;
+    return FLT_MAX;
     }


//poisce, katere tocke bo uporabil
@@ -492,7 +493,7 @@ f0r_instance_t f0r_construct(unsigned int width, unsigned int height)
{
inst *in;

-in=calloc(1,sizeof(inst));
+in= (inst *) calloc(1,sizeof(inst));
in->w=width;
in->h=height;

diff --git a/src/filter/alpha0ps/alphagrad.c b/src/filter/alpha0ps/alphagrad.c
index 160f479..55dbab0 100755
--- a/src/filter/alpha0ps/alphagrad.c
+++ b/src/filter/alpha0ps/alphagrad.c
@@ -174,7 +174,7 @@ f0r_instance_t f0r_construct(unsigned int width, unsigned int height)
{
inst *in;

-in=calloc(1,sizeof(inst));
+in= (inst *) calloc(1,sizeof(inst));
in->w=width;
in->h=height;

diff --git a/src/filter/alpha0ps/alphaspot.c b/src/filter/alpha0ps/alphaspot.c
index c26ebd5..c475269 100755
--- a/src/filter/alpha0ps/alphaspot.c
+++ b/src/filter/alpha0ps/alphaspot.c
@@ -340,7 +340,7 @@ f0r_instance_t f0r_construct(unsigned int width, unsigned int height)
{
inst *in;

-in=calloc(1,sizeof(inst));
+in= (inst *) calloc(1,sizeof(inst));
in->w=width;
in->h=height;

diff --git a/src/filter/blur/IIRblur.c b/src/filter/blur/IIRblur.c
index a119ad3..8e480c0 100755
--- a/src/filter/blur/IIRblur.c
+++ b/src/filter/blur/IIRblur.c
@@ -35,6 +35,7 @@ Copyright (C) 2011  Marko Cebokli    http://lea.hamradio.si/~s57uuu
 #include <math.h>
 #include <assert.h>
 #include <inttypes.h>
+#include <float.h>


double PI=3.14159265358979;

@@ -83,7 +84,7 @@ int i,j,m;
 if ((x<xt[0])||(x>xt[t-1]))
     {
 //    printf("\n\n x=%f je izven mej tabele!",x);
-    return 1.0/0.0;
+    return FLT_MAX;
     }


//poisce, katere tocke bo uporabil
@@ -197,11 +198,11 @@ f0r_instance_t f0r_construct(unsigned int width, unsigned int height)
{
inst *in;

-in=calloc(1,sizeof(inst));
+in= (inst *) calloc(1,sizeof(inst));
in->w=width;
in->h=height;

-in->img=calloc(width*height*4,sizeof(float));
+in->img= (float_rgba *) calloc(width*height*4,sizeof(float));

in->am=map_value_forward_log(0.2, 0.5, 100.0);
in->a1=-0.796093; in->a2=0.186308;
diff --git a/src/filter/colgate/colgate.c b/src/filter/colgate/colgate.c
index 4414d4d..455e804 100644
--- a/src/filter/colgate/colgate.c
+++ b/src/filter/colgate/colgate.c
@@ -90,6 +90,13 @@
#include "frei0r.h"
#include "frei0r_math.h"

+#ifdef _MSC_VER
+int __inline lrintf(const float x)
+{
+  __asm cvtss2si eax, x
+}
+#endif
+
 enum ParamIndex {
     NEUTRAL_COLOR,
     COLOR_TEMPERATURE,
diff --git a/src/filter/coloradj/coloradj_RGB.c b/src/filter/coloradj/coloradj_RGB.c
index e043518..5e5e5f1 100755
--- a/src/filter/coloradj/coloradj_RGB.c
+++ b/src/filter/coloradj/coloradj_RGB.c
@@ -34,6 +34,16 @@ Copyright (C) 2010  Marko Cebokli    http://lea.hamradio.si/~s57uuu


#include <frei0r.h>

+#ifdef _MSC_VER
+float __inline rintf( float x )
+{
+    __asm {
+        fld x
+        frndint
+    }
+}
+#endif
+
 //------------------------------------------------------
 //computes x to the power p
 //only for positive x
@@ -368,7 +378,7 @@ f0r_instance_t f0r_construct(unsigned int width, unsigned int height)
 {
 inst *in;


-in=calloc(1,sizeof(inst));
+in= (inst *) calloc(1,sizeof(inst));
 in->w=width;
 in->h=height;
 in->r = 0.5;
diff --git a/src/filter/colortap/colortap.c b/src/filter/colortap/colortap.c
index 41e70d1..9d0e32b 100644
--- a/src/filter/colortap/colortap.c
+++ b/src/filter/colortap/colortap.c
@@ -38,7 +38,7 @@
  *  - save as "C source"
  *  - the array in the saved file is the lookup table
  */
-static const uint8_t sepia_table[768] =
+static const uint8_t sepia_table[769] =
     "\0\0\0\0\0\0\0\0\0\0\1\0\1\1\0\1\1\0\1\1\1\2\1\1\2\2\1\3\2\1\3\2\1\3\2\1"
     "\4\3\2\4\3\2\4\3\2\6\4\2\6\4\2\6\4\2\7\5\2\7\5\3\11\6\3\11\6\3\12\7\3\13"
     "\10\3\15\10\4\16\11\4\17\11\4\21\12\4\22\13\4\22\13\5\23\14\5\24\15\5\26"
@@ -71,7 +71,7 @@ static const uint8_t sepia_table[768] =
     "\344\374\373\347\374\374\350\375\374\351\375\374\351\375\374\352\375\375"
     "\352\376\375\353\376\376\355\376\376\356\376\376\357\377\377\357";


-static const uint8_t heat_table[768] =
+static const uint8_t heat_table[769] =
     "\0\0\0\0\0\0\0\1\0\0\1\0\0\1\1\0\2\1\0\2\1\1\2\1\1\2\2\1\2\2\1\3\2\1\3\3"
     "\1\3\3\1\4\3\1\4\4\1\5\4\1\5\5\2\5\6\2\6\6\2\6\7\2\6\7\2\7\7\2\7\11\2\10"
     "\11\2\10\12\3\11\13\3\11\13\3\11\14\3\12\15\3\12\17\3\13\17\3\14\20\3\14"
@@ -103,7 +103,7 @@ static const uint8_t heat_table[768] =
     "\3648\0\3641\0\365.\0\366+\0\366'\0\367'\0\370!\0\370\36\0\370\33\0\371\30"
     "\0\371\26\0\373\26\0\373\23\0\374\15\0\374\13\0\375\10\0\375\5\0\376\3\0";


-static const uint8_t red_green_table[768] =
+static const uint8_t red_green_table[769] =
"\13\0\2\17\0\2\23\0\3\27\0\3\33\1\4\37\1\5\"\1\5&\1\5&\1\6-\1\7""1\2\7""4"
"\2\10""8\2\10;\2\11>\2\12A\3\12D\3\13G\3\13G\3\14L\4\14O\4\14Q\4\16Q\4\16"
"V\5\17V\5\17Y\5\17[\5\20]\6\21^\6\22_\6\22`\7\22`\7\23a\7\23b\10\24b\10\24"
@@ -130,7 +130,7 @@ static const uint8_t red_green_table[768] =
"\361\327\377\362\334\377\364\341\377\366\341\377\367\352\377\367\357\377"
"\371\364\377\374\364\377\376\371\377\377";

-static const uint8_t old_photo_table[768] =
+static const uint8_t old_photo_table[769] =
"&\3@'\4@(\5A)\6A*\7A*\10A+\11A,\12A,\13B.\13B/\15B0\16B0\17B1\20C2\21C3\22"
"C4\23C5\24C5\25C6\26D7\27D8\30D8\31D:\32D:\33E<\34E<\35E=\36E>\37E?\40F@"
"!F@!FA\"FB$FC$FC%GE&GE'GF(GG*GG*HH+HI,HK-HK/HM0IM0IM1IO2IO3JQ4JQ5JR6JR8K"
@@ -159,7 +159,7 @@ static const uint8_t old_photo_table[768] =
"\326\370\270\327\371\271\327\371\272\330\372\272\330\374\273\331\374\275"
"\331\375\275\332\377\276";

-static const uint8_t xray_table[768] =
+static const uint8_t xray_table[769] =
     "\377\377\377\377\377\377\376\376\376\375\375\376\374\375\375\373\374\375"
     "\372\374\374\371\374\374\370\373\373\366\373\372\366\372\372\365\372\371"
     "\363\371\371\363\371\370\362\370\370\360\370\367\360\367\366\357\367\365"
@@ -196,7 +196,7 @@ static const uint8_t xray_table[768] =
     "\36\32\13\33\26\13\31\24\11\26\22\11\24\20\7\24\16\6\21\16\5\14\14\4\12\10"
     "\3\7\6\3\5\4\1\2\2";


-static const uint8_t xpro_table[768] =
+static const uint8_t xpro_table[769] =
     "\0\0\37\0\0\37\0\1\40\0\2!\0\2\"\0\3\"\1\4%\1\4%\1\5%\1\5'\1\7'\1\7(\1\7"
     "(\1\10*\1\11+\1\11,\1\12,\1\13/\1\14/\1\14" "1\2\15" "1\2\15" "1\2\16"
     "4\2\17" "" "4\3\17" "5\3\22" "7\3\22" "7\3\23" "8\3\24"
@@ -234,7 +234,7 @@ static const uint8_t xpro_table[768] =
     "\377\367\377\377\367\377\377\370";


 /*Used for a video magnifer emulator in gnome-video-effects*/
-static const uint8_t yellowblue_table[768] =
+static const uint8_t yellowblue_table[769] =
     "\0\0\377\1\1\376\2\2\375\3\3\374\4\4\373\5\5\372\6\6\371\7\7\370\10\10\367"
     "\11\11\367\12\12\365\13\13\364\14\14\363\15\14\362\16\16\361\17\17\360\20"
     "\20\357\20\21\356\22\22\355\23\23\354\24\24\354\24\25\352\26\26\351\27\27"
@@ -265,7 +265,7 @@ static const uint8_t yellowblue_table[768] =
     "\361\361\16\362\362\15\363\362\14\364\364\13\365\365\12\365\366\11\367\367"
     "\11\370\370\7\371\371\6\372\371\5\373\373\4\374\374\4\375\375\3\375\376\1";


-static const uint8_t esses_table[768] =
+static const uint8_t esses_table[769] =
   "\252\252\245\245\245\240\240\240\233\233\233\226\226\226\220\220\220\213"
   "\213\213\213\206\206\206\206\202}}\202xxxsssnnnjjjeeeaaaa\\\\XXXTXTPPPLL"
   "LLHHDHDAAA=A=::::66333000---++++++(((&$$\"\"$\"\"\"\40\36\40\36\36\36\34"
diff --git a/src/filter/curves/curves.c b/src/filter/curves/curves.c
index f2fa96f..d745e48 100644
--- a/src/filter/curves/curves.c
+++ b/src/filter/curves/curves.c
@@ -251,8 +251,8 @@ f0r_instance_t f0r_construct(unsigned int width, unsigned int height)
   inst->curvesPosition = 3;
   inst->pointNumber = 2;
   inst->formula = 1;
-  inst->bspline = calloc(1, sizeof(char));
-  inst->bsplineMap = malloc(sizeof(double));
+  inst->bspline = (char *) calloc(1, sizeof(char));
+  inst->bsplineMap = (double *) malloc(sizeof(double));
   inst->points[0] = 0;
   inst->points[1] = 0;
   inst->points[2] = 1;
@@ -304,7 +304,8 @@ void f0r_set_param_value(f0r_instance_t instance,
               }
           } else {
               if ((int)inst->channel != (int)(tmp * 10)) {
-                inst->channel = (enum CHANNELS)(tmp * 10);
+                  // MSVC error: Conversions between enumeration and floating point values are no longer allowed
+                inst->channel = (enum CHANNELS) ((int) (tmp * 10));
                 if (strlen(inst->bspline))
                     updateBsplineMap(instance);
               }
@@ -555,7 +556,7 @@ int tokenise(char *string, const char *delimiter, char ***tokens)
     char *result = NULL;
     result = strtok(input, delimiter);
     while (result != NULL) {
-        *tokens = realloc(*tokens, (count + 1) * sizeof(char *));
+        *tokens = (char **) realloc(*tokens, (count + 1) * sizeof(char *));
         (*tokens)[count++] = strdup(result);
         result = strtok(NULL, delimiter);
     }
@@ -573,7 +574,7 @@ void updateBsplineMap(f0r_instance_t instance)


     int range = inst->channel == CHANNEL_HUE ? 361 : 256;
     free(inst->bsplineMap);
-    inst->bsplineMap = malloc(range * sizeof(double));
+    inst->bsplineMap = (double *) malloc(range * sizeof(double));
     // fill with default values, in case the spline does not cover the whole range
     if (inst->channel == CHANNEL_HUE) {
         for(int i = 0; i < 361; ++i)
@@ -589,17 +590,18 @@ void updateBsplineMap(f0r_instance_t instance)
     /*
      * string -> list of points
      */
-    char **pointStr = calloc(1, sizeof(char *));
+    char **pointStr = (char **) calloc(1, sizeof(char *));
     int count = tokenise(inst->bspline, "|", &pointStr);


-    bspline_point points[count];
+    bspline_point* points;
+    points = (bspline_point *) calloc(count, sizeof(bspline_point));


     for (int i = 0; i < count; ++i) {
-        char **positionsStr = calloc(1, sizeof(char *));
+        char **positionsStr = (char **) calloc(1, sizeof(char *));
         int positionsNum = tokenise(pointStr[i], "#", &positionsStr);
         if (positionsNum == 3) { // h1, p, h2
             for (int j = 0; j < positionsNum; ++j) {
-                char **coords = calloc(1, sizeof(char *));
+                char **coords = (char **) calloc(1, sizeof(char *));
                 int coordsNum = tokenise(positionsStr[j], ";", &coords);
                 if (coordsNum == 2) { // x, y
                     points[i][j].x = atof(coords[0]);
@@ -650,7 +652,8 @@ void updateBsplineMap(f0r_instance_t instance)
             c = 1;
         }
         step = 1 / (double)c;
-        position curve[c];
+        position* curve;
+        curve = (position *) calloc(c, sizeof(position));
         while (t <= 1) {
             curve[pn++] = pointOnBezier(t, p);
             t += step;
@@ -731,7 +734,7 @@ void f0r_update(f0r_instance_t instance, double time,
       free(coeffs);


       if (inst->channel == CHANNEL_HUE || inst->channel == CHANNEL_SATURATION) {
-          map = malloc(361*sizeof(double));
+          map = (double *) malloc(361*sizeof(double));
           if (CHANNEL_SATURATION)
               for (i = 0; i < 256; ++i)
                   map[i] = mapI[i] / 255.;
@@ -740,7 +743,7 @@ void f0r_update(f0r_instance_t instance, double time,
                   map[i] = mapI[(int)(i / 360. * 255)] / 360. * 255;
       }
   } else {
-      map = malloc(361*sizeof(double));
+      map = (double *) malloc(361*sizeof(double));
       memcpy(map, inst->bsplineMap, (inst->channel == CHANNEL_HUE ? 361 : 256)*sizeof(double));
       if (inst->channel != CHANNEL_SATURATION && inst->channel != CHANNEL_HUE) {
           if (inst->channel == CHANNEL_LUMA)
diff --git a/src/filter/d90stairsteppingfix/d90stairsteppingfix.cpp b/src/filter/d90stairsteppingfix/d90stairsteppingfix.cpp
index 45ed2ae..1c38a93 100644
--- a/src/filter/d90stairsteppingfix/d90stairsteppingfix.cpp
+++ b/src/filter/d90stairsteppingfix/d90stairsteppingfix.cpp
@@ -135,7 +135,8 @@ public:
              * and therefore get the number (line1+line2)/2, here 6.5.
              * This positions will later be used for interpolation.
              */
-            float filled[newHeight];
+            float *filled;
+            filled = (float *) calloc(newHeight, sizeof(float));


             int count = 0;
             int index = 0;
@@ -160,7 +161,8 @@ public:
              * Calculate scaling numbers to scale the full height matrix
              * with the slice lines down to the original height (720p).
              */
-            float downScaling[height];
+            float *downScaling;
+            downScaling = (float *) calloc(height, sizeof(float));


             float scaleFactor = (float) newHeight/height;
 //          printf("scale factor: %f\n", scaleFactor);
diff --git a/src/filter/denoise/hqdn3d.c b/src/filter/denoise/hqdn3d.c
index 7a91044..54366db 100755
--- a/src/filter/denoise/hqdn3d.c
+++ b/src/filter/denoise/hqdn3d.c
@@ -149,7 +149,7 @@ void deNoise(unsigned char *Frame,        // mpi->planes[x]
     unsigned short* FrameAnt=(*FrameAntPtr);


     if(!FrameAnt){
-    (*FrameAntPtr)=FrameAnt=malloc(W*H*sizeof(unsigned short));
+    (*FrameAntPtr)=FrameAnt= (unsigned short*) malloc(W*H*sizeof(unsigned short));
     for (Y = 0; Y < H; Y++){
         unsigned short* dst=&FrameAnt[Y*W];
         unsigned char* src=Frame+Y*sStride;
@@ -296,19 +296,19 @@ f0r_instance_t f0r_construct(unsigned int width, unsigned int height)
 {
 inst *in;


-in=calloc(1,sizeof(inst));
+in= (inst *) calloc(1,sizeof(inst));
in->w=width;
in->h=height;

in->LumSpac=4;
in->LumTmp=6;
-in->vps.Line=calloc(width,sizeof(int));
-in->Rplani=calloc(width*height,sizeof(unsigned char));
-in->Gplani=calloc(width*height,sizeof(unsigned char));
-in->Bplani=calloc(width*height,sizeof(unsigned char));
-in->Rplano=calloc(width*height,sizeof(unsigned char));
-in->Gplano=calloc(width*height,sizeof(unsigned char));
-in->Bplano=calloc(width*height,sizeof(unsigned char));
+in->vps.Line= (unsigned int *) calloc(width,sizeof(int));
+in->Rplani= (unsigned char *) calloc(width*height,sizeof(unsigned char));
+in->Gplani= (unsigned char *) calloc(width*height,sizeof(unsigned char));
+in->Bplani= (unsigned char *) calloc(width*height,sizeof(unsigned char));
+in->Rplano= (unsigned char *) calloc(width*height,sizeof(unsigned char));
+in->Gplano= (unsigned char *) calloc(width*height,sizeof(unsigned char));
+in->Bplano= (unsigned char *) calloc(width*height,sizeof(unsigned char));

PrecalcCoefs(in->vps.Coefs[0],in->LumSpac);
PrecalcCoefs(in->vps.Coefs[1],in->LumTmp);
diff --git a/src/filter/dither/dither.c b/src/filter/dither/dither.c
index 13fac58..ebbeb36 100644
--- a/src/filter/dither/dither.c
+++ b/src/filter/dither/dither.c
@@ -252,8 +252,9 @@ void f0r_update(f0r_instance_t instance, double time,

   // init look-ups
     int rows, cols;
-  rows = cols = (int)sqrt(matrixLength);
-  int map[levels];
+  rows = cols = (int)sqrt( (float) matrixLength);
+  int *map;
+  map = (int *) calloc(levels, sizeof(int));
   int i,v;
     for (i = 0; i < levels; i++)
   {
diff --git a/src/filter/emboss/emboss.c b/src/filter/emboss/emboss.c
index fd1d65e..f5e3a0e 100644
--- a/src/filter/emboss/emboss.c
+++ b/src/filter/emboss/emboss.c
@@ -164,8 +164,10 @@ void f0r_update(f0r_instance_t instance, double time,


   // Create brightness image
   unsigned int len = inst->width * inst->height;
-  unsigned char bumpPixels[len];
-  unsigned char alphaVals[len];
+  unsigned char *bumpPixels;
+  unsigned char *alphaVals;
+  bumpPixels = (unsigned char *) calloc(len, sizeof(unsigned char));
+  alphaVals = (unsigned char *) calloc(len, sizeof(unsigned char));
   unsigned int index, r, g, b, a = 0;
   const unsigned char* src = (unsigned char*)inframe;
   while (len--)
@@ -214,7 +216,7 @@ void f0r_update(f0r_instance_t instance, double time,
             else if ((NdotL = Nx*Lx + Ny*Ly + NzLz) < 0)
                 shade = 0;
             else
-                shade = (int)(NdotL / sqrt(Nx*Nx + Ny*Ny + Nz2));
+                shade = (int)(NdotL / sqrt((float) Nx*Nx + Ny*Ny + Nz2));
         } 
       else
       {
diff --git a/src/filter/keyspillm0pup/keyspillm0pup.c b/src/filter/keyspillm0pup/keyspillm0pup.c
index c1b02f9..22f7a12 100644
--- a/src/filter/keyspillm0pup/keyspillm0pup.c
+++ b/src/filter/keyspillm0pup/keyspillm0pup.c
@@ -49,6 +49,27 @@ typedef struct
     float a;
     } float_rgba;


+#ifdef _MSC_VER
+#include <float.h>
+long __inline lroundf ( float x )
+{
+  /* Add +/- 0.5, then round towards zero.  */
+  float tmp = floorf ( x );
+  if (_isnan (tmp)
+      || tmp > (float)LONG_MAX
+      || tmp < (float)LONG_MIN)
+    {
+      errno = ERANGE;
+      /* Undefined behaviour, so we could return anything.  */
+      /* return tmp > 0.0F ? LONG_MAX : LONG_MIN;  */
+    }
+  return (long)tmp;
+}
+float __inline roundf ( float x )
+{
+  return (float)lroundf( x );
+}
+#endif
 //----------------------------------------------------
 void RGBA8888_2_float(const uint32_t* in, float_rgba *out, int w, int h)
 {
@@ -808,12 +829,12 @@ f0r_instance_t f0r_construct(unsigned int width, unsigned int height)
 {
 inst *in;


-in=calloc(1,sizeof(inst));
+in= (inst *) calloc(1,sizeof(inst));
in->w=width;
in->h=height;

-in->sl=calloc(in->w*in->h,sizeof(float_rgba));
-in->mask=calloc(in->w*in->h,sizeof(float));
+in->sl= (float_rgba *) calloc(in->w*in->h,sizeof(float_rgba));
+in->mask= (float *) calloc(in->w*in->h,sizeof(float));

 //defaults
 in->key.r = 0.1; 
@@ -982,7 +1003,7 @@ switch(param_index)
         *((f0r_param_color_t*)param)=p->tgt;
         break;
     case 2:        //Mask type   (list)
-        p->liststr=realloc(p->liststr,16);
+        p->liststr= (char *) realloc(p->liststr,16);
         sprintf(p->liststr,"%d",p->maskType);
         *((char**)param) = p->liststr;
         break;
@@ -999,7 +1020,7 @@ switch(param_index)
         *((double*)param)=p->Sthresh;
         break;
     case 7:        //Operation 1  (list)
-        p->liststr=realloc(p->liststr,16);
+        p->liststr= (char *) realloc(p->liststr,16);
         sprintf(p->liststr,"%d",p->op1);
         *((char**)param) = p->liststr;
         break;
@@ -1007,7 +1028,7 @@ switch(param_index)
         *((double*)param)=p->am1;
         break;
     case 9:        //Operation 2  (list)
-        p->liststr=realloc(p->liststr,16);
+        p->liststr= (char *) realloc(p->liststr,16);
         sprintf(p->liststr,"%d",p->op2);
         *((char**)param) = p->liststr;
         break;
diff --git a/src/filter/levels/levels.c b/src/filter/levels/levels.c
index f5d93dc..6ba6134 100644
--- a/src/filter/levels/levels.c
+++ b/src/filter/levels/levels.c
@@ -34,6 +34,13 @@
 #define POS_BOTTOM_LEFT 2
 #define POS_BOTTOM_RIGHT 3


+#ifdef _MSC_VER
+int __inline lrintf(const float x)
+{
+ __asm cvtss2si eax, x
+}
+#endif
+
typedef struct levels_instance
{
unsigned int width;
diff --git a/src/filter/lightgraffiti/lightgraffiti.cpp b/src/filter/lightgraffiti/lightgraffiti.cpp
index a84932d..c9fd548 100644
--- a/src/filter/lightgraffiti/lightgraffiti.cpp
+++ b/src/filter/lightgraffiti/lightgraffiti.cpp
@@ -71,6 +71,10 @@
#include <climits>
#include <algorithm>

+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
 #define LG_ADV
 //#define LG_NO_OVERLAY // Not really working yet
 //#define LG_DEBUG
diff --git a/src/filter/measure/measure.h b/src/filter/measure/measure.h
index 44dfa26..661b9c7 100755
--- a/src/filter/measure/measure.h
+++ b/src/filter/measure/measure.h
@@ -40,7 +40,7 @@ typedef struct        //statistics
     float rms;
     float min;
     float max;
-    } stat;
+    } statistics; // windows headers already define stat


 typedef struct        //profile data and statistics
     {
@@ -52,13 +52,13 @@ typedef struct        //profile data and statistics
     float y[8192];
     float u[8192];
     float v[8192];
-    stat sr;
-    stat sg;
-    stat sb;
-    stat sa;
-    stat sy;
-    stat su;
-    stat sv;
+    statistics sr;
+    statistics sg;
+    statistics sb;
+    statistics sa;
+    statistics sy;
+    statistics su;
+    statistics sv;
     int xz,xk,yz,yk;    //start and end point
     } profdata;


@@ -70,7 +70,7 @@ typedef struct        //profile data and statistics
 //w=width of image (stride)
 //x,y=position of the center of the group in pixels
 //sx,sy=size of the group in pixels
-void meri_y(float_rgba *s, stat *yy, int color, int x, int y, int w, int sx, int sy)
+void meri_y(float_rgba *s, statistics *yy, int color, int x, int y, int w, int sx, int sy)
 {
 float wr,wg,wb,luma,nf;
 int xp,yp;
@@ -116,7 +116,7 @@ yy->rms=sqrtf((yy->rms-nf*yy->avg*yy->avg)/nf);
 //w=width of image (stride)
 //x,y=position of the center of the group in pixels
 //sx,sy=size of the group in pixels
-void meri_rgb(float_rgba *s, stat *r, stat *g, stat *b, int x, int y, int w, int sx, int sy)
+void meri_rgb(float_rgba *s, statistics *r, statistics *g, statistics *b, int x, int y, int w, int sx, int sy)
 {
 float nf;
 int xp,yp;
@@ -168,7 +168,7 @@ b->rms=sqrtf((b->rms-nf*b->avg*b->avg)/nf);
 //w=width of image (stride)
 //x,y=position of the center of the group in pixels
 //sx,sy=size of the group in pixels
-void meri_a(float_rgba *s, stat *a, int x, int y, int w, int sx, int sy)
+void meri_a(float_rgba *s, statistics *a, int x, int y, int w, int sx, int sy)
 {
 float nf;
 int xp,yp;
@@ -205,7 +205,7 @@ a->rms=sqrtf((a->rms-nf*a->avg*a->avg)/nf);
 //w=width of image (stride)
 //x,y=position of the center of the group in pixels
 //sx,sy=size of the group in pixels
-void meri_uv(float_rgba *s, stat *u, stat *v, int color, int x, int y, int w, int sx, int sy)
+void meri_uv(float_rgba *s, statistics *u, statistics *v, int color, int x, int y, int w, int sx, int sy)
 {
 float wr,wg,wb,uu,vv,nf;
 int xp,yp;
diff --git a/src/filter/measure/pr0be.c b/src/filter/measure/pr0be.c
index d1b7743..108ae62 100644
--- a/src/filter/measure/pr0be.c
+++ b/src/filter/measure/pr0be.c
@@ -174,7 +174,7 @@ sprintf(s,"%s",ss);
 //u=units    0=0.0-1.0    1=0-255
 //m=sign  0=unsigned
 //mm=1  print min/max
-void izpis(char *str, char *lab, stat s, int u, int m, int mm)
+void izpis(char *str, char *lab, statistics s, int u, int m, int mm)
 {
 char fs[256],as[16],rs[16],ns[16],xs[16];


@@ -281,7 +281,7 @@ void sonda(float_rgba *s, int w, int h, int x, int y, int sx, int sy, int *poz,
int x0,y0,vx,vy,vp,np,np2,xn,yn;
int i,j,xp,yp;
char string[256];
-stat yy,rr,gg,bb,aa,uu,vv;
+statistics yy,rr,gg,bb,aa,uu,vv;
float al,be,h2,c1,c2,ss,va,li;

float_rgba white={1.0,1.0,1.0,1.0};
@@ -607,7 +607,7 @@ f0r_instance_t f0r_construct(unsigned int width, unsigned int height)
{
inst *in;

-in=calloc(1,sizeof(inst));
+in= (inst *) calloc(1,sizeof(inst));
in->w=width;
in->h=height;

diff --git a/src/filter/measure/pr0file.c b/src/filter/measure/pr0file.c
index 0b61b33..940915a 100644
--- a/src/filter/measure/pr0file.c
+++ b/src/filter/measure/pr0file.c
@@ -755,7 +755,7 @@ f0r_instance_t f0r_construct(unsigned int width, unsigned int height)
{
inst *in;

-in=calloc(1,sizeof(inst));
+in= (inst *) calloc(1,sizeof(inst));
in->w=width;
in->h=height;

diff --git a/src/filter/medians/medians.c b/src/filter/medians/medians.c
index 48293c4..22181e4 100755
--- a/src/filter/medians/medians.c
+++ b/src/filter/medians/medians.c
@@ -442,20 +442,20 @@ f0r_instance_t f0r_construct(unsigned int width, unsigned int height)
{
inst *in;

-in=calloc(1,sizeof(inst));
+in= (inst *) calloc(1,sizeof(inst));
in->w=width;
in->h=height;

in->type=1;
-in->liststr=calloc(1,strlen("Square3x3")+1);
+in->liststr= (char *) calloc(1,strlen("Square3x3")+1);
strcpy(in->liststr,"Square3x3");
in->size=5;

-in->f1=calloc(in->w*in->h,sizeof(uint32_t));
-in->f2=calloc(in->w*in->h,sizeof(uint32_t));
-in->f3=calloc(in->w*in->h,sizeof(uint32_t));
-in->f4=calloc(in->w*in->h,sizeof(uint32_t));
-in->f5=calloc(in->w*in->h,sizeof(uint32_t));
+in->f1= (uint32_t *) calloc(in->w*in->h,sizeof(uint32_t));
+in->f2= (uint32_t *) calloc(in->w*in->h,sizeof(uint32_t));
+in->f3= (uint32_t *) calloc(in->w*in->h,sizeof(uint32_t));
+in->f4= (uint32_t *) calloc(in->w*in->h,sizeof(uint32_t));
+in->f5= (uint32_t *) calloc(in->w*in->h,sizeof(uint32_t));

in->ppf=in->f1;
in->pf=in->f2;
diff --git a/src/filter/select0r/select0r.c b/src/filter/select0r/select0r.c
index d24d31e..a9e36dd 100755
--- a/src/filter/select0r/select0r.c
+++ b/src/filter/select0r/select0r.c
@@ -781,7 +781,7 @@ f0r_instance_t f0r_construct(unsigned int width, unsigned int height)
{
inst *in;

-in=calloc(1,sizeof(inst));
+in= (inst *) calloc(1,sizeof(inst));

in->w=width;
in->h=height;
diff --git a/src/filter/sharpness/sharpness.c b/src/filter/sharpness/sharpness.c
index 830251d..3ce5623 100755
--- a/src/filter/sharpness/sharpness.c
+++ b/src/filter/sharpness/sharpness.c
@@ -201,16 +201,16 @@ f0r_instance_t f0r_construct(unsigned int width, unsigned int height)
inst *in;
int z;

-in=calloc(1,sizeof(inst));
+in= (inst *) calloc(1,sizeof(inst));
in->w=width;
in->h=height;

-in->Rplani=calloc(width*height,sizeof(unsigned char));
-in->Gplani=calloc(width*height,sizeof(unsigned char));
-in->Bplani=calloc(width*height,sizeof(unsigned char));
-in->Rplano=calloc(width*height,sizeof(unsigned char));
-in->Gplano=calloc(width*height,sizeof(unsigned char));
-in->Bplano=calloc(width*height,sizeof(unsigned char));
+in->Rplani= (unsigned char *) calloc(width*height,sizeof(unsigned char));
+in->Gplani= (unsigned char *) calloc(width*height,sizeof(unsigned char));
+in->Bplani= (unsigned char *) calloc(width*height,sizeof(unsigned char));
+in->Rplano= (unsigned char *) calloc(width*height,sizeof(unsigned char));
+in->Gplano= (unsigned char *) calloc(width*height,sizeof(unsigned char));
+in->Bplano= (unsigned char *) calloc(width*height,sizeof(unsigned char));

//defaults
in->fp.amount=0.0;
@@ -221,7 +221,7 @@ in->ac=0;

 memset(in->fp.SC,0,sizeof(in->fp.SC));
 for( z=0; z<in->fp.msizeY; z++ )
-    in->fp.SC[z] = calloc(in->w+in->fp.msizeX , sizeof(*(in->fp.SC[z])));
+    in->fp.SC[z] = (uint32_t *) calloc(in->w+in->fp.msizeX , sizeof(*(in->fp.SC[z])));


return (f0r_instance_t)in;
}
@@ -280,7 +280,7 @@ p->fp.msizeY=p->size;

 memset(p->fp.SC,0,sizeof(p->fp.SC));
 for( z=0; z<p->fp.msizeY; z++ )
-    p->fp.SC[z] = calloc(p->w+p->fp.msizeX , sizeof(*(p->fp.SC[z])));
+    p->fp.SC[z] = (uint32_t *) calloc(p->w+p->fp.msizeX , sizeof(*(p->fp.SC[z])));


}

diff --git a/src/filter/vignette/vignette.cpp b/src/filter/vignette/vignette.cpp
index 3b176da..f049835 100644
--- a/src/filter/vignette/vignette.cpp
+++ b/src/filter/vignette/vignette.cpp
@@ -21,6 +21,9 @@
#include "frei0r.hpp"
#include "frei0r_math.h"

+#ifndef M_PI_2
+#define M_PI_2 1.5707963267948966192
+#endif

/**
Lens vignetting effect.
diff --git a/src/generator/dem0scene/CMakeLists.txt b/src/generator/dem0scene/CMakeLists.txt
index c550f8d..0ab2bef 100644
--- a/src/generator/dem0scene/CMakeLists.txt
+++ b/src/generator/dem0scene/CMakeLists.txt
@@ -1,5 +1,5 @@
set (SOURCES plasma.cpp)
-set (TARGET plasma)
+set (TARGET plasmaeffect) #so it does not conflict with kde's plasma.dll

if (MSVC)
set (SOURCES ${SOURCES} ${FREI0R_DEF})
diff --git a/src/generator/partik0l/partik0l.cpp b/src/generator/partik0l/partik0l.cpp
index 6dd5a8a..a83d02a 100644
--- a/src/generator/partik0l/partik0l.cpp
+++ b/src/generator/partik0l/partik0l.cpp
@@ -45,6 +45,11 @@

#define PRIMES 11

+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
+
class Partik0l: public frei0r::source {
public:

diff --git a/src/generator/test_pat/test_pat_B.c b/src/generator/test_pat/test_pat_B.c
index dcb7ce2..9b721e8 100644
--- a/src/generator/test_pat/test_pat_B.c
+++ b/src/generator/test_pat/test_pat_B.c
@@ -59,6 +59,15 @@ typedef struct
     float a;
     } float_rgba;


+#ifdef _MSC_VER
+float __inline rintf( float x )
+{
+    __asm {
+        fld x
+        frndint
+    }
+}
+#endif


//------------------------------------------------------------------
void draw_rectangle(float_rgba *s, int w, int h, float x, float y, float wr, float hr, float_rgba c)
@@ -756,7 +765,7 @@ void f0r_get_param_info(f0r_param_info_t* info, int param_index)
//--------------------------------------------------
f0r_instance_t f0r_construct(unsigned int width, unsigned int height)
{
- tp_inst_t* inst = calloc(1, sizeof(*inst));
+ tp_inst_t* inst = (tp_inst_t*) calloc(1, sizeof(*inst));
inst->w = width;
inst->h = height;

diff --git a/src/generator/test_pat/test_pat_C.c b/src/generator/test_pat/test_pat_C.c
index 393289b..cafd3d4 100644
--- a/src/generator/test_pat/test_pat_C.c
+++ b/src/generator/test_pat/test_pat_C.c
@@ -543,7 +543,7 @@ f0r_instance_t f0r_construct(unsigned int width, unsigned int height)
{
int x0,y0,velx,vely;
float_rgba c;
- tp_inst_t* inst = calloc(1, sizeof(*inst));
+ tp_inst_t* inst = (tp_inst_t*) calloc(1, sizeof(*inst));
inst->w = width;
inst->h = height;

diff --git a/src/generator/test_pat/test_pat_G.c b/src/generator/test_pat/test_pat_G.c
index 6109f14..7cc7527 100644
--- a/src/generator/test_pat/test_pat_G.c
+++ b/src/generator/test_pat/test_pat_G.c
@@ -649,7 +649,7 @@ void f0r_get_param_info(f0r_param_info_t* info, int param_index)
//--------------------------------------------------
f0r_instance_t f0r_construct(unsigned int width, unsigned int height)
{
- tp_inst_t* inst = calloc(1, sizeof(*inst));
+ tp_inst_t* inst = (tp_inst_t*) calloc(1, sizeof(*inst));
inst->w = width;
inst->h = height;

diff --git a/src/generator/test_pat/test_pat_I.c b/src/generator/test_pat/test_pat_I.c
index 00beb68..39c83f3 100644
--- a/src/generator/test_pat/test_pat_I.c
+++ b/src/generator/test_pat/test_pat_I.c
@@ -442,7 +442,7 @@ void f0r_get_param_info(f0r_param_info_t* info, int param_index)
//--------------------------------------------------
f0r_instance_t f0r_construct(unsigned int width, unsigned int height)
{
- tp_inst_t* inst = calloc(1, sizeof(*inst));
+ tp_inst_t* inst = (tp_inst_t*) calloc(1, sizeof(*inst));
inst->w = width;
inst->h = height;

diff --git a/src/generator/test_pat/test_pat_L.c b/src/generator/test_pat/test_pat_L.c
index 38ed3a1..0a54504 100644
--- a/src/generator/test_pat/test_pat_L.c
+++ b/src/generator/test_pat/test_pat_L.c
@@ -582,7 +582,7 @@ void f0r_get_param_info(f0r_param_info_t* info, int param_index)
//--------------------------------------------------
f0r_instance_t f0r_construct(unsigned int width, unsigned int height)
{
- tp_inst_t* inst = calloc(1, sizeof(*inst));
+ tp_inst_t* inst = (tp_inst_t*) calloc(1, sizeof(*inst));
inst->w = width;
inst->h = height;

diff --git a/src/generator/test_pat/test_pat_R.c b/src/generator/test_pat/test_pat_R.c
index 55f15be..bb68850 100644
--- a/src/generator/test_pat/test_pat_R.c
+++ b/src/generator/test_pat/test_pat_R.c
@@ -854,7 +854,7 @@ void f0r_get_param_info(f0r_param_info_t* info, int param_index)
//--------------------------------------------------
f0r_instance_t f0r_construct(unsigned int width, unsigned int height)
{
- tp_inst_t* inst = calloc(1, sizeof(*inst));
+ tp_inst_t* inst = (tp_inst_t *) calloc(1, sizeof(*inst));
inst->w = width;
inst->h = height;