[theora-dev] further debugging of my ogg/theora decoder

salsaman salsaman at gmail.com
Thu Nov 13 03:53:27 PST 2008


On Thu, Nov 13, 2008 at 7:37 AM, Conrad Parker <conrad at metadecks.org> wrote:

> 2008/11/13 salsaman <salsaman at gmail.com>:
> >
> > Actually I have now realised it`s not that complicated, as you say, just
> > counting frames and not caring about keyframes at all is the way to go.
> >
> > My search runs in 2 passes:
> >
> > pass 1, find largest gpos <= target - this gives us keyframe for target
> > (note that a granulepos with k<= target, f>=target is also acceptable)
> >
> > pass 2, calculate gpos from kframe, search for largest gpos < this
> >
> > then starting from that page:
> >  - ignore any packets on that page
> >  - count frames starting from the following page
>
> To clarify what you mean by "ignore" and "frames starting from the
> following page":
>

Yes, sorry, I meant ignore any *complete* packets on that page.



>
> If you are always feeding these pages into ogg_stream_pagein(), and
> always running ogg_stream_packetout() on them, then this should be
> correct. In this case, "ignoring any packets on that page" means that
> you retrieve all of the completed packets from that page with
> ogg_stream_packetout(), but discard them. You then load the next page
> with ogg_stream_pagein(). "Count frames starting from the following
> page" means that you start counting from the next packet that is
> returned by ogg_stream_packetout().
>

Right.



>
> >  - when we reach a page which produces (target -1), we know that is where
> > kframe starts, so store that page offset (this is useful for playing
> > backwards...)
>
> probably, but not guaranteed.


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).




> As you're pulling packets out of the
> stream anyway then you might as well just call
> theora_packet_iskeyframe() which is cheap and will definitely give you
> the correct info.
>

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.



>
> > - decode the next packet : this is our target frame
> >
> >
> > Does that look correct ?
>
> Yes, as long as you are pushing all those pages into ogg_stream_pagein().
>

Right. ogg_stream_pagein() and ogg_stream_packetout().

Gabriel.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/theora-dev/attachments/20081113/62604fa6/attachment-0001.htm 


More information about the theora-dev mailing list