<br><br><div class="gmail_quote">On Thu, Nov 13, 2008 at 8:53 AM, salsaman <span dir="ltr"><<a href="mailto:salsaman@gmail.com">salsaman@gmail.com</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;">
<br><br><div class="gmail_quote"><div class="Ih2E3d">On Thu, Nov 13, 2008 at 7:37 AM, Conrad Parker <span dir="ltr"><<a href="mailto:conrad@metadecks.org" target="_blank">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>2008/11/13 salsaman <<a href="mailto:salsaman@gmail.com" target="_blank">salsaman@gmail.com</a>>:<br>
><br>
</div><div>> 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><div><br>Yes, sorry, I meant ignore any *complete* packets on that page.<br><br> </div><div class="Ih2E3d"><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></div></blockquote></div><div><br>Right.<br><br> </div><div class="Ih2E3d"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><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><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><div class="Ih2E3d"><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></div></blockquote></div><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><div class="Ih2E3d">
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><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><div><br>Right. ogg_stream_pagein() and ogg_stream_packetout().<br><br>Gabriel.<br><br></div></div>
</blockquote></div><br><br><br><br>I am finding something very strange in my test ogg files.<br><br>For example: I have a shift of 64, and I get a granulepos of 5130.<br>
<br>5130 == 80*64 + 10<br><br>which suggests that frame 80 is a keyframe.<br><br>However, if I start decoding from the beginning, the 81st frame is a keyframe.<br><br>This suggests that the first frame should be 0. But if I try to search for frame 0, it fails.<br>
<br>Everything is fine from frame 64 up, but the start is messed up.<br><br>I have found 2 partial workarounds for this:<br><br>a) add 1 to all frames - this works fine for continuous playback: 1, 2, 3, 4, etc. but frames > 64 are 1 out when seeking<br>
<br>b) add 1 to all frames < 64 - this works fine for seeking, but messes up continuous playback when frame 64 is reached<br><br>Any suggestions ?<br><br><br><br>Gabriel.<br><a href="http://lives.sourceforge.net/" target="_blank">http://lives.sourceforge.net</a><br>
<br><br><br>