Changeset 2930

Show
Ignore:
Timestamp:
11/12/99 18:13:29 (15 years ago)
Author:
ucacoxh
Message:

- Added emergency buffer adaptation. When playing classical music
(for instance) there are not enough suitable repeated segments which
means if skew is sufficient we can still accumulate audio. Now there
is panic point, beyond which we arbitrarily drop the odd half frame
instead of the whizzy pattern matching stuff.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • rat/trunk/source.c

    r2927 r2930  
    4646#define SOURCE_YOUNG_AGE             20 
    4747#define SOURCE_AUDIO_HISTORY_MS    1000 
    48 #define NO_CONT_TOGED_FOR_PLAYOUT_RECALC 4 
     48#define NO_CONT_TOGED_FOR_PLAYOUT_RECALC 2 
     49 
     50#define SOURCE_COMPARE_WINDOW_SIZE 8 
     51/* Match threshold is mean abs diff. lower score gives less noise, but less  */ 
     52/* adaption..., might be better if threshold adapted with how much extra     */ 
     53/* data we have buffered...                                                  */ 
     54#define MATCH_THRESHOLD 1200 
    4955 
    5056/* constants for skew adjustment: 
     
    192198        bw_avg_period  = ts_map32(8000, 8000); 
    193199        skew_thresh    = ts_map32(8000, 160); 
    194         skew_limit     = ts_map32(8000, 2000); 
     200        skew_limit     = ts_map32(8000, 4000); 
    195201        time_constants_inited = TRUE; 
    196202} 
     
    762768/* dropped with causing glitch.                                              */ 
    763769 
    764 #define SOURCE_COMPARE_WINDOW_SIZE 8 
    765 /* Match threshold is mean abs diff. lower score gives less noise, but less  */ 
    766 /* adaption..., might be better if threshold adapted with how much extra     */ 
    767 /* data we have buffered...                                                  */ 
    768 #define MATCH_THRESHOLD 1000 
    769  
    770770static ts_t 
    771771recommend_drop_dur(media_data *md)  
     
    808808                return ts_map32(rate, lowest_begin); 
    809809        } else { 
     810                debug_msg("Score %d > Thresh %d\n", lowest_score/SOURCE_COMPARE_WINDOW_SIZE, MATCH_THRESHOLD); 
    810811                return zero_ts; 
    811812        } 
     
    870871        diff    = ts_abs_diff(actual, desired); 
    871872 
    872         if (ts_gt(diff, skew_thresh) && ts_gt(skew_limit, diff)) { 
     873        if (ts_gt(diff, skew_thresh)) { 
    873874                src->skew_adjust = diff; 
    874875                if (ts_gt(actual, desired)) { 
     
    931932                 * classified.  */ 
    932933 
    933                 adjustment = recommend_drop_dur(md);  
     934                if (ts_gt(skew_limit, src->skew_adjust)) { 
     935                        adjustment = recommend_drop_dur(md);  
     936                } else { 
     937                        /* Things are really skewed.  We're more than        */ 
     938                        /* skew_limit off of where we ought to be.  Just     */ 
     939                        /* drop a frame and don't worry.                     */ 
     940                        debug_msg("Dropping Frame\n"); 
     941                        adjustment = ts_div(src->pdbe->frame_dur, 2); 
     942                } 
     943 
    934944                if (ts_gt(adjustment, src->skew_adjust) || adjustment.ticks == 0) { 
    935                         /* adjustment needed is greater than adjustment period 
    936                          * that best matches dropable by signal matching. 
    937                         */ 
     945                        /* adjustment needed is greater than adjustment      */ 
     946                        /* period that best matches dropable by signal       */ 
     947                        /* matching.                                        */ 
    938948                        return SOURCE_SKEW_NONE; 
    939949                }