[xiph-commits] r3801 - liboggz/trunk/src/liboggz

conrad at svn.annodex.net conrad at svn.annodex.net
Thu Nov 20 18:43:25 PST 2008


Author: conrad
Date: 2008-11-20 18:43:25 -0800 (Thu, 20 Nov 2008)
New Revision: 3801

Modified:
   liboggz/trunk/src/liboggz/metric_internal.c
   liboggz/trunk/src/liboggz/oggz_auto.c
Log:
metric_internal: add a custom metric for Dirac. This moves the Dirac
granulepos handling (specifically the shift of (iframe+pframe)>>9)
to where it is more generally used for converting granulepos to time.
Now oggz merge and oggz sort seem to handle Dirac; please test.


Modified: liboggz/trunk/src/liboggz/metric_internal.c
===================================================================
--- liboggz/trunk/src/liboggz/metric_internal.c	2008-11-21 02:43:17 UTC (rev 3800)
+++ liboggz/trunk/src/liboggz/metric_internal.c	2008-11-21 02:43:25 UTC (rev 3801)
@@ -35,6 +35,37 @@
 #include "oggz_private.h"
 
 static ogg_int64_t
+oggz_metric_dirac (OGGZ * oggz, long serialno,
+                   ogg_int64_t granulepos, void * user_data)
+{
+  oggz_stream_t * stream;
+  ogg_int64_t iframe, pframe;
+  ogg_uint32_t pt;
+  ogg_uint16_t dist;
+  ogg_uint16_t delay;
+  ogg_int64_t dt;
+  ogg_int64_t units;
+
+  stream = oggz_get_stream (oggz, serialno);
+  if (stream == NULL) return -1;
+
+  iframe = granulepos >> stream->granuleshift;
+  pframe = granulepos - (iframe << stream->granuleshift);
+  pt = (iframe + pframe) >> 9;
+  delay = pframe >> 9;
+  dt = (int64_t)pt - delay;
+
+  units = dt * stream->granulerate_d / stream->granulerate_n;
+
+#ifdef DEBUG
+  printf ("oggz_..._granuleshift: serialno %010ld Got frame or field %lld (%lld + %lld): %lld units\n",
+	  serialno, dt, iframe, pframe, units);
+#endif
+
+  return units;
+}
+
+static ogg_int64_t
 oggz_metric_default_granuleshift (OGGZ * oggz, long serialno,
 				  ogg_int64_t granulepos, void * user_data)
 {
@@ -92,6 +123,10 @@
     return oggz_set_metric_internal (oggz, serialno,
 				     oggz_metric_default_linear,
 				     NULL, 1);
+  } else if (oggz_stream_get_content (oggz, serialno) == OGGZ_CONTENT_DIRAC) {
+    return oggz_set_metric_internal (oggz, serialno,
+				     oggz_metric_dirac,
+				     NULL, 1);
   } else {
     return oggz_set_metric_internal (oggz, serialno,
 				     oggz_metric_default_granuleshift,

Modified: liboggz/trunk/src/liboggz/oggz_auto.c
===================================================================
--- liboggz/trunk/src/liboggz/oggz_auto.c	2008-11-21 02:43:17 UTC (rev 3800)
+++ liboggz/trunk/src/liboggz/oggz_auto.c	2008-11-21 02:43:25 UTC (rev 3801)
@@ -375,11 +375,9 @@
     fps_numerator, fps_denominator, granule_shift);
 #endif
 
-  /* the granulerate is twice the frame rate (in order to handle interlace)
-   * it is also multiplied by (1<<9) since the decode time is stored in
-   * the top 32bits of granulepos, but the granule_shift is 22. */
+  /* the granulerate is twice the frame rate (in order to handle interlace) */
   oggz_set_granulerate (oggz, serialno,
-	2*(1<<9)*(ogg_int64_t)info->fps_numerator,
+	2 * (ogg_int64_t)info->fps_numerator,
 	OGGZ_AUTO_MULT * (ogg_int64_t)info->fps_denominator);
   oggz_set_granuleshift (oggz, serialno, granule_shift);
 



More information about the commits mailing list