[PATCH] Re-enable ffmpeg frame based mt (decide case by case)
Download Patch: http://www.mediafire.com/download.php?m52s416kuryaj4w
2nd version: http://www.mediafire.com/?9aboa3c7fiap4d8 (Win32 binary linked here)

The current XBMC master with ffmpeg 0.10.2 will only allow slice based multi-threading. Since common h.264 files are only using 1 slice per frame, this means no multi-threading at all. Even for BD content (I tried AVCHD due to lack of BD drive in PC), which should be 4(?) slices, decoding is apparently still single threaded.

This patch reverts commit a0fc63df94 and adds a logic to allow frame based multi-threading on a case-by-case basis instead.

This fixes playback performance issues when using sw decode with more demanding files, like h.264 Hi10 Profile streams, while not breaking hw acceleration for other files (like just reverting a0fc63df94 would).

Each file is probed before playing, whether it's going to be decoded in software or using hardware acceleration. This is done by opening the file and decoding at least one frame (since ffmpeg h.264 decoder will not decide on a PIX_FMT before the first call to avcodec_decode). If hw acceleration, e.g. DXVA2, is used, mt will be limited to slice based, as the current ffmpeg would crash when attempting to use frame based multi-threading during a hw accelerated decode. For sw decoded files, both threading methods, frame and slice are enabled. Afterwards, normal playback will start using a new, proper codec context with the correct thread type and count. This pre-check adds a slight overhead before playback starts, which in my case was ranging from 50ms (SD content) to 100-300ms (HD content).

Note: This is largely a C&P job from CDVDFileInfo::ExtractThumb(). That's also the reason why I left the code in DVDFileInfo.cpp. The necessary includes are already there, so I didn't have to clutter up other files with #includes.

This needs regression testing, cleanup and it needs to be moved to a better place than DVDFileInfo.cpp. For now it works, so I decided to post it for a first review.

Update: First version had the following regressions - 1. XBMC detects AVCHD ISOs as "DVD", so I can't assume that DVD is always sw-decoded. 2. Probe would error out on BluRay content and fall back to a single thread, regardless of codec. Now, always falls back to slice threading for DVD/AVCHD and BD - not nice, but better than crashing...
Shine, could please add this patch as a github pull request? Thx!
This patch isn't in a state that would be worthy for a pull request at this time. Basically, I posted it here for discussion whether this is even the right approach or not.

It's made with the idea in mind that it should be easily removable once ffmpeg doesn't crash anymore with mt and hw accel enabled at the same time (ie. the next ffmpeg update, hopefully?)

If you give me a few days, I could try and change it to blend in a little better. I might have some time the coming weekend.
Okee. Thanks.
Sounds like a very interesting patch. Did it progress anywhere beyond this forum thread?

Logout Mark Read Team Forum Stats Members Help
[PATCH] Re-enable ffmpeg frame based mt (decide case by case)0
This forum uses Lukasz Tkacz MyBB addons.