mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
gst/law/: The encoder can't really renegotiate at the time they perform a pad-alloc so make the srcpads use fixed caps.
Original commit message from CVS: * gst/law/alaw-encode.c: (gst_alaw_enc_init), (gst_alaw_enc_chain): * gst/law/mulaw-conversion.c: * gst/law/mulaw-encode.c: (gst_mulawenc_init), (gst_mulawenc_chain): The encoder can't really renegotiate at the time they perform a pad-alloc so make the srcpads use fixed caps. Check the buffer size after a pad-alloc because the returned size might not be right when the downstream element does not know the size of the new buffer (capsfilter). Fixes #549073.
This commit is contained in:
parent
4cefe7e944
commit
c0826dc21d
4 changed files with 38 additions and 12 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
||||||
|
2008-08-25 Wim Taymans <wim.taymans@collabora.co.uk>
|
||||||
|
|
||||||
|
* gst/law/alaw-encode.c: (gst_alaw_enc_init), (gst_alaw_enc_chain):
|
||||||
|
* gst/law/mulaw-conversion.c:
|
||||||
|
* gst/law/mulaw-encode.c: (gst_mulawenc_init),
|
||||||
|
(gst_mulawenc_chain):
|
||||||
|
The encoder can't really renegotiate at the time they perform a
|
||||||
|
pad-alloc so make the srcpads use fixed caps.
|
||||||
|
Check the buffer size after a pad-alloc because the returned size might
|
||||||
|
not be right when the downstream element does not know the size of the
|
||||||
|
new buffer (capsfilter). Fixes #549073.
|
||||||
|
|
||||||
2008-08-23 Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
2008-08-23 Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
||||||
|
|
||||||
Patch by: Filippo Argiolas <filippo dot argiolas at gmail dot com>
|
Patch by: Filippo Argiolas <filippo dot argiolas at gmail dot com>
|
||||||
|
|
|
@ -421,6 +421,7 @@ gst_alaw_enc_init (GstALawEnc * alawenc, GstALawEncClass * klass)
|
||||||
GST_DEBUG_FUNCPTR (gst_alaw_enc_setcaps));
|
GST_DEBUG_FUNCPTR (gst_alaw_enc_setcaps));
|
||||||
gst_pad_set_getcaps_function (alawenc->srcpad,
|
gst_pad_set_getcaps_function (alawenc->srcpad,
|
||||||
GST_DEBUG_FUNCPTR (gst_alaw_enc_getcaps));
|
GST_DEBUG_FUNCPTR (gst_alaw_enc_getcaps));
|
||||||
|
gst_pad_use_fixed_caps (alawenc->srcpad);
|
||||||
gst_element_add_pad (GST_ELEMENT (alawenc), alawenc->srcpad);
|
gst_element_add_pad (GST_ELEMENT (alawenc), alawenc->srcpad);
|
||||||
|
|
||||||
/* init rest */
|
/* init rest */
|
||||||
|
@ -457,11 +458,6 @@ gst_alaw_enc_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
GST_LOG_OBJECT (alawenc, "buffer with ts=%" GST_TIME_FORMAT,
|
GST_LOG_OBJECT (alawenc, "buffer with ts=%" GST_TIME_FORMAT,
|
||||||
GST_TIME_ARGS (timestamp));
|
GST_TIME_ARGS (timestamp));
|
||||||
|
|
||||||
if (duration == GST_CLOCK_TIME_NONE) {
|
|
||||||
duration = gst_util_uint64_scale_int (alaw_size,
|
|
||||||
GST_SECOND, alawenc->rate * alawenc->channels);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret =
|
ret =
|
||||||
gst_pad_alloc_buffer_and_set_caps (alawenc->srcpad,
|
gst_pad_alloc_buffer_and_set_caps (alawenc->srcpad,
|
||||||
GST_BUFFER_OFFSET_NONE, alaw_size, GST_PAD_CAPS (alawenc->srcpad),
|
GST_BUFFER_OFFSET_NONE, alaw_size, GST_PAD_CAPS (alawenc->srcpad),
|
||||||
|
@ -469,6 +465,17 @@ gst_alaw_enc_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
if (ret != GST_FLOW_OK)
|
if (ret != GST_FLOW_OK)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
|
if (duration == GST_CLOCK_TIME_NONE) {
|
||||||
|
duration = gst_util_uint64_scale_int (alaw_size,
|
||||||
|
GST_SECOND, alawenc->rate * alawenc->channels);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GST_BUFFER_SIZE (outbuf) < alaw_size) {
|
||||||
|
/* pad-alloc can return a smaller buffer */
|
||||||
|
gst_buffer_unref (outbuf);
|
||||||
|
outbuf = gst_buffer_new_and_alloc (alaw_size);
|
||||||
|
}
|
||||||
|
|
||||||
alaw_data = (guint8 *) GST_BUFFER_DATA (outbuf);
|
alaw_data = (guint8 *) GST_BUFFER_DATA (outbuf);
|
||||||
|
|
||||||
/* copy discont flag */
|
/* copy discont flag */
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
/* #define ZEROTRAP *//* turn on the trap as per the MIL-STD */
|
#undef ZEROTRAP /* turn on the trap as per the MIL-STD */
|
||||||
#define BIAS 0x84 /* define the add-in bias for 16 bit samples */
|
#define BIAS 0x84 /* define the add-in bias for 16 bit samples */
|
||||||
#define CLIP 32635
|
#define CLIP 32635
|
||||||
|
|
||||||
|
|
|
@ -194,6 +194,7 @@ gst_mulawenc_init (GstMuLawEnc * mulawenc)
|
||||||
mulawenc->srcpad = gst_pad_new_from_template (mulawenc_src_template, "src");
|
mulawenc->srcpad = gst_pad_new_from_template (mulawenc_src_template, "src");
|
||||||
gst_pad_set_setcaps_function (mulawenc->srcpad, mulawenc_setcaps);
|
gst_pad_set_setcaps_function (mulawenc->srcpad, mulawenc_setcaps);
|
||||||
gst_pad_set_getcaps_function (mulawenc->srcpad, mulawenc_getcaps);
|
gst_pad_set_getcaps_function (mulawenc->srcpad, mulawenc_getcaps);
|
||||||
|
gst_pad_use_fixed_caps (mulawenc->srcpad);
|
||||||
gst_element_add_pad (GST_ELEMENT (mulawenc), mulawenc->srcpad);
|
gst_element_add_pad (GST_ELEMENT (mulawenc), mulawenc->srcpad);
|
||||||
|
|
||||||
/* init rest */
|
/* init rest */
|
||||||
|
@ -225,17 +226,23 @@ gst_mulawenc_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
|
|
||||||
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||||
duration = GST_BUFFER_DURATION (buffer);
|
duration = GST_BUFFER_DURATION (buffer);
|
||||||
|
|
||||||
|
ret = gst_pad_alloc_buffer_and_set_caps (mulawenc->srcpad,
|
||||||
|
GST_BUFFER_OFFSET_NONE, mulaw_size, GST_PAD_CAPS (mulawenc->srcpad),
|
||||||
|
&outbuf);
|
||||||
|
if (ret != GST_FLOW_OK)
|
||||||
|
goto alloc_failed;
|
||||||
|
|
||||||
if (duration == -1) {
|
if (duration == -1) {
|
||||||
duration = gst_util_uint64_scale_int (mulaw_size,
|
duration = gst_util_uint64_scale_int (mulaw_size,
|
||||||
GST_SECOND, mulawenc->rate * mulawenc->channels);
|
GST_SECOND, mulawenc->rate * mulawenc->channels);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret =
|
if (GST_BUFFER_SIZE (outbuf) < mulaw_size) {
|
||||||
gst_pad_alloc_buffer_and_set_caps (mulawenc->srcpad,
|
/* pad-alloc can suggest a smaller size */
|
||||||
GST_BUFFER_OFFSET_NONE, mulaw_size, GST_PAD_CAPS (mulawenc->srcpad),
|
gst_buffer_unref (outbuf);
|
||||||
&outbuf);
|
outbuf = gst_buffer_new_and_alloc (mulaw_size);
|
||||||
if (ret != GST_FLOW_OK)
|
}
|
||||||
goto alloc_failed;
|
|
||||||
|
|
||||||
mulaw_data = (guint8 *) GST_BUFFER_DATA (outbuf);
|
mulaw_data = (guint8 *) GST_BUFFER_DATA (outbuf);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue