From 9f7490a09c1e6736623c2909f045254fb6b31499 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 23 Feb 2010 17:35:44 +0000 Subject: Also favor streams with more packets in ffplay. Originally committed as revision 22008 to svn://svn.ffmpeg.org/ffmpeg/trunk --- ffplay.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'ffplay.c') diff --git a/ffplay.c b/ffplay.c index f79e3acb04..101f663ba1 100644 --- a/ffplay.c +++ b/ffplay.c @@ -209,8 +209,8 @@ static enum PixelFormat frame_pix_fmt = PIX_FMT_NONE; static int audio_disable; static int video_disable; static int wanted_stream[CODEC_TYPE_NB]={ - [CODEC_TYPE_AUDIO]=0, - [CODEC_TYPE_VIDEO]=0, + [CODEC_TYPE_AUDIO]=-1, + [CODEC_TYPE_VIDEO]=-1, [CODEC_TYPE_SUBTITLE]=-1, }; static int seek_by_bytes=-1; @@ -1981,6 +1981,7 @@ static int decode_thread(void *arg) int err, i, ret; int st_index[CODEC_TYPE_NB]; int st_count[CODEC_TYPE_NB]={0}; + int st_best_packet_count[CODEC_TYPE_NB]; AVPacket pkt1, *pkt = &pkt1; AVFormatParameters params, *ap = ¶ms; int eof=0; @@ -1988,6 +1989,7 @@ static int decode_thread(void *arg) ic = avformat_alloc_context(); memset(st_index, -1, sizeof(st_index)); + memset(st_best_packet_count, -1, sizeof(st_best_packet_count)); is->video_stream = -1; is->audio_stream = -1; is->subtitle_stream = -1; @@ -2044,13 +2046,18 @@ static int decode_thread(void *arg) } for(i = 0; i < ic->nb_streams; i++) { - AVCodecContext *avctx = ic->streams[i]->codec; + AVStream *st= ic->streams[i]; + AVCodecContext *avctx = st->codec; ic->streams[i]->discard = AVDISCARD_ALL; if(avctx->codec_type >= (unsigned)CODEC_TYPE_NB) exit(1); if(st_count[avctx->codec_type]++ != wanted_stream[avctx->codec_type] && wanted_stream[avctx->codec_type] >= 0) continue; + if(st_best_packet_count[avctx->codec_type] >= st->codec_info_nb_frames) + continue; + st_best_packet_count[avctx->codec_type]= st->codec_info_nb_frames; + switch(avctx->codec_type) { case CODEC_TYPE_AUDIO: if (!audio_disable) -- cgit v1.2.3