static int read_avserver_streams(OptionsContext *o, AVFormatContext *s, const char *filename)
{
    int i, err;
    AVFormatContext *ic = avformat_alloc_context();
    ic->interrupt_callback = int_cb;
    err = avformat_open_input(&ic, filename, NULL, NULL);
    if (err < 0)
        return err;
    for(i=0;i<ic->nb_streams;i++) {
        AVStream *st;
        OutputStream *ost;
        AVCodec *codec;
        codec = avcodec_find_encoder(ic->streams[i]->codec->codec_id);
        ost   = new_output_stream(o, s, codec->type);
        st    = ost->st;
        memcpy(st, ic->streams[i], sizeof(AVStream));
        st->info = NULL;
        avcodec_copy_context(st->codec, ic->streams[i]->codec);
        if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && !ost->stream_copy)
            choose_sample_fmt(st, codec);
        else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && !ost->stream_copy)
            choose_pixel_fmt(st, codec);
    }
    av_close_input_file(ic);
    return 0;
}
['static int read_avserver_streams(OptionsContext *o, AVFormatContext *s, const char *filename)\n{\n    int i, err;\n    AVFormatContext *ic = avformat_alloc_context();\n    ic->interrupt_callback = int_cb;\n    err = avformat_open_input(&ic, filename, NULL, NULL);\n    if (err < 0)\n        return err;\n    for(i=0;i<ic->nb_streams;i++) {\n        AVStream *st;\n        OutputStream *ost;\n        AVCodec *codec;\n        codec = avcodec_find_encoder(ic->streams[i]->codec->codec_id);\n        ost   = new_output_stream(o, s, codec->type);\n        st    = ost->st;\n        memcpy(st, ic->streams[i], sizeof(AVStream));\n        st->info = NULL;\n        avcodec_copy_context(st->codec, ic->streams[i]->codec);\n        if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && !ost->stream_copy)\n            choose_sample_fmt(st, codec);\n        else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && !ost->stream_copy)\n            choose_pixel_fmt(st, codec);\n    }\n    av_close_input_file(ic);\n    return 0;\n}', 'AVFormatContext *avformat_alloc_context(void)\n{\n    AVFormatContext *ic;\n    ic = av_malloc(sizeof(AVFormatContext));\n    if (!ic) return ic;\n    avformat_get_context_defaults(ic);\n    return ic;\n}', 'void *av_malloc(size_t size)\n{\n    void *ptr = NULL;\n#if CONFIG_MEMALIGN_HACK\n    long diff;\n#endif\n    if(size > (INT_MAX-32) )\n        return NULL;\n#if CONFIG_MEMALIGN_HACK\n    ptr = malloc(size+32);\n    if(!ptr)\n        return ptr;\n    diff= ((-(long)ptr - 1)&31) + 1;\n    ptr = (char*)ptr + diff;\n    ((char*)ptr)[-1]= diff;\n#elif HAVE_POSIX_MEMALIGN\n    if (posix_memalign(&ptr,32,size))\n        ptr = NULL;\n#elif HAVE_MEMALIGN\n    ptr = memalign(32,size);\n#else\n    ptr = malloc(size);\n#endif\n    return ptr;\n}']