Mercurial > libavformat.hg
comparison raw.c @ 924:6a9265af0009 libavformat
improve mpeg1/2-es detection
author | michael |
---|---|
date | Thu, 02 Feb 2006 13:56:42 +0000 |
parents | edbe5c3717f9 |
children | 0667558dbb8f |
comparison
equal
deleted
inserted
replaced
923:76c5dfe0b805 | 924:6a9265af0009 |
---|---|
284 } | 284 } |
285 | 285 |
286 #define SEQ_START_CODE 0x000001b3 | 286 #define SEQ_START_CODE 0x000001b3 |
287 #define GOP_START_CODE 0x000001b8 | 287 #define GOP_START_CODE 0x000001b8 |
288 #define PICTURE_START_CODE 0x00000100 | 288 #define PICTURE_START_CODE 0x00000100 |
289 | 289 #define SLICE_START_CODE 0x00000101 |
290 /* XXX: improve that by looking at several start codes */ | 290 #define PACK_START_CODE 0x000001ba |
291 | |
291 static int mpegvideo_probe(AVProbeData *p) | 292 static int mpegvideo_probe(AVProbeData *p) |
292 { | 293 { |
293 int code; | 294 uint32_t code= -1; |
294 const uint8_t *d; | 295 int pic=0, seq=0, slice=0, pspack=0; |
295 | 296 int i; |
296 /* we search the first start code. If it is a sequence, gop or | 297 |
297 picture start code then we decide it is an mpeg video | 298 for(i=0; i<p->buf_size; i++){ |
298 stream. We do not send highest value to give a chance to mpegts */ | 299 code = (code<<8) + p->buf[i]; |
299 /* NOTE: the search range was restricted to avoid too many false | 300 if ((code & 0xffffff00) == 0x100) { |
300 detections */ | 301 switch(code){ |
301 | 302 case SEQ_START_CODE: seq++; break; |
302 if (p->buf_size < 6) | 303 case PICTURE_START_CODE: pic++; break; |
303 return 0; | 304 case SLICE_START_CODE: slice++; break; |
304 d = p->buf; | 305 case PACK_START_CODE: pspack++; break; |
305 code = (d[0] << 24) | (d[1] << 16) | (d[2] << 8) | (d[3]); | 306 } |
306 if ((code & 0xffffff00) == 0x100) { | 307 } |
307 if (code == SEQ_START_CODE || | 308 } |
308 code == GOP_START_CODE || | 309 if(seq && pic && slice && seq<pic && (ABS(pic-slice)-1)*10 < pic && !pspack) |
309 code == PICTURE_START_CODE) | 310 return AVPROBE_SCORE_MAX/2+1; // +1 for .mpg |
310 return 50 - 1; | |
311 else | |
312 return 0; | |
313 } | |
314 return 0; | 311 return 0; |
315 } | 312 } |
316 | 313 |
317 static int h263_probe(AVProbeData *p) | 314 static int h263_probe(AVProbeData *p) |
318 { | 315 { |