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 av_exit()\n{\n    int i;\n    for(i=0;i<nb_output_files;i++) {\n        AVFormatContext *s = output_files[i];\n        int j;\n        if (!(s->oformat->flags & AVFMT_NOFILE))\n            url_fclose(s->pb);\n        for(j=0;j<s->nb_streams;j++) {\n            av_free(s->streams[j]->codec);\n            av_free(s->streams[j]);\n        }\n        av_free(s);\n    }\n    for(i=0;i<nb_input_files;i++)\n        av_close_input_file(input_files[i]);\n    av_free_static();\n    av_free(intra_matrix);\n    av_free(inter_matrix);\n    if (vstats_file)\n        fclose(vstats_file);\n    av_free(vstats_filename);\n    av_free(opt_names);\n    av_free(video_codec_name);\n    av_free(audio_codec_name);\n    av_free(subtitle_codec_name);\n    av_free(video_standard);\n#ifdef CONFIG_POWERPC_PERF\n    extern void powerpc_display_perf_report(void);\n    powerpc_display_perf_report();\n#endif\n    if (received_sigterm) {\n        fprintf(stderr,\n            "Received signal %d: terminating.\\n",\n            (int) received_sigterm);\n        exit (255);\n    }\n    exit(0);\n    return 0;\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}']