Argh, I screwed this up. (So much for "simple rules.") It should have been:
(1) "Reference frames" means I-frames or P-frames. (2) If you hit a B-frame, decode it (using BOTH previously-encountered "reference frames") and discard it. (3) If you hit an I-frame, decode it (it stands alone) and display the *previously encountered* "reference frame" if one exists. (4) If you hit a P-frame, decode it (using the previous "reference frame") and display the previously encountered "reference frame" if one exists. -Keith On Fri, 6 Apr 2007, Keith Winstein wrote: > Hi Dinkar, > > In the example below, the frames would be displayed according to the > "display order," i.e., #-3 (B), #-2 (B), #-1 (P), #0 (B), #1 (B), #2 (I). > > If you get confused, just remember that MPEG-2 video follows these simple > rules: > > (1) Keep two slots -- the "last I-frame" slot and the "last P-frame" slot. > > (2) If you hit an I-frame, decode it, put it into the "last I-frame" slot, > and display the contents of the "last P-frame" slot > > (3) If you hit a P-frame, decode it (using the "last I-frame" slot as a > reference), put it into the "last P-frame" slot, and display the > contents of the "last I-frame" slot. > > (4) If you hit a B-frame, decode it (using both slots as references) and > display it immediately. > > That's it. > > Best, > Keith > > On Fri, 6 Apr 2007, Dinkar Bhat wrote: > >> Hi Keith, >> >> Thanks for this example. In this example, would the first picture that is >> displayed >> be the P-picture in the second GOP followed by the I picture? I am getting >> a little >> confused about the display order of the all the frames. >> >> Thanks >> Dinkar >> >> Keith Winstein <[EMAIL PROTECTED]> wrote: >> 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 >>> Libmpeg2-devel@lists.sourceforge.net >>> 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 >> Libmpeg2-devel@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/libmpeg2-devel >> >> >> >> --------------------------------- >> Finding fabulous fares is fun. >> Let Yahoo! FareChase search your favorite travel sites to find flight and >> hotel bargains. > > ------------------------------------------------------------------------- > 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 > Libmpeg2-devel@lists.sourceforge.net > 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 Libmpeg2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libmpeg2-devel