static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap)

{

    VideoData *s = s1->priv_data;

    int ret, first_index, last_index;

    char buf[1024];

    ByteIOContext pb1, *f = &pb1;

    AVStream *st;



    st = av_new_stream(s1, 0);

    if (!st) {

        av_free(s);

        return -ENOMEM;

    }



    if (ap->image_format)

        s->img_fmt = ap->image_format;



    pstrcpy(s->path, sizeof(s->path), s1->filename);

    s->img_number = 0;

    s->img_count = 0;



    /* find format */

    if (s1->iformat->flags & AVFMT_NOFILE)

        s->is_pipe = 0;

    else

        s->is_pipe = 1;



    if (!ap->time_base.num) {

        st->codec->time_base= (AVRational){1,25};

    } else {

        st->codec->time_base= ap->time_base;

    }



    if (!s->is_pipe) {

        if (find_image_range(&first_index, &last_index, s->path) < 0)

            goto fail;

        s->img_first = first_index;

        s->img_last = last_index;

        s->img_number = first_index;

        /* compute duration */

        st->start_time = 0;

        st->duration = last_index - first_index + 1;

        if (get_frame_filename(buf, sizeof(buf), s->path, s->img_number) < 0)

            goto fail;

        if (url_fopen(f, buf, URL_RDONLY) < 0)

            goto fail;

    } else {

        f = &s1->pb;

    }



    ret = av_read_image(f, s1->filename, s->img_fmt, read_header_alloc_cb, s);

    if (ret < 0)

        goto fail1;



    if (!s->is_pipe) {

        url_fclose(f);

    } else {

        url_fseek(f, 0, SEEK_SET);

    }



    st->codec->codec_type = CODEC_TYPE_VIDEO;

    st->codec->codec_id = CODEC_ID_RAWVIDEO;

    st->codec->width = s->width;

    st->codec->height = s->height;

    st->codec->pix_fmt = s->pix_fmt;

    s->img_size = avpicture_get_size(s->pix_fmt, (s->width+15)&(~15), (s->height+15)&(~15));



    return 0;

 fail1:

    if (!s->is_pipe)

        url_fclose(f);

 fail:

    av_free(s);

    return AVERROR_IO;

}

static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap)

{

    VideoData *s = s1->priv_data;

    int ret, first_index, last_index;

    char buf[1024];

    ByteIOContext pb1, *f = &pb1;

    AVStream *st;



    st = av_new_stream(s1, 0);

    if (!st) {

        av_free(s);

        return -ENOMEM;

    }



    if (ap->image_format)

        s->img_fmt = ap->image_format;



    pstrcpy(s->path, sizeof(s->path), s1->filename);

    s->img_number = 0;

    s->img_count = 0;



    

    if (s1->iformat->flags & AVFMT_NOFILE)

        s->is_pipe = 0;

    else

        s->is_pipe = 1;



    if (!ap->time_base.num) {

        st->codec->time_base= (AVRational){1,25};

    } else {

        st->codec->time_base= ap->time_base;

    }



    if (!s->is_pipe) {

        if (find_image_range(&first_index, &last_index, s->path) < 0)

            goto fail;

        s->img_first = first_index;

        s->img_last = last_index;

        s->img_number = first_index;

        

        st->start_time = 0;

        st->duration = last_index - first_index + 1;

        if (get_frame_filename(buf, sizeof(buf), s->path, s->img_number) < 0)

            goto fail;

        if (url_fopen(f, buf, URL_RDONLY) < 0)

            goto fail;

    } else {

        f = &s1->pb;

    }



    ret = av_read_image(f, s1->filename, s->img_fmt, read_header_alloc_cb, s);

    if (ret < 0)

        goto fail1;



    if (!s->is_pipe) {

        url_fclose(f);

    } else {

        url_fseek(f, 0, SEEK_SET);

    }



    st->codec->codec_type = CODEC_TYPE_VIDEO;

    st->codec->codec_id = CODEC_ID_RAWVIDEO;

    st->codec->width = s->width;

    st->codec->height = s->height;

    st->codec->pix_fmt = s->pix_fmt;

    s->img_size = avpicture_get_size(s->pix_fmt, (s->width+15)&(~15), (s->height+15)&(~15));



    return 0;

 fail1:

    if (!s->is_pipe)

        url_fclose(f);

 fail:

    av_free(s);

    return AVERROR_IO;

}

        av_free(s);     av_free(s);
static int FUNC_0(AVFormatContext *VAR_0, AVFormatParameters *VAR_1)

{

    VideoData *s = VAR_0->priv_data;

    int VAR_2, VAR_3, VAR_4;

    char VAR_5[1024];

    ByteIOContext pb1, *f = &pb1;

    AVStream *st;



    st = av_new_stream(VAR_0, 0);

    if (!st) {

        av_free(s);

        return -ENOMEM;

    }



    if (VAR_1->image_format)

        s->img_fmt = VAR_1->image_format;



    pstrcpy(s->path, sizeof(s->path), VAR_0->filename);

    s->img_number = 0;

    s->img_count = 0;



    

    if (VAR_0->iformat->flags & AVFMT_NOFILE)

        s->is_pipe = 0;

    else

        s->is_pipe = 1;



    if (!VAR_1->time_base.num) {

        st->codec->time_base= (AVRational){1,25};

    } else {

        st->codec->time_base= VAR_1->time_base;

    }



    if (!s->is_pipe) {

        if (find_image_range(&VAR_3, &VAR_4, s->path) < 0)

            goto fail;

        s->img_first = VAR_3;

        s->img_last = VAR_4;

        s->img_number = VAR_3;

        

        st->start_time = 0;

        st->duration = VAR_4 - VAR_3 + 1;

        if (get_frame_filename(VAR_5, sizeof(VAR_5), s->path, s->img_number) < 0)

            goto fail;

        if (url_fopen(f, VAR_5, URL_RDONLY) < 0)

            goto fail;

    } else {

        f = &VAR_0->pb;

    }



    VAR_2 = av_read_image(f, VAR_0->filename, s->img_fmt, read_header_alloc_cb, s);

    if (VAR_2 < 0)

        goto fail1;



    if (!s->is_pipe) {

        url_fclose(f);

    } else {

        url_fseek(f, 0, SEEK_SET);

    }



    st->codec->codec_type = CODEC_TYPE_VIDEO;

    st->codec->codec_id = CODEC_ID_RAWVIDEO;

    st->codec->width = s->width;

    st->codec->height = s->height;

    st->codec->pix_fmt = s->pix_fmt;

    s->img_size = avpicture_get_size(s->pix_fmt, (s->width+15)&(~15), (s->height+15)&(~15));



    return 0;

 fail1:

    if (!s->is_pipe)

        url_fclose(f);

 fail:

    av_free(s);

    return AVERROR_IO;

}

static int FUNC_0(AVFormatContext *VAR_0, AVFormatParameters *VAR_1)
{ VideoData *s = VAR_0->priv_data; int VAR_2, VAR_3, VAR_4; char VAR_5[1024]; ByteIOContext pb1, *f = &pb1; AVStream *st; st = av_new_stream(VAR_0, 0); if (!st) { av_free(s); return -ENOMEM; } if (VAR_1->image_format)
s->img_fmt = VAR_1->image_format; pstrcpy(s->path, sizeof(s->path), VAR_0->filename); s->img_number = 0; s->img_count = 0; if (VAR_0->iformat->flags & AVFMT_NOFILE)
s->is_pipe = 0; else
s->is_pipe = 1; if (!VAR_1->time_base.num) { st->codec->time_base= (AVRational){1,25}; } else { st->codec->time_base= VAR_1->time_base; } if (!s->is_pipe) { if (find_image_range(&VAR_3, &VAR_4, s->path) < 0)
goto fail; s->img_first = VAR_3; s->img_last = VAR_4; s->img_number = VAR_3; st->start_time = 0; st->duration = VAR_4 - VAR_3 + 1; if (get_frame_filename(VAR_5, sizeof(VAR_5), s->path, s->img_number) < 0)
goto fail; if (url_fopen(f, VAR_5, URL_RDONLY) < 0)
goto fail; } else { f = &VAR_0->pb; } VAR_2 = av_read_image(f, VAR_0->filename, s->img_fmt, read_header_alloc_cb, s); if (VAR_2 < 0)
goto fail1; if (!s->is_pipe) { url_fclose(f); } else { url_fseek(f, 0, SEEK_SET); } st->codec->codec_type = CODEC_TYPE_VIDEO; st->codec->codec_id = CODEC_ID_RAWVIDEO; st->codec->width = s->width; st->codec->height = s->height; st->codec->pix_fmt = s->pix_fmt; s->img_size = avpicture_get_size(s->pix_fmt, (s->width+15)&(~15), (s->height+15)&(~15)); return 0; fail1:
if (!s->is_pipe)
url_fclose(f); fail:
av_free(s); return AVERROR_IO; }