summaryrefslogtreecommitdiff
path: root/libavformat/utils.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-07-01 22:35:07 +0200
committerMichael Niedermayer <michaelni@gmx.at>2015-07-01 22:51:48 +0200
commit838c5f3df7e98b15fd3acbcacaf315c32600ca45 (patch)
treec38012b6bd01e6ca16ffd241f8187ed87c7916ed /libavformat/utils.c
parent52c5521877aaba1a8effdb5e4924b0897060bd21 (diff)
avformat/utils: Redesign scoring in av_find_default_stream_index()
This avoids empty streams from being selected if a equivalent non empty one is available The new system is also clearer and more systematic This may need finetuning, which should be easy to do ... Fixes Ticket2687 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r--libavformat/utils.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index caa15abbae..66c3ed7ab2 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1585,26 +1585,26 @@ int av_find_default_stream_index(AVFormatContext *s)
int i;
AVStream *st;
int best_stream = 0;
- int best_score = -1;
+ int best_score = INT_MIN;
if (s->nb_streams <= 0)
return -1;
for (i = 0; i < s->nb_streams; i++) {
int score = 0;
st = s->streams[i];
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
- !(st->disposition & AV_DISPOSITION_ATTACHED_PIC)) {
- if (!st->codec->width && !st->codec->height && !st->codec_info_nb_frames)
- score += 25;
- else
- score += 100;
+ if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (st->disposition & AV_DISPOSITION_ATTACHED_PIC)
+ score -= 400;
+ if (st->codec->width && st->codec->height)
+ score += 50;
+ score+= 25;
}
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
- if (!st->codec->sample_rate && !st->codec_info_nb_frames)
- score += 12;
- else
+ if (st->codec->sample_rate)
score += 50;
}
+ if (st->codec_info_nb_frames)
+ score += 12;
if (st->discard != AVDISCARD_ALL)
score += 200;