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

jm at svn.xiph.org jm at svn.xiph.org
Tue Mar 6 19:44:29 PST 2007


Author: jm
Date: 2007-03-06 19:44:25 -0800 (Tue, 06 Mar 2007)
New Revision: 12670

Modified:
   trunk/speex/include/speex/speex_jitter.h
   trunk/speex/libspeex/jitter.c
Log:
Making jitter buffer harder to misuse -- and closer to the original version of
it.


Modified: trunk/speex/include/speex/speex_jitter.h
===================================================================
--- trunk/speex/include/speex/speex_jitter.h	2007-03-07 00:05:38 UTC (rev 12669)
+++ trunk/speex/include/speex/speex_jitter.h	2007-03-07 03:44:25 UTC (rev 12670)
@@ -141,7 +141,7 @@
 */
 int jitter_buffer_ctl(JitterBuffer *jitter, int request, void *ptr);
 
-int jitter_buffer_update_delay(JitterBuffer *jitter);
+int jitter_buffer_update_delay(JitterBuffer *jitter, JitterBufferPacket *packet, spx_uint32_t *start_offset);
 
 /* @} */
 

Modified: trunk/speex/libspeex/jitter.c
===================================================================
--- trunk/speex/libspeex/jitter.c	2007-03-07 00:05:38 UTC (rev 12669)
+++ trunk/speex/libspeex/jitter.c	2007-03-07 03:44:25 UTC (rev 12670)
@@ -71,7 +71,8 @@
    int tick_size;                                                         /**< Output granularity                  */
    int reset_state;                                                       /**< True if state was just reset        */
    int buffer_margin;                                                     /**< How many frames we want to keep in the buffer (lower bound) */
-   
+   int interp_requested;                                                  /**< An interpolation is requested by speex_jitter_update_delay() */
+
    int lost_count;                                                        /**< Number of consecutive lost packets  */
    float shortterm_margin[MAX_MARGIN];                                    /**< Short term margin histogram         */
    float longterm_margin[MAX_MARGIN];                                     /**< Long term margin histogram          */
@@ -252,6 +253,17 @@
    int chunk_size;
    int incomplete = 0;
    
+   if (jitter->interp_requested)
+   {
+      jitter->interp_requested = 0;
+      if (start_offset)
+         *start_offset = 0;
+      packet->timestamp = jitter->pointer_timestamp;
+      packet->span = jitter->tick_size;
+      jitter->pointer_timestamp += chunk_size;
+      packet->len = 0;
+      return JITTER_BUFFER_MISSING;
+   }
    if (LT32(jitter->current_timestamp+jitter->tick_size, jitter->pointer_timestamp))
    {
       jitter->current_timestamp = jitter->pointer_timestamp;
@@ -423,7 +435,7 @@
 }
 
 /* Let the jitter buffer know it's the right time to adjust the buffering delay to the network conditions */
-int jitter_buffer_update_delay(JitterBuffer *jitter)
+int jitter_buffer_update_delay(JitterBuffer *jitter, JitterBufferPacket *packet, spx_uint32_t *start_offset)
 {
    int i, j;
    float late_ratio_short;
@@ -473,9 +485,9 @@
       }
       jitter->shortterm_margin[0] = 0;
       jitter->longterm_margin[0] = 0;            
-      /*jitter->pointer_timestamp -= jitter->tick_size;*/
+      jitter->pointer_timestamp -= jitter->tick_size;
       jitter->current_timestamp -= jitter->tick_size;
-      
+      jitter->interp_requested = 1;
       return JITTER_BUFFER_ADJUST_INTERPOLATE;
    
    } else if (late_ratio_short + ontime_ratio_short < .005 && late_ratio_long + ontime_ratio_long < .01 && early_ratio_short > .8)
@@ -492,9 +504,8 @@
       jitter->longterm_margin[MAX_MARGIN-1] = 0;      
       /*fprintf (stderr, "drop frame\n");*/
       /*fprintf (stderr, "d");*/
-      /*jitter->pointer_timestamp += jitter->tick_size;*/
+      jitter->pointer_timestamp += jitter->tick_size;
       jitter->current_timestamp += jitter->tick_size;
-      
       return JITTER_BUFFER_ADJUST_DROP;
    }
    
@@ -592,6 +603,7 @@
             out[i]=0;
       }
    }
+   jitter_buffer_update_delay(jitter->packets, &packet, NULL);
    jitter_buffer_tick(jitter->packets);
 }
 



More information about the commits mailing list