Revision 6625a3de ffplay.c

View differences:

ffplay.c
1976 1976
{
1977 1977
    VideoState *is = arg;
1978 1978
    AVFormatContext *ic;
1979
    int err, i, ret, video_index, audio_index, subtitle_index;
1979
    int err, i, ret;
1980
    int st_index[CODEC_TYPE_NB];
1980 1981
    AVPacket pkt1, *pkt = &pkt1;
1981 1982
    AVFormatParameters params, *ap = &params;
1982 1983
    int eof=0;
1983 1984

  
1984 1985
    ic = avformat_alloc_context();
1985 1986

  
1986
    video_index = -1;
1987
    audio_index = -1;
1988
    subtitle_index = -1;
1987
    memset(st_index, -1, sizeof(st_index));
1989 1988
    is->video_stream = -1;
1990 1989
    is->audio_stream = -1;
1991 1990
    is->subtitle_stream = -1;
......
2047 2046
        switch(avctx->codec_type) {
2048 2047
        case CODEC_TYPE_AUDIO:
2049 2048
            if (wanted_audio_stream-- >= 0 && !audio_disable)
2050
                audio_index = i;
2049
                st_index[CODEC_TYPE_AUDIO] = i;
2051 2050
            break;
2052 2051
        case CODEC_TYPE_VIDEO:
2053 2052
            if (wanted_video_stream-- >= 0 && !video_disable)
2054
                video_index = i;
2053
                st_index[CODEC_TYPE_VIDEO] = i;
2055 2054
            break;
2056 2055
        case CODEC_TYPE_SUBTITLE:
2057 2056
            if (wanted_subtitle_stream-- >= 0 && !video_disable)
2058
                subtitle_index = i;
2057
                st_index[CODEC_TYPE_SUBTITLE] = i;
2059 2058
            break;
2060 2059
        default:
2061 2060
            break;
......
2066 2065
    }
2067 2066

  
2068 2067
    /* open the streams */
2069
    if (audio_index >= 0) {
2070
        stream_component_open(is, audio_index);
2068
    if (st_index[CODEC_TYPE_AUDIO] >= 0) {
2069
        stream_component_open(is, st_index[CODEC_TYPE_AUDIO]);
2071 2070
    }
2072 2071

  
2073 2072
    ret=-1;
2074
    if (video_index >= 0) {
2075
        ret= stream_component_open(is, video_index);
2073
    if (st_index[CODEC_TYPE_VIDEO] >= 0) {
2074
        ret= stream_component_open(is, st_index[CODEC_TYPE_VIDEO]);
2076 2075
    }
2077 2076
    if(ret<0) {
2078 2077
        /* add the refresh timer to draw the picture */
......
2082 2081
            is->show_audio = 2;
2083 2082
    }
2084 2083

  
2085
    if (subtitle_index >= 0) {
2086
        stream_component_open(is, subtitle_index);
2084
    if (st_index[CODEC_TYPE_SUBTITLE] >= 0) {
2085
        stream_component_open(is, st_index[CODEC_TYPE_SUBTITLE]);
2087 2086
    }
2088 2087

  
2089 2088
    if (is->video_stream < 0 && is->audio_stream < 0) {

Also available in: Unified diff