Closed Bug 470639 Opened 16 years ago Closed 15 years ago

skip video frames to ensure smooth audio

Categories

(Core :: Audio/Video, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: BijuMailList, Assigned: cajbir)

References

Details

Attachments

(1 file, 2 obsolete files)

OGG performance has improved a lot!!!

And now a days, in my old favorite computer I can play 
http://lachy.id.au/dev/markup/tests/html5/video/002.html
http://www.double.co.nz/video_test/test4.html
http://www.double.co.nz/video_test/test5.html

But audio has some problem.

This is due to all resource are consumed by VIDEO.
How do I know?
I can do a Ctrl+T (new tab)
And when the video is in the background the AUDIO is clear.

So can We SKIP some VIDEO FRAMES to save resources for the audio

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2a1pre)
Gecko/20081220 Minefield/3.2a1pre
Summary: AV:Can we SKIP some VIDEO FRAMES to save resources for the AUDIO → skip video frames to ensure smooth audio
Blocks: 476397
OS: Windows XP → All
Hardware: x86 → All
Attached patch Fix (obsolete) — Splinter Review
Matthew, I put you as a reviewer as I know you're looking at improving the framedata stuff.

While fixing bug 466699 I changed things so frames could be skipped. I've taken this patch from there and put it here since this is the bug for it.

When it's time to display a frame I go through the frame queue and look for the latest frame that should play for this time. I play the audio for the skipped frames however.

This will work even better when Matthews experimental yuv2rgb fix mentioned in bug 474748 comment 8 is done. That will mean skipped frames don't have the yuv2rgb routine called which saves a bit of processing time.

All this still will cause audio to skip on some videos (the ghostbusters HD video on tinyvid for example). This is because we skip all the frames in the framequeue but from then on we can only decode one frame at a time since even that takes too long (when combined with the yuv2rgb for that frame and the display of it). Since there is only one frame in the queue we can't skip any. 

For that to be fixed we need a way of telling liboggplay to skip video decoding up until frame 'X'. I'll discuss this with the liboggplay maintainer and see what they think. Improvements to the yuv2rgb code that are coming may also help resolve this.
Assignee: nobody → chris.double
Status: NEW → ASSIGNED
Attachment #367569 - Flags: superreview?(roc)
Attachment #367569 - Flags: review?(kinetik)
Attachment #367569 - Flags: superreview?(roc) → superreview+
Comment on attachment 367569 [details] [diff] [review]
Fix

       double time = (PR_IntervalToMilliseconds(PR_IntervalNow()-mPlayStartTime-mPauseDuration)/1000.0);
-      if (time >= frame->mTime) {
-        // Audio for the current frame is played, but video for the next frame
-        // is displayed, to account for lag from the time the audio is written
-        // to when it is played. This will go away when we move to a/v sync
-        // using the audio hardware clock.
-        PlayAudio(frame);
+
+      if (mDecodedFrames.IsFull() && time < frame->mTime) {
+        mon.Wait(PR_MillisecondsToInterval(PRInt64((frame->mTime - time)*1000)));
+        if (mState == DECODER_STATE_SHUTDOWN)
+          return;
+        time = (PR_IntervalToMilliseconds(PR_IntervalNow()-mPlayStartTime-mPauseDuration)/1000.0);
+      }

How about
double time;
for (;;) {
  time = (PR_IntervalToMilliseconds(PR_IntervalNow()-mPlayStartTime-mPauseDuration)/1000.0);
  if (mDecodedFrames.IsFull() && time < frame->mTime) {
    mon.Wait(PR_MillisecondsToInterval(PRInt64((frame->mTime - time)*1000)));
    if (mState == DECODER_STATE_SHUTDOWN)
      return;
    continue;
  }
  break;
}

so we don't have to duplicate the code to compute 'time'...

+      if(time >= frame->mTime) {
+        while(!mDecodedFrames.IsEmpty() && time >= mDecodedFrames.Peek()->mTime) {

Missing space before (
Attached patch Address review comments (obsolete) — Splinter Review
Addressed review comments from Robert, carried forward sr+
Attachment #367569 - Attachment is obsolete: true
Attachment #367673 - Flags: superreview+
Attachment #367673 - Flags: review?(kinetik)
Attachment #367569 - Flags: review?(kinetik)
Comment on attachment 367673 [details] [diff] [review]
Address review comments

Oops, included a bunch of things from a recent pull.
Attachment #367673 - Attachment is obsolete: true
Attachment #367673 - Flags: review?(kinetik)
The real patch
Attachment #367674 - Flags: superreview+
Attachment #367674 - Flags: review?(kinetik)
Attachment #367674 - Flags: review?(kinetik) → review+
Flags: wanted1.9.1?
Flags: wanted1.9.1? → wanted1.9.1+
Chris, when is this going to land?
I'm looking into some audio/video sync issues and it'll land once I'm happy this isn't affect that.
Fixed in bug 466699.
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Depends on: 466699
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: