mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-24 10:41:04 +00:00
[480/906] win32 builds: add glshader filter sources to vs9 and codeblocks
Also fix some warnings from msvc9 and mingw-3.4.5
This commit is contained in:
parent
e44c1040fe
commit
9e535a0410
3 changed files with 63 additions and 61 deletions
|
@ -20,8 +20,12 @@
|
|||
|
||||
#include "gstglshadervariables.h"
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
#if !defined(strtok_r) && defined(G_OS_WIN32)
|
||||
#if defined(_MSC_VER)
|
||||
#define strtok_r strtok_s
|
||||
#else
|
||||
#define strtok_r(s,d,p) strtok(s,d)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define trimleft(s,chars) while(s[0] && strchr(chars,s[0])) ++s;
|
||||
|
@ -349,7 +353,7 @@ parsename (char **varname, int *arraysize, char **saveptr)
|
|||
{
|
||||
char *t;
|
||||
char *i;
|
||||
int j;
|
||||
gint j;
|
||||
|
||||
*arraysize = 0;
|
||||
t = strtok_r (0, "=", saveptr);
|
||||
|
@ -363,7 +367,7 @@ parsename (char **varname, int *arraysize, char **saveptr)
|
|||
if (!i) { // not an array
|
||||
if (!t[0])
|
||||
return t;
|
||||
for (j = 0; j < strlen (t); ++j) {
|
||||
for (j = 0; j < (gint) strlen (t); ++j) {
|
||||
if (!strchr (VALID_VARNAME_CHARS, t[j]))
|
||||
return t + j;
|
||||
}
|
||||
|
@ -380,7 +384,7 @@ parsename (char **varname, int *arraysize, char **saveptr)
|
|||
|
||||
if (!t[0])
|
||||
return t;
|
||||
for (j = 0; j < strlen (t); ++j) {
|
||||
for (j = 0; j < (gint) strlen (t); ++j) {
|
||||
if (!strchr (VALID_VARNAME_CHARS, t[j]))
|
||||
return t;
|
||||
}
|
||||
|
@ -656,7 +660,7 @@ parsevalue (char *value, char *_saveptr, struct gst_gl_shadervariable_desc *ret)
|
|||
case _int:
|
||||
ret->count = (ret->arraysize) ? ret->arraysize : 1;
|
||||
if (ret->count == 1) {
|
||||
for (j = 0; j < strlen (value); ++j) {
|
||||
for (j = 0; j < (gint) strlen (value); ++j) {
|
||||
if (!strchr ("-0123456789", value[j]))
|
||||
return _saveptr + j;
|
||||
}
|
||||
|
@ -677,7 +681,7 @@ parsevalue (char *value, char *_saveptr, struct gst_gl_shadervariable_desc *ret)
|
|||
if (!t[0])
|
||||
return _saveptr + (saveptr - t);
|
||||
|
||||
for (j = 0; j < strlen (value); ++j) {
|
||||
for (j = 0; j < (gint) strlen (value); ++j) {
|
||||
if (!strchr ("-0123456789", value[j]))
|
||||
return _saveptr + (saveptr - t) + j;
|
||||
}
|
||||
|
@ -691,7 +695,7 @@ parsevalue (char *value, char *_saveptr, struct gst_gl_shadervariable_desc *ret)
|
|||
case _uint:
|
||||
ret->count = (ret->arraysize) ? ret->arraysize : 1;
|
||||
if (ret->count == 1) {
|
||||
for (j = 0; j < strlen (value); ++j) {
|
||||
for (j = 0; j < (gint) strlen (value); ++j) {
|
||||
if (!strchr ("0123456789", value[j]))
|
||||
return _saveptr + j;
|
||||
}
|
||||
|
@ -712,7 +716,7 @@ parsevalue (char *value, char *_saveptr, struct gst_gl_shadervariable_desc *ret)
|
|||
if (!t[0])
|
||||
return _saveptr + (saveptr - t);
|
||||
|
||||
for (j = 0; j < strlen (value); ++j) {
|
||||
for (j = 0; j < (gint) strlen (value); ++j) {
|
||||
if (!strchr ("0123456789", value[j]))
|
||||
return _saveptr + (saveptr - t) + j;
|
||||
}
|
||||
|
@ -726,7 +730,7 @@ parsevalue (char *value, char *_saveptr, struct gst_gl_shadervariable_desc *ret)
|
|||
case _float:
|
||||
ret->count = (ret->arraysize) ? ret->arraysize : 1;
|
||||
if (ret->count == 1) {
|
||||
for (j = 0; j < strlen (value); ++j) {
|
||||
for (j = 0; j < (gint) strlen (value); ++j) {
|
||||
if (!strchr ("0123456789.-", value[j]))
|
||||
return _saveptr + j;
|
||||
}
|
||||
|
@ -747,7 +751,7 @@ parsevalue (char *value, char *_saveptr, struct gst_gl_shadervariable_desc *ret)
|
|||
if (!t[0])
|
||||
return _saveptr + (saveptr - t);
|
||||
|
||||
for (j = 0; j < strlen (value); ++j) {
|
||||
for (j = 0; j < (gint) strlen (value); ++j) {
|
||||
if (!strchr ("0123456789.-", value[j]))
|
||||
return _saveptr + (saveptr - t) + j;
|
||||
}
|
||||
|
@ -910,7 +914,7 @@ vec_parsevalue (int n, char *value, char *_saveptr,
|
|||
if (!t[0])
|
||||
return _saveptr + (saveptr - t);
|
||||
|
||||
for (j = 0; j < strlen (value); ++j) {
|
||||
for (j = 0; j < (gint) strlen (value); ++j) {
|
||||
if (!strchr ("0123456789.-", value[j]))
|
||||
return _saveptr + (saveptr - t) + j;
|
||||
}
|
||||
|
@ -960,7 +964,7 @@ vec_parsevalue (int n, char *value, char *_saveptr,
|
|||
if (!t[0])
|
||||
return _saveptr + (t - value);
|
||||
|
||||
for (j = 0; j < strlen (t); ++j) {
|
||||
for (j = 0; j < (gint) strlen (t); ++j) {
|
||||
if (!strchr ("0123456789.-", t[j]))
|
||||
return _saveptr + (t - value) + j;
|
||||
}
|
||||
|
@ -1157,7 +1161,7 @@ ivec_parsevalue (int n, char *value, char *_saveptr,
|
|||
if (!t[0])
|
||||
return _saveptr + (saveptr - t);
|
||||
|
||||
for (j = 0; j < strlen (value); ++j) {
|
||||
for (j = 0; j < (gint) strlen (value); ++j) {
|
||||
if (!strchr ("0123456789-", value[j]))
|
||||
return _saveptr + (saveptr - t) + j;
|
||||
}
|
||||
|
@ -1207,7 +1211,7 @@ ivec_parsevalue (int n, char *value, char *_saveptr,
|
|||
if (!t[0])
|
||||
return _saveptr + (t - value);
|
||||
|
||||
for (j = 0; j < strlen (t); ++j) {
|
||||
for (j = 0; j < (gint) strlen (t); ++j) {
|
||||
if (!strchr ("0123456789-", t[j]))
|
||||
return _saveptr + (t - value) + j;
|
||||
}
|
||||
|
@ -1283,7 +1287,7 @@ uvec_parsevalue (int n, char *value, char *_saveptr,
|
|||
if (!t[0])
|
||||
return _saveptr + (saveptr - t);
|
||||
|
||||
for (j = 0; j < strlen (value); ++j) {
|
||||
for (j = 0; j < (gint) strlen (value); ++j) {
|
||||
if (!strchr ("0123456789", value[j]))
|
||||
return _saveptr + (saveptr - t) + j;
|
||||
}
|
||||
|
@ -1333,7 +1337,7 @@ uvec_parsevalue (int n, char *value, char *_saveptr,
|
|||
if (!t[0])
|
||||
return _saveptr + (t - value);
|
||||
|
||||
for (j = 0; j < strlen (t); ++j) {
|
||||
for (j = 0; j < (gint) strlen (t); ++j) {
|
||||
if (!strchr ("0123456789", t[j]))
|
||||
return _saveptr + (t - value) + j;
|
||||
}
|
||||
|
@ -1409,7 +1413,7 @@ mat_parsevalue (int n, int m, char *value, char *_saveptr,
|
|||
if (!t[0])
|
||||
return _saveptr + (saveptr - t);
|
||||
|
||||
for (j = 0; j < strlen (value); ++j) {
|
||||
for (j = 0; j < (gint) strlen (value); ++j) {
|
||||
if (!strchr ("0123456789.-", value[j]))
|
||||
return _saveptr + (saveptr - t) + j;
|
||||
}
|
||||
|
@ -1459,7 +1463,7 @@ mat_parsevalue (int n, int m, char *value, char *_saveptr,
|
|||
if (!t[0])
|
||||
return _saveptr + (t - value);
|
||||
|
||||
for (j = 0; j < strlen (t); ++j) {
|
||||
for (j = 0; j < (gint) strlen (t); ++j) {
|
||||
if (!strchr ("0123456789.-", t[j]))
|
||||
return _saveptr + (t - value) + j;
|
||||
}
|
||||
|
|
|
@ -258,13 +258,13 @@ gst_gl_filtershader_load_file (char *filename, char **storage)
|
|||
{
|
||||
|
||||
size_t count;
|
||||
ssize_t bytes;
|
||||
int f;
|
||||
size_t bytes;
|
||||
FILE *f;
|
||||
|
||||
// read the filter from file
|
||||
GST_INFO ("loading file: %s", filename);
|
||||
f = open (filename, O_RDONLY);
|
||||
if (f < 0) {
|
||||
f = fopen (filename, O_RDONLY);
|
||||
if (f == NULL) {
|
||||
GST_ERROR ("could not open file: %s", filename);
|
||||
return -1;
|
||||
}
|
||||
|
@ -274,22 +274,23 @@ gst_gl_filtershader_load_file (char *filename, char **storage)
|
|||
*storage = 0;
|
||||
}
|
||||
|
||||
count = lseek (f, 0, SEEK_END);
|
||||
count = fseek (f, 0, SEEK_END);
|
||||
*storage = g_malloc (count + 1);
|
||||
if (!*storage) {
|
||||
GST_ERROR ("g_malloc failed: %u", count);
|
||||
return -1;
|
||||
}
|
||||
|
||||
lseek (f, 0, SEEK_SET);
|
||||
bytes = read (f, (void *) *storage, count);
|
||||
fseek (f, 0, SEEK_SET);
|
||||
bytes = fread ((void *) *storage, sizeof (char), count, f);
|
||||
if (bytes < 0 || bytes != count) {
|
||||
GST_ERROR ("read failed: %u/%u", bytes, count);
|
||||
return -1;
|
||||
}
|
||||
((char *) *storage)[count] = 0;
|
||||
|
||||
close (f);
|
||||
if (f)
|
||||
fclose (f);
|
||||
GST_INFO ("read: %u", bytes);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -284,46 +284,46 @@ gst_gl_overlay_draw (GstGLOverlay * o, int flag)
|
|||
width = o->width_window;
|
||||
height = o->height_window;
|
||||
} else if (flag == 0 && o->type_file == 1) {
|
||||
width = o->width;
|
||||
height = o->height;
|
||||
width = (gfloat) o->width;
|
||||
height = (gfloat) o->height;
|
||||
} else if (flag == 0 && o->type_file == 2) {
|
||||
width = 1.0;
|
||||
height = 1.0;
|
||||
width = 1.0f;
|
||||
height = 1.0f;
|
||||
}
|
||||
y = (o->type_file == 2 && flag == 0 ? o->ratio_y : -o->ratio_y) + o->posy;
|
||||
glTexCoord3f (0.0f, 0.0f, 0.0f);
|
||||
glVertex3f (-o->ratio_x + o->posx, y, 0.0f);
|
||||
glTexCoord3f (width, 0.0, 0.0);
|
||||
glTexCoord3f (width, 0.0f, 0.0f);
|
||||
glVertex3f (o->ratio_x + o->posx, y, 0.0f);
|
||||
glTexCoord3f (width, height, 0.0);
|
||||
glTexCoord3f (width, height, 0.0f);
|
||||
y = (o->type_file == 2 && flag == 0 ? -o->ratio_y : o->ratio_y) + o->posy;
|
||||
glVertex3f (o->ratio_x + o->posx, y, 0.0);
|
||||
glVertex3f (o->ratio_x + o->posx, y, 0.0f);
|
||||
glTexCoord3f (0.0f, height, 0.0f);
|
||||
glVertex3f (-o->ratio_x + o->posx, y, 0.0);
|
||||
glVertex3f (-o->ratio_x + o->posx, y, 0.0f);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_gl_overlay_calc_proportion (GstGLOverlay * o, int flag, float size_texture,
|
||||
float width, float height)
|
||||
{
|
||||
if ((1.59 < o->ratio_window && o->ratio_window < 1.61
|
||||
&& 1.77 < o->ratio_texture && o->ratio_texture < 1.78)
|
||||
|| (1.3 < o->ratio_window && o->ratio_window < 1.34
|
||||
&& ((1.7 < o->ratio_texture && o->ratio_texture < 1.78)
|
||||
|| (1.59 < o->ratio_texture && o->ratio_texture < 1.61)))) {
|
||||
o->ratio_x = o->ratio_window * (gfloat) size_texture / 100.0;
|
||||
if ((1.59f < o->ratio_window && o->ratio_window < 1.61f
|
||||
&& 1.77f < o->ratio_texture && o->ratio_texture < 1.78f)
|
||||
|| (1.3f < o->ratio_window && o->ratio_window < 1.34f
|
||||
&& ((1.7f < o->ratio_texture && o->ratio_texture < 1.78f)
|
||||
|| (1.59f < o->ratio_texture && o->ratio_texture < 1.61f)))) {
|
||||
o->ratio_x = o->ratio_window * (gfloat) size_texture / 100.0f;
|
||||
o->ratio_y =
|
||||
(o->ratio_window / width) * height * (gfloat) size_texture / 100.0;
|
||||
(o->ratio_window / width) * height * (gfloat) size_texture / 100.0f;
|
||||
} else {
|
||||
o->ratio_x = o->ratio_texture * (gfloat) size_texture / 100.0;
|
||||
o->ratio_y = 1.0 * size_texture / 100.0;
|
||||
o->ratio_x = o->ratio_texture * (gfloat) size_texture / 100.0f;
|
||||
o->ratio_y = 1.0f * size_texture / 100.0f;
|
||||
}
|
||||
o->posx =
|
||||
((o->ratio_window - o->ratio_x) * ((flag ==
|
||||
1 ? o->pos_x_video : o->pos_x_png) - 50.0) / 50.0);
|
||||
1 ? o->pos_x_video : o->pos_x_png) - 50.0f) / 50.0f);
|
||||
o->posy =
|
||||
(1.0 - o->ratio_y) * (((flag ==
|
||||
1 ? o->pos_y_video : o->pos_y_png) - 50.0) / 50.0);
|
||||
(1.0f - o->ratio_y) * (((flag ==
|
||||
1 ? o->pos_y_video : o->pos_y_png) - 50.0f) / 50.0f);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -350,7 +350,8 @@ gst_gl_overlay_load_texture (GstGLOverlay * o, GLuint tex, int flag)
|
|||
o->ratio_texture = (gfloat) o->width / (gfloat) o->height;
|
||||
if (o->rotate_png == 2)
|
||||
glRotatef (o->angle_png, 0, 1, 0);
|
||||
gst_gl_overlay_calc_proportion (o, flag, o->size_png, o->width, o->height);
|
||||
gst_gl_overlay_calc_proportion (o, flag, o->size_png, (gfloat) o->width,
|
||||
(gfloat) o->height);
|
||||
}
|
||||
glBegin (GL_POLYGON);
|
||||
gst_gl_overlay_draw (o, flag);
|
||||
|
@ -437,7 +438,7 @@ gst_gl_overlay_set_property (GObject * object, guint prop_id,
|
|||
overlay->angle_video = g_value_get_int (value);
|
||||
break;
|
||||
case PROP_RATIO_VIDEO:
|
||||
overlay->ratio_video = g_value_get_int (value);
|
||||
overlay->ratio_video = (gfloat) g_value_get_int (value);
|
||||
break;
|
||||
/* case PROP_STRETCH:
|
||||
overlay->stretch = g_value_get_boolean (value);
|
||||
|
@ -493,7 +494,7 @@ gst_gl_overlay_get_property (GObject * object, guint prop_id,
|
|||
g_value_set_int (value, overlay->angle_video);
|
||||
break;
|
||||
case PROP_RATIO_VIDEO:
|
||||
g_value_set_int (value, overlay->ratio_video);
|
||||
g_value_set_int (value, (gint) overlay->ratio_video);
|
||||
break;
|
||||
/* case PROP_STRETCH:
|
||||
g_value_set_boolean (value, overlay->stretch);
|
||||
|
@ -510,19 +511,15 @@ gst_gl_overlay_set_caps (GstGLFilter * filter, GstCaps * incaps,
|
|||
GstCaps * outcaps)
|
||||
{
|
||||
GstGLOverlay *overlay = GST_GL_OVERLAY (filter);
|
||||
gchar *str_caps;
|
||||
GstStructure *structure;
|
||||
const GValue *width_value;
|
||||
GstStructure *s = gst_caps_get_structure (incaps, 0);
|
||||
gint width = 0;
|
||||
gint height = 0;
|
||||
|
||||
structure = gst_caps_get_structure (incaps, 0);
|
||||
width_value = gst_structure_get_value (structure, "width");
|
||||
str_caps = g_strdup_value_contents (width_value);
|
||||
overlay->width_window = atof (str_caps);
|
||||
g_free (str_caps);
|
||||
width_value = gst_structure_get_value (structure, "height");
|
||||
str_caps = g_strdup_value_contents (width_value);
|
||||
overlay->height_window = atof (str_caps);
|
||||
g_free (str_caps);
|
||||
gst_structure_get_int (s, "width", &width);
|
||||
gst_structure_get_int (s, "height", &height);
|
||||
|
||||
overlay->width_window = (gfloat) width;
|
||||
overlay->height_window = (gfloat) height;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue