[xiph-commits] r14153 - in trunk/speex: include/speex libspeex

jm at svn.xiph.org jm at svn.xiph.org
Thu Nov 15 06:37:00 PST 2007


Author: jm
Date: 2007-11-15 06:36:59 -0800 (Thu, 15 Nov 2007)
New Revision: 14153

Modified:
   trunk/speex/include/speex/speex_jitter.h
   trunk/speex/libspeex/jitter.c
Log:
jitter buffer: Minor API changing. Also doing rounding directly in the delay
search.


Modified: trunk/speex/include/speex/speex_jitter.h
===================================================================
--- trunk/speex/include/speex/speex_jitter.h	2007-11-15 14:23:26 UTC (rev 14152)
+++ trunk/speex/include/speex/speex_jitter.h	2007-11-15 14:36:59 UTC (rev 14153)
@@ -62,6 +62,8 @@
    spx_uint32_t len;        /**< Length of the packet in bytes */
    spx_uint32_t timestamp;  /**< Timestamp for the packet */
    spx_uint32_t span;       /**< Time covered by the packet (same units as timestamp) */
+   spx_uint16_t sequence;   /**< RTP Sequence number if available (0 otherwise) */
+   spx_uint16_t flags;      /**< Info about the returned packet */
    spx_uint32_t user_data;  /**< Put whatever data you like here (it's ignored by the jitter buffer) */
 };
 
@@ -108,13 +110,6 @@
 #define JITTER_BUFFER_GET_LATE_COST 13
 
 
-
-
-
-#define JITTER_BUFFER_ADJUST_INTERPOLATE -1
-#define JITTER_BUFFER_ADJUST_OK 0
-#define JITTER_BUFFER_ADJUST_DROP 1
-
 /** Initialises jitter buffer 
  * 
  * @param tick Number of samples per "tick", i.e. the time period of the elements that will be retrieved

Modified: trunk/speex/libspeex/jitter.c
===================================================================
--- trunk/speex/libspeex/jitter.c	2007-11-15 14:23:26 UTC (rev 14152)
+++ trunk/speex/libspeex/jitter.c	2007-11-15 14:36:59 UTC (rev 14153)
@@ -35,8 +35,10 @@
 /*
 TODO:
 - Make tick() smarter by using the desired and returned span of the last get()
-- rounding directly in the opt computation
 - Add short-term estimate
+- Defensive programming
+  + warn when last returned < last desired (begative buffering)
+  + warn if update_delay not called between get() and tick() or is called twice in a row
 - 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
@@ -223,6 +225,7 @@
          if (i==0)
             worst = latest;
          best = latest;
+         latest = ROUND_DOWN(latest, jitter->delay_step);
          pos[next]++;
          cost = -latest + late_factor*late;
          /*fprintf(stderr, "cost %d = %d + %f * %d\n", cost, -latest, late_factor, late);*/
@@ -588,7 +591,7 @@
       *start_offset = 0;
    
    opt = compute_opt_delay(jitter);
-   opt = ROUND_DOWN(opt, jitter->delay_step);
+   
    /* Should we force an increase in the buffer or just do normal interpolation? */   
    if (opt < 0)
    {
@@ -674,11 +677,6 @@
 {
    spx_int16_t opt = compute_opt_delay(jitter);
    /*fprintf(stderr, "opt adjustment is %d ", opt);*/
-
-   /* Round down to next delay_step */
-   opt = ROUND_DOWN(opt, jitter->delay_step);
-
-   /*fprintf(stderr, "(%d for multiple of %d)\n", opt, jitter->delay_step);*/
    
    if (opt < 0)
    {
@@ -687,17 +685,14 @@
       jitter->pointer_timestamp += opt;
       jitter->interp_requested = -opt;
       /*fprintf (stderr, "Decision to interpolate %d samples\n", -opt);*/
-      return JITTER_BUFFER_ADJUST_INTERPOLATE;
-   
    } else if (opt > 0)
    {
       shift_timings(jitter, -opt);
       jitter->pointer_timestamp += opt;
       /*fprintf (stderr, "Decision to drop %d samples\n", opt);*/
-      return JITTER_BUFFER_ADJUST_DROP;
-   } else {
-      return JITTER_BUFFER_ADJUST_OK;
    }
+   
+   return opt;
 }
 
 /* Used like the ioctl function to control the jitter buffer parameters */



More information about the commits mailing list