Commit 406f0f1b authored by Nicolas George's avatar Nicolas George

Use av_find_best_stream in ffplay.

Originally committed as revision 26105 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 9128ae08
...@@ -2398,8 +2398,6 @@ static int decode_thread(void *arg) ...@@ -2398,8 +2398,6 @@ static int decode_thread(void *arg)
AVFormatContext *ic; AVFormatContext *ic;
int err, i, ret; int err, i, ret;
int st_index[AVMEDIA_TYPE_NB]; int st_index[AVMEDIA_TYPE_NB];
int st_count[AVMEDIA_TYPE_NB]={0};
int st_best_packet_count[AVMEDIA_TYPE_NB];
AVPacket pkt1, *pkt = &pkt1; AVPacket pkt1, *pkt = &pkt1;
AVFormatParameters params, *ap = &params; AVFormatParameters params, *ap = &params;
int eof=0; int eof=0;
...@@ -2408,7 +2406,6 @@ static int decode_thread(void *arg) ...@@ -2408,7 +2406,6 @@ static int decode_thread(void *arg)
ic = avformat_alloc_context(); ic = avformat_alloc_context();
memset(st_index, -1, sizeof(st_index)); memset(st_index, -1, sizeof(st_index));
memset(st_best_packet_count, -1, sizeof(st_best_packet_count));
is->video_stream = -1; is->video_stream = -1;
is->audio_stream = -1; is->audio_stream = -1;
is->subtitle_stream = -1; is->subtitle_stream = -1;
...@@ -2464,32 +2461,25 @@ static int decode_thread(void *arg) ...@@ -2464,32 +2461,25 @@ static int decode_thread(void *arg)
} }
} }
for(i = 0; i < ic->nb_streams; i++) { for (i = 0; i < ic->nb_streams; i++)
AVStream *st= ic->streams[i];
AVCodecContext *avctx = st->codec;
ic->streams[i]->discard = AVDISCARD_ALL; ic->streams[i]->discard = AVDISCARD_ALL;
if(avctx->codec_type >= (unsigned)AVMEDIA_TYPE_NB) if (!audio_disable)
continue; st_index[AVMEDIA_TYPE_VIDEO] =
if(st_count[avctx->codec_type]++ != wanted_stream[avctx->codec_type] && wanted_stream[avctx->codec_type] >= 0) av_find_best_stream(ic, AVMEDIA_TYPE_VIDEO,
continue; wanted_stream[AVMEDIA_TYPE_VIDEO], -1, NULL, 0);
if (!video_disable) {
if(st_best_packet_count[avctx->codec_type] >= st->codec_info_nb_frames) st_index[AVMEDIA_TYPE_AUDIO] =
continue; av_find_best_stream(ic, AVMEDIA_TYPE_AUDIO,
st_best_packet_count[avctx->codec_type]= st->codec_info_nb_frames; wanted_stream[AVMEDIA_TYPE_AUDIO],
st_index[AVMEDIA_TYPE_VIDEO],
switch(avctx->codec_type) { NULL, 0);
case AVMEDIA_TYPE_AUDIO: st_index[AVMEDIA_TYPE_SUBTITLE] =
if (!audio_disable) av_find_best_stream(ic, AVMEDIA_TYPE_SUBTITLE,
st_index[AVMEDIA_TYPE_AUDIO] = i; wanted_stream[AVMEDIA_TYPE_SUBTITLE],
break; (st_index[AVMEDIA_TYPE_AUDIO] >= 0 ?
case AVMEDIA_TYPE_VIDEO: st_index[AVMEDIA_TYPE_AUDIO] :
case AVMEDIA_TYPE_SUBTITLE: st_index[AVMEDIA_TYPE_VIDEO]),
if (!video_disable) NULL, 0);
st_index[avctx->codec_type] = i;
break;
default:
break;
}
} }
if (show_status) { if (show_status) {
dump_format(ic, 0, is->filename, 0); dump_format(ic, 0, is->filename, 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment