Page 2 of 3

Re: DGAvcDecDI crashes when playing mkv-file

Posted: Thu Jan 06, 2011 3:11 pm
by prokhozhijj
admin wrote:You need to ask DiAVC about it. I have confirmed that DGSource() itself is threadsafe. I can open a script several times in simultaneous VirtualDub instances and they play fine and independently.
As far as I know possibility to run several applications simultaneously is not equal to multi-threading. Threadsafe means that you can run several threads within one application process in operating system. It is because every process runs in its own memory area which is isolated from other processes. But threads run in shared memory area which one process owns.
admin wrote:Beyond that, it's your problem to get MT working. I know nothing about it, and more precisely, I don't care at all about it.
Yes, you told me already about it. It is a pity (for me of course).
admin wrote:And what are you after anyway? The source filter is already multithreaded and the remainder of your script is running fine under MT. What are you trying to achieve by MT'ing the souce filter?
I am trying to use all cores of my CPU. I don't know exactly how it works with DSS2() but it works smoothly on all cores and when I am not MT'ing before this filter it works on one core only. The same situation with your plug-in - it can works on one core only when I am not turning on MT before it.

May be MT spawns several threads when filter loads the video. And consequent filters runs within these threads.
admin wrote:You are free to use DSS2() if that works better for you. :)
I know, I know... But DiAVC decoder is better than it analogues. So I tried to use it.

Re: DGAvcDecDI crashes when playing mkv-file

Posted: Thu Jan 06, 2011 3:18 pm
by admin
I know, I know... But DiAVC decoder is better than it analogues. So I tried to use it.
What makes you think that DSS2() cannot use the DiAVC decoder?

One more time: DiAVC runs multithreaded distributed on all your CPUs. There is no need to try to instantiate DGSource() multiple times. If you cannot get DiAVC to use all your cores, then again, talk to DiAVC about it!

Re: DGAvcDecDI crashes when playing mkv-file

Posted: Thu Jan 06, 2011 3:25 pm
by prokhozhijj
admin wrote:
I know, I know... But DiAVC decoder is better than it analogues. So I tried to use it.
What makes you think that DSS2() cannot use the DiAVC decoder?
At present I not quite understand how to make it work with DiAVC.
admin wrote:One more time: DiAVC runs multithreaded distributed on all your CPUs. There is no need to try to instantiate DGSource() multiple times. If you cannot get DiAVC to use all your cores, then again, talk to DiAVC about it!

On forum.doom9.org I've got reply regarding this. There is no need to perform special action to force decoder for using multithreading.

And I've notice that when I run following script within VirtualDub all my cores were used. But that happened only one time and only within VirtualDub

Code: Select all

SetMTmode(5,4)
DGSource()
SetMTMode(2,4)
May be MT spawns several threads when filter is loading the video. And consequent filters run within these threads. I think this explanation is reasonable. Every filter (including DGSource) runs in its own thread which has been spawned by MT.

Re: DGAvcDecDI crashes when playing mkv-file

Posted: Thu Jan 06, 2011 3:37 pm
by admin
What version of Avisynth are you running? Also, what version of MT.dll?

If you give me enough information I will try to duplicate the issue.

Re: DGAvcDecDI crashes when playing mkv-file

Posted: Thu Jan 06, 2011 3:57 pm
by prokhozhijj
I have usual Avisynth (last 32-bit version from SourceForge) and MT-libraries from SEt version 2009.07.12. I've got Avisynth MT here http://forum.doom9.org/showthread.php?p ... ost1301410

There are my Avisynth files

http://www.filefactory.com/file/b4g40cf ... isynth.zip

MD5: 869C8001ACF985372DC9E0F7A8328745
Size: 2'200'278

Re: DGAvcDecDI crashes when playing mkv-file

Posted: Thu Jan 06, 2011 4:16 pm
by prokhozhijj
Not quite. Firstly you need to install usual Avisynth and after that you should copy dll-s from SEt distributive over dll-s from official Avisynth.

Re: DGAvcDecDI crashes when playing mkv-file

Posted: Thu Jan 06, 2011 5:03 pm
by admin
I asked which one you are *running*.

Re: DGAvcDecDI crashes when playing mkv-file

Posted: Thu Jan 06, 2011 5:57 pm
by admin
I installed Avisynth MT and MT.dll. I ran this script:

loadplugin("dgavcdecodedi.dll")
dgsource("X:\RATATOUILLE\BDMV\STREAM\00027.dgi")

and this one:

loadplugin("f:\don\Programming\C++\DiAVC\DGAVCDecodeDI\x32\Release\dgavcdecodedi.dll")
dgsource("X:\RATATOUILLE\BDMV\STREAM\00027.dgi")
SetMTMode(2,0)
tweak(sat=0.0)

They both ran fine and both gave a utilization graph like this:

Image

So, the first script shows that the decoder is using all the cores. The second shows that you can MT additional functions after the DGSource() call.

You *do not need* to MT DGSource(). DiAVC takes care of threading for the source filter. But just for fun, I added SetMTMode(5,0) before DGSource(). It still worked but
was slower than without it.

Re: DGAvcDecDI crashes when playing mkv-file

Posted: Fri Jan 07, 2011 7:46 am
by prokhozhijj
When I run my script (DiAVCDecode), It crashes all time

Code: Select all

SetMTMode(5,4)
DGSource()
SetMTMode(2,4)
MVTools processing part ...


If I am running following script (DiAVCDecode), it works but with one thread only. It is because only 1 thread actually load video source as I wrote early.

Code: Select all

DGSource()
SetMTMode(2,4)
MVTools processing part ...
If I am running this script (DSS2), it also works with one thread only.

Code: Select all

DSS2()
SetMTMode(2,4)
MVTools processing part ...
But if I am running script listed below (DSS2), it runs on all my cores with 4 threads. And all cores utilization is 100% (not just 5 or 10 like your screenshot shows). x264 FPS processing speed is also much higher (15 or 16 FPS instead of 4-5 with 1 thread only).

Code: Select all

SetMTMode(5,4)
DSS2()
SetMTMode(2,4)
MVTools processing part ...
You show me on your screenshot all cores with 1-thread-only-loading. I see it because utilization of your cores is just 5-10 percent. OS just distribute in your case load from 1 thread to all your cores. But it is NOT multi-threading.

As I think decoder will not spawns additional threads automatically. You should tell him so explicitly. And it is can be done with SetMTMode calling BEFORE using DGDecode.

Re: DGAvcDecDI crashes when playing mkv-file

Posted: Fri Jan 07, 2011 8:51 am
by admin
My CPU utilization is low because I was not transcoding but only decoding and playing the script in VirtualDub.

You are a self-confessed amateur yet here you are lecturing me on threading.

Re: DGAvcDecDI crashes when playing mkv-file

Posted: Fri Jan 07, 2011 9:34 am
by prokhozhijj
I am not lecturing you. I'm just voicing my thoughts aloud. Also I clearly see the difference of CPU utilization between DGSource and DSS2 in my script. You can easily check that I am right. Just use Microsoft Process Explorer tool. It can show how many threads actually in use within one application process and what the nature of these threads.

I am amateur in video standards. It is true. But I am not amateur in system administration - in this area I am professional. And I know difference between multi-processing, multi-threading and multi-coring. I'm sorry if my knowledge in this area hurt you.

Please show me example of video processing script for Avisynth, when CPU utilization with DGSource will be equal to 100%. Because until now I can't understand how to reach it with DGSource. However I can easily do it with DSS2. All my scripts have been given already to you.

Re: DGAvcDecDI crashes when playing mkv-file

Posted: Fri Jan 07, 2011 10:37 am
by admin
I do not get crashing when I put SetMTMode(5,0) before DGSource(). If you do, perhaps you should remove all that MV tools stuff and see if it still crashes. If so, then please use your awesome system administration skills to provide me with a Dr. Watson dump of the crash.

Re: DGAvcDecDI crashes when playing mkv-file

Posted: Fri Jan 07, 2011 1:55 pm
by prokhozhijj
There is a dump.

http://www.filefactory.com/file/b4g7c95/n/x264.zip
MD5: 5B24798EFD065F78523CA09F45308FD4
Size: 19'002'233

Avisynth script:

Code: Select all

SetMemoryMax(2000)
SetMTmode(5,0)
LoadPlugin("D:\arh\media\edit\video\_Filters\DGAVCDecDI\2025_20110106\DGAVCDecodeDI.dll")
DGSource("g:\video1.dgi")
return last
I've removed any dll-s from Avisynth plugins folder except for following:

DirectShowSource
MT
TCPDeliver

Re: DGAvcDecDI crashes when playing mkv-file

Posted: Fri Jan 07, 2011 2:29 pm
by admin
What is x264.DMP and how do I view it?

DrWatson logs are *.wlg.

Re: DGAvcDecDI crashes when playing mkv-file

Posted: Fri Jan 07, 2011 3:33 pm
by prokhozhijj
I've made this dump with Windows Task Manager. It can can be viewed with Windows debugger which comes with Windows SDK 7.
As far as I know there is no Dr.Watson debugger in Windows 7. But maybe I am wrong and you can tell me how I can run it in Windows 7.

Also I have diagnostic message from OS. I don't know if it could help... It looks like following

Event name: APPCRASH
Application name: x264.exe
Application version: 0.0.0.0
Application timestamp: 4d08623f
Module name: DGAVCDecodeDI.dll
Module version: 0.0.0.2025
Module timestamp: 4d2542b7
Exception code: c0000005
Exception offset: 000057c5
OS version: 6.1.7600.2.0.0.256.1
Language code: 1049
Additional info 1: 0a9e
Additional info 2: 0a9e372d3b4ad19135b953a78882e789
Additional info 3: 0a9e
Additional info 4: 0a9e372d3b4ad19135b953a78882e789

Re: DGAvcDecDI crashes when playing mkv-file

Posted: Fri Jan 07, 2011 3:35 pm
by admin
Sorry I do not currently have Win7.

Can't you provide a text dump?

Also, what happens with your script if you just load it into VirtualDub and play it?

Re: DGAvcDecDI crashes when playing mkv-file

Posted: Fri Jan 07, 2011 3:44 pm
by prokhozhijj
admin wrote: Can't you provide a text dump?
How it can be done? I'll do it, of course.
admin wrote: Also, what happens with your script if you just load it into VirtualDub and play it?

It crashes in very beginning. I've attached text file with crash info.

Re: DGAvcDecDI crashes when playing mkv-file

Posted: Fri Jan 07, 2011 4:27 pm
by admin
That's strange because you say it crashes at the beginning but the dump shows decoder_flush() in the call stack and that is not called until end of stream.

Can you test on a WinXP SP3 system?

I plan to install Win7 soon on my old machine. I will test there when it is done.

Re: DGAvcDecDI crashes when playing mkv-file

Posted: Sat Jan 08, 2011 9:49 am
by prokhozhijj
admin wrote:That's strange because you say it crashes at the beginning but the dump shows decoder_flush() in the call stack and that is not called until end of stream.
I have no time to notice any video when it crashes.
admin wrote: Can you test on a WinXP SP3 system?
I can try under virtual machine only. But I don't think that it will be relevant testing because of different hardware list that virtual machine has. If you count that it will be useful than I'll try without any doubt.
admin wrote: I plan to install Win7 soon on my old machine. I will test there when it is done.
Of course, I can wait until you install new OS. There is no any hurry. Just let me know about this event, please.

Re: DGAvcDecDI crashes when playing mkv-file

Posted: Sat Jan 08, 2011 10:11 am
by admin
prokhozhijj wrote:Of course, I can wait until you install new OS. There is no any hurry. Just let me know about this event, please.
I'm installing Win7 on one of my rigs right now. It may take me some time to get DiAVC installed and registered, etc.

Re: DGAvcDecDI crashes when playing mkv-file

Posted: Mon Jan 10, 2011 5:42 pm
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.

Re: DGAvcDecDI crashes when playing mkv-file

Posted: Tue Jan 11, 2011 8:41 am
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. ;)

Re: DGAvcDecDI crashes when playing mkv-file

Posted: Tue Jan 11, 2011 9:10 am
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.

Re: DGAvcDecDI crashes when playing mkv-file

Posted: Tue Jan 11, 2011 9:31 am
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.

Re: DGAvcDecDI crashes when playing mkv-file

Posted: Tue Jan 11, 2011 2:30 pm
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.