ASUS V1/V2 Codecs
Contents
1 Introduction
2 Terms and definitions
3 Highlevel Description
3.1 Picture
3.2 Macroblock
3.3 Block
3.4 Coefficient group
3.5 DC coefficient Dequantization
3.6 AC coefficient Dequantization
4 Bitstream
4.1 Fourcc
4.2 Global (per file) Header
4.3 Macroblock
4.4 ASV1 Block
4.5 ASV2 Block
5 VLC Codes
5.1 ASV1
5.1.1 Level
5.1.2 Coded coefficient pattern
5.2 ASV2
5.2.1 First Coded coefficient pattern
5.2.2 Coded coefficient pattern
5.2.3 Level
6 Example ASV1 decoder
7 Changelog
8 Copyright
1 Introduction
ASV1/2 are purely intracoded DCT-based codecs, with a per file quantization
parameter (QP), use 4:2:0 YCbCr colorspace and operate on macroblocks.
The latest version of this document is available at http://www.mplayerhq.hu/michael/asv1.{lyx,txt,html,ps}
This document assumes familiarity with mathematical and
coding concepts such as the discrete cosine transform, quantization,
YUV (YCbCr) colorspaces, macroblocks, and variable length codes (VLCs).
2 Terms and definitions
- AC
- Any DCT coefficient for which the frequency in one or both both
dimensions in non-zero.
- DC
- The DCT coefficient for which the frequency is zero in both dimensions
- QP
- Quantization Parameter
- (I)DCT
- (Inverse) Discrete Cosine Transform
- VLC
- Variable Length Code
3 Highlevel Description
3.1 Picture
The picture is split into macroblocks which are coded left->right,
top->bottom, as long as MBs are completely within the width/height
area that is divisible by 16. If width is not divisible by 16, the
right column is coded after the main body. If height is not divisible
by 16, the bottom strip is coded after the right column.
Example: 56x56 sized image
0 | 1 | 2 | 9 |
3 | 4 | 5 | 10 |
6 | 7 | 8 | 11 |
12 | 13 | 14 | 15 |
3.2 Macroblock
16x16 luma + 8x8 chroma as 4 8x8 luma blocks and 2 8x8 chroma blocks
Y:
Cb:
Cr:
Contains 64(=8x8) coefficients in 16(=4x4) coefficient groups with
4(=2x2) coefficients each
0 | 1 | 5 | 9 |
2 | 3 | 8 | 12 |
4 | 7 | 11 | 14 |
6 | 10 | 13 | 15 |
Coefficients in the coefficient groups 10..15 cannot be coded (they
must be 0) in ASV1.
The first coefficient (DC coefficient) in the first coefficient group
must be coded as 0. Note it is coded seperately in the 8 bits prior
to the AC coefficients.
3.4 Coefficient group
3.5 DC coefficient Dequantization
c00¢=8c00
- c00
- quantized and coded DC coefficient
- c00¢
- unquantized DC coefficient
3.6 AC coefficient Dequantization
cxy¢= |
cxy
16
|
|
ê ë
|
Dqxy
QP
|
ú û
|
|
- QP
- Quantization Parameter from the global header
- D
- 64 for ASV1, 128 forASV2
- c
- quantized and coded coefficient
- c'
- unquantized coefficient
- q
- ISO MPEG1 intra quantization matrix
4 Bitstream
The bitstream in ASV1 is stored with byte-swapped 32bit words (24..31,
16..23, 8..15, 0..7, 56..63, 48..55, 40..47, 32..39, ...)
The bitstream in ASV2 is stored with the bits in each byte reversed
so (7..0, 15..8, 23..16, 31..24, 39..32, ...)
4.1 Fourcc
ASV1 / ASV2
4.2 Global (per file) Header
Length in bits | Value |
|
8 | QP |
24 | unkown, 0 for ASV1 |
8 | 'A' |
8 | 'S' |
8 | 'U' |
8 | 'S' |
4.3 Macroblock
Simply the bitstream of the 6 blocks
4.4 ASV1 Block
- 8-bit
- DC coefficient
- .
- for each coefficient group
- 2-5bit
- Coded coefficient pattern
- .
- for each coded coefficient
- 2-11bit
- level
- 5bit
- End Of Block
4.5 ASV2 Block
- 4-bit
- coefficient group count
- 8-bit
- DC coefficient
- 2-4bit
- First Coded coefficient pattern
- .
- for each coded coefficient
- 2-13bit
- level
- .
- for each coefficient group
- 2-6bit
- Coded coefficient pattern
- .
- for each coded coefficient
- 2-13bit
- level
5 VLC Codes
0011 | -3 |
011 | -2 |
11 | -1 |
000xxxxxxxx | xxxxxxxx |
10 | 1 |
010 | 2 |
0010 | 3 |
xxxxxxxx is a twos complement signed 8 bit nubmer (=int8_t)
5.1.2 Coded coefficient pattern
00001 | 14 |
00010 | 13 |
... | ... |
01101 | 2 |
01110 | 1 |
01111 | EOB |
10 | 0 |
11 | 15 |
5.2.1 First Coded coefficient pattern
VLC | CCP |
00 | 0111 |
01 | 0000 |
100 | 0110 |
101 | 0100 |
1100 | 0011 |
1101 | 0001 |
1110 | 0101 |
1111 | 0010 |
5.2.2 Coded coefficient pattern
VLC | CCP |
00 | 0000 |
010 | 0100 |
011 | 1000 |
1000 | 1010 |
1001 | 1100 |
1010 | 0010 |
1011 | 1101 |
1100 | 1111 |
1101 | 1110 |
111000 | 0111 |
111001 | 0101 |
111010 | 0011 |
111011 | 0001 |
111100 | 0110 |
111101 | 1001 |
11111 | 1011 |
0000111111 | -31 |
... | ... |
001111 | -7 |
001011 | -6 |
001101 | -5 |
001001 | -4 |
0111 | -3 |
0101 | -2 |
11 | -1 |
00000xxxxxxxx | xxxxxxxx |
10 | 1 |
0100 | 2 |
0110 | 3 |
001000 | 4 |
001100 | 5 |
001010 | 6 |
001110 | 7 |
... | ... |
0000111110 | 31 |
xxxxxxxx is a twos complement signed 8 bit nubmer (=int8_t)
6 Example ASV1 decoder
- foreach macroblock, decode Y0 Y1 Y2 Y3 U V blocks, Y blocks are arranged
as:
Y0 Y1
Y2 Y3
- foreach block:
- DC coeff is the next 8 bits in the stream * 8 (this gives a range
of 0..2040)
- foreach of up to 11 coefficient groups:
- get vlc from ccp table, value should range from 0..16
- if value is 16, coefficient decode is done
- if 11th iteration, 16 should occur, else error
- ccp contains 4 bits at this point (3-0)
- each bit corresponds to a quantized coeff. #(iter. * 4 + bit)
- if 0, coeff. is 0 else get_level():
- get vlc from level vlc table
- if vlc is 3, use the next 8 bits (as a signed number) as level
- else, use vlc - 3
- store coefficient
- dequantize, idct
7 Changelog
- 0.01
- 2003-05-21
initial version by Michael Niedermayer with some stuff from Mike Melanson
- 0.02
- 2003-05-21
spelling, punctuation, example decoder, various minor changes by Mike
Melanson
various minor changes by Michael
- 0.03
- 2003-09-01
minor fixes and ASV2 by Michael
- 0.04
- 2004-08-24
clarify bitstream order by Michael
8 Copyright
Copyright 2003 Michael Niedermayer <michaelni@gmx.at>
This text can be used under the GNU Free Documentation License or
GNU General Public License
see http://www.gnu.org/licenses/fdl.txt
File translated from
TEX
by
TTH,
version 3.67.
On 1 Sep 2005, 03:40.