Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 231805 - media-libs/xvid-1.1.3-r3 encoding is slow in media-video/avidemux-2.4.1 and 2.4.2 in comparsion with Mandriva 2008.1 on the same machine
Summary: media-libs/xvid-1.1.3-r3 encoding is slow in media-video/avidemux-2.4.1 and 2...
Status: RESOLVED TEST-REQUEST
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Library (show other bugs)
Hardware: AMD64 Linux
: High normal (vote)
Assignee: Gentoo Media-video project
URL:
Whiteboard:
Keywords:
Depends on: 271786
Blocks:
  Show dependency tree
 
Reported: 2008-07-14 19:54 UTC by David Kredba
Modified: 2009-05-29 17:30 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Needed informations. (info.txt,18.54 KB, text/plain)
2008-07-14 19:55 UTC, David Kredba
Details
Lspci -v and kernel .config (info1.txt,61.65 KB, text/plain)
2008-07-15 13:39 UTC, David Kredba
Details
ebuild that fixes this problem (xvid-1.1.3-r4.ebuild,1.95 KB, text/plain)
2008-12-11 16:13 UTC, Anders Kaare Straadt
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Kredba 2008-07-14 19:54:30 UTC
The first pass encoding framerate using media-libs/xvid-1.1.3-r3 on ~amd64 is 2-3 times slower than using the same source video and settings on updated Mandriva 2008.1 x86_64 on the same machine.

Reproducible: Always

Steps to Reproduce:
1. On ~amd64 emerge media-libs/xvid and media-video/avidemux
2. Start encoding with xvid in two pass mode for a target video size with Quarter Pixel, ultra high motion search precision, ultra wide motion search and MPEG matrix. The computed target bitrate is about 1940kbps here.
3. The first pass framerate is 2-3 times slower than with updated Mandriva 2008.1 x86_64 on the same machine, got about 30/s when expected above 80/s.
Only one xvid thread is running. Both for autodetection and manual setting for 2,3,4 threads in avidemux.

Actual Results:  
The first pass framerate is 2-3 times slower than with updated Mandriva 2008.1 x86_64 on the same machine.

Expected Results:  
Above 80 frames per second for the first pass.

I tried to use libxvid.so.4.1 from Mandriva in Gentoo and got the same results.
It is runnung in KDE session.
The media-libs/libmpeg2 is 0.4.1.
I probably does not see something, shoud I compile media-libs/libmpeg2 and 
media-libs/xvid with -msse2? Or -march="something"?

Please see attached info.txt.

Thank you.
Comment 1 David Kredba 2008-07-14 19:55:07 UTC
Created attachment 160383 [details]
Needed informations.
Comment 2 David Kredba 2008-07-15 11:56:17 UTC
The 2nd pass is doing about 2.57 per sec.
Comment 3 David Kredba 2008-07-15 13:39:26 UTC
Created attachment 160439 [details]
Lspci -v and kernel .config
Comment 4 Mads Martin Joergensen 2008-12-11 12:12:33 UTC
Does not applying the xvid-1.1.0-3dnow-2.patch patch when building fix the performance issue for you?
Comment 5 Anders Kaare Straadt 2008-12-11 16:09:31 UTC
We are experiencing the same problem and have tracked it down to an old Gentoo specific patch (portage/media-libs/xvid/files/xvid-1.1.0-3dnow-2.patch) that attempts to fix a problem with lack of 3dnow support on EM64T (see bug #129022). It is still applied today even though the problem was fixed years ago by the xvid team:

$ cvs log src/xvid.c
(snip)
revision 1.67
date: 2006/01/09 00:39:43;  author: Isibaar;  state: Exp;  lines: +2 -2
- fix for EMT64 platform
(snip)

$ cvs diff -r1.66 -r1.67 src/xvid.c
(snip)
-               emms = emms_3dn;
+               emms = emms_mmx;
(snip)

As far as I can tell, the Gentoo patch makes xvidcore fall back to a pure C implementation if 3dnow is not detected. The problem is worsened further by the fact that xvid's 3dnow detection fails on at least two contemporary AMD CPUs:

(from /proc/cpuinfo)
model name      : AMD Athlon(tm) 64 X2 Dual Core Processor 5000+
model name      : Dual Core AMD Opteron(tm) Processor 270

This was determined by writing a small program that calls check_cpu_features() in src/utils/x86_64_asm/cpuid.asm; check_cpu_features() & XVID_CPU_3DNOW == 0 on the above CPUs which clearly have 3dnow support.

Removing the 3dnow patch from the ebuild causes a ~2x performance boost (and of course no segfaults) on the following platforms:

model name      : AMD Athlon(tm) 64 X2 Dual Core Processor 5000+
model name      : Dual Core AMD Opteron(tm) Processor 270
model name      : Intel(R) Core(TM)2 CPU          6300  @ 1.86GHz
Comment 6 Anders Kaare Straadt 2008-12-11 16:13:11 UTC
Created attachment 174974 [details]
ebuild that fixes this problem

Removes "epatch "${FILESDIR}"/${PN}-1.1.0-3dnow-2.patch", otherwise identical in behavior compared to xvid-1.1.3-r3.ebuild
Comment 7 David Kredba 2008-12-11 20:51:08 UTC
Hello, thank you, I`ll try it using emerge -e system and let you know.

Best regards, David Kredba.
Comment 8 Samuli Suominen (RETIRED) gentoo-dev 2008-12-13 05:41:29 UTC
We are working on getting xvid-1.2.1 into ~arch, it's currently in package.mask for testing.
Comment 9 David Kredba 2008-12-16 17:06:08 UTC
Hello, yes, it is working for me now with unmasked xvid-1.2.1.
It is doing about 69 frames per second using two threads.

Later I try it on 4 proc machine, but it will be perfect.

Great, thank you very much.

Best regards, David Kredba.
Comment 10 Mads Martin Joergensen 2008-12-16 18:26:47 UTC
When can we get this package updated in the portage tree then?
Comment 11 Mads Martin Joergensen 2009-01-21 10:07:27 UTC
So how long should we wait for this to be accepted into the port? Is anybody even reading these from gentoo?
Comment 12 Steve Dibb (RETIRED) gentoo-dev 2009-02-07 03:01:38 UTC
(In reply to comment #10)
> When can we get this package updated in the portage tree then?
> 

As soon as someone tests it againsts every reverse dependency in the tree.  It affects a lot of stuff.
Comment 13 David Kredba 2009-02-10 21:56:22 UTC
After I built the xvid-1.2.1 for testing I called revdep-rebuild and it did not find any breakage to the system. So please what "every reverse dependency in the tree" do you mean? Am i missing something? Thank you.
Comment 14 Alexis Ballier gentoo-dev 2009-02-10 22:20:39 UTC
Its been masked long enough and i've been using it since the beginning; everything seems fine wrt rev deps so i've unmasked it. We probably can close this bug or wait for 1.2 to hit stable
Comment 15 Samuli Suominen (RETIRED) gentoo-dev 2009-05-29 17:30:11 UTC
Please test =media-libs/xvid-1.2.2-r1, it's going stable for security issues.