# HG changeset patch # User philipjsg # Date 1039576727 0 # Node ID 995bb04e02f10ed95f06225ada56936a1005d157 # Parent 47e502ac63492fc2a6ba43f75e9a3f00203015c5 * 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....... diff -r 47e502ac6349 -r 995bb04e02f1 img.c --- a/img.c Mon Dec 09 12:03:43 2002 +0000 +++ b/img.c Wed Dec 11 03:18:47 2002 +0000 @@ -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 #include "avformat.h" extern AVInputFormat pgm_iformat; @@ -55,6 +56,8 @@ 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 @@ 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