Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 20th June 2019, 21:43   #41  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by StainlessS View Post
Ie, does SSE, SSE2, SSE3 == ISSE
I don't think so. I'll look into it.

Edit: From this page:

Quote:
SSE was originally called Katmai New Instructions (KNI), Katmai being the code name for the first Pentium III core revision. During the Katmai project Intel sought to distinguish it from their earlier product line, particularly their flagship Pentium II. It was later renamed Internet Streaming SIMD Extensions (ISSE[1]), then SSE. AMD eventually added support for SSE instructions, starting with its Athlon XP and Duron (Morgan core) processors.
So, ISSE = SSE (I guess?).
__________________
Groucho's Avisynth Stuff

Last edited by Groucho2004; 20th June 2019 at 21:49.
Groucho2004 is offline   Reply With Quote
Old 20th June 2019, 22:03   #42  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by StainlessS View Post
Code:
Function ShowAvsInfo() {
    myName="InitExternalPlugins:ShowAvsInfo: "
    S=RT_String("\nVersionString      = '%s'\n",                VersionString)
    S=RT_String("%sOSVersionString    = '%s'\n",                S,SI_OSVersionString)
    S=RT_String("%sOSVersionNumber    = %f\n",                  S,SI_OSVersionNumber)
    S=RT_String("%sCPUName            = '%s'\n",                S,SI_CPUName)
    S=RT_String("%sCores              = %02d:%02d (Phy:Log)\n", S,SI_PhysicalCores,SI_LogicalCores)
    S=RT_String("%sCPU Extensions     = '%s'\n",                S,SI_CPUExtensions)
    S=RT_String("%sTotal Memory       = %dMB\n",                S,SI_TotalSystemMemory)
    S=RT_String("%sAvail Memory       = %dMB'\n",               S,SI_AvailableSystemMemory)
    S=RT_String("%sSys Bitness        = %d\n",                  S,SI_ProcessBitness)
    S=RT_String("%sScreen Res         = %dx%d\n",               S,SI_ScreenResX,SI_ScreenResY)
    S=RT_String("%sScreen BitPerPixel = %d\n",                  S,SI_ScreenBitsPerPixel)
    RT_DebugF("%s",S,name=myName)
}
Just curious - Why do you call the function "ShowAvsInfo()" even though it doesn't gather anything related to Avisynth?
__________________
Groucho's Avisynth Stuff
Groucho2004 is offline   Reply With Quote
Old 20th June 2019, 22:08   #43  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Thanks G2K4,

I take it that all three SSE, SSE2 and SSE3 are integer SSE, and so maybe in AVS ISSE is just shorthand for the lot.

Just thought that additional nicety might be the current or Parent process name, in RT_stats we have RT_GetProcessName(), might be handy in your plug too.
I have used to make small changes when using eg MPC-HC (where eg enable output of float audio),
and some other reason connected with Vdub current process, cant offhand remember what that was.

Code:
RT_GetProcessName(bool "parent"=false,bool "debug"=false)
 Returns string, name of current process eg "VirtualDubMod.exe" or "AvsPMod.exe" or name of parent process
 (the one that started our process eg "Explorer.exe"). Debug outputs some info to DebugView.
From RT_

Code:
/*
	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

*/

#include "RT_Stats.h"


#define DPRINTFNAME "RT_GetProcessName: "


AVSValue __cdecl RT_GetProcessName(AVSValue args, void*, IScriptEnvironment* env) {

	bool parent= args[0].AsBool(false);
	bool debug = args[1].AsBool(false);


//	DWORD WINAPI GetCurrentProcessId(void);
//	Return value: The return value is the process identifier of the calling process.
//	Minimum supported client:- Windows XP WinBase.h (Processthreadsapi.h W8 Server 2012)
//  ssS, Rubbish, also works fine on W2K

	DWORD PID = GetCurrentProcessId();	// Cannot fail (I think) as current process is obviously running.





// HANDLE WINAPI CreateToolhelp32Snapshot(DWORD dwFlags,DWORD th32ProcessID);
//
//
// The th32ProcessID argument is only used if TH32CS_SNAPHEAPLIST or
// TH32CS_SNAPMODULE is specified. th32ProcessID == 0 means the current
// process.
//
// NOTE that all of the snapshots are global except for the heap and module
//      lists which are process specific. To enumerate the heap or module
//      state for all WIN32 processes call with TH32CS_SNAPALL and the
//      current process. Then for each process in the TH32CS_SNAPPROCESS
//      list that isn't the current process, do a call with just
//      TH32CS_SNAPHEAPLIST and/or TH32CS_SNAPMODULE.
//
// dwFlags
//
// #define TH32CS_SNAPHEAPLIST 0x00000001
// #define TH32CS_SNAPPROCESS  0x00000002
// #define TH32CS_SNAPTHREAD   0x00000004
// #define TH32CS_SNAPMODULE   0x00000008
// #define TH32CS_SNAPMODULE32 0x00000010
// #define TH32CS_SNAPALL      (TH32CS_SNAPHEAPLIST | TH32CS_SNAPPROCESS | TH32CS_SNAPTHREAD | TH32CS_SNAPMODULE)
// #define TH32CS_INHERIT      0x80000000
//
    HANDLE         hProcessSnap = NULL; 

    //  Take a snapshot of all processes in the system. 
    hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); 
	// Returns an open handle to the specified snapshot if successful or INVALID_HANDLE_VALUE otherwise. 
	// The snapshot taken by this function is examined by the other tool help functions to provide their results.
	// Access to the snapshot is read only. The snapshot handle acts like an object handle and is subject to the same
	// rules regarding which processes and threads it is valid in. 
	// To retrieve an extended error status code generated by this function, use the GetLastError function.
	// To destroy the snapshot, use the CloseHandle function.


    if (hProcessSnap == INVALID_HANDLE_VALUE) 
        return -1; 
 

// Describes an entry from a list that enumerates the processes residing in the system address space when a snapshot was taken.
//
// typedef struct tagPROCESSENTRY32 { 
//   DWORD dwSize; 
//   DWORD cntUsage; 
//   DWORD th32ProcessID; 
//   ULONG_PTR th32DefaultHeapID; 
//   DWORD th32ModuleID; 
//   DWORD cntThreads; 
//   DWORD th32ParentProcessID; 
//   LONG  pcPriClassBase; 
//   DWORD dwFlags; 
//   TCHAR szExeFile[MAX_PATH]; 
// } PROCESSENTRY32; 
// typedef PROCESSENTRY32 *PPROCESSENTRY32; 
//
// Members 
//
// dwSize 
//		Specifies the length, in bytes, of the structure. Before calling the Process32First function, set this member to
//		sizeof(PROCESSENTRY32). If you do not initialize dwSize, Process32First will fail. 
// cntUsage 
//		Number of references to the process. A process exists as long as its usage count is nonzero. As soon as its usage
//		count becomes zero, a process terminates. 
// th32ProcessID 
//		Identifier of the process. 
// th32DefaultHeapID 
//		Identifier of the default heap for the process. The contents of this member has meaning only to the tool help
//		functions. It is not a handle, nor is it usable by functions other than the ToolHelp functions. 
// th32ModuleID 
//		Module identifier of the process. The contents of this member has meaning only to the tool help functions
//		It is not a handle, nor is it usable by functions other than the ToolHelp functions. 
// cntThreads 
//		Number of execution threads started by the process. 
// th32ParentProcessID 
//		Identifier of the process that created the process being examined. 
// pcPriClassBase 
//		Base priority of any threads created by this process. 
// dwFlags 
//		Reserved; do not use. 
// szExeFile 
//		Path and filename of the executable file for the process. 
//
// Requirements:- Windows NT/2000/XP: Included in Windows 2000 and later. ::: Tlhelp32.h.

    PROCESSENTRY32 pe32			= {0}; 
    //  Fill in the size of the structure before using it. 
    pe32.dwSize = sizeof(PROCESSENTRY32); 

	

    //  Walk the snapshot of the processes, and for each process, 
	//	BOOL WINAPI Process32First(HANDLE hSnapshot,LPPROCESSENTRY32 lppe);
    if (!Process32First(hProcessSnap, &pe32)) {
	    CloseHandle (hProcessSnap); 
		return -2;			// Cant find first process
	}

	AVSValue ret =  -3;		// Init to cant find my own PID

    do {
		if(pe32.th32ProcessID == PID) {
			if(debug) {
				dprintf(DPRINTFNAME"ExeFile    = %s\n",pe32.szExeFile);
				dprintf(DPRINTFNAME"ProcessID  = 0x%08X\n",pe32.th32ProcessID);
				dprintf(DPRINTFNAME"Threads    = %d\n",pe32.cntThreads);
				dprintf(DPRINTFNAME"ParentProc = 0x%08X\n",pe32.th32ParentProcessID);
			}
			if(parent==false) {
				ret = env->SaveString(pe32.szExeFile);
			} else {
				ret = -4;		// Init Cant find parent
				DWORD PARPID = pe32.th32ParentProcessID;
				if (Process32First(hProcessSnap, &pe32)) {
					do {
						if(pe32.th32ProcessID == PARPID) {
							if(debug) {
								dprintf(DPRINTFNAME"ExeFile    = %s\n",pe32.szExeFile);
								dprintf(DPRINTFNAME"ProcessID  = 0x%08X\n",pe32.th32ProcessID);
								dprintf(DPRINTFNAME"Threads    = %d\n",pe32.cntThreads);
								dprintf(DPRINTFNAME"ParentProc = 0x%08X\n",pe32.th32ParentProcessID);
							}
							ret = env->SaveString(pe32.szExeFile);
							break;
						}
					} while (Process32Next(hProcessSnap, &pe32)); 
				}
			}
			break;		// DONE
		}
    } while (Process32Next(hProcessSnap, &pe32)); 

    CloseHandle (hProcessSnap);		// Cleanup process snapshot

    return (ret); 
}
EDIT: Above there seems to be quite a few '32' snippits in code, perhaps it dont work in 64 bit proc.


EDIT:
Quote:
Just curious - Why do you call the function "ShowAvsInfo()" even though it doesn't gather anything related to Avisynth?
Just be thankfull that it aint called Test() or Fred(), two popular names I use a lot. [and it does show Avs version String, 1st line).
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 20th June 2019 at 22:20.
StainlessS is offline   Reply With Quote
Old 20th June 2019, 22:12   #44  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by StainlessS View Post
Just thought that additional nicety might be the Parent process name, in RT_stats we have RT_GetProcessName(), might be handy in your plug too.
Yep, sounds like a good idea, thanks for the code snippet.
__________________
Groucho's Avisynth Stuff
Groucho2004 is offline   Reply With Quote
Old 20th June 2019, 22:14   #45  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by StainlessS View Post
EDIT:

Just be thankfull that it aint called Test() or Fred(), two popular names I use a lot. [and it does show Avs version String, 1st line).
Ok, never mind.

I do like "Fred()".
__________________
Groucho's Avisynth Stuff
Groucho2004 is offline   Reply With Quote
Old 20th June 2019, 22:23   #46  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
On Qwerty Keyboard, all 4 keys are adjacent, so easy to type for us lazy coders [Fred].
Note also the comment below code on lots of '32' snippits in code block, maybe not work on x64.

EDIT: Off to pub for last orders.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 20th June 2019, 22:24   #47  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by StainlessS View Post
EDIT: Above there seems to be quite a few '32' snippits in code, perhaps it dont work in 64 bit proc.
I wrote a ProcessInfo() class for AVSMeter so there should not be any problems with 64 bit.
__________________
Groucho's Avisynth Stuff
Groucho2004 is offline   Reply With Quote
Old 21st June 2019, 11:36   #48  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by StainlessS View Post
Just thought that additional nicety might be the Parent process name, in RT_stats we have RT_GetProcessName(), might be handy in your plug too.
Yep, sounds like a good idea, thanks for the code snippet.

Edit: It's actually as simple as this:
Code:
char szBuffer[MAX_PATH];
GetModuleFileName(NULL, (LPTSTR)szBuffer, sizeof(szBuffer));
__________________
Groucho's Avisynth Stuff
Groucho2004 is offline   Reply With Quote
Old 21st June 2019, 12:15   #49  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Will you be implementing both Current Process Name, & Parent Process Name ? [I intially wrote parent, but meant current process, RT_ returns either].
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 21st June 2019, 12:18   #50  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by StainlessS View Post
Will you be implementing both Current Process Name, & Parent Process Name ?
I don't understand the difference. There is always just one process that loads avisynth.dll.

Edit: Ok, I see what you mean. Can you give me an example where it's useful to know the parent process?
__________________
Groucho's Avisynth Stuff

Last edited by Groucho2004; 21st June 2019 at 12:23.
Groucho2004 is offline   Reply With Quote
Old 21st June 2019, 12:24   #51  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Difference is, Current Process is eg MPC-HC or AvsPMod or VirtualDub or MeGUI, Parent is whatever started current, eg Windows Explorer, or maybe command line [maybe Cmd.Exe, not sure] or whatever.
Parent might be of use on rare occasion.
EDIT: I think parent may sometimes not exist, if has been killed since current process start.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 21st June 2019 at 12:26.
StainlessS is offline   Reply With Quote
Old 21st June 2019, 12:31   #52  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Until a flash of enlightenment reveals its usefulness to me I think I'll give 'parent process name' a miss.
__________________
Groucho's Avisynth Stuff
Groucho2004 is offline   Reply With Quote
Old 21st June 2019, 13:27   #53  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
v0.1.1.0
- Added 'SI_ProcessName'
__________________
Groucho's Avisynth Stuff
Groucho2004 is offline   Reply With Quote
Old 21st June 2019, 14:05   #54  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Ooo lovely

EDIT: nothing wrong with a pat on the head (so long as its not a cow pat).
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 22nd June 2019 at 18:54.
StainlessS is offline   Reply With Quote
Old 22nd July 2019, 10:01   #55  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
v0.1.1.1
- Updated libcpuid (AMD Zen 2 support)
__________________
Groucho's Avisynth Stuff
Groucho2004 is offline   Reply With Quote
Old 26th July 2019, 20:39   #56  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
v0.1.1.2
- Added SI_GetEnvVar
__________________
Groucho's Avisynth Stuff
Groucho2004 is offline   Reply With Quote
Old 26th October 2019, 11:43   #57  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
No hurry, but if updating dll, please add a SysInfo dll version number, just so we know what we got available, will display it in AvsInit thingy.

Thanx muchly
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 26th October 2019, 11:50   #58  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by StainlessS View Post
No hurry, but if updating dll, please add a SysInfo dll version number, just so we know what we got available, will display it in AvsInit thingy.

Thanx muchly
It has a version resource.
__________________
Groucho's Avisynth Stuff
Groucho2004 is offline   Reply With Quote
Old 26th October 2019, 11:52   #59  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Arh, so I gotta write something to extract version from version resource. [was wantin' it at runtime, check minimum requirement, likely future mandatory Sysinfo of minimum version]
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 26th October 2019 at 11:55.
StainlessS is offline   Reply With Quote
Old 26th October 2019, 11:57   #60  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by StainlessS View Post
Arh, so I gotta write something to extract version from version resource. [was wantin' it at runtime, check minimum requirement, likely future mandatory Sysinfo of minimum version]
Do you mean to add it to the return value of AvisynthPluginInit? Extracting it from the version resource it easy, have a look at AVSMeter, utility.h, GetFileVersion()/GetProductVersion().
__________________
Groucho's Avisynth Stuff
Groucho2004 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 16:01.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.