TTA

From Hydrogenaudio Knowledgebase
Revision as of 17:51, 25 April 2024 by Porcuswiki (talk | contribs) (Update with the 2023 comparison, the independent rewrite, and higher precision in some of the text)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The True Audio (TTA) is a lossless audio codec. It is distributed as a free open-source (GPL/LGPL) encoder/decoder and library for several operating systems, and with DirectShow filters and plugins for several audio players, including foobar2000.

It is not known whether the project is abandoned. The codec sometimes identifies itself as "TTA1", and an announced development of a "TTA2" format has passed with no known updates since 2010.[1]

TTA has a couple of unique properties: one is encryption with password protection, and that – apart from metadata – the bitstream is uniquely determined by the signal (and if applicable, the password). That is, one single setting with no encoding options for heavier / lighter compression / CPU load. These properties have seen some appeal in certain applications, outside which TTA seems to have a limited userbase.

Performance-wise, TTA has been measured around WavPack between default and -h on CD audio signals[2] – putting it on what traditionally has been considered on the fast encoder side rather than the heavy compression (Monkey's Audio/OptimFROG) side. In the most recent edition of the comparison, two codecs (TAK and, narrowly, FLAC after its recent performance improvements) could beat TTA simultaneously on all three tested parameters (encoding speed, decoding speed and file size) on the average signal tested.

FFmpeg offers a third-party implementation which can encode and decode to higher channel count and accepts more input files than the official Windows encoder can do. Also the foobar2000 component at foobar2000.org implements more features than the official version. This wiki article aims at describing the features and limitations in the available end-user applications, rather than what the TTA format might accommodate (but nobody has implemented). A 3rd party source code rewrite was posted in the Hydrogenaudio forums in 2023[3][4].


Features

From an end-user perspective, the following features are quite common among lossless codecs, except for password protection. Some competing formats are lacking certain of these features, and some are free from certain of the limitations listed. To compare TTA with other lossless codecs, see HA Wiki's Lossless Codec Comparison.

  • Seekable and streaming playback.
  • High-resolution audio support: the format supports 24 bits per sample, at any WAVE sampling rate (integers up to 4 GiHz; although the encoders may stop short of the 4 GiHz mark – ffmpeg at 2 GiHz – this limitation is hardly relevant for audio).
  • Multichannel support, however with limitations (see below). Currently the reference encoder supports up to six channels, the ffmpeg implementation supports 16, and the unofficially modified foobar2000 component can handle 8.
  • Piping support.
  • Tagging (APEv2 or ID3v1/2).
  • Embedded CUE sheets support.
  • Unicode support.
  • Can be used in the Matroska container.
  • Password-protected encryption.

The lack of encoding options may be a limitation or sometimes considered a feature: a given music signal corresponds to precisely one (unencrypted) TTA bit stream – no matter whether encoded with the reference encoder or ffmpeg. Metadata sections may of course differ.

Limitations

The following list is in part based on issues revealed by tests in the Hydrogenaudio forums, as per 2022 available implementations – the 2023 independent rewrite not tested and is known to handle more input files.

  • Bad error handling.[5] Errors will upon playback lead to full-volume static noise played back, at worst for the rest of the file. Only the most severe errors seem to be detected by the reference decoder. Testing reveals that ffmpeg can detect errors the reference decoder cannot, and might drop more defective frames, but ffmpeg might still play back static unmuted. The lack of (MD5) audio checksum is a more severe shortcoming when the capability to detect errors by other means is so limited; there seems to be no reliable way implemented to scan a collection of files for corruption, although the format provides block checksums.
  • The existing implementations have limitations for non-CDDA signals:
    • Bit depth: The format supports 8, 16 or 24 bit files – and 8-bit signals are only supported in ffmpeg's implementation, not in the the reference encoder/decoder (nor the official foobar2000 playback component). Note, some old sources refer to 32-bit (floating-point) support; that was apparently dropped circa 2004, and it is not known how to decode such files, should they even exist.
      Non-integer byte depths (say 20 valid bits in a 24-bit WAVE container) are not well supported. Testing with 20-bit WAVE files has provoked the reference encoder into either of the following three: rejecting the file altogether; producing undecodeable files; silently upconverting to 24 bits, losing any information that it was ever 20 bits (ffmpeg appears to always do this). In the latter case, TTA will not compress it well, as it is unable to make use of "wasted bits": other codecs can detect that bits 21 to 24 are zero and compress a 20-bit signal virtually without penalty. (See van Beurden's lossless comparison, section 2.3.)
    • Limitations in multichannel support: Although the TTA format claims support for up to 65536 channels, no implementation seems to support more than 16 (ffmpeg), the reference implementation being capped at 6. The foobar2000 component repository includes a component version that handles 8 channels (unlike the component provided by the TTA developers), and that component also honours the WAVEFORMATEXTENSIBLE tag to interpret what channels are encoded. This is an unofficial feature; the format itself offers no channel assignment (e.g., if a TTA file has three channels there is no rule to tell whether it is 2.1 or 3.0, and likewise there is no rule to tell whether a five-channel file a 5.0 or a 4.1 – the component implements support through a tag). Also, in van Beurden's comparison, TTA fared worse on multichannel material than on stereo.
    • The reference encoder is picky about input files, only supporting some versions/generations of the WAVE format (and no other format than WAVE) and requiring workarounds at 2 GiB input size. Also the reference implementation might truncate too large files. These issues can be circumvented by using ffmpeg instead.
  • Metadata:
    • TTA might be the lossless format most likely to suffer from tagging ambiguity. While there are other formats which can (like MP3) accommotate both ID3 and APEv2 tags, applications seem to have converged to APEv2 for other lossless formats which accept it, and both ffmpeg's TTA encoder and foobar2000 will try to enforce APEv2 in TTA. However, a tagger like MusicBrainz Picard will treat TTA files as MP3 files, defaulting to ID3v1&ID3v2.3 while ignoring any APEv2. Apparently Mp3tag will write ID3 to an untagged .tta file, but ignore ID3 when APEv2 is already present.
    • There is no provision for (R)IFF chunks; i.e. TTA cannot store nor recreate non-audio chunks of the original file. That means that one limitation of ffmpeg – that it drops RIFF chunks – is moot for TTA, which could not store them in any case. Note that ffmpeg will transfer tags upon conversion in the usual way (to APEv2 when encoding), but the reference encoder/decoder does not know tags in WAVE.
  • Its unique feature – password protection – seems to be unsupported in players, save for invoking ffplay from a command-line with the password typed in.
  • Just as the lack of options might be useful in specialized applications, other users will find it a limitation. However, one may argue that by 2023, performance differences are less of an issue even if there is no way to speed up neither encoding nor decoding (which takes even more CPU power than encoding).
  • Like most lossless formats, TTA has no functionality for hybrid lossless/lossy encoding. For TTA, there is also no way (for power users!) to hack a hybrid solution by way of LossyWAV.

Hardware support is limited outside Rockbox. A few hardware players with TTA support have been around over the years[6] until Cowon exited the hardware player market. However the distinction between «hardware» and «software» support is arguably less clear with ffmpeg-based players on smart devices.

Using TTA (missing: info about DirectShow)

At least for 16-bit signals, one might rather use ffmpeg than the reference implementation. Note that ffmpeg will, upon decoding to WAVE/AIFF, default to 16 bits regardless whether that is a lossy operation. (This is not specific to input source, and users should take care before using ffmpeg for lossless conversion.)

For foobar2000 playback, the component at the foobar2000 website has more features than the TTA developers' decoding component and is also available for 64-bit versions of the player. Since non-audio chunks are not stored in .tta files, foobar2000 just as well be the preferred software to convert .tta files unless one encounters > 8 channels.

Links

Additional sources: