svn commit: r194233 - in head/sys: dev/sound tools/sound

Ariff Abdullah ariff at FreeBSD.org
Mon Jun 15 04:31:35 UTC 2009


Author: ariff
Date: Mon Jun 15 04:31:34 2009
New Revision: 194233
URL: http://svn.freebsd.org/changeset/base/194233

Log:
  - Add a way to change filter oversampling factor through
    FEEDER_RATE_PRESET "OVERSAMPLING_FACTOR:X .. .." where
    X = log2(oversampling factor).
  
  - Lower down default filter oversampling factor from 128
    (log2 = 7) to 32 (log2 = 5), saving worth of 80 Kb.
    The use of better polynomial interpolator will raise
    its conversion quality/accuracy to match (or slightly
    better) with previous settings.
  
  - Bump driver version.

Modified:
  head/sys/dev/sound/version.h
  head/sys/tools/sound/feeder_rate_mkfilter.awk

Modified: head/sys/dev/sound/version.h
==============================================================================
--- head/sys/dev/sound/version.h	Mon Jun 15 04:05:38 2009	(r194232)
+++ head/sys/dev/sound/version.h	Mon Jun 15 04:31:34 2009	(r194233)
@@ -37,6 +37,6 @@
  * Last 2 decimal places reserved for daily versioning, starting
  * with 0.
  */
-#define SND_DRV_VERSION		2009060800
+#define SND_DRV_VERSION		2009061500
 
 #endif /* !_SND_VERSION_H_ */

Modified: head/sys/tools/sound/feeder_rate_mkfilter.awk
==============================================================================
--- head/sys/tools/sound/feeder_rate_mkfilter.awk	Mon Jun 15 04:05:38 2009	(r194232)
+++ head/sys/tools/sound/feeder_rate_mkfilter.awk	Mon Jun 15 04:31:34 2009	(r194233)
@@ -379,8 +379,15 @@ function filter_parse(s, a, i, attn, ale
 	split(s, a, ":");
 	alen = length(a);
 
+	if (alen > 0 && a[1] == "OVERSAMPLING_FACTOR") {
+		if (alen != 2)
+			return (-1);
+		init_drift(floor(a[2]));
+		return (-1);
+	}
+
 	if (alen == 1 || alen == 2) {
-		if (a[1] == "nyquist_hover") {
+		if (a[1] == "NYQUIST_HOVER") {
 			i = 1.0 * a[2];
 			Z_NYQUIST_HOVER = (i > 0.0 && i < 1.0) ? i : 0.0;
 			return (-1);
@@ -493,6 +500,33 @@ function genlerp(bit, use64, lerp)
 	    bit, (bit < 10) ? "\t" : "", lerp);
 }
 
+function init_drift(drift, xdrift)
+{
+	xdrift = floor(drift);
+
+	if (Z_DRIFT_SHIFT != -1) {
+		if (xdrift != Z_DRIFT_SHIFT)
+			printf("#error Z_DRIFT_SHIFT reinitialize!\n");
+		return;
+	}
+
+	#
+	# Initialize filter oversampling factor, or in other word
+	# Z_DRIFT_SHIFT.
+	#
+	if (xdrift < 0)
+		xdrift = 1;
+	else if (xdrift > 31)
+		xdrift = 31;
+
+	Z_DRIFT_SHIFT  = xdrift;
+	Z_DRIFT_ONE    = shl(1, Z_DRIFT_SHIFT);
+
+	Z_SHIFT        = Z_FULL_SHIFT - Z_DRIFT_SHIFT;
+	Z_ONE          = shl(1, Z_SHIFT);
+	Z_MASK         = Z_ONE - 1;
+}
+
 BEGIN {
 	I0_EPSILON = 1e-21;
 	M_PI = atan2(0.0, -1.0);
@@ -511,25 +545,14 @@ BEGIN {
 	Z_INTERP_COEFF_SHIFT = 24;
 	Z_INTERP_COEFF_ONE   = shl(1, Z_INTERP_COEFF_SHIFT);
 
-	#
-	# Filter oversampling factor.
-	#
-	# 6, 7, or 8 depending on how much you can trade off between memory
-	# consumption (due to large tables) and precision / quality.
-	#
-	Z_DRIFT_SHIFT   = 7;
-	Z_DRIFT_ONE     = shl(1, Z_DRIFT_SHIFT);
-
-	Z_SHIFT         = Z_FULL_SHIFT - Z_DRIFT_SHIFT;
-	Z_ONE           = shl(1, Z_SHIFT);
-	Z_MASK          = Z_ONE - 1;
-
 	Z_LINEAR_FULL_SHIFT = Z_FULL_SHIFT;
 	Z_LINEAR_FULL_ONE   = shl(1, Z_LINEAR_FULL_SHIFT);
 	Z_LINEAR_SHIFT      = 8;
 	Z_LINEAR_UNSHIFT    = Z_LINEAR_FULL_SHIFT - Z_LINEAR_SHIFT;
 	Z_LINEAR_ONE        = shl(1, Z_LINEAR_SHIFT)
 
+	Z_DRIFT_SHIFT_DEFAULT = 5;
+	Z_DRIFT_SHIFT         = -1;
 	# meehhhh... let it overflow...
 	#Z_SCALE_SHIFT   = 31;
 	#Z_SCALE_ONE     = shl(1, Z_SCALE_SHIFT);
@@ -595,6 +618,8 @@ BEGIN {
 			beta = Popts["beta"];
 			nmult = Popts["nmult"];
 			rolloff = Popts["rolloff"];
+			if (Z_DRIFT_SHIFT == -1)
+				init_drift(Z_DRIFT_SHIFT_DEFAULT);
 			ztab[imp["quality"] - 2] =				\
 			    mkfilter(imp, nmult, rolloff, beta, Z_DRIFT_ONE);
 			imp["quality"]++;


More information about the svn-src-all mailing list