mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-26 19:01:44 +02:00
Use get_bits_left() instead of size_in_bits - get_bits_count().
Originally committed as revision 20543 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
830628e11c
commit
6e44ba1550
@ -380,7 +380,7 @@ static void parse_bs_info(const uint32_t bs_info, unsigned int n,
|
||||
*/
|
||||
static int32_t decode_rice(GetBitContext *gb, unsigned int k)
|
||||
{
|
||||
int max = gb->size_in_bits - get_bits_count(gb) - k;
|
||||
int max = get_bits_left(gb) - k;
|
||||
int q = get_unary(gb, 0, max);
|
||||
int r = k ? get_bits1(gb) : !(q & 1);
|
||||
|
||||
|
@ -170,7 +170,7 @@ static int ff_h261_resync(H261Context *h){
|
||||
//OK, it is not where it is supposed to be ...
|
||||
s->gb= s->last_resync_gb;
|
||||
align_get_bits(&s->gb);
|
||||
left= s->gb.size_in_bits - get_bits_count(&s->gb);
|
||||
left= get_bits_left(&s->gb);
|
||||
|
||||
for(;left>15+1+4+5; left-=8){
|
||||
if(show_bits(&s->gb, 15)==0){
|
||||
@ -444,7 +444,7 @@ static int h261_decode_picture_header(H261Context *h){
|
||||
int format, i;
|
||||
uint32_t startcode= 0;
|
||||
|
||||
for(i= s->gb.size_in_bits - get_bits_count(&s->gb); i>24; i-=1){
|
||||
for(i= get_bits_left(&s->gb); i>24; i-=1){
|
||||
startcode = ((startcode << 1) | get_bits(&s->gb, 1)) & 0x000FFFFF;
|
||||
|
||||
if(startcode == 0x10)
|
||||
|
@ -2994,7 +2994,7 @@ static int h263_decode_gob_header(MpegEncContext *s)
|
||||
|
||||
/* We have a GBSC probably with GSTUFF */
|
||||
skip_bits(&s->gb, 16); /* Drop the zeros */
|
||||
left= s->gb.size_in_bits - get_bits_count(&s->gb);
|
||||
left= get_bits_left(&s->gb);
|
||||
//MN: we must check the bits left or we might end in a infinite loop (or segfault)
|
||||
for(;left>13; left--){
|
||||
if(get_bits1(&s->gb)) break; /* Seek the '1' bit */
|
||||
@ -3329,7 +3329,7 @@ int ff_h263_resync(MpegEncContext *s){
|
||||
//OK, it's not where it is supposed to be ...
|
||||
s->gb= s->last_resync_gb;
|
||||
align_get_bits(&s->gb);
|
||||
left= s->gb.size_in_bits - get_bits_count(&s->gb);
|
||||
left= get_bits_left(&s->gb);
|
||||
|
||||
for(;left>16+1+5+5; left-=8){
|
||||
if(show_bits(&s->gb, 16)==0){
|
||||
@ -3774,7 +3774,7 @@ static int mpeg4_decode_partitioned_mb(MpegEncContext *s, DCTELEM block[6][64])
|
||||
/* per-MB end of slice check */
|
||||
|
||||
if(--s->mb_num_left <= 0){
|
||||
//printf("%06X %d\n", show_bits(&s->gb, 24), s->gb.size_in_bits - get_bits_count(&s->gb));
|
||||
//printf("%06X %d\n", show_bits(&s->gb, 24), get_bits_left(&s->gb));
|
||||
if(mpeg4_is_resync(s))
|
||||
return SLICE_END;
|
||||
else
|
||||
@ -5034,7 +5034,7 @@ int h263_decode_picture_header(MpegEncContext *s)
|
||||
|
||||
startcode= get_bits(&s->gb, 22-8);
|
||||
|
||||
for(i= s->gb.size_in_bits - get_bits_count(&s->gb); i>24; i-=8) {
|
||||
for(i= get_bits_left(&s->gb); i>24; i-=8) {
|
||||
startcode = ((startcode << 8) | get_bits(&s->gb, 8)) & 0x003FFFFF;
|
||||
|
||||
if(startcode == 0x20)
|
||||
|
@ -268,8 +268,8 @@ static int decode_slice(MpegEncContext *s){
|
||||
/* try to detect the padding bug */
|
||||
if( s->codec_id==CODEC_ID_MPEG4
|
||||
&& (s->workaround_bugs&FF_BUG_AUTODETECT)
|
||||
&& s->gb.size_in_bits - get_bits_count(&s->gb) >=0
|
||||
&& s->gb.size_in_bits - get_bits_count(&s->gb) < 48
|
||||
&& get_bits_left(&s->gb) >=0
|
||||
&& get_bits_left(&s->gb) < 48
|
||||
// && !s->resync_marker
|
||||
&& !s->data_partitioning){
|
||||
|
||||
@ -300,7 +300,7 @@ static int decode_slice(MpegEncContext *s){
|
||||
|
||||
// handle formats which don't have unique end markers
|
||||
if(s->msmpeg4_version || (s->workaround_bugs&FF_BUG_NO_PADDING)){ //FIXME perhaps solve this more cleanly
|
||||
int left= s->gb.size_in_bits - get_bits_count(&s->gb);
|
||||
int left= get_bits_left(&s->gb);
|
||||
int max_extra=7;
|
||||
|
||||
/* no markers in M$ crap */
|
||||
@ -325,7 +325,7 @@ static int decode_slice(MpegEncContext *s){
|
||||
}
|
||||
|
||||
av_log(s->avctx, AV_LOG_ERROR, "slice end not reached but screenspace end (%d left %06X, score= %d)\n",
|
||||
s->gb.size_in_bits - get_bits_count(&s->gb),
|
||||
get_bits_left(&s->gb),
|
||||
show_bits(&s->gb, 24), s->padding_bug_score);
|
||||
|
||||
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END)&part_mask);
|
||||
|
@ -6692,7 +6692,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg){
|
||||
ff_init_cabac_states( &h->cabac);
|
||||
ff_init_cabac_decoder( &h->cabac,
|
||||
s->gb.buffer + get_bits_count(&s->gb)/8,
|
||||
( s->gb.size_in_bits - get_bits_count(&s->gb) + 7)/8);
|
||||
(get_bits_left(&s->gb) + 7)/8);
|
||||
/* calculate pre-state */
|
||||
for( i= 0; i < 460; i++ ) {
|
||||
int pre;
|
||||
|
@ -693,7 +693,7 @@ static void decode_422_bitstream(HYuvContext *s, int count){
|
||||
|
||||
count/=2;
|
||||
|
||||
if(count >= (s->gb.size_in_bits - get_bits_count(&s->gb))/(31*4)){
|
||||
if(count >= (get_bits_left(&s->gb))/(31*4)){
|
||||
for(i=0; i<count && get_bits_count(&s->gb) < s->gb.size_in_bits; i++){
|
||||
READ_2PIX(s->temp[0][2*i ], s->temp[1][i], 1);
|
||||
READ_2PIX(s->temp[0][2*i+1], s->temp[2][i], 2);
|
||||
@ -711,7 +711,7 @@ static void decode_gray_bitstream(HYuvContext *s, int count){
|
||||
|
||||
count/=2;
|
||||
|
||||
if(count >= (s->gb.size_in_bits - get_bits_count(&s->gb))/(31*2)){
|
||||
if(count >= (get_bits_left(&s->gb))/(31*2)){
|
||||
for(i=0; i<count && get_bits_count(&s->gb) < s->gb.size_in_bits; i++){
|
||||
READ_2PIX(s->temp[0][2*i ], s->temp[0][2*i+1], 0);
|
||||
}
|
||||
|
@ -1818,7 +1818,7 @@ static int mpeg_decode_slice(Mpeg1Context *s1, int mb_y,
|
||||
s->mb_y++;
|
||||
|
||||
if(s->mb_y<<field_pic >= s->mb_height){
|
||||
int left= s->gb.size_in_bits - get_bits_count(&s->gb);
|
||||
int left= get_bits_left(&s->gb);
|
||||
int is_d10= s->chroma_format==2 && s->pict_type==FF_I_TYPE && avctx->profile==0 && avctx->level==5
|
||||
&& s->intra_dc_precision == 2 && s->q_scale_type == 1 && s->alternate_scan == 0
|
||||
&& s->progressive_frame == 0 /* vbv_delay == 0xBBB || 0xE10*/;
|
||||
|
@ -32,7 +32,7 @@
|
||||
*/
|
||||
static int parse_config_ALS(GetBitContext *gb, MPEG4AudioConfig *c)
|
||||
{
|
||||
if (gb->size_in_bits - get_bits_count(gb) < 112)
|
||||
if (get_bits_left(gb) < 112)
|
||||
return -1;
|
||||
|
||||
if (get_bits_long(gb, 32) != MKBETAG('A','L','S','\0'))
|
||||
|
@ -2162,7 +2162,7 @@ static int mp_decode_frame(MPADecodeContext *s,
|
||||
s->last_buf_size=0;
|
||||
if(s->in_gb.buffer){
|
||||
align_get_bits(&s->gb);
|
||||
i= (s->gb.size_in_bits - get_bits_count(&s->gb))>>3;
|
||||
i= get_bits_left(&s->gb)>>3;
|
||||
if(i >= 0 && i <= BACKSTEP_SIZE){
|
||||
memmove(s->last_buf, s->gb.buffer + (get_bits_count(&s->gb)>>3), i);
|
||||
s->last_buf_size=i;
|
||||
@ -2174,7 +2174,7 @@ static int mp_decode_frame(MPADecodeContext *s,
|
||||
|
||||
align_get_bits(&s->gb);
|
||||
assert((get_bits_count(&s->gb) & 7) == 0);
|
||||
i= (s->gb.size_in_bits - get_bits_count(&s->gb))>>3;
|
||||
i= get_bits_left(&s->gb)>>3;
|
||||
|
||||
if(i<0 || i > BACKSTEP_SIZE || nb_frames<0){
|
||||
if(i<0)
|
||||
|
@ -1823,7 +1823,7 @@ int ff_msmpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
|
||||
if (i > 62){
|
||||
i-= 192;
|
||||
if(i&(~63)){
|
||||
const int left= s->gb.size_in_bits - get_bits_count(&s->gb);
|
||||
const int left= get_bits_left(&s->gb);
|
||||
if(((i+192 == 64 && level/qmul==-1) || s->error_recognition<=1) && left>=0){
|
||||
av_log(s->avctx, AV_LOG_ERROR, "ignoring overflow at %d %d\n", s->mb_x, s->mb_y);
|
||||
break;
|
||||
|
@ -378,7 +378,7 @@ static float wv_get_value_float(WavpackContext *s, uint32_t *crc, int S)
|
||||
|
||||
if(s->got_extra_bits){
|
||||
const int max_bits = 1 + 23 + 8 + 1;
|
||||
const int left_bits = s->gb_extra_bits.size_in_bits - get_bits_count(&s->gb_extra_bits);
|
||||
const int left_bits = get_bits_left(&s->gb_extra_bits);
|
||||
|
||||
if(left_bits + 8 * FF_INPUT_BUFFER_PADDING_SIZE < max_bits)
|
||||
return 0.0;
|
||||
@ -897,7 +897,7 @@ static int wavpack_decode_frame(AVCodecContext *avctx,
|
||||
return -1;
|
||||
}
|
||||
if(s->got_extra_bits && avctx->sample_fmt != SAMPLE_FMT_FLT){
|
||||
const int size = s->gb_extra_bits.size_in_bits - get_bits_count(&s->gb_extra_bits);
|
||||
const int size = get_bits_left(&s->gb_extra_bits);
|
||||
const int wanted = s->samples * s->extra_bits << s->stereo_in;
|
||||
if(size < wanted){
|
||||
av_log(avctx, AV_LOG_ERROR, "Too small EXTRABITS\n");
|
||||
|
Loading…
Reference in New Issue
Block a user