Hi Sebastian,

Unfortunately, MPEG-2 isn't quite this simple. The approach you're 
describing will only work on a *closed* GOP. In normal (non-closed) GOPs, 
decoding the first two B frames will require access to the previous P 
frame -- from the previous GOP.

Here's an example of what you'll see right around the GOP boundary:

P-picture (coded order #-3, display order #-1)
        [This guy is predicted from the previous I-picture, not shown here.]
B-picture (coded order #-2, display order #-3)
        [Predicted from prev. I-pic AND P-picture in coded order #-3.]
B-picture (coded order #-1, display order #-2)
        [Predicted from prev. I-pic AND P-picture in coded order #-3.]
SEQUENCE header
GOP header
I-picture (coded order #0, display order #2)
        [Stands alone.]
B-picture (coded order #1, display order #0)
        [Predicted from I-picture in coded order #0 and P-picture #-3.]
B-picture (coded order #2, display order #1)
        [Predicted from I-picture in coded order #0 and P-picture #-3.]
P-picture (coded order #3, display order #5)
...

So, you see, decoding the first two B-pictures requires access to the last 
P-picture in the previous GOP. That's not the case in a closed GOP, but it 
is in a normal GOP.

So, what can you do? The easiest thing is probably to pretend that the GOP 
starts with the I-picture (the one sent first but not displayed first). 
Skip any B-pictures until you've seen one I-picture and one P-picture. 
Then decode and display everything *and continue* beyond the end of the 
GOP, decoding all the frames until you hit a P-picture, and displaying all 
the frames until you have to display an I-picture (which will be the first 
one sent in the next GOP.)

This method will require you to do a little extra decoding if you want to 
hit all the frames, but basically you're just offsetting what you consider 
to be the start of the "GOP".

Hope this helps. Happy to help if you have further questions.

Best,
Keith

On Thu, 5 Apr 2007, Sebastian Vetter wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hallo everyone,
>
> I just started working with libmpeg2 to integrate video support into the
> application I'm working at.
>
> What I would like to do is decode all frames within ONE GOP and store
> them in memory. The user should have the ability to jump to a random GOP
> resulting in decoding that one and make its frames accessible.
>
> Unfortunately, I had some problems making it work. It seems that even if
> the I-frame is decoded correctly all consecutive frames are decoded with
> loads of artifacts.
>
> Could anyone suggest a good way to achieve what I described before?
> Especially the way of using skip and seek functionality still is kind of
> a red rag to me.
>
> Any suggestion are hint will be highly appreciated.
>
> Cheers,
> Sebastian
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.3 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFGFDgx/ZEwc0fz/xMRAlqvAJ925c/kKewQhDqDNPERNyCLH4b/YACcDsEY
> clKo+Ac+TOAbhJ0H14CT5EQ=
> =OWFQ
> -----END PGP SIGNATURE-----
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Libmpeg2-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/libmpeg2-devel
>

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Libmpeg2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libmpeg2-devel

Reply via email to