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

giles at svn.xiph.org giles at svn.xiph.org
Wed Apr 16 10:50:15 PDT 2008


Author: giles
Date: 2008-04-16 10:50:15 -0700 (Wed, 16 Apr 2008)
New Revision: 14750

Modified:
   trunk/theora/tests/granulepos.c
   trunk/theora/tests/granulepos_theora.c
Log:
Reduce noise and print better fail information in the granulepos tests.


Modified: trunk/theora/tests/granulepos.c
===================================================================
--- trunk/theora/tests/granulepos.c	2008-04-16 17:32:05 UTC (rev 14749)
+++ trunk/theora/tests/granulepos.c	2008-04-16 17:50:15 UTC (rev 14750)
@@ -44,7 +44,7 @@
   ogg_packet op;
   long long int last_granule = -1;
 
-  INFO ("+ Initializing th_info struct");
+/*  INFO ("+ Initializing th_info struct"); */
   th_info_init (&ti);
 
   ti.frame_width = 32;
@@ -62,7 +62,7 @@
   ti.quality = 16;
   ti.keyframe_granule_shift=ilog(frequency);
 
-  INFO ("+ Allocating encoder context");
+/*  INFO ("+ Allocating encoder context"); */
   te = th_encode_alloc(&ti);
   if (te == NULL) {
     INFO ("+ Clearing th_info");
@@ -70,7 +70,7 @@
     FAIL ("negative return code initializing encoder");
   }
 
-  INFO ("+ Setting up dummy 4:2:0 frame data");
+/*  INFO ("+ Setting up dummy 4:2:0 frame data"); */
   framedata = calloc(ti.frame_height, ti.frame_width);
   yuv[0].width = ti.frame_width;
   yuv[0].height = ti.frame_height;
@@ -89,7 +89,7 @@
   shift = ti.keyframe_granule_shift;
   rate = (double)ti.fps_denominator/ti.fps_numerator;
   for (frame = 0; frame < frequency * 2 + 1; frame++) {
-    result = th_encode_ycbcr_in (te, &yuv);
+    result = th_encode_ycbcr_in (te, yuv);
     if (result < 0) {
       printf("th_encode_ycbcr_in() returned %d\n", result);
       FAIL ("negative error code submitting frame for compression");
@@ -100,29 +100,32 @@
     last_granule = op.granulepos;
     keyframe = op.granulepos >> shift;
     keydist = op.granulepos - (keyframe << shift);
-    if ((keyframe + keydist) != frame + 1)
-      FAIL ("encoder granulepos does not map to the correct frame number");
     tframe = th_granule_frame (te, op.granulepos);
-    if (tframe != frame)
-      FAIL ("th_granule_frame returned incorrect results");
     ttime = th_granule_time(te, op.granulepos);
-    if (fabs(rate*(frame+1) - ttime) > 1.0e-6)
-      FAIL ("th_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,
 	tframe, th_granule_time (te, op.granulepos));
 #endif
+    /* granulepos stores the frame count */
+    if ((keyframe + keydist) != frame + 1)
+      FAIL ("encoder granulepos does not map to the correct frame number");
+    /* th_granule_frame() returns the frame index */
+    if (tframe != frame)
+      FAIL ("th_granule_frame() returned incorrect results");
+    /* th_granule_time() returns the end time */
+    if (fabs(rate*(frame+1) - ttime) > 1.0e-6)
+      FAIL ("th_granule_time() returned incorrect results");
   }
 
   /* clean up */
-  INFO ("+ Freeing dummy frame data");
+/*  INFO ("+ Freeing dummy frame data"); */
   free(framedata);
 
-  INFO ("+ Clearing th_info struct");
+/*  INFO ("+ Clearing th_info struct"); */
   th_info_clear(&ti);
 
-  INFO ("+ Freeing encoder context");
+/*  INFO ("+ Freeing encoder context"); */
   th_encode_free(te);
 
   return 0;

Modified: trunk/theora/tests/granulepos_theora.c
===================================================================
--- trunk/theora/tests/granulepos_theora.c	2008-04-16 17:32:05 UTC (rev 14749)
+++ trunk/theora/tests/granulepos_theora.c	2008-04-16 17:50:15 UTC (rev 14750)
@@ -44,7 +44,7 @@
   ogg_packet op;
   long long int last_granule = -1;
 
-  INFO ("+ Initializing theora_info struct");
+/*  INFO ("+ Initializing theora_info struct"); */
   theora_info_init (&ti);
 
   ti.width = 32;
@@ -76,7 +76,7 @@
   ti.keyframe_mindistance = MIN(8, frequency);
   ti.noise_sensitivity = 1;
 
-  INFO ("+ Initializing theora_state for encoding");
+/*  INFO ("+ Initializing theora_state for encoding"); */
   result = theora_encode_init (&th, &ti);
   if (result == OC_DISABLED) {
     INFO ("+ Clearing theora_state");
@@ -85,7 +85,7 @@
     FAIL ("negative return code initializing encoder");
   }
 
-  INFO ("+ Setting up dummy 4:2:0 frame data");
+/*  INFO ("+ Setting up dummy 4:2:0 frame data"); */
   framedata = calloc(ti.height, ti.width);
   yuv.y_width = ti.width;
   yuv.y_height = ti.height;
@@ -112,29 +112,29 @@
     last_granule = op.granulepos;
     keyframe = op.granulepos >> shift;
     keydist = op.granulepos - (keyframe << shift);
-    if ((keyframe + keydist) != frame + 1)
-      FAIL ("encoder granulepos does not map to the correct frame number");
     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,
 	tframe, theora_granule_time (&th, op.granulepos));
 #endif
+    if ((keyframe + keydist) != frame + 1)
+      FAIL ("encoder granulepos does not map to the correct frame number");
+    if (tframe != frame)
+      FAIL ("theora_granule_frame returned incorrect results");
+    if (fabs(rate*(frame+1) - ttime) > 1.0e-6)
+      FAIL ("theora_granule_time returned incorrect results");
   }
 
   /* clean up */
-  INFO ("+ Freeing dummy frame data");
+/*  INFO ("+ Freeing dummy frame data"); */
   free (framedata);
 
-  INFO ("+ Clearing theora_info struct");
+/*  INFO ("+ Clearing theora_info struct"); */
   theora_info_clear (&ti);
 
-  INFO ("+ Clearing theora_state");
+/*  INFO ("+ Clearing theora_state"); */
   theora_clear (&th);
 
   return 0;



More information about the commits mailing list