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 Development
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 17th June 2015, 12:04   #161  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Code:
global MeGUI_darx = 40
global MeGUI_dary = 17
SetMemoryMax(1024)
SetMTMode(5,2)
LoadPlugin("D:\Program Files (x86)\MeGUInew\tools\dgindexnv\DGDecodeNV.dll")
DGSource("E:\MeGUI\rsxyxu0x.yip\05 You only live twice (1967).dgi",fieldop=0)
SetMTMode(5,1)
KNLMeansCL(D=2, A=1, h=1.2, device_type="GPU")
SetMTMode(2)
#deinterlace
#crop
#resize
#denoise
That script doesn't even work, it does not return a clip because "SetMTMode(2)" is the last statement.

The "SetMTMode(5,1)" is completely pointless (since you can't change the number of threads after the first call) as is "SetMTMode(2)" at the end.

I tried your script with and without MT (adding "return last" at the end to get it to work), the speed difference in AVSMeter is virtually zero. If you understood how AVS MT works or read the documentation you would know that this is the expected result.
__________________
Groucho's Avisynth Stuff
Groucho2004 is offline   Reply With Quote
Old 17th June 2015, 17:34   #162  |  Link
Khanattila
Registered User
 
Khanattila's Avatar
 
Join Date: Nov 2014
Posts: 440
Quote:
Originally Posted by Pulp Catalyst View Post
anyway.... moving forward, i'm still at a lost why

Version 0.5.1
Version 0.5.2
Version 0.5.3
Version 0.5.4

all gives me the same error, OpenCL device not found, however Version 0.5.0 works perfectly???

But i'm sure time will answer this dilemma...

anyway thank you all for your feed back, i always appreciate feedback off all kind.
Because Version 0.5.* != 0.5.0. In Version 0.5.1 I rewrote a lot of things...
Anyway I have a GTX 760, then it should work.
Khanattila is offline   Reply With Quote
Old 25th June 2015, 18:08   #163  |  Link
Khanattila
Registered User
 
Khanattila's Avatar
 
Join Date: Nov 2014
Posts: 440
>>>> KNLMeansCL_v0.5.5.zip <<<<

ChangeLog
  • v0.5.5 (2015-06-25)
    - New: AviSynth RGB32 support.

VS takes longer.
Khanattila is offline   Reply With Quote
Old 25th June 2015, 18:31   #164  |  Link
Khanattila
Registered User
 
Khanattila's Avatar
 
Join Date: Nov 2014
Posts: 440
Code:
 #RGB32
Colorbars(1920, 1080, "RGB32").KillAudio().KNLMeansCL()

#YV24
Colorbars(1920, 1080, "YV24").KillAudio()
y = KNLMeansCL()
u = UToY8().KNLMeansCL()
v = VToY8().KNLMeansCL()
YToUV(u, v, y)

#YV12
Colorbars(1920, 1080, "YV12").KillAudio()
y = KNLMeansCL()
u = UToY8().KNLMeansCL()
v = VToY8().KNLMeansCL()
YToUV(u, v, y)

#Y8
Colorbars(1920, 1080, "YV12").KillAudio()
RGB32 ----- 46.36 FPS
YV24 ------ 22.49 FPS
YV12 ------ 43.58 FPS
Y8--------- 68.98 FPS

GPU architecture. Lovable.
Khanattila is offline   Reply With Quote
Old 26th June 2015, 09:24   #165  |  Link
RazorBurn
Registered User
 
Join Date: Aug 2014
Posts: 14
Does KNLMeansCL support Temporal in Vapoursynth?

Got Error on this

Code:
clip = core.knlm.KNLMeansCL (clip = clip, d=1, a=0, h=5.4, device_type="GPU") ##KNLMeans Temporal  Medium
Code:
clip = core.knlm.KNLMeansCL (clip = clip, d=1, a=1, h=4.5, device_type="GPU") ##KNLMeans Spatio-Temporal  Medium
Yet no Error on this

Code:
clip = core.knlm.KNLMeansCL (clip = clip, d=0, a=4, h=3.6, device_type="GPU") ##KNLMeans Spatial Medium
RazorBurn is offline   Reply With Quote
Old 26th June 2015, 09:54   #166  |  Link
Khanattila
Registered User
 
Khanattila's Avatar
 
Join Date: Nov 2014
Posts: 440
Quote:
Originally Posted by RazorBurn View Post
Does KNLMeansCL support Temporal in Vapoursynth?

Got Error on this

Code:
clip = core.knlm.KNLMeansCL (clip = clip, d=1, a=0, h=5.4, device_type="GPU") ##KNLMeans Temporal  Medium
Code:
clip = core.knlm.KNLMeansCL (clip = clip, d=1, a=1, h=4.5, device_type="GPU") ##KNLMeans Spatio-Temporal  Medium
Yet no Error on this

Code:
clip = core.knlm.KNLMeansCL (clip = clip, d=0, a=4, h=3.6, device_type="GPU") ##KNLMeans Spatial Medium
I have to investigate, some more details?
Khanattila is offline   Reply With Quote
Old 26th June 2015, 11:07   #167  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,582
Latest version finding OpenCL device (Nvidia GTX 760) is 0.5.0, latest driver version on Win 8.1_x64.
__________________
@turment on Telegram
tormento is offline   Reply With Quote
Old 26th June 2015, 11:33   #168  |  Link
RazorBurn
Registered User
 
Join Date: Aug 2014
Posts: 14
Quote:
Originally Posted by Khanattila View Post
I have to investigate, some more details?
Script ==>
Code:
import vapoursynth as vs
core = vs.get_core()
core.std.LoadPlugin(r'C:\Apps\Encoders\StaxRip\Apps\Plugins\both\ffms2\ffms2.dll')
clip = core.ffms2.Source(source = r'C:\Temp\Media\SampleClip.mpg', cachefile = r'C:\Temp\Media\SampleClip temp files\SampleClip.ffindex')
clip = core.knlm.KNLMeansCL (clip = clip, d=1, a=1, h=4.5, device_type="GPU")
clip.set_output()
CMD Line ==

Code:
vspipe.exe" "C:\Temp\Media\SampleClip temp files\SampleClip.vpy" - --y4m | x264.exe --crf 22 --demuxer y4m --frames 59 --output "C:\Temp\Media\SampleClip temp files\SampleClip_out.h264" "-"
Error Log ==

Code:
Negative frame request by: Cache1
x264 [error]: could not open input file `-'
SampleClip (From NeatVideo) ==

https://www.neatvideo.com/files4/testkit.zip
RazorBurn is offline   Reply With Quote
Old 26th June 2015, 16:09   #169  |  Link
Khanattila
Registered User
 
Khanattila's Avatar
 
Join Date: Nov 2014
Posts: 440
It should fix everything.

>>>> KNLMeansCL_v0.5.6.zip <<<<

ChangeLog
  • v0.5.6 (2015-06-26)
    - Fixed: VapourSynth temporal support (regression v0.5.2)
    - Fixed: VapourSynth device_type ignored.
    - Fixed: Possible opencl device not available.

Last edited by Khanattila; 26th June 2015 at 17:59.
Khanattila is offline   Reply With Quote
Old 26th June 2015, 18:18   #170  |  Link
Monarc
Registered User
 
Join Date: Jun 2002
Posts: 35
Hi,

i tried to use your filter 0.5.6 with vapoursynth under linux.

It compiles after some small changes, but vapoursynth stops with errors.

vs script:

Code:
import vapoursynth as vs
core = vs.get_core()

file="/home/monarc/Downloads/test.mp4"
clip = core.ffms2.Source(source=file)

clip = core.knlm.KNLMeansCL (clip = clip, d=0, a=4, h=3.6, info=True)
clip.set_output()
vapoursynth error:

Code:
Failed to evaluate the script:
Python exception: knlm.KNLMeansCL: VapourSynthCreate error (1)!
Traceback (most recent call last):
  File "vapoursynth.pyx", line 1469, in vapoursynth.vpy_evaluateScript (src/cython/vapoursynth.c:23703)
  File "/home/monarc/filters/filters.vpy", line 50, in <module>
    clip = core.knlm.KNLMeansCL (clip = clip, d=0, a=4, h=3.6, info=True)
  File "vapoursynth.pyx", line 1368, in vapoursynth.Function.__call__ (src/cython/vapoursynth.c:22272)
vapoursynth.Error: knlm.KNLMeansCL: VapourSynthCreate error (1)!
KNLMeansCL.txt
Quote:
<kernel>:90:40: error: invalid digit 'f' in decimal constant
(NLMK_WMODE == 2) ? fmax(1.0f -sum * NLMK_H2_INV_NORM, 0.0f) * fmax(1.0f -sum * NLMK_H2_INV_NORM, 0.0f) :
^
<built-in>:31:35: note: expanded from here
#define NLMK_H2_INV_NORM 61,942730f
^
<kernel>:90:83: error: invalid digit 'f' in decimal constant
(NLMK_WMODE == 2) ? fmax(1.0f -sum * NLMK_H2_INV_NORM, 0.0f) * fmax(1.0f -sum * NLMK_H2_INV_NORM, 0.0f) :
^
<built-in>:31:35: note: expanded from here
#define NLMK_H2_INV_NORM 61,942730f
^
<kernel>:91:41: error: invalid digit 'f' in decimal constant
(NLMK_WMODE == 1) ? native_exp(-sum * NLMK_H2_INV_NORM) :
^
<built-in>:31:35: note: expanded from here
#define NLMK_H2_INV_NORM 61,942730f
^
<kernel>:92:29: error: invalid digit 'f' in decimal constant
native_recip(1.0f + sum * NLMK_H2_INV_NORM);
^
<built-in>:31:35: note: expanded from here
#define NLMK_H2_INV_NORM 61,942730f
^
^@^@
I am not sure, if this is even possible with my card:

Code:
clinfo --help
Number of platforms:                             1
  Platform Profile:                              FULL_PROFILE
  Platform Version:                              OpenCL 1.2 CUDA 7.5.9
  Platform Name:                                 NVIDIA CUDA
  Platform Vendor:                               NVIDIA Corporation
  Platform Extensions:                           cl_khr_byte_addressable_store cl_khr_icd cl_khr_gl_sharing cl_nv_compiler_options cl_nv_device_attribute_query cl_nv_pragma_unroll cl_nv_copy_opts 


  Platform Name:                                 NVIDIA CUDA                                                                                                                                  
Number of devices:                               1                                                                                                                                            
  Device Type:                                   CL_DEVICE_TYPE_GPU                                                                                                                           
  Device ID:                                     4318                                                                                                                                         
  Max compute units:                             8                                                                                                                                            
  Max work items dimensions:                     3                                                                                                                                            
    Max work items[0]:                           1024                                                                                                                                         
    Max work items[1]:                           1024                                                                                                                                         
    Max work items[2]:                           64                                                                                                                                           
  Max work group size:                           1024                                                                                                                                         
  Preferred vector width char:                   1                                                                                                                                            
  Preferred vector width short:                  1
  Preferred vector width int:                    1
  Preferred vector width long:                   1
  Preferred vector width float:                  1
  Preferred vector width double:                 1
  Native vector width char:                      1
  Native vector width short:                     1
  Native vector width int:                       1
  Native vector width long:                      1
  Native vector width float:                     1
  Native vector width double:                    1
  Max clock frequency:                           1760Mhz
  Address bits:                                  64
  Max memory allocation:                         268222464
  Image support:                                 Yes
  Max number of images read arguments:           128
  Max number of images write arguments:          8
  Max image 2D width:                            16384
  Max image 2D height:                           16384
  Max image 3D width:                            2048
  Max image 3D height:                           2048
  Max image 3D depth:                            2048
  Max samplers within kernel:                    16
  Max size of kernel argument:                   4352
  Alignment (bits) of base address:              4096
  Minimum alignment (bytes) for any datatype:    128
  Single precision floating point capability
    Denorms:                                     Yes
    Quiet NaNs:                                  Yes
    Round to nearest even:                       Yes
    Round to zero:                               Yes
    Round to +ve and infinity:                   Yes
    IEEE754-2008 fused multiply-add:             Yes
  Cache type:                                    Read/Write
  Cache line size:                               128
  Cache size:                                    131072
  Global memory size:                            1072889856
  Constant buffer size:                          65536
  Max number of constant args:                   9
  Local memory type:                             Local
  Local memory size:                             49152
  Error correction support:                      0
  Unified memory for Host and Device:            0
  Profiling timer resolution:                    1000
  Device endianess:                              Little
  Available:                                     Yes
  Compiler available:                            Yes
  Execution capabilities:                                
    Execute OpenCL kernels:                      Yes
    Execute native function:                     No
  Queue properties:                              
    Out-of-Order:                                Yes
    Profiling :                                  Yes
  Platform ID:                                   0x234f7f0
  Name:                                          GeForce GTX 560 Ti
  Vendor:                                        NVIDIA Corporation
  Device OpenCL C version:                       OpenCL C 1.1 
  Driver version:                                352.21
  Profile:                                       FULL_PROFILE
  Version:                                       OpenCL 1.1 CUDA
  Extensions:                                    cl_khr_byte_addressable_store cl_khr_icd cl_khr_gl_sharing cl_nv_compiler_options cl_nv_device_attribute_query cl_nv_pragma_unroll cl_nv_copy_opts  cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_fp64
Monarc is offline   Reply With Quote
Old 26th June 2015, 19:46   #171  |  Link
Khanattila
Registered User
 
Khanattila's Avatar
 
Join Date: Nov 2014
Posts: 440
Can you tell me what you had to change? So I implement them.
However, it is a stupid mistake. Just do not use TAB with snprintf. Or just do not break line ("\").
Code:
if (channel == CL_FLOAT) {
    snprintf(options, 2048, "-Werror -D H_BLOCK_X=%i -D H_BLOCK_Y=%i -D V_BLOCK_X=%i -D V_BLOCK_Y=%i -D NLMK_RGB=%i -D NLMK_S=%i -D NLMK_WMODE=%i -D NLMK_TEMPORAL=%i -D NLMK_H2_INV_NORM=%ff",
         H_BLOCK_X, H_BLOCK_Y, V_BLOCK_X, V_BLOCK_Y, 0, d.s, d.wmode, d.d, 65025.0 / (d.h*d.h*(2 * d.s + 1) * (2 * d.s + 1)));
} else {
    snprintf(options, 2048, "-cl-denorms-are-zero -cl-fast-relaxed-math -Werror -D H_BLOCK_X=%i -D H_BLOCK_Y=%i -D V_BLOCK_X=%i -D V_BLOCK_Y=%i -D NLMK_RGB=%i -D NLMK_S=%i -D NLMK_WMODE=%i -D NLMK_TEMPORAL=%i -D NLMK_H2_INV_NORM=%ff",
        H_BLOCK_X, H_BLOCK_Y, V_BLOCK_X, V_BLOCK_Y, 0, d.s, d.wmode, d.d, 65025.0 / (d.h*d.h*(2 * d.s + 1) * (2 * d.s + 1)));
}

Last edited by Khanattila; 26th June 2015 at 20:11.
Khanattila is offline   Reply With Quote
Old 26th June 2015, 21:18   #172  |  Link
Monarc
Registered User
 
Join Date: Jun 2002
Posts: 35
Does not change much ... maybe i do something wrong.

Even with all changes, vapoursynth error remains the same.

KNLMeansCL.txt:
Code:
<kernel>:90:40: error: invalid digit 'f' in decimal constant
                (NLMK_WMODE == 2) ? fmax(1.0f -sum * NLMK_H2_INV_NORM, 0.0f) * fmax(1.0f -sum * NLMK_H2_INV_NORM, 0.0f) :       
                                                     ^
<built-in>:31:35: note: expanded from here
#define NLMK_H2_INV_NORM 61,942730f
                                  ^
<kernel>:90:83: error: invalid digit 'f' in decimal constant
                (NLMK_WMODE == 2) ? fmax(1.0f -sum * NLMK_H2_INV_NORM, 0.0f) * fmax(1.0f -sum * NLMK_H2_INV_NORM, 0.0f) :       
                                                                                                ^
<built-in>:31:35: note: expanded from here
#define NLMK_H2_INV_NORM 61,942730f
                                  ^
<kernel>:91:41: error: invalid digit 'f' in decimal constant
                (NLMK_WMODE == 1) ? native_exp(-sum * NLMK_H2_INV_NORM) :                                                                                                       
                                                      ^
<built-in>:31:35: note: expanded from here
#define NLMK_H2_INV_NORM 61,942730f
                                  ^
<kernel>:92:29: error: invalid digit 'f' in decimal constant
                native_recip(1.0f + sum * NLMK_H2_INV_NORM);                                                                                                                            
                                          ^
<built-in>:31:35: note: expanded from here
#define NLMK_H2_INV_NORM 61,942730f
to compile under linux, i tried this line:

Code:
clang++-3.7 -o ../KNLMeansCL.so -std=c++11 -O3 -march=native -mtune=native -I/usr/local/include/vapoursynth -shared -fPIC -lOpenCL KNLMeansCL.cpp
in KNLMeansCL.h:

i wrapped #include "avisynth.h" with #ifdef _WIN32
and added #include "math.h" for ceil

in KNLMeansCL.cpp:
added a space between " Version " VERSION in line 454

Code:
diff -r -u3 KNLMeansCL/src/KNLMeansCL.cpp KNLMeansCL.patch/src/KNLMeansCL.cpp
--- KNLMeansCL/src/KNLMeansCL.cpp       2015-06-26 16:31:48.000000000 +0200
+++ KNLMeansCL.patch/src/KNLMeansCL.cpp 2015-06-26 21:37:16.362359041 +0200
@@ -324,7 +324,7 @@
                int pitch = dst->GetPitch(PLANAR_Y);
                char buffer[2048], str[2048], str1[2048];
                DrawString(frm, pitch, 0, y++, "KNLMeansCL");
-               DrawString(frm, pitch, 0, y++, " Version "VERSION);
+               DrawString(frm, pitch, 0, y++, " Version " VERSION);
                DrawString(frm, pitch, 0, y++, " Copyright(C) Khanattila");
                snprintf(buffer, 2048, " D:%i  A:%ix%i  S:%ix%i", 2 * D + 1, 2 * A + 1, 2 * A + 1, 2 * S + 1, 2 * S + 1);
                DrawString(frm, pitch, 0, y++, buffer);
@@ -451,7 +451,7 @@
                        int pitch = vsapi->getStride(dst, 0);
                        char buffer[2048], str[2048], str1[2048];
                        DrawString(frm, pitch, 0, y++, "KNLMeansCL");
-                       DrawString(frm, pitch, 0, y++, " Version "VERSION);
+                       DrawString(frm, pitch, 0, y++, " Version " VERSION);
                        DrawString(frm, pitch, 0, y++, " Copyright(C) Khanattila");
                        snprintf(buffer, 2048, " D:%i  A:%ix%i  S:%ix%i", 2 * d->d + 1, 2 * d->a + 1, 2 * d->a + 1, 2 * d->s + 1, 2 * d->s + 1);
                        DrawString(frm, pitch, 0, y++, buffer);
@@ -703,15 +703,9 @@
        d.program = clCreateProgramWithSource(d.context, 1, &source_code, NULL, NULL);
        char options[2048];
        if (channel == CL_FLOAT) {
-               snprintf(options, 2048, "-Werror \
-            -D H_BLOCK_X=%i -D H_BLOCK_Y=%i -D V_BLOCK_X=%i -D V_BLOCK_Y=%i \
-            -D NLMK_RGB=%i -D NLMK_S=%i -D NLMK_WMODE=%i -D NLMK_TEMPORAL=%i -D NLMK_H2_INV_NORM=%ff",
-                   H_BLOCK_X, H_BLOCK_Y, V_BLOCK_X, V_BLOCK_Y, 0, d.s, d.wmode, d.d, 65025.0 / (d.h*d.h*(2 * d.s + 1) * (2 * d.s + 1)));
+           snprintf(options, 2048, "-Werror -D H_BLOCK_X=%i -D H_BLOCK_Y=%i -D V_BLOCK_X=%i -D V_BLOCK_Y=%i -D NLMK_RGB=%i -D NLMK_S=%li -D NLMK_WMODE=%li -D NLMK_TEMPORAL=%li -D NLMK_H2_INV_NORM=%ff",H_BLOCK_X, H_BLOCK_Y, V_BLOCK_X, V_BLOCK_Y, 0, d.s, d.wmode, d.d, 65025.0 / (d.h*d.h*(2 * d.s + 1) * (2 * d.s + 1)));
        } else {
-               snprintf(options, 2048, "-cl-denorms-are-zero -cl-fast-relaxed-math -Werror \
-            -D H_BLOCK_X=%i -D H_BLOCK_Y=%i -D V_BLOCK_X=%i -D V_BLOCK_Y=%i \
-            -D NLMK_RGB=%i -D NLMK_S=%i -D NLMK_WMODE=%i -D NLMK_TEMPORAL=%i -D NLMK_H2_INV_NORM=%ff",
-            H_BLOCK_X, H_BLOCK_Y, V_BLOCK_X, V_BLOCK_Y, 0, d.s, d.wmode, d.d, 65025.0 / (d.h*d.h*(2 * d.s + 1) * (2 * d.s + 1)));
+           snprintf(options, 2048, "-cl-denorms-are-zero -cl-fast-relaxed-math -Werror -D H_BLOCK_X=%i -D H_BLOCK_Y=%i -D V_BLOCK_X=%i -D V_BLOCK_Y=%i -D NLMK_RGB=%i -D NLMK_S=%li -D NLMK_WMODE=%li -D NLMK_TEMPORAL=%li -D NLMK_H2_INV_NORM=%ff",H_BLOCK_X, H_BLOCK_Y, V_BLOCK_X, V_BLOCK_Y, 0, d.s, d.wmode, d.d, 65025.0 / (d.h*d.h*(2 * d.s + 1) * (2 * d.s + 1)));
        }
        ret = clBuildProgram(d.program, 1, &d.deviceID, options, NULL, NULL);
        if (ret != CL_SUCCESS) {

diff -r -u3 KNLMeansCL/src/KNLMeansCL.h KNLMeansCL.patch/src/KNLMeansCL.h
--- KNLMeansCL/src/KNLMeansCL.h 2015-06-26 16:32:42.000000000 +0200
+++ KNLMeansCL.patch/src/KNLMeansCL.h   2015-06-26 18:52:07.686612969 +0200
@@ -31,7 +31,10 @@
 #include <CL/cl.h>
 #include "kernel.h"
 #include "startchar.h"
+#ifdef _WIN32
 #include "avisynth.h"
+#endif
+#include "math.h"
 #include "VapourSynth.h"
 #include "VSHelper.h"
then it compiles (with warnings):

Code:
clang++-3.7 -ferror-limit=0 -o ../KNLMeansCL.so -std=c++11 -O3 -march=native -mtune=native -I/usr/local/include/vapoursynth -shared -fPIC -lOpenCL KNLMeansCL.cpp
KNLMeansCL.cpp:397:60: warning: implicit conversion of NULL constant to 'cl_uint' (aka 'unsigned int') [-Wnull-conversion]
                        vsapi->getStride(src, 0), 0, vsapi->getReadPtr(src, 0), NULL, NULL, NULL);
                                                                                ^~~~
                                                                                0                                                                                                             
KNLMeansCL.cpp:405:36: warning: implicit conversion of NULL constant to 'cl_uint' (aka 'unsigned int') [-Wnull-conversion]                                                                    
                                        0, vsapi->getReadPtr(src, 0), NULL, NULL, NULL);
                                                                      ^~~~
                                                                      0                                                                                                                       
KNLMeansCL.cpp:439:35: warning: implicit conversion of NULL constant to 'cl_uint' (aka 'unsigned int') [-Wnull-conversion]                                                                    
                        0, vsapi->getWritePtr(dst, 0), NULL, NULL, NULL);
                                                       ^~~~
                                                       0                                                                                                                                      
KNLMeansCL.cpp:456:54: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]                                                                                       
                        snprintf(buffer, 2048, " D:%i  A:%ix%i  S:%ix%i", 2 * d->d + 1, 2 * d->a + 1, 2 * d->a + 1, 2 * d->s + 1, 2 * d->s + 1);
                                                   ~~                     ^~~~~~~~~~~~
                                                   %li                                                                                                                                        
KNLMeansCL.cpp:456:68: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]                                                                                       
                        snprintf(buffer, 2048, " D:%i  A:%ix%i  S:%ix%i", 2 * d->d + 1, 2 * d->a + 1, 2 * d->a + 1, 2 * d->s + 1, 2 * d->s + 1);
                                                         ~~                             ^~~~~~~~~~~~
                                                         %li                                                                                                                                  
KNLMeansCL.cpp:456:82: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]                                                                                       
                        snprintf(buffer, 2048, " D:%i  A:%ix%i  S:%ix%i", 2 * d->d + 1, 2 * d->a + 1, 2 * d->a + 1, 2 * d->s + 1, 2 * d->s + 1);
                                                            ~~                                        ^~~~~~~~~~~~
                                                            %li                                                                                                                               
KNLMeansCL.cpp:456:96: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]                                                                                       
                        snprintf(buffer, 2048, " D:%i  A:%ix%i  S:%ix%i", 2 * d->d + 1, 2 * d->a + 1, 2 * d->a + 1, 2 * d->s + 1, 2 * d->s + 1);
                                                                  ~~                                                ^~~~~~~~~~~~
                                                                  %li                                                                                                                         
KNLMeansCL.cpp:456:110: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]                                                                                      
                        snprintf(buffer, 2048, " D:%i  A:%ix%i  S:%ix%i", 2 * d->d + 1, 2 * d->a + 1, 2 * d->a + 1, 2 * d->s + 1, 2 * d->s + 1);
                                                                     ~~                                                           ^~~~~~~~~~~~
                                                                     %li                                                                                                                      
KNLMeansCL.cpp:458:46: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]                                                                                       
                        snprintf(buffer, 2048, " Iterations: %i", ((2 * d->d + 1)*(2 * d->a + 1)*(2 * d->a + 1) - 1) / (d->d ? 1 : 2));
                                                             ~~   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                             %li                                                                                                                              
KNLMeansCL.cpp:460:55: warning: format specifies type 'int' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]                                                               
                        snprintf(buffer, 2048, " Global work size: %ix%i", global_work[0], global_work[1]);
                                                                   ~~      ^~~~~~~~~~~~~~
                                                                   %zu                                                                                                                        
KNLMeansCL.cpp:460:71: warning: format specifies type 'int' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]                                                               
                        snprintf(buffer, 2048, " Global work size: %ix%i", global_work[0], global_work[1]);
                                                                      ~~                   ^~~~~~~~~~~~~~
                                                                      %zu                                                                                                                     
KNLMeansCL.cpp:664:52: warning: implicit conversion of NULL constant to 'cl_uint' (aka 'unsigned int') [-Wnull-conversion]                                                                    
                ret |= clGetDeviceIDs(temp_platforms[i], device, NULL, NULL, &num_devices);
                       ~~~~~~~~~~~~~~                            ^~~~
                                                                 0                                                                                                                            
KNLMeansCL.cpp:694:16: warning: 'clCreateImage2D' is deprecated [-Wdeprecated-declarations]                                                                                                   
        d.mem_in[0] = clCreateImage2D(d.context, CL_MEM_READ_ONLY, &image_format, d.image_dimensions[0], d.image_dimensions[1], 0, NULL, NULL);
                      ^
/usr/include/CL/cl.h:1170:1: note: 'clCreateImage2D' has been explicitly marked deprecated here                                                                                               
clCreateImage2D(cl_context              /* context */,
^
KNLMeansCL.cpp:695:25: warning: 'clCreateImage2D' is deprecated [-Wdeprecated-declarations]                                                                                                   
        if (d.d) d.mem_in[1] = clCreateImage2D(d.context, CL_MEM_READ_ONLY, &image_format, d.image_dimensions[0], d.image_dimensions[1], 0, NULL, NULL);
                               ^
/usr/include/CL/cl.h:1170:1: note: 'clCreateImage2D' has been explicitly marked deprecated here                                                                                               
clCreateImage2D(cl_context              /* context */,
^
KNLMeansCL.cpp:696:14: warning: 'clCreateImage2D' is deprecated [-Wdeprecated-declarations]                                                                                                   
        d.mem_out = clCreateImage2D(d.context, CL_MEM_WRITE_ONLY, &image_format, d.image_dimensions[0], d.image_dimensions[1], 0, NULL, NULL);
                    ^
/usr/include/CL/cl.h:1170:1: note: 'clCreateImage2D' has been explicitly marked deprecated here                                                                                               
clCreateImage2D(cl_context              /* context */,
^
15 warnings generated.
Monarc is offline   Reply With Quote
Old 26th June 2015, 22:11   #173  |  Link
Khanattila
Registered User
 
Khanattila's Avatar
 
Join Date: Nov 2014
Posts: 440
Try to add "-cl-single-precision-constant" in clBuildProgram options.
And / Or change "-D NLMK_H2_INV_NORM=%ff" to "-D NLMK_H2_INV_NORM=%f".
Khanattila is offline   Reply With Quote
Old 27th June 2015, 06:15   #174  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
fast yv24
y=converttoy8 ()
u=utoy8 ()
v=vtoy8 ()
fakergb=mergergb (y,u,v).converttorgb32 ()
nlm=fakergb.knlmeanscl (xxx)
y=nlm.showred ("y8")
u=nlm.showgreen ("y8")
v=nlm.showblue ("y8")
ytouv (u,v,y)
feisty2 is offline   Reply With Quote
Old 27th June 2015, 10:08   #175  |  Link
Khanattila
Registered User
 
Khanattila's Avatar
 
Join Date: Nov 2014
Posts: 440
Quote:
Originally Posted by feisty2 View Post
fast yv24
y=converttoy8 ()
u=utoy8 ()
v=vtoy8 ()
fakergb=mergergb (y,u,v).converttorgb32 ()
nlm=fakergb.knlmeanscl (xxx)
y=nlm.showred ("y8")
u=nlm.showgreen ("y8")
v=nlm.showblue ("y8")
ytouv (u,v,y)
This however is not gamma-correct. (Even if colour perception is not exactly orthogonal...)

Example:
Red RGB(255, 0, 0) YUV(76, 84, 255)
Violet RGB(127, 0, 255) YUV(67, 234, 170)

Squared Euclidean distance between two points p(r, g, b) and q(r, g, b).

d^2(p, q) = (p.r -q.r)^2 + (p.g - q.g)^2 + (p.b - q.b)^2
d^2(p, q) = (255 - 127)^2 + (0 - 0)^2 + (0 - 255)^2
d^2(p, q) = 81409

Squared Euclidean distance between two points p(y, u, v) and q(y, u, v).

d^2(p, q) = (p.y - q.y)^2 + (p.u - q.u) ^2 + (p.v - q.u)^2
d^2(p, q) = (76 - 64)^2 + (84 - 234)^2 + (255 - 170)^2
d^2(p, q) = 29869

EDIT.
Some people suggested a weighted Euclidean distance in RGB, example:
d^2(p, q) = 3*(p.r -q.r)^2 + 4*(p.g - q.g)^2 + 2*(p.b - q.b)^2 = 179202
d^2(p, q) = 2*(p.r -q.r)^2 + 4*(p.g - q.g)^2 + 3*(p.b - q.b)^2 = 227843
Future investigations are needed.

Last edited by Khanattila; 27th June 2015 at 10:58.
Khanattila is offline   Reply With Quote
Old 27th June 2015, 12:58   #176  |  Link
Monarc
Registered User
 
Join Date: Jun 2002
Posts: 35
Code:
#define NLMK_H2_INV_NORM 61,942730f
its snprintf and my local language settings (german)

In german floats are written in plain text with a comma : e.g. 3,14
In english with point: 3.14

if i start vapoursynth with LC_ALL=C, the error is gone.
Monarc is offline   Reply With Quote
Old 27th June 2015, 13:23   #177  |  Link
Khanattila
Registered User
 
Khanattila's Avatar
 
Join Date: Nov 2014
Posts: 440
Quote:
Originally Posted by Monarc View Post
Code:
#define NLMK_H2_INV_NORM 61,942730f
its snprintf and my local language settings (german)

In german floats are written in plain text with a comma : e.g. 3,14
In english with point: 3.14

if i start vapoursynth with LC_ALL=C, the error is gone.
Easier than expected
Khanattila is offline   Reply With Quote
Old 27th June 2015, 15:24   #178  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
I want to try Dithertools to denoise with 16 bit precision. Would the following code be correct?

Code:
Dither_convert_8_to_16()

y = KNLMeansCL(D = 1, A = 1, h = 1.5, lsb_inout = true)
u = UToY8().KNLMeansCL(D = 1, A = 1, h = 1.5, lsb_inout = true)
v = VToY8().KNLMeansCL(D = 1, A = 1, h = 1.5, lsb_inout = true)
YToUV(u, v, y)

f3kdb(sample_mode = 2, keep_tv_range = true, input_mode = 1, output_mode = 1)

DitherPost()
__________________
Groucho's Avisynth Stuff
Groucho2004 is offline   Reply With Quote
Old 27th June 2015, 15:58   #179  |  Link
Khanattila
Registered User
 
Khanattila's Avatar
 
Join Date: Nov 2014
Posts: 440
Yes of course.
Khanattila is offline   Reply With Quote
Old 27th June 2015, 16:09   #180  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
Quote:
Originally Posted by Khanattila View Post
This however is not gamma-correct. (Even if colour perception is not exactly orthogonal...)

Example:
Red RGB(255, 0, 0) YUV(76, 84, 255)
Violet RGB(127, 0, 255) YUV(67, 234, 170)

Squared Euclidean distance between two points p(r, g, b) and q(r, g, b).

d^2(p, q) = (p.r -q.r)^2 + (p.g - q.g)^2 + (p.b - q.b)^2
d^2(p, q) = (255 - 127)^2 + (0 - 0)^2 + (0 - 255)^2
d^2(p, q) = 81409

Squared Euclidean distance between two points p(y, u, v) and q(y, u, v).

d^2(p, q) = (p.y - q.y)^2 + (p.u - q.u) ^2 + (p.v - q.u)^2
d^2(p, q) = (76 - 64)^2 + (84 - 234)^2 + (255 - 170)^2
d^2(p, q) = 29869

EDIT.
Some people suggested a weighted Euclidean distance in RGB, example:
d^2(p, q) = 3*(p.r -q.r)^2 + 4*(p.g - q.g)^2 + 2*(p.b - q.b)^2 = 179202
d^2(p, q) = 2*(p.r -q.r)^2 + 4*(p.g - q.g)^2 + 3*(p.b - q.b)^2 = 227843
Future investigations are needed.
guess b should have the least weight, so 3r+4g+2b kinda stuff, if the image comes from an actually camera, not CGI, blue channel will be VERY NOISY (compared to R,G), so not good to make that as a reference of the noise estimation at all
feisty2 is offline   Reply With Quote
Reply


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 00:30.


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