[FFmpeg-cvslog] avformat/mpegts: Improve probe heuristic by considering the overall frequency of 0x47 headers
Michael Niedermayer
git at videolan.org
Sat Nov 1 15:56:41 CET 2014
ffmpeg | branch: release/2.3 | Michael Niedermayer <michaelni at gmx.at> | Sat Sep 13 22:08:21 2014 +0200| [63ed7e09dd1e4b6a0721f3d5f74b4819d53e103c] | committer: Carl Eugen Hoyos
avformat/mpegts: Improve probe heuristic by considering the overall frequency of 0x47 headers
Fixes Ticket3939
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
(cherry picked from commit 296cd9c432775bbf57867fd76e8d2f505a512569)
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=63ed7e09dd1e4b6a0721f3d5f74b4819d53e103c
---
libavformat/mpegts.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index b1dd8c6..520644f 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -504,9 +504,9 @@ static void mpegts_close_filter(MpegTSContext *ts, MpegTSFilter *filter)
static int analyze(const uint8_t *buf, int size, int packet_size, int *index)
{
int stat[TS_MAX_PACKET_SIZE];
+ int stat_all = 0;
int i;
int best_score = 0;
- int best_score2 = 0;
memset(stat, 0, packet_size * sizeof(*stat));
@@ -514,17 +514,16 @@ static int analyze(const uint8_t *buf, int size, int packet_size, int *index)
if (buf[i] == 0x47 && !(buf[i + 1] & 0x80) && buf[i + 3] != 0x47) {
int x = i % packet_size;
stat[x]++;
+ stat_all++;
if (stat[x] > best_score) {
best_score = stat[x];
if (index)
*index = x;
- } else if (stat[x] > best_score2) {
- best_score2 = stat[x];
}
}
}
- return best_score - best_score2;
+ return best_score - FFMAX(stat_all - 10*best_score, 0)/10;
}
/* autodetect fec presence. Must have at least 1024 bytes */
More information about the ffmpeg-cvslog
mailing list