From c269fdcdfceba3f34a63a2373c43580d3409f321 Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Tue, 16 Jul 2013 12:34:05 +1000 Subject: [PATCH] Update myth mpeg-ts probing score calculation to match FFmpeg's own. the mpegts probe used to be identical, but has been changed over time, always related to bug fixes. This will allow to differentiate more easily between the two demuxers --- .../FFmpeg/libavformat/mpegts-mythtv.c | 39 ++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/mythtv/external/FFmpeg/libavformat/mpegts-mythtv.c b/mythtv/external/FFmpeg/libavformat/mpegts-mythtv.c index 5aaa2151618..c4bc3e22164 100644 --- a/mythtv/external/FFmpeg/libavformat/mpegts-mythtv.c +++ b/mythtv/external/FFmpeg/libavformat/mpegts-mythtv.c @@ -2635,32 +2635,35 @@ static int handle_packets(MpegTSContext *ts, int nb_packets) static int mpegts_probe(AVProbeData *p) { -#if 1 const int size= p->buf_size; - int score, fec_score, dvhs_score; + int maxscore=0; + int sumscore=0; + int i; int check_count= size / TS_FEC_PACKET_SIZE; #define CHECK_COUNT 10 +#define CHECK_BLOCK 100 if (check_count < CHECK_COUNT) return -1; - score = analyze(p->buf, TS_PACKET_SIZE *check_count, TS_PACKET_SIZE , NULL)*CHECK_COUNT/check_count; - dvhs_score= analyze(p->buf, TS_DVHS_PACKET_SIZE*check_count, TS_DVHS_PACKET_SIZE, NULL)*CHECK_COUNT/check_count; - fec_score = analyze(p->buf, TS_FEC_PACKET_SIZE *check_count, TS_FEC_PACKET_SIZE , NULL)*CHECK_COUNT/check_count; -// av_log(NULL, AV_LOG_DEBUG, "score: %d, dvhs_score: %d, fec_score: %d \n", score, dvhs_score, fec_score); + for (i=0; ibuf + TS_PACKET_SIZE *i, TS_PACKET_SIZE *left, TS_PACKET_SIZE , NULL); + int dvhs_score= analyze(p->buf + TS_DVHS_PACKET_SIZE*i, TS_DVHS_PACKET_SIZE*left, TS_DVHS_PACKET_SIZE, NULL); + int fec_score = analyze(p->buf + TS_FEC_PACKET_SIZE *i, TS_FEC_PACKET_SIZE *left, TS_FEC_PACKET_SIZE , NULL); + score = FFMAX3(score, dvhs_score, fec_score); + sumscore += score; + maxscore = FFMAX(maxscore, score); + } -// we need a clear definition for the returned score otherwise things will become messy sooner or later - if (score > fec_score && score > dvhs_score && score > 6) return AVPROBE_SCORE_MAX + score - CHECK_COUNT; - else if(dvhs_score > score && dvhs_score > fec_score && dvhs_score > 6) return AVPROBE_SCORE_MAX + dvhs_score - CHECK_COUNT; - else if( fec_score > 6) return AVPROBE_SCORE_MAX + fec_score - CHECK_COUNT; - else return -1; -#else - /* only use the extension for safer guess */ - if (av_match_ext(p->filename, "ts")) - return AVPROBE_SCORE_MAX; - else - return 0; -#endif + sumscore = sumscore*CHECK_COUNT/check_count; + maxscore = maxscore*CHECK_COUNT/CHECK_BLOCK; + + av_dlog(0, "TS score: %d %d\n", sumscore, maxscore); + + if (sumscore > 6) return AVPROBE_SCORE_MAX + sumscore - CHECK_COUNT; + else if (maxscore > 6) return AVPROBE_SCORE_MAX/2 + sumscore - CHECK_COUNT; + else return -1; } /* return the 90kHz PCR and the extension for the 27MHz PCR. return