[Ffmpeg-devel] [BUG] put bit problem
Benjamin Larsson
banan
Sat Mar 3 12:28:39 CET 2007
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.
MvH
Benjamin Larsson
More information about the ffmpeg-devel
mailing list