Difference between revisions of "On2 VP4"

From MultimediaWiki
Jump to navigation Jump to search
Line 26: Line 26:
* ??? - 3 bits
* ??? - 3 bits
* ??? - 2 bits
* ??? - 2 bits
=== Display fragments ===
This is present for non-base frames only.
First there's <code>MBFullyFlags[]</code> coded as flag array.
Then for all macroblocks that are not fully coded (i.e. <code>MBFullyFlags[mb]</code> is zero) there are flag values in <code>MBCoded[]</code> 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);
  }


[[Category:Video Codecs]]
[[Category:Video Codecs]]
[[Category:Undiscovered Video Codecs]]
[[Category:Undiscovered Video Codecs]]

Revision as of 10:16, 16 April 2016

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);
 }