OSDN Git Service

aac: Simplify decode_mid_side_stereo
authorLuca Barbato <lu_zero@gentoo.org>
Fri, 21 Nov 2014 12:57:36 +0000 (12:57 +0000)
committerVittorio Giovara <vittorio.giovara@gmail.com>
Tue, 2 Dec 2014 15:28:22 +0000 (15:28 +0000)
Might spare few cycles if the compiler is naive and
makes the function more readable.

libavcodec/aacdec.c

index 76190e2..9c0a46d 100644 (file)
@@ -1419,13 +1419,12 @@ static void decode_mid_side_stereo(ChannelElement *cpe, GetBitContext *gb,
                                    int ms_present)
 {
     int idx;
+    int max_idx = cpe->ch[0].ics.num_window_groups * cpe->ch[0].ics.max_sfb;
     if (ms_present == 1) {
-        for (idx = 0;
-             idx < cpe->ch[0].ics.num_window_groups * cpe->ch[0].ics.max_sfb;
-             idx++)
+        for (idx = 0; idx < max_idx; idx++)
             cpe->ms_mask[idx] = get_bits1(gb);
     } else if (ms_present == 2) {
-        memset(cpe->ms_mask, 1, cpe->ch[0].ics.num_window_groups * cpe->ch[0].ics.max_sfb * sizeof(cpe->ms_mask[0]));
+        memset(cpe->ms_mask, 1, max_idx * sizeof(cpe->ms_mask[0]));
     }
 }