slight optimization to conversion of M/S->L/R
authorJosh Coalson <jcoalson@users.sourceforce.net>
Mon, 12 Mar 2007 07:23:22 +0000 (07:23 +0000)
committerJosh Coalson <jcoalson@users.sourceforce.net>
Mon, 12 Mar 2007 07:23:22 +0000 (07:23 +0000)
src/libFLAC/stream_decoder.c

index e09db2f..0da4661 100644 (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: