summaryrefslogtreecommitdiff
path: root/libavformat/img.c
diff options
context:
space:
mode:
authorPhilip Gladstone <philipjsg@users.sourceforge.net>2002-12-11 03:18:47 +0000
committerPhilip Gladstone <philipjsg@users.sourceforge.net>2002-12-11 03:18:47 +0000
commit38758ab0cd029473cd6bec061b59ab9dadc97b5d (patch)
tree48f2ab5f6dc815c0304b444fc9c34bdccd61ffa1 /libavformat/img.c
parenta4d70941cd4a82f7db9fbaa2148d60ce550e7611 (diff)
* Add code to allow the img reader to read files at the nominal frame rate.
This (will) allow testing of ffserver in an automated way. The code is nasty in that it uses a global....... Originally committed as revision 1331 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/img.c')
-rw-r--r--libavformat/img.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/libavformat/img.c b/libavformat/img.c
index 305cbb08f2..5f93450368 100644
--- a/libavformat/img.c
+++ b/libavformat/img.c
@@ -16,6 +16,7 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <unistd.h>
#include "avformat.h"
extern AVInputFormat pgm_iformat;
@@ -55,6 +56,8 @@ typedef struct {
char path[1024];
} VideoData;
+int emulate_frame_rate;
+
static inline int pnm_space(int c)
{
return (c==' ' || c=='\n' || c=='\r' || c=='\t');
@@ -190,6 +193,23 @@ static int img_read_packet(AVFormatContext *s1, AVPacket *pkt)
char filename[1024];
int ret;
ByteIOContext f1, *f;
+ static INT64 first_frame;
+
+ if (emulate_frame_rate) {
+ if (!first_frame) {
+ first_frame = av_gettime();
+ } else {
+ INT64 pts;
+ INT64 nowus;
+
+ nowus = av_gettime() - first_frame;
+
+ pts = ((INT64)s->img_number * FRAME_RATE_BASE * 1000000) / (s1->streams[0]->codec.frame_rate);
+
+ if (pts > nowus)
+ usleep(pts - nowus);
+ }
+ }
/*
This if-statement destroys pipes - I do not see why it is necessary