diff options
| author | Brad Midgley <bmidgley@xmission.com> | 2007-11-30 01:20:01 +0000 | 
|---|---|---|
| committer | Brad Midgley <bmidgley@xmission.com> | 2007-11-30 01:20:01 +0000 | 
| commit | 76e595a98b7b73ee54ae17e6162f05ad81c9b654 (patch) | |
| tree | 3385bcb5b4db32b30b7cd2ec8118e050487a80fc /sbc/sbc.c | |
| parent | 4161e8201ea54fe605b2aa14d864e0bad941c5d8 (diff) | |
change inner loop bit packing to use shift-in-place instead of complex ops
Diffstat (limited to 'sbc/sbc.c')
| -rw-r--r-- | sbc/sbc.c | 15 | 
1 files changed, 8 insertions, 7 deletions
| @@ -1162,20 +1162,21 @@ static int sbc_pack_frame(uint8_t *data, struct sbc_frame *frame, size_t len)  					audio_sample = 0;  				if (bits[ch][sb] != 0) { +					audio_sample <<= 16 - bits[ch][sb];  					for (bit = 0; bit < bits[ch][sb]; bit++) { -						int b;	/* A bit */ -						if (produced % 8 == 0) -							data[produced >> 3] = 0; -						b = ((audio_sample) >> -								(bits[ch][sb] - bit - 1)) & 0x01; -						data[produced >> 3] |= b << (7 - (produced % 8)); +						data[produced >> 3] <<= 1; +						if(audio_sample & 0x8000) +							data[produced >> 3] |= 0x1; +						audio_sample <<= 1;  						produced++;  					}  				}  			}  		}  	} - +	/* align the last byte */ +	if(produced % 8) data[produced >> 3] <<= 8 - (produced % 8); +	  	return (produced + 7) >> 3;  } | 
