aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorRamiro Polla <ramiro.polla@gmail.com>2008-07-13 14:27:48 +0000
committerRamiro Polla <ramiro.polla@gmail.com>2008-07-13 14:27:48 +0000
commit6647ab80e36aa2484a145029141984843958b246 (patch)
tree48875bae682ea15a8e2ef0163cef880fc63f49f2 /libavcodec
parentf9bd305694747b0bb51700c8fe1745beaaf886e3 (diff)
downloadffmpeg-6647ab80e36aa2484a145029141984843958b246.tar.gz
bitstream: move put_sbits() from flacenc.c to bitstream.h and use it
throughout libavcodec. Originally committed as revision 14204 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/adpcm.c2
-rw-r--r--libavcodec/asv1.c2
-rw-r--r--libavcodec/bitstream.h7
-rw-r--r--libavcodec/flacenc.c7
-rw-r--r--libavcodec/golomb.h2
-rw-r--r--libavcodec/h261enc.c4
-rw-r--r--libavcodec/h263.c16
-rw-r--r--libavcodec/mjpegenc.c4
-rw-r--r--libavcodec/mpeg12enc.c20
-rw-r--r--libavcodec/msmpeg4.c2
-rw-r--r--libavcodec/rv10.c2
11 files changed, 34 insertions, 34 deletions
diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index 0e5160424b..9cd03fe787 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -563,7 +563,7 @@ static int adpcm_encode_frame(AVCodecContext *avctx,
//Init the encoder state
for(i=0; i<avctx->channels; i++){
c->status[i].step_index = av_clip(c->status[i].step_index, 0, 63); // clip step so it fits 6 bits
- put_bits(&pb, 16, samples[i] & 0xFFFF);
+ put_sbits(&pb, 16, samples[i]);
put_bits(&pb, 6, c->status[i].step_index);
c->status[i].prev_sample = (signed short)samples[i];
}
diff --git a/libavcodec/asv1.c b/libavcodec/asv1.c
index 7bf93fbf38..f7ef68e343 100644
--- a/libavcodec/asv1.c
+++ b/libavcodec/asv1.c
@@ -166,7 +166,7 @@ static inline void asv1_put_level(PutBitContext *pb, int level){
if(index <= 6) put_bits(pb, level_tab[index][1], level_tab[index][0]);
else{
put_bits(pb, level_tab[3][1], level_tab[3][0]);
- put_bits(pb, 8, level&0xFF);
+ put_sbits(pb, 8, level);
}
}
diff --git a/libavcodec/bitstream.h b/libavcodec/bitstream.h
index b0e4ce9984..a90d48df53 100644
--- a/libavcodec/bitstream.h
+++ b/libavcodec/bitstream.h
@@ -315,6 +315,13 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value)
}
#endif
+static inline void put_sbits(PutBitContext *pb, int bits, int32_t val)
+{
+ assert(bits >= 0 && bits <= 31);
+
+ put_bits(pb, bits, val & ((1<<bits)-1));
+}
+
static inline uint8_t* pbBufPtr(PutBitContext *s)
{
diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c
index 34fdd031bc..622db4b524 100644
--- a/libavcodec/flacenc.c
+++ b/libavcodec/flacenc.c
@@ -1236,13 +1236,6 @@ static void channel_decorrelation(FlacEncodeContext *ctx)
}
}
-static void put_sbits(PutBitContext *pb, int bits, int32_t val)
-{
- assert(bits >= 0 && bits <= 31);
-
- put_bits(pb, bits, val & ((1<<bits)-1));
-}
-
static void write_utf8(PutBitContext *pb, uint32_t val)
{
uint8_t tmp;
diff --git a/libavcodec/golomb.h b/libavcodec/golomb.h
index f2bc7fda60..db4586521c 100644
--- a/libavcodec/golomb.h
+++ b/libavcodec/golomb.h
@@ -469,7 +469,7 @@ static inline void set_ur_golomb_jpegls(PutBitContext *pb, int i, int k, int lim
}
put_bits(pb, e, 1);
if(k)
- put_bits(pb, k, i&((1<<k)-1));
+ put_sbits(pb, k, i);
}else{
while(limit > 31) {
put_bits(pb, 31, 0);
diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c
index 74f6ab7b09..564113fdfd 100644
--- a/libavcodec/h261enc.c
+++ b/libavcodec/h261enc.c
@@ -61,7 +61,7 @@ void ff_h261_encode_picture_header(MpegEncContext * s, int picture_number){
temp_ref= s->picture_number * (int64_t)30000 * s->avctx->time_base.num /
(1001 * (int64_t)s->avctx->time_base.den); //FIXME maybe this should use a timestamp
- put_bits(&s->pb, 5, temp_ref & 0x1f); /* TemporalReference */
+ put_sbits(&s->pb, 5, temp_ref); /* TemporalReference */
put_bits(&s->pb, 1, 0); /* split screen off */
put_bits(&s->pb, 1, 0); /* camera off */
@@ -309,7 +309,7 @@ static void h261_encode_block(H261Context * h, DCTELEM * block, int n){
put_bits(&s->pb, 6, run);
assert(slevel != 0);
assert(level <= 127);
- put_bits(&s->pb, 8, slevel & 0xff);
+ put_sbits(&s->pb, 8, slevel);
} else {
put_bits(&s->pb, 1, sign);
}
diff --git a/libavcodec/h263.c b/libavcodec/h263.c
index 3ffda9ffc1..95ad1f3ed1 100644
--- a/libavcodec/h263.c
+++ b/libavcodec/h263.c
@@ -249,7 +249,7 @@ void h263_encode_picture_header(MpegEncContext * s, int picture_number)
put_bits(&s->pb, 22, 0x20); /* PSC */
temp_ref= s->picture_number * (int64_t)coded_frame_rate * s->avctx->time_base.num / //FIXME use timestamp
(coded_frame_rate_base * (int64_t)s->avctx->time_base.den);
- put_bits(&s->pb, 8, temp_ref & 0xff); /* TemporalReference */
+ put_sbits(&s->pb, 8, temp_ref); /* TemporalReference */
put_bits(&s->pb, 1, 1); /* marker */
put_bits(&s->pb, 1, 0); /* h263 id */
@@ -326,7 +326,7 @@ void h263_encode_picture_header(MpegEncContext * s, int picture_number)
put_bits(&s->pb, 1, best_clock_code);
put_bits(&s->pb, 7, best_divisor);
}
- put_bits(&s->pb, 2, (temp_ref>>8)&3);
+ put_sbits(&s->pb, 2, temp_ref>>8);
}
/* Unlimited Unrestricted Motion Vectors Indicator (UUI) */
@@ -2224,11 +2224,11 @@ static void h263_encode_block(MpegEncContext * s, DCTELEM * block, int n)
assert(slevel != 0);
if(level < 128)
- put_bits(&s->pb, 8, slevel & 0xff);
+ put_sbits(&s->pb, 8, slevel);
else{
put_bits(&s->pb, 8, 128);
- put_bits(&s->pb, 5, slevel & 0x1f);
- put_bits(&s->pb, 6, (slevel>>5)&0x3f);
+ put_sbits(&s->pb, 5, slevel);
+ put_sbits(&s->pb, 6, slevel>>5);
}
}else{
if(level < 64) { // 7-bit level
@@ -2236,14 +2236,14 @@ static void h263_encode_block(MpegEncContext * s, DCTELEM * block, int n)
put_bits(&s->pb, 1, last);
put_bits(&s->pb, 6, run);
- put_bits(&s->pb, 7, slevel & 0x7f);
+ put_sbits(&s->pb, 7, slevel);
} else {
/* 11-bit level */
put_bits(&s->pb, 1, 1);
put_bits(&s->pb, 1, last);
put_bits(&s->pb, 6, run);
- put_bits(&s->pb, 11, slevel & 0x7ff);
+ put_sbits(&s->pb, 11, slevel);
}
}
} else {
@@ -2804,7 +2804,7 @@ static inline void mpeg4_encode_block(MpegEncContext * s, DCTELEM * block, int n
put_bits(ac_pb, 1, last);
put_bits(ac_pb, 6, run);
put_bits(ac_pb, 1, 1);
- put_bits(ac_pb, 12, slevel & 0xfff);
+ put_sbits(ac_pb, 12, slevel);
put_bits(ac_pb, 1, 1);
} else {
/* second escape */
diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index 5ef6db5ac3..9268af0e1f 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -369,7 +369,7 @@ void ff_mjpeg_encode_dc(MpegEncContext *s, int val,
put_bits(&s->pb, huff_size[nbits], huff_code[nbits]);
- put_bits(&s->pb, nbits, mant & ((1 << nbits) - 1));
+ put_sbits(&s->pb, nbits, mant);
}
}
@@ -421,7 +421,7 @@ static void encode_block(MpegEncContext *s, DCTELEM *block, int n)
put_bits(&s->pb, huff_size_ac[code], huff_code_ac[code]);
- put_bits(&s->pb, nbits, mant & ((1 << nbits) - 1));
+ put_sbits(&s->pb, nbits, mant);
run = 0;
}
}
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 37d1d56a18..6ef7e1ba75 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -184,7 +184,7 @@ static void put_header(MpegEncContext *s, int header)
{
align_put_bits(&s->pb);
put_bits(&s->pb, 16, header>>16);
- put_bits(&s->pb, 16, header&0xFFFF);
+ put_sbits(&s->pb, 16, header);
}
/* put sequence header if needed */
@@ -206,8 +206,8 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
/* mpeg1 header repeated every gop */
put_header(s, SEQ_START_CODE);
- put_bits(&s->pb, 12, s->width & 0xFFF);
- put_bits(&s->pb, 12, s->height & 0xFFF);
+ put_sbits(&s->pb, 12, s->width );
+ put_sbits(&s->pb, 12, s->height);
for(i=1; i<15; i++){
float error= aspect_ratio;
@@ -242,9 +242,9 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
vbv_buffer_size = (( 20 * s->bit_rate) / (1151929 / 2)) * 8 * 1024;
vbv_buffer_size= (vbv_buffer_size + 16383) / 16384;
- put_bits(&s->pb, 18, v & 0x3FFFF);
+ put_sbits(&s->pb, 18, v);
put_bits(&s->pb, 1, 1); /* marker */
- put_bits(&s->pb, 10, vbv_buffer_size & 0x3FF);
+ put_sbits(&s->pb, 10, vbv_buffer_size);
constraint_parameter_flag=
s->width <= 768 && s->height <= 576 &&
@@ -557,7 +557,7 @@ static av_always_inline void mpeg1_encode_mb_internal(MpegEncContext *s,
put_bits(&s->pb, ff_mpeg12_mbPatTable[cbp][1], ff_mpeg12_mbPatTable[cbp][0]);
} else {
put_bits(&s->pb, ff_mpeg12_mbPatTable[cbp>>2][1], ff_mpeg12_mbPatTable[cbp>>2][0]);
- put_bits(&s->pb, 2, cbp & 3);
+ put_sbits(&s->pb, 2, cbp);
}
}
s->f_count++;
@@ -640,7 +640,7 @@ static av_always_inline void mpeg1_encode_mb_internal(MpegEncContext *s,
put_bits(&s->pb, ff_mpeg12_mbPatTable[cbp][1], ff_mpeg12_mbPatTable[cbp][0]);
} else {
put_bits(&s->pb, ff_mpeg12_mbPatTable[cbp>>2][1], ff_mpeg12_mbPatTable[cbp>>2][0]);
- put_bits(&s->pb, 2, cbp & 3);
+ put_sbits(&s->pb, 2, cbp);
}
}
}
@@ -908,16 +908,16 @@ static void mpeg1_encode_block(MpegEncContext *s,
put_bits(&s->pb, 6, run);
if(s->codec_id == CODEC_ID_MPEG1VIDEO){
if (alevel < 128) {
- put_bits(&s->pb, 8, level & 0xff);
+ put_sbits(&s->pb, 8, level);
} else {
if (level < 0) {
put_bits(&s->pb, 16, 0x8001 + level + 255);
} else {
- put_bits(&s->pb, 16, level & 0xffff);
+ put_sbits(&s->pb, 16, level);
}
}
}else{
- put_bits(&s->pb, 12, level & 0xfff);
+ put_sbits(&s->pb, 12, level);
}
}
last_non_zero = i;
diff --git a/libavcodec/msmpeg4.c b/libavcodec/msmpeg4.c
index 214ebb4b93..16fdd8608c 100644
--- a/libavcodec/msmpeg4.c
+++ b/libavcodec/msmpeg4.c
@@ -957,7 +957,7 @@ else
put_bits(&s->pb, s->esc3_level_length, level);
}else{
put_bits(&s->pb, 6, run);
- put_bits(&s->pb, 8, slevel & 0xff);
+ put_sbits(&s->pb, 8, slevel);
}
} else {
/* second escape */
diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
index 7a031ae64d..86f8aeb1bc 100644
--- a/libavcodec/rv10.c
+++ b/libavcodec/rv10.c
@@ -265,7 +265,7 @@ void rv20_encode_picture_header(MpegEncContext *s, int picture_number){
put_bits(&s->pb, 1, 0); /* unknown bit */
put_bits(&s->pb, 5, s->qscale);
- put_bits(&s->pb, 8, picture_number&0xFF); //FIXME wrong, but correct is not known
+ put_sbits(&s->pb, 8, picture_number); //FIXME wrong, but correct is not known
s->mb_x= s->mb_y= 0;
ff_h263_encode_mba(s);