Mercurial > libavcodec.hg
changeset 10535:95f3daa991a2 libavcodec
Use get_bits_left() instead of size_in_bits - get_bits_count().
author | rbultje |
---|---|
date | Mon, 16 Nov 2009 17:42:43 +0000 |
parents | 4cd2ef16fb63 |
children | 046dcf7aa19c |
files | alsdec.c h261dec.c h263.c h263dec.c h264.c huffyuv.c mpeg12.c mpeg4audio.c mpegaudiodec.c msmpeg4.c wavpack.c |
diffstat | 11 files changed, 21 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/alsdec.c Mon Nov 16 01:56:47 2009 +0000 +++ b/alsdec.c Mon Nov 16 17:42:43 2009 +0000 @@ -380,7 +380,7 @@ */ 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);
--- a/h261dec.c Mon Nov 16 01:56:47 2009 +0000 +++ b/h261dec.c Mon Nov 16 17:42:43 2009 +0000 @@ -170,7 +170,7 @@ //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 @@ 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)
--- a/h263.c Mon Nov 16 01:56:47 2009 +0000 +++ b/h263.c Mon Nov 16 17:42:43 2009 +0000 @@ -2994,7 +2994,7 @@ /* 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 @@ //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 @@ /* 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 @@ 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)
--- a/h263dec.c Mon Nov 16 01:56:47 2009 +0000 +++ b/h263dec.c Mon Nov 16 17:42:43 2009 +0000 @@ -268,8 +268,8 @@ /* 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 @@ // 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 @@ } 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);
--- a/h264.c Mon Nov 16 01:56:47 2009 +0000 +++ b/h264.c Mon Nov 16 17:42:43 2009 +0000 @@ -6692,7 +6692,7 @@ 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;
--- a/huffyuv.c Mon Nov 16 01:56:47 2009 +0000 +++ b/huffyuv.c Mon Nov 16 17:42:43 2009 +0000 @@ -693,7 +693,7 @@ 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 @@ 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); }
--- a/mpeg12.c Mon Nov 16 01:56:47 2009 +0000 +++ b/mpeg12.c Mon Nov 16 17:42:43 2009 +0000 @@ -1818,7 +1818,7 @@ 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*/;
--- a/mpeg4audio.c Mon Nov 16 01:56:47 2009 +0000 +++ b/mpeg4audio.c Mon Nov 16 17:42:43 2009 +0000 @@ -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'))
--- a/mpegaudiodec.c Mon Nov 16 01:56:47 2009 +0000 +++ b/mpegaudiodec.c Mon Nov 16 17:42:43 2009 +0000 @@ -2162,7 +2162,7 @@ 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 @@ 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)
--- a/msmpeg4.c Mon Nov 16 01:56:47 2009 +0000 +++ b/msmpeg4.c Mon Nov 16 17:42:43 2009 +0000 @@ -1823,7 +1823,7 @@ 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;
--- a/wavpack.c Mon Nov 16 01:56:47 2009 +0000 +++ b/wavpack.c Mon Nov 16 17:42:43 2009 +0000 @@ -378,7 +378,7 @@ 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 @@ 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");