Mercurial > libavformat.hg
changeset 8:995bb04e02f1 libavformat
* 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.......
author | philipjsg |
---|---|
date | Wed, 11 Dec 2002 03:18:47 +0000 |
parents | 47e502ac6349 |
children | 97e61383cb81 |
files | img.c |
diffstat | 1 files changed, 20 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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 <unistd.h> #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