Commit 427bcdf0 authored by Michael Niedermayer's avatar Michael Niedermayer

avformat/mpegts: Use differential score for analyze()

This avoids high scores in random data that has a high 0x47 frequency

Fixes Ticket3844
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent b7d5e016
...@@ -506,6 +506,7 @@ static int analyze(const uint8_t *buf, int size, int packet_size, int *index) ...@@ -506,6 +506,7 @@ static int analyze(const uint8_t *buf, int size, int packet_size, int *index)
int stat[TS_MAX_PACKET_SIZE]; int stat[TS_MAX_PACKET_SIZE];
int i; int i;
int best_score = 0; int best_score = 0;
int best_score2 = 0;
memset(stat, 0, packet_size * sizeof(*stat)); memset(stat, 0, packet_size * sizeof(*stat));
...@@ -517,11 +518,13 @@ static int analyze(const uint8_t *buf, int size, int packet_size, int *index) ...@@ -517,11 +518,13 @@ static int analyze(const uint8_t *buf, int size, int packet_size, int *index)
best_score = stat[x]; best_score = stat[x];
if (index) if (index)
*index = x; *index = x;
} else if (stat[x] > best_score2) {
best_score2 = stat[x];
} }
} }
} }
return best_score; return best_score - best_score2;
} }
/* autodetect fec presence. Must have at least 1024 bytes */ /* autodetect fec presence. Must have at least 1024 bytes */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment