[theora-dev] VP3 Format Doc, v0.4

Timothy B. Terriberry tterribe at vt.edu
Thu Mar 4 17:22:44 PST 2004

> 	Rounding variant...is that referring to round up or round down?
> Yes, it does look like it rounds down.

There are actually lots of different variants used in various places in 
the codec, the common ones being:

Truncation towards 0,


Truncation away from 0,


Truncation towards -infinity,


Rounding away from 0,


Rounding away from -infinity.


> 	I realized on a recent reading that, indeed, it is not entirely
> clear which way the MBs are coded. This is important for unpacking MB
> coding info and motion vectors. I will come up with a way to clarify this.

It's also important to note that in 4MV mode, the vectors are NOT stored 
in (what I call) bitstream order, but in display order.

> 	Good questions on these and I am actually still trying to sort out
> the answer. Anyone who has used ffmpeg/libavcodec's VP3 decoder knows that
> it is not 100% correct yet. It looks to me like a motion vector problem.
> The problem affects all planes. So I will be doing some research to find
> the discrepancies.

This is the explanation I wrote for myself in my own decoder:

"decimated directions" refers to either horizontal or vertical 
subsampling by 2 in the chroma planes. Theora (in my experimental 
encoder and decoder at least) allows 4:2:2 and 4:4:4 pixel formats.

   /*Here is a brief description of how Theora handles motion vectors:
     Motion vector components are specified to half-pixel accuracy in
      undecimated directions of each plane, and quarter-pixel accuracy in
      decimated directions.
     Integer parts are extracted by dividing (not shifting) by the
      appropriate amount, with truncation towards zero.
     These integer values are used to calculate the first offset.

     If either of the fractional parts are non-zero, then a second offset is
     No third or fourth offsets are computed, even if both components have
      non-zero fractional parts.
     The second offset is computed by dividing (not shifting) by the
      appropriate amount, always truncating _away_ from zero.*/

There are always either one or two offsets computed. In the two-offset 
case, the two samples are averaged (with truncation towards 0 or 
-infinity... all sample values are positive so they're equivalent) to 
form the predictor.

Some examples, all in 4:2:0 mode (decimation in both X and Y directions 
in the U and V planes):

(-1,-1) in the Y plane produces two offsets: (0,0) and (-1,-1)
(-2,-2) in the Y plane produces one offset: (-1,-1)
(-1,-2) in the Y plane produces two offsets: (0,-1) and (-1,-1)

(1,2) in the U plane produces two offsets: (0,0) and (1,1)
(3,4) in the U plane produces two offsets: (0,1) and (1,1)
(4,4) in the U plane produces one offset: (1,1)
--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'theora-dev-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.

More information about the Theora-dev mailing list