History

Use av_find_best_stream in ffplay.

Originally committed as revision 26105 to svn://svn.ffmpeg.org/ffmpeg/trunk

Nicolas George committed 15 years ago

Commit 406f0f11 parent 9128ae01 file · +18 −28Browse files

Unified · Split

ffplay.c+18−28
@@ -2398,8 +2398,6 @@ static int decode_thread(void *arg) · 2397 unmodified lines
23982398 AVFormatContext *ic;
23992399 int err, i, ret;
24002400 int st_index[AVMEDIA_TYPE_NB];
2401− int st_count[AVMEDIA_TYPE_NB]={0};
2402− int st_best_packet_count[AVMEDIA_TYPE_NB];
24032401 AVPacket pkt1, *pkt = &pkt1;
24042402 AVFormatParameters params, *ap = &params;
24052403 int eof=0;
@@ -2408,7 +2406,6 @@ static int decode_thread(void *arg) · 2 unmodified lines
24082406 ic = avformat_alloc_context();
24092407
24102408 memset(st_index, -1, sizeof(st_index));
2411− memset(st_best_packet_count, -1, sizeof(st_best_packet_count));
24122409 is->video_stream = -1;
24132410 is->audio_stream = -1;
24142411 is->subtitle_stream = -1;
@@ -2464,32 +2461,25 @@ static int decode_thread(void *arg) · 49 unmodified lines
24642461 }
24652462 }
24662463
2467− for(i = 0; i < ic->nb_streams; i++) {
2468− AVStream *st= ic->streams[i];
2469− AVCodecContext *avctx = st->codec;
2464+ for (i = 0; i < ic->nb_streams; i++)
24702465 ic->streams[i]->discard = AVDISCARD_ALL;
2471− if(avctx->codec_type >= (unsigned)AVMEDIA_TYPE_NB)
2472− continue;
2473− if(st_count[avctx->codec_type]++ != wanted_stream[avctx->codec_type] && wanted_stream[avctx->codec_type] >= 0)
2474− continue;
2475−
2476− if(st_best_packet_count[avctx->codec_type] >= st->codec_info_nb_frames)
2477− continue;
2478− st_best_packet_count[avctx->codec_type]= st->codec_info_nb_frames;
2479−
2480− switch(avctx->codec_type) {
2481− case AVMEDIA_TYPE_AUDIO:
2482− if (!audio_disable)
2483− st_index[AVMEDIA_TYPE_AUDIO] = i;
2484− break;
2485− case AVMEDIA_TYPE_VIDEO:
2486− case AVMEDIA_TYPE_SUBTITLE:
2487− if (!video_disable)
2488− st_index[avctx->codec_type] = i;
2489− break;
2490− default:
2491− break;
2492− }
2466+ if (!audio_disable)
2467+ st_index[AVMEDIA_TYPE_VIDEO] =
2468+ av_find_best_stream(ic, AVMEDIA_TYPE_VIDEO,
2469+ wanted_stream[AVMEDIA_TYPE_VIDEO], -1, NULL, 0);
2470+ if (!video_disable) {
2471+ st_index[AVMEDIA_TYPE_AUDIO] =
2472+ av_find_best_stream(ic, AVMEDIA_TYPE_AUDIO,
2473+ wanted_stream[AVMEDIA_TYPE_AUDIO],
2474+ st_index[AVMEDIA_TYPE_VIDEO],
2475+ NULL, 0);
2476+ st_index[AVMEDIA_TYPE_SUBTITLE] =
2477+ av_find_best_stream(ic, AVMEDIA_TYPE_SUBTITLE,
2478+ wanted_stream[AVMEDIA_TYPE_SUBTITLE],
2479+ (st_index[AVMEDIA_TYPE_AUDIO] >= 0 ?
2480+ st_index[AVMEDIA_TYPE_AUDIO] :
2481+ st_index[AVMEDIA_TYPE_VIDEO]),
2482+ NULL, 0);
24932483 }
24942484 if (show_status) {
24952485 dump_format(ic, 0, is->filename, 0);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t