Introduction
The EA3 header is always 96 bytes. It starts at the first byte after the tag, or at byte 0 when the file has no tag, and the sound data starts right after it. Numbers are big-endian. A reader needs four things from it: whether the data is encrypted, the codec id, the 24-bit parameter word, and for encrypted data the initial value.
Fields
| Offset | Size | Field | Meaning |
|---|---|---|---|
| 0 | 3 | Magic | The bytes 45 41 33, the letters EA3 in upper case. |
| 3 | 1 | Header version | 0 in files written by FFmpeg, 1 in files written by SonicStage and by atracdenc. No reader tests it. |
| 4 | 2 | Header size | The bytes 00 60: the size of the header, 96. A reader rejects any other value. |
| 6 | 2 | Encryption id | A signed 16-bit number. FFFF (−1) and FF80 (−128) mean the sound data is not encrypted. Any other value means it is, and the key ring in the tag is needed (Encryption). SonicStage files use 0001. |
| 8 | 4 | Selector | Sony’s header class (Ea3::Header::getOmgcid in OMGUtils.dll of SonicStage 4.3, disassembled) returns the content id only when these four bytes are zero. Zero in every file read; FFmpeg and atracdenc do not read them. |
| 12 | 20 | Content id (OMGCID) | The 20-byte content id of the track. Sony’s Ea3::Header::getOmgcid (disassembled from OMGUtils.dll of SonicStage 4.3) checks that bytes 8 to 11 are zero and then copies exactly bytes 12 to 31; setOmgcid writes them and zeroes bytes 8 to 11. SonicStage files start 01 0F 50 00 00 04 00 00 and then differ from file to file; the at3p_sample files start 02 03 00 00 02 00 01 16 bb 7f 00 00. Zero in files written by FFmpeg and atracdenc and in the .aa3 files (the thirteen lossless ones included). FFmpeg and atracdenc do not read it. |
| 24 | 8 | Track id (alternative reading) | Ea3::Header::getTcid reads bytes 24 to 31 as an 8-byte track id, but only when bytes 8 to 23 are 00 00 00 00 01 0F 51 00 70 00 00 00 00 00 00 00 (the constant in the DLL’s data section). No file read has that prefix. |
| 32 | 1 | Codec id | Which codec the sound data uses: the table. |
| 33 | 3 | Parameters | A 24-bit word whose fields depend on the codec: the table. In a WMA file (codec id 5) the rate, channels, block size and bit rate come from the ASF header in the sound data and these three bytes are Unknown: in the one real file they are 40 80 44, the middle byte (128) equals the bit rate in kbit/s and the last byte (0x44) the digits of the 44.1 kHz rate, and the first byte matches nothing in the ASF header; one file cannot tell a pattern from a coincidence. |
| 33 to 35 in the lossless files (ids 33 and 34) | 3 | Constant and tail | In the thirteen real lossless files byte 33 is 0x52 for id 34 and 0x91 for id 33 (the same in every file of a codec, not a parameter that a reader needs), and the low 12 bits of bytes 34 and 35 are the number of samples in the last BLK chunk, the same number as the low 15 bits of that chunk’s bytes 12 and 13 (1,506 or 1,507 for the ATRAC3plus files, 482 for the ATRAC3 file). Sony’s checkCodecInfoLosslessAT3/ATX require the top 12 bits of the 24-bit word to be 0x520 (id 34) or 0x910 (id 33); the top two bits of byte 33 give the sound-unit size, 512 << (byte 33 >> 6 & 3), 1,024 or 2,048 samples. getLosslessTotalSamples returns (count at bytes 40 to 43 − 2) × that size + the 12-bit tail, and getLosslessTotalSuCount returns the count itself, as a big-endian number. The formula gives the same length as the sample count in the last BLK chunk in all thirteen real lossless files (2,598,370 samples for nine of them and 2,598,371 for the four files named lossless_*_44khz; the explorer takes the length of the sound from it). |
| 36 | 4 | Duration | Not read by FFmpeg, liboma or atracdenc. In the .aa3 files made by Sony’s tools (the lossless files and one lossy ATRAC3plus file, from samples.ffmpeg.org) a duration in milliseconds. In the lossless files it is about ((chunks − 2) × samples in a chunk + tail samples) / 44.1. In the WMA file (codec id 5) it is 3,343,034 ms, exactly the play duration of the ASF File Properties object (33,446,130,000 in units of 100 ns, that is 3,344,613 ms) minus its preroll (1,579 ms), the length FFmpeg reports for the stream. |
| 40 | 4 | Count | In the lossy Sony .aa3 file the number of packets of the sound data (7,064, exactly the data size divided by the packet size); in the lossless files the number of BLK chunks (equal to the chunks found in all thirteen files); in the WMA file the number of ASF data packets (9,000, the count in the File Properties and Data objects). |
| 44 | 3 | Zero | Not read by Sony’s header class; zero in every file read. |
| 47 | 1 | Relative volume | A signed byte: getRelativeVolume returns it and setRelativeVolume stores it, raising a header of version 0 or 1 to version 2 (so only a header of version 2 or later holds it). Zero in every file read. |
| 48 | 4 | Core codec and parameters (lossless files) | Byte 48 is the codec id of the lossy core (0 ATRAC3 for id 34, 1 ATRAC3plus for id 33) and bytes 49 to 51 are that core’s 24-bit parameter word, laid out as bytes 33 to 35 of a plain file (for id 34: 00 20 30, a 384-byte core packet; for id 33: 00 28 xx, whose packet size is the size of the core frame in each BLK chunk, so 64 to 352 kbit/s files have different values). The core size and rate of an AL file come from here; the chunks themselves do not repeat them. Zero in other files. |
| 52 | 36 | Zero | Zero in every file read. |
| 88 | 8 | Initial value | The 8-byte initial value of the DES-CBC encryption of the sound data. Zero when the data is not encrypted. |
Probing
A file is an OMA file when, after the tag (if any, found by its length), the next five bytes are
45 41 33 xx 00 with the sixth byte 60. FFmpeg’s probe gives the file its top score on that test alone,
and a half score when the tag is longer than the bytes it was given to look at.
Sources
- FFmpeg
libavformat/omadec.c(oma_read_header,oma_read_probe) andoma.h(EA3_HEADER_SIZE96): every field above that a reader uses. - FFmpeg
libavformat/omaenc.c: the values its writer puts in the header (version 0, encryption id FFFF, zeros elsewhere). - Sony SonicStage 4.3,
OMGUtils.dll(exportedEa3::Headermethods, disassembled with llvm-objdump; the listing is kept in research/oma/src-al/ss43-disasm): the fields at bytes 3, 6 to 7, 8 to 31, 32 to 35, 40 to 43, 47 and 48 to 51.setAt3Paramfor the lossless codecs writes the core’s own header word to bytes 48 to 51 and sets version 3. - The values of the unused bytes were read from the files in samples/oma (three real SonicStage files, files written by FFmpeg and by atracdenc).