Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange artifacts in version compiled for macOS #4

Closed
radioproektor opened this issue Aug 29, 2020 · 53 comments
Closed

Strange artifacts in version compiled for macOS #4

radioproektor opened this issue Aug 29, 2020 · 53 comments

Comments

@radioproektor
Copy link

Strange artifacts in version compiled for macOS. Please see example in this discussion posts https://forum.selur.net/showthread.php?tid=1495&pid=8759#pid8759
https://forum.selur.net/showthread.php?tid=1495&pid=8774#pid8774
No problem with Windows version.

@sekrit-twc
Copy link
Owner

What about with cpu=0?

@radioproektor
Copy link
Author

cpu=0 didn't help
# color adjustment using TimeCube clip = core.timecube.Cube(clip=clip, cube="/Applications/Hybrid.app/Contents/MacOS/TimeCubeFiles/BT709_to_BT601_PAL.cube",cpu=0)

@radioproektor
Copy link
Author

By the way, i test on macOS 10.14.6 Mojave. Could it be some incompatibility or maybe some missing OpenCl options in it?

@sekrit-twc
Copy link
Owner

Do you get these artifacts when using the no-op LUT (attached)?
identity.cube.txt

@radioproektor
Copy link
Author

Yes. I still see artifact when use identify LUT.
Some observations:

  • It is somehow always dependent of Levels range in source video.
  • I render test bars from Davinci Resolve to 10bit ProRes 422 file with and without option "retain sub black and sub white data", (Data Levels Range set to Video as usual), next i open it in Hybrid and apply Time cubes. Glitch effect looks different in these two example files.
  • There is 100% no glitch effect on monochrome ramp bars or grayscale gradient.

@sekrit-twc
Copy link
Owner

sekrit-twc commented Aug 31, 2020

What about this script?

c = core.std.BlankClip(format=vs.RGB24, color=[128,64,192])
c = core.timecube.Cube(c, cube="identity.cube")

Also, does cube work in Linux?

@radioproektor
Copy link
Author

Here are some examples with different test patterns:
Screen Shot 2020-08-31 at 4 23 09 AM
Screen Shot 2020-08-31 at 4 23 34 AM
Screen Shot 2020-08-31 at 4 23 13 AM
Screen Shot 2020-08-31 at 4 23 37 AM
Screen Shot 2020-08-31 at 4 23 01 AM
Screen Shot 2020-08-31 at 4 23 31 AM

@radioproektor
Copy link
Author

Also i noticed that 10 bit Grayscale gradient ramp show 8-bit like reduced bit depth if look very close. But no color artifacts.
Going to test your script now...

@radioproektor
Copy link
Author

please specify where to add those code lines? Should i add both of them? I am not extra advanced in vapoursynth codes.

@radioproektor
Copy link
Author

radioproektor commented Aug 31, 2020

Here is my script:

# Imports
import vapoursynth as vs
core = vs.get_core()
# loading source: /Users/shph/Desktop/Resolve 422 HQ.mov
# color sampling YUV422P10@10, matrix:709, scantyp: progressive
# luminance scale TV
# resolution: 720x576
# frame rate: 25 fps
# input color space: YUV422P10, bit depth: 10, resolution: 720x576, fps: 25
# Loading /Users/shph/Desktop/Resolve 422 HQ.mov using LWLibavSource
clip = core.lsmas.LWLibavSource(source="/Users/shph/Desktop/Resolve 422 HQ.mov", format="YUV422P10", cache=0, prefer_hw=0)
# making sure input color matrix is set as 709
clip = core.resize.Point(clip, matrix_in_s="709",range_s="limited")
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip, fpsnum=25, fpsden=1)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# adjusting color space from YUV422P10 to RGB24 for vscube
clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="709", range_s="limited")
# color adjustment using TimeCube
clip = core.timecube.Cube(clip=clip, cube="/Applications/Hybrid.app/Contents/MacOS/TimeCubeFiles/identity.cube")
# adjusting output color from: RGB24 to YUV444P10 for ProResModel (i444)
clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P10, matrix_s="709", range_s="limited")
# Output
clip.set_output()

@sekrit-twc
Copy link
Owner

please specify where to add those code lines? Should i add both of them? I am not extra advanced in vapoursynth codes.

It is a complete script. Create an empty text document add the normal VS header

import vapoursynth as vs
core = vs.get_core()

Then add the test script

c = core.std.BlankClip(format=vs.RGB24, color=[128,64,192])
c = core.timecube.Cube(c, cube="identity.cube")
c.set_output()

@radioproektor
Copy link
Author

When i open script in VS viewer i got this error:

Failed to evaluate the script:
Python exception: Cube: error reading LUT from file

Traceback (most recent call last):
File "src/cython/vapoursynth.pyx", line 2244, in vapoursynth.vpy_evaluateScript
File "src/cython/vapoursynth.pyx", line 2245, in vapoursynth.vpy_evaluateScript
File "/Users/shph/Desktop/ test.vpy", line 4, in
c = core.timecube.Cube(c, cube="identity.cube")
File "src/cython/vapoursynth.pyx", line 2069, in vapoursynth.Function.call
vapoursynth.Error: Cube: error reading LUT from file

@sekrit-twc
Copy link
Owner

Replace "identity.cube" with the full path of identity.cube.

@radioproektor
Copy link
Author

Failed to evaluate the script:
Python exception: invalid syntax ( test.vpy, line 4)

Traceback (most recent call last):
File "src/cython/vapoursynth.pyx", line 2241, in vapoursynth.vpy_evaluateScript
File "/Users/shph/Desktop/ test.vpy", line 4
c = core.timecube.Cube(c, cube= /Users/shph/Desktop/identity.cube)
^
SyntaxError: invalid syntax

@sekrit-twc
Copy link
Owner

In quotes...

@radioproektor
Copy link
Author

Screen Shot 2020-08-31 at 4 59 50 AM

@sekrit-twc
Copy link
Owner

The test script is intended to produce a purple square, so it is working. What if you use your 601_709_PAL cube?

@radioproektor
Copy link
Author

same.
Screen Shot 2020-08-31 at 5 05 51 AM

@radioproektor
Copy link
Author

I test Technical color space transfocm LUTs, 1D contrast curve only LUTs and Film emulation LUTs. The all give the same glitch.
Different type (or strength) of glitch only when change TV to data levels range.

@sekrit-twc
Copy link
Owner

sekrit-twc commented Aug 31, 2020

It sounds like the issue is unrelated to TimeCube. Maybe it is caused by one of the other lines in the original script.

EDIT: I tested the full script on Windows, except I replaced the source with BlankClip, and it works. I can't fix the issue without a way to reproduce it.

@radioproektor
Copy link
Author

Ok, got it. Hope someone somewhere may help with test on Linux or test on another macOS version.
One more small question - what is plug-in bit depth internal operation? I tested filters bit depth here https://forum.doom9.org/showthread.php?p=1922287#post1922287 and see that gradient with with TimeCube filter became look like 8bit instead of 10 bit. Is it ok like this or is it also due some glitch?

@sekrit-twc
Copy link
Owner

In the script you pasted, the input is converted to 8-bit before it reaches TimeCube:

# adjusting color space from YUV422P10 to RGB24 for vscube
clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="709", range_s="limited")
# color adjustment using TimeCube
clip = core.timecube.Cube(clip=clip, cube="/Applications/Hybrid.app/Contents/MacOS/TimeCubeFiles/identity.cube")

@radioproektor
Copy link
Author

Yep, i see. Other filters don't use that transformation. Is it a mistake in script?

@sekrit-twc
Copy link
Owner

TimeCube can work on any RGB format, not just RGB24, so it is an issue with the script generator.

@radioproektor
Copy link
Author

Ok, that make sense. I will report to Hibrid UI developer.

@radioproektor
Copy link
Author

radioproektor commented Aug 31, 2020

Ok. Some updates:

  • Script code was changed, to RGB 16 bit.
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# adjusting color space from YUV444P16 to RGB48 for vscube
clip = core.resize.Bicubic(clip=clip, format=vs.RGB48, matrix_in_s="709", range_s="limited")
# color adjustment using TimeCube
  • No more 8-bit banding on greyscale gradient.
  • Color glitch artifacts still exist but looks more "detailed" due higher bit depth.

How do you think, maybe we just need somehow in script convert limited to full range levels, before apply TimeCube and next convert range back to video/tv/limited levels?
Also maybe try to use RGB 32 bit depth?

@sekrit-twc
Copy link
Owner

sekrit-twc commented Aug 31, 2020

Do the artifacts go away if the video is full range?

EDIT: Also, in case the issue is with the source filter, have you tried using ffms2 or some other source filter?

@radioproektor
Copy link
Author

Yes. Currently when i apply limited to full (TV to PC) range convert filter before TimeCube artifact is 100% gone.

In older script version when filter was operated in 8 bit depth and i apply limited to full (TV to PC) range convert filter before TimeCube, artifact was almost gone (some glitch dots where still visible). Probably it was due not enough bit and not too precise range transform.

@sekrit-twc
Copy link
Owner

Please try the latest commit, which may solve the limited range issue.

@radioproektor
Copy link
Author

Same artifacts with latest commit. Let's wait till tomorrow, maybe Selur will change script or something...

@radioproektor
Copy link
Author

radioproektor commented Aug 31, 2020

Also seems like ColorMatrix filter somehow conflicts with RangeConversion filter.

If i apply: 
ColorMatrix 601 to 709
RangeConversion filter limited to full (TV to PC)
Time Cube
---
artifacts are visible again.

If i apply: 
RangeConversion filter limited to full (TV to PC)
Time Cube
---
no artifacts

@radioproektor
Copy link
Author

radioproektor commented Aug 31, 2020

Here is current script with applied color range filter when artifacts disappear.
I was thinking here, maybe we should use 32 float for this filter instead of RGB48? 32 float usually helps when need to bring back negative (clipped) data.

# Imports
import vapoursynth as vs
core = vs.get_core()
# loading source: /Users/shph/Desktop/Kramer test patterm 02 [ProRes422HQ].mov
# color sampling YUV422P10@10, matrix:470bg, scantyp: top field first
# luminance scale TV
# resolution: 720x576
# frame rate: 25 fps
# input color space: YUV422P10, bit depth: 10, resolution: 720x576, fps: 25
# Loading /Users/shph/Desktop/Kramer test patterm 02 [ProRes422HQ].mov using LWLibavSource
clip = core.lsmas.LWLibavSource(source="/Users/shph/Desktop/Kramer test patterm 02 [ProRes422HQ].mov", format="YUV422P10", cache=0, prefer_hw=0)
# making sure input color matrix is set as 470bg
clip = core.resize.Point(clip, matrix_in_s="470bg",range_s="limited")
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip, fpsnum=25, fpsden=1)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
clip = core.resize.Point(clip, range_in_s="limited", range_s="full")
# Setting color range to PC (full) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=0)
# converting interlaced to progressive
clip = core.std.SeparateFields(clip)
clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=0)
# adjusting color space from YUV422P10 to RGB48 for vscube
clip = core.resize.Bicubic(clip=clip, format=vs.RGB48, matrix_in_s="470bg", range_s="full")
# color adjustment using TimeCube
clip = core.timecube.Cube(clip=clip, cube="/Applications/Hybrid.app/Contents/MacOS/TimeCubeFiles/identity.cube")
# converting progressive to interlaced
clip = core.std.DoubleWeave(clip)
clip = core.std.SelectEvery(clip , 2, 0)
clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=2)
# adjusting output color from: RGB48 to YUV422P10 for ProResModel (i422)
clip = core.resize.Bicubic(clip=clip, format=vs.YUV422P10, matrix_s="470bg", range_s="full")
# Output
clip.set_output()

@radioproektor
Copy link
Author

Examples with and without RangeConversion filter limited to full (TV to PC) applied before TimeCube identify.cube
tempPreviewVapoursynthFile03_46_52_046 vpy - 1084
tempPreviewVapoursynthFile03_45_19_612 vpy - 1084

@sekrit-twc
Copy link
Owner

Please share the source image.

@radioproektor
Copy link
Author

radioproektor commented Sep 1, 2020

It is ProRes video file. But it was transcoded from highly compressed MPEG1 source, so there are just compression blocks amplified by TimeCube artifact. Any compressed image or video will look like this.

@radioproektor
Copy link
Author

Maybe try these example videos https://www.dropbox.com/sh/bak63hnr7mnpgbj/AAAf-rMK0LvHYTAFjPuQaaxFa?dl=0 I rendered same test patters with and without sub blacks and superwhites data in ProRes422HQ. If you want i can put video with compression blocks to same folder.

@radioproektor
Copy link
Author

Those artifacts looks pretty cool and artistic on high compressed source videos. Love to see a separate glitch filter with same effect :)

@sekrit-twc
Copy link
Owner

sekrit-twc commented Sep 1, 2020

I reproduced the corrupted image https://user-images.githubusercontent.com/35053925/91674740-98ac0280-eb42-11ea-824b-227d28f756da.jpg on commit d3982b2 and confirmed that it was fixed by a4cde0e. The issue is caused by incorrect handling of superwhite/black. Please do a clean build and try again.

@radioproektor
Copy link
Author

radioproektor commented Sep 1, 2020

Yep, i use eversion a4cde0e it is named vscube now. Old and new compiled versions shared here https://www.mediafire.com/folder/wvdlnjapm1vvw#8amumhhefmoiy but i still see problem in Hybrid UI. Can you share you script to run in VS viewer without Hybrid UI? Just to make sure if problem still exists (or don't) with same basic script? I'll just change paths to to source file and to lut in script.

@sekrit-twc
Copy link
Owner

I used this script:

import vapoursynth as vs

core = vs.core

core.std.LoadPlugin(r"vscube.dll")
core.std.LoadPlugin(r"ffms2.dll")

c = core.ffms2.Source("Test Patterns Resolve 422 HQ (retain sub black and super white).mov")
c = core.resize.Bicubic(c, format=vs.RGB24, range_in_s="limited", range_s="limited")
c = core.timecube.Cube(c, "identity.cube")
c.set_output()

@radioproektor
Copy link
Author

Ok, so i edited names, parts and changed c, to clip, to match macOS script, and also removed paths to filters because they are autoloaded here. And problem still exists... Very strange....

Screen Shot 2020-09-01 at 6 33 58 AM

@radioproektor
Copy link
Author

It looks normal only if i use
clip = core.resize.Bicubic(clip, format=vs.RGB48, range_in_s="limited", range_s="full")
Screen Shot 2020-09-01 at 6 48 12 AM

@radioproektor
Copy link
Author

Or if i remove range code at all
Screen Shot 2020-09-01 at 6 52 24 AM

@radioproektor
Copy link
Author

radioproektor commented Sep 1, 2020

Some concept idea: Maybe it is somehow related to Windows vs macOS system default "range" representation? TimeCube or Vapoursynth itself somehow passes image through some default color system that uses TV range on one OS, but PC range on other OS. As a result with same settings problem reproduced only on one system.

@radioproektor
Copy link
Author

Also if i just use clip = core.resize.Bicubic(clip, format=vs.RGB48) - There is no conflict with ColorMatrix filter. I can do 601 to 709 correction and have no any additional artifacts.

@sekrit-twc
Copy link
Owner

Please clear out your autoload folder and explicitly load the plugins to rule out the possibility of old builds. There is no difference between OSes on color range, besides which, the resize.Bicubic line explicitly sets the range flag.

@radioproektor
Copy link
Author

Artifact is still there.

  • I done deep search (including system folders, hidden folders and package contents) and there is no libtimecube.dylib on system. Only libvscube.dylib installed and loaded.
  • To make sure there is no any cashed or loaded plugins i uninstalled Vapoursynth and all pugins, restarted computer and install Vapoursynth and all pugins again.
  • I run basic code in VS viewer.
import vapoursynth as vs

core = vs.get_core()

clip = core.ffms2.Source('/Users/shph/Desktop/Test Patterns Resolve 422 HQ.mov')
clip = core.resize.Bicubic(clip, format=vs.RGB48, range_in_s="limited", range_s="limited")
clip = core.timecube.Cube(clip, "/Users/shph/Desktop/identity.cube")
clip.set_output()

@radioproektor
Copy link
Author

radioproektor commented Sep 1, 2020

There is no artifact if i use change code line to:
clip = core.resize.Bicubic(clip, format=vs.RGB48)
or to:
clip = core.resize.Bicubic(clip, format=vs.RGB48, range_in_s="limited", range_s="full")
or to:
clip = core.resize.Bicubic(clip, format=vs.RGB48, range_in_s="full", range_s="full")

@sekrit-twc
Copy link
Owner

Please use manual plugin load, not autoload.

@radioproektor
Copy link
Author

Same problem with plug-in loaded manually directly from desktop:
Screen Shot 2020-09-01 at 7 06 17 PM

@radioproektor
Copy link
Author

Just curious what is the benefit to use limited data range for this filter in script? What is the real life purpose to transform input to range_in_s="limited", range_s="limited" for this plug-in? .cube LUTs works with images as well as with video so they are natively operate in RGB and in full range.

@sekrit-twc
Copy link
Owner

The CUBE always operates on full range (actually 0-1 floats) internally. The issue is with converting limited-range inputs when they contain WTW/BTB information. I looked at it again and realized that the fix was incomplete. Please try commit cb4227b

@radioproektor
Copy link
Author

Great! Problem fixed!
Screen Shot 2020-09-01 at 10 57 41 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants