*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "avformat.h"
/* return -1 if no image found */
-static int find_image_range(int *pfirst_index, int *plast_index,
+static int find_image_range(int *pfirst_index, int *plast_index,
const char *path)
{
char buf[1024];
}
if (first_index == 5)
goto fail;
-
+
/* find the last image */
last_index = first_index;
for(;;) {
range1 = 1;
else
range1 = 2 * range;
- if (get_frame_filename(buf, sizeof(buf), path,
+ if (get_frame_filename(buf, sizeof(buf), path,
last_index + range1) < 0)
goto fail;
if (!url_exist(buf))
st = av_new_stream(s1, 0);
if (!st) {
- av_free(s);
return -ENOMEM;
}
- if (ap && ap->image_format)
+ 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 || !ap->time_base.num) {
+ 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;
} else {
f = &s1->pb;
}
-
+
ret = av_read_image(f, s1->filename, s->img_fmt, read_header_alloc_cb, s);
if (ret < 0)
goto fail1;
} 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;
if (!s->is_pipe)
url_fclose(f);
fail:
- av_free(s);
return AVERROR_IO;
}
int i;
/* find output image format */
- if (ap && ap->image_format) {
+ if (ap->image_format) {
img_fmt = ap->image_format;
} else {
img_fmt = guess_image_format(s->filename);
if (s->nb_streams != 1)
return -1;
-
+
st = s->streams[0];
/* we select the first matching format */
for(i=0;i<PIX_FMT_NB;i++) {
img->is_pipe = 0;
else
img->is_pipe = 1;
-
+
return 0;
}
width = st->codec->width;
height = st->codec->height;
-
+
picture = (AVPicture *)pkt->data;
if (!img->is_pipe) {
- if (get_frame_filename(filename, sizeof(filename),
+ if (get_frame_filename(filename, sizeof(filename),
img->path, img->img_number) < 0)
return AVERROR_IO;
pb = &pb1;
av_register_input_format(&imagepipe_iformat);
av_register_output_format(&imagepipe_oformat);
-
+
return 0;
}