int av_open_input_stream(AVFormatContext **ic_ptr,

                         ByteIOContext *pb, const char *filename,

                         AVInputFormat *fmt, AVFormatParameters *ap)

{

    int err;

    AVFormatContext *ic;

    AVFormatParameters default_ap;



    if(!ap){

        ap=&default_ap;

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

    }



    if(!ap->prealloced_context)

        ic = avformat_alloc_context();

    else

        ic = *ic_ptr;

    if (!ic) {

        err = AVERROR(ENOMEM);

        goto fail;

    }

    ic->iformat = fmt;

    ic->pb = pb;

    ic->duration = AV_NOPTS_VALUE;

    ic->start_time = AV_NOPTS_VALUE;

    av_strlcpy(ic->filename, filename, sizeof(ic->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(ENOMEM);

            goto fail;

        }

    } else {

        ic->priv_data = NULL;

    }



    if (ic->iformat->read_header) {

        err = ic->iformat->read_header(ic, ap);

        if (err < 0)

            goto fail;

    }



    if (pb && !ic->data_offset)

        ic->data_offset = url_ftell(ic->pb);



#if LIBAVFORMAT_VERSION_MAJOR < 53

    ff_metadata_demux_compat(ic);

#endif



    ic->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE;



    *ic_ptr = ic;

    return 0;

 fail:

    if (ic) {

        int i;

        av_freep(&ic->priv_data);

        for(i=0;i<ic->nb_streams;i++) {

            AVStream *st = ic->streams[i];

            if (st) {

                av_free(st->priv_data);

                av_free(st->codec->extradata);


            }

            av_free(st);

        }

    }

    av_free(ic);

    *ic_ptr = NULL;

    return err;

}
int av_open_input_stream(AVFormatContext **ic_ptr,

                         ByteIOContext *pb, const char *filename,

                         AVInputFormat *fmt, AVFormatParameters *ap)

{

    int err;

    AVFormatContext *ic;

    AVFormatParameters default_ap;



    if(!ap){

        ap=&default_ap;

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

    }



    if(!ap->prealloced_context)

        ic = avformat_alloc_context();

    else

        ic = *ic_ptr;

    if (!ic) {

        err = AVERROR(ENOMEM);

        goto fail;

    }

    ic->iformat = fmt;

    ic->pb = pb;

    ic->duration = AV_NOPTS_VALUE;

    ic->start_time = AV_NOPTS_VALUE;

    av_strlcpy(ic->filename, filename, sizeof(ic->filename));



    

    if (fmt->priv_data_size > 0) {

        ic->priv_data = av_mallocz(fmt->priv_data_size);

        if (!ic->priv_data) {

            err = AVERROR(ENOMEM);

            goto fail;

        }

    } else {

        ic->priv_data = NULL;

    }



    if (ic->iformat->read_header) {

        err = ic->iformat->read_header(ic, ap);

        if (err < 0)

            goto fail;

    }



    if (pb && !ic->data_offset)

        ic->data_offset = url_ftell(ic->pb);



#if LIBAVFORMAT_VERSION_MAJOR < 53

    ff_metadata_demux_compat(ic);

#endif



    ic->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE;



    *ic_ptr = ic;

    return 0;

 fail:

    if (ic) {

        int i;

        av_freep(&ic->priv_data);

        for(i=0;i<ic->nb_streams;i++) {

            AVStream *st = ic->streams[i];

            if (st) {

                av_free(st->priv_data);

                av_free(st->codec->extradata);


            }

            av_free(st);

        }

    }

    av_free(ic);

    *ic_ptr = NULL;

    return err;

}
int FUNC_0(AVFormatContext **VAR_0,

                         ByteIOContext *VAR_1, const char *VAR_2,

                         AVInputFormat *VAR_3, AVFormatParameters *VAR_4)

{

    int VAR_5;

    AVFormatContext *ic;

    AVFormatParameters default_ap;



    if(!VAR_4){

        VAR_4=&default_ap;

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

    }



    if(!VAR_4->prealloced_context)

        ic = avformat_alloc_context();

    else

        ic = *VAR_0;

    if (!ic) {

        VAR_5 = AVERROR(ENOMEM);

        goto fail;

    }

    ic->iformat = VAR_3;

    ic->VAR_1 = VAR_1;

    ic->duration = AV_NOPTS_VALUE;

    ic->start_time = AV_NOPTS_VALUE;

    av_strlcpy(ic->VAR_2, VAR_2, sizeof(ic->VAR_2));



    

    if (VAR_3->priv_data_size > 0) {

        ic->priv_data = av_mallocz(VAR_3->priv_data_size);

        if (!ic->priv_data) {

            VAR_5 = AVERROR(ENOMEM);

            goto fail;

        }

    } else {

        ic->priv_data = NULL;

    }



    if (ic->iformat->read_header) {

        VAR_5 = ic->iformat->read_header(ic, VAR_4);

        if (VAR_5 < 0)

            goto fail;

    }



    if (VAR_1 && !ic->data_offset)

        ic->data_offset = url_ftell(ic->VAR_1);



#if LIBAVFORMAT_VERSION_MAJOR < 53

    ff_metadata_demux_compat(ic);

#endif



    ic->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE;



    *VAR_0 = ic;

    return 0;

 fail:

    if (ic) {

        int VAR_6;

        av_freep(&ic->priv_data);

        for(VAR_6=0;VAR_6<ic->nb_streams;VAR_6++) {

            AVStream *st = ic->streams[VAR_6];

            if (st) {

                av_free(st->priv_data);

                av_free(st->codec->extradata);


            }

            av_free(st);

        }

    }

    av_free(ic);

    *VAR_0 = NULL;

    return VAR_5;

}
int FUNC_0(AVFormatContext **VAR_0,
ByteIOContext *VAR_1, const char *VAR_2,
AVInputFormat *VAR_3, AVFormatParameters *VAR_4)
{ int VAR_5; AVFormatContext *ic; AVFormatParameters default_ap; if(!VAR_4){ VAR_4=&default_ap; memset(VAR_4, 0, sizeof(default_ap)); } if(!VAR_4->prealloced_context)
ic = avformat_alloc_context(); else
ic = *VAR_0; if (!ic) { VAR_5 = AVERROR(ENOMEM); goto fail; } ic->iformat = VAR_3; ic->VAR_1 = VAR_1; ic->duration = AV_NOPTS_VALUE; ic->start_time = AV_NOPTS_VALUE; av_strlcpy(ic->VAR_2, VAR_2, sizeof(ic->VAR_2)); if (VAR_3->priv_data_size > 0) { ic->priv_data = av_mallocz(VAR_3->priv_data_size); if (!ic->priv_data) { VAR_5 = AVERROR(ENOMEM); goto fail; } } else { ic->priv_data = NULL; } if (ic->iformat->read_header) { VAR_5 = ic->iformat->read_header(ic, VAR_4); if (VAR_5 < 0)
goto fail; } if (VAR_1 && !ic->data_offset)
ic->data_offset = url_ftell(ic->VAR_1); #if LIBAVFORMAT_VERSION_MAJOR < 53
ff_metadata_demux_compat(ic); #endif
ic->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE; *VAR_0 = ic; return 0; fail:
if (ic) { int VAR_6; av_freep(&ic->priv_data); for(VAR_6=0;VAR_6<ic->nb_streams;VAR_6++) { AVStream *st = ic->streams[VAR_6]; if (st) { av_free(st->priv_data); av_free(st->codec->extradata); } av_free(st); } } av_free(ic); *VAR_0 = NULL; return VAR_5; }