Introduction
An OpenMG audio file holds music prepared by Sony’s OpenMG and SonicStage software, for MiniDisc (ATRAC3 in the LP modes), Walkman players and the PSP. The extensions are .oma (the usual one), .omg and .aa3. The file is a thin wrapper: a tag with the title and artist, a 96-byte header that names the codec, and the sound data, which is cut into packets of one fixed size.
The codec is most often ATRAC3 (the LP2 and LP4 rates of 132 and 66 kbit/s) or ATRAC3plus (48 to 352 kbit/s). The same wrapper also carries AAC, MP3 and uncompressed 16-bit PCM, and two lossless layers (ATRAC Advanced Lossless). Files bought from the old OpenMG store were encrypted; the key ring that unlocks them sits in the tag.
Structure
A file has up to three parts. The tag is optional: players accept a file that starts with the EA3 header.
0Tag the letters ea3, a version, a 28-bit size and frames: title, artist, and for protected files the key ringoptionaltag sizeEA3 header the letters EA3, the encryption id, the codec id, the codec parameters and the initial value96 bytes…Sound data packets of one fixed size, in the codec named by the headerto the end
The reference pages give every field:
- The ea3 tag – the ID3v2-style tag: header, frames, the text fields, the key ring object and padding
- EA3 header – the 96 bytes: magic, size, encryption id, codec id, parameters, initial value
- Codecs and packets – the codec ids, what the parameter word means for each, the packet sizes, the sound data of each codec and the lossless chunks
- ATRAC3 – the sound unit syntax and how the sound is rebuilt: gain control, tonal components, spectrum, joint stereo, filter bank
- ATRAC3plus – channel units, word lengths, scale factors, the Huffman-coded spectrum, gain control, tones and the synthesis
- Encryption – the key ring, the key checks and the DES-CBC layer, the built-in key table, and how to open a file with a key of your own
The AAC payload is plain AAC in ADTS and the MP3 payload is plain MP3. The tag is the one of ID3v2 with the three letters changed.
What the pages follow
OpenMG was never published as a document. The pages follow the readers and writers that implement it: FFmpeg’s
OMA reader and writer (omadec.c, oma.c, oma.h, omaenc.c) and its ATRAC3 decoder (atrac3.c),
checked against the open-source encoder atracdenc, which writes the container and ATRAC3 and ATRAC3plus frames of its own.
The explorer reads the tag, the header, every ATRAC3 sound unit down to its gain control points, tonal components and
spectrum codes, and plays ATRAC3, ATRAC3plus, linear PCM, MP3, AAC and WMA (an ASF file inside the OMA file). The sound of every codec it plays was compared with FFmpeg’s
output for the same file: ATRAC3 (both stereo modes) agrees to within 1e−7 of full scale, linear PCM exactly.
Sources
- FFmpeg
libavformat/omadec.c,oma.c,oma.h,omaenc.cand the ID3v2 reader: the probe, the tag, the header, the codec ids, the parameter word, the key ring and the DES layer. - FFmpeg
libavcodec/atrac3.c,atrac3data.handatrac.c: the ATRAC3 frame syntax, tables and synthesis. - FFmpeg
libavcodec/atrac3plus.c,atrac3plus_data.h,atrac3plusdsp.candatrac3plusdec.c: the ATRAC3plus frame syntax, tables and synthesis. - FFmpeg
libavcodec/atrac3plus*.c: the ATRAC3plus parameter word and the frame size (the frame syntax itself is not described yet). - ATRACodec (github.com/Solari0225/ATRACodec, commit c7428888, GPL-3, one commit): the data flow and tables of the ATRAC3 integer core of ATRAC Advanced Lossless. A lead only, not a Sony source.
- atracdenc (commit cb17070), an ATRAC3 and ATRAC3plus encoder with its own OMA writer, used to make test files.
- FFmpeg’s sample set at samples.ffmpeg.org/oma: three real files (ATRAC3, ATRAC3plus, an encrypted file).
- Sony SonicStage 4.3 (the OpenMG cabinet,
OMGUtils.dll): the disassembly ofEa3::Header(getOmgcid,getTcid,getEid,getCodecId,getRelativeVolume,checkCodecInfoAT3/ATX,checkCodecInfoLosslessAT3/ATX,getLosslessTotalSamples,getLosslessTotalSuCount,setAt3Param) gives the meaning of header bytes 6 to 7, 12 to 31, 32 to 35, 40 to 43, 47 and 48 to 51. - FFmpeg
libavcodec/wmadec.c,wma.c,wmadata.h,wma_freqs.candaactab.c, andlibavformat/asfdec_f.candasf.c, with the Microsoft ASF specification: the WMA version 1 and 2 decoder and the ASF container of codec id 5 (WMA section). - ID3v2.3 informal standard, for the tag frames.
Not described
The pages follow the container, ATRAC3 and ATRAC3plus. The explorer shows every field it can read, plays ATRAC3, ATRAC3plus, MP3, AAC, WMA and PCM, lists the frames of every codec, and plays an encrypted file with the three built-in keys of FFmpeg’s demuxer (or with a key you type).
Known, not yet covered
- Reference and viewer: the ATRAC3 core of ATRAC Advanced Lossless (codec id 34). The chunk headers and the enhancement packets are described and parse exactly, and the ATRAC3plus core (id 33) is decoded with an integer core and shown to give the original samples (the proof); for id 34 only one real file exists, from a different source. The viewer adds the correction to an integer ATRAC3 core written from the ATRACodec source, which gives a cleaner sum than the floating-point core, but it cannot be shown to be sample-exact: the decoder code of SonicStage 4.3 is stored in encrypted modules (
.ocmfiles, loaded bysalwrap.dll) and no plain ATRAC3 decoder is in the installer, and no second file or decoder exists to compare with, so the played samples can be a few steps off. - Viewer: the other kinds of WMA stream that the ASF file of a codec id 5 file could carry. The decoder plays WMA version 1 and 2 (format tags 0x160 and 0x161), with exponent coding by Huffman code or by line spectral pairs, and matches FFmpeg on real files of both. WMA Professional (0x162), WMA Lossless (0x163), WMA Voice and protected (DRM) streams are not decoded: no source for a decoder of the first three was read in this stage. No real OMA file with any of them exists in reach, and the only OMA file with WMA inside holds a version 2 stream.
- Reference and viewer: mono and multichannel ATRAC3plus: no real file with one channel or more than two exists in reach, so the layouts are read from FFmpeg’s source only.
Unknown
- The meaning of the WMA parameter bytes 33 to 35 (40 80 44) of the codec id 5 header. Bytes 36 to 39 are the play duration in milliseconds minus the preroll (0x3302BA = 3,343,034, equal to the ASF header’s values) and bytes 40 to 43 the ASF packet count (9,000), but Sony’s header class (
Ea3::HeaderinOMGUtils.dll) has no code for any of them, and the code that writes them is inside Sony’s encrypted modules. In the one file the middle byte of the three equals the bit rate in kbit/s (128) and the last byte the digits 44 of the sample rate; the first byte (0x40) matches nothing in the ASF header. - The meaning of the header version byte (0 in FFmpeg’s files, 1 in atracdenc’s, 3 in the .aa3 files): no reader tests it.
- The ATRAC3plus noise level and table index, tone amplitude mode 0 and the channel unit extension: FFmpeg reads the first, rejects the other two, and no other source describes them.
Links
Software
- FFmpeg – command-line tool that reads and writes OMA files with ATRAC3 and ATRAC3plus (Windows, macOS, Linux)
- VLC media player – free player that plays OMA files (Windows, macOS, Linux, mobile)
- atracdenc – open-source ATRAC3 and ATRAC3plus encoder that writes OMA files (Windows, macOS, Linux)
Developers
- libavformat and libavcodec – FFmpeg’s OMA reader and writer and its ATRAC3 and ATRAC3plus decoders (C)
- atracdenc – the encoder source, with its OMA writer (C++)
Reference
- Sony OpenMG – the MultimediaWiki summary of the container
- FFmpeg OMA samples – real files, including an encrypted one