Skip to content

Commit

Permalink
Update myth mpeg-ts probing score calculation to match FFmpeg's own.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jyavenard committed Jul 16, 2013
1 parent f3c6dad commit c269fdc
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions mythtv/external/FFmpeg/libavformat/mpegts-mythtv.c
Expand Up @@ -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; i<check_count; i+=CHECK_BLOCK){
int left = FFMIN(check_count - i, CHECK_BLOCK);
int score = analyze(p->buf + 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
Expand Down

0 comments on commit c269fdc

Please sign in to comment.