-/*
+/*
* GStreamer
* Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
*
#define GST_CAT_DEFAULT gst_gl_colorscale_debug
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
-static const GstElementDetails element_details =
+static const GstElementDetails element_details =
GST_ELEMENT_DETAILS ("OpenGL color scale",
"Filter/Effect",
"Colorspace converter and video scaler",
{
//GstGLColorscale* colorscale = GST_GL_COLORSCALE (object);
- switch (prop_id)
+ switch (prop_id)
{
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
{
//GstGLColorscale *colorscale = GST_GL_COLORSCALE (object);
- switch (prop_id)
+ switch (prop_id)
{
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
static void
gst_gl_colorscale_reset (GstGLColorscale* colorscale)
-{
- if (colorscale->display)
+{
+ if (colorscale->display)
{
g_object_unref (colorscale->display);
colorscale->display = NULL;
const GValue* framerate_value = NULL;
const GValue* par_value = NULL;
- GST_ERROR ("transform caps %" GST_PTR_FORMAT, caps);
+ GST_DEBUG ("transform caps %" GST_PTR_FORMAT, caps);
framerate_value = gst_structure_get_value (structure, "framerate");
par_value = gst_structure_get_value (structure, "pixel-aspect-ratio");
gst_structure_set (structure,
"width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
"height", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
-
+
gst_structure_set_value (structure, "framerate", framerate_value);
if (par_value)
gst_structure_set_value (structure, "pixel-aspect-ratio", par_value);
gst_caps_merge_structure (newcaps, gst_structure_copy (structure));
- GST_ERROR ("new caps %" GST_PTR_FORMAT, newcaps);
+ GST_DEBUG ("new caps %" GST_PTR_FORMAT, newcaps);
return newcaps;
}
to_par = gst_structure_get_value (outs, "pixel-aspect-ratio");
//we have both PAR but they might not be fixated
- if (from_par && to_par)
+ if (from_par && to_par)
{
gint from_w, from_h, from_par_n, from_par_d, to_par_n, to_par_d;
from_par_d = gst_value_get_fraction_denominator (from_par);
//fixate the out PAR
- if (!gst_value_is_fixed (to_par))
+ if (!gst_value_is_fixed (to_par))
{
GST_DEBUG_OBJECT (base, "fixating to_par to %dx%d", from_par_n,
from_par_d);
to_par_d = gst_value_get_fraction_denominator (to_par);
//f both width and height are already fixed, we can't do anything
- //about it anymore
+ //about it anymore
if (gst_structure_get_int (outs, "width", &w))
++count;
if (gst_structure_get_int (outs, "height", &h))
++count;
- if (count == 2)
+ if (count == 2)
{
GST_DEBUG_OBJECT (base, "dimensions already set to %dx%d, not fixating",
w, h);
gst_structure_get_int (ins, "height", &from_h);
if (!gst_video_calculate_display_ratio (&num, &den, from_w, from_h,
- from_par_n, from_par_d, to_par_n, to_par_d))
+ from_par_n, from_par_d, to_par_n, to_par_d))
{
GST_ELEMENT_ERROR (base, CORE, NEGOTIATION, (NULL),
("Error calculating the output scaled size - integer overflow"));
//prefer those that have one of w/h the same as the incoming video
//using wd / hd = num / den
- //if one of the output width or height is fixed, we work from there
- if (h)
+ //if one of the output width or height is fixed, we work from there
+ if (h)
{
GST_DEBUG_OBJECT (base, "height is fixed,scaling width");
w = (guint) gst_util_uint64_scale_int (h, num, den);
- }
- else if (w)
+ }
+ else if (w)
{
GST_DEBUG_OBJECT (base, "width is fixed, scaling height");
h = (guint) gst_util_uint64_scale_int (w, den, num);
- }
- else
+ }
+ else
{
//none of width or height is fixed, figure out both of them based only on
//the input width and height
- //check hd / den is an integer scale factor, and scale wd with the PAR
- if (from_h % den == 0)
+ //check hd / den is an integer scale factor, and scale wd with the PAR
+ if (from_h % den == 0)
{
GST_DEBUG_OBJECT (base, "keeping video height");
h = from_h;
w = (guint) gst_util_uint64_scale_int (h, num, den);
- }
- else if (from_w % num == 0)
+ }
+ else if (from_w % num == 0)
{
GST_DEBUG_OBJECT (base, "keeping video width");
w = from_w;
h = (guint) gst_util_uint64_scale_int (w, den, num);
- }
- else
+ }
+ else
{
GST_DEBUG_OBJECT (base, "approximating but keeping video height");
h = from_h;
//now fixate
gst_structure_fixate_field_nearest_int (outs, "width", w);
gst_structure_fixate_field_nearest_int (outs, "height", h);
- }
- else
+ }
+ else
{
gint width, height;
- if (gst_structure_get_int (ins, "width", &width))
+ if (gst_structure_get_int (ins, "width", &width))
{
- if (gst_structure_has_field (outs, "width"))
+ if (gst_structure_has_field (outs, "width"))
gst_structure_fixate_field_nearest_int (outs, "width", width);
}
if (gst_structure_get_int (ins, "height", &height)) {
ret |= gst_video_format_parse_caps (incaps, &colorscale->input_video_format,
&colorscale->input_video_width, &colorscale->input_video_height);
- if (!ret)
+ if (!ret)
{
GST_DEBUG ("bad caps");
return FALSE;
}
colorscale->display = gst_gl_display_new ();
-
+
//init unvisible opengl context
- gst_gl_display_create_context (colorscale->display,
+ gst_gl_display_create_context (colorscale->display,
50, y_pos++ * (colorscale->output_video_height+50) + 50,
- colorscale->output_video_width, colorscale->output_video_height,
+ colorscale->output_video_width, colorscale->output_video_height,
0, FALSE);
//blocking call, init colorspace conversion if needed
- gst_gl_display_init_upload (colorscale->display, colorscale->input_video_format,
+ gst_gl_display_init_upload (colorscale->display, colorscale->input_video_format,
colorscale->output_video_width, colorscale->output_video_height);
//blocking call, init colorspace conversion if needed
gint height;
structure = gst_caps_get_structure (caps, 0);
- if (gst_structure_has_name (structure, "video/x-raw-gl"))
+ if (gst_structure_has_name (structure, "video/x-raw-gl"))
{
ret = gst_gl_buffer_parse_caps (caps, &width, &height);
- if (ret)
+ if (ret)
*size = gst_gl_buffer_get_size (width, height);
- }
- else
+ }
+ else
{
GstVideoFormat video_format;
ret = gst_video_format_parse_caps (caps, &video_format, &width, &height);
- if (ret)
+ if (ret)
*size = gst_video_format_get_size (video_format, width, height);
}
GST_BUFFER_DATA (inbuf), GST_BUFFER_SIZE (inbuf));
//blocking call
- isAlive = gst_gl_display_do_upload (colorscale->display, gl_temp_buffer->texture,
- colorscale->input_video_width, colorscale->input_video_height,
+ isAlive = gst_gl_display_do_upload (colorscale->display, gl_temp_buffer->texture,
+ colorscale->input_video_width, colorscale->input_video_height,
GST_BUFFER_DATA (inbuf));
GST_DEBUG ("output size %p size %d",
GST_BUFFER_DATA (outbuf), GST_BUFFER_SIZE (outbuf));
//blocking call
- isAlive &= gst_gl_display_do_download(colorscale->display, gl_temp_buffer->texture,
- gl_temp_buffer->width, gl_temp_buffer->height,
+ isAlive &= gst_gl_display_do_download(colorscale->display, gl_temp_buffer->texture,
+ gl_temp_buffer->width, gl_temp_buffer->height,
GST_BUFFER_DATA (outbuf));
gst_buffer_unref (gl_temp_buffer);
if (isAlive)
return GST_FLOW_OK;
- else
+ else
return GST_FLOW_UNEXPECTED;
}
-/*
+/*
* GStreamer
* Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
*
#define GST_CAT_DEFAULT gst_gl_download_debug
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
-static const GstElementDetails element_details =
+static const GstElementDetails element_details =
GST_ELEMENT_DETAILS ("OpenGL video maker",
"Filter/Effect",
"A from GL to video flow filter",
{
//GstGLDownload *download = GST_GL_DOWNLOAD (object);
- switch (prop_id)
+ switch (prop_id)
{
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
static void
gst_gl_download_reset (GstGLDownload* download)
{
- if (download->display)
+ if (download->display)
{
g_object_unref (download->display);
download->display = NULL;
download = GST_GL_DOWNLOAD (bt);
- GST_ERROR ("transform caps %" GST_PTR_FORMAT, caps);
+ GST_DEBUG ("transform caps %" GST_PTR_FORMAT, caps);
structure = gst_caps_get_structure (caps, 0);
framerate_value = gst_structure_get_value (structure, "framerate");
par_value = gst_structure_get_value (structure, "pixel-aspect-ratio");
- if (direction == GST_PAD_SINK)
+ if (direction == GST_PAD_SINK)
{
newothercaps = gst_caps_new_simple ("video/x-raw-rgb", NULL);
newstruct = gst_caps_get_structure (newothercaps, 0);
1, 1, NULL);
newcaps = gst_caps_new_simple ("video/x-raw-yuv", NULL);
gst_caps_append(newcaps, newothercaps);
- }
+ }
else newcaps = gst_caps_new_simple ("video/x-raw-gl", NULL);
newstruct = gst_caps_get_structure (newcaps, 0);
gst_structure_set (newstruct, "pixel-aspect-ratio", GST_TYPE_FRACTION,
1, 1, NULL);
- GST_ERROR ("new caps %" GST_PTR_FORMAT, newcaps);
+ GST_DEBUG ("new caps %" GST_PTR_FORMAT, newcaps);
return newcaps;
}
ret = gst_video_format_parse_caps (outcaps, &download->video_format,
&download->width, &download->height);
- if (!ret)
+ if (!ret)
{
GST_ERROR ("bad caps");
return FALSE;
gint height;
structure = gst_caps_get_structure (caps, 0);
- if (gst_structure_has_name (structure, "video/x-raw-gl"))
+ if (gst_structure_has_name (structure, "video/x-raw-gl"))
{
ret = gst_gl_buffer_parse_caps (caps, &width, &height);
- if (ret)
+ if (ret)
*size = gst_gl_buffer_get_size (width, height);
- }
- else
+ }
+ else
{
GstVideoFormat video_format;
ret = gst_video_format_parse_caps (caps, &video_format, &width, &height);
- if (ret)
+ if (ret)
*size = gst_video_format_get_size (video_format, width, height);
}
GstGLDownload* download = GST_GL_DOWNLOAD (trans);
GstGLBuffer* gl_inbuf = GST_GL_BUFFER (inbuf);
- if (download->display == NULL)
+ if (download->display == NULL)
{
download->display = g_object_ref (gl_inbuf->display);
gst_gl_display_init_download (download->display, download->video_format,
download->width, download->height);
}
- else
+ else
g_assert (download->display == gl_inbuf->display);
GST_DEBUG ("making video %p size %d",
GST_BUFFER_DATA (outbuf), GST_BUFFER_SIZE (outbuf));
//blocking call
- if (gst_gl_display_do_download(download->display, gl_inbuf->texture,
+ if (gst_gl_display_do_download(download->display, gl_inbuf->texture,
gl_inbuf->width, gl_inbuf->height, GST_BUFFER_DATA (outbuf)))
return GST_FLOW_OK;
else