[xiph-cvs] cvs commit: theora/examples splayer.c

Ralph Giles giles at xiph.org
Fri Mar 12 19:52:11 PST 2004



giles       04/03/12 22:52:11

  Modified:    examples splayer.c
  Log:
  Display one frame a second no matter how behind we get.
  
  Also remove a debug printf.

Revision  Changes    Path
1.12      +5 -3      theora/examples/splayer.c

Index: splayer.c
===================================================================
RCS file: /usr/local/cvsroot/theora/examples/splayer.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- a/splayer.c	13 Mar 2004 03:45:45 -0000	1.11
+++ b/splayer.c	13 Mar 2004 03:52:11 -0000	1.12
@@ -882,7 +882,7 @@
   SDL_Event event;
   int hasdatatobuffer = 1;
   int playbackdone = 0;
-  double delay;
+  double delay, lastframetime = 0;
 
   int frameNum=0;
 
@@ -1014,7 +1014,6 @@
           videobuf_granulepos=td.granulepos;
           videobuf_time=theora_granule_time(&td,videobuf_granulepos);
           /* update the frame counter */
-	  //printf("Frame\n");
           frameNum++;
 
           /* check if this frame time has not passed yet.
@@ -1022,10 +1021,12 @@
              ones and keep looping, since theora at this stage
              needs to decode all frames */
           delay = videobuf_time-get_time();
-	  fprintf(stderr, "frame %d delay %.3f\n", frameNum, delay);
           if(delay>0.0){
                 /* got a good frame, not late, ready to break out */
                 videobuf_ready=1;
+	  }else if(videobuf_time-lastframetime>=1.0){
+		/* display at least one frame per second, regardless */
+		videobuf_ready=1;
           }else{
                 fprintf(stderr, "dropping frame %d (%.3fs behind)\n",
                         frameNum, -delay);
@@ -1040,6 +1041,7 @@
       /*time to write our cached frame*/
       video_write();
       videobuf_ready=0;
+      lastframetime=get_time();
 
       /*if audio has not started (first frame) then start it*/
       if ((!isPlaying)&&(vorbis_p)){

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list