[gstreamer-bugs] [Bug 305231] [theoraenc] messes up granulepos

bugzilla-daemon at bugzilla.gnome.org bugzilla-daemon at bugzilla.gnome.org
Tue May 24 12:21:11 PDT 2005


Please DO NOT reply to this by email. All additional comments should be made in
the comments box of this bug report.

 http://bugzilla.gnome.org/show_bug.cgi?id=305231
 GStreamer | gst-plugins | Ver: 0.8.8





------- Additional Comments From Tim-Philipp Müller  2005-05-24 19:21 -------
The previous patch just removes something that's obviously wrong and should keep
things working for the normal case. However, it doesn't really address the
problem of a video starting at a nonzero offset properly.

The proper solution would rather be something along these lines:

/* FIXME: copy from libtheora, theora should somehow make this available for
seeking */
static int
_theora_ilog (unsigned int v)
{
  int ret = 0;
  while (v) {
    ret++;
    v >>= 1;
  }
  return (ret);
}

static GstBuffer *
theora_buffer_from_packet (....)
{
  ......

  /* if duration is 0, it's a header packet and should
   *  have granulepos 0 (so no delta regardless of delay) */
  if (duration == 0) {
    granulepos_delta = 0;
    timestamp_delta = 0;
  } else {
    /* granulepos: lowest ilog bits are number of frames since last
     * keyframe. Bits above that represents the framenumber of the
     * last keyframe. */
    guint ilog = _theora_ilog (enc->info.keyframe_frequency_force - 1);
    granulepos_delta = enc->initial_delay * enc->fps / GST_SECOND;
    granulepos_delta <<= ilog;
    /* The timestamp passed to us comes from theora_granule_time()
     *  based on the granulepos theora created, which counts from 0,
     *  so we have to adjust the timestamp */
    timestamp_delta = enc->initial_delay;
  }

  buf = gst_pad_alloc_buffer (enc->srcpad,
      GST_BUFFER_OFFSET_NONE, packet->bytes);
  memcpy (GST_BUFFER_DATA (buf), packet->packet, packet->bytes);
  GST_BUFFER_OFFSET (buf) = enc->bytes_out;
  GST_BUFFER_OFFSET_END (buf) = packet->granulepos + granulepos_delta;
  GST_BUFFER_TIMESTAMP (buf) = timestamp + timestamp_delta;
  GST_BUFFER_DURATION (buf) = duration;

  ....
}

However, in the last 24 hours I've tried this and several other combinations of
fixes, and there's just nothing that works across the board. I begin to suspect
that playback in totem/playbin is slightly buggered as well though, as some
clips I've encoded end up having a different a/v (un-)sync after a seek than before.

No idea what's going on here. Can't test with mplayer as it crashes on
ogg/theora files, and don't entirely trust totem/playbin, so someone else needs
should probably have a  look at this.

Cheers
 -Tim


------- You are receiving this mail because: -------
You are the assignee for the bug.
You are the QA contact for the bug.




More information about the Gstreamer-bugs mailing list