Revision 5126a8ec

View differences:

libavformat/utils.c
2498 2498
                        AVCodec **decoder_ret,
2499 2499
                        int flags)
2500 2500
{
2501
    int i, nb_streams = ic->nb_streams, stream_number = 0;
2501
    int i, nb_streams = ic->nb_streams;
2502 2502
    int ret = AVERROR_STREAM_NOT_FOUND, best_count = -1;
2503 2503
    unsigned *program = NULL;
2504 2504
    AVCodec *decoder = NULL, *best_decoder = NULL;
......
2511 2511
        }
2512 2512
    }
2513 2513
    for (i = 0; i < nb_streams; i++) {
2514
        AVStream *st = ic->streams[program ? program[i] : i];
2514
        int real_stream_index = program ? program[i] : i;
2515
        AVStream *st = ic->streams[real_stream_index];
2515 2516
        AVCodecContext *avctx = st->codec;
2516 2517
        if (avctx->codec_type != type)
2517 2518
            continue;
2518
        if (wanted_stream_nb >= 0 && stream_number++ != wanted_stream_nb)
2519
        if (wanted_stream_nb >= 0 && real_stream_index != wanted_stream_nb)
2519 2520
            continue;
2520 2521
        if (st->disposition & (AV_DISPOSITION_HEARING_IMPAIRED|AV_DISPOSITION_VISUAL_IMPAIRED))
2521 2522
            continue;
......
2530 2531
        if (best_count >= st->codec_info_nb_frames)
2531 2532
            continue;
2532 2533
        best_count = st->codec_info_nb_frames;
2533
        ret = program ? program[i] : i;
2534
        ret = real_stream_index;
2534 2535
        best_decoder = decoder;
2535 2536
        if (program && i == nb_streams - 1 && ret < 0) {
2536 2537
            program = NULL;

Also available in: Unified diff