void offset_add_value(cdrom_paranoia *p,offsets *o,long value, void(*callback)(long,int)){ if(o->offpoints!=-1){ o->offdiff+=abs(value); o->offpoints++; o->newpoints++; o->offaccum+=value; if(value<o->offmin)o->offmin=value; if(value>o->offmax)o->offmax=value; if(o->newpoints>=10)offset_adjust_settings(p,callback); } }
/* =========================================================================== * offset_add_value (internal) * * This function adds the given jitter detected (value) to the statistics * for the given stage (o). It is called whenever jitter has been identified * by stage 1 or 2. After every 10 samples, we update the overall jitter- * compensation settings (e.g. dynoverlap). This allows us to narrow our * search for matching runs (in both stages) in low-jitter conditions * and also widen our search appropriately when there is jitter. * * * "???BUG???: * Note that there is a bug in the way that this is called by try_sort_sync(). * Silence looks like zero jitter, and dynoverlap may be incorrectly reduced * when there's lots of silence but also jitter." * * Strictly speaking, this is only sort-of true. The silence will * incorrectly somewhat reduce dynoverlap. However, it will increase * again once past the silence (even if reduced to zero, it will be * increased by the block read loop if we're not getting matches). * In reality, silence usually passes rapidly. Anyway, long streaks * of silence benefit performance-wise from having dynoverlap decrease * momentarily. There is no correctness bug. --Monty * */ void offset_add_value(cdrom_paranoia_t *p,offsets *o,long value, void(*callback)(long int, paranoia_cb_mode_t)) { if(o->offpoints!=-1){ /* Track the average magnitude of jitter (in either direction) */ o->offdiff += labs(value); o->offpoints++; o->newpoints++; /* Track the net value of the jitter (to track drift) */ o->offaccum+=value; /* Track the largest jitter we've encountered in each direction */ if(value<o->offmin)o->offmin=value; if(value>o->offmax)o->offmax=value; /* After 10 samples, update dynoverlap, etc. */ if(o->newpoints>=10)offset_adjust_settings(p,callback); } }