[xiph-commits] r14089 - trunk/speex/libspeex
jm at svn.xiph.org
jm at svn.xiph.org
Fri Nov 2 00:01:58 PDT 2007
Author: jm
Date: 2007-11-02 00:01:58 -0700 (Fri, 02 Nov 2007)
New Revision: 14089
Modified:
trunk/speex/libspeex/jitter.c
Log:
jitter buffer: histogram shifting function (not used yet)
Modified: trunk/speex/libspeex/jitter.c
===================================================================
--- trunk/speex/libspeex/jitter.c 2007-11-02 07:01:48 UTC (rev 14088)
+++ trunk/speex/libspeex/jitter.c 2007-11-02 07:01:58 UTC (rev 14089)
@@ -32,7 +32,15 @@
*/
-
+/*
+TODO:
+- Write generic functions for computing stats and shifting the histogram
+- Take into account the delay step when computing the stats and when shifting
+- Linked list structure for holding the packets instead of the current fixed-size array
+ + return memory to a pool
+ + allow pre-allocation of the pool
+ + optional max number of elements
+*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -174,6 +182,43 @@
}
}
+static void shift_histogram(JitterBuffer *jitter, int amount)
+{
+ int i, c;
+ if (amount == 0)
+ return;
+ if (amount > 0)
+ {
+ /* FIXME: This is terribly inefficient */
+ for (c=0;c<amount;c++)
+ {
+ jitter->shortterm_margin[MAX_MARGIN-1] += jitter->shortterm_margin[MAX_MARGIN-2];
+ jitter->longterm_margin[MAX_MARGIN-1] += jitter->longterm_margin[MAX_MARGIN-2];
+ for (i=MAX_MARGIN-3;i>=0;i--)
+ {
+ jitter->shortterm_margin[i+1] = jitter->shortterm_margin[i];
+ jitter->longterm_margin[i+1] = jitter->longterm_margin[i];
+ }
+ jitter->shortterm_margin[0] = 0;
+ jitter->longterm_margin[0] = 0;
+ }
+ } else {
+ /* FIXME: This is terribly inefficient */
+ for (c=0;c<-amount;c++)
+ {
+ jitter->shortterm_margin[0] += jitter->shortterm_margin[1];
+ jitter->longterm_margin[0] += jitter->longterm_margin[1];
+ for (i=1;i<MAX_MARGIN-1;i++)
+ {
+ jitter->shortterm_margin[i] = jitter->shortterm_margin[i+1];
+ jitter->longterm_margin[i] = jitter->longterm_margin[i+1];
+ }
+ jitter->shortterm_margin[MAX_MARGIN-1] = 0;
+ jitter->longterm_margin[MAX_MARGIN-1] = 0;
+ }
+ }
+}
+
/** Put one packet into the jitter buffer */
void jitter_buffer_put(JitterBuffer *jitter, const JitterBufferPacket *packet)
{
More information about the commits
mailing list