Skip to contentSkip to conversation

libmad: Add optimization config options

PATCH Superseded Benoît Thébaudeau 2 participants 6 messages Jul 13, 2012 1 message not in the archive

lore
Share & tools
lore
#1 lore raw

PATCH 1/1 libmad: Add optimization config options

In reply to a message not in the archive

Configuring libmad with --enable-speed compromises accuracy and can cause audio clipping in some cases (heard on ARM platform with some loud MP3s), so give users the choice of MAD optimizations.

The default config corresponds to the default behavior of libmad's configure.

---
 .../package/libmad/Config.in                       |   41 ++++++++++++++++++++
 .../package/libmad/libmad.mk                       |    6 ++-
 2 files changed, 46 insertions(+), 1 deletion(-)
package/libmad/Config.in +41 -0
index 4d4f930..d4d08de 100644
@@ -6,3 +6,44 @@ config BR2_PACKAGE_LIBMAD
 	  without a floating-point unit.
 
 	  http://www.underbit.com/products/mad/
+
+if BR2_PACKAGE_LIBMAD
+
+choice
+	prompt "Speed vs. accuracy"
+	default BR2_PACKAGE_LIBMAD_SPEED_ACCURACY
+
+config BR2_PACKAGE_LIBMAD_SPEED
+	bool "Optimize for speed over accuracy"
+	help
+	  Compromise accuracy for speed.
+
+config BR2_PACKAGE_LIBMAD_ACCURACY
+	bool "Optimize for accuracy over speed"
+	help
+	  Compromise speed for accuracy.
+
+config BR2_PACKAGE_LIBMAD_SPEED_ACCURACY
+	bool "Optimize for both speed and accuracy"
+	help
+	  Keep optimizations balanced between speed and accuracy.
+
+endchoice
+
+config BR2_PACKAGE_LIBMAD_SSO
+	bool "Subband synthesis optimization"
+	help
+	  Use the subband synthesis optimization, with reduced accuracy.
+
+config BR2_PACKAGE_LIBMAD_ASO
+	bool "Architecture-specific optimizations"
+	default y
+	help
+	  Use certain architecture-specific optimizations.
+
+config BR2_PACKAGE_LIBMAD_STRICT_ISO
+	bool "Strict ISO/IEC interpretations"
+	help
+	  Use strict ISO/IEC interpretations.
+
+endif
package/libmad/libmad.mk +5 -1
index 6e53cf2..ce9b9f6 100644
@@ -30,6 +30,10 @@ LIBMAD_POST_INSTALL_TARGET_HOOKS += LIBMAD_INSTALL_TARGET_PC
 
 LIBMAD_CONF_OPT = \
 		--disable-debugging \
-		--enable-speed
+		$(if $(BR2_PACKAGE_LIBMAD_SPEED),--enable-speed) \
+		$(if $(BR2_PACKAGE_LIBMAD_ACCURACY),--enable-accuracy) \
+		--$(if $(BR2_PACKAGE_LIBMAD_SSO),enable,disable)-sso \
+		--$(if $(BR2_PACKAGE_LIBMAD_ASO),enable,disable)-aso \
+		--$(if $(BR2_PACKAGE_LIBMAD_STRICT_ISO),enable,disable)-strict-iso
 
 $(eval $(call AUTOTARGETS))
#2 lore raw

PATCH v2 1/1 libmad: Add optimization config options

Configuring libmad with --enable-speed compromises accuracy and can cause audio clipping in some cases (heard on ARM platform with some loud MP3s), so give users the choice of MAD optimizations.

The default config corresponds to the default behavior of libmad's configure.

---
Note that, if applicable, the options are always passed with either '--enable-' or '--disable-' to be more robust than a simple omission, since this can avoid a mismatch in config options if the package version is changed and its new default configure options are different.

Changes for v2:
- Factorize the 'able' in the $(if ).

 .../package/libmad/Config.in                       |   41 ++++++++++++++++++++
 .../package/libmad/libmad.mk                       |    6 ++-
 2 files changed, 46 insertions(+), 1 deletion(-)
package/libmad/Config.in +41 -0
index 4d4f930..d4d08de 100644
@@ -6,3 +6,44 @@ config BR2_PACKAGE_LIBMAD
 	  without a floating-point unit.
 
 	  http://www.underbit.com/products/mad/
+
+if BR2_PACKAGE_LIBMAD
+
+choice
+	prompt "Speed vs. accuracy"
+	default BR2_PACKAGE_LIBMAD_SPEED_ACCURACY
+
+config BR2_PACKAGE_LIBMAD_SPEED
+	bool "Optimize for speed over accuracy"
+	help
+	  Compromise accuracy for speed.
+
+config BR2_PACKAGE_LIBMAD_ACCURACY
+	bool "Optimize for accuracy over speed"
+	help
+	  Compromise speed for accuracy.
+
+config BR2_PACKAGE_LIBMAD_SPEED_ACCURACY
+	bool "Optimize for both speed and accuracy"
+	help
+	  Keep optimizations balanced between speed and accuracy.
+
+endchoice
+
+config BR2_PACKAGE_LIBMAD_SSO
+	bool "Subband synthesis optimization"
+	help
+	  Use the subband synthesis optimization, with reduced accuracy.
+
+config BR2_PACKAGE_LIBMAD_ASO
+	bool "Architecture-specific optimizations"
+	default y
+	help
+	  Use certain architecture-specific optimizations.
+
+config BR2_PACKAGE_LIBMAD_STRICT_ISO
+	bool "Strict ISO/IEC interpretations"
+	help
+	  Use strict ISO/IEC interpretations.
+
+endif
package/libmad/libmad.mk +5 -1
index 6e53cf2..1c77e28 100644
@@ -30,6 +30,10 @@ LIBMAD_POST_INSTALL_TARGET_HOOKS += LIBMAD_INSTALL_TARGET_PC
 
 LIBMAD_CONF_OPT = \
 		--disable-debugging \
-		--enable-speed
+		$(if $(BR2_PACKAGE_LIBMAD_SPEED),--enable-speed) \
+		$(if $(BR2_PACKAGE_LIBMAD_ACCURACY),--enable-accuracy) \
+		--$(if $(BR2_PACKAGE_LIBMAD_SSO),en,dis)able-sso \
+		--$(if $(BR2_PACKAGE_LIBMAD_ASO),en,dis)able-aso \
+		--$(if $(BR2_PACKAGE_LIBMAD_STRICT_ISO),en,dis)able-strict-iso
 
 $(eval $(call AUTOTARGETS))
#3 lore raw

PATCH v2 1/1 libmad: Add optimization config options

Hello,

Le Fri, 13 Jul 2012 19:25:12 +0200 (CEST),
Beno?t Th?baudeau <[email protected]> a ?crit :

Quoted 2 lines

Changes for v2:
- Factorize the 'able' in the $(if ).

I prefer the solution in v1 with regard to this, as it is much easier to read.

package/libmad/Config.in config BR2_PACKAGE_LIBMAD · line 14

Quoted 3 lines
package/libmad/Config.in +3 -0
+choice
+	prompt "Speed vs. accuracy"
+	default BR2_PACKAGE_LIBMAD_SPEED_ACCURACY

What about calling those options:

BR2_PACKAGE_LIBMAD_OPTIMIZATION_SPEED
BR2_PACKAGE_LIBMAD_OPTIMIZATION_ACCURACY
BR2_PACKAGE_LIBMAD_OPTIMIZATION_DEFAULT

package/libmad/Config.in config BR2_PACKAGE_LIBMAD · line 27

Quoted 2 lines
package/libmad/Config.in +2 -0
+config BR2_PACKAGE_LIBMAD_SPEED_ACCURACY
+	bool "Optimize for both speed and accuracy"

This should rather be:

bool "Default"

or something like that. Technically, this option does not enable any special optimization for both speed and accuracy, it just uses the default options.

Thanks,

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#4 lore raw

PATCH v2 1/1 libmad: Add optimization config options

Hi Thomas,

Quoted 5 lines
Quoted 2 lines

Changes for v2:
- Factorize the 'able' in the $(if ).

I prefer the solution in v1 with regard to this, as it is much easier to read.

As you prefer.

Quoted 15 lines

package/libmad/Config.in config BR2_PACKAGE_LIBMAD · line 14

Quoted 3 lines
package/libmad/Config.in +3 -0
+choice
+	prompt "Speed vs. accuracy"
+	default BR2_PACKAGE_LIBMAD_SPEED_ACCURACY

What about calling those options:

BR2_PACKAGE_LIBMAD_OPTIMIZATION_SPEED
BR2_PACKAGE_LIBMAD_OPTIMIZATION_ACCURACY
BR2_PACKAGE_LIBMAD_OPTIMIZATION_DEFAULT

package/libmad/Config.in config BR2_PACKAGE_LIBMAD · line 27

Quoted 2 lines
package/libmad/Config.in +2 -0
+config BR2_PACKAGE_LIBMAD_SPEED_ACCURACY
+	bool "Optimize for both speed and accuracy"

This should rather be:

Quoted 5 lines

bool "Default"

or something like that. Technically, this option does not enable any special optimization for both speed and accuracy, it just uses the default options.

Actually, libmad's README says that the default options (neither --enable-speed nor --enable-accuracy) imply an optimization of both:

"Note that you need not specify one of --enable-speed or --enable-accuracy; in its default configuration, MAD is optimized for both."

But it refuses to configure with both options, and there is indeed technically nothing special done by default.

I'll post a v3 doing all that.

Regards,
Beno?t

#5 lore raw

PATCH v3 1/1 libmad: Add optimization config options

Configuring libmad with --enable-speed compromises accuracy and can cause audio clipping in some cases (heard on ARM platform with some loud MP3s), so give users the choice of MAD optimizations.

The default config corresponds to the default behavior of libmad's configure.

---
Note that, if applicable, the options are always passed with either '--enable-' or '--disable-' to be more robust than a simple omission, since this can avoid a mismatch in config options if the package version is changed and its new default configure options are different.

Changes for v2:
- Factorize the 'able' in the $(if ).

Changes for v3 (according to Thomas Petazzoni's comments):
- Undo v2.
- Rename the speed vs. accuracy choice configs to BR2_PACKAGE_LIBMAD_OPTIMIZATION_*.
- Use 'default' naming if neither speed nor accuracy is compromised for the other.

 .../package/libmad/Config.in                       |   41 ++++++++++++++++++++
 .../package/libmad/libmad.mk                       |    6 ++-
 2 files changed, 46 insertions(+), 1 deletion(-)
package/libmad/Config.in +41 -0
index 4d4f930..d0edc49 100644
@@ -6,3 +6,44 @@ config BR2_PACKAGE_LIBMAD
 	  without a floating-point unit.
 
 	  http://www.underbit.com/products/mad/
+
+if BR2_PACKAGE_LIBMAD
+
+choice
+	prompt "Speed vs. accuracy"
+	default BR2_PACKAGE_LIBMAD_OPTIMIZATION_DEFAULT
+
+config BR2_PACKAGE_LIBMAD_OPTIMIZATION_DEFAULT
+	bool "Default"
+	help
+	  Keep optimizations balanced between speed and accuracy.
+
+config BR2_PACKAGE_LIBMAD_OPTIMIZATION_SPEED
+	bool "Optimize for speed over accuracy"
+	help
+	  Compromise accuracy for speed.
+
+config BR2_PACKAGE_LIBMAD_OPTIMIZATION_ACCURACY
+	bool "Optimize for accuracy over speed"
+	help
+	  Compromise speed for accuracy.
+
+endchoice
+
+config BR2_PACKAGE_LIBMAD_SSO
+	bool "Subband synthesis optimization"
+	help
+	  Use the subband synthesis optimization, with reduced accuracy.
+
+config BR2_PACKAGE_LIBMAD_ASO
+	bool "Architecture-specific optimizations"
+	default y
+	help
+	  Use certain architecture-specific optimizations.
+
+config BR2_PACKAGE_LIBMAD_STRICT_ISO
+	bool "Strict ISO/IEC interpretations"
+	help
+	  Use strict ISO/IEC interpretations.
+
+endif
package/libmad/libmad.mk +5 -1
index 6e53cf2..3c92d52 100644
@@ -30,6 +30,10 @@ LIBMAD_POST_INSTALL_TARGET_HOOKS += LIBMAD_INSTALL_TARGET_PC
 
 LIBMAD_CONF_OPT = \
 		--disable-debugging \
-		--enable-speed
+		$(if $(BR2_PACKAGE_LIBMAD_OPTIMIZATION_SPEED),--enable-speed) \
+		$(if $(BR2_PACKAGE_LIBMAD_OPTIMIZATION_ACCURACY),--enable-accuracy) \
+		--$(if $(BR2_PACKAGE_LIBMAD_SSO),enable,disable)-sso \
+		--$(if $(BR2_PACKAGE_LIBMAD_ASO),enable,disable)-aso \
+		--$(if $(BR2_PACKAGE_LIBMAD_STRICT_ISO),enable,disable)-strict-iso
 
 $(eval $(call AUTOTARGETS))
#6 lore raw

PATCH v3 1/1 libmad: Add optimization config options

Le Fri, 13 Jul 2012 22:14:05 +0200 (CEST),
Beno?t Th?baudeau <[email protected]> a ?crit :

Quoted 7 lines

Configuring libmad with --enable-speed compromises accuracy and can cause audio clipping in some cases (heard on ARM platform with some loud MP3s), so give users the choice of MAD optimizations.

The default config corresponds to the default behavior of libmad's configure.

Applied, thanks.

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com