[FFmpeg-soc] [soc]: r282 - in jpeg2000: checkout.sh ffmpeg.patch j2k.h j2kenc.c
ods15 at ods15.dyndns.org
ods15 at ods15.dyndns.org
Tue Jul 3 19:20:38 CEST 2007
On Sat, Jun 30, 2007 at 04:35:10PM +0200, Kamil Nowosad wrote:
> Hi
>
> On Mon, Jun 25, 2007 at 02:07:04PM +0200, Michael Niedermayer wrote:
> > > +/* bitstream routines */
> > > +
> > > +/* put n times val bit */
> > > +static void put_bits(J2kEncoderContext *s, int val, int n) // TODO: optimize
> > > +{
> > > + while (n-- > 0){
> > > + if (s->bit_index == 8)
> > > + {
> > > + s->bit_index = *s->buf == 0xff ? 1:0;
> > > + *(++s->buf) = 0;
> > > + }
> > > + *s->buf |= val << (7 - s->bit_index++);
> > > + }
> > > +}
> > > +
> > > +/* put n least significant bits of a number num */
> > > +static void put_num(J2kEncoderContext *s, int num, int n)
> > > +{
> > > + while(--n >= 0)
> > > + put_bits(s, (num & (1<<n)) ? 1:0, 1);
> > > +}
> >
> > maybe something from libavcodec/bitstream.h could be used?
>
> I've read that through, but unfortunately nothing looked useful for me.
Umm, am I missing something, or would this work?
put_bits(s, num & ((1<<n)-1), n);
More information about the FFmpeg-soc
mailing list