Closed Bug 516847 Opened 13 years ago Closed 13 years ago

oggz calculates granulepos incorrectly for duplicate frames


(Core :: Audio/Video, defect)

Not set



Tracking Status
status1.9.2 --- beta1-fixed
status1.9.1 --- .6-fixed


(Reporter: cajbir, Assigned: kinetik)




(Keywords: verified1.9.1)


(1 file, 1 obsolete file)

TinyVid recently moved to using the thusnelda encoder to encode the Theora videos. This encoder is more aggressive at marking duplicate frames so decoders don't need to do so much work decoding them.

Unfortunately liboggplay based players (Firefox being one) don't seem to handle this well. The first ten seconds of the video in the URL don't play correctly. The time skips and it misses some of the frames that contain different content.

Steps to reproduce:

1) Visit URL
2) Play

What happens:

1) Watch the time in the controls skip from 1 to 3 to 10 seconds. 
2) Notice the first ten seconds of the video are all black.

What should happen:

1) Time increases in a sane manner
2) The first ten seconds show the title information (Crazy G, U900 text).

Note that this video crashes Firefox 3.5.3 so you'll need to test on trunk or Firefox 3.5.4pre.
Looks like this is to do with the granulepos/presentation time calculation in oggz and oggplay.

Starting at the first data packet, I see the following granulepos from oggz_tell_granulepos (DF == duplicate frame):

512 (DF)
768 (DF)
259 (DF)
264 (DF)
2560 (DF)
2816 (DF)
3072 (DF)
268 (DF)

oggplay_callback_theora has the following early exit:
94	  if ( (granulepos > 0) && (common->last_granulepos > granulepos)) {

So we end up skipping the decode and frame enqueue of a large number of frames.
Assignee: nobody → kinetik
Summary: Thusnelda encoded videos with duplicate frames don't play back correctly → Videos with duplicate frames don't play back correctly
Attached patch patch v0 (obsolete) — Splinter Review
oggz's auto granulepos calculation does not handle zero-byte (duplicate frame) packets correctly.  When the packet size is zero, it reads a byte of random garbage from the heap.
Summary: Videos with duplicate frames don't play back correctly → oggz calculates granulepos incorrectly for duplicate frames
Attachment #400954 - Attachment is obsolete: true
Attachment #400955 - Flags: review?(chris.double)
It's tricky to get this with mochitest, I think.  We could check the currentTime when timeupdate fires to ensure it's advancing sanely, but I suspect this sort of test will be prone to random orange due to timing dependencies.
Attachment #400955 - Flags: review?(chris.double) → review+
Closed: 13 years ago
Resolution: --- → FIXED
Attachment #400955 - Flags: approval1.9.2?
Attachment #400955 - Flags: approval1.9.1.5?
Comment on attachment 400955 [details] [diff] [review]
patch v0 with etc.

Simple patch that fixes poor playback with duplicate frames caused by reading outside the bounds of a buffer.

I wonder if we want to take this for, too, since duplicate frames are going to become significantly more common once the Theora 1.1 (Thusnelda) decoder is released.
Applied to liboggz upstream, commit 5405282442397372897cd6d148820eb518ffaf83
Duplicate of this bug: 498279
status1.9.1: --- → ?
Flags: wanted1.9.2?
Attachment #400955 - Flags: approval1.9.2? → approval1.9.2+
Flags: wanted1.9.2? → wanted1.9.2+
Comment on attachment 400955 [details] [diff] [review]
patch v0 with etc.

Approved for, a=dveditz for release-drivers
Attachment #400955 - Flags: approval1.9.1.5? → approval1.9.1.5+
Verified for using video url. Video plays back smoothly with where it jumps around for

 Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20091119 Shiretoko/3.5.6pre (.NET CLR 3.5.30729)
Keywords: verified1.9.1
You need to log in before you can comment on or make changes to this bug.