M4A is a file extension for an audio file encoded with Advanced Audio Coding (AAC) which is a lossy compression. M4A stands for MPEG 4 Audio. Audio-only MPEG 4 container files usually have an M4A file extension. The MPEG-4 file format specification was based on the QuickTime format specification. M4A file quality is better and file sizes smaller compared to MP3 files. M4A files sound better than MP3 files when encoded at the same bit rate. The reason that these file extensions are so common is that they have been adopted by Apple for use in the iTunes Music Store.
M4B format is only different from M4A because it can be bookmarked allowing an MP3 player to return exactly to the last listening point. M4B is popular for audiobooks and podcasts for this very reason.
M4P is Apple's version of the M4A format that includes DRM protection, called FairPlay. This is the format used for protected music purchased from the iTunes Music Store.
MPEG-4 Part14 (M4A,M4B,M4P) files consist of consecutive chunks. Each chunk has 8 byte header: 4-byte chunk size (big-endian, high byte first) and 4-byte chunk type - one of pre-defined signatures: "ftyp", "mdat", "moov", "pnot", "udta", "uuid", "moof", "free", "skip", "jP2 ", "wide", "load", "ctab", "imap", "matt", "kmat", "clip", "crgn", "sync", "chap", "tmcd", "scpt", "ssrc", "PICT".
First chunk must be of type "ftype" and has a sub-type at offset 8. M4A defined by sub-type which must be "M4A_", for M4B sub-type must be "M4B_" and for M4P sub-type must be "M4P_".
Iterating chunks, until chunk of unknown type is detected, we compose MPEG-4 Audio file.
When inspecting sample.m4a file's binary data using any Hex Viewer, like Active@ Disk Editor we can see it starts with a signatureftyp (hex: 66 74 79 70) at offset 4, which defines QuickTime Container File Type. File sub-type is M4A_ (hex: 4D 34 41 20) which points to M4A file type. First block size is 24 (hex: 00 00 00 18, big-endian, highest byte first), size located at offset 0. At offset 24 (hex: 18) is located the second chunk, which has a size of 8 and type free (hex: 66 72 65 65). The next chunk is located at offset 24+8=32 (hex: 20) and has a size 93,590 (hex: 00 01 6D 96) and type mdat (hex: 6D 64 61 74) at offset 36 (hex: 24). The next chunk is located at offset 32 + 93,590=93,622 (hex: 01 6D B6) and has a size 2,476 (hex: 00 00 09 AC) and type moov (hex: 6D 6F 6F 76) at offset 93,626 (hex: 01 6D BA). This is the last chunk, so total file size is 93,622+2,476 =96,098 bytes.
https://wiki.multimedia.cx/index.php?title=Apple_Lossless_Audio_Coding
Apple LosslessAudio Coding
· FOURCCS: alac
· Company: Apple
· Technical Description: http://craz.net/programs/itunes/alac.html
· Samples: http://samples.mplayerhq.hu/A-codecs/lossless/ (luckynight.m4a)
Apple Lossless Audio Coding using linear predictionwith Golomb-Rice coding ofthe difference. Similar to FLAC, although the bitstreams are not compatible.Usually stored in an MP4 container, as a private extensionsince it is not part of the MPEG-4 standard.
On October 27, 2011, ALAC was open sourced under theApache License 2.0. The source can be found at http://alac.macosforge.org/.
Contents
[hide]
· 1 Extradata
· 2 FrameHeader
· 3 Verbatimframe
· 4 Compressedframe
· 5 FrameFooter
Extradata
Syntax
Number of bits
Semantics
atom size
32
(0x24), big-endian
tag
32
'alac'
???
32
zero ?
max sample per frame
32
???
8
zero ?
sample size
8
rice history mult
8
rice initial history
8
rice kmodifier
8
channels
8
?
???
16
max coded frame size
32
bitrate
32
?
samplerate
32
Frame Header
Syntax
Number of bits
Semantics
channels
3
Number of channel -1 (Should be the same than in extradata ???)
???
4
??? (seem to be always 0)
???
12
??? (seem to be always 0)
hasoutputsamples
1
the number of samples is stored in the header
wasted_bytes
2
unknow (same as flac ???)
isverbatim
1
if 1, the data is not compressed
if (hasoutputsamples) {
outputsamples
32
number of samples (sometimes the value is wrong [1])
}
[1] http://www1.mplayerhq.hu/MPlayer/samples/A-codecs/lossless/luckynight.m4a need+ 32 and http://www1.mplayerhq.hu/MPlayer/samples/A-codecs/lossless/ALAC/old_midi_stuff.m4a +112
Verbatim frame
Syntax
Number of bits
Semantics
data
sample_size * outputsamples * channels
Unencoded subblock
Compressed frame
Syntax
Number of bits
Semantics
interlacing_shift
8
should be 0 if no channel interlacing.
interlacing_leftweight
8
for each channel {
prediction_type
4
should be 0
prediction_quantitization
4
ricemodifier
3
predictor_coef_num
5
predictor_coef_table
16 * predictor_coef_num
}
for each channel {
compressed data
modfied Rice coding and Adaptive FIR filter
}
Channel Interlacing
It is a mid/side stereo with weight. channel 0 is themid(average) channel, channel 1 is the side(difference) channel.
right = mid -((difference * interlacing_leftweight) >> interlacing_shift)
left = right +difference
It seems we have interlacing_leftweight ==interlacing_shift in most of the samples
Frame Footer
Syntax
Number of bits
Semantics
EOF
3
should be always 7
Categories:
· LosslessAudio Codecs
· Audio Codecs
Navigation menu
· Log in
· Page
· Discussion
· Read
· View source
· View history
窗体顶端
窗体底端
· Main Page
· Recent changes
· Video Codecs
· Video FourCCs
· Audio Codecs
· Container Formats
· Game Formats
· Subtitle Formats
· Image Formats
· All Categories
· Randompage
Tools
· What links here
· Related changes
· Specialpages
· Printableversion
· Permanentlink
· Page information
· This page was last modified on 27 October 2011, at 18:08.
· This page has been accessed 23,223 times.