int av_open_input_stream(AVFormatContext **ic_ptr,

                         AVIOContext *pb, const char *filename,

                         AVInputFormat *fmt, AVFormatParameters *ap)

{

    int err;

    AVDictionary *opts;

    AVFormatContext *ic;

    AVFormatParameters default_ap;



    if(!ap){

        ap=&default_ap;

        memset(ap, 0, sizeof(default_ap));

    }

    opts = convert_format_parameters(ap);



    if(!ap->prealloced_context)

        ic = avformat_alloc_context();

    else

        ic = *ic_ptr;

    if (!ic) {

        err = AVERROR(ENOMEM);

        goto fail;

    }

    if (pb && fmt && fmt->flags & AVFMT_NOFILE)

        av_log(ic, AV_LOG_WARNING, "Custom AVIOContext makes no sense and "

                                   "will be ignored with AVFMT_NOFILE format.\n");

    else

        ic->pb = pb;



    err = avformat_open_input(&ic, filename, fmt, &opts);

    ic->pb = ic->pb ? ic->pb : pb; // don't leak custom pb if it wasn't set above



    *ic_ptr = ic;

fail:

    av_dict_free(&opts);

    return err;

}

int av_open_input_stream(AVFormatContext **ic_ptr,

                         AVIOContext *pb, const char *filename,

                         AVInputFormat *fmt, AVFormatParameters *ap)

{

    int err;

    AVDictionary *opts;

    AVFormatContext *ic;

    AVFormatParameters default_ap;



    if(!ap){

        ap=&default_ap;

        memset(ap, 0, sizeof(default_ap));

    }

    opts = convert_format_parameters(ap);



    if(!ap->prealloced_context)

        ic = avformat_alloc_context();

    else

        ic = *ic_ptr;

    if (!ic) {

        err = AVERROR(ENOMEM);

        goto fail;

    }

    if (pb && fmt && fmt->flags & AVFMT_NOFILE)

        av_log(ic, AV_LOG_WARNING, "Custom AVIOContext makes no sense and "

                                   "will be ignored with AVFMT_NOFILE format.\n");

    else

        ic->pb = pb;



    err = avformat_open_input(&ic, filename, fmt, &opts);

    ic->pb = ic->pb ? ic->pb : pb; 



    *ic_ptr = ic;

fail:

    av_dict_free(&opts);

    return err;

}

        ic = avformat_alloc_context();
int FUNC_0(AVFormatContext **VAR_0,

                         AVIOContext *VAR_1, const char *VAR_2,

                         AVInputFormat *VAR_3, AVFormatParameters *VAR_4)

{

    int VAR_5;

    AVDictionary *opts;

    AVFormatContext *ic;

    AVFormatParameters default_ap;



    if(!VAR_4){

        VAR_4=&default_ap;

        memset(VAR_4, 0, sizeof(default_ap));

    }

    opts = convert_format_parameters(VAR_4);



    if(!VAR_4->prealloced_context)

        ic = avformat_alloc_context();

    else

        ic = *VAR_0;

    if (!ic) {

        VAR_5 = AVERROR(ENOMEM);

        goto fail;

    }

    if (VAR_1 && VAR_3 && VAR_3->flags & AVFMT_NOFILE)

        av_log(ic, AV_LOG_WARNING, "Custom AVIOContext makes no sense and "

                                   "will be ignored with AVFMT_NOFILE format.\n");

    else

        ic->VAR_1 = VAR_1;



    VAR_5 = avformat_open_input(&ic, VAR_2, VAR_3, &opts);

    ic->VAR_1 = ic->VAR_1 ? ic->VAR_1 : VAR_1; 



    *VAR_0 = ic;

fail:

    av_dict_free(&opts);

    return VAR_5;

}

int FUNC_0(AVFormatContext **VAR_0,
AVIOContext *VAR_1, const char *VAR_2,
AVInputFormat *VAR_3, AVFormatParameters *VAR_4)
{ int VAR_5; AVDictionary *opts; AVFormatContext *ic; AVFormatParameters default_ap; if(!VAR_4){ VAR_4=&default_ap; memset(VAR_4, 0, sizeof(default_ap)); } opts = convert_format_parameters(VAR_4); if(!VAR_4->prealloced_context)
ic = avformat_alloc_context(); else
ic = *VAR_0; if (!ic) { VAR_5 = AVERROR(ENOMEM); goto fail; } if (VAR_1 && VAR_3 && VAR_3->flags & AVFMT_NOFILE)
av_log(ic, AV_LOG_WARNING, "Custom AVIOContext makes no sense and "
"will be ignored with AVFMT_NOFILE format.\n"); else
ic->VAR_1 = VAR_1; VAR_5 = avformat_open_input(&ic, VAR_2, VAR_3, &opts); ic->VAR_1 = ic->VAR_1 ? ic->VAR_1 : VAR_1; *VAR_0 = ic; fail:
av_dict_free(&opts); return VAR_5; }