void av_close_input_stream(AVFormatContext *s)
{
    int i;
    AVStream *st;
    if (s->cur_st && s->cur_st->parser)
        av_free_packet(&s->cur_pkt);
    if (s->iformat->read_close)
        s->iformat->read_close(s);
    for(i=0;i<s->nb_streams;i++) {
        st = s->streams[i];
        if (st->parser) {
            av_parser_close(st->parser);
        }
        av_free(st->index_entries);
        av_free(st->codec->extradata);
        av_free(st->codec);
        av_free(st->filename);
        av_free(st);
    }
    for(i=s->nb_programs-1; i>=0; i--) {
        av_freep(&s->programs[i]->provider_name);
        av_freep(&s->programs[i]->name);
        av_freep(&s->programs[i]->stream_index);
        av_freep(&s->programs[i]);
    }
    flush_packet_queue(s);
    av_freep(&s->priv_data);
    av_free(s);
}
['static int read_ffserver_streams(AVFormatContext *s, const char *filename)\n{\n    int i, err;\n    AVFormatContext *ic;\n    err = av_open_input_file(&ic, filename, NULL, FFM_PACKET_SIZE, NULL);\n    if (err < 0)\n        return err;\n    s->nb_streams = ic->nb_streams;\n    for(i=0;i<ic->nb_streams;i++) {\n        AVStream *st;\n        st = av_mallocz(sizeof(AVStream));\n        memcpy(st, ic->streams[i], sizeof(AVStream));\n        st->codec = avcodec_alloc_context();\n        memcpy(st->codec, ic->streams[i]->codec, sizeof(AVCodecContext));\n        s->streams[i] = st;\n    }\n    av_close_input_file(ic);\n    return 0;\n}', 'int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,\n                       AVInputFormat *fmt,\n                       int buf_size,\n                       AVFormatParameters *ap)\n{\n    int err, probe_size;\n    AVProbeData probe_data, *pd = &probe_data;\n    ByteIOContext *pb = NULL;\n    pd->filename = "";\n    if (filename)\n        pd->filename = filename;\n    pd->buf = NULL;\n    pd->buf_size = 0;\n    if (!fmt) {\n        fmt = av_probe_input_format(pd, 0);\n    }\n    if (!fmt || !(fmt->flags & AVFMT_NOFILE)) {\n        if ((err=url_fopen(&pb, filename, URL_RDONLY)) < 0) {\n            goto fail;\n        }\n        if (buf_size > 0) {\n            url_setbufsize(pb, buf_size);\n        }\n        for(probe_size= PROBE_BUF_MIN; probe_size<=PROBE_BUF_MAX && !fmt; probe_size<<=1){\n            int score= probe_size < PROBE_BUF_MAX ? AVPROBE_SCORE_MAX/4 : 0;\n            pd->buf= av_realloc(pd->buf, probe_size + AVPROBE_PADDING_SIZE);\n            pd->buf_size = get_buffer(pb, pd->buf, probe_size);\n            memset(pd->buf+pd->buf_size, 0, AVPROBE_PADDING_SIZE);\n            if (url_fseek(pb, 0, SEEK_SET) < 0) {\n                url_fclose(pb);\n                if (url_fopen(&pb, filename, URL_RDONLY) < 0) {\n                    pb = NULL;\n                    err = AVERROR(EIO);\n                    goto fail;\n                }\n            }\n            fmt = av_probe_input_format2(pd, 1, &score);\n        }\n        av_freep(&pd->buf);\n    }\n    if (!fmt) {\n        err = AVERROR_NOFMT;\n        goto fail;\n    }\n    if (fmt->flags & AVFMT_NEEDNUMBER) {\n        if (!av_filename_number_test(filename)) {\n            err = AVERROR_NUMEXPECTED;\n            goto fail;\n        }\n    }\n    err = av_open_input_stream(ic_ptr, pb, filename, fmt, ap);\n    if (err)\n        goto fail;\n    return 0;\n fail:\n    av_freep(&pd->buf);\n    if (pb)\n        url_fclose(pb);\n    *ic_ptr = NULL;\n    return err;\n}', 'void av_close_input_file(AVFormatContext *s)\n{\n    ByteIOContext *pb = s->iformat->flags & AVFMT_NOFILE ? NULL : s->pb;\n    av_close_input_stream(s);\n    if (pb)\n        url_fclose(pb);\n}', 'void av_close_input_stream(AVFormatContext *s)\n{\n    int i;\n    AVStream *st;\n    if (s->cur_st && s->cur_st->parser)\n        av_free_packet(&s->cur_pkt);\n    if (s->iformat->read_close)\n        s->iformat->read_close(s);\n    for(i=0;i<s->nb_streams;i++) {\n        st = s->streams[i];\n        if (st->parser) {\n            av_parser_close(st->parser);\n        }\n        av_free(st->index_entries);\n        av_free(st->codec->extradata);\n        av_free(st->codec);\n        av_free(st->filename);\n        av_free(st);\n    }\n    for(i=s->nb_programs-1; i>=0; i--) {\n        av_freep(&s->programs[i]->provider_name);\n        av_freep(&s->programs[i]->name);\n        av_freep(&s->programs[i]->stream_index);\n        av_freep(&s->programs[i]);\n    }\n    flush_packet_queue(s);\n    av_freep(&s->priv_data);\n    av_free(s);\n}']