comparison raw.c @ 2071:228e5fd9a357 libavformat

improve mpeg4-es detection by rejecting streams with reserved startcodes (fixes 11-i_need_your_love-daw.mp3 detected as mpeg4)
author michael
date Mon, 07 May 2007 11:57:46 +0000
parents f9861524ff86
children f316c0daf0ad
comparison
equal deleted inserted replaced
2070:a3fe42b9f15a 2071:228e5fd9a357
345 if(seq && seq*9<=pic*10 && pic*9<=slice*10 && !pspack && !pes) 345 if(seq && seq*9<=pic*10 && pic*9<=slice*10 && !pspack && !pes)
346 return AVPROBE_SCORE_MAX/2+1; // +1 for .mpg 346 return AVPROBE_SCORE_MAX/2+1; // +1 for .mpg
347 return 0; 347 return 0;
348 } 348 }
349 349
350 #define VIDEO_OBJECT_START_CODE 0x00000100
351 #define VIDEO_OBJECT_LAYER_START_CODE 0x00000120
352 #define VISUAL_OBJECT_START_CODE 0x000001b5 350 #define VISUAL_OBJECT_START_CODE 0x000001b5
353 #define VOP_START_CODE 0x000001b6 351 #define VOP_START_CODE 0x000001b6
354 352
355 static int mpeg4video_probe(AVProbeData *probe_packet) 353 static int mpeg4video_probe(AVProbeData *probe_packet)
356 { 354 {
357 uint32_t temp_buffer= -1; 355 uint32_t temp_buffer= -1;
358 int VO=0, VOL=0, VOP = 0, VISO = 0; 356 int VO=0, VOL=0, VOP = 0, VISO = 0, res=0;
359 int i; 357 int i;
360 358
361 for(i=0; i<probe_packet->buf_size; i++){ 359 for(i=0; i<probe_packet->buf_size; i++){
362 temp_buffer = (temp_buffer<<8) + probe_packet->buf[i]; 360 temp_buffer = (temp_buffer<<8) + probe_packet->buf[i];
363 if ((temp_buffer & 0xffffff00) == 0x100) { 361 if ((temp_buffer & 0xffffff00) == 0x100) {
364 switch(temp_buffer){ 362 switch(temp_buffer){
365 case VOP_START_CODE: VOP++; break; 363 case VOP_START_CODE: VOP++; break;
366 case VISUAL_OBJECT_START_CODE: VISO++; break; 364 case VISUAL_OBJECT_START_CODE: VISO++; break;
367 } 365 case 0x100 ... 0x11F: VO++; break;
368 switch(temp_buffer & 0xfffffff0){ 366 case 0x120 ... 0x12F: VOL++; break;
369 case VIDEO_OBJECT_START_CODE: VO++; break; 367 case 0x130 ... 0x1AF:
370 case VIDEO_OBJECT_LAYER_START_CODE: VOL++; break; 368 case 0x1B7 ... 0x1B9:
369 case 0x1C4 ... 0x1FF: res++; break;
371 } 370 }
372 } 371 }
373 } 372 }
374 373
375 if ( VOP >= VISO && VOP >= VOL && VO >= VOL && VOL > 0) 374 if ( VOP >= VISO && VOP >= VOL && VO >= VOL && VOL > 0 && res==0)
376 return AVPROBE_SCORE_MAX/2; 375 return AVPROBE_SCORE_MAX/2;
377 return 0; 376 return 0;
378 } 377 }
379 378
380 static int h263_probe(AVProbeData *p) 379 static int h263_probe(AVProbeData *p)