mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
speexenc: Use speex intern silence detection
Speex has build in silence detection. If speex_encode_int returns 0, than there is silence and sample do not need to be transmitted. This work only if vbr=1 and dtx=1 optionas are enabled. So if we get 0, we add GAP flag to the sample.
This commit is contained in:
parent
547c97f590
commit
0016ceaa2b
1 changed files with 5 additions and 2 deletions
|
@ -901,7 +901,7 @@ gst_speex_enc_encode (GstSpeexEnc * enc, gboolean flush)
|
||||||
|
|
||||||
while (gst_adapter_available (enc->adapter) >= bytes) {
|
while (gst_adapter_available (enc->adapter) >= bytes) {
|
||||||
gint16 *data;
|
gint16 *data;
|
||||||
gint outsize, written;
|
gint outsize, written, dtx_ret;
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
|
|
||||||
data = (gint16 *) gst_adapter_take (enc->adapter, bytes);
|
data = (gint16 *) gst_adapter_take (enc->adapter, bytes);
|
||||||
|
@ -913,7 +913,7 @@ gst_speex_enc_encode (GstSpeexEnc * enc, gboolean flush)
|
||||||
if (enc->channels == 2) {
|
if (enc->channels == 2) {
|
||||||
speex_encode_stereo_int (data, frame_size, &enc->bits);
|
speex_encode_stereo_int (data, frame_size, &enc->bits);
|
||||||
}
|
}
|
||||||
speex_encode_int (enc->state, data, &enc->bits);
|
dtx_ret = speex_encode_int (enc->state, data, &enc->bits);
|
||||||
|
|
||||||
g_free (data);
|
g_free (data);
|
||||||
|
|
||||||
|
@ -937,6 +937,9 @@ gst_speex_enc_encode (GstSpeexEnc * enc, gboolean flush)
|
||||||
g_assert (written == outsize);
|
g_assert (written == outsize);
|
||||||
speex_bits_reset (&enc->bits);
|
speex_bits_reset (&enc->bits);
|
||||||
|
|
||||||
|
if (!dtx_ret)
|
||||||
|
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_GAP);
|
||||||
|
|
||||||
GST_BUFFER_TIMESTAMP (outbuf) = enc->start_ts +
|
GST_BUFFER_TIMESTAMP (outbuf) = enc->start_ts +
|
||||||
gst_util_uint64_scale_int ((enc->frameno_out -
|
gst_util_uint64_scale_int ((enc->frameno_out -
|
||||||
enc->nframes) * frame_size - enc->lookahead, GST_SECOND, enc->rate);
|
enc->nframes) * frame_size - enc->lookahead, GST_SECOND, enc->rate);
|
||||||
|
|
Loading…
Reference in a new issue