<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<META content="MSHTML 6.00.6000.17063" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>>I have implemented this. The best approach to
performance depends on codec.</FONT></DIV>
<DIV><FONT face=Arial size=2>>But if we are talking about something like avc
with reasonable keyframe</FONT></DIV>
<DIV><FONT face=Arial size=2>>interval (order of 100), I came up with
this:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>>1) If I can reach desired frame by decoding
forward less than ~100 frames,</FONT></DIV>
<DIV><FONT face=Arial size=2>>I just decode all these frames (even if most of
them are already cached).</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>>2) Every decoded frame is cached within window
of 2*keyframe interval frames</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>>3) If I need to go backward, I seek to previous
keyframe and decode everything</FONT></DIV>
<DIV><FONT face=Arial size=2>>forward until desired frame (and cache all
decoded frames)</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>>4) If I can go backward and all frames until
previous key are already cached,</FONT></DIV>
<DIV><FONT face=Arial size=2>>I speculatively decode frames which are further
away.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>>This way if I move sequentially (backward or
forward), for each frame step there</FONT></DIV>
<DIV><FONT face=Arial size=2>> is exactly one frame decode. The frame
cache allows to hide the fact that </FONT></DIV>
<DIV><FONT face=Arial size=2>>frames are always decoded forward while you
request them backward.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>>Then there are other tiny details with seeking.
To perform it realistically you best deal</FONT></DIV>
<DIV><FONT face=Arial size=2>>with single stream at a time (multistream
seeking is really not designed for scrubbing).</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>For my use case I will have to have both audio and
video scrubing with the audio also playing backward or forward and speeding
up or slowing down. This is to accomodate DJs who do this in front of a live
audience. The target machines are normally i7 or better but if one has to suffer
a bit it should be the video and not the audio.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>>And you have to have proper keyframe index to
know how to seek to keyframes and measure distances.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV></BODY></HTML>