/*
* Image format
- * Copyright (c) 2000, 2001, 2002 Fabrice Bellard.
+ * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
* Copyright (c) 2004 Michael Niedermayer
*
* This file is part of FFmpeg.
{ CODEC_ID_SUNRAST , "im24"},
{ CODEC_ID_SUNRAST , "sunras"},
{ CODEC_ID_JPEG2000 , "jp2"},
+ { CODEC_ID_DPX , "dpx"},
{ CODEC_ID_NONE , NULL}
};
if (s1->loop_input && s->img_number > s->img_last) {
s->img_number = s->img_first;
}
+ if (s->img_number > s->img_last)
+ return AVERROR_EOF;
if (av_get_frame_filename(filename, sizeof(filename),
s->path, s->img_number)<0 && s->img_number > 1)
return AVERROR(EIO);
for(i=0; i<3; i++){
- if (url_fopen(&f[i], filename, URL_RDONLY) < 0)
+ if (url_fopen(&f[i], filename, URL_RDONLY) < 0) {
+ av_log(s1, AV_LOG_ERROR, "Could not open file : %s\n",filename);
return AVERROR(EIO);
+ }
size[i]= url_fsize(f[i]);
if(codec->codec_id != CODEC_ID_RAWVIDEO)
img->path, img->img_number) < 0 && img->img_number>1)
return AVERROR(EIO);
for(i=0; i<3; i++){
- if (url_fopen(&pb[i], filename, URL_WRONLY) < 0)
+ if (url_fopen(&pb[i], filename, URL_WRONLY) < 0) {
+ av_log(s, AV_LOG_ERROR, "Could not open file : %s\n",filename);
return AVERROR(EIO);
+ }
if(codec->codec_id != CODEC_ID_RAWVIDEO)
break;
url_fclose(pb[1]);
url_fclose(pb[2]);
}else{
+ if(av_str2id(img_tags, s->filename) == CODEC_ID_JPEG2000){
+ AVStream *st = s->streams[0];
+ if(st->codec->extradata_size > 8 &&
+ AV_RL32(st->codec->extradata+4) == MKTAG('j','p','2','h')){
+ if(pkt->size < 8 || AV_RL32(pkt->data+4) != MKTAG('j','p','2','c'))
+ goto error;
+ put_be32(pb[0], 12);
+ put_tag (pb[0], "jP ");
+ put_be32(pb[0], 0x0D0A870A); // signature
+ put_be32(pb[0], 20);
+ put_tag (pb[0], "ftyp");
+ put_tag (pb[0], "jp2 ");
+ put_be32(pb[0], 0);
+ put_tag (pb[0], "jp2 ");
+ put_buffer(pb[0], st->codec->extradata, st->codec->extradata_size);
+ }else if(pkt->size < 8 ||
+ (!st->codec->extradata_size &&
+ AV_RL32(pkt->data+4) != MKTAG('j','P',' ',' '))){ // signature
+ error:
+ av_log(s, AV_LOG_ERROR, "malformated jpeg2000 codestream\n");
+ return -1;
+ }
+ }
put_buffer(pb[0], pkt->data, pkt->size);
}
put_flush_packet(pb[0]);
"image2",
NULL_IF_CONFIG_SMALL("image2 sequence"),
"",
- "bmp,jpeg,jpg,ljpg,pam,pbm,pgm,pgmyuv,png,ppm,sgi,tif,tiff",
+ "bmp,jpeg,jpg,ljpg,pam,pbm,pcx,pgm,pgmyuv,png,ppm,sgi,tif,tiff,jp2",
sizeof(VideoData),
CODEC_ID_NONE,
CODEC_ID_MJPEG,