[Ffmpeg-devel] [BUG] put bit problem
Michael Niedermayer
michaelni
Sat Mar 3 12:53:21 CET 2007
Hi
On Sat, Mar 03, 2007 at 12:28:39PM +0100, Benjamin Larsson wrote:
> Hi, I'm using this code to pack some bits.
>
> PutBitContext pb;
> GetBitContext gb;
> init_put_bits(&pb, dst, buf_size*8);
> init_get_bits(&gb, dst, buf_size*8);
>
> put_bits(&pb, 2, 2);
> put_bits(&pb, 16, samples[0]);
> put_bits(&pb, 6, c->status[0].step_index);
> flush_put_bits(&pb);
>
> av_log(NULL,AV_LOG_INFO,"bits = %d\n", get_bits(&gb,2));
> av_log(NULL,AV_LOG_INFO,"samples = %d\n", get_sbits(&gb,16));
> av_log(NULL,AV_LOG_INFO,"step index = %d\n", get_bits(&gb,6));
>
> av_log(NULL,AV_LOG_INFO,"sample %d step index %d\n",
> samples[0], c->status[0].step_index);
>
> But when I run this I sometimes get the value 3 from bits.
>
> Here follows an actual printout.
>
> bits = 3
> samples = -22
> step index = 0
> sample -22 step index 0
> bits = 3
> samples = -85
> step index = 25
> sample -85 step index 25
> bits = 2
> samples = 304
> step index = 30
> sample 304 step index 30
> bits = 3
> samples = -1058
> step index = 32
> sample -1058 step index 32
> bits = 3
> samples = -2179
> step index = 36
> sample -2179 step index 36
> bits = 3
> samples = -197
> step index = 34
> sample -197 step index 34
>
>
> So to me it seems like put_bits(&pb, 2, 2) is putting incorrect bits for
> me but the others work as they should. So whats wrong with my code? I'm
> running on amd64.
you store samples as 16bit but samples is larger so it randomizes the bitwriter
state
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The greatest way to live with honor in this world is to be what we pretend
to be. -- Socrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070303/18a82057/attachment.pgp>
More information about the ffmpeg-devel
mailing list