better non conformant divx packed bitstream detection, so unpacked (no b frames) divx MPEG4-ES streams can be read
Originally committed as revision 1695 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
d66c7abc93
commit
d5a2117228
@ -4566,6 +4566,7 @@ static int decode_user_data(MpegEncContext *s, GetBitContext *gb){
|
||||
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 @@ static int decode_user_data(MpegEncContext *s, GetBitContext *gb){
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ int ff_h263_decode_end(AVCodecContext *avctx)
|
||||
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 @@ retry:
|
||||
}
|
||||
|
||||
/* 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
|
||||
|
@ -499,6 +499,7 @@ typedef struct MpegEncContext {
|
||||
/* 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;
|
||||
|
Loading…
Reference in New Issue
Block a user