Motion Compensation in MMX?

Christophe Massiot massiot at via.ecp.fr
Wed Jul 12 18:27:11 CEST 2000


Hello,

On Wed, Jul 12, 2000, Shervin Shir wrote:

> I just tried out vlc, I really like the fact that it
> drops B frames on not-so-powerful machines (like my
> Celeron 400Mhz) instead of playing in slowmotion, in
> order to keep the playing rate natural. Great job on
> that one!

Thanks, we had to do that, since vlc was initially written for network
reads. The version sam put out yesterday even improves this feature.

> I went through the code and noticed MMX support is
> used for iDCT and YUV, but not for Motion Compensation
> (MC). That could further increase the framerate, by
> about 3 to 5 fps on my machine.

Agreed.

> The Livid project is using MMX support for MC, they
> have it in their libmpeg library. I'm considering
> using that code to increase the performance of vlc.
> 
> Is this being worked on right now? Approximately how

That was planned, but no one here has actually started it, since our MMX
specialists are on vacation. It is surely the last "easy" modification that
would dramatically improve the decoding speed.

> much effort is involved if someone wants to do it?
> What are the steps?

First you need to know if libmpeg does the motion compensation the same way
we do. It is plausible, but not mandatory.
[Motion compensation is basically :
1. either a memcpy a blocks of various sizes (16x16, 16x8, 8x8 or 8x4),
2. or an add/mean of matrices
In the first part of the algorithm, you try to determine which one you will
choose, and the block size you will work on (it depends on the image type,
IPB, the image structure, frame/field, the chroma format, and some flags of
the macroblock). You shouldn't have to modify that part, it is in
video_decoder/vdec_motion.c.
The second part is the copy itself, and that's what you should look at
(video_decoder/vdec_motion_inner.c). All functions are macros with
pre-determined coefficients, so that loops get expanded at compile time.]

The C source is pretty understandable, you should be able to compare it with
libmpeg's functions and grab their MMX equivalents :). So if libmpeg has
direct equivalents to our macros, the job is a simple copy/paste. If they
don't, we will have to do some MMX assembly.

Don't hesitate to ask questions if something isn't clear, or if you have
any problem. If you're not completely familiar with the MPEG-2
specifications, we can help you too. Finally, il you want to talk about it,
we can organize an IRC meeting... :-)

To include the work you will do into vlc, you can either send us patches
against the current cvs tree, or we can give you a cvs write account, at
your convenience.

-- 
Christophe Massiot.




More information about the vlc mailing list