星期一, 7月 03, 2006

ffmpeg : probe - mpegts

static int mpegts_probe(AVProbeData *p)
{
const int size= p->buf_size;
int score, fec_score;
#define CHECK_COUNT 10

if (size < (TS_FEC_PACKET_SIZE * CHECK_COUNT))
return -1;

score = analyze(p->buf, TS_PACKET_SIZE *CHECK_COUNT, TS_PACKET_SIZE, NULL);
fec_score= analyze(p->buf, TS_FEC_PACKET_SIZE*CHECK_COUNT, TS_FEC_PACKET_SIZE, NULL);

if(score > fec_score && score > 6)
return AVPROBE_SCORE_MAX + score - CHECK_COUNT;
else if(fec_score > 6)
return AVPROBE_SCORE_MAX + fec_score - CHECK_COUNT;
else
return -1;
}

很奇怪...
analyze是...
static int analyze(const uint8_t *buf, int size, int packet_size, int *index)
{
int stat[packet_size];
int i;
int x=0;
int best_score=0;

memset(stat, 0, packet_size*sizeof(int));

x=0;
for(i=0; i<size; i++){
if(buf[i] == 0x47){
stat[x]++;
if(stat[x] > best_score){
best_score= stat[x];
if(index) *index= x;
}
}
x++;
if(x == packet_size) x= 0;
}
return best_score;
}
.裡面有一個偉大的用法??state[]這個local array 可以用argument packet_size最為array size。

這個analyze( )的功能是?

沒有留言:

網誌存檔