snprintf(buf, sizeof(buf), s->path, s->img_number);
if (get_frame_filename(buf, sizeof(buf), s->path, s->img_number) < 0) goto fail;
static int jpeg_read_header(AVFormatContext *s1, AVFormatParameters *ap){    JpegContext *s;    int i;    char buf[1024];    ByteIOContext pb1, *f = &pb1;    AVStream *st;    s = av_mallocz(sizeof(JpegContext));    if (!s)        return -1;    s1->priv_data = s;    nstrcpy(s->path, sizeof(s->path), s1->filename);    s1->nb_streams = 1;    st = av_mallocz(sizeof(AVStream));    if (!st) {        free(s);        return -ENOMEM;    }    s1->streams[0] = st;    s->img_number = 0;    /* try to find the first image */    for(i=0;i<5;i++) {        snprintf(buf, sizeof(buf), s->path, s->img_number);        if (url_fopen(f, buf, URL_RDONLY) >= 0)            break;        s->img_number++;    }    if (i == 5)        goto fail;    url_fclose(f);    st->codec.codec_type = CODEC_TYPE_VIDEO;    st->codec.codec_id = CODEC_ID_MJPEG;        if (!ap || !ap->frame_rate)        st->codec.frame_rate = 25 * FRAME_RATE_BASE;    else        st->codec.frame_rate = ap->frame_rate;    return 0; fail:    free(s);    return -EIO;}