}
static int decode_thread(void *arg){    VideoState *is = arg;    AVFormatContext *ic;    int err, i, ret, video_index, audio_index;    AVPacket pkt1, *pkt = &pkt1;    video_index = -1;    audio_index = -1;    is->video_stream = -1;    is->audio_stream = -1;    global_video_state = is;    url_set_interrupt_cb(decode_interrupt_cb);    err = av_open_input_file(&ic, is->filename, NULL, 0, NULL);    if (err < 0)        return 0;    is->ic = ic;    err = av_find_stream_info(ic);    if (err < 0)        goto fail;    for(i = 0; i < ic->nb_streams; i++) {        AVCodecContext *enc = &ic->streams[i]->codec;        switch(enc->codec_type) {        case CODEC_TYPE_AUDIO:            if (audio_index < 0 && !audio_disable)                audio_index = i;            break;        case CODEC_TYPE_VIDEO:            if (video_index < 0 && !video_disable)                video_index = i;            break;        default:            break;        }    }    if (show_status) {        dump_format(ic, 0, is->filename, 0);    }    /* open the streams */    if (audio_index >= 0) {        stream_component_open(is, audio_index);    }    if (video_index >= 0) {        stream_component_open(is, video_index);    } else {        if (!display_disable)            is->show_audio = 1;    }    if (is->video_stream < 0 && is->audio_stream < 0) {        goto fail;    }    for(;;) {        if (is->abort_request)            break;        if (is->paused != is->last_paused) {            is->last_paused = is->paused;            if (ic->iformat == &rtsp_demux) {                if (is->paused)                    rtsp_pause(ic);                else                    rtsp_resume(ic);            }        }        if (is->paused && ic->iformat == &rtsp_demux) {            /* wait 10 ms to avoid trying to get another packet */            /* XXX: horrible */            SDL_Delay(10);            continue;        }        /* if the queue are full, no need to read more */        if (is->audioq.size > MAX_AUDIOQ_SIZE ||            is->videoq.size > MAX_VIDEOQ_SIZE) {            /* wait 10 ms */            SDL_Delay(10);            continue;        }        ret = av_read_packet(ic, pkt);        if (ret < 0) {            break;        }        if (pkt->stream_index == is->audio_stream) {            packet_queue_put(&is->audioq, pkt);        } else if (pkt->stream_index == is->video_stream) {            packet_queue_put(&is->videoq, pkt);        } else {            av_free_packet(pkt);        }    }    /* wait until the end */    while (!is->abort_request) {        SDL_Delay(100);    } fail:    /* disable interrupting */    global_video_state = NULL;    /* close each stream */    if (is->audio_stream >= 0)        stream_component_close(is, is->audio_stream);    if (is->video_stream >= 0)        stream_component_close(is, is->video_stream);    av_close_input_file(is->ic);    is->ic = NULL; /* safety */    url_set_interrupt_cb(NULL);    return 0;}