All of lore.kernel.org
 help / color / mirror / Atom feed
* [Bluez-devel] libsbc optimizing
@ 2005-05-18 23:31 Brad Midgley
  2005-05-20 22:04 ` Henryk Plötz
  0 siblings, 1 reply; 7+ messages in thread
From: Brad Midgley @ 2005-05-18 23:31 UTC (permalink / raw)
  To: BlueZ Mailing List

[-- 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;
 				}
 			}
 		}

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-05-24 17:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-18 23:31 [Bluez-devel] libsbc optimizing Brad Midgley
2005-05-20 22:04 ` 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

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.