[XviD-devel] Invalid stuffing bits

Christoph Lampert chl at math.uni-bonn.de
Tue Mar 18 10:43:50 CET 2003


On Tue, 18 Mar 2003, Bobololo wrote:

> 
> On Tue, 18 Mar 2003, Edouard Gomez wrote:
> 
> > Bobololo (b0b0l0l0 at free.fr) wrote:
> > >     BitstreamPutBits(&bs, 0xFFFF, 16);
> > >     BitstreamPutBits(&bs, 0xFFFF, 16);
> > >     BitstreamPad(&bs);
> >
> > The fix  is trivial, we only have  to remove the 0xfffff  bytes from the
> > bitstream.

We might have to use BitstreamPadAlways(&bs) instead of BitstreamPad(&bs).
Btw. if I remember correctly, this has been fixed a long time ago in CVS. 

> Hum, I'm not sure to understand your correction. Did I miss some
> initialization code of the pFrame->bitstream buffer ? Otherwise I can't
> figure out how the stuffing bits are set at the end of a VOP. Would you
> mind clarifying the fix ?

The 0xFFFF were plain wrong. Most likely they were inserted for some
Windows VfW compatability or something. Anyway, they are against the
standard, so they have to be removed. 
The BitstreamPad() routine pads the Bitstream to full byte boundary if
needed by inserting one 0 bit and then 1 bits until the byte boundary is
reached. 
The BitstreamPadAlways() routine does the same, but it _always_ writes the
first 0 bit, so BitstreamPadAlways() writes 1 to 8 bits to stream, whereas
BitstreamPad writes 0 to 7 padding bits.

At the end of VOP, BitstreamPadAlways() is required, if I remember
correctly. 

gruel




More information about the XviD-devel mailing list