00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "avformat.h"
00024 #include "rawdec.h"
00025
00026 #define SEQ_START_CODE 0x000001b3
00027 #define GOP_START_CODE 0x000001b8
00028 #define PICTURE_START_CODE 0x00000100
00029 #define SLICE_START_CODE 0x00000101
00030 #define PACK_START_CODE 0x000001ba
00031 #define VIDEO_ID 0x000001e0
00032 #define AUDIO_ID 0x000001c0
00033
00034 static int mpegvideo_probe(AVProbeData *p)
00035 {
00036 uint32_t code= -1;
00037 int pic=0, seq=0, slice=0, pspack=0, vpes=0, apes=0, res=0;
00038 int i;
00039
00040 for(i=0; i<p->buf_size; i++){
00041 code = (code<<8) + p->buf[i];
00042 if ((code & 0xffffff00) == 0x100) {
00043 switch(code){
00044 case SEQ_START_CODE: seq++; break;
00045 case PICTURE_START_CODE: pic++; break;
00046 case PACK_START_CODE: pspack++; break;
00047 case 0x1b6:
00048 res++; break;
00049 }
00050 if (code >= SLICE_START_CODE && code <= 0x1af) slice++;
00051 if ((code & 0x1f0) == VIDEO_ID) vpes++;
00052 else if((code & 0x1e0) == AUDIO_ID) apes++;
00053 }
00054 }
00055 if(seq && seq*9<=pic*10 && pic*9<=slice*10 && !pspack && !apes && !res)
00056 if(vpes) return AVPROBE_SCORE_MAX/8;
00057 else return pic>1 ? AVPROBE_SCORE_MAX/2+1 : AVPROBE_SCORE_MAX/4;
00058 return 0;
00059 }
00060
00061 FF_DEF_RAWVIDEO_DEMUXER(mpegvideo, "raw MPEG video", mpegvideo_probe, NULL, CODEC_ID_MPEG1VIDEO)