On2 VP4
Jump to navigation
Jump to search
- FourCC: VP40
- Company: On2
- Samples: http://samples.mplayerhq.hu/V-codecs/VP4/
This codec has source code base common with its predecessor but sets version to 2.
Frame header
The same as VP3 with some extensions.
- Frame type - 1 bit
- Unused - 1 bit
- DCT Q mask - 6 bits
For frame type 0 (BASE_FRAME
):
- version byte 0 - 8 bits
- version - 5 bits (should be 2)
- key frame type - 1 bit
- spare bits - 2 bits
- ??? - 8 bits
- ??? - 8 bits
- ??? - 5 bits
- ??? - 3 bits
- ??? - 5 bits
- ??? - 3 bits
- ??? - 2 bits
Display fragments
This is present for non-base frames only.
First there's MBFullyFlags[]
coded as flag array.
Then for all macroblocks that are not fully coded (i.e. MBFullyFlags[mb]
is zero) there are flag values in MBCoded[]
coded the same way.
And finally for coded blocks there's some Huffman-coded value.
Flag arrays coding
Flag arrays are run-coded using some strange variation of VLC and having initial flag value signalled at the start.
flag = getbit(); len = get_mplayer(); for (i = 0; i < size; i++) { if (!len) { flag = !flag; len = get_mplayer(); } array[i] = flag; len--; }
Variable-length code
int get_mplayer() { val = 1; tail = 0; while (getbit()) { val++; for (i = 0; i < 8; i++) { if (!getbit()) break; val += 1 << i; } if (i < 8) { tail = i; break; } } return val + getbits(tail); }