From 742980f94c4018bb38e09f2437dd708d4ecda2b3 Mon Sep 17 00:00:00 2001 From: Andree Buschmann Date: Wed, 16 Mar 2011 22:05:46 +0000 Subject: [PATCH] Avoid magic numbers. Use the available defines to set up the bit mask to compare MPEG frame headers. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29607 a1c6a512-1295-4272-9138-f99709370657 --- apps/mp3data.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/apps/mp3data.c b/apps/mp3data.c index 31ed492679..90362e33ec 100644 --- a/apps/mp3data.c +++ b/apps/mp3data.c @@ -49,19 +49,19 @@ #define VDEBUGF(...) do { } while(0) #endif -#define SYNC_MASK (0x7ffL << 21) -#define VERSION_MASK (3L << 19) -#define LAYER_MASK (3L << 17) -#define PROTECTION_MASK (1L << 16) -#define BITRATE_MASK (0xfL << 12) -#define SAMPLERATE_MASK (3L << 10) -#define PADDING_MASK (1L << 9) -#define PRIVATE_MASK (1L << 8) -#define CHANNELMODE_MASK (3L << 6) -#define MODE_EXT_MASK (3L << 4) -#define COPYRIGHT_MASK (1L << 3) -#define ORIGINAL_MASK (1L << 2) -#define EMPHASIS_MASK 3L +#define SYNC_MASK (0x7ffL << 21) +#define VERSION_MASK (3L << 19) +#define LAYER_MASK (3L << 17) +#define PROTECTION_MASK (1L << 16) +#define BITRATE_MASK (0xfL << 12) +#define SAMPLERATE_MASK (3L << 10) +#define PADDING_MASK (1L << 9) +#define PRIVATE_MASK (1L << 8) +#define CHANNELMODE_MASK (3L << 6) +#define MODE_EXT_MASK (3L << 4) +#define COPYRIGHT_MASK (1L << 3) +#define ORIGINAL_MASK (1L << 2) +#define EMPHASIS_MASK (3L) /* MPEG Version table, sorted by version index */ static const signed char version_table[4] = { @@ -206,8 +206,8 @@ static bool headers_have_same_type(unsigned long header1, unsigned long header2) { /* Compare MPEG version, layer and sampling frequency. If header1 is zero - * it is assumed the headers are of same type. */ - unsigned int mask = 0xfffe0c00; + * it is assumed both frame headers are of same type. */ + unsigned int mask = SYNC_MASK | VERSION_MASK | LAYER_MASK | SAMPLERATE_MASK; header1 &= mask; header2 &= mask; return header1 ? (header1 == header2) : true;