Difference between revisions of "TAK"

From MultimediaWiki
Jump to: navigation, search
(Data header)
Line 148: Line 148:
 
   2 bits    padding (only for the last frame)
 
   2 bits    padding (only for the last frame)
  
==== Information header ====
+
==== Extra info ====
  
   1 bit    previous frame position is present
+
   1 bit    previous frame position is present (currently always set to 0)
 
   5 bits    reserved (should be 0)
 
   5 bits    reserved (should be 0)
   25 bits    offset to the previous frame header from the end of this header (only if first bit = 1)
+
            if previous frame position is present:
 +
   25 bits    offset to the previous frame header from the end of this header
  
  
 
[[Category:Audio Codecs]]
 
[[Category:Audio Codecs]]
 
[[Category:Lossless Audio Codecs]]
 
[[Category:Lossless Audio Codecs]]

Revision as of 02:11, 15 October 2012

TAK (Tom's verlustfreier Audio Kompressor), formerly known as YALAC (Yet Another Lossless Audio Codec) is a lossless audio codec developed by Thomas Becker. As of January 2006, the codec is at the 1.0 release stage. Source code is not available.



Stream format

Integers are little-endian. 24-bit CRC is employed for checking data integrity.

TAK file consists of signature ("tBaK"), obligatory metadata and compressed audio data. APE tags may be present at the end of file.

Metadata

Metadata consists of series of objects, each object has 32-bit header.

Header meaning:

  7 bits - object type
  1 bit  - reserved
 24 bits - object size

Metadata object types:

 0x00 - end of metadata
 0x01 - stream info
 0x02 - seektable (obsoleted in TAK 1.1.1)
 0x03 - original file data
 0x04 - encoder info
 0x05 - padding (since 1.0.3)
 0x06 - MD5 checksum (since 1.1.1)
 0x07 - last frame information (since 1.1.1)

Non-empty metadata object ends with 3 bytes of object data CRC.

Stream information

  6 bits    codec type
  4 bits    encoder profile (= encoder preset at least for versions <= 1.1.2)

Known codec types:

  0    Integer 24 bit (TAK 1.0)
  1    Experimental!
  2    Integer 24 bit (TAK 2.0)
  3    LossyWav (TAK 2.1 Beta)
  4    Integer 24 bit MC (TAK 2.2)
  frame size information (32 bits, see below)
Frame size information
  4 bits    frame size index
 35 bits    number of samples in whole stream

Possible frame sizes:

  0    94 ms of audio
  1    125 ms
  2    188 ms
  3    250 ms
  4    4096 ms
  5    8192 ms
  6    16384 ms
  7    512 ms
  8    1024 ms
  9    2048 ms
 10    6144 ms (obsoleted in 1.1.0, invalid)
 11    12288 ms (obsoleted in 1.1.0, invalid)
 12-14    reserved
 15    frame contains number of samples stored in next 35 bits (not supported yet)
Audio format
  3 bits    data type (should be 0 = PCM)
 18 bits    sample rate - 6000
  5 bits    sample bits - 8
  4 bits    audio channels - 1 (5 bits in 1.1.1 version, last bit is never
                                used anyway because older encoders did not
                                supported multi-channel input)
  1 bit     is extension present

(>= 2.2.0 only)

            if extension is present:
  5 bits    valid bits per sample
  1 bit     is speaker assignment present
            if speaker assignment present:

6xCh bits speaker assignment for each channel

supported assignments:

   0    none
   1    FRONT_LEFT
   2    FRONT_RIGHT
   3    FRONT_CENTER
   4    LOW_FREQUENCY
   5    BACK_LEFT
   6    BACK_RIGHT
   7    FRONT_LEFT_OF_CENTER
   8    FRONT_RIGHT_OF_CENTER
   9    BACK_CENTER
  10    SIDE_LEFT
  11    SIDE_RIGHT
  12    TOP_CENTER
  13    TOP_FRONT_LEFT
  14    FRONT_CENTER
  15    FRONT_RIGHT
  16    BACK_LEFT
  17    BACK_CENTER
  18    BACK_RIGHT

Original file data

Called "simple wave data", this contains trailer and footer from original file to allow perfect reconstruction:

  0-2   trailer size
  3-6   footer size
  trailer data
  footer data

Encoder info

  24 bits    encoder version (8 bits per each version component)
   4 bits    preset
   2 bits    evaluation
   2 bits    reserved

Last frame information

 40 bits    frame position relative to the beginning of audio data
 24 bits    frame size

Audio data

TODO: header order, padding, CRC positions

Data header

 16 bits    syncword (0xA0FF little-endian)
  1 bit     last frame
  1 bit     frame contains stream information + extra info (see "stream information" above and "extra info" bellow)
  1 bit     frame contains metadata (unsupported)
 21 bits    frame number
 14 bits    sample count - 1 (only for the last frame)
  2 bits    padding (only for the last frame)

Extra info

  1 bit     previous frame position is present (currently always set to 0)
  5 bits    reserved (should be 0)
            if previous frame position is present:
 25 bits    offset to the previous frame header from the end of this header