[ogg-dev] [PATCH] liboggz: Update Dirac granulepos definition
David Flynn
davidf+nntp at woaf.net
Tue Nov 4 01:46:04 PST 2008
The definition of granule position for an OggDirac elementary stream
isn't the same as theora.
Index: tools/oggz_tools.c
===================================================================
--- tools/oggz_tools.c (revision 3759)
+++ tools/oggz_tools.c (working copy)
@@ -454,7 +454,15 @@
iframe = granulepos >> granuleshift;
pframe = granulepos - (iframe << granuleshift);
- ret = fprintf (stream, "%" PRId64 "|%" PRId64, iframe, pframe);
+ if (oggz_stream_get_content (oggz, serialno) != OGGZ_CONTENT_DIRAC) {
+ ret = fprintf (stream, "%" PRId64 "|%" PRId64, iframe, pframe);
+ } else {
+ uint32_t pt = (iframe + pframe) >> 9;
+ uint16_t dist = ((iframe & 0xff) << 8) | (pframe & 0xff);
+ uint16_t delay = pframe >> 9;
+ int64_t dt = pt - delay;
+ ret = fprintf (stream, "(pt:%u,dt:%"PRId64",dist:%hu,delay:%hu)", pt, dt, dist, delay);
+ }
}
return ret;
Index: liboggz/oggz_auto.c
===================================================================
--- liboggz/oggz_auto.c (revision 3759)
+++ liboggz/oggz_auto.c (working copy)
@@ -358,31 +358,26 @@
static int
auto_dirac (OGGZ * oggz, long serialno, unsigned char * data, long length, void * user_data)
{
- char keyframe_granule_shift = 32;
- int keyframe_shift;
+ int granule_shift = 22; /* not a typo */
dirac_info *info;
info = malloc(sizeof(dirac_info));
dirac_parse_info(info, data, length);
- /*
- FIXME: where is this in Ogg Dirac?
- keyframe_granule_shift = (char) ((header[40] & 0x03) << 3);
- keyframe_granule_shift |= (header[41] & 0xe0) >> 5;
- */
- keyframe_shift = keyframe_granule_shift;
-
#ifdef DEBUG
- printf ("Got dirac fps %d/%d, keyframe_shift %d\n",
- fps_numerator, fps_denominator, keyframe_shift);
+ printf ("Got dirac fps %d/%d, granule_shift %d\n",
+ info->fps_numerator, info->fps_denominator, granule_shift);
#endif
- oggz_set_granulerate (oggz, serialno, (ogg_int64_t)info->fps_numerator,
+ /* 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. */
+ oggz_set_granulerate (oggz, serialno, 2*(1<<9)*(ogg_int64_t)info->fps_numerator,
OGGZ_AUTO_MULT * (ogg_int64_t)info->fps_denominator);
- oggz_set_granuleshift (oggz, serialno, keyframe_shift);
+ oggz_set_granuleshift (oggz, serialno, granule_shift);
- oggz_stream_set_numheaders (oggz, serialno, 3);
+ oggz_stream_set_numheaders (oggz, serialno, 0);
free(info);
return 1;
More information about the ogg-dev
mailing list