ic = av_mallocz(sizeof(AVFormatContext));
ic = av_alloc_format_context();
int av_open_input_stream(AVFormatContext **ic_ptr,                          ByteIOContext *pb, const char *filename,                          AVInputFormat *fmt, AVFormatParameters *ap){    int err;    AVFormatContext *ic;    ic = av_mallocz(sizeof(AVFormatContext));    if (!ic) {        err = AVERROR_NOMEM;        goto fail;    }    ic->iformat = fmt;    if (pb)        ic->pb = *pb;    ic->duration = AV_NOPTS_VALUE;    ic->start_time = AV_NOPTS_VALUE;    pstrcpy(ic->filename, sizeof(ic->filename), filename);    /* allocate private data */    if (fmt->priv_data_size > 0) {        ic->priv_data = av_mallocz(fmt->priv_data_size);        if (!ic->priv_data) {            err = AVERROR_NOMEM;            goto fail;        }    } else {        ic->priv_data = NULL;    }    /* default pts settings is MPEG like */    av_set_pts_info(ic, 33, 1, 90000);    ic->last_pkt_pts = AV_NOPTS_VALUE;    ic->last_pkt_dts = AV_NOPTS_VALUE;    ic->last_pkt_stream_pts = AV_NOPTS_VALUE;    ic->last_pkt_stream_dts = AV_NOPTS_VALUE;        err = ic->iformat->read_header(ic, ap);    if (err < 0)        goto fail;    if (pb)        ic->data_offset = url_ftell(&ic->pb);    *ic_ptr = ic;    return 0; fail:    if (ic) {        av_freep(&ic->priv_data);    }    av_free(ic);    *ic_ptr = NULL;    return err;}