Commit 22b37f5d authored by Fabrice Bellard's avatar Fabrice Bellard

suppressed frame number modulus hack - added loop_input hack which I find easier to understand

Originally committed as revision 2151 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent b1b77fe9
...@@ -20,10 +20,16 @@ ...@@ -20,10 +20,16 @@
#include "avformat.h" #include "avformat.h"
#include "os_support.h" #include "os_support.h"
/* XXX: this is a hack */
int loop_input = 0;
typedef struct { typedef struct {
int width; int width;
int height; int height;
int img_first;
int img_last;
int img_number; int img_number;
int img_count;
int img_size; int img_size;
AVImageFormat *img_fmt; AVImageFormat *img_fmt;
int pix_fmt; int pix_fmt;
...@@ -121,6 +127,7 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap) ...@@ -121,6 +127,7 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap)
strcpy(s->path, s1->filename); strcpy(s->path, s1->filename);
s->img_number = 0; s->img_number = 0;
s->img_count = 0;
/* find format */ /* find format */
if (s1->iformat->flags & AVFMT_NOFILE) if (s1->iformat->flags & AVFMT_NOFILE)
...@@ -139,6 +146,8 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap) ...@@ -139,6 +146,8 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap)
if (!s->is_pipe) { if (!s->is_pipe) {
if (find_image_range(&first_index, &last_index, s->path) < 0) if (find_image_range(&first_index, &last_index, s->path) < 0)
goto fail; goto fail;
s->img_first = first_index;
s->img_last = last_index;
s->img_number = first_index; s->img_number = first_index;
/* compute duration */ /* compute duration */
st->start_time = 0; st->start_time = 0;
...@@ -198,6 +207,10 @@ static int img_read_packet(AVFormatContext *s1, AVPacket *pkt) ...@@ -198,6 +207,10 @@ static int img_read_packet(AVFormatContext *s1, AVPacket *pkt)
ByteIOContext f1, *f; ByteIOContext f1, *f;
if (!s->is_pipe) { if (!s->is_pipe) {
/* loop over input */
if (loop_input && s->img_number > s->img_last) {
s->img_number = s->img_first;
}
if (get_frame_filename(filename, sizeof(filename), if (get_frame_filename(filename, sizeof(filename),
s->path, s->img_number) < 0) s->path, s->img_number) < 0)
return -EIO; return -EIO;
...@@ -223,7 +236,10 @@ static int img_read_packet(AVFormatContext *s1, AVPacket *pkt) ...@@ -223,7 +236,10 @@ static int img_read_packet(AVFormatContext *s1, AVPacket *pkt)
av_free_packet(pkt); av_free_packet(pkt);
return -EIO; /* signal EOF */ return -EIO; /* signal EOF */
} else { } else {
pkt->pts = av_rescale((int64_t)s->img_number * s1->streams[0]->codec.frame_rate_base, s1->pts_den, s1->streams[0]->codec.frame_rate) / s1->pts_num; /* XXX: computing this pts is not necessary as it is done in
the generic code too */
pkt->pts = av_rescale((int64_t)s->img_count * s1->streams[0]->codec.frame_rate_base, s1->pts_den, s1->streams[0]->codec.frame_rate) / s1->pts_num;
s->img_count++;
s->img_number++; s->img_number++;
return 0; return 0;
} }
......
...@@ -606,7 +606,6 @@ static void av_estimate_timings_from_pts(AVFormatContext *ic) ...@@ -606,7 +606,6 @@ static void av_estimate_timings_from_pts(AVFormatContext *ic)
st->start_time < start_time) st->start_time < start_time)
start_time = st->start_time; start_time = st->start_time;
} }
fprintf(stderr, "start=%lld\n", start_time);
if (start_time != MAXINT64) if (start_time != MAXINT64)
ic->start_time = start_time; ic->start_time = start_time;
...@@ -1504,12 +1503,6 @@ int get_frame_filename(char *buf, int buf_size, ...@@ -1504,12 +1503,6 @@ int get_frame_filename(char *buf, int buf_size,
nd = nd * 10 + *p++ - '0'; nd = nd * 10 + *p++ - '0';
} }
c = *p++; c = *p++;
if (c == '*' && nd > 0) {
// The nd field is actually the modulus
number = number % nd;
c = *p++;
nd = 0;
}
} while (isdigit(c)); } while (isdigit(c));
switch(c) { switch(c) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment