static int read_ffserver_streams(AVFormatContext *s, const char *filename)

{

    int i, err;

    AVFormatContext *ic;

    int nopts = 0;



    err = av_open_input_file(&ic, filename, NULL, FFM_PACKET_SIZE, NULL);

    if (err < 0)

        return err;

    /* copy stream format */

    s->nb_streams = ic->nb_streams;

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

        AVStream *st;

        AVCodec *codec;



        // FIXME: a more elegant solution is needed

        st = av_mallocz(sizeof(AVStream));

        memcpy(st, ic->streams[i], sizeof(AVStream));

        st->codec = avcodec_alloc_context();

        if (!st->codec) {

            print_error(filename, AVERROR(ENOMEM));

            ffmpeg_exit(1);

        }

        avcodec_copy_context(st->codec, ic->streams[i]->codec);

        s->streams[i] = st;



        codec = avcodec_find_encoder(st->codec->codec_id);

        if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {

            if (audio_stream_copy) {

                st->stream_copy = 1;

            } else

                choose_sample_fmt(st, codec);

        } else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {

            if (video_stream_copy) {

                st->stream_copy = 1;

            } else

                choose_pixel_fmt(st, codec);

        }



        if(!st->codec->thread_count)

            st->codec->thread_count = 1;

        if(st->codec->thread_count>1)

            avcodec_thread_init(st->codec, st->codec->thread_count);



        if(st->codec->flags & CODEC_FLAG_BITEXACT)

            nopts = 1;

    }



    if (!nopts)

        s->timestamp = av_gettime();



    av_close_input_file(ic);

    return 0;

}

static int read_ffserver_streams(AVFormatContext *s, const char *filename)

{

    int i, err;

    AVFormatContext *ic;

    int nopts = 0;



    err = av_open_input_file(&ic, filename, NULL, FFM_PACKET_SIZE, NULL);

    if (err < 0)

        return err;

    

    s->nb_streams = ic->nb_streams;

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

        AVStream *st;

        AVCodec *codec;



        

        st = av_mallocz(sizeof(AVStream));

        memcpy(st, ic->streams[i], sizeof(AVStream));

        st->codec = avcodec_alloc_context();

        if (!st->codec) {

            print_error(filename, AVERROR(ENOMEM));

            ffmpeg_exit(1);

        }

        avcodec_copy_context(st->codec, ic->streams[i]->codec);

        s->streams[i] = st;



        codec = avcodec_find_encoder(st->codec->codec_id);

        if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {

            if (audio_stream_copy) {

                st->stream_copy = 1;

            } else

                choose_sample_fmt(st, codec);

        } else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {

            if (video_stream_copy) {

                st->stream_copy = 1;

            } else

                choose_pixel_fmt(st, codec);

        }



        if(!st->codec->thread_count)

            st->codec->thread_count = 1;

        if(st->codec->thread_count>1)

            avcodec_thread_init(st->codec, st->codec->thread_count);



        if(st->codec->flags & CODEC_FLAG_BITEXACT)

            nopts = 1;

    }



    if (!nopts)

        s->timestamp = av_gettime();



    av_close_input_file(ic);

    return 0;

}

    s->nb_streams = ic->nb_streams;
static int FUNC_0(AVFormatContext *VAR_0, const char *VAR_1)

{

    int VAR_2, VAR_3;

    AVFormatContext *ic;

    int VAR_4 = 0;



    VAR_3 = av_open_input_file(&ic, VAR_1, NULL, FFM_PACKET_SIZE, NULL);

    if (VAR_3 < 0)

        return VAR_3;

    

    VAR_0->nb_streams = ic->nb_streams;

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

        AVStream *st;

        AVCodec *codec;



        

        st = av_mallocz(sizeof(AVStream));

        memcpy(st, ic->streams[VAR_2], sizeof(AVStream));

        st->codec = avcodec_alloc_context();

        if (!st->codec) {

            print_error(VAR_1, AVERROR(ENOMEM));

            ffmpeg_exit(1);

        }

        avcodec_copy_context(st->codec, ic->streams[VAR_2]->codec);

        VAR_0->streams[VAR_2] = st;



        codec = avcodec_find_encoder(st->codec->codec_id);

        if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {

            if (audio_stream_copy) {

                st->stream_copy = 1;

            } else

                choose_sample_fmt(st, codec);

        } else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {

            if (video_stream_copy) {

                st->stream_copy = 1;

            } else

                choose_pixel_fmt(st, codec);

        }



        if(!st->codec->thread_count)

            st->codec->thread_count = 1;

        if(st->codec->thread_count>1)

            avcodec_thread_init(st->codec, st->codec->thread_count);



        if(st->codec->flags & CODEC_FLAG_BITEXACT)

            VAR_4 = 1;

    }



    if (!VAR_4)

        VAR_0->timestamp = av_gettime();



    av_close_input_file(ic);

    return 0;

}

static int FUNC_0(AVFormatContext *VAR_0, const char *VAR_1)
{ int VAR_2, VAR_3; AVFormatContext *ic; int VAR_4 = 0; VAR_3 = av_open_input_file(&ic, VAR_1, NULL, FFM_PACKET_SIZE, NULL); if (VAR_3 < 0)
return VAR_3; VAR_0->nb_streams = ic->nb_streams; for(VAR_2=0;VAR_2<ic->nb_streams;VAR_2++) { AVStream *st; AVCodec *codec; st = av_mallocz(sizeof(AVStream)); memcpy(st, ic->streams[VAR_2], sizeof(AVStream)); st->codec = avcodec_alloc_context(); if (!st->codec) { print_error(VAR_1, AVERROR(ENOMEM)); ffmpeg_exit(1); } avcodec_copy_context(st->codec, ic->streams[VAR_2]->codec); VAR_0->streams[VAR_2] = st; codec = avcodec_find_encoder(st->codec->codec_id); if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { if (audio_stream_copy) { st->stream_copy = 1; } else choose_sample_fmt(st, codec); } else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { if (video_stream_copy) { st->stream_copy = 1; } else choose_pixel_fmt(st, codec); } if(!st->codec->thread_count)
st->codec->thread_count = 1; if(st->codec->thread_count>1)
avcodec_thread_init(st->codec, st->codec->thread_count); if(st->codec->flags & CODEC_FLAG_BITEXACT)
VAR_4 = 1; } if (!VAR_4)
VAR_0->timestamp = av_gettime(); av_close_input_file(ic); return 0; }