Ronald S. Bultje wrote:
> Hi Mark,
>
> On Tue, Jan 27, 2009 at 4:25 AM, Mark Kenna
> <[email protected]> wrote:
>   
>> I'm wondering the best way to handle B-Frames within the MPEG4 stream
>> when you don't have access to the PTS or DTS value's (check previous posts).
>> Currently I am thinking of just reading the GOP which is sent as [I P B
>> B B P B B B] and reordering the frames into [I B B B P B B B P] and then
>> displaying them and carrying on...
>>
>> What I would like to know is:
>> a) is it a good idea to handle them this way? (probably not)
>>     
>
> No.
>   

I have implemented a solution that "kind of" uses the above method and 
works very well. I will just post it as a possible alternative to 
relying on libav* to correctly realign the frames - especially when you 
do not have access to AVFormatContext and/or av_read_frame(..).

I populate a List with decoded Frames as they arrive on the stream, once 
I have read three frames I do the following:

                    do
                    {

                      frameList.add(newestFrame);

                      if (frameList.Count == 3)
                      {

                        switch (frameList[0].PictType)
                        {
                            case I_FRAME:
                                {
                                    DrawPicture(frameList[0]);
                                    frameList.RemoveAt(0);

                                    break;
                                }
                            case P_FRAME:
                                {
                                    if ((frameList[1].PictType == 
P_FRAME) || (frameList[1].PictType == I_FRAME))
                                    {
                                        DrawPicture(frameList[0]);
                                        frameList.RemoveAt(0);
                                    }

                                    else
                                    {
                                        Frame tempFrame = frameList[0];
                                        frameList[0] = frameList[1];
                                        frameList[1] = tempFrame;
                                    }

                                    break;
                                }
                            case B_FRAME:
                                {
                                    DrawPicture(frameList[0]);
                                    frameList.RemoveAt(0);

                                    break;
                                }
                        }
                      }
                    } while(reading);


I understand fully that this is not the correct way to do this kind of 
decoding, but under my circumstances I don't think I have any other option.
I hope this helps someone.

Thanks for the help guys,
Mark.

_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to