diff --git a/nnedi3 - Readme.txt b/nnedi3 - Readme.txt index 760297a..2b2bc90 100644 --- a/nnedi3 - Readme.txt +++ b/nnedi3 - Readme.txt @@ -1,7 +1,7 @@ | nnedi3 for Avisynth by tritical | modified by JPSDR | - v0.9.4.51 (27/05/2018) | + v0.9.4.52 (30/05/2019) | HELP FILE | ----------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------- @@ -21,13 +21,13 @@ INFO: nnedi3(int field, bool dh, bool Y, bool U, bool V, int nsize, int nns, int qual, int etype, int pscrn, int threads, int opt, int fapprox, bool logicalCores, bool MaxPhysCore, bool SetAffinity, - bool A, bool sleep, int prefetch, int range) + bool A, bool sleep, int prefetch, int range,int ThreadLevel) nnedi3_rpow2(int rfactor, int nsize, int nns, int qual, int etype, int pscrn, string cshift, int fwidth, int fheight, float ep0, float ep1, int threads, int opt, int fapprox, bool csresize, bool mpeg2,bool logicalCores, bool MaxPhysCore, bool SetAffinity, int threads_rs,bool logicalCores_rs, bool MaxPhysCore_rs, bool SetAffinity_rs, - bool sleep, int prefetch, int range) + bool sleep, int prefetch, int range,int ThreadLevel) @@ -272,6 +272,18 @@ PARAMETERS (nnedi3): Default: 1 + ThreadLevel - + This parameter will set the priority level of the threads created for the processing (internal + multithreading). No effect if threads=1. + 1 : Idle level. + 2 : Lowest level. + 3 : Below level. + 4 : Normal level. + 5 : Above level. + 6 : Highest level. + 7 : Time critical level (WARNING !!! use this level at your own risk) + + Default : 6 The logicalCores, MaxPhysCore, SetAffinity and sleep are parameters to specify how the pool of thread will be created and handled, allowing if necessary each people to tune according his configuration. diff --git a/nnedi3/ThreadPool.cpp b/nnedi3/ThreadPool.cpp index ad5b678..c6b18e6 100644 --- a/nnedi3/ThreadPool.cpp +++ b/nnedi3/ThreadPool.cpp @@ -2,7 +2,7 @@ * Threadpool * * Create and manage a threadpool. - * Copyright (C) 2017 JPSDR + * Copyright (C) 2016 JPSDR * * Threadpool is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,7 +20,7 @@ * */ -// ThreadPoolInterface.cpp : Define the exported functions for using with the threadpool. +// ThreadPoolDLL.cpp : Define the exported functions for using with the threadpool. // Kind of API. #include "ThreadPool.h" @@ -28,6 +28,9 @@ #define myfree(ptr) if (ptr!=NULL) { free(ptr); ptr=NULL;} #define myCloseHandle(ptr) if (ptr!=NULL) { CloseHandle(ptr); ptr=NULL;} +static const int TabThreadLevel[8]={THREAD_PRIORITY_NORMAL,THREAD_PRIORITY_IDLE,THREAD_PRIORITY_LOWEST, + THREAD_PRIORITY_BELOW_NORMAL,THREAD_PRIORITY_NORMAL,THREAD_PRIORITY_ABOVE_NORMAL, + THREAD_PRIORITY_HIGHEST,THREAD_PRIORITY_TIME_CRITICAL}; // Helper function to count set bits in the processor mask. static uint8_t CountSetBits(ULONG_PTR bitMask) @@ -226,7 +229,6 @@ DWORD WINAPI ThreadPool::StaticThreadpool(LPVOID lpParam ) } - ThreadPool::ThreadPool(void): Status_Ok(true) { int16_t i; @@ -243,12 +245,13 @@ ThreadPool::ThreadPool(void): Status_Ok(true) thds[i]=NULL; ThreadSleep[i]=true; } + nPriority=NormalThreadLevel; TotalThreadsRequested=0; CurrentThreadsAllocated=0; CurrentThreadsUsed=0; Get_CPU_Info(CPU); - if ((CPU.NbLogicCPU==0) || (CPU.NbPhysCore==0)) Status_Ok=false; + Status_Ok=!(((CPU.NbLogicCPU==0) || (CPU.NbPhysCore==0))); } @@ -259,10 +262,13 @@ void ThreadPool::FreeThreadPool(void) if (TotalThreadsRequested>0) { + const int nPr=TabThreadLevel[AboveThreadLevel]; + for (i=TotalThreadsRequested-1; i>=0; i--) { if (thds[i]!=NULL) { + SetThreadPriority(thds[i],nPr); if (ThreadSleep[i]) ResumeThread(thds[i]); MT_Thread[i].f_process=255; SetEvent(nextJob[i]); @@ -283,6 +289,7 @@ void ThreadPool::FreeThreadPool(void) } } + nPriority=NormalThreadLevel; TotalThreadsRequested=0; CurrentThreadsAllocated=0; CurrentThreadsUsed=0; @@ -335,32 +342,24 @@ uint8_t ThreadPool::GetThreadNumber(uint8_t thread_number,bool logical) { const uint8_t nCPU=(logical) ? CPU.NbLogicCPU:CPU.NbPhysCore; - if (thread_number==0) return((nCPU>MAX_MT_THREADS) ? MAX_MT_THREADS:nCPU); - else return(thread_number); + return((thread_number==0) ? ((nCPU>MAX_MT_THREADS) ? MAX_MT_THREADS:nCPU):thread_number); } -bool ThreadPool::AllocateThreads(uint8_t thread_number,uint8_t offset_core,uint8_t offset_ht,bool UseMaxPhysCore,bool SetAffinity,bool sleep) +bool ThreadPool::AllocateThreads(uint8_t thread_number,uint8_t offset_core,uint8_t offset_ht,bool UseMaxPhysCore, + bool SetAffinity,bool sleep,ThreadLevelName priority) { if ((!Status_Ok) || (thread_number==0)) return(false); if (thread_number>CurrentThreadsAllocated) { TotalThreadsRequested=thread_number; - CreateThreadPool(offset_core,offset_ht,UseMaxPhysCore,SetAffinity,sleep); + CreateThreadPool(offset_core,offset_ht,UseMaxPhysCore,SetAffinity,sleep,priority); } return(Status_Ok); } -bool ThreadPool::ChangeThreadsAffinity(uint8_t offset_core,uint8_t offset_ht,bool UseMaxPhysCore,bool SetAffinity,bool sleep) -{ - if ((!Status_Ok) || (CurrentThreadsAllocated==0)) return(false); - - CreateThreadPool(offset_core,offset_ht,UseMaxPhysCore,SetAffinity,sleep); - - return(Status_Ok); -} bool ThreadPool::DeAllocateThreads(void) { @@ -372,34 +371,74 @@ bool ThreadPool::DeAllocateThreads(void) } +bool ThreadPool::ChangeThreadsAffinity(uint8_t offset_core,uint8_t offset_ht,bool UseMaxPhysCore,bool SetAffinity) +{ + if ((!Status_Ok) || (CurrentThreadsAllocated==0)) return(false); -void ThreadPool::CreateThreadPool(uint8_t offset_core,uint8_t offset_ht,bool UseMaxPhysCore,bool SetAffinity,bool sleep) + CreateThreadsMasks(CPU,ThreadMask,TotalThreadsRequested,offset_core,offset_ht,UseMaxPhysCore); + + for(uint8_t i=0; iCurrentThreadsAllocated)) return(false); + const int nPr=TabThreadLevel[(priority!=NoneThreadLevel)?priority:nPriority]; + for(uint8_t i=0; i0) { - if (sleep) + const int nPr=TabThreadLevel[IdleThreadLevel]; + + for(uint8_t i=0; iAllocateThreads(thread_number,offset_core,offset_ht,UseMaxPhysCore,SetAffinity,sleep); + bool ok=ptrPool[i]->AllocateThreads(thread_number,offset_core,offset_ht,UseMaxPhysCore, + SetAffinity,sleep,priority); if (!ok) { Error_Occured=true; @@ -634,7 +636,8 @@ bool ThreadPoolInterface::AllocateThreads(uint8_t thread_number,uint8_t offset_c return(false); } } - bool ok=ptrPool[nPool]->AllocateThreads(thread_number,offset_core,offset_ht,UseMaxPhysCore,SetAffinity,sleep); + bool ok=ptrPool[nPool]->AllocateThreads(thread_number,offset_core,offset_ht,UseMaxPhysCore, + SetAffinity,sleep,priority); if (!ok) { Error_Occured=true; @@ -712,7 +715,7 @@ bool ThreadPoolInterface::GetUserId(uint16_t &UserId) } -bool ThreadPoolInterface::ChangeThreadsAffinity(uint8_t offset_core,uint8_t offset_ht,bool UseMaxPhysCore,bool SetAffinity,bool sleep,int8_t nPool) +bool ThreadPoolInterface::ChangeThreadsAffinity(uint8_t offset_core,uint8_t offset_ht,bool UseMaxPhysCore,bool SetAffinity,int8_t nPool) { if ((!Status_Ok) || Error_Occured || (nPool<-1)) return(false); @@ -738,19 +741,7 @@ bool ThreadPoolInterface::ChangeThreadsAffinity(uint8_t offset_core,uint8_t offs { if (ptrPool[i]->GetCurrentThreadAllocated()>0) { - while (JobsRunning[i]) - { - LeaveCriticalSection(&CriticalSection); - WaitForSingleObject(JobsEnded[i],INFINITE); - EnterCriticalSection(&CriticalSection); - if ((!Status_Ok) || Error_Occured) - { - LeaveCriticalSection(&CriticalSection); - ReleaseMutex(ghMutexResources); - return(false); - } - } - bool ok=ptrPool[i]->ChangeThreadsAffinity(offset_core,offset_ht,UseMaxPhysCore,SetAffinity,sleep); + bool ok=ptrPool[i]->ChangeThreadsAffinity(offset_core,offset_ht,UseMaxPhysCore,SetAffinity); if (!ok) { Error_Occured=true; @@ -768,19 +759,72 @@ bool ThreadPoolInterface::ChangeThreadsAffinity(uint8_t offset_core,uint8_t offs { if (ptrPool[nPool]->GetCurrentThreadAllocated()>0) { - while (JobsRunning[nPool]) + bool ok=ptrPool[nPool]->ChangeThreadsAffinity(offset_core,offset_ht,UseMaxPhysCore,SetAffinity); + if (!ok) { + Error_Occured=true; + FreePool(); + Status_Ok=false; + FreeData(); LeaveCriticalSection(&CriticalSection); - WaitForSingleObject(JobsEnded[nPool],INFINITE); - EnterCriticalSection(&CriticalSection); - if ((!Status_Ok) || Error_Occured) + ReleaseMutex(ghMutexResources); + return(false); + } + } + } + + LeaveCriticalSection(&CriticalSection); + ReleaseMutex(ghMutexResources); + + return(true); +} + + +bool ThreadPoolInterface::ChangeThreadsLevel(ThreadLevelName priority,int8_t nPool) +{ + if ((!Status_Ok) || Error_Occured || (nPool<-1)) return(false); + + WaitForSingleObject(ghMutexResources,INFINITE); + + if ((!Status_Ok) || Error_Occured || (nPool>=(int8_t)NbrePool)) + { + ReleaseMutex(ghMutexResources); + return(false); + } + + EnterCriticalSection(&CriticalSection); + if ((!Status_Ok) || Error_Occured ) + { + LeaveCriticalSection(&CriticalSection); + ReleaseMutex(ghMutexResources); + return(false); + } + + if (nPool==-1) + { + for(uint8_t i=0; iGetCurrentThreadAllocated()>0) + { + bool ok=ptrPool[i]->ChangeThreadsLevel(priority); + if (!ok) { + Error_Occured=true; + FreePool(); + Status_Ok=false; + FreeData(); LeaveCriticalSection(&CriticalSection); ReleaseMutex(ghMutexResources); return(false); } } - bool ok=ptrPool[nPool]->ChangeThreadsAffinity(offset_core,offset_ht,UseMaxPhysCore,SetAffinity,sleep); + } + } + else + { + if (ptrPool[nPool]->GetCurrentThreadAllocated()>0) + { + bool ok=ptrPool[nPool]->ChangeThreadsLevel(priority); if (!ok) { Error_Occured=true; @@ -1000,15 +1044,16 @@ bool ThreadPoolInterface::DeAllocateAllThreads(bool check) } -bool ThreadPoolInterface::RequestThreadPool(uint16_t UserId,uint8_t thread_number,Public_MT_Data_Thread *Data,int8_t nPool,bool Exclusive) +bool ThreadPoolInterface::RequestThreadPool(uint16_t UserId,uint8_t thread_number,Public_MT_Data_Thread *Data, + ThreadLevelName priority,int8_t nPool,bool Exclusive) { - if (!RequestThreadPool(UserId,thread_number,Data,nPool,Exclusive,false) || (nPool==-1)) return(false); + if (!RequestThreadPool(UserId,thread_number,Data,priority,nPool,Exclusive,false) || (nPool==-1)) return(false); else return(true); } - -bool ThreadPoolInterface::RequestThreadPool(uint16_t UserId,uint8_t thread_number,Public_MT_Data_Thread *Data,int8_t &nPool,bool Exclusive,bool AllowSeveral) +bool ThreadPoolInterface::RequestThreadPool(uint16_t UserId,uint8_t thread_number,Public_MT_Data_Thread *Data, + ThreadLevelName priority,int8_t &nPool,bool Exclusive,bool AllowSeveral) { if ((!Status_Ok) || Error_Occured || (UserId==0) || (nPool<-1) || (thread_number==0) || (Data==NULL)) { @@ -1233,7 +1278,7 @@ bool ThreadPoolInterface::RequestThreadPool(uint16_t UserId,uint8_t thread_numbe } } - bool out=ptrPool[nPool]->RequestThreadPool(thread_number,Data); + bool out=ptrPool[nPool]->RequestThreadPool(thread_number,Data,priority); if (out) { diff --git a/nnedi3/ThreadPoolInterface.h b/nnedi3/ThreadPoolInterface.h index 03bd54b..853c22e 100644 --- a/nnedi3/ThreadPoolInterface.h +++ b/nnedi3/ThreadPoolInterface.h @@ -27,7 +27,7 @@ #include "ThreadPoolDef.h" -#define THREADPOOLINTERFACE_VERSION "ThreadPoolInterface 1.8.0" +#define THREADPOOLINTERFACE_VERSION "ThreadPoolInterface 1.9.0" typedef struct _UserData { @@ -48,16 +48,20 @@ class ThreadPoolInterface int16_t AddPool(uint8_t num); bool CreatePool(uint8_t num); bool DeletePool(uint8_t num); - bool RemovePool(uint8_t num); - bool AllocateThreads(uint8_t thread_number,uint8_t offset_core,uint8_t offset_ht,bool UseMaxPhysCore,bool SetAffinity,bool sleep,int8_t nPool); + bool RemovePool(uint8_t num); + bool AllocateThreads(uint8_t thread_number,uint8_t offset_core,uint8_t offset_ht,bool UseMaxPhysCore, + bool SetAffinity,bool sleep,ThreadLevelName priority,int8_t nPool); bool GetUserId(uint16_t &UserId); bool RemoveUserId(uint16_t UserId); - bool ChangeThreadsAffinity(uint8_t offset_core,uint8_t offset_ht,bool UseMaxPhysCore,bool SetAffinity,bool sleep,int8_t nPool); + bool ChangeThreadsAffinity(uint8_t offset_core,uint8_t offset_ht,bool UseMaxPhysCore,bool SetAffinity,int8_t nPool); + bool ChangeThreadsLevel(ThreadLevelName priority,int8_t nPool); bool DeAllocateUserThreads(uint16_t UserId,bool check); bool DeAllocatePoolThreads(uint8_t nPool,bool check); bool DeAllocateAllThreads(bool check); - bool RequestThreadPool(uint16_t UserId,uint8_t thread_number,Public_MT_Data_Thread *Data,int8_t nPool,bool Exclusive); - bool RequestThreadPool(uint16_t UserId,uint8_t thread_number,Public_MT_Data_Thread *Data,int8_t &nPool,bool Exclusive,bool AllowSeveral); + bool RequestThreadPool(uint16_t UserId,uint8_t thread_number,Public_MT_Data_Thread *Data, + ThreadLevelName priority,int8_t nPool,bool Exclusive); + bool RequestThreadPool(uint16_t UserId,uint8_t thread_number,Public_MT_Data_Thread *Data, + ThreadLevelName priority,int8_t &nPool,bool Exclusive,bool AllowSeveral); bool ReleaseThreadPool(uint16_t UserId,bool sleep); bool ReleaseThreadPool(uint16_t UserId,bool sleep,int8_t nPool); bool StartThreads(uint16_t UserId); diff --git a/nnedi3/nnedi3.cpp b/nnedi3/nnedi3.cpp index fa65381..3a59938 100644 --- a/nnedi3/nnedi3.cpp +++ b/nnedi3/nnedi3.cpp @@ -1,5 +1,5 @@ /* -** nnedi3 v0.9.4.51 for Avs+/Avisynth 2.6.x +** nnedi3 v0.9.4.52 for Avs+/Avisynth 2.6.x ** ** Copyright (C) 2010-2011 Kevin Stone ** @@ -1107,7 +1107,7 @@ PVideoFrame __stdcall nnedi3::GetFrame(int n, IScriptEnvironment *env) if (threads_number>1) { - if (!poolInterface->RequestThreadPool(UserId,threads_number,MT_Thread,-1,false)) + if (!poolInterface->RequestThreadPool(UserId,threads_number,MT_Thread,NoneThreadLevel,-1,false)) env->ThrowError("nnedi3: Error with the TheadPool while requesting threadpool !"); for (uint8_t b=0; bMAX_MT_THREADS)) env->ThrowError("nnedi3: [threads] must be between 0 and %ld.",MAX_MT_THREADS); if (prefetch==0) prefetch=1; if ((prefetch<0) || (prefetch>MAX_THREAD_POOL)) env->ThrowError("nnedi3: [prefetch] must be between 0 and %d.", MAX_THREAD_POOL); + if ((thread_level<1) || (thread_level>7)) + env->ThrowError("nnedi3: [ThreadLevel] must be between 1 and 7."); const bool dh = args[2].AsBool(false); if (((vi.height&1)!=0) && !dh) @@ -3917,6 +3920,9 @@ AVSValue __cdecl Create_nnedi3(AVSValue args, void* user_data, IScriptEnvironmen if (threads!=1) { + const ThreadLevelName TabLevel[8]={NoneThreadLevel,IdleThreadLevel,LowestThreadLevel, + BelowThreadLevel,NormalThreadLevel,AboveThreadLevel,HighestThreadLevel,CriticalThreadLevel}; + if (!poolInterface->CreatePool(prefetch)) env->ThrowError("nnedi3: Unable to create ThreadPool!"); threads_number=poolInterface->GetThreadNumber(threads,LogicalCores); @@ -3933,7 +3939,8 @@ AVSValue __cdecl Create_nnedi3(AVSValue args, void* user_data, IScriptEnvironmen for(uint8_t i=0; iAllocateThreads(threads_number,(uint8_t)ceil(Offset),0,MaxPhysCores,true,true,i)) + if (!poolInterface->AllocateThreads(threads_number,(uint8_t)ceil(Offset),0,MaxPhysCores, + true,true,TabLevel[thread_level],i)) { poolInterface->DeAllocateAllThreads(true); env->ThrowError("nnedi3: Error with the TheadPool while allocating threadpool!"); @@ -3943,7 +3950,7 @@ AVSValue __cdecl Create_nnedi3(AVSValue args, void* user_data, IScriptEnvironmen } else { - if (!poolInterface->AllocateThreads(threads_number,0,0,MaxPhysCores,false,true,-1)) + if (!poolInterface->AllocateThreads(threads_number,0,0,MaxPhysCores,false,true,TabLevel[thread_level],-1)) { poolInterface->DeAllocateAllThreads(true); env->ThrowError("nnedi3: Error with the TheadPool while allocating threadpool!"); @@ -3952,7 +3959,7 @@ AVSValue __cdecl Create_nnedi3(AVSValue args, void* user_data, IScriptEnvironmen } else { - if (!poolInterface->AllocateThreads(threads_number,0,0,MaxPhysCores,SetAffinity,true,-1)) + if (!poolInterface->AllocateThreads(threads_number,0,0,MaxPhysCores,SetAffinity,true,TabLevel[thread_level],-1)) { poolInterface->DeAllocateAllThreads(true); env->ThrowError("nnedi3: Error with the TheadPool while allocating threadpool!"); @@ -4046,6 +4053,8 @@ AVSValue __cdecl Create_nnedi3_rpow2(AVSValue args, void* user_data, IScriptEnvi const bool sleep = args[24].AsBool(false); int prefetch = args[25].AsInt(0); int range_mode = args[26].AsInt(1); + int thread_level=args[27].AsInt(6); + int thread_level_rs=args[28].AsInt(6); if ((rfactor<2) || (rfactor>1024)) env->ThrowError("nnedi3_rpow2: 2 <= rfactor <= 1024, and rfactor be a power of 2!\n"); int rf=1,ct=0; @@ -4077,11 +4086,18 @@ AVSValue __cdecl Create_nnedi3_rpow2(AVSValue args, void* user_data, IScriptEnvi if (prefetch==0) prefetch=1; if ((prefetch<0) || (prefetch>MAX_THREAD_POOL)) env->ThrowError("nnedi3_rpow2: [prefetch] must be between 0 and %d.", MAX_THREAD_POOL); + if ((thread_level<1) || (thread_level>7)) + env->ThrowError("nnedi3_rpow2: [ThreadLevel] must be between 1 and 7."); + if ((thread_level_rs<1) || (thread_level_rs>7)) + env->ThrowError("nnedi3_rpow2: [ThreadLevel_rs] must be between 1 and 7."); uint8_t threads_number=1; if (threads!=1) { + const ThreadLevelName TabLevel[8]={NoneThreadLevel,IdleThreadLevel,LowestThreadLevel, + BelowThreadLevel,NormalThreadLevel,AboveThreadLevel,HighestThreadLevel,CriticalThreadLevel}; + if (!poolInterface->CreatePool(prefetch)) env->ThrowError("nnedi3_rpow2: Unable to create ThreadPool!"); threads_number=poolInterface->GetThreadNumber(threads,LogicalCores); @@ -4098,7 +4114,8 @@ AVSValue __cdecl Create_nnedi3_rpow2(AVSValue args, void* user_data, IScriptEnvi for(uint8_t i=0; iAllocateThreads(threads_number,(uint8_t)ceil(Offset),0,MaxPhysCores,true,true,i)) + if (!poolInterface->AllocateThreads(threads_number,(uint8_t)ceil(Offset),0,MaxPhysCores, + true,true,TabLevel[thread_level],i)) { poolInterface->DeAllocateAllThreads(true); env->ThrowError("nnedi3_rpow2: Error with the TheadPool while allocating threadpool!"); @@ -4108,7 +4125,7 @@ AVSValue __cdecl Create_nnedi3_rpow2(AVSValue args, void* user_data, IScriptEnvi } else { - if (!poolInterface->AllocateThreads(threads_number,0,0,MaxPhysCores,false,true,-1)) + if (!poolInterface->AllocateThreads(threads_number,0,0,MaxPhysCores,false,true,TabLevel[thread_level],-1)) { poolInterface->DeAllocateAllThreads(true); env->ThrowError("nnedi3_rpow2: Error with the TheadPool while allocating threadpool!"); @@ -4117,7 +4134,7 @@ AVSValue __cdecl Create_nnedi3_rpow2(AVSValue args, void* user_data, IScriptEnvi } else { - if (!poolInterface->AllocateThreads(threads_number,0,0,MaxPhysCores,SetAffinity,true,-1)) + if (!poolInterface->AllocateThreads(threads_number,0,0,MaxPhysCores,SetAffinity,true,TabLevel[thread_level],-1)) { poolInterface->DeAllocateAllThreads(true); env->ThrowError("nnedi3_rpow2: Error with the TheadPool while allocating threadpool!"); @@ -4352,11 +4369,12 @@ AVSValue __cdecl Create_nnedi3_rpow2(AVSValue args, void* user_data, IScriptEnvi if ((type==0) || ((type!=3) && (ep0==-FLT_MAX)) || ((type==3) && (ep0==-FLT_MAX) && (ep1==-FLT_MAX))) { - AVSValue sargs[14] = { v, fwidth, fheight, Y_hshift, Y_vshift, + AVSValue sargs[15] = { v, fwidth, fheight, Y_hshift, Y_vshift, vi.width*rfactor, vi.height*rfactor,threads_rs,LogicalCores_rs,MaxPhysCores_rs,SetAffinity_rs,sleep, - prefetch,range_mode }; - const char *nargs[14] = { 0, 0, 0, "src_left", "src_top", - "src_width", "src_height","threads","logicalCores","MaxPhysCore","SetAffinity","sleep","prefetch","range" }; + prefetch,range_mode,thread_level_rs }; + const char *nargs[15] = { 0, 0, 0, "src_left", "src_top", + "src_width", "src_height","threads","logicalCores","MaxPhysCore","SetAffinity","sleep", + "prefetch","range","ThreadLevel" }; const uint8_t nbarg=(use_rs_mt) ? 14:7; v=env->Invoke(cshift,AVSValue(sargs,nbarg),nargs).AsClip(); @@ -4432,12 +4450,13 @@ AVSValue __cdecl Create_nnedi3_rpow2(AVSValue args, void* user_data, IScriptEnvi } else if ((type!=3) || (min(ep0,ep1)==-FLT_MAX)) { - AVSValue sargs[15] = { v, fwidth, fheight, Y_hshift, Y_vshift, + AVSValue sargs[16] = { v, fwidth, fheight, Y_hshift, Y_vshift, vi.width*rfactor, vi.height*rfactor, type==1?AVSValue((int)(ep0+0.5f)): - (type==2?ep0:max(ep0,ep1)),threads_rs,LogicalCores_rs,MaxPhysCores_rs,SetAffinity_rs,sleep,prefetch,range_mode }; - const char *nargs[15] = { 0, 0, 0, "src_left", "src_top", + (type==2?ep0:max(ep0,ep1)),threads_rs,LogicalCores_rs,MaxPhysCores_rs,SetAffinity_rs, + sleep,prefetch,range_mode,thread_level_rs }; + const char *nargs[16] = { 0, 0, 0, "src_left", "src_top", "src_width", "src_height", type==1?"taps":(type==2?"p":(max(ep0,ep1)==ep0?"b":"c")), - "threads","logicalCores","MaxPhysCore","SetAffinity","sleep","prefetch","range" }; + "threads","logicalCores","MaxPhysCore","SetAffinity","sleep","prefetch","range","ThreadLevel" }; const uint8_t nbarg=(use_rs_mt) ? 15:8; v=env->Invoke(cshift,AVSValue(sargs,nbarg),nargs).AsClip(); @@ -4513,12 +4532,12 @@ AVSValue __cdecl Create_nnedi3_rpow2(AVSValue args, void* user_data, IScriptEnvi } else { - AVSValue sargs[16] = { v, fwidth, fheight, Y_hshift, Y_vshift, + AVSValue sargs[17] = { v, fwidth, fheight, Y_hshift, Y_vshift, vi.width*rfactor, vi.height*rfactor, ep0, ep1,threads_rs,LogicalCores_rs,MaxPhysCores_rs, - SetAffinity_rs,sleep,prefetch,range_mode }; - const char *nargs[16] = { 0, 0, 0, "src_left", "src_top", + SetAffinity_rs,sleep,prefetch,range_mode,thread_level_rs }; + const char *nargs[17] = { 0, 0, 0, "src_left", "src_top", "src_width", "src_height", "b", "c", "threads","logicalCores","MaxPhysCore","SetAffinity", - "sleep","prefetch","range" }; + "sleep","prefetch","range","ThreadLevel" }; const uint8_t nbarg=(use_rs_mt) ? 16:9; v = env->Invoke(cshift,AVSValue(sargs,nbarg),nargs).AsClip(); @@ -4599,11 +4618,11 @@ AVSValue __cdecl Create_nnedi3_rpow2(AVSValue args, void* user_data, IScriptEnvi { if (vi.Is420()) { - AVSValue sargs[14]={vu,(vi.width*rfactor)>>1,(vi.height*rfactor)>>1,0.0,-0.25, + AVSValue sargs[15]={vu,(vi.width*rfactor)>>1,(vi.height*rfactor)>>1,0.0,-0.25, (vi.width*rfactor)>>1,(vi.height*rfactor)>>1,threads_rs,LogicalCores_rs,MaxPhysCores_rs, - SetAffinity_rs,sleep,prefetch,plane_range[1]}; - const char *nargs[14]={0,0,0,"src_left","src_top","src_width","src_height","threads", - "logicalCores","MaxPhysCore","SetAffinity","sleep","prefetch","range" }; + SetAffinity_rs,sleep,prefetch,plane_range[1],thread_level_rs}; + const char *nargs[15]={0,0,0,"src_left","src_top","src_width","src_height","threads", + "logicalCores","MaxPhysCore","SetAffinity","sleep","prefetch","range","ThreadLevel" }; const uint8_t nbarg=(SplineMT) ? 14:7; vu = env->Invoke(Spline36,AVSValue(sargs,nbarg),nargs).AsClip(); @@ -4663,10 +4682,12 @@ extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit3(IScri if (!poolInterface->GetThreadPoolInterfaceStatus()) env->ThrowError("nnedi3: Error with the TheadPool status!"); env->AddFunction("nnedi3", "c[field]i[dh]b[Y]b[U]b[V]b[nsize]i[nns]i[qual]i[etype]i[pscrn]i" \ - "[threads]i[opt]i[fapprox]i[logicalCores]b[MaxPhysCore]b[SetAffinity]b[A]b[sleep]b[prefetch]i[range]i", Create_nnedi3, 0); + "[threads]i[opt]i[fapprox]i[logicalCores]b[MaxPhysCore]b[SetAffinity]b[A]b[sleep]b[prefetch]i" \ + "[range]i[ThreadLevel]i", Create_nnedi3, 0); env->AddFunction("nnedi3_rpow2", "c[rfactor]i[nsize]i[nns]i[qual]i[etype]i[pscrn]i[cshift]s[fwidth]i" \ "[fheight]i[ep0]f[ep1]f[threads]i[opt]i[fapprox]i[csresize]b[mpeg2]b[logicalCores]b[MaxPhysCore]b" \ - "[SetAffinity]b[threads_rs]i[logicalCores_rs]b[MaxPhysCore_rs]b[SetAffinity_rs]b[sleep]b[prefetch]i[range]i", Create_nnedi3_rpow2, 0); + "[SetAffinity]b[threads_rs]i[logicalCores_rs]b[MaxPhysCore_rs]b[SetAffinity_rs]b[sleep]b" \ + "[prefetch]i[range]i[ThreadLevel]i[ThreadLevel_rs]i", Create_nnedi3_rpow2, 0); return "NNEDI3 plugin"; diff --git a/nnedi3/nnedi3.h b/nnedi3/nnedi3.h index b551214..8c82804 100644 --- a/nnedi3/nnedi3.h +++ b/nnedi3/nnedi3.h @@ -1,5 +1,5 @@ /* -** nnedi3 v0.9.4.51 for Avs+/Avisynth 2.6.x +** nnedi3 v0.9.4.52 for Avs+/Avisynth 2.6.x ** ** Copyright (C) 2010-2011 Kevin Stone ** diff --git a/nnedi3/nnedi3.rc b/nnedi3/nnedi3.rc index 2b0e28b..20e0380 100644 --- a/nnedi3/nnedi3.rc +++ b/nnedi3/nnedi3.rc @@ -55,8 +55,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,9,4,51 - PRODUCTVERSION 0,9,4,51 + FILEVERSION 0,9,4,52 + PRODUCTVERSION 0,9,4,52 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L @@ -71,11 +71,11 @@ BEGIN BEGIN BLOCK "040904b0" BEGIN - VALUE "FileDescription", "nnedi3 v0.9.4.51 for Avisynth 2.6.x" - VALUE "FileVersion", "0.9.4.51" - VALUE "LegalCopyright", "Copyright (C) 2010-2011 Kevin Stone" + VALUE "FileDescription", "nnedi3 v0.9.4.52 for Avisynth 2.6.x" + VALUE "FileVersion", "0.9.4.52" + VALUE "LegalCopyright", "Copyright (C) 2010-2011 Kevin Stone, 2016 JPSDR" VALUE "OriginalFilename", "nnedi3.dll" - VALUE "ProductVersion", "0.9.4.51" + VALUE "ProductVersion", "0.9.4.52" END END BLOCK "VarFileInfo"