mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
replaygain: port to 0.11
* use G_DEFINE_TYPE * adjust to new GstBuffer
This commit is contained in:
parent
8d73748509
commit
19145ce5f5
3 changed files with 67 additions and 72 deletions
|
@ -125,8 +125,8 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
"signed = (boolean) true, " "endianness = (int) BYTE_ORDER, "
|
"signed = (boolean) true, " "endianness = (int) BYTE_ORDER, "
|
||||||
REPLAY_GAIN_CAPS));
|
REPLAY_GAIN_CAPS));
|
||||||
|
|
||||||
GST_BOILERPLATE (GstRgAnalysis, gst_rg_analysis, GstBaseTransform,
|
#define gst_rg_analysis_parent_class parent_class
|
||||||
GST_TYPE_BASE_TRANSFORM);
|
G_DEFINE_TYPE (GstRgAnalysis, gst_rg_analysis, GST_TYPE_BASE_TRANSFORM);
|
||||||
|
|
||||||
static void gst_rg_analysis_set_property (GObject * object, guint prop_id,
|
static void gst_rg_analysis_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec);
|
const GValue * value, GParamSpec * pspec);
|
||||||
|
@ -150,31 +150,16 @@ static gboolean gst_rg_analysis_track_result (GstRgAnalysis * filter,
|
||||||
static gboolean gst_rg_analysis_album_result (GstRgAnalysis * filter,
|
static gboolean gst_rg_analysis_album_result (GstRgAnalysis * filter,
|
||||||
GstTagList ** tag_list);
|
GstTagList ** tag_list);
|
||||||
|
|
||||||
static void
|
|
||||||
gst_rg_analysis_base_init (gpointer g_class)
|
|
||||||
{
|
|
||||||
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
|
||||||
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
|
||||||
gst_static_pad_template_get (&src_factory));
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
|
||||||
gst_static_pad_template_get (&sink_factory));
|
|
||||||
gst_element_class_set_details_simple (element_class, "ReplayGain analysis",
|
|
||||||
"Filter/Analyzer/Audio",
|
|
||||||
"Perform the ReplayGain analysis",
|
|
||||||
"Ren\xc3\xa9 Stadler <mail@renestadler.de>");
|
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_INIT (gst_rg_analysis_debug, "rganalysis", 0,
|
|
||||||
"ReplayGain analysis element");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_rg_analysis_class_init (GstRgAnalysisClass * klass)
|
gst_rg_analysis_class_init (GstRgAnalysisClass * klass)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class;
|
GObjectClass *gobject_class;
|
||||||
|
GstElementClass *element_class;
|
||||||
GstBaseTransformClass *trans_class;
|
GstBaseTransformClass *trans_class;
|
||||||
|
|
||||||
gobject_class = (GObjectClass *) klass;
|
gobject_class = (GObjectClass *) klass;
|
||||||
|
element_class = (GstElementClass *) klass;
|
||||||
|
|
||||||
gobject_class->set_property = gst_rg_analysis_set_property;
|
gobject_class->set_property = gst_rg_analysis_set_property;
|
||||||
gobject_class->get_property = gst_rg_analysis_get_property;
|
gobject_class->get_property = gst_rg_analysis_get_property;
|
||||||
|
|
||||||
|
@ -279,10 +264,22 @@ gst_rg_analysis_class_init (GstRgAnalysisClass * klass)
|
||||||
trans_class->event = GST_DEBUG_FUNCPTR (gst_rg_analysis_event);
|
trans_class->event = GST_DEBUG_FUNCPTR (gst_rg_analysis_event);
|
||||||
trans_class->stop = GST_DEBUG_FUNCPTR (gst_rg_analysis_stop);
|
trans_class->stop = GST_DEBUG_FUNCPTR (gst_rg_analysis_stop);
|
||||||
trans_class->passthrough_on_same_caps = TRUE;
|
trans_class->passthrough_on_same_caps = TRUE;
|
||||||
|
|
||||||
|
gst_element_class_add_pad_template (element_class,
|
||||||
|
gst_static_pad_template_get (&src_factory));
|
||||||
|
gst_element_class_add_pad_template (element_class,
|
||||||
|
gst_static_pad_template_get (&sink_factory));
|
||||||
|
gst_element_class_set_details_simple (element_class, "ReplayGain analysis",
|
||||||
|
"Filter/Analyzer/Audio",
|
||||||
|
"Perform the ReplayGain analysis",
|
||||||
|
"Ren\xc3\xa9 Stadler <mail@renestadler.de>");
|
||||||
|
|
||||||
|
GST_DEBUG_CATEGORY_INIT (gst_rg_analysis_debug, "rganalysis", 0,
|
||||||
|
"ReplayGain analysis element");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_rg_analysis_init (GstRgAnalysis * filter, GstRgAnalysisClass * gclass)
|
gst_rg_analysis_init (GstRgAnalysis * filter)
|
||||||
{
|
{
|
||||||
GstBaseTransform *base = GST_BASE_TRANSFORM (filter);
|
GstBaseTransform *base = GST_BASE_TRANSFORM (filter);
|
||||||
|
|
||||||
|
@ -479,6 +476,8 @@ static GstFlowReturn
|
||||||
gst_rg_analysis_transform_ip (GstBaseTransform * base, GstBuffer * buf)
|
gst_rg_analysis_transform_ip (GstBaseTransform * base, GstBuffer * buf)
|
||||||
{
|
{
|
||||||
GstRgAnalysis *filter = GST_RG_ANALYSIS (base);
|
GstRgAnalysis *filter = GST_RG_ANALYSIS (base);
|
||||||
|
guint8 *data;
|
||||||
|
gsize size;
|
||||||
|
|
||||||
g_return_val_if_fail (filter->ctx != NULL, GST_FLOW_WRONG_STATE);
|
g_return_val_if_fail (filter->ctx != NULL, GST_FLOW_WRONG_STATE);
|
||||||
g_return_val_if_fail (filter->analyze != NULL, GST_FLOW_NOT_NEGOTIATED);
|
g_return_val_if_fail (filter->analyze != NULL, GST_FLOW_NOT_NEGOTIATED);
|
||||||
|
@ -486,12 +485,13 @@ gst_rg_analysis_transform_ip (GstBaseTransform * base, GstBuffer * buf)
|
||||||
if (filter->skip)
|
if (filter->skip)
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
|
||||||
GST_LOG_OBJECT (filter, "processing buffer of size %u",
|
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||||
GST_BUFFER_SIZE (buf));
|
GST_LOG_OBJECT (filter, "processing buffer of size %" G_GSIZE_FORMAT, size);
|
||||||
|
|
||||||
rg_analysis_start_buffer (filter->ctx, GST_BUFFER_TIMESTAMP (buf));
|
rg_analysis_start_buffer (filter->ctx, GST_BUFFER_TIMESTAMP (buf));
|
||||||
filter->analyze (filter->ctx, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf),
|
filter->analyze (filter->ctx, data, size, filter->depth);
|
||||||
filter->depth);
|
|
||||||
|
gst_buffer_unmap (buf, data, size);
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,8 +67,8 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
"width = (int) 32, channels = (int) [1, MAX], "
|
"width = (int) 32, channels = (int) [1, MAX], "
|
||||||
"rate = (int) [1, MAX], endianness = (int) BYTE_ORDER"));
|
"rate = (int) [1, MAX], endianness = (int) BYTE_ORDER"));
|
||||||
|
|
||||||
GST_BOILERPLATE (GstRgLimiter, gst_rg_limiter, GstBaseTransform,
|
#define gst_rg_limiter_parent_class parent_class
|
||||||
GST_TYPE_BASE_TRANSFORM);
|
G_DEFINE_TYPE (GstRgLimiter, gst_rg_limiter, GST_TYPE_BASE_TRANSFORM);
|
||||||
|
|
||||||
static void gst_rg_limiter_set_property (GObject * object, guint prop_id,
|
static void gst_rg_limiter_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec);
|
const GValue * value, GParamSpec * pspec);
|
||||||
|
@ -79,9 +79,25 @@ static GstFlowReturn gst_rg_limiter_transform_ip (GstBaseTransform * base,
|
||||||
GstBuffer * buf);
|
GstBuffer * buf);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_rg_limiter_base_init (gpointer g_class)
|
gst_rg_limiter_class_init (GstRgLimiterClass * klass)
|
||||||
{
|
{
|
||||||
GstElementClass *element_class = g_class;
|
GObjectClass *gobject_class;
|
||||||
|
GstElementClass *element_class;
|
||||||
|
GstBaseTransformClass *trans_class;
|
||||||
|
|
||||||
|
gobject_class = (GObjectClass *) klass;
|
||||||
|
element_class = (GstElementClass *) klass;
|
||||||
|
|
||||||
|
gobject_class->set_property = gst_rg_limiter_set_property;
|
||||||
|
gobject_class->get_property = gst_rg_limiter_get_property;
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class, PROP_ENABLED,
|
||||||
|
g_param_spec_boolean ("enabled", "Enabled", "Enable processing", TRUE,
|
||||||
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
trans_class = GST_BASE_TRANSFORM_CLASS (klass);
|
||||||
|
trans_class->transform_ip = GST_DEBUG_FUNCPTR (gst_rg_limiter_transform_ip);
|
||||||
|
trans_class->passthrough_on_same_caps = FALSE;
|
||||||
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
gst_element_class_add_pad_template (element_class,
|
||||||
gst_static_pad_template_get (&src_factory));
|
gst_static_pad_template_get (&src_factory));
|
||||||
|
@ -97,27 +113,7 @@ gst_rg_limiter_base_init (gpointer g_class)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_rg_limiter_class_init (GstRgLimiterClass * klass)
|
gst_rg_limiter_init (GstRgLimiter * filter)
|
||||||
{
|
|
||||||
GObjectClass *gobject_class;
|
|
||||||
GstBaseTransformClass *trans_class;
|
|
||||||
|
|
||||||
gobject_class = (GObjectClass *) klass;
|
|
||||||
|
|
||||||
gobject_class->set_property = gst_rg_limiter_set_property;
|
|
||||||
gobject_class->get_property = gst_rg_limiter_get_property;
|
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class, PROP_ENABLED,
|
|
||||||
g_param_spec_boolean ("enabled", "Enabled", "Enable processing", TRUE,
|
|
||||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
||||||
|
|
||||||
trans_class = GST_BASE_TRANSFORM_CLASS (klass);
|
|
||||||
trans_class->transform_ip = GST_DEBUG_FUNCPTR (gst_rg_limiter_transform_ip);
|
|
||||||
trans_class->passthrough_on_same_caps = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_rg_limiter_init (GstRgLimiter * filter, GstRgLimiterClass * gclass)
|
|
||||||
{
|
{
|
||||||
GstBaseTransform *base = GST_BASE_TRANSFORM (filter);
|
GstBaseTransform *base = GST_BASE_TRANSFORM (filter);
|
||||||
|
|
||||||
|
@ -170,6 +166,7 @@ gst_rg_limiter_transform_ip (GstBaseTransform * base, GstBuffer * buf)
|
||||||
{
|
{
|
||||||
GstRgLimiter *filter = GST_RG_LIMITER (base);
|
GstRgLimiter *filter = GST_RG_LIMITER (base);
|
||||||
gfloat *input;
|
gfloat *input;
|
||||||
|
guint8 *data;
|
||||||
guint count;
|
guint count;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
|
@ -179,8 +176,9 @@ gst_rg_limiter_transform_ip (GstBaseTransform * base, GstBuffer * buf)
|
||||||
if (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_GAP))
|
if (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_GAP))
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
|
||||||
input = (gfloat *) GST_BUFFER_DATA (buf);
|
data = gst_buffer_map (buf, NULL, NULL, GST_MAP_READ);
|
||||||
count = GST_BUFFER_SIZE (buf) / sizeof (gfloat);
|
input = (gfloat *) data;
|
||||||
|
count = gst_buffer_get_size (buf) / sizeof (gfloat);
|
||||||
|
|
||||||
for (i = count; i--;) {
|
for (i = count; i--;) {
|
||||||
if (*input > THRES)
|
if (*input > THRES)
|
||||||
|
@ -190,5 +188,7 @@ gst_rg_limiter_transform_ip (GstBaseTransform * base, GstBuffer * buf)
|
||||||
input++;
|
input++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gst_buffer_unmap (buf, data, -1);
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,8 @@ static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
"endianness = (int) BYTE_ORDER, "
|
"endianness = (int) BYTE_ORDER, "
|
||||||
"width = (int) 16, " "depth = (int) 16, " "signed = (bool) TRUE"));
|
"width = (int) 16, " "depth = (int) 16, " "signed = (bool) TRUE"));
|
||||||
|
|
||||||
GST_BOILERPLATE (GstRgVolume, gst_rg_volume, GstBin, GST_TYPE_BIN);
|
#define gst_rg_volume_parent_class parent_class
|
||||||
|
G_DEFINE_TYPE (GstRgVolume, gst_rg_volume, GST_TYPE_BIN);
|
||||||
|
|
||||||
static void gst_rg_volume_set_property (GObject * object, guint prop_id,
|
static void gst_rg_volume_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec);
|
const GValue * value, GParamSpec * pspec);
|
||||||
|
@ -138,24 +139,6 @@ static void gst_rg_volume_update_gain (GstRgVolume * self);
|
||||||
static inline void gst_rg_volume_determine_gain (GstRgVolume * self,
|
static inline void gst_rg_volume_determine_gain (GstRgVolume * self,
|
||||||
gdouble * target_gain, gdouble * result_gain);
|
gdouble * target_gain, gdouble * result_gain);
|
||||||
|
|
||||||
static void
|
|
||||||
gst_rg_volume_base_init (gpointer g_class)
|
|
||||||
{
|
|
||||||
GstElementClass *element_class = g_class;
|
|
||||||
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
|
||||||
gst_static_pad_template_get (&src_template));
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
|
||||||
gst_static_pad_template_get (&sink_template));
|
|
||||||
gst_element_class_set_details_simple (element_class, "ReplayGain volume",
|
|
||||||
"Filter/Effect/Audio",
|
|
||||||
"Apply ReplayGain volume adjustment",
|
|
||||||
"Ren\xc3\xa9 Stadler <mail@renestadler.de>");
|
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_INIT (gst_rg_volume_debug, "rgvolume", 0,
|
|
||||||
"ReplayGain volume element");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_rg_volume_class_init (GstRgVolumeClass * klass)
|
gst_rg_volume_class_init (GstRgVolumeClass * klass)
|
||||||
{
|
{
|
||||||
|
@ -298,10 +281,22 @@ gst_rg_volume_class_init (GstRgVolumeClass * klass)
|
||||||
* mess with our internals. */
|
* mess with our internals. */
|
||||||
bin_class->add_element = NULL;
|
bin_class->add_element = NULL;
|
||||||
bin_class->remove_element = NULL;
|
bin_class->remove_element = NULL;
|
||||||
|
|
||||||
|
gst_element_class_add_pad_template (element_class,
|
||||||
|
gst_static_pad_template_get (&src_template));
|
||||||
|
gst_element_class_add_pad_template (element_class,
|
||||||
|
gst_static_pad_template_get (&sink_template));
|
||||||
|
gst_element_class_set_details_simple (element_class, "ReplayGain volume",
|
||||||
|
"Filter/Effect/Audio",
|
||||||
|
"Apply ReplayGain volume adjustment",
|
||||||
|
"Ren\xc3\xa9 Stadler <mail@renestadler.de>");
|
||||||
|
|
||||||
|
GST_DEBUG_CATEGORY_INIT (gst_rg_volume_debug, "rgvolume", 0,
|
||||||
|
"ReplayGain volume element");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_rg_volume_init (GstRgVolume * self, GstRgVolumeClass * gclass)
|
gst_rg_volume_init (GstRgVolume * self)
|
||||||
{
|
{
|
||||||
GObjectClass *volume_class;
|
GObjectClass *volume_class;
|
||||||
GstPad *volume_pad, *ghost_pad;
|
GstPad *volume_pad, *ghost_pad;
|
||||||
|
|
Loading…
Reference in a new issue