All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brad Midgley <bmidgley@xmission.com>
To: BlueZ Mailing List <bluez-devel@lists.sourceforge.net>
Subject: [Bluez-devel] libsbc optimizing
Date: Wed, 18 May 2005 17:31:10 -0600	[thread overview]
Message-ID: <428BD03E.9000307@xmission.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 827 bytes --]

Hi,

I have been looking at the problem of libsbc performance on arm. My 
first pass is on the decoder. I'm trying to cut down deeply nested fp 
multiply/divide ops.

I originally planned regression tests in the build process for 
performance/correctness but decided against them:

  - performance may actually go down on x86 where I build when we reduce 
  fp usage
  - the character of roundoff errors will change and the lossy stream 
will probably look different even when it is still "correct"

Anyway, I will need to know the range of certain values in order to make 
much progress. I tried hunting down how they are calculated but it gets 
difficult very quickly.

Can I get help with the ranges for bits[ch][sb] in sbc_unpack_frame and 
the state.* vectors if they're bounded?

How about this first little patch?

Brad

[-- Attachment #2: opt1.patch --]
[-- Type: text/plain, Size: 1884 bytes --]

Index: sbc/sbc.c
===================================================================
RCS file: /cvsroot/bluetooth-alsa/btsco/sbc/sbc.c,v
retrieving revision 1.33
diff -u -b -B -w -p -r1.33 sbc.c
--- sbc/sbc.c	17 May 2005 06:48:02 -0000	1.33
+++ sbc/sbc.c	18 May 2005 22:32:13 -0000
@@ -391,7 +391,6 @@ static int sbc_unpack_frame(const u_int8
 	int bits[2][8];		/* bits distribution */
 	int levels[2][8];	/* levels derived from that */
 
-	double scalefactor[2][8];	/* derived from frame->scale_factors */
 
 	if (len < 4)
 		return -1;
@@ -525,7 +524,6 @@ static int sbc_unpack_frame(const u_int8
 	for (ch = 0; ch < frame->channels; ch++) {
 		for (sb = 0; sb < frame->subbands; sb++) {
 			levels[ch][sb] = (1 << bits[ch][sb]) - 1;
-			scalefactor[ch][sb] = 2 << frame->scale_factor[ch][sb];
 		}
 	}
 
@@ -534,8 +532,8 @@ static int sbc_unpack_frame(const u_int8
 			for (sb = 0; sb < frame->subbands; sb++) {
 				if (levels[ch][sb] > 0) {
 					frame->sb_sample[blk][ch][sb] =
-					    scalefactor[ch][sb] * ((frame->audio_sample[blk][ch][sb] * 2.0 + 1.0) /
-								   levels[ch][sb] - 1.0);
+						(((frame->audio_sample[blk][ch][sb] << 1) | 1) << frame->scale_factor[ch][sb])/(float)levels[ch][sb]
+						- (1 << frame->scale_factor[ch][sb]);
 				} else {
 					frame->sb_sample[blk][ch][sb] = 0;
 				}
@@ -547,10 +545,11 @@ static int sbc_unpack_frame(const u_int8
 		for (blk = 0; blk < frame->blocks; blk++) {
 			for (sb = 0; sb < frame->subbands; sb++) {
 				if (frame->join & (0x01 << sb)) {
-					frame->sb_sample[blk][0][sb] =
+					double temp =
 					    frame->sb_sample[blk][0][sb] + frame->sb_sample[blk][1][sb];
 					frame->sb_sample[blk][1][sb] =
-					    frame->sb_sample[blk][0][sb] - 2 * frame->sb_sample[blk][1][sb];
+					    frame->sb_sample[blk][0][sb] - frame->sb_sample[blk][1][sb];
+					frame->sb_sample[blk][0][sb] = temp;
 				}
 			}
 		}

             reply	other threads:[~2005-05-18 23:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-18 23:31 Brad Midgley [this message]
2005-05-20 22:04 ` [Bluez-devel] libsbc optimizing Henryk Plötz
2005-05-21  0:14   ` Brad Midgley
2005-05-21  0:28     ` Brad Midgley
2005-05-24 16:55       ` Brad Midgley
2005-05-24 17:10         ` Marcel Holtmann
2005-05-24 17:59           ` Brad Midgley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=428BD03E.9000307@xmission.com \
    --to=bmidgley@xmission.com \
    --cc=bluez-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.