# HG changeset patch # User michaelni # Date 1048182750 0 # Node ID 79e8ed620b17d5e35965c470da928e28e9cd2bcf # Parent 21c85c4ab2f075c2cee12ed0441fe49fc9544c3c better non conformant divx packed bitstream detection, so unpacked (no b frames) divx MPEG4-ES streams can be read diff -r 21c85c4ab2f0 -r 79e8ed620b17 h263.c --- a/h263.c Thu Mar 20 01:00:57 2003 +0000 +++ b/h263.c Thu Mar 20 17:52:30 2003 +0000 @@ -4566,6 +4566,7 @@ int i; int e; int ver, build, ver2, ver3; + char last; buf[0]= show_bits(gb, 8); for(i=1; i<256; i++){ @@ -4574,16 +4575,21 @@ skip_bits(gb, 8); } buf[255]=0; - + /* divx detection */ - e=sscanf(buf, "DivX%dBuild%d", &ver, &build); - if(e!=2) - e=sscanf(buf, "DivX%db%d", &ver, &build); - if(e==2){ + e=sscanf(buf, "DivX%dBuild%d%c", &ver, &build, &last); + if(e<2) + e=sscanf(buf, "DivX%db%d%c", &ver, &build, &last); + if(e>=2){ s->divx_version= ver; s->divx_build= build; + s->divx_packed= e==3 && last=='p'; if(s->picture_number==0){ - printf("This file was encoded with DivX%d Build%d\n", ver, build); + printf("This file was encoded with DivX%d Build%d", ver, build); + if(s->divx_packed) + printf("p\n"); + else + printf("\n"); } } diff -r 21c85c4ab2f0 -r 79e8ed620b17 h263dec.c --- a/h263dec.c Thu Mar 20 01:00:57 2003 +0000 +++ b/h263dec.c Thu Mar 20 17:52:30 2003 +0000 @@ -128,7 +128,7 @@ static int get_consumed_bytes(MpegEncContext *s, int buf_size){ int pos= (get_bits_count(&s->gb)+7)>>3; - if(s->divx_version>=500){ + if(s->divx_packed){ //we would have to scan through the whole buf to handle the weird reordering ... return buf_size; }else if(s->flags&CODEC_FLAG_TRUNCATED){ @@ -675,7 +675,7 @@ } /* divx 5.01+ bistream reorder stuff */ - if(s->codec_id==CODEC_ID_MPEG4 && s->bitstream_buffer_size==0 && s->divx_version>=500){ + if(s->codec_id==CODEC_ID_MPEG4 && s->bitstream_buffer_size==0 && s->divx_packed){ int current_pos= get_bits_count(&s->gb)>>3; if( buf_size - current_pos > 5 diff -r 21c85c4ab2f0 -r 79e8ed620b17 mpegvideo.h --- a/mpegvideo.h Thu Mar 20 01:00:57 2003 +0000 +++ b/mpegvideo.h Thu Mar 20 17:52:30 2003 +0000 @@ -499,6 +499,7 @@ /* divx specific, used to workaround (many) bugs in divx5 */ int divx_version; int divx_build; + int divx_packed; #define BITSTREAM_BUFFER_SIZE 1024*256 uint8_t *bitstream_buffer; //Divx 5.01 puts several frames in a single one, this is used to reorder them int bitstream_buffer_size;