Version
0.96 – Date: July 5th, 2011
Introduction
TCAS is short for Ternary Color Advanced
Subtitle,
it is extended from TCS. TCAS files have an extension .TCAS. TCAS is part of the RIXE project. A TCAS filename looks like example.tcas. TCAS is a file
format that mainly stores raw pixel data as well as its position and living
duration. Theoretically speaking, TCAS allows you to draw anything on video
frames, although it is mainly designed to store karaoke effects. After parsing
the data stored in the TCAS file, you will get TCAS frames, which are going to be
rendered on the video frames. See also the libtcas
and tcasFilter project for its implementation
and usage.
TCAS File Structures
Summary
TCAS
file is mainly organized by two part the Header and the Body. Header contains 4
signature bytes (a DWORD) indicating the TCAS file format, other general
information about TCAS file is also stored in the Header. Body holds the main
TCAS data, and this part is consisted of many data chunks. The data stored in
the TCAS file is aligned to 4 bytes (a DWORD), so DWORD is the unit used when
talking about the size of a certain chunk in TCAS file instead of BYTE. The
minimum unit of TCAS data is a Dynamic Isolated Pixel (DIP), which holds information about its living
duration, position and pixel values. Dislike videos whose data is stored in a linear
time-line sequence form, the data of TCAS file (TCAS data chunks) can be stored
in any order. This feature is to guarantee the flexibility of using TCAS file
to store karaoke effects, since we can write the effects in any order as we
like without caring about their effective duration. However non-linear timing
makes it inefficient to parse the TCAS file, so TCAS brings in the indexing
technique to make time-line linearization possible, hence increasing performance
dramatically, moreover, as a side effect of such indexing technique,
multi-threading becomes possible and can be easily implemented at the parsing
phase. Another important improvement is that TCAS brings in key-framing which
can enormously decrease the target file size.
Detail
Header
The
size of the Header part is 16 DWORDs,
the same with TCS.
Offset |
Size |
Name |
Purpose |
0000h |
1
DWORD |
Signature |
Identify
the TCAS file |
0004h |
1
DWORD |
Version |
TCAS
file version |
0008h |
1
DWORD |
Flag |
HIWORD
indicates TCAS file type, LOWORD indicates whether to use key framing |
000Ch |
1
DWORD |
Resolution |
Resolution
of TCAS FX |
0010h |
1
DWORD |
MinTime |
Minimal
time of the TCAS FX |
0014h |
1
DWORD |
MaxTime |
Maximal
time of the TCAS FX |
0018h |
1
DWORD |
Chunks |
Number
of data chunks |
001Ch |
1
DWORD |
||
0020h |
1
DWORD |
Denominator
of TCAS FX frame rate |
|
0024h |
7
DWORDs |
Reserved |
May
be used in the future |
Remarks:
1.
The Signature of TCAS
file is 0x54 0x43
0x41 0x53, which
means TCAS
in ASCII.
2.
Low word of Version
indicates minor TCAS file version, the initial minor TCAS file version is 0. High
word of Version indicates major TCAS file
version, the initial major TCS file version is 1.
3.
The meaning of Flag in
TCAS is slightly different from the old TCS file format. HIWORD of Flag is just the same with Flag
in TCS file, but LOWORD of Flag indicates whether
to enable key framing. TCAS file type can be 0 - raw
TCAS file, 1 - compressed TCAS file.
4.
Low word of Resolution
indicates the horizontal resolution that the TCAS FX is dealing with. High word
of Resolution indicates the vertical resolution
that the TCAS FX is dealing with. The unit of Resolution is pixel. Note that
the maximal width and height can both reach 65535, but they are regarded as
reserved value, so, in fact the maximal valid width and height are both 65534,
which is still much enough as video resolution.
5.
MinTime indicates the first time
that the TCAS FX has taken effects. The unit of MinTime
is millisecond, so the range of MinTime is [0,
4294967295], more than 1 thousand hours.
6.
MaxTime indicates the first time
that the TCAS FX has ended its effects. The unit of MaxTime
is millisecond, so the range of MaxTime is [0,
4294967295], more than 1 thousand hours.
7.
Chunks indicate the number of data
chunks in the body part of the TCAS file.
8.
TCAS FX FPS = fpsNumerator
/ (double) fpsDenominator, fpsNumerator and fpsDenominator
indicate in which frame rate the TCAS FX has been generated. However, in most
cases of rendering a TCAS file, they will simply be ignored.
Body
The
Body part starts at 0040h, right
after the Header part. A TCAS file is created by receiving raw TCAS data
chunks.
Raw TCAS Data Chunk Stream
Raw
TCAS data chunk stream is made up of dozens of raw DIPs. The data is organized
as below
Compressed TCAS Data Chunk Stream
Compressed
TCAS data chunk stream is made up of dozens of packed DIPs. The data is
organized as below
Definition
of Chunk
Chunk
is the minimal unit of complete TCAS FX data, but when talking about its exact
meaning, it is different between raw TCAS data and TCAS data.
-
When used to describe raw TCAS data: A chunk means
data of a DIP. The size of a chunk in raw TCAS data stream is 5 DWORDs.
-
When used to describe TCAS data: A chunk stands for
several packed DIPs. The size of a chunk in TCAS file can be calculated by the
following formula: size = (3 + 2 * nPixels) DWORDs.
Remarks:
1.
We obtain such a file format partly because that
karaoke FXs usually occupy relatively small area and their time durations are
relatively short compared to the host videos.
2.
The unit of StartT/EndT is millisecond, so the range of StartT/EndT is [0, 4294967295] ms, more than 1 thousand hours. The unit of
PosX/PosY is pixel, so the range of PosX/PosY is 65535 pix. Note that, 65535 is reserved,
so the maximal valid PosX and PosY are both 65534. When coming to the rendering
phase, the range of valid PosX/PosY is -32767 to 32767, while -32768 is
reserved.
3.
Layer will contribute
when coming to render the TCAS FX, TCAS frames with higher layers will overlay
upon TCAS frames with lower layers to make up a whole FX frame. However, in one
FX frame, if two TCAS frames are on the same layer, then the one which is placed
in a larger part of TCAS file will overlay upon the one which is placed in a
prior TCAS file. Its value is between 0 and 15 (inclusive).
4.
nPixels indicates the
number of packed DIPs in the chunk. It occupies the low 24 bits of a DWORD.
5.
The smallest size of a chunk is 5 DWORDs.
6.
In the compression process, adjacent
raw DIPs who have the same StartT EndT Layer type and pair can share the
same chunk. Here, adjacent is a big
issue. It indicates that you should consider the locality
when creating the original raw TCAS FX data. Every compression of two raw DIPs
saves 3 DWORDs space.
7.
Any two packed DIPs in the same chunk if they have
the same position the latter will cover the former at the rendering phase;
8.
When parsing, the TCAS frame should be merged
according to their layers and orders;
9.
type indicates which key framing algorithm should be
applied, 0 indicates no key framing, 1 indicates fast generation, 2 indicates
bilinear filtered. Its value is between 0 and 7 (inclusive), and in TCAS file chunks
with the same type except for type 0, should appear in pairs, and their layer
must be the same. Intermediate frame chunks will be generated between two key
frames, that’s why they should appear in pairs. With key frames, StartT = EndT.
TCAS File Creation
Please refer to the libtcas
project.
Indexing Technique
Please refer to the libtcas
project.
Key Framing Technique
Please refer to the libtcas
project.
TCAS FX Frame Generation
Technique
Please refer to the libtcas
project.
Note:
1.
libtcas is the implementation of this specification,
and this specification is also a description of libtcas.
2.
To see the usage of libtcas please check the tcax
project and the tcasFilter project.