[xiph-commits] r14376 - trunk/theora/tests

giles at svn.xiph.org giles at svn.xiph.org
Sat Jan 5 21:54:43 PST 2008


Author: giles
Date: 2008-01-05 21:54:41 -0800 (Sat, 05 Jan 2008)
New Revision: 14376

Modified:
   trunk/theora/tests/granulepos.c
Log:
Verify theora_granule_time() in the granulepos unit test.


Modified: trunk/theora/tests/granulepos.c
===================================================================
--- trunk/theora/tests/granulepos.c	2008-01-06 05:37:33 UTC (rev 14375)
+++ trunk/theora/tests/granulepos.c	2008-01-06 05:54:41 UTC (rev 14376)
@@ -17,6 +17,7 @@
 
 #include <stdlib.h>
 #include <theora/theora.h>
+#include <math.h>
 
 #include "tests.h"
 
@@ -37,6 +38,7 @@
   int result;
   int frame, tframe, keyframe, keydist;
   int shift;
+  double rate, ttime;
   yuv_buffer yuv;
   unsigned char *framedata;
   ogg_packet op;
@@ -97,6 +99,7 @@
 
   INFO ("+ Checking granulepos generation");
   shift = theora_granule_shift(&ti);
+  rate = (double)ti.fps_denominator/ti.fps_numerator;
   for (frame = 0; frame < frequency * 2 + 1; frame++) {
     result = theora_encode_YUVin (&th, &yuv);
     if (result < 0) {
@@ -114,6 +117,9 @@
     tframe = theora_granule_frame (&th, op.granulepos);
     if (tframe != frame)
       FAIL ("theora_granule_frame returned incorrect results");
+    ttime = theora_granule_time(&th, op.granulepos);
+    if (fabs(rate*(frame+1) - ttime) > 1.0e-6)
+      FAIL ("theora_granule_time returned incorrect results");
 #if DEBUG
     printf("++ frame %d granulepos %lld %d:%d %d %.3lfs\n", 
 	frame, (long long int)op.granulepos, keyframe, keydist,



More information about the commits mailing list