Xvid-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Original]

Re: Re[4]: [XviD-devel] scene change detecting in Bframes mode


To: xvid-devel@xxxxxxxx
Subject: Re: Re[4]: [XviD-devel] scene change detecting in Bframes mode
From: "peter ross" <suxen_drol@xxxxxxxxxxx>
Date: Wed, 21 Aug 2002 01:09:36 +1000

> syskin, i think you've got I-frames and P-frames mixed up.

gruel is right here

my appologies.


> For each frame we assume its going to be a P-frame ad perform motion
> estimation. After the m.e. we then decide on the frame type
> - I-frame: code the i-frame

No I don't like it. I frame should be on a scene change, not a few
frames after. If you do it a few frames after, then B frames before
this I frame will use only backward prediction, as they belong to the
same scene as the I frame. That's gonna be very inefficient.

the IPB-encoder is rather complex, but i assure you it handles all the issues of reording, backward prediction and such correctly. when i designed it, i drew up a rough flow-chart sketch of the encoder. i'll scan it in and post for you someday.

xvid currently handles I-frames followed B-frames correctly. eg.
       (display order) PBBPBBI

and if you use DX50IVOP, xvid will ensure the frame prior to an I-frame
is encoded as a P-frame. eg.
       (display order) PBBPBPI

xvid also handles the last frame correctly, to prevent this error
       (display order) PBBPBB<end of stream>
note: this is not functional with vfw/vdub at the moment.

Now how? To code a b-frame you need a future P frame. To have a future
P frame, you need previous P frame. Once you have both P frames, this
frame can ONLY be B, because if you would decide to make it P/B then
you would have to trash the future P frame (not valid anymore).

internally xvid has two queues, one for frames which have not been
processed yet, and another for bframes. when you give xvid a frame to be encoded, the encoder essentially has a three-way if statement:


1. if this is the very first frame, OR a detected keyframe,
  then flag this frame as an I-frame and add it to the queue.
  now, if there are any bframes waiting, code them accordingly.
  otherwise, pop a frame from the queue and code it.
  return;

2. otherwise, if we have reached our max_bframes count, then flag
  this frame as a P-frame and add it to the queue.
  (from here onwwards, we perform the same operation as choice 1).
  if there are any bframes waiting, code them accordingly.
  otherwise, pop a frame from the queue and code it.
  return;

3. otherwise, flag this frame as a bframe and add it to the bframe
  queue.
  return;

in summary, XVID encodes frames in bitstream, not display order.

goodnight.
-- pete

_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx




[Prev in Thread] Current Thread [Next in Thread]