mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-07-10 08:35:58 +00:00
goom: clean dereferences of private structure
https://bugzilla.gnome.org/show_bug.cgi?id=742875
This commit is contained in:
parent
fce8e5fb26
commit
0b8c7ab797
|
@ -2,7 +2,7 @@
|
||||||
* Copyright (C) <2011> Stefan Kost <ensonic@users.sf.net>
|
* Copyright (C) <2011> Stefan Kost <ensonic@users.sf.net>
|
||||||
* Copyright (C) <2015> Luis de Bethencourt <luis@debethencourt.com>
|
* Copyright (C) <2015> Luis de Bethencourt <luis@debethencourt.com>
|
||||||
*
|
*
|
||||||
* gstaudiovisualizer.h: class for audio visualisation elements
|
* gstaudiovisualizer.c: class for audio visualisation elements
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -63,7 +63,7 @@ static void gst_audio_visualizer_set_property (GObject * object,
|
||||||
guint prop_id, const GValue * value, GParamSpec * pspec);
|
guint prop_id, const GValue * value, GParamSpec * pspec);
|
||||||
static void gst_audio_visualizer_get_property (GObject * object,
|
static void gst_audio_visualizer_get_property (GObject * object,
|
||||||
guint prop_id, GValue * value, GParamSpec * pspec);
|
guint prop_id, GValue * value, GParamSpec * pspec);
|
||||||
static void gst_audio_visualizer_dispose (GObject * object);
|
static void gst_audio_visualizer_finalize (GObject * object);
|
||||||
|
|
||||||
static gboolean gst_audio_visualizer_src_negotiate (GstAudioVisualizer * scope);
|
static gboolean gst_audio_visualizer_src_negotiate (GstAudioVisualizer * scope);
|
||||||
static gboolean gst_audio_visualizer_src_setcaps (GstAudioVisualizer *
|
static gboolean gst_audio_visualizer_src_setcaps (GstAudioVisualizer *
|
||||||
|
@ -199,9 +199,10 @@ shader_fade (GstAudioVisualizer * scope, const GstVideoFrame * sframe,
|
||||||
GstVideoFrame * dframe)
|
GstVideoFrame * dframe)
|
||||||
{
|
{
|
||||||
guint i, j;
|
guint i, j;
|
||||||
guint r = (scope->priv->shade_amount >> 16) & 0xff;
|
guint32 shade_amount = scope->priv->shade_amount;
|
||||||
guint g = (scope->priv->shade_amount >> 8) & 0xff;
|
guint r = (shade_amount >> 16) & 0xff;
|
||||||
guint b = (scope->priv->shade_amount >> 0) & 0xff;
|
guint g = (shade_amount >> 8) & 0xff;
|
||||||
|
guint b = (shade_amount >> 0) & 0xff;
|
||||||
guint8 *s, *d;
|
guint8 *s, *d;
|
||||||
gint ss, ds, width, height;
|
gint ss, ds, width, height;
|
||||||
|
|
||||||
|
@ -227,9 +228,10 @@ shader_fade_and_move_up (GstAudioVisualizer * scope,
|
||||||
const GstVideoFrame * sframe, GstVideoFrame * dframe)
|
const GstVideoFrame * sframe, GstVideoFrame * dframe)
|
||||||
{
|
{
|
||||||
guint i, j;
|
guint i, j;
|
||||||
guint r = (scope->priv->shade_amount >> 16) & 0xff;
|
guint32 shade_amount = scope->priv->shade_amount;
|
||||||
guint g = (scope->priv->shade_amount >> 8) & 0xff;
|
guint r = (shade_amount >> 16) & 0xff;
|
||||||
guint b = (scope->priv->shade_amount >> 0) & 0xff;
|
guint g = (shade_amount >> 8) & 0xff;
|
||||||
|
guint b = (shade_amount >> 0) & 0xff;
|
||||||
guint8 *s, *d;
|
guint8 *s, *d;
|
||||||
gint ss, ds, width, height;
|
gint ss, ds, width, height;
|
||||||
|
|
||||||
|
@ -255,9 +257,10 @@ shader_fade_and_move_down (GstAudioVisualizer * scope,
|
||||||
const GstVideoFrame * sframe, GstVideoFrame * dframe)
|
const GstVideoFrame * sframe, GstVideoFrame * dframe)
|
||||||
{
|
{
|
||||||
guint i, j;
|
guint i, j;
|
||||||
guint r = (scope->priv->shade_amount >> 16) & 0xff;
|
guint32 shade_amount = scope->priv->shade_amount;
|
||||||
guint g = (scope->priv->shade_amount >> 8) & 0xff;
|
guint r = (shade_amount >> 16) & 0xff;
|
||||||
guint b = (scope->priv->shade_amount >> 0) & 0xff;
|
guint g = (shade_amount >> 8) & 0xff;
|
||||||
|
guint b = (shade_amount >> 0) & 0xff;
|
||||||
guint8 *s, *d;
|
guint8 *s, *d;
|
||||||
gint ss, ds, width, height;
|
gint ss, ds, width, height;
|
||||||
|
|
||||||
|
@ -283,9 +286,10 @@ shader_fade_and_move_left (GstAudioVisualizer * scope,
|
||||||
const GstVideoFrame * sframe, GstVideoFrame * dframe)
|
const GstVideoFrame * sframe, GstVideoFrame * dframe)
|
||||||
{
|
{
|
||||||
guint i, j;
|
guint i, j;
|
||||||
guint r = (scope->priv->shade_amount >> 16) & 0xff;
|
guint32 shade_amount = scope->priv->shade_amount;
|
||||||
guint g = (scope->priv->shade_amount >> 8) & 0xff;
|
guint r = (shade_amount >> 16) & 0xff;
|
||||||
guint b = (scope->priv->shade_amount >> 0) & 0xff;
|
guint g = (shade_amount >> 8) & 0xff;
|
||||||
|
guint b = (shade_amount >> 0) & 0xff;
|
||||||
guint8 *s, *d;
|
guint8 *s, *d;
|
||||||
gint ss, ds, width, height;
|
gint ss, ds, width, height;
|
||||||
|
|
||||||
|
@ -315,9 +319,10 @@ shader_fade_and_move_right (GstAudioVisualizer * scope,
|
||||||
const GstVideoFrame * sframe, GstVideoFrame * dframe)
|
const GstVideoFrame * sframe, GstVideoFrame * dframe)
|
||||||
{
|
{
|
||||||
guint i, j;
|
guint i, j;
|
||||||
guint r = (scope->priv->shade_amount >> 16) & 0xff;
|
guint32 shade_amount = scope->priv->shade_amount;
|
||||||
guint g = (scope->priv->shade_amount >> 8) & 0xff;
|
guint r = (shade_amount >> 16) & 0xff;
|
||||||
guint b = (scope->priv->shade_amount >> 0) & 0xff;
|
guint g = (shade_amount >> 8) & 0xff;
|
||||||
|
guint b = (shade_amount >> 0) & 0xff;
|
||||||
guint8 *s, *d;
|
guint8 *s, *d;
|
||||||
gint ss, ds, width, height;
|
gint ss, ds, width, height;
|
||||||
|
|
||||||
|
@ -347,9 +352,10 @@ shader_fade_and_move_horiz_out (GstAudioVisualizer * scope,
|
||||||
const GstVideoFrame * sframe, GstVideoFrame * dframe)
|
const GstVideoFrame * sframe, GstVideoFrame * dframe)
|
||||||
{
|
{
|
||||||
guint i, j;
|
guint i, j;
|
||||||
guint r = (scope->priv->shade_amount >> 16) & 0xff;
|
guint32 shade_amount = scope->priv->shade_amount;
|
||||||
guint g = (scope->priv->shade_amount >> 8) & 0xff;
|
guint r = (shade_amount >> 16) & 0xff;
|
||||||
guint b = (scope->priv->shade_amount >> 0) & 0xff;
|
guint g = (shade_amount >> 8) & 0xff;
|
||||||
|
guint b = (shade_amount >> 0) & 0xff;
|
||||||
guint8 *s, *d;
|
guint8 *s, *d;
|
||||||
gint ss, ds, width, height;
|
gint ss, ds, width, height;
|
||||||
|
|
||||||
|
@ -384,9 +390,10 @@ shader_fade_and_move_horiz_in (GstAudioVisualizer * scope,
|
||||||
const GstVideoFrame * sframe, GstVideoFrame * dframe)
|
const GstVideoFrame * sframe, GstVideoFrame * dframe)
|
||||||
{
|
{
|
||||||
guint i, j;
|
guint i, j;
|
||||||
guint r = (scope->priv->shade_amount >> 16) & 0xff;
|
guint32 shade_amount = scope->priv->shade_amount;
|
||||||
guint g = (scope->priv->shade_amount >> 8) & 0xff;
|
guint r = (shade_amount >> 16) & 0xff;
|
||||||
guint b = (scope->priv->shade_amount >> 0) & 0xff;
|
guint g = (shade_amount >> 8) & 0xff;
|
||||||
|
guint b = (shade_amount >> 0) & 0xff;
|
||||||
guint8 *s, *d;
|
guint8 *s, *d;
|
||||||
gint ss, ds, width, height;
|
gint ss, ds, width, height;
|
||||||
|
|
||||||
|
@ -421,9 +428,10 @@ shader_fade_and_move_vert_out (GstAudioVisualizer * scope,
|
||||||
const GstVideoFrame * sframe, GstVideoFrame * dframe)
|
const GstVideoFrame * sframe, GstVideoFrame * dframe)
|
||||||
{
|
{
|
||||||
guint i, j;
|
guint i, j;
|
||||||
guint r = (scope->priv->shade_amount >> 16) & 0xff;
|
guint32 shade_amount = scope->priv->shade_amount;
|
||||||
guint g = (scope->priv->shade_amount >> 8) & 0xff;
|
guint r = (shade_amount >> 16) & 0xff;
|
||||||
guint b = (scope->priv->shade_amount >> 0) & 0xff;
|
guint g = (shade_amount >> 8) & 0xff;
|
||||||
|
guint b = (shade_amount >> 0) & 0xff;
|
||||||
guint8 *s, *s1, *d, *d1;
|
guint8 *s, *s1, *d, *d1;
|
||||||
gint ss, ds, width, height;
|
gint ss, ds, width, height;
|
||||||
|
|
||||||
|
@ -456,9 +464,10 @@ shader_fade_and_move_vert_in (GstAudioVisualizer * scope,
|
||||||
const GstVideoFrame * sframe, GstVideoFrame * dframe)
|
const GstVideoFrame * sframe, GstVideoFrame * dframe)
|
||||||
{
|
{
|
||||||
guint i, j;
|
guint i, j;
|
||||||
guint r = (scope->priv->shade_amount >> 16) & 0xff;
|
guint32 shade_amount = scope->priv->shade_amount;
|
||||||
guint g = (scope->priv->shade_amount >> 8) & 0xff;
|
guint r = (shade_amount >> 16) & 0xff;
|
||||||
guint b = (scope->priv->shade_amount >> 0) & 0xff;
|
guint g = (shade_amount >> 8) & 0xff;
|
||||||
|
guint b = (shade_amount >> 0) & 0xff;
|
||||||
guint8 *s, *s1, *d, *d1;
|
guint8 *s, *s1, *d, *d1;
|
||||||
gint ss, ds, width, height;
|
gint ss, ds, width, height;
|
||||||
|
|
||||||
|
@ -489,42 +498,46 @@ shader_fade_and_move_vert_in (GstAudioVisualizer * scope,
|
||||||
static void
|
static void
|
||||||
gst_audio_visualizer_change_shader (GstAudioVisualizer * scope)
|
gst_audio_visualizer_change_shader (GstAudioVisualizer * scope)
|
||||||
{
|
{
|
||||||
|
GstAudioVisualizerShaderFunc shader;
|
||||||
|
|
||||||
switch (scope->priv->shader_type) {
|
switch (scope->priv->shader_type) {
|
||||||
case GST_AUDIO_VISUALIZER_SHADER_NONE:
|
case GST_AUDIO_VISUALIZER_SHADER_NONE:
|
||||||
scope->priv->shader = NULL;
|
shader = NULL;
|
||||||
break;
|
break;
|
||||||
case GST_AUDIO_VISUALIZER_SHADER_FADE:
|
case GST_AUDIO_VISUALIZER_SHADER_FADE:
|
||||||
scope->priv->shader = shader_fade;
|
shader = shader_fade;
|
||||||
break;
|
break;
|
||||||
case GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_UP:
|
case GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_UP:
|
||||||
scope->priv->shader = shader_fade_and_move_up;
|
shader = shader_fade_and_move_up;
|
||||||
break;
|
break;
|
||||||
case GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_DOWN:
|
case GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_DOWN:
|
||||||
scope->priv->shader = shader_fade_and_move_down;
|
shader = shader_fade_and_move_down;
|
||||||
break;
|
break;
|
||||||
case GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_LEFT:
|
case GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_LEFT:
|
||||||
scope->priv->shader = shader_fade_and_move_left;
|
shader = shader_fade_and_move_left;
|
||||||
break;
|
break;
|
||||||
case GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_RIGHT:
|
case GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_RIGHT:
|
||||||
scope->priv->shader = shader_fade_and_move_right;
|
shader = shader_fade_and_move_right;
|
||||||
break;
|
break;
|
||||||
case GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_HORIZ_OUT:
|
case GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_HORIZ_OUT:
|
||||||
scope->priv->shader = shader_fade_and_move_horiz_out;
|
shader = shader_fade_and_move_horiz_out;
|
||||||
break;
|
break;
|
||||||
case GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_HORIZ_IN:
|
case GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_HORIZ_IN:
|
||||||
scope->priv->shader = shader_fade_and_move_horiz_in;
|
shader = shader_fade_and_move_horiz_in;
|
||||||
break;
|
break;
|
||||||
case GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_VERT_OUT:
|
case GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_VERT_OUT:
|
||||||
scope->priv->shader = shader_fade_and_move_vert_out;
|
shader = shader_fade_and_move_vert_out;
|
||||||
break;
|
break;
|
||||||
case GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_VERT_IN:
|
case GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_VERT_IN:
|
||||||
scope->priv->shader = shader_fade_and_move_vert_in;
|
shader = shader_fade_and_move_vert_in;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
GST_ERROR ("invalid shader function");
|
GST_ERROR ("invalid shader function");
|
||||||
scope->priv->shader = NULL;
|
shader = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scope->priv->shader = shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* class */
|
/* class */
|
||||||
|
@ -550,7 +563,7 @@ gst_audio_visualizer_get_type (void)
|
||||||
|
|
||||||
/* TODO: rename when exporting it as a library */
|
/* TODO: rename when exporting it as a library */
|
||||||
_type = g_type_register_static (GST_TYPE_ELEMENT,
|
_type = g_type_register_static (GST_TYPE_ELEMENT,
|
||||||
"GstAudioVisualizer-ExtGom", &audio_visualizer_info,
|
"GstAudioVisualizer-ExtGoom", &audio_visualizer_info,
|
||||||
G_TYPE_FLAG_ABSTRACT);
|
G_TYPE_FLAG_ABSTRACT);
|
||||||
g_once_init_leave (&audio_visualizer_type, _type);
|
g_once_init_leave (&audio_visualizer_type, _type);
|
||||||
}
|
}
|
||||||
|
@ -572,7 +585,7 @@ gst_audio_visualizer_class_init (GstAudioVisualizerClass * klass)
|
||||||
|
|
||||||
gobject_class->set_property = gst_audio_visualizer_set_property;
|
gobject_class->set_property = gst_audio_visualizer_set_property;
|
||||||
gobject_class->get_property = gst_audio_visualizer_get_property;
|
gobject_class->get_property = gst_audio_visualizer_get_property;
|
||||||
gobject_class->dispose = gst_audio_visualizer_dispose;
|
gobject_class->finalize = gst_audio_visualizer_finalize;
|
||||||
|
|
||||||
element_class->change_state =
|
element_class->change_state =
|
||||||
GST_DEBUG_FUNCPTR (gst_audio_visualizer_change_state);
|
GST_DEBUG_FUNCPTR (gst_audio_visualizer_change_state);
|
||||||
|
@ -679,41 +692,43 @@ gst_audio_visualizer_get_property (GObject * object, guint prop_id,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_audio_visualizer_dispose (GObject * object)
|
gst_audio_visualizer_finalize (GObject * object)
|
||||||
{
|
{
|
||||||
GstAudioVisualizer *scope = GST_AUDIO_VISUALIZER (object);
|
GstAudioVisualizer *scope = GST_AUDIO_VISUALIZER (object);
|
||||||
|
GstAudioVisualizerPrivate *priv = scope->priv;
|
||||||
|
|
||||||
if (scope->priv->adapter) {
|
if (priv->adapter) {
|
||||||
g_object_unref (scope->priv->adapter);
|
g_object_unref (priv->adapter);
|
||||||
scope->priv->adapter = NULL;
|
priv->adapter = NULL;
|
||||||
}
|
}
|
||||||
if (scope->priv->inbuf) {
|
if (priv->inbuf) {
|
||||||
gst_buffer_unref (scope->priv->inbuf);
|
gst_buffer_unref (priv->inbuf);
|
||||||
scope->priv->inbuf = NULL;
|
priv->inbuf = NULL;
|
||||||
}
|
}
|
||||||
if (scope->priv->tempbuf) {
|
if (priv->tempbuf) {
|
||||||
gst_video_frame_unmap (&scope->priv->tempframe);
|
gst_video_frame_unmap (&priv->tempframe);
|
||||||
gst_buffer_unref (scope->priv->tempbuf);
|
gst_buffer_unref (priv->tempbuf);
|
||||||
scope->priv->tempbuf = NULL;
|
priv->tempbuf = NULL;
|
||||||
}
|
}
|
||||||
if (scope->priv->config_lock.p) {
|
|
||||||
g_mutex_clear (&scope->priv->config_lock);
|
g_mutex_clear (&priv->config_lock);
|
||||||
scope->priv->config_lock.p = NULL;
|
|
||||||
}
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_audio_visualizer_reset (GstAudioVisualizer * scope)
|
gst_audio_visualizer_reset (GstAudioVisualizer * scope)
|
||||||
{
|
{
|
||||||
gst_adapter_clear (scope->priv->adapter);
|
GstAudioVisualizerPrivate *priv = scope->priv;
|
||||||
gst_segment_init (&scope->priv->segment, GST_FORMAT_UNDEFINED);
|
|
||||||
|
gst_adapter_clear (priv->adapter);
|
||||||
|
gst_segment_init (&priv->segment, GST_FORMAT_UNDEFINED);
|
||||||
|
|
||||||
GST_OBJECT_LOCK (scope);
|
GST_OBJECT_LOCK (scope);
|
||||||
scope->priv->proportion = 1.0;
|
priv->proportion = 1.0;
|
||||||
scope->priv->earliest_time = -1;
|
priv->earliest_time = -1;
|
||||||
scope->priv->dropped = 0;
|
priv->dropped = 0;
|
||||||
scope->priv->processed = 0;
|
priv->processed = 0;
|
||||||
GST_OBJECT_UNLOCK (scope);
|
GST_OBJECT_UNLOCK (scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -754,6 +769,7 @@ gst_audio_visualizer_src_setcaps (GstAudioVisualizer * scope, GstCaps * caps)
|
||||||
{
|
{
|
||||||
GstVideoInfo info;
|
GstVideoInfo info;
|
||||||
GstAudioVisualizerClass *klass;
|
GstAudioVisualizerClass *klass;
|
||||||
|
GstAudioVisualizerPrivate *priv;
|
||||||
gboolean res;
|
gboolean res;
|
||||||
|
|
||||||
if (!gst_video_info_from_caps (&info, caps))
|
if (!gst_video_info_from_caps (&info, caps))
|
||||||
|
@ -761,23 +777,24 @@ gst_audio_visualizer_src_setcaps (GstAudioVisualizer * scope, GstCaps * caps)
|
||||||
|
|
||||||
klass = GST_AUDIO_VISUALIZER_CLASS (G_OBJECT_GET_CLASS (scope));
|
klass = GST_AUDIO_VISUALIZER_CLASS (G_OBJECT_GET_CLASS (scope));
|
||||||
|
|
||||||
|
priv = scope->priv;
|
||||||
|
|
||||||
scope->vinfo = info;
|
scope->vinfo = info;
|
||||||
|
|
||||||
scope->priv->frame_duration = gst_util_uint64_scale_int (GST_SECOND,
|
priv->frame_duration = gst_util_uint64_scale_int (GST_SECOND,
|
||||||
GST_VIDEO_INFO_FPS_D (&info), GST_VIDEO_INFO_FPS_N (&info));
|
GST_VIDEO_INFO_FPS_D (&info), GST_VIDEO_INFO_FPS_N (&info));
|
||||||
scope->priv->spf =
|
priv->spf = gst_util_uint64_scale_int (GST_AUDIO_INFO_RATE (&scope->ainfo),
|
||||||
gst_util_uint64_scale_int (GST_AUDIO_INFO_RATE (&scope->ainfo),
|
|
||||||
GST_VIDEO_INFO_FPS_D (&info), GST_VIDEO_INFO_FPS_N (&info));
|
GST_VIDEO_INFO_FPS_D (&info), GST_VIDEO_INFO_FPS_N (&info));
|
||||||
scope->req_spf = scope->priv->spf;
|
scope->req_spf = priv->spf;
|
||||||
|
|
||||||
if (scope->priv->tempbuf) {
|
if (priv->tempbuf) {
|
||||||
gst_video_frame_unmap (&scope->priv->tempframe);
|
gst_video_frame_unmap (&priv->tempframe);
|
||||||
gst_buffer_unref (scope->priv->tempbuf);
|
gst_buffer_unref (priv->tempbuf);
|
||||||
}
|
}
|
||||||
scope->priv->tempbuf = gst_buffer_new_wrapped (g_malloc0 (scope->vinfo.size),
|
priv->tempbuf = gst_buffer_new_wrapped (g_malloc0 (scope->vinfo.size),
|
||||||
scope->vinfo.size);
|
scope->vinfo.size);
|
||||||
gst_video_frame_map (&scope->priv->tempframe, &scope->vinfo,
|
gst_video_frame_map (&priv->tempframe, &scope->vinfo, priv->tempbuf,
|
||||||
scope->priv->tempbuf, GST_MAP_READWRITE);
|
GST_MAP_READWRITE);
|
||||||
|
|
||||||
if (klass->setup && !klass->setup (scope))
|
if (klass->setup && !klass->setup (scope))
|
||||||
goto setup_failed;
|
goto setup_failed;
|
||||||
|
@ -785,10 +802,10 @@ gst_audio_visualizer_src_setcaps (GstAudioVisualizer * scope, GstCaps * caps)
|
||||||
GST_DEBUG_OBJECT (scope, "video: dimension %dx%d, framerate %d/%d",
|
GST_DEBUG_OBJECT (scope, "video: dimension %dx%d, framerate %d/%d",
|
||||||
GST_VIDEO_INFO_WIDTH (&info), GST_VIDEO_INFO_HEIGHT (&info),
|
GST_VIDEO_INFO_WIDTH (&info), GST_VIDEO_INFO_HEIGHT (&info),
|
||||||
GST_VIDEO_INFO_FPS_N (&info), GST_VIDEO_INFO_FPS_D (&info));
|
GST_VIDEO_INFO_FPS_N (&info), GST_VIDEO_INFO_FPS_D (&info));
|
||||||
GST_DEBUG_OBJECT (scope, "blocks: spf %u, req_spf %u",
|
GST_DEBUG_OBJECT (scope, "blocks: spf %u, req_spf %u", priv->spf,
|
||||||
scope->priv->spf, scope->req_spf);
|
scope->req_spf);
|
||||||
|
|
||||||
gst_pad_set_caps (scope->priv->srcpad, caps);
|
gst_pad_set_caps (priv->srcpad, caps);
|
||||||
|
|
||||||
/* find a pool for the negotiated caps now */
|
/* find a pool for the negotiated caps now */
|
||||||
res = gst_audio_visualizer_do_bufferpool (scope, caps);
|
res = gst_audio_visualizer_do_bufferpool (scope, caps);
|
||||||
|
@ -1064,6 +1081,7 @@ gst_audio_visualizer_chain (GstPad * pad, GstObject * parent,
|
||||||
{
|
{
|
||||||
GstFlowReturn ret = GST_FLOW_OK;
|
GstFlowReturn ret = GST_FLOW_OK;
|
||||||
GstAudioVisualizer *scope;
|
GstAudioVisualizer *scope;
|
||||||
|
GstAudioVisualizerPrivate *priv;
|
||||||
GstAudioVisualizerClass *klass;
|
GstAudioVisualizerClass *klass;
|
||||||
GstBuffer *inbuf;
|
GstBuffer *inbuf;
|
||||||
guint64 dist, ts;
|
guint64 dist, ts;
|
||||||
|
@ -1072,19 +1090,20 @@ gst_audio_visualizer_chain (GstPad * pad, GstObject * parent,
|
||||||
gint bps, channels, rate;
|
gint bps, channels, rate;
|
||||||
|
|
||||||
scope = GST_AUDIO_VISUALIZER (parent);
|
scope = GST_AUDIO_VISUALIZER (parent);
|
||||||
|
priv = scope->priv;
|
||||||
klass = GST_AUDIO_VISUALIZER_CLASS (G_OBJECT_GET_CLASS (scope));
|
klass = GST_AUDIO_VISUALIZER_CLASS (G_OBJECT_GET_CLASS (scope));
|
||||||
|
|
||||||
GST_LOG_OBJECT (scope, "chainfunc called");
|
GST_LOG_OBJECT (scope, "chainfunc called");
|
||||||
|
|
||||||
/* resync on DISCONT */
|
/* resync on DISCONT */
|
||||||
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT)) {
|
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT)) {
|
||||||
gst_adapter_clear (scope->priv->adapter);
|
gst_adapter_clear (priv->adapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure have an output format */
|
/* Make sure have an output format */
|
||||||
if (gst_pad_check_reconfigure (scope->priv->srcpad)) {
|
if (gst_pad_check_reconfigure (priv->srcpad)) {
|
||||||
if (!gst_audio_visualizer_src_negotiate (scope)) {
|
if (!gst_audio_visualizer_src_negotiate (scope)) {
|
||||||
gst_pad_mark_reconfigure (scope->priv->srcpad);
|
gst_pad_mark_reconfigure (priv->srcpad);
|
||||||
goto not_negotiated;
|
goto not_negotiated;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1098,26 +1117,26 @@ gst_audio_visualizer_chain (GstPad * pad, GstObject * parent,
|
||||||
goto beach;
|
goto beach;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_adapter_push (scope->priv->adapter, buffer);
|
gst_adapter_push (priv->adapter, buffer);
|
||||||
|
|
||||||
g_mutex_lock (&scope->priv->config_lock);
|
g_mutex_lock (&priv->config_lock);
|
||||||
|
|
||||||
/* this is what we want */
|
/* this is what we want */
|
||||||
sbpf = scope->req_spf * channels * sizeof (gint16);
|
sbpf = scope->req_spf * channels * sizeof (gint16);
|
||||||
|
|
||||||
inbuf = scope->priv->inbuf;
|
inbuf = priv->inbuf;
|
||||||
/* FIXME: the timestamp in the adapter would be different */
|
/* FIXME: the timestamp in the adapter would be different */
|
||||||
gst_buffer_copy_into (inbuf, buffer, GST_BUFFER_COPY_METADATA, 0, -1);
|
gst_buffer_copy_into (inbuf, buffer, GST_BUFFER_COPY_METADATA, 0, -1);
|
||||||
|
|
||||||
/* this is what we have */
|
/* this is what we have */
|
||||||
avail = gst_adapter_available (scope->priv->adapter);
|
avail = gst_adapter_available (priv->adapter);
|
||||||
GST_LOG_OBJECT (scope, "avail: %u, bpf: %u", avail, sbpf);
|
GST_LOG_OBJECT (scope, "avail: %u, bpf: %u", avail, sbpf);
|
||||||
while (avail >= sbpf) {
|
while (avail >= sbpf) {
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
GstVideoFrame outframe;
|
GstVideoFrame outframe;
|
||||||
|
|
||||||
/* get timestamp of the current adapter content */
|
/* get timestamp of the current adapter content */
|
||||||
ts = gst_adapter_prev_pts (scope->priv->adapter, &dist);
|
ts = gst_adapter_prev_pts (priv->adapter, &dist);
|
||||||
if (GST_CLOCK_TIME_IS_VALID (ts)) {
|
if (GST_CLOCK_TIME_IS_VALID (ts)) {
|
||||||
/* convert bytes to time */
|
/* convert bytes to time */
|
||||||
dist /= bps;
|
dist /= bps;
|
||||||
|
@ -1131,12 +1150,12 @@ gst_audio_visualizer_chain (GstPad * pad, GstObject * parent,
|
||||||
gint64 qostime;
|
gint64 qostime;
|
||||||
|
|
||||||
qostime =
|
qostime =
|
||||||
gst_segment_to_running_time (&scope->priv->segment,
|
gst_segment_to_running_time (&priv->segment, GST_FORMAT_TIME,
|
||||||
GST_FORMAT_TIME, ts) + scope->priv->frame_duration;
|
ts) + priv->frame_duration;
|
||||||
|
|
||||||
GST_OBJECT_LOCK (scope);
|
GST_OBJECT_LOCK (scope);
|
||||||
earliest_time = scope->priv->earliest_time;
|
earliest_time = priv->earliest_time;
|
||||||
proportion = scope->priv->proportion;
|
proportion = priv->proportion;
|
||||||
GST_OBJECT_UNLOCK (scope);
|
GST_OBJECT_UNLOCK (scope);
|
||||||
|
|
||||||
if (GST_CLOCK_TIME_IS_VALID (earliest_time) && qostime <= earliest_time) {
|
if (GST_CLOCK_TIME_IS_VALID (earliest_time) && qostime <= earliest_time) {
|
||||||
|
@ -1147,26 +1166,26 @@ gst_audio_visualizer_chain (GstPad * pad, GstObject * parent,
|
||||||
"QoS: skip ts: %" GST_TIME_FORMAT ", earliest: %" GST_TIME_FORMAT,
|
"QoS: skip ts: %" GST_TIME_FORMAT ", earliest: %" GST_TIME_FORMAT,
|
||||||
GST_TIME_ARGS (qostime), GST_TIME_ARGS (earliest_time));
|
GST_TIME_ARGS (qostime), GST_TIME_ARGS (earliest_time));
|
||||||
|
|
||||||
++scope->priv->dropped;
|
++priv->dropped;
|
||||||
stream_time = gst_segment_to_stream_time (&scope->priv->segment,
|
stream_time = gst_segment_to_stream_time (&priv->segment,
|
||||||
GST_FORMAT_TIME, ts);
|
GST_FORMAT_TIME, ts);
|
||||||
jitter = GST_CLOCK_DIFF (qostime, earliest_time);
|
jitter = GST_CLOCK_DIFF (qostime, earliest_time);
|
||||||
qos_msg = gst_message_new_qos (GST_OBJECT (scope), FALSE, qostime,
|
qos_msg = gst_message_new_qos (GST_OBJECT (scope), FALSE, qostime,
|
||||||
stream_time, ts, GST_BUFFER_DURATION (buffer));
|
stream_time, ts, GST_BUFFER_DURATION (buffer));
|
||||||
gst_message_set_qos_values (qos_msg, jitter, proportion, 1000000);
|
gst_message_set_qos_values (qos_msg, jitter, proportion, 1000000);
|
||||||
gst_message_set_qos_stats (qos_msg, GST_FORMAT_BUFFERS,
|
gst_message_set_qos_stats (qos_msg, GST_FORMAT_BUFFERS,
|
||||||
scope->priv->processed, scope->priv->dropped);
|
priv->processed, priv->dropped);
|
||||||
gst_element_post_message (GST_ELEMENT (scope), qos_msg);
|
gst_element_post_message (GST_ELEMENT (scope), qos_msg);
|
||||||
|
|
||||||
goto skip;
|
goto skip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
++scope->priv->processed;
|
++priv->processed;
|
||||||
|
|
||||||
g_mutex_unlock (&scope->priv->config_lock);
|
g_mutex_unlock (&priv->config_lock);
|
||||||
ret = default_prepare_output_buffer (scope, &outbuf);
|
ret = default_prepare_output_buffer (scope, &outbuf);
|
||||||
g_mutex_lock (&scope->priv->config_lock);
|
g_mutex_lock (&priv->config_lock);
|
||||||
/* recheck as the value could have changed */
|
/* recheck as the value could have changed */
|
||||||
sbpf = scope->req_spf * channels * sizeof (gint16);
|
sbpf = scope->req_spf * channels * sizeof (gint16);
|
||||||
|
|
||||||
|
@ -1179,16 +1198,16 @@ gst_audio_visualizer_chain (GstPad * pad, GstObject * parent,
|
||||||
gst_object_sync_values (GST_OBJECT (scope), ts);
|
gst_object_sync_values (GST_OBJECT (scope), ts);
|
||||||
|
|
||||||
GST_BUFFER_TIMESTAMP (outbuf) = ts;
|
GST_BUFFER_TIMESTAMP (outbuf) = ts;
|
||||||
GST_BUFFER_DURATION (outbuf) = scope->priv->frame_duration;
|
GST_BUFFER_DURATION (outbuf) = priv->frame_duration;
|
||||||
|
|
||||||
/* this can fail as the data size we need could have changed */
|
/* this can fail as the data size we need could have changed */
|
||||||
if (!(adata = (gpointer) gst_adapter_map (scope->priv->adapter, sbpf)))
|
if (!(adata = (gpointer) gst_adapter_map (priv->adapter, sbpf)))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
gst_video_frame_map (&outframe, &scope->vinfo, outbuf, GST_MAP_READWRITE);
|
gst_video_frame_map (&outframe, &scope->vinfo, outbuf, GST_MAP_READWRITE);
|
||||||
|
|
||||||
if (scope->priv->shader) {
|
if (priv->shader) {
|
||||||
gst_video_frame_copy (&outframe, &scope->priv->tempframe);
|
gst_video_frame_copy (&outframe, &priv->tempframe);
|
||||||
} else {
|
} else {
|
||||||
/* gst_video_frame_clear() or is output frame already cleared */
|
/* gst_video_frame_clear() or is output frame already cleared */
|
||||||
gint i;
|
gint i;
|
||||||
|
@ -1211,18 +1230,17 @@ gst_audio_visualizer_chain (GstPad * pad, GstObject * parent,
|
||||||
} else {
|
} else {
|
||||||
/* run various post processing (shading and geometric transformation) */
|
/* run various post processing (shading and geometric transformation) */
|
||||||
/* FIXME: SHADER assumes 32bpp */
|
/* FIXME: SHADER assumes 32bpp */
|
||||||
if (scope->priv->shader &&
|
if (priv->shader && GST_VIDEO_INFO_COMP_PSTRIDE (&scope->vinfo, 0) == 4) {
|
||||||
GST_VIDEO_INFO_COMP_PSTRIDE (&scope->vinfo, 0) == 4) {
|
priv->shader (scope, &outframe, &priv->tempframe);
|
||||||
scope->priv->shader (scope, &outframe, &scope->priv->tempframe);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gst_video_frame_unmap (&outframe);
|
gst_video_frame_unmap (&outframe);
|
||||||
|
|
||||||
g_mutex_unlock (&scope->priv->config_lock);
|
g_mutex_unlock (&priv->config_lock);
|
||||||
ret = gst_pad_push (scope->priv->srcpad, outbuf);
|
ret = gst_pad_push (priv->srcpad, outbuf);
|
||||||
outbuf = NULL;
|
outbuf = NULL;
|
||||||
g_mutex_lock (&scope->priv->config_lock);
|
g_mutex_lock (&priv->config_lock);
|
||||||
|
|
||||||
skip:
|
skip:
|
||||||
/* recheck as the value could have changed */
|
/* recheck as the value could have changed */
|
||||||
|
@ -1230,21 +1248,21 @@ gst_audio_visualizer_chain (GstPad * pad, GstObject * parent,
|
||||||
GST_LOG_OBJECT (scope, "avail: %u, bpf: %u", avail, sbpf);
|
GST_LOG_OBJECT (scope, "avail: %u, bpf: %u", avail, sbpf);
|
||||||
/* we want to take less or more, depending on spf : req_spf */
|
/* we want to take less or more, depending on spf : req_spf */
|
||||||
if (avail - sbpf >= sbpf) {
|
if (avail - sbpf >= sbpf) {
|
||||||
gst_adapter_flush (scope->priv->adapter, sbpf);
|
gst_adapter_flush (priv->adapter, sbpf);
|
||||||
gst_adapter_unmap (scope->priv->adapter);
|
gst_adapter_unmap (priv->adapter);
|
||||||
} else if (avail >= sbpf) {
|
} else if (avail >= sbpf) {
|
||||||
/* just flush a bit and stop */
|
/* just flush a bit and stop */
|
||||||
gst_adapter_flush (scope->priv->adapter, (avail - sbpf));
|
gst_adapter_flush (priv->adapter, (avail - sbpf));
|
||||||
gst_adapter_unmap (scope->priv->adapter);
|
gst_adapter_unmap (priv->adapter);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
avail = gst_adapter_available (scope->priv->adapter);
|
avail = gst_adapter_available (priv->adapter);
|
||||||
|
|
||||||
if (ret != GST_FLOW_OK)
|
if (ret != GST_FLOW_OK)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_mutex_unlock (&scope->priv->config_lock);
|
g_mutex_unlock (&priv->config_lock);
|
||||||
|
|
||||||
beach:
|
beach:
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1263,8 +1281,10 @@ gst_audio_visualizer_src_event (GstPad * pad, GstObject * parent,
|
||||||
{
|
{
|
||||||
gboolean res;
|
gboolean res;
|
||||||
GstAudioVisualizer *scope;
|
GstAudioVisualizer *scope;
|
||||||
|
GstAudioVisualizerPrivate *priv;
|
||||||
|
|
||||||
scope = GST_AUDIO_VISUALIZER (parent);
|
scope = GST_AUDIO_VISUALIZER (parent);
|
||||||
|
priv = scope->priv;
|
||||||
|
|
||||||
switch (GST_EVENT_TYPE (event)) {
|
switch (GST_EVENT_TYPE (event)) {
|
||||||
case GST_EVENT_QOS:
|
case GST_EVENT_QOS:
|
||||||
|
@ -1277,17 +1297,16 @@ gst_audio_visualizer_src_event (GstPad * pad, GstObject * parent,
|
||||||
|
|
||||||
/* save stuff for the _chain() function */
|
/* save stuff for the _chain() function */
|
||||||
GST_OBJECT_LOCK (scope);
|
GST_OBJECT_LOCK (scope);
|
||||||
scope->priv->proportion = proportion;
|
priv->proportion = proportion;
|
||||||
if (diff >= 0)
|
if (diff >= 0)
|
||||||
/* we're late, this is a good estimate for next displayable
|
/* we're late, this is a good estimate for next displayable
|
||||||
* frame (see part-qos.txt) */
|
* frame (see part-qos.txt) */
|
||||||
scope->priv->earliest_time = timestamp + 2 * diff +
|
priv->earliest_time = timestamp + 2 * diff + priv->frame_duration;
|
||||||
scope->priv->frame_duration;
|
|
||||||
else
|
else
|
||||||
scope->priv->earliest_time = timestamp + diff;
|
priv->earliest_time = timestamp + diff;
|
||||||
GST_OBJECT_UNLOCK (scope);
|
GST_OBJECT_UNLOCK (scope);
|
||||||
|
|
||||||
res = gst_pad_push_event (scope->priv->sinkpad, event);
|
res = gst_pad_push_event (priv->sinkpad, event);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GST_EVENT_RECONFIGURE:
|
case GST_EVENT_RECONFIGURE:
|
||||||
|
|
Loading…
Reference in a new issue