Mercurial > libavcodec.hg
changeset 2966:564788471dd4 libavcodec
bitstream related fixes from [PATCH] from DivX, Part 9: bitstream crashes by (Steve Lhomme | slhomme divxcorp com)
author | michael |
---|---|
date | Sat, 17 Dec 2005 11:31:56 +0000 |
parents | 40f745e4fdff |
children | ef2149182f1c |
files | h263.c svq3.c |
diffstat | 2 files changed, 9 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/h263.c Sat Dec 17 11:29:34 2005 +0000 +++ b/h263.c Sat Dec 17 11:31:56 2005 +0000 @@ -5744,10 +5744,10 @@ char buf[256]; int i; int e; - int ver, build, ver2, ver3; + int ver = 0, build = 0, ver2 = 0, ver3 = 0; char last; - for(i=0; i<255; i++){ + for(i=0; i<255 && gb->index < gb->size_in_bits; i++){ if(show_bits(gb, 23) == 0) break; buf[i]= get_bits(gb, 8); } @@ -5769,7 +5769,8 @@ e=sscanf(buf, "FFmpeg v%d.%d.%d / libavcodec build: %d", &ver, &ver2, &ver3, &build); if(e!=4){ e=sscanf(buf, "Lavc%d.%d.%d", &ver, &ver2, &ver3)+1; - build= (ver<<16) + (ver2<<8) + ver3; + if (e>1) + build= (ver<<16) + (ver2<<8) + ver3; } if(e!=4){ if(strcmp(buf, "ffmpeg")==0){ @@ -6013,9 +6014,6 @@ startcode = 0xff; for(;;) { - v = get_bits(gb, 8); - startcode = ((startcode << 8) | v) & 0xffffffff; - if(get_bits_count(gb) >= gb->size_in_bits){ if(gb->size_in_bits==8 && (s->divx_version || s->xvid_build)){ av_log(s->avctx, AV_LOG_ERROR, "frame skip %d\n", gb->size_in_bits); @@ -6024,6 +6022,10 @@ return -1; //end of stream } + /* use the bits after the test */ + v = get_bits(gb, 8); + startcode = ((startcode << 8) | v) & 0xffffffff; + if((startcode&0xFFFFFF00) != 0x100) continue; //no startcode
--- a/svq3.c Sat Dec 17 11:29:34 2005 +0000 +++ b/svq3.c Sat Dec 17 11:31:56 2005 +0000 @@ -829,7 +829,7 @@ GetBitContext gb; size = BE_32(&extradata[4]); - init_get_bits (&gb, extradata + 8, size); + init_get_bits (&gb, extradata + 8, size*8); /* 'frame size code' and optional 'width, height' */ if (get_bits (&gb, 3) == 7) {