comparison mpeg.c @ 936:7eb5c18614ae libavformat

replace probe() by one similar to MPEG-ES
author michael
date Wed, 08 Feb 2006 17:35:44 +0000
parents edbe5c3717f9
children 53c4a89c1a82
comparison
equal deleted inserted replaced
935:761c9467215c 936:7eb5c18614ae
1260 1260
1261 #define MAX_SYNC_SIZE 100000 1261 #define MAX_SYNC_SIZE 100000
1262 1262
1263 static int mpegps_probe(AVProbeData *p) 1263 static int mpegps_probe(AVProbeData *p)
1264 { 1264 {
1265 uint32_t code= -1;
1266 int sys=0, pspack=0;
1265 int i; 1267 int i;
1266 int size= FFMIN(20, p->buf_size); 1268
1267 uint32_t code=0xFF; 1269 for(i=0; i<p->buf_size; i++){
1268 1270 code = (code<<8) + p->buf[i];
1269 /* we search the first start code. If it is a packet start code,
1270 then we decide it is mpeg ps. We do not send highest value to
1271 give a chance to mpegts */
1272 /* NOTE: the search range was restricted to avoid too many false
1273 detections */
1274
1275 for (i = 0; i < size; i++) {
1276 code = (code << 8) | p->buf[i];
1277 if ((code & 0xffffff00) == 0x100) { 1271 if ((code & 0xffffff00) == 0x100) {
1278 if (code == PACK_START_CODE || 1272 switch(code){
1279 code == SYSTEM_HEADER_START_CODE || 1273 case SYSTEM_HEADER_START_CODE: sys++; break;
1280 (code >= 0x1e0 && code <= 0x1ef) || 1274 case PACK_START_CODE: pspack++; break;
1281 (code >= 0x1c0 && code <= 0x1df) || 1275 }
1282 code == PRIVATE_STREAM_2 || 1276 }
1283 code == PROGRAM_STREAM_MAP || 1277 }
1284 code == PRIVATE_STREAM_1 || 1278 if(sys && sys*9 <= pspack*10)
1285 code == PADDING_STREAM) 1279 return AVPROBE_SCORE_MAX/2+2; // +1 for .mpg
1286 return AVPROBE_SCORE_MAX - 2;
1287 else
1288 return 0;
1289 }
1290 }
1291 return 0; 1280 return 0;
1292 } 1281 }
1293 1282
1294 1283
1295 typedef struct MpegDemuxContext { 1284 typedef struct MpegDemuxContext {