diff options
author | Eric Wong <normalperson@yhbt.net> | 2006-09-03 01:41:43 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2006-09-09 18:57:40 -0700 |
commit | f23b8f5147eed4520ced9a88fc80ec72777b21b4 (patch) | |
tree | f56377d670106b89b0afa46c3bfaeaf06e9fb8e8 | |
parent | 3df8e38af6da6c0699da8ef040ffc80cf7dab810 (diff) | |
download | flac-arm-1.1.3-f23b8f5147eed4520ced9a88fc80ec72777b21b4.tar.gz |
libFLAC/stream_decoder.c: attempt array index overhead reduction
-rw-r--r-- | src/libFLAC/stream_decoder.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/libFLAC/stream_decoder.c b/src/libFLAC/stream_decoder.c index e10de5f5..8c07dad5 100644 --- a/src/libFLAC/stream_decoder.c +++ b/src/libFLAC/stream_decoder.c @@ -1386,8 +1386,6 @@ FLAC__bool frame_sync_(FLAC__StreamDecoder *decoder) FLAC__bool read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame, FLAC__bool do_full_decode) { unsigned channel; - unsigned i; - FLAC__int32 mid, side, left, right; FLAC__uint16 frame_crc; /* the one we calculate from the input stream */ FLAC__uint32 x; @@ -1451,6 +1449,10 @@ FLAC__bool read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame, FL return false; /* the read_callback_ sets the state for us */ if(frame_crc == (FLAC__uint16)x) { if(do_full_decode) { + int i; + FLAC__int32 *lchan, *rchan; + lchan = &(decoder->private_->output[0])[0]; + rchan = &(decoder->private_->output[1])[0]; /* Undo any special channel coding */ switch(decoder->private_->frame.header.channel_assignment) { case FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT: @@ -1458,26 +1460,26 @@ FLAC__bool read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame, FL break; case FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE: FLAC__ASSERT(decoder->private_->frame.header.channels == 2); - for(i = 0; i < decoder->private_->frame.header.blocksize; i++) - decoder->private_->output[1][i] = decoder->private_->output[0][i] - decoder->private_->output[1][i]; + for(i = decoder->private_->frame.header.blocksize; --i >= 0; ) { + *rchan = *(lchan++) - *rchan; + ++rchan; + } break; case FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE: FLAC__ASSERT(decoder->private_->frame.header.channels == 2); - for(i = 0; i < decoder->private_->frame.header.blocksize; i++) - decoder->private_->output[0][i] += decoder->private_->output[1][i]; + for(i = decoder->private_->frame.header.blocksize; --i >= 0; ) + *(lchan++) += *(rchan++); break; case FLAC__CHANNEL_ASSIGNMENT_MID_SIDE: FLAC__ASSERT(decoder->private_->frame.header.channels == 2); - for(i = 0; i < decoder->private_->frame.header.blocksize; i++) { - mid = decoder->private_->output[0][i]; - side = decoder->private_->output[1][i]; + for(i = decoder->private_->frame.header.blocksize; --i >= 0; ) { + FLAC__int32 mid = *lchan; + FLAC__int32 side = *rchan; mid <<= 1; if(side & 1) /* i.e. if 'side' is odd... */ - mid++; - left = mid + side; - right = mid - side; - decoder->private_->output[0][i] = left >> 1; - decoder->private_->output[1][i] = right >> 1; + ++mid; + *(lchan++) = (mid + side) >> 1; + *(rchan++) = (mid - side) >> 1; } break; default: |