pinterf / KNLMeansCL

An optimized OpenCL implementation of the Non-local means de-noising algorithm
GNU General Public License v3.0
16 stars 4 forks source link

Corrupt / garbage output when image width is a multiple of 64 #6

Open JohnstonJ opened 2 months ago

JohnstonJ commented 2 months ago

If the image width is a multiple of 64, KNLMeansCL outputs garbage. Tested with the release at https://github.com/pinterf/KNLMeansCL/releases/tag/v1.1.1e using 64-bit version, on an AMD Ryzen 7 Pro 4750U with integrated Radeon graphics.

This is a simple test case:

plugin_dir = "C:\VideoProject\Software\AviSynth-plugin\"
LoadPlugin(plugin_dir + "KNLMeansCL.dll")

function test(int width) {
    input = ColorBars(width=width, height=480, pixel_type="YV24").Trim(0, 50).Subtitle(String(width), size=36).FadeOut(50).ConvertToY8()
    output = input.KNLMeansCL()
    StackVertical(input, output)
}

StackHorizontal( \
    test(8*1),  test(8*2),  test(8*3),  test(8*4),  test(8*5),  test(8*6),  test(8*7),  test(8*8),  \
    test(8*9),  test(8*10), test(8*11), test(8*12), test(8*13), test(8*14), test(8*15), test(8*16), \
    test(8*17), test(8*18), test(8*19), test(8*20), test(8*21), test(8*22), test(8*23), test(8*24), \
    test(8*25), test(8*26), test(8*27), test(8*28), test(8*29), test(8*30), test(8*31), test(8*32), \
    test(8*33), test(8*34), test(8*35), test(8*36), test(8*37), test(8*38), test(8*39), test(8*40), \
    test(8*41), test(8*42), test(8*43), test(8*44), test(8*45), test(8*46), test(8*47), test(8*48) \
)

Preview it in AvsPmod, or render it with ffmpeg -i knlbug.avs -c:v huffyuv knlbug.avi.

And here is an example output image:

image

Notice that the bottom row (filter output) is missing outputs whenever width is a multiple of 64.

In real-world videos, I've seen where the filter output gets stuck at a specific frame, and doesn't change when I move the AvsPmod slider bar. Other times, it will show total garbage, as if it was displaying uninitialized memory.

For reference, here's what ColorBars(width=720, height=480).ConvertToY8().KNLMeansCL(info=true) shows:

image

JohnstonJ commented 2 months ago

Here's another example that shows corrupt output. This is from the same test code above, except I removed the ConvertToY8 call.

image