Subject: misc/6497: Add "mp3" audio file information to file(1)/magic
To: None <gnats-bugs@gnats.netbsd.org>
From: C Kane <ckane@best.com>
List: netbsd-bugs
Date: 11/24/1998 18:47:25
>Number: 6497
>Category: misc
>Synopsis: Add "mp3" audio file information to file(1)/magic
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: misc-bug-people (Misc Bug People)
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Tue Nov 24 20:05:10 1998
>Last-Modified:
>Originator: C Kane
>Organization:
>Release: NetBSD-1.3.2
>Environment:
System: NetBSD ckane2 1.3.2 NetBSD 1.3.2 (ckane2) #2: Sun Jul 26 23:00:18 PDT 1998 ckane@ckane2:/usr/src/sys/arch/i386/compile/ckane2 i386
>Description:
Add information to /usr/share/misc/magic so that file(1) can
properly identify "mp3" audio files.
>How-To-Repeat:
Try "file *.mp3" before and after modifying the magic file.
Before:
file1.mp3: MPEG audio stream data
file2.mp3: MPEG audio stream data
file3.mp3: MPEG audio stream data
After:
file1.mp3: MPEG 1.0 Layer III, 128 kbit/s, 44100 Hz joint-stereo
file2.mp3: MPEG 2.0 Layer III, 64 kbit/s, 22050 Hz joint-stereo
file2.mp3: MPEG 2.0 Layer III, 32 kbit/s, 22050 Hz mono
>Fix:
Apply this diff. If file(1) can do math on the matched value
before printing it out (using %d), this could be shorter.
*** /usr/share/misc/magic Wed Nov 4 02:11:39 1998
--- /tmp/magic-new Tue Nov 24 18:30:41 1998
***************
*** 350,356 ****
#>4 beshort&0xfff0 x (%d x
#>5 beshort&0x0fff x %d)
0 belong 0x000001ba MPEG system stream data
! 0 beshort&0xfff0 0xfff0 MPEG audio stream data
# FLI animation format
4 leshort 0xAF11 FLI file
--- 350,357 ----
#>4 beshort&0xfff0 x (%d x
#>5 beshort&0x0fff x %d)
0 belong 0x000001ba MPEG system stream data
! #MPEG Audio Stream Data magic is later in this file.
! #0 beshort&0xfff0 0xfff0 MPEG audio stream data
# FLI animation format
4 leshort 0xAF11 FLI file
***************
*** 5025,5027 ****
--- 5026,5167 ----
>10 byte&0x0B 3 - ADPCM4 encoding
>10 byte&0x0B 8 - New ADPCM3 encoding
>10 byte&0x04 4 with resync
+
+
+
+ #------------------------
+ # MPEG: file(1) magic for MPEG audio.
+ #
+ # From <ckane@best.com>
+ # Show MPEG level, layer, kbit/s, hz, stereo/mono for an MPG audio file.
+ # This section is lengthy because the kbit/s rate depends on the
+ # level and layer, and file(1) doesn't allow math on the values.
+ #
+
+ ####### MPEG begins with three hex 'f' nibbles.
+ 0 beshort&0xfff0 0xfff0 MPEG
+ ####### Level 2
+ >1 byte&0x08 0x00 2.0
+ >>1 byte&0x06 0x00 Layer Unknown,
+ ####### Level 2, Layers I, II, and III
+ >>1 byte&0x06 0x02 Layer III,
+ >>>2 byte&0xf0 0x00 0 kbit/s,
+ >>>2 byte&0xf0 0x10 8 kbit/s,
+ >>>2 byte&0xf0 0x20 16 kbit/s,
+ >>>2 byte&0xf0 0x30 24 kbit/s,
+ >>>2 byte&0xf0 0x40 32 kbit/s,
+ >>>2 byte&0xf0 0x50 40 kbit/s,
+ >>>2 byte&0xf0 0x60 48 kbit/s,
+ >>>2 byte&0xf0 0x70 56 kbit/s,
+ >>>2 byte&0xf0 0x80 64 kbit/s,
+ >>>2 byte&0xf0 0x90 80 kbit/s,
+ >>>2 byte&0xf0 0xa0 96 kbit/s,
+ >>>2 byte&0xf0 0xb0 112 kbit/s,
+ >>>2 byte&0xf0 0xc0 128 kbit/s,
+ >>>2 byte&0xf0 0xd0 144 kbit/s,
+ >>>2 byte&0xf0 0xe0 160 kbit/s,
+ >>>2 byte&0xf0 0xf0 ? kbit/s,
+ >>1 byte&0x06 0x04 Layer II,
+ >>>2 byte&0xf0 0x00 0 kbit/s,
+ >>>2 byte&0xf0 0x10 8 kbit/s,
+ >>>2 byte&0xf0 0x20 16 kbit/s,
+ >>>2 byte&0xf0 0x30 24 kbit/s,
+ >>>2 byte&0xf0 0x40 32 kbit/s,
+ >>>2 byte&0xf0 0x50 40 kbit/s,
+ >>>2 byte&0xf0 0x60 48 kbit/s,
+ >>>2 byte&0xf0 0x70 56 kbit/s,
+ >>>2 byte&0xf0 0x80 64 kbit/s,
+ >>>2 byte&0xf0 0x90 80 kbit/s,
+ >>>2 byte&0xf0 0xa0 96 kbit/s,
+ >>>2 byte&0xf0 0xb0 112 kbit/s,
+ >>>2 byte&0xf0 0xc0 128 kbit/s,
+ >>>2 byte&0xf0 0xd0 144 kbit/s,
+ >>>2 byte&0xf0 0xe0 160 kbit/s,
+ >>>2 byte&0xf0 0xf0 ? kbit/s,
+ >>1 byte&0x06 0x06 Layer I,
+ >>>2 byte&0xf0 0x00 0 kbit/s,
+ >>>2 byte&0xf0 0x10 32 kbit/s,
+ >>>2 byte&0xf0 0x20 48 kbit/s,
+ >>>2 byte&0xf0 0x30 56 kbit/s,
+ >>>2 byte&0xf0 0x40 64 kbit/s,
+ >>>2 byte&0xf0 0x50 80 kbit/s,
+ >>>2 byte&0xf0 0x60 96 kbit/s,
+ >>>2 byte&0xf0 0x70 112 kbit/s,
+ >>>2 byte&0xf0 0x80 128 kbit/s,
+ >>>2 byte&0xf0 0x90 144 kbit/s,
+ >>>2 byte&0xf0 0xa0 160 kbit/s,
+ >>>2 byte&0xf0 0xb0 176 kbit/s,
+ >>>2 byte&0xf0 0xc0 192 kbit/s,
+ >>>2 byte&0xf0 0xd0 224 kbit/s,
+ >>>2 byte&0xf0 0xe0 256 kbit/s,
+ >>>2 byte&0xf0 0xf0 ? kbit/s,
+ ####### Level 2, Hz
+ >>2 byte&0x0c 0x00 22050 Hz
+ >>2 byte&0x0c 0x04 24000 Hz
+ >>2 byte&0x0c 0x08 16000 Hz
+ >>2 byte&0x0c 0x0c ? Hz
+ ####### Level 1 decoding
+ >1 byte&0x08 0x08 1.0
+ >>1 byte&0x06 0x00 Layer Unknown.
+ ####### Level 1, Layers I, II, and III
+ >>1 byte&0x06 0x02 Layer III,
+ >>>2 byte&0xf0 0x00 0 kbit/s,
+ >>>2 byte&0xf0 0x10 32 kbit/s,
+ >>>2 byte&0xf0 0x20 40 kbit/s,
+ >>>2 byte&0xf0 0x30 48 kbit/s,
+ >>>2 byte&0xf0 0x40 56 kbit/s,
+ >>>2 byte&0xf0 0x50 64 kbit/s,
+ >>>2 byte&0xf0 0x60 80 kbit/s,
+ >>>2 byte&0xf0 0x70 96 kbit/s,
+ >>>2 byte&0xf0 0x80 112 kbit/s,
+ >>>2 byte&0xf0 0x90 128 kbit/s,
+ >>>2 byte&0xf0 0xa0 160 kbit/s,
+ >>>2 byte&0xf0 0xb0 192 kbit/s,
+ >>>2 byte&0xf0 0xc0 224 kbit/s,
+ >>>2 byte&0xf0 0xd0 256 kbit/s,
+ >>>2 byte&0xf0 0xe0 320 kbit/s,
+ >>>2 byte&0xf0 0xf0 ? kbit/s,
+ >>1 byte&0x06 0x04 Layer II,
+ >>>2 byte&0xf0 0x00 0 kbit/s,
+ >>>2 byte&0xf0 0x10 32 kbit/s,
+ >>>2 byte&0xf0 0x20 48 kbit/s,
+ >>>2 byte&0xf0 0x30 56 kbit/s,
+ >>>2 byte&0xf0 0x40 64 kbit/s,
+ >>>2 byte&0xf0 0x50 80 kbit/s,
+ >>>2 byte&0xf0 0x60 96 kbit/s,
+ >>>2 byte&0xf0 0x70 112 kbit/s,
+ >>>2 byte&0xf0 0x80 128 kbit/s,
+ >>>2 byte&0xf0 0x90 160 kbit/s,
+ >>>2 byte&0xf0 0xa0 192 kbit/s,
+ >>>2 byte&0xf0 0xb0 224 kbit/s,
+ >>>2 byte&0xf0 0xc0 256 kbit/s,
+ >>>2 byte&0xf0 0xd0 320 kbit/s,
+ >>>2 byte&0xf0 0xe0 384 kbit/s,
+ >>>2 byte&0xf0 0xf0 ? kbit/s,
+ >>1 byte&0x06 0x06 Layer I,
+ >>>2 byte&0xf0 0x00 0 kbit/s,
+ >>>2 byte&0xf0 0x10 32 kbit/s,
+ >>>2 byte&0xf0 0x20 64 kbit/s,
+ >>>2 byte&0xf0 0x30 96 kbit/s,
+ >>>2 byte&0xf0 0x40 128 kbit/s,
+ >>>2 byte&0xf0 0x50 160 kbit/s,
+ >>>2 byte&0xf0 0x60 192 kbit/s,
+ >>>2 byte&0xf0 0x70 224 kbit/s,
+ >>>2 byte&0xf0 0x80 256 kbit/s,
+ >>>2 byte&0xf0 0x90 288 kbit/s,
+ >>>2 byte&0xf0 0xa0 320 kbit/s,
+ >>>2 byte&0xf0 0xb0 352 kbit/s,
+ >>>2 byte&0xf0 0xc0 384 kbit/s,
+ >>>2 byte&0xf0 0xd0 416 kbit/s,
+ >>>2 byte&0xf0 0xe0 448 kbit/s,
+ >>>2 byte&0xf0 0xf0 ? kbit/s,
+ ####### Level 2, Hz
+ >>2 byte&0x0c 0x00 44100 Hz
+ >>2 byte&0x0c 0x04 48000 Hz
+ >>2 byte&0x0c 0x08 32000 Hz
+ >>2 byte&0x0c 0x0c ? Hz
+ ####### Stereo or Mono
+ >3 byte&0xc0 0x00 stereo
+ >3 byte&0xc0 0x40 joint-stereo
+ >3 byte&0xc0 0x80 dual-channel
+ >3 byte&0xc0 0xc0 mono
>Audit-Trail:
>Unformatted: