[FFmpeg-devel] [PATCH]Basic XSUB encoder

Reimar Döffinger Reimar.Doeffinger
Mon Feb 2 10:47:03 CET 2009


On Mon, Feb 02, 2009 at 10:38:20AM +0100, Reimar D?ffinger wrote:
> On Sun, Feb 01, 2009 at 11:39:46PM +0100, Bj?rn Axelsson wrote:
> > +            if (len <=3) {
> > +                // 2-bit len, 2-bit color
> > +                PUTNIBBLE((len << 2) | color);
> > +            } else if (len <= 15) {
> > +                // 2-bit zero, 4-bit len, 2-bit color
> > +                PUTNIBBLE( (len & 0x0c) >> 2);
> > +                PUTNIBBLE(((len & 0x03) << 2) | color);
> > +            } else if (len <= 63) {
> > +                // 4-bit zero, 6-bit len, 2-bit color
> > +                PUTNIBBLE(0);
> > +                PUTNIBBLE( (len & 0x3c) >> 2);
> > +                PUTNIBBLE(((len & 0x03) << 2) | color);
> > +            } else if (len <= 255) {
> > +                // 6-bit zero, 8-bit len, 2-bit color
> > +                PUTNIBBLE(0);
> > +                PUTNIBBLE( (len & 0xc0) >> 6);
> > +                PUTNIBBLE( (len & 0x3c) >> 2);
> > +                PUTNIBBLE(((len & 0x03) << 2) | color);
> 
> going by the decoder, it should be possible to simplify once you use
> put_bits, I think it should not need any branches, only the
> full-line-length does.

More precisely these all should simplify to (note then len > 255 case must be
handled separately):
int log2 = ff_log2_tab[len];
put_bits(&pb, 2 + 4 * (log2 >> 1), len);
put_bits(&pb, 2, color);

Greetings,
Reimar D?ffinger




More information about the ffmpeg-devel mailing list