[XviD-devel] motion estimation for B/P/I decision

Radoslaw 'sysKin' Czyz xvid-devel@xvid.org
Thu, 19 Sep 2002 20:28:22 +0930


Hey everyone

I made a simple ME-similar routine for P/B/I-frame decision. I was
able to include it in encoder.c (most of the code there is still a
mistery for me ;) ) and - I must say - the results are beautiful :D

Tests show that it's behaviour is reasonably simple - low motion
scenes get more b-frames while high-motion don't have b-frames at all.
I'm not saying that it's the best decision ever, but I definitely like
the results, at least compared to a dumb 'PBPBP....' pattern.

I-frame decision is not perfect (I'll have to include deviation there,
I think) but better then image_mad() used before.
I didn't notice any slowdown, although I didn't realy measure anything.
It's quite possible that it's because image_mad() was pure C, so it
was damn slow.
The only missing feature is that second pass doesn't re-use P/B
decisions from the first. Or maybe it does? I'm sorry, I don't know
this portion of the code.
Ffdshow seems to have problems playing such files. It produces one
jerky frame every one second, or something close to that.
Divx has it's own problem playing more than 2 B-frames in a row so if
you set max_bframes = 2 (or 1) it plays fine.
Xvid decoder plays the files without any problems.

Please tell me what do you think. If using ME for the decision is OK,
then I can extend the code to, for example, do SKIP-decision. It
will do better then current skip in 'normal' ME - and faster, too.

You can download the working (i.e. I hope) source at
http://users.bigpond.com/syskin/src3.zip . Make sure to #define
BFRAMES and BFRAMES_DEC.
The code is at the end of motion_est.c . Two thresholds are also
there, so you can change them if you want more (or less) of any frame
type.

Radek