#define MAX_SYNC_SIZE 100000
-static int cdxa_probe(AVProbeData *p)
-{
- /* check file header */
- if (p->buf[0] == 'R' && p->buf[1] == 'I' &&
- p->buf[2] == 'F' && p->buf[3] == 'F' &&
- p->buf[8] == 'C' && p->buf[9] == 'D' &&
- p->buf[10] == 'X' && p->buf[11] == 'A')
- return AVPROBE_SCORE_MAX;
- else
- return 0;
-}
-
static int check_pes(uint8_t *p, uint8_t *end){
int pes1;
int pes2= (p[3] & 0xC0) == 0x80
static int mpegps_probe(AVProbeData *p)
{
uint32_t code= -1;
- int sys=0, pspack=0, priv1=0, vid=0, audio=0;
+ int sys=0, pspack=0, priv1=0, vid=0, audio=0, invalid=0;
int i;
int score=0;
- score = cdxa_probe(p);
- if (score > 0) return score;
-
- /* Search for MPEG stream */
for(i=0; i<p->buf_size; i++){
code = (code<<8) + p->buf[i];
if ((code & 0xffffff00) == 0x100) {
else if(code == PACK_START_CODE) pspack++;
else if((code & 0xf0) == VIDEO_ID && pes) vid++;
else if((code & 0xe0) == AUDIO_ID && pes) audio++;
+
+ else if((code & 0xf0) == VIDEO_ID && !pes) invalid++;
+ else if((code & 0xe0) == AUDIO_ID && !pes) invalid++;
}
}
- if(vid || audio) /* invalid VDR files nd short PES streams */
+ if(vid+audio > invalid) /* invalid VDR files nd short PES streams */
score= AVPROBE_SCORE_MAX/4;
//av_log(NULL, AV_LOG_ERROR, "%d %d %d %d %d len:%d\n", sys, priv1, pspack,vid, audio, p->buf_size);
- if(sys && sys*9 <= pspack*10)
+ if(sys>invalid && sys*9 <= pspack*10)
return AVPROBE_SCORE_MAX/2+2; // +1 for .mpg
- if((priv1 || vid || audio) && (priv1+vid+audio)*9 <= pspack*10)
+ if(priv1 + vid + audio > invalid && (priv1+vid+audio)*9 <= pspack*10)
return AVPROBE_SCORE_MAX/2+2; // +1 for .mpg
if((!!vid ^ !!audio) && (audio+vid > 1) && !sys && !pspack && p->buf_size>2048) /* PES stream */
return AVPROBE_SCORE_MAX/2+2;
static int64_t get_pts(ByteIOContext *pb, int c)
{
- int64_t pts;
- int val;
-
- if (c < 0)
- c = get_byte(pb);
- pts = (int64_t)((c >> 1) & 0x07) << 30;
- val = get_be16(pb);
- pts |= (int64_t)(val >> 1) << 15;
- val = get_be16(pb);
- pts |= (int64_t)(val >> 1);
- return pts;
+ uint8_t buf[5];
+
+ buf[0] = c<0 ? get_byte(pb) : c;
+ get_buffer(pb, buf+1, 4);
+
+ return ff_parse_pes_pts(buf);
}
static int find_next_start_code(ByteIOContext *pb, int *size_ptr,
header_len -= 5;
}
}
+ if (flags & 0x3f && header_len == 0){
+ flags &= 0xC0;
+ av_log(s, AV_LOG_WARNING, "Further flags set but no bytes left\n");
+ }
if (flags & 0x01) { /* PES extension */
pes_ext = get_byte(s->pb);
header_len--;
if(dts != AV_NOPTS_VALUE && ppos){
int i;
for(i=0; i<s->nb_streams; i++){
- if(startcode == s->streams[i]->id) {
+ if(startcode == s->streams[i]->id &&
+ !url_is_streamed(s->pb) /* index useless on streams anyway */) {
+ ff_reduce_index(s, i);
av_add_index_entry(s->streams[i], *ppos, dts, 0, 0, AVINDEX_KEYFRAME /* FIXME keyframe? */);
}
}