slight optimization to conversion of M/S->L/R

This commit is contained in:
Josh Coalson
2007-03-12 07:23:22 +00:00
parent 14b184cced
commit 3847879a55

View File

@@ -1981,7 +1981,7 @@ FLAC__bool read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame, FL
{
unsigned channel;
unsigned i;
FLAC__int32 mid, side, left, right;
FLAC__int32 mid, side;
unsigned frame_crc; /* the one we calculate from the input stream */
FLAC__uint32 x;
@@ -2063,15 +2063,19 @@ FLAC__bool read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame, FL
case FLAC__CHANNEL_ASSIGNMENT_MID_SIDE:
FLAC__ASSERT(decoder->private_->frame.header.channels == 2);
for(i = 0; i < decoder->private_->frame.header.blocksize; i++) {
#if 1
mid = decoder->private_->output[0][i];
side = decoder->private_->output[1][i];
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 |= (side & 1); /* i.e. if 'side' is odd... */
decoder->private_->output[0][i] = (mid + side) >> 1;
decoder->private_->output[1][i] = (mid - side) >> 1;
#else
//@@@@@@ OPT: try without 'side' temp variable
mid = (decoder->private_->output[0][i] << 1) | (decoder->private_->output[1][i] & 1); /* i.e. if 'side' is odd... */
decoder->private_->output[0][i] = (mid + decoder->private_->output[1][i]) >> 1;
decoder->private_->output[1][i] = (mid - decoder->private_->output[1][i]) >> 1;
#endif
}
break;
default: