Commit 19145ce5 authored by Mark Nauwelaerts's avatar Mark Nauwelaerts

replaygain: port to 0.11

* use G_DEFINE_TYPE
* adjust to new GstBuffer
parent 8d737485
......@@ -125,8 +125,8 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
"signed = (boolean) true, " "endianness = (int) BYTE_ORDER, "
REPLAY_GAIN_CAPS));
GST_BOILERPLATE (GstRgAnalysis, gst_rg_analysis, GstBaseTransform,
GST_TYPE_BASE_TRANSFORM);
#define gst_rg_analysis_parent_class parent_class
G_DEFINE_TYPE (GstRgAnalysis, gst_rg_analysis, GST_TYPE_BASE_TRANSFORM);
static void gst_rg_analysis_set_property (GObject * object, guint prop_id,
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,
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
gst_rg_analysis_class_init (GstRgAnalysisClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *element_class;
GstBaseTransformClass *trans_class;
gobject_class = (GObjectClass *) klass;
element_class = (GstElementClass *) klass;
gobject_class->set_property = gst_rg_analysis_set_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->stop = GST_DEBUG_FUNCPTR (gst_rg_analysis_stop);
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
gst_rg_analysis_init (GstRgAnalysis * filter, GstRgAnalysisClass * gclass)
gst_rg_analysis_init (GstRgAnalysis * filter)
{
GstBaseTransform *base = GST_BASE_TRANSFORM (filter);
......@@ -479,6 +476,8 @@ static GstFlowReturn
gst_rg_analysis_transform_ip (GstBaseTransform * base, GstBuffer * buf)
{
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->analyze != NULL, GST_FLOW_NOT_NEGOTIATED);
......@@ -486,12 +485,13 @@ gst_rg_analysis_transform_ip (GstBaseTransform * base, GstBuffer * buf)
if (filter->skip)
return GST_FLOW_OK;
GST_LOG_OBJECT (filter, "processing buffer of size %u",
GST_BUFFER_SIZE (buf));
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
GST_LOG_OBJECT (filter, "processing buffer of size %" G_GSIZE_FORMAT, size);
rg_analysis_start_buffer (filter->ctx, GST_BUFFER_TIMESTAMP (buf));
filter->analyze (filter->ctx, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf),
filter->depth);
filter->analyze (filter->ctx, data, size, filter->depth);
gst_buffer_unmap (buf, data, size);
return GST_FLOW_OK;
}
......
......@@ -67,8 +67,8 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
"width = (int) 32, channels = (int) [1, MAX], "
"rate = (int) [1, MAX], endianness = (int) BYTE_ORDER"));
GST_BOILERPLATE (GstRgLimiter, gst_rg_limiter, GstBaseTransform,
GST_TYPE_BASE_TRANSFORM);
#define gst_rg_limiter_parent_class parent_class
G_DEFINE_TYPE (GstRgLimiter, gst_rg_limiter, GST_TYPE_BASE_TRANSFORM);
static void gst_rg_limiter_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
......@@ -78,31 +78,15 @@ static void gst_rg_limiter_get_property (GObject * object, guint prop_id,
static GstFlowReturn gst_rg_limiter_transform_ip (GstBaseTransform * base,
GstBuffer * buf);
static void
gst_rg_limiter_base_init (gpointer g_class)
{
GstElementClass *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 limiter",
"Filter/Effect/Audio",
"Apply signal compression to raw audio data",
"Ren\xc3\xa9 Stadler <mail@renestadler.de>");
GST_DEBUG_CATEGORY_INIT (gst_rg_limiter_debug, "rglimiter", 0,
"ReplayGain limiter element");
}
static void
gst_rg_limiter_class_init (GstRgLimiterClass * klass)
{
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;
......@@ -114,10 +98,22 @@ gst_rg_limiter_class_init (GstRgLimiterClass * klass)
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_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 limiter",
"Filter/Effect/Audio",
"Apply signal compression to raw audio data",
"Ren\xc3\xa9 Stadler <mail@renestadler.de>");
GST_DEBUG_CATEGORY_INIT (gst_rg_limiter_debug, "rglimiter", 0,
"ReplayGain limiter element");
}
static void
gst_rg_limiter_init (GstRgLimiter * filter, GstRgLimiterClass * gclass)
gst_rg_limiter_init (GstRgLimiter * 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);
gfloat *input;
guint8 *data;
guint count;
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))
return GST_FLOW_OK;
input = (gfloat *) GST_BUFFER_DATA (buf);
count = GST_BUFFER_SIZE (buf) / sizeof (gfloat);
data = gst_buffer_map (buf, NULL, NULL, GST_MAP_READ);
input = (gfloat *) data;
count = gst_buffer_get_size (buf) / sizeof (gfloat);
for (i = count; i--;) {
if (*input > THRES)
......@@ -190,5 +188,7 @@ gst_rg_limiter_transform_ip (GstBaseTransform * base, GstBuffer * buf)
input++;
}
gst_buffer_unmap (buf, data, -1);
return GST_FLOW_OK;
}
......@@ -120,7 +120,8 @@ static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
"endianness = (int) BYTE_ORDER, "
"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,
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,
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
gst_rg_volume_class_init (GstRgVolumeClass * klass)
{
......@@ -298,10 +281,22 @@ gst_rg_volume_class_init (GstRgVolumeClass * klass)
* mess with our internals. */
bin_class->add_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
gst_rg_volume_init (GstRgVolume * self, GstRgVolumeClass * gclass)
gst_rg_volume_init (GstRgVolume * self)
{
GObjectClass *volume_class;
GstPad *volume_pad, *ghost_pad;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment