[MPlayer-dev-eng] Cache optimized rotation.

David Bateman adb014 at gmail.com
Thu Apr 5 01:55:12 CEST 2007

As smart phones and pdas typically have the reverse aspect ratio of most
displays and that most videos have a more normal width greater than
height aspect ratio, it is important to have a fast rotation routine for
smart phones and pdas. I attach here two different versions of a patch
to improve the speed of the rotation code. The first uses a statically
allocated block of memory to copy a tile of the image in row-wise and
then copies it out to the display column wise. As the tile is always in
the cache and the src and dst are incremented upto the the size of the
tile significant performance improvements can be had.

The second version of the patch is based on comments by Michael
Niedermayer to the previous zaurus thread in February, though completed,
cleaned up and tested. It does without the additional memory block, but
has to step across the destination in steps of dststride.

I'm limited in the benchmarking I can do on these two patches due to my
test platform is a Motorola A1200 phone and I can't change the depth of
the screen without hanging the phone (the FBIOPUT ioctl to the pxafb
driver crashes). So, only a single test case of 3bpp is considered. For
the benchmark I ran

 time ./mplayer -quiet -vf rotate=1,crop=240:320  test.avi

on the motorola phone with a xscale PXA270 chipset running at 300MHz. I
then combined the user and sys time and then divided it by the wall
time. Note that the test video was deliberately chosen to be one that
required more resources to play than mplayer could with no patch. The
results were

No patch: 99.20%  (framedrops)
Original Patch: 87.62%
Patch based on Michael's idea: 88.77%

So the tile based patch is slightly faster. I ran these tests a number
of times and came up with consistent results. However, there isn't much
difference in the speed, so the choice of which patch might come down
more to code maintainability, than anything else. The patches are

Original Patch: 06_CacheOptimizedBlockedRotate.diff
Patch based on suggest by Michael:

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 06_CacheOptimizedBlockedRotate.diff
Type: text/x-patch
Size: 4436 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20070405/9ace99b6/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 06_Alternate2CacheOptimizedBlockedRotate.diff
Type: text/x-patch
Size: 2312 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20070405/9ace99b6/attachment-0001.bin>

More information about the MPlayer-dev-eng mailing list