[RESOLVED] DGAvcDecDI crashes when playing mkv-file

Support forum for DGAVCDecDI
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: DGAvcDecDI crashes when playing mkv-file

Post by admin »

OK, I have some results for you. I have Win7 running on an E8500 dual core. Comments follow the results.

Test 1: No MT
----------------

loadplugin("D:\DGAVCDecDI\DGAVCDecodeDI.dll")
DGSource("00271.dgi")
Tweak(sat=0.0)
assumefps(5000) # to make VirtualDub play at maximum possible rate

Playing in VirtualDub gives 23.4 fps @ 100% CPU.

Test 2: SetMTMode(2,0) at top of script
-----------------------------------------------

SetMTMode(2,0)
loadplugin("D:\DGAVCDecDI\DGAVCDecodeDI.dll")
DGSource("00271.dgi")
Tweak(sat=0.0)
assumefps(5000) # to make VirtualDub play at maximum possible rate

Playing in VirtualDub gives 17.9 fps @ 100% CPU.

Test 3: SetMTMode(5,0) and SetMTMode(2,0)
-----------------------------------------------------

SetMTMode(5,0)
loadplugin("D:\DGAVCDecDI\DGAVCDecodeDI.dll")
DGSource("00271.dgi")
SetMTMode(2,0)
Tweak(sat=0.0)
assumefps(5000)

Playing in VirtualDub gives 3.2 fps @ 100% CPU. The MT documentation warns that SetMTMode(5,0) is very slow. Here you can see it.

Comments
------------

When the filters accessing the source filter are multithreaded, then the filter will receive nonlinear (not monotonically increasing) frame number requests. This will lead to poor performance due to random access being invoked. You can see it in the results. If you must have multithreading, then you can *try* the Test 2 setup and hope that the multithreading in the remainder of the script makes up for the loss due to random accesses in the source filter.

Note that I also ran Tests 1 and 3 on my fast WinXP machine at the stream's display rate of 23.976. With no threading (Test 1) I got about 13% CPU utilization. With threading as in Test 3, the CPU utilization went to 100% but the frame rate was radically degraded, just as shown above for the Win7 machine. The MT support page clearly warns about not optimizing for CPU utilization but rather for rendering rate. Now it's clear to me that that warning is spot on.

Finally, at no time did I ever experience any crashes during this testing. If you are seeing crashes then in the absence of any other people reporting it I have to assume you have some system-specific problem.

I don't know what more I can say or do for you on this.
DAE avatar
Didée
Posts: 22
Joined: Wed Oct 27, 2010 2:19 pm

Re: DGAvcDecDI crashes when playing mkv-file

Post by Didée »

admin wrote:The MT documentation warns that SetMTMode(5,0) is very slow. Here you can see it..
That's not what the documentation is talking about. Mode 5 is "slow" because it *effectively* uses only 1 Thread. The slowdown you're experiencing here has nothing to do with that.

First off, I'm wondering what you're trying to achieve here. Tweak(sat=0.0) is a zero-cost filter (or close to). Isolated from the rest, this filter runs (single-threaded!) at ~1500fps on SD-PAL video for me. Hence, your script is 99% limited by the decoding speed of the source filter, there is zero speed gain to expect from MT.
My little practice test:
1Thread-script without Tweak: 2:58 m:s
1Thread-script with Tweak: 3:00 m:s
8Thread-script with Tweak: 3:02 m:s (thats mode=5 before sourcecall, mode=2 before tweak)

However, the slowdown that you are getting shouldn't happen, of course ... expected would be "same" speed as single-threaded. It could be related to thread syncronization a/o out-of-order frame requests to the source filter. However, I really know too little about the inner workings of Avisynth and its multithreading-models to draw any definitive conclusions...

You might try the readahead/caching-trick, and see if it changes anything:

--------------------------------------------------------------
SetMTMode(5,0)
loadplugin("D:\DGAVCDecDI\DGAVCDecodeDI.dll")
DGSource("00271.dgi")
ChangeFPS(last,last,true) # forces Avisynth to do a small readahead & cache the pre-read frames. A buffer of ~20 frames, or so.
SetMTMode(2,0)
Tweak(sat=0.0)
assumefps(5000)
--------------------------------------------------------------

In any case, (it seems to me that) SetMTMode is not awfully effective with only two threads (Dualcore CPU). From my experience, good performance is achieved with 4 to 8 threads ... my poke in the blue: with only two threads, the overhead of thread synchronization is eating up a good part of the theoretical gain. On a Dualcore, you're probably better off with the [spatial] MT() instead of the [temporal] SetMTMode().

Note: I can only speak for DGDecode/mpeg2source and DGDecNV/DGSource. DGDecDI is not of interest for me - scope is too small. I use DGDecode and DGDecNV whenever they're applicable. In the remaining cases, decoding is done by ... a filter you don't particularly like, Don. ;)
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: DGAvcDecDI crashes when playing mkv-file

Post by admin »

Didée wrote:In the remaining cases, decoding is done by ... a filter you don't particularly like, Don. ;)
What filter is that and why do you think I don't like it? If you are talking about CoreAVC I am a registered user. I don't understand why this comment of yours was necessary.
DAE avatar
Didée
Posts: 22
Joined: Wed Oct 27, 2010 2:19 pm

Re: DGAvcDecDI crashes when playing mkv-file

Post by Didée »

Oops, sorry ... there was no pun intended! (And the unnamed decoder is an eff-eff-something...)

I just wanted to make clear that in case of a problem specific to DGDecDI, I'm not able to report anything.
DAE avatar
prokhozhijj
Posts: 30
Joined: Sat Jan 01, 2011 11:16 am

Re: DGAvcDecDI crashes when playing mkv-file

Post by prokhozhijj »

Thanks a lot, Donald, for your work and testing.

1.I've noticed that on Test2 your plugin runs properly. But on Test3 always crashes.

===============
Test2
===============
------------------------------------
DGAVCDecodeDI+DiAVC+MT
------------------------------------
with SetMTMode(2,0) - 20-30 fps with 60% CPU load
with SetMTMode(5,0) - 110-140 fps with 25-30% CPU load.

------------------------------------
DSS2+ffmpeg_mt+MT
------------------------------------
Test2 with SetMTMode(2,0) - 100-110 fps with 100% CPU load
Test2 with SetMTMode(5,0) - 110-140 fps with 25-30% CPU load.

===============
Test3
===============
------------------------------------
DGAVCDecodeDI+DiAVC+MT
------------------------------------
Always crashes

------------------------------------
DSS2+ffmpeg_mt+MT
------------------------------------
110-140 fps with 25-30% CPU load


2. For two my files (they are large - about 10-11 Gb in lossless h.264 format) DGAVCIndexDI and Avisynth+DSS2() shows different frame count. Could you advice, please, is it can be checked by third-party tools? Because for now I don't know which tool is correct.

For the first file the difference between frames quantity is 112461 (Avisynth) - 112440 (DGAVCIndexDI) = 21.
For the second file 103013(Avisynth) - 102960 (DGAVCIndexDI) = 53.
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: DGAvcDecDI crashes when playing mkv-file

Post by admin »

I don't know anything about DSS2() and therefore will not speculate about differences in the reported frame counts.
Post Reply