mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
gst/speexresample/gstspeexresample.c: Fixate to the nearest supported rate instead of the first one.
Original commit message from CVS: * gst/speexresample/gstspeexresample.c: (gst_speex_resample_class_init), (gst_speex_resample_fixate_caps), (gst_speex_resample_process): Fixate to the nearest supported rate instead of the first one.
This commit is contained in:
parent
e449388276
commit
8416cc94b5
2 changed files with 31 additions and 1 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2008-10-28 Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
||||||
|
|
||||||
|
* gst/speexresample/gstspeexresample.c:
|
||||||
|
(gst_speex_resample_class_init), (gst_speex_resample_fixate_caps),
|
||||||
|
(gst_speex_resample_process):
|
||||||
|
Fixate to the nearest supported rate instead of the first one.
|
||||||
|
|
||||||
2008-10-28 Sebastian Dröge <slomo@circular-chaos.org>
|
2008-10-28 Sebastian Dröge <slomo@circular-chaos.org>
|
||||||
|
|
||||||
* gst/speexresample/README:
|
* gst/speexresample/README:
|
||||||
|
|
|
@ -88,6 +88,8 @@ static gboolean gst_speex_resample_get_unit_size (GstBaseTransform * base,
|
||||||
GstCaps * caps, guint * size);
|
GstCaps * caps, guint * size);
|
||||||
static GstCaps *gst_speex_resample_transform_caps (GstBaseTransform * base,
|
static GstCaps *gst_speex_resample_transform_caps (GstBaseTransform * base,
|
||||||
GstPadDirection direction, GstCaps * caps);
|
GstPadDirection direction, GstCaps * caps);
|
||||||
|
static void gst_speex_resample_fixate_caps (GstBaseTransform * base,
|
||||||
|
GstPadDirection direction, GstCaps * caps, GstCaps * othercaps);
|
||||||
static gboolean gst_speex_resample_transform_size (GstBaseTransform * trans,
|
static gboolean gst_speex_resample_transform_size (GstBaseTransform * trans,
|
||||||
GstPadDirection direction, GstCaps * incaps, guint insize,
|
GstPadDirection direction, GstCaps * incaps, guint insize,
|
||||||
GstCaps * outcaps, guint * outsize);
|
GstCaps * outcaps, guint * outsize);
|
||||||
|
@ -148,6 +150,8 @@ gst_speex_resample_class_init (GstSpeexResampleClass * klass)
|
||||||
GST_DEBUG_FUNCPTR (gst_speex_resample_get_unit_size);
|
GST_DEBUG_FUNCPTR (gst_speex_resample_get_unit_size);
|
||||||
GST_BASE_TRANSFORM_CLASS (klass)->transform_caps =
|
GST_BASE_TRANSFORM_CLASS (klass)->transform_caps =
|
||||||
GST_DEBUG_FUNCPTR (gst_speex_resample_transform_caps);
|
GST_DEBUG_FUNCPTR (gst_speex_resample_transform_caps);
|
||||||
|
GST_BASE_TRANSFORM_CLASS (klass)->fixate_caps =
|
||||||
|
GST_DEBUG_FUNCPTR (gst_speex_resample_fixate_caps);
|
||||||
GST_BASE_TRANSFORM_CLASS (klass)->set_caps =
|
GST_BASE_TRANSFORM_CLASS (klass)->set_caps =
|
||||||
GST_DEBUG_FUNCPTR (gst_speex_resample_set_caps);
|
GST_DEBUG_FUNCPTR (gst_speex_resample_set_caps);
|
||||||
GST_BASE_TRANSFORM_CLASS (klass)->transform =
|
GST_BASE_TRANSFORM_CLASS (klass)->transform =
|
||||||
|
@ -239,6 +243,22 @@ gst_speex_resample_transform_caps (GstBaseTransform * base,
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Fixate rate to the allowed rate that has the smallest difference */
|
||||||
|
static void
|
||||||
|
gst_speex_resample_fixate_caps (GstBaseTransform * base,
|
||||||
|
GstPadDirection direction, GstCaps * caps, GstCaps * othercaps)
|
||||||
|
{
|
||||||
|
GstStructure *s;
|
||||||
|
gint rate;
|
||||||
|
|
||||||
|
s = gst_caps_get_structure (caps, 0);
|
||||||
|
if (!gst_structure_get_int (s, "rate", &rate))
|
||||||
|
return;
|
||||||
|
|
||||||
|
s = gst_caps_get_structure (othercaps, 0);
|
||||||
|
gst_structure_fixate_field_nearest_int (s, "rate", rate);
|
||||||
|
}
|
||||||
|
|
||||||
static SpeexResamplerState *
|
static SpeexResamplerState *
|
||||||
gst_speex_resample_init_state (guint channels, guint inrate, guint outrate,
|
gst_speex_resample_init_state (guint channels, guint inrate, guint outrate,
|
||||||
guint quality, gboolean fp)
|
guint quality, gboolean fp)
|
||||||
|
@ -735,9 +755,11 @@ gst_speex_resample_process (GstSpeexResample * resample, GstBuffer * inbuf,
|
||||||
}
|
}
|
||||||
|
|
||||||
return GST_BASE_TRANSFORM_FLOW_DROPPED;
|
return GST_BASE_TRANSFORM_FLOW_DROPPED;
|
||||||
} else if (out_len - out_processed != 1)
|
} else if (out_len - out_processed != 1) {
|
||||||
GST_WARNING ("Converted to %d instead of %d output samples",
|
GST_WARNING ("Converted to %d instead of %d output samples",
|
||||||
out_processed, out_len);
|
out_processed, out_len);
|
||||||
|
}
|
||||||
|
|
||||||
if (out_len > out_processed) {
|
if (out_len > out_processed) {
|
||||||
gst_speex_fix_output_buffer (resample, outbuf, out_len - out_processed);
|
gst_speex_fix_output_buffer (resample, outbuf, out_len - out_processed);
|
||||||
} else {
|
} else {
|
||||||
|
@ -757,6 +779,7 @@ gst_speex_resample_process (GstSpeexResample * resample, GstBuffer * inbuf,
|
||||||
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)),
|
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)),
|
||||||
GST_TIME_ARGS (GST_BUFFER_DURATION (outbuf)),
|
GST_TIME_ARGS (GST_BUFFER_DURATION (outbuf)),
|
||||||
GST_BUFFER_OFFSET (outbuf), GST_BUFFER_OFFSET_END (outbuf));
|
GST_BUFFER_OFFSET (outbuf), GST_BUFFER_OFFSET_END (outbuf));
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue