<br><br><div class="gmail_quote">On Thu, Nov 13, 2008 at 7:37 AM, Conrad Parker <span dir="ltr"><<a href="mailto:conrad@metadecks.org">conrad@metadecks.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">2008/11/13 salsaman <<a href="mailto:salsaman@gmail.com">salsaman@gmail.com</a>>:<br>
><br>
</div><div class="Ih2E3d">> Actually I have now realised it`s not that complicated, as you say, just<br>
> counting frames and not caring about keyframes at all is the way to go.<br>
><br>
> My search runs in 2 passes:<br>
><br>
> pass 1, find largest gpos <= target - this gives us keyframe for target<br>
> (note that a granulepos with k<= target, f>=target is also acceptable)<br>
><br>
> pass 2, calculate gpos from kframe, search for largest gpos < this<br>
><br>
> then starting from that page:<br>
> - ignore any packets on that page<br>
> - count frames starting from the following page<br>
<br>
</div>To clarify what you mean by "ignore" and "frames starting from the<br>
following page":<br>
</blockquote><div><br>Yes, sorry, I meant ignore any *complete* packets on that page.<br><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
If you are always feeding these pages into ogg_stream_pagein(), and<br>
always running ogg_stream_packetout() on them, then this should be<br>
correct. In this case, "ignoring any packets on that page" means that<br>
you retrieve all of the completed packets from that page with<br>
ogg_stream_packetout(), but discard them. You then load the next page<br>
with ogg_stream_pagein(). "Count frames starting from the following<br>
page" means that you start counting from the next packet that is<br>
returned by ogg_stream_packetout().<br>
<div class="Ih2E3d"></div></blockquote><div><br>Right.<br><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d"><br>
> - when we reach a page which produces (target -1), we know that is where<br>
> kframe starts, so store that page offset (this is useful for playing<br>
> backwards...)<br>
<br>
</div>probably, but not guaranteed. </blockquote><div><br>My error here, I meant to say, "when we reach a page which produces kframe -1". Then we know that kframe`s packet begins on this page (or possibly the following page, if it is not a continuation).<br>
<br><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">As you're pulling packets out of the<br>
stream anyway then you might as well just call<br>
theora_packet_iskeyframe() which is cheap and will definitely give you<br>
the correct info.<br>
<div class="Ih2E3d"></div></blockquote><div><br>Shouldn`t be needed, since we are counting frames and we know which frame is the target`s keyframe already. Could be useful as a double check though.<br><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d"><br>
> - decode the next packet : this is our target frame<br>
><br>
><br>
> Does that look correct ?<br>
<br>
</div>Yes, as long as you are pushing all those pages into ogg_stream_pagein().<br>
<font color="#888888"></font></blockquote><div><br>Right. ogg_stream_pagein() and ogg_stream_packetout().<br><br>Gabriel.<br><br></div></div>